Переглянути джерело

采购需求单-重构需求窗口期

002390 1 рік тому
батько
коміт
eb35794315

+ 2 - 0
src/views/purchase/PurchaseDemandList/columns.js

@@ -189,5 +189,7 @@ export default function useColumns() {
     },
   ];
 
+
+
   return { TableColumns, SearchColumns }
 }

+ 53 - 0
src/views/purchase/PurchaseDemandList/demand/columns.js

@@ -0,0 +1,53 @@
+export default function useColumns() {
+  const DemandColumns = [
+    {
+      item: {
+        key: "ways",
+        title: "方案",
+      },
+      attr: {
+        is: "el-select",
+        dictName: "sys_plan_type",
+        disabled: true,
+      }
+    },
+    {
+      item: {
+        key: "category",
+        title: "类型",
+      },
+      attr: {
+        is: "el-select",
+        dictName: "sys_plan_type",
+        disabled: true,
+      }
+    },
+    {
+      item: {
+        key: "deadline",
+        title: "截止星期",
+      },
+      attr: {
+        is: "el-input-number",
+        clearable: true,
+        min: 1,
+        max: (prop) => {
+          let { ways } = prop;
+          return ways === 'ZJH' ? 7 : 12
+        },
+      }
+    },
+    {
+      item: {
+        key: "remark",
+        title: "备注",
+      },
+      attr: {
+        is: "el-input",
+        clearable: true,
+      }
+    },
+  ];
+
+  return { DemandColumns }
+}

+ 109 - 0
src/views/purchase/PurchaseDemandList/demand/index.vue

@@ -0,0 +1,109 @@
+<script>
+import useColumns from "./columns";
+import {
+  getDemandWindowList,
+  saveDemandWindow,
+} from "@/api/purchase/purchaseDemand.js";
+export default {
+  name: "Demand",
+  props: {
+    dict: {
+      type: [Array, Object],
+      default: () => [],
+    },
+  },
+  components: {
+    ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
+  },
+  data() {
+    const { DemandColumns } = useColumns();
+    return {
+      title: "需求窗口期",
+      visible: false,
+      loading: false,
+      DemandColumns: DemandColumns,
+      innerValue: [],
+    };
+  },
+  methods: {
+    async open() {
+      // 需求窗口期配置
+      this.visible = true;
+      try {
+        this.loading = true;
+        let { code, rows } = await getDemandWindowList();
+        if (code === 200) {
+          this.innerValue = rows;
+        }
+      } catch (error) {
+      } finally {
+        this.loading = false;
+      }
+    },
+    close() {
+      this.visible = false;
+      this.innerValue = [];
+    },
+
+    async saveDemand() {
+      try {
+        let params = this.innerValue;
+        let { code } = await saveDemandWindow(params);
+        if (code === 200) {
+          this.$modal.notifySuccess("保存成功");
+          this.close();
+        }
+      } catch (error) {}
+    },
+
+    changeDeadline(row) {
+      row.delFlag = "2";
+    },
+  },
+  created() {},
+};
+</script>
+
+<template>
+  <el-button type="primary" :size="$attrs.size" @click="open">
+    {{ title }}
+
+    <el-dialog
+      :title="title"
+      :visible.sync="visible"
+      width="800px"
+      append-to-body
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+    >
+      <div slot="footer">
+        <el-button :size="$attrs.size" @click="close">取 消</el-button>
+        <el-button type="primary" :size="$attrs.size" @click="saveDemand"
+          >保 存</el-button
+        >
+      </div>
+
+      <el-super-ux-table
+        v-loading="loading"
+        v-model="innerValue"
+        :columns="DemandColumns"
+        :size="$attrs.size"
+        :dict="dict"
+        height="450"
+      >
+        <template slot="deadline" slot-scope="scope">
+          <component
+            v-bind="scope.attr"
+            v-model="scope.row[scope.item.key]"
+            :size="$attrs.size"
+            :source.sync="scope.row"
+            :max="scope.attr.max(scope.row)"
+            @input="changeDeadline(scope.row)"
+          >
+          </component>
+        </template>
+      </el-super-ux-table>
+      <!-- <span style="color: red">注:周计划星期填写范围1-7,月计划填写范围1-12</span> -->
+    </el-dialog>
+  </el-button>
+</template>

+ 34 - 33
src/views/purchase/PurchaseDemandList/index.vue

@@ -12,9 +12,10 @@
         ></el-super-search>
 
         <div class="btn_grooup">
-          <el-button type="primary" :size="size" @click="demandWindow"
+          <!-- <el-button type="primary" :size="size" @click="demandWindow"
             >需求窗口期</el-button
-          >
+          > -->
+          <DemandButton :size="size" :dict="dict"></DemandButton>
           <el-button type="primary" :size="size" @click="addDivision"
             >新增</el-button
           >
@@ -250,7 +251,7 @@
     </el-dialog>
 
     <!-- 需求窗口期 -->
-    <el-dialog title="需求窗口期" :visible.sync="setDemand.open" width="800px">
+    <!-- <el-dialog title="需求窗口期" :visible.sync="setDemand.open" width="800px">
       <div slot="footer">
         <el-button :size="size" @click="setDemand.open = false"
           >取 消</el-button
@@ -308,8 +309,7 @@
           </template>
         </el-table-column>
       </el-table>
-      <!-- <span style="color: red">注:周计划星期填写范围1-7,月计划填写范围1-12</span> -->
-    </el-dialog>
+    </el-dialog> -->
 
     <Add
       v-model="isList"
@@ -340,8 +340,8 @@ import {
   exportDemand,
   submitDemand,
   confirmSubmit,
-  getDemandWindowList,
-  saveDemandWindow,
+  // getDemandWindowList,
+  // saveDemandWindow,
 } from "@/api/purchase/purchaseDemand.js";
 export default {
   name: "PurchaseDemandList",
@@ -352,6 +352,7 @@ export default {
     ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
     BatchImport: () => import("@/components/BatchImport/index.vue"),
     ElSuperSearch: () => import("@/components/super-search/index.vue"),
+    DemandButton: () => import("./demand/index.vue"),
   },
   dicts: [
     ...dicts,
@@ -424,10 +425,10 @@ export default {
       rowDetail: {},
       disable: false,
       ids: [],
-      setDemand: {
-        open: false,
-        gridData: [],
-      },
+      // setDemand: {
+      //   open: false,
+      //   gridData: [],
+      // },
     };
   },
   created() {
@@ -797,28 +798,28 @@ export default {
       this.download.category = selection.code;
     },
     // 需求窗口期配置
-    demandWindow() {
-      this.setDemand.open = true;
-      this.$nextTick(() => {
-        getDemandWindowList().then((res) => {
-          if (res.code === 200) {
-            this.setDemand.gridData = res.rows;
-          }
-        });
-      });
-    },
-    saveDemand() {
-      let params = this.setDemand.gridData;
-      saveDemandWindow(params).then((res) => {
-        if (res.code === 200) {
-          this.$modal.notifySuccess("保存成功");
-          this.setDemand.open = false;
-        }
-      });
-    },
-    changeDeadline(row) {
-      row.delFlag = "2";
-    },
+    // demandWindow() {
+    //   this.setDemand.open = true;
+    //   this.$nextTick(() => {
+    //     getDemandWindowList().then((res) => {
+    //       if (res.code === 200) {
+    //         this.setDemand.gridData = res.rows;
+    //       }
+    //     });
+    //   });
+    // },
+    // saveDemand() {
+    //   let params = this.setDemand.gridData;
+    //   saveDemandWindow(params).then((res) => {
+    //     if (res.code === 200) {
+    //       this.$modal.notifySuccess("保存成功");
+    //       this.setDemand.open = false;
+    //     }
+    //   });
+    // },
+    // changeDeadline(row) {
+    //   row.delFlag = "2";
+    // },
   },
 };
 </script>