Sfoglia il codice sorgente

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

002637 1 anno fa
parent
commit
b28c9d2124

+ 1 - 35
src/api/business/spd/goal_management/monthSaleGoalDetails.js

@@ -12,7 +12,7 @@ export function listMonthSaleGoalDetails(query) {
 // 查询月销售目标明细详细
 export function getMonthSaleGoalDetails(id) {
   return request({
-    url: '/goal_management/monthSaleGoalDetails/' + id,
+    url: '/goal_management/monthSaleGoalDetails/parent' + id,
     method: 'get'
   })
 }
@@ -42,37 +42,3 @@ export function delMonthSaleGoalDetails(id) {
     method: 'delete'
   })
 }
-
-// 将数据的code设置成非空
-export function setCodeIsNotNull() {
-  return request({
-    url: '/goal_management/monthSaleGoalDetails/setCodeIsNotNull',
-    method: 'post'
-  })
-}
-
-// 复制单据
-export function copyGoalDetails(data) {
-  return request({
-    url: '/goal_management/monthSaleGoalDetails/copyGoalDetails',
-    method: 'put',
-    data: data
-  })
-}
-
-// 根据code得到明细
-export function listMonthSaleGoalDetailsByCode(query, code) {
-  return request({
-    url: '/goal_management/monthSaleGoalDetails/listMonthSaleGoalDetailsByCode/' + code,
-    method: 'get',
-    params: query
-  })
-}
-
-// 在修改页中修改明细时,修改数据库的数据
-export function updateMainGoalSum(code) {
-  return request({
-    url: '/goal_management/monthSaleGoalDetails/updateMainGoalSum/' + code,
-    method: 'post'
-  })
-}

+ 3 - 3
src/views/business/spd/goal_management/AnnualSaleGoal.vue

@@ -856,12 +856,12 @@ export default {
         if (selection.code.length !== 1) {
           return this.$message.info('请在一级分类中选择')
         }
-        this.annualSaleGoalDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
-        this.annualSaleGoalDetailsList[this.referCondition.index].oneLevelClassify = selection.name
-        if (selection.code !== this.formDetails.oneLevelClassifyCode) {
+        if (selection.code !== this.annualSaleGoalDetailsList[this.referCondition.index].oneLevelClassifyCode) {
           this.annualSaleGoalDetailsList[this.referCondition.index].twoLevelClassifyCode = null
           this.annualSaleGoalDetailsList[this.referCondition.index].twoLevelClassify = null
         }
+        this.annualSaleGoalDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
+        this.annualSaleGoalDetailsList[this.referCondition.index].oneLevelClassify = selection.name
       } else if (this.referCondition.title === '二级物料分类') {
         if (selection.code.length !== 4) {
           return this.$message.info('请在二级分类中选择')

+ 3 - 3
src/views/business/spd/goal_management/AnnualSaleGoalMerge.vue

@@ -971,12 +971,12 @@ export default {
         if (selection.code.length !== 1) {
           return this.$message.info('请在一级分类中选择')
         }
-        this.annualSaleGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
-        this.annualSaleGoalMergeDetailsList[this.referCondition.index].oneLevelClassify = selection.name
-        if (selection.code !== this.formDetails.oneLevelClassifyCode) {
+        if (selection.code !== this.annualSaleGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode) {
           this.annualSaleGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = null
           this.annualSaleGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = null
         }
+        this.annualSaleGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
+        this.annualSaleGoalMergeDetailsList[this.referCondition.index].oneLevelClassify = selection.name
       } else if (this.referCondition.title === '二级物料分类') {
         if (selection.code.length !== 4) {
           return this.$message.info('请在二级分类中选择')

+ 117 - 72
src/views/business/spd/goal_management/MonthSaleGoal.vue

@@ -26,44 +26,42 @@
         </el-date-picker>
       </el-form-item>
       <el-form-item label="年度" prop="annual">
-        <el-input
+        <el-date-picker
           v-model="queryParams.annual"
-          placeholder="请输入年度"
+          type="year"
+          value-format="yyyy"
+          placeholder="选择年度"
           clearable
-          @keyup.enter.native="handleQuery"
-        />
+          @keyup.enter.native="handleQuery">
+        </el-date-picker>
       </el-form-item>
       <el-form-item label="客户" prop="custom">
-        <el-input
-          v-model="queryParams.custom"
-          placeholder="请输入客户"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
+        <el-popover-select-v2 v-model="queryParams.custom" title="客户" valueKey="name"
+                              referName="CUSTOMER_PARAM"
+                              :dataMapping="{ customCode: 'code', custom: 'name'}"
+                              :source.sync="queryParams" placeholder="请输入客户" @keyup.enter.native="handleQuery">
+        </el-popover-select-v2>
       </el-form-item>
       <el-form-item label="销售区域" prop="saleZone">
-        <el-input
-          v-model="queryParams.saleZone"
-          placeholder="请输入销售区域"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
+        <el-popover-select-v2 v-model="queryParams.saleZone" title="销售区域" valueKey="name"
+                              referName="CUSTOMER_PARAM"
+                              :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
+                              :source.sync="queryParams" placeholder="请输入销售区域" @keyup.enter.native="handleQuery">
+        </el-popover-select-v2>
       </el-form-item>
       <el-form-item label="制单人" prop="creator">
-        <el-input
-          v-model="queryParams.creator"
-          placeholder="请输入制单人"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
+        <el-popover-select-v2 v-model="queryParams.creator" title="制单人" valueKey="name"
+                              referName="CONTACTS_PARAM"
+                              :dataMapping="{ creatorCode: 'code', creator: 'name'}"
+                              :source.sync="queryParams" placeholder="请输入制单人" @keyup.enter.native="handleQuery">
+        </el-popover-select-v2>
       </el-form-item>
       <el-form-item label="部门" prop="dept">
-        <el-input
-          v-model="queryParams.dept"
-          placeholder="请输入部门"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
+        <el-popover-select-v2 v-model="queryParams.dept" title="部门" valueKey="name"
+                              referName="DEPT_PARAM"
+                              :dataMapping="{ deptCode: 'code', dept: 'name'}"
+                              :source.sync="queryParams" placeholder="请输入部门" @keyup.enter.native="handleQuery">
+        </el-popover-select-v2>
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -111,7 +109,6 @@
 
     <el-table v-loading="loading" :data="monthSaleGoalList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center"/>
-      <el-table-column label="id唯一标识" align="center" prop="id"/>
       <el-table-column label="编码" align="center" prop="code"/>
       <el-table-column label="目标名称" align="center" prop="goalName"/>
       <el-table-column label="单据日期" align="center" prop="documentDate" width="180">
@@ -120,18 +117,13 @@
         </template>
       </el-table-column>
       <el-table-column label="年度" align="center" prop="annual"/>
-      <el-table-column label="客户编码" align="center" prop="customCode"/>
       <el-table-column label="客户" align="center" prop="custom"/>
-      <el-table-column label="销售区域编码" align="center" prop="saleZoneCode"/>
       <el-table-column label="销售区域" align="center" prop="saleZone"/>
-      <el-table-column label="制单人编码" align="center" prop="creatorCode"/>
       <el-table-column label="制单人" align="center" prop="creator"/>
-      <el-table-column label="部门编码" align="center" prop="deptCode"/>
       <el-table-column label="部门" align="center" prop="dept"/>
       <el-table-column label="目标合计" align="center" prop="goalSum"/>
       <el-table-column label="备注" align="center" prop="notes"/>
       <el-table-column label="单据状态" align="center" prop="documentStatus"/>
-      <el-table-column label="删除状态" align="center" prop="deleteStatus"/>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140" fixed="right">
         <template slot-scope="scope">
           <el-button
@@ -246,7 +238,7 @@
           </el-col>
           <el-col :span="6">
             <el-form-item label="单据状态" prop="documentStatus">
-              <el-input v-model="form.documentStatus" disabled/>
+              <el-input v-model="form.documentStatus" placeholder="新增页默认'未提交'" disabled/>
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -309,14 +301,22 @@
             </el-popover-select-v2>
           </template>
         </el-table-column>
-        <el-table-column label="一级分类" align="center" prop="oneLevelClassify" width="180">
+        <el-table-column label="一级分类" align="center" prop="oneLevelClassify" width="220">
           <template slot-scope="scope">
-            <el-input v-model="monthSaleGoalDetailsList[scope.$index].oneLevelClassify" disabled></el-input>
+            <el-select v-model="monthSaleGoalDetailsList[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">
+        <el-table-column label="二级分类" align="center" prop="twoLevelClassify" width="220">
           <template slot-scope="scope">
-            <el-input v-model="monthSaleGoalDetailsList[scope.$index].twoLevelClassify" disabled></el-input>
+            <el-select v-model="monthSaleGoalDetailsList[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">
@@ -367,6 +367,8 @@
         </el-table-column>
       </el-table>
     </el-drawer>
+
+    <TreeRefers ref="treeDetails" @doSubmit="selectionsToInputForDetails" :single="true"/>
   </div>
 </template>
 
@@ -378,6 +380,10 @@ import {
   addMonthSaleGoal,
   updateMonthSaleGoal
 } from "@/api/business/spd/goal_management/monthSaleGoal";
+import {
+  getMonthSaleGoalDetails,
+  delMonthSaleGoalDetails
+} from "@/api/business/spd/goal_management/monthSaleGoalDetails"
 
 // 树形参照
 import TreeRefers from '@/components/Refers/treeRefer.vue'
@@ -449,7 +455,6 @@ export default {
         goalSum: null,
         notes: null,
         documentStatus: null,
-        deleteStatus: null,
         monthDetailsList: null
       },
       formDetails: {
@@ -472,7 +477,10 @@ export default {
         goalValue: null
       },
       // 表单校验
-      rules: {}
+      rules: {},
+      // 参照条件
+      referCondition: {type: '', isPage: true, title: '', index: null},
+      classOptions: [],
     };
   },
   created() {
@@ -486,17 +494,19 @@ export default {
         this.monthSaleGoalList = response.rows;
         this.total = response.total;
         this.loading = false;
-        for (const element of this.monthSaleGoalList) {
-          if (element.documentStatus === '0') {
-            element.documentStatus = '未提交'
-          } else if (element.documentStatus === '1') {
-            element.documentStatus = '审核中'
-          } else {
-            element.documentStatus = '已审核'
-          }
-        }
       });
     },
+    getListDetails() {
+      this.loading = true
+      getMonthSaleGoalDetails(this.form.id).then(response => {
+        this.monthSaleGoalDetailsList = response.data
+        this.computeTotal()
+        this.form.monthDetailsList = this.monthSaleGoalDetailsList
+        updateMonthSaleGoal(this.form).then(response => {
+        })
+        this.loading = false
+      })
+    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -521,7 +531,6 @@ export default {
         goalSum: null,
         notes: null,
         documentStatus: null,
-        deleteStatus: null,
         monthDetailsList: null
       };
       this.resetForm("form");
@@ -576,13 +585,7 @@ export default {
       const id = row.id || this.ids
       getMonthSaleGoal(id).then(response => {
         this.form = response.data;
-        if (this.form.documentStatus === '0') {
-          this.form.documentStatus = '未提交'
-        } else if (this.form.documentStatus === '1') {
-          this.form.documentStatus = '审批中'
-        } else {
-          this.form.documentStatus = '已审核'
-        }
+        this.monthSaleGoalDetailsList = this.form.monthDetailsList
         this.open = true;
         this.title = "修改月销售目标填报";
       });
@@ -592,13 +595,6 @@ export default {
       this.$refs["form"].validate(valid => {
         if (valid) {
           if (this.form.id != null) {
-            if (this.form.documentStatus === '未提交') {
-              this.form.documentStatus = 0
-            } else if (this.form.documentStatus === '审批中') {
-              this.form.documentStatus = 1
-            } else {
-              this.form.documentStatus = 2
-            }
             this.form.monthDetailsList = this.monthSaleGoalDetailsList
             updateMonthSaleGoal(this.form).then(response => {
               this.$modal.msgSuccess("修改成功");
@@ -606,12 +602,14 @@ export default {
               this.getList();
             });
           } else {
+            this.form.documentStatus = '未提交'
             this.form.monthDetailsList = this.monthSaleGoalDetailsList
-            addMonthSaleGoal(this.form).then(response => {
+            console.log(this.form);
+            /*addMonthSaleGoal(this.form).then(response => {
               this.$modal.msgSuccess("新增成功");
               this.open = false;
               this.getList();
-            });
+            });*/
           }
         }
       });
@@ -628,8 +626,24 @@ export default {
       });
     },
     handleDeleteDetails(index, row) {
-      this.monthSaleGoalDetailsList.splice(index, 1)
-      this.computeTotal()
+      if (this.form.id === null) {
+        this.monthSaleGoalDetailsList.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.monthSaleGoalDetailsList.splice(index, 1)
+          this.$message.success('删除成功')
+          this.computeTotal()
+        }
+      }
     },
     /** 导出按钮操作 */
     handleExport() {
@@ -642,12 +656,13 @@ export default {
         .then(_ => {
           done();
         })
-        .catch(_ => {});
+        .catch(_ => {
+        });
     },
     // 复制明细
     handleCopyDetails(row) {
       let list = {
-        id: row.id,
+        id: null,
         code: row.code,
         saleOrg: row.saleOrg,
         saleZone: row.saleZone,
@@ -676,7 +691,37 @@ export default {
         sum = (sum * 1000000 + listElement.goalValue * 1000000) / 1000000
       }
       this.form.goalSum = sum
+    },
+    // 树形物料分类
+    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)
+    },
+    selectionsToInputForDetails(selection) {
+      this.classOptions.push(selection)
+      if (this.referCondition.title === '一级物料分类') {
+        if (selection.code.length !== 1) {
+          return this.$message.info('请在一级分类中选择')
+        }
+        if (selection.code !== this.monthSaleGoalDetailsList[this.referCondition.index].oneLevelClassifyCode) {
+          this.monthSaleGoalDetailsList[this.referCondition.index].twoLevelClassifyCode = null
+          this.monthSaleGoalDetailsList[this.referCondition.index].twoLevelClassify = null
+        }
+        this.monthSaleGoalDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
+        this.monthSaleGoalDetailsList[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.monthSaleGoalDetailsList[this.referCondition.index].oneLevelClassifyCode) {
+          return this.$message.error('所选择的二级物料分类不属于一级分类')
+        }
+        this.monthSaleGoalDetailsList[this.referCondition.index].twoLevelClassifyCode = selection.code
+        this.monthSaleGoalDetailsList[this.referCondition.index].twoLevelClassify = selection.name
+      }
     }
   }
-};
+}
 </script>