Forráskód Böngészése

lizhuo submits AnnualSaleGoal at 2023-7-21 17:00

002637 1 éve
szülő
commit
18210d0b23

+ 86 - 31
src/views/business/spd/goal_management/MonthGoalMerge.vue

@@ -191,7 +191,7 @@
 
     <!-- 添加或修改月销售目标合并抽屉 -->
     <el-drawer :title="title" :visible.sync="open" direction="rtl" :before-close="handleClose" size="100%">
-      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
         <el-row :gutter="20">
           <el-col :span="6">
             <el-form-item label="编码" prop="code">
@@ -289,14 +289,14 @@
             </el-form-item>
             <el-form-item v-if="form.goalCategory === '一级分类'" label="一级分类" prop="oneLevelClassify">
               <el-select v-model="form.oneLevelClassify" size="mini" clearable
-                         @focus="chooseTreeReferForQuery('MATERIALCLASSIFY_PARAM', false, '一级物料分类')"
+                         @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '一级物料分类')"
                          style="width: 200px">
                 <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
               </el-select>
             </el-form-item>
             <el-form-item v-if="form.goalCategory === '二级分类'" label="二级分类" prop="custom">
               <el-select v-model="form.twoLevelClassify" size="mini" clearable
-                         @focus="chooseTreeReferForQuery('MATERIALCLASSIFY_PARAM', false, '二级物料分类')"
+                         @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '二级物料分类')"
                          style="width: 200px">
                 <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
               </el-select>
@@ -371,12 +371,20 @@
         </el-table-column>
         <el-table-column label="一级分类" align="center" prop="oneLevelClassify" width="180">
           <template slot-scope="scope">
-            <el-input v-model="monthGoalMergeDetailsList[scope.$index].oneLevelClassify" disabled></el-input>
+            <el-select v-model="monthGoalMergeDetailsList[scope.$index].oneLevelClassify" size="mini" clearable
+                       @focus="chooseTreeReferForDetails('MATERIALCLASSIFY_PARAM', false, '一级物料分类', scope.$index)"
+                       style="width: 200px">
+              <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
+            </el-select>
           </template>
         </el-table-column>
         <el-table-column label="二级分类" align="center" prop="twoLevelClassify" width="180">
           <template slot-scope="scope">
-            <el-input v-model="monthGoalMergeDetailsList[scope.$index].twoLevelClassify" disabled></el-input>
+            <el-select v-model="monthGoalMergeDetailsList[scope.$index].twoLevelClassify" size="mini" clearable
+                       @focus="chooseTreeReferForDetails('MATERIALCLASSIFY_PARAM', false, '二级物料分类', scope.$index)"
+                       style="width: 200px">
+              <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
+            </el-select>
           </template>
         </el-table-column>
         <el-table-column label="物料" align="center" prop="material" width="180">
@@ -420,6 +428,7 @@
     </el-drawer>
 
     <TreeRefers ref="treeQuery" @doSubmit="selectionsToInputForQuery" :single="true"/>
+    <TreeRefers ref="treeMain" @doSubmit="selectionsToInputForMain" :single="true"/>
     <TreeRefers ref="treeDetails" @doSubmit="selectionsToInputForDetails" :single="true"/>
   </div>
 </template>
@@ -432,6 +441,10 @@ import {
   addMonthGoalMerge,
   updateMonthGoalMerge
 } from "@/api/business/spd/goal_management/monthGoalMerge";
+import {
+  getMonthSaleGoalDetails,
+  delMonthSaleGoalDetails
+} from "@/api/business/spd/goal_management/monthSaleGoalDetails"
 
 // 树形参照
 import TreeRefers from '@/components/Refers/treeRefer.vue'
@@ -534,13 +547,13 @@ export default {
         goalCategory: null,
         goalSum: null,
         documentStatus: null,
-        deleteStatus: null,
         saleZoneCode: null,
         saleZone: null,
         oneLevelClassifyCode: null,
         oneLevelClassify: null,
         twoLevelClassifyCode: null,
-        twoLevelClassify: null
+        twoLevelClassify: null,
+        monthMergeDetailsList: null
       },
       formDetails: {
         id: null,
@@ -570,11 +583,7 @@ export default {
         { value: '二级分类', label: '二级分类' }
       ],
       // 树形参照
-      referCondition: {
-        type: '',
-        isPage: true,
-        title: ''
-      },
+      referCondition: { type: '', isPage: true, title: '', index: null },
       classOptions: []
     };
   },
@@ -591,6 +600,16 @@ export default {
         this.loading = false;
       });
     },
+    getListDetails() {
+      this.loading = true;
+      getMonthSaleGoalDetails(this.form.id).then(response => {
+        this.monthGoalMergeDetailsList = response.data;
+        this.computeTotal()
+        this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
+        updateMonthGoalMerge(this.form).then(response => {})
+        this.loading = false;
+      });
+    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -614,7 +633,6 @@ export default {
         goalCategory: null,
         goalSum: null,
         documentStatus: null,
-        deleteStatus: null,
         saleZoneCode: null,
         saleZone: null,
         oneLevelClassifyCode: null,
@@ -680,22 +698,24 @@ export default {
     },
     /** 提交按钮 */
     submitForm() {
-      this.resetQuery()
       this.$refs["form"].validate(valid => {
         if (valid) {
-          if (this.form.id != null) {
+          if (this.form.id !== null) {
+            this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
             updateMonthGoalMerge(this.form).then(response => {
               this.$modal.msgSuccess("修改成功");
               this.open = false;
               this.getList();
             });
           } else {
+            this.form.documentStatus = '未提交'
+            this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
             console.log(this.form);
-            /*addMonthGoalMerge(this.form).then(response => {
+            addMonthGoalMerge(this.form).then(response => {
               this.$modal.msgSuccess("新增成功");
               this.open = false;
               this.getList();
-            });*/
+            });
           }
         }
       });
@@ -712,8 +732,24 @@ export default {
       });
     },
     handleDeleteDetails(index, row) {
-      this.monthGoalMergeDetailsList.splice(index, 1)
-      this.computeTotal()
+      if (this.form.id === null) {
+        this.monthGoalMergeDetailsList.splice(index, 1)
+        this.computeTotal()
+      } else {
+        if (row.id !== null) {
+          this.$modal.confirm('是否确认删除月销售目标合并明细编号为"' + ids + '"的数据项?').then(function () {
+            return delMonthSaleGoalDetails(row.id);
+          }).then(() => {
+            this.getListDetails();
+            this.$modal.msgSuccess("删除成功");
+          }).catch(() => {
+          });
+        } else {
+          this.monthGoalMergeDetailsList.splice(index, 1)
+          this.$message.success('删除成功')
+          this.computeTotal()
+        }
+      }
     },
     /** 导出按钮操作 */
     handleExport() {
@@ -728,10 +764,17 @@ export default {
       this.referCondition.title = title
       this.$refs.treeQuery.init(this.referCondition)
     },
-    chooseTreeReferForDetails(type, isPage, title) {
+    chooseTreeReferForMain(type, isPage, title) {
+      this.referCondition.type = type
+      this.referCondition.isPage = isPage
+      this.referCondition.title = title
+      this.$refs.treeMain.init(this.referCondition)
+    },
+    chooseTreeReferForDetails(type, isPage, title, index) {
       this.referCondition.type = type
       this.referCondition.isPage = isPage
       this.referCondition.title = title
+      this.referCondition.index = index
       this.$refs.treeDetails.init(this.referCondition)
     },
     selectionsToInputForQuery(selection) {
@@ -742,14 +785,26 @@ export default {
         }
         this.queryParams.oneLevelClassifyCode = selection.code
         this.queryParams.oneLevelClassify = selection.name
-        this.form.oneLevelClassifyCode = selection.code
-        this.form.oneLevelClassify = selection.name
       } else if (this.referCondition.title === '二级物料分类') {
         if (selection.code.length !== 4) {
           return this.$message.info('请在二级分类下选择')
         }
         this.queryParams.twoLevelClassifyCode = selection.code
         this.queryParams.twoLevelClassify = selection.name
+      }
+    },
+    selectionsToInputForMain(selection) {
+      this.classOptions.push(selection)
+      if (this.referCondition.title === '一级物料分类') {
+        if (selection.code.length !== 1) {
+          return this.$message.info('请在一级分类下选择')
+        }
+        this.form.oneLevelClassifyCode = selection.code
+        this.form.oneLevelClassify = selection.name
+      } else if (this.referCondition.title === '二级物料分类') {
+        if (selection.code.length !== 4) {
+          return this.$message.info('请在二级分类下选择')
+        }
         this.form.twoLevelClassifyCode = selection.code
         this.form.twoLevelClassify = selection.name
       }
@@ -760,20 +815,20 @@ export default {
         if (selection.code.length !== 1) {
           return this.$message.info('请在一级分类中选择')
         }
-        this.formDetails.oneLevelClassifyCode = selection.code
-        this.formDetails.oneLevelClassify = selection.name
-        if (selection.code !== this.formDetails.oneLevelClassifyCode) {
-          this.formDetails.twoLevelClassifyCode = null
-          this.formDetails.twoLevelClassify = null
+        if (selection.code !== this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode) {
+          this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = null
+          this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = null
         }
+        this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
+        this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassify = selection.name
       } else if (this.referCondition.title === '二级物料分类') {
         if (selection.code.length !== 4) {
           return this.$message.info('请在二级分类中选择')
-        } else if (selection.code[0] !== this.formDetails.oneLevelClassifyCode) {
+        } else if (selection.code[0] !== this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode) {
           return this.$message.error('所选择的二级物料分类不属于一级分类')
         }
-        this.formDetails.twoLevelClassifyCode = selection.code
-        this.formDetails.twoLevelClassify = selection.name
+        this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = selection.code
+        this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = selection.name
       }
     },
     // 改变查询表单的目标分类
@@ -871,7 +926,7 @@ export default {
     // 复制明细
     handleCopyDetails(row) {
       let list = {
-        id: row.id,
+        id: null,
         code: row.code,
         saleOrg: row.saleOrg,
         saleZone: row.saleZone,

+ 2 - 2
src/views/business/spd/goal_management/MonthSaleGoal.vue

@@ -479,7 +479,7 @@ export default {
       // 表单校验
       rules: {},
       // 参照条件
-      referCondition: {type: '', isPage: true, title: '', index: null},
+      referCondition: { type: '', isPage: true, title: '', index: null },
       classOptions: [],
     };
   },
@@ -630,7 +630,7 @@ export default {
         this.monthSaleGoalDetailsList.splice(index, 1)
         this.computeTotal()
       } else {
-        if (row.id === null) {
+        if (row.id !== null) {
           this.$modal.confirm('是否确认删除月销售目标填报明细编号为"' + ids + '"的数据项?').then(function () {
             return delMonthSaleGoalDetails(row.id);
           }).then(() => {