123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <template>
- <div style="padding-bottom: 60px">
- <van-nav-bar :title="'报工明细'" left-text="" left-arrow @click-left="onClickLeft" @click-right="handleScanCode">
- <!-- <template #right> 扫码 </template> -->
- </van-nav-bar>
- <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
- <!-- <van-button @click="handleSend">发送</van-button> -->
- <van-pull-refresh v-model="loading" @refresh="onRefresh">
- <div class="list">
- <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
- <commonList :data="listData" :config="listConfig" :showMore="false">
- <template #btn="{ row }">
- <div style="width:100%;text-align:right">
- <van-button type="danger" size="small" style="margin-right:10px" @click="toDelete(row)">删除</van-button>
- </div>
- </template>
- </commonList>
- </van-list>
- </div>
- </van-pull-refresh>
- <!-- <div style="padding:20px">
- <van-button type="success" style="width:100%;height:200px;font-size:36px" @click="handleScanCode">扫码</van-button>
- </div> -->
- </div>
- </template>
- <script setup>
- import { ref, getCurrentInstance, onMounted, nextTick } from "vue";
- import commonList from "@/components/common-list.vue";
- import { useRoute } from "vue-router";
- import { showSuccessToast, showConfirmDialog } from "vant";
- const loading = ref(false);
- const route = useRoute();
- const req = ref({
- pageNum: 1,
- keyword: null,
- userId: "",
- dataDate: "",
- });
- const finished = ref(false);
- const proxy = getCurrentInstance().proxy;
- const listData = ref([]);
- const listConfig = ref([
- {
- label: "任务编号",
- prop: "orderCode",
- },
- {
- label: "报工数量",
- prop: "quantity",
- },
- {
- label: "单价",
- prop: "price",
- },
- {
- label: "小计",
- prop: "amount",
- },
- {
- label: "报工人",
- prop: "userName",
- },
- {
- label: "报工时间",
- prop: "createTime",
- },
- {
- label: "工序名称",
- prop: "processesName",
- },
- {
- label: "订单号",
- prop: "orderCode",
- },
- {
- label: "产品编码",
- prop: "productCode",
- },
- {
- label: "产品名称",
- prop: "productName",
- },
- {
- type: "slot",
- label: "",
- slotName: "btn",
- },
- ]);
- const onRefresh = () => {
- req.value.pageNum = 1;
- finished.value = false;
- getList("refresh");
- };
- if (route.query && route.query.userId) {
- req.value.userId = route.query.userId;
- req.value.dataDate = route.query.dataDate;
- }
- const onLoad = () => {
- getList();
- };
- const onClickLeft = () => history.back();
- const onClickRight = () => {
- proxy.$router.push("/main/taskAdd");
- };
- proxy.uploadDdRightBtn(onClickRight, proxy.t("common.add"));
- // const toDtl = (row) => {
- // proxy.$router.push({
- // path: "taskDtl",
- // query: {
- // id: row.id,
- // },
- // });
- // };
- const getList = (type) => {
- loading.value = true;
- proxy
- .post("/productionReporting/page", req.value)
- .then((res) => {
- // const data = res.data.rows.map((x) => ({
- // ...x,
- // time: x.startDate + " ~ " + x.stopDate,
- // statusName:
- // x.status == 0
- // ? "未开始"
- // : x.status == 1
- // ? "进行中"
- // : x.status == 2
- // ? "完成"
- // : "",
- // }));
- // if (type === "refresh") {
- // listData.value = data;
- // } else {
- // listData.value = listData.value.concat(data);
- // }
- listData.value =
- type === "refresh"
- ? res.data.rows
- : listData.value.concat(res.data.rows);
- if (req.value.pageNum * 10 >= res.data.total) {
- finished.value = true;
- }
- req.value.pageNum++;
- loading.value = false;
- })
- .catch((err) => {
- loading.value = false;
- });
- };
- getList();
- const handleScanCode = () => {
- // proxy.$router.push({
- // path: "/main/productionReportAdd",
- // query: {
- // id: "contract_flow",
- // },
- // });
- uni.postMessage({
- data: {
- type: "scanCode",
- },
- });
- };
- // const showScanData = (val) => {
- // proxy.post("/productionTaskDetail/snInfo", { productSn: val }).then((res) => {
- // if (res.data && res.data.productId) {
- // formData.data.productId = res.data.productId;
- // formData.data.productSn = res.data.productSn;
- // formData.data.code = res.data.contractCode;
- // formData.data.productName = res.data.productName;
- // formData.data.productSpec = res.data.productSpec;
- // formData.data.customerName = res.data.customerName;
- // }
- // });
- // };
- // onMounted(() => {
- // nextTick(() => {
- // window.getVueMessage = (data) => {
- // if (data) {
- // showScanData(data);
- // }
- // };
- // });
- // });
- const handleSend = () => {
- // uni.postMessage({
- // data: {
- // type: "push",
- // content: "推送测试",
- // },
- // });
- setInterval(() => {
- uni.postMessage({
- data: {
- type: "message",
- count: 10,
- },
- });
- }, 1000 * 10);
- };
- const toDelete = (row) => {
- showConfirmDialog({
- title: "提示",
- message: `您确定删除该数据吗?`,
- })
- .then(() => {
- proxy
- .post("/productionReporting/delete", {
- id: row.id,
- })
- .then((res) => {
- showSuccessToast("操作成功");
- onRefresh();
- });
- })
- .catch(() => {
- return;
- });
- };
- </script>
- <style lang="scss" scoped>
- .list {
- min-height: 70vh;
- }
- </style>
|