lxf 1 year ago
parent
commit
1eb5780ec9
2 changed files with 287 additions and 1 deletions
  1. 37 1
      src/utils/util.js
  2. 250 0
      src/views/production/schedule/production-work-order/index.vue

+ 37 - 1
src/utils/util.js

@@ -442,7 +442,7 @@ export function downloadFile(fileStream, fileName) {
   URL.revokeObjectURL(url);
 }
 
-// 深冻结 
+// 深冻结
 export function deepFreeze(obj) {
   // 获取所有属性
   var propNames = Object.getOwnPropertyNames(obj);
@@ -457,3 +457,39 @@ export function deepFreeze(obj) {
   // 冻结自身
   return Object.freeze(obj);
 }
+
+// 日期格式化
+export function dateFormat(date, format) {
+  format = format || "yyyy-MM-dd hh:mm:ss";
+  if (date !== "Invalid Date") {
+    let o = {
+      "M+": date.getMonth() + 1, //month
+      "d+": date.getDate(), //day
+      "h+": date.getHours(), //hour
+      "m+": date.getMinutes(), //minute
+      "s+": date.getSeconds(), //second
+      "q+": Math.floor((date.getMonth() + 3) / 3), //quarter
+      S: date.getMilliseconds(), //millisecond
+    };
+    if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
+    for (let k in o)
+      if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
+    return format;
+  }
+  return "";
+}
+
+// 获取近几天日期
+export function getNearDays(num) {
+  // 如果包括今天,如需获取当前日期的近7天,days应该为6
+  let oneDay = 24 * 60 * 60 * 1000;
+  let beginTime = new Date(Date.now() - num * oneDay); //当前时间为结束时间
+  beginTime = dateFormat(beginTime, "yyyy-MM-dd");
+  let endTime = new Date(Date.now() + num * oneDay);
+  endTime = dateFormat(endTime, "yyyy-MM-dd");
+  const days = {
+    beginTime,
+    endTime,
+  };
+  return days;
+}

+ 250 - 0
src/views/production/schedule/production-work-order/index.vue

@@ -0,0 +1,250 @@
+<template>
+  <el-card class="box-card">
+    <byTable
+      :source="sourceList.data"
+      :pagination="sourceList.pagination"
+      :config="config"
+      :loading="loading"
+      :searchConfig="searchConfig"
+      highlight-current-row
+      @get-list="getList"
+      @clickReset="clickReset"
+      @changeRadioGroup="changeRadioGroup">
+      <template #code="{ item }">
+        <div>
+          <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickCode(item)">{{ item.code }}</a>
+        </div>
+      </template>
+      <template #address="{ item }">
+        <div>{{ item.province }}, {{ item.city }}, {{ item.county }}, {{ item.detailedAddress }}</div>
+      </template>
+    </byTable>
+  </el-card>
+</template>
+
+<script setup>
+import byTable from "/src/components/byTable/index";
+import { getNearDays } from "/src/utils/util";
+
+const { proxy } = getCurrentInstance();
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 0,
+    pageNum: 1,
+    pageSize: 10,
+    orderCode: "",
+    orderWlnCode: "",
+    skuSpecCode: "",
+    skuSpecName: "",
+    bomSpecCode: "",
+    bomSpecName: "",
+    productionWorkOrderCode: "",
+    beginTime: "",
+    endTime: "",
+    type: 3,
+  },
+});
+const loading = ref(false);
+const searchConfig = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "orderCode",
+      label: "订单号",
+    },
+    {
+      type: "input",
+      prop: "orderWlnCode",
+      label: "万里牛单号",
+    },
+    {
+      type: "input",
+      prop: "skuSpecCode",
+      label: "SKU品号",
+    },
+    {
+      type: "input",
+      prop: "skuSpecName",
+      label: "SKU品名",
+    },
+    {
+      type: "input",
+      prop: "bomSpecCode",
+      label: "BOM品号",
+    },
+    {
+      type: "input",
+      prop: "bomSpecName",
+      label: "BOM品名",
+    },
+    {
+      type: "input",
+      prop: "productionWorkOrderCode",
+      label: "工单号",
+    },
+    {
+      type: "radio-group",
+      prop: "type",
+      label: "交期",
+      data: [
+        {
+          dictKey: 1,
+          dictValue: "近3天",
+        },
+        {
+          dictKey: 3,
+          dictValue: "近7天",
+        },
+        {
+          dictKey: 15,
+          dictValue: "近31天",
+        },
+      ],
+    },
+    {
+      type: "date",
+      propList: ["beginTime", "endTime"],
+      label: "日期",
+    },
+  ];
+});
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "订单号",
+        prop: "orderCode",
+        width: 180,
+      },
+    },
+    {
+      attrs: {
+        label: "万里牛单号",
+        prop: "orderWlnCode",
+        width: 150,
+      },
+    },
+    {
+      attrs: {
+        label: "SKU品号",
+        prop: "skuSpecCode",
+        width: 140,
+      },
+    },
+    {
+      attrs: {
+        label: "SKU品名",
+        prop: "skuSpecName",
+        'min-width': 220,
+      },
+    },
+    {
+      attrs: {
+        label: "BOM品号",
+        prop: "bomSpecCode",
+        width: 140,
+      },
+    },
+    {
+      attrs: {
+        label: "BOM品名",
+        prop: "bomSpecName",
+        'min-width': 280,
+      },
+    },
+    {
+      attrs: {
+        label: "生产状态",
+        prop: "status",
+        width: 100,
+      },
+      render(val) {
+        if (val == 0) {
+          return "待投产";
+        }
+      },
+    },
+    // {
+    //   attrs: {
+    //     label: "工艺路线",
+    //     prop: "departmentName",
+    //     width: 120,
+    //   },
+    // },
+    // {
+    //   attrs: {
+    //     label: "投产时间",
+    //     prop: "departmentName",
+    //     width: 160,
+    //     align: "center",
+    //     fixed: "right",
+    //   },
+    // },
+    {
+      attrs: {
+        label: "完成时间",
+        prop: "completeTime",
+        width: 160,
+        align: "center",
+        fixed: "right",
+      },
+    },
+    // {
+    //   attrs: {
+    //     label: "生产用时",
+    //     prop: "departmentName",
+    //     width: 160,
+    //     align: "center",
+    //     fixed: "right",
+    //   },
+    // },
+  ];
+});
+const getList = async (req, status) => {
+  if (status) {
+    sourceList.value.pagination = {
+      pageNum: sourceList.value.pagination.pageNum,
+      pageSize: sourceList.value.pagination.pageSize,
+      type: 3,
+      beginTime: getNearDays(3).beginTime,
+      endTime: getNearDays(3).endTime,
+    };
+  } else {
+    sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  }
+  loading.value = true;
+  proxy.post("/productionWorkOrder/page", sourceList.value.pagination).then((res) => {
+    sourceList.value.data = res.rows;
+    sourceList.value.pagination.total = res.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
+getList({ beginTime: getNearDays(3).beginTime, endTime: getNearDays(3).endTime });
+const clickReset = () => {
+  getList("", true);
+};
+const changeRadioGroup = () => {
+  getList({ beginTime: getNearDays(sourceList.value.pagination.type).beginTime, endTime: getNearDays(sourceList.value.pagination.type).endTime });
+};
+const clickCode = (row) => {
+  proxy.$router.replace({
+    path: "/addOrder",
+    query: {
+      detailId: row.id,
+      text: "订单详情",
+      random: proxy.random(),
+      orderInquiry: true,
+    },
+  });
+};
+</script>
+
+<style lang="scss" scoped>
+:deep(.el-dialog) {
+  margin-top: 10px !important;
+  margin-bottom: 10px !important;
+}
+</style>