Browse Source

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

002637 1 năm trước cách đây
mục cha
commit
0828e4fa8b

+ 26 - 0
src/api/business/spd/goal_management/monthSaleGoalDetails.js

@@ -50,3 +50,29 @@ export function 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'
+  })
+}

+ 58 - 13
src/views/business/spd/goal_management/MonthSaleGoal.vue

@@ -272,7 +272,7 @@
         </el-col>
       </el-row>
       <el-table v-loading="loading" :data="monthSaleGoalDetailsList" @selection-change="handleSelectionChange">
-        <el-table-column type="selection" width="55" align="center"/>
+        <el-table-column type="selection" width="55" align="center" fixed/>
         <el-table-column label="id唯一标识" align="center" prop="id"/>
         <el-table-column label="编码" align="center" prop="code"/>
         <el-table-column label="销售组织" align="center" prop="saleOrg"/>
@@ -290,7 +290,7 @@
         <el-table-column label="数量" align="center" prop="num"/>
         <el-table-column label="月份" align="center" prop="monthly"/>
         <el-table-column label="目标值" align="center" prop="goalValue"/>
-        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="180px">
           <template slot-scope="scope">
             <el-button
               size="mini"
@@ -308,6 +308,9 @@
               v-hasPermi="['goal_management:monthSaleGoalDetails:remove']"
             >删除
             </el-button>
+            <el-button size="mini" type="text" icon="el-icon-paperclip" @click="copyGoalDetails(scope.row)">
+              复制
+            </el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -423,7 +426,10 @@ import {
   addMonthSaleGoalDetails,
   updateMonthSaleGoalDetails,
   delMonthSaleGoalDetails,
-  setCodeIsNotNull
+  setCodeIsNotNull,
+  copyGoalDetails,
+  listMonthSaleGoalDetailsByCode,
+  updateMainGoalSum
 } from "@/api/business/spd/goal_management/monthSaleGoalDetails"
 
 import TreeRefers from '@/components/Refers/treeRefer.vue'
@@ -582,11 +588,29 @@ export default {
     },
     getListDetails() {
       this.loading = true;
-      listMonthSaleGoalDetails(this.queryParamsDetails).then(response => {
-        this.monthSaleGoalDetailsList = response.rows;
-        this.totalDetails = response.total;
-        this.loading = false;
-      });
+      this.queryParamsDetails.numPage = 1
+      this.queryParamsDetails.numSize = 10
+      if (this.form.id === null || this.form.id === '') {
+        listMonthSaleGoalDetails(this.queryParamsDetails).then(response => {
+          this.monthSaleGoalDetailsList = response.rows;
+          this.totalDetails = response.total;
+          this.loading = false;
+          this.form.goalSum = 0
+          for (const element of response.rows) {
+            this.form.goalSum = this.form.goalSum + (element.num * element.goalValue)
+          }
+        });
+      } else {
+        listMonthSaleGoalDetailsByCode(this.queryParamsDetails, this.form.code).then(response => {
+          this.monthSaleGoalDetailsList = response.rows
+          this.totalDetails = response.total
+          this.loading = false
+          // 仅仅页面变了,在后端通过操作也变了
+          for (const element of response.rows) {
+            this.form.goalSum = this.form.goalSum + (element.num * element.goalValue)
+          }
+        })
+      }
     },
     // 取消按钮
     cancel() {
@@ -657,9 +681,6 @@ export default {
     /** 新增按钮操作 */
     handleAdd() {
       this.reset();
-      this.queryParamsDetails.numPage = 1
-      this.queryParamsDetails.numSize = 10
-      this.getListDetails()
       this.drawerAddOrEdit = true;
       this.title = "添加月销售目标填报";
     },
@@ -677,6 +698,9 @@ export default {
       if (this.form.creator !== null && this.form.creator !== '') {
         this.formDetails.creator = this.form.creator
       }
+      if (this.form.code !== null && this.form.code !== '') {
+        this.formDetails.code = this.form.code
+      }
       this.titleDetails = '月销售目标明细--新增'
       this.innerDrawer = !this.innerDrawer
     },
@@ -686,6 +710,7 @@ export default {
       const id = row.id || this.ids
       getMonthSaleGoal(id).then(response => {
         this.form = response.data;
+        this.getListDetails()
         this.drawerAddOrEdit = true;
         this.title = "修改月销售目标填报";
       });
@@ -756,6 +781,14 @@ export default {
       });
     },
     handleDeleteDetails(row) {
+      const ids = row.id || this.ids;
+      this.$modal.confirm('是否确认删除月销售目标填报编号为"' + ids + '"的数据项?').then(function () {
+        return delMonthSaleGoalDetails(ids);
+      }).then(() => {
+        this.getListDetails();
+        this.$modal.msgSuccess("删除成功");
+      }).catch(() => {
+      });
     },
     /** 导出按钮操作 */
     handleExport() {
@@ -768,11 +801,11 @@ export default {
       this.$confirm('确认关闭?')
         .then(_ => {
           done();
-          this.reset()
-          if (this.monthSaleGoalDetailsList.length !== 0) {
+          if (this.monthSaleGoalDetailsList.length !== 0 && (this.form.id === null || this.form.id === '')) {
             this.setCodeIsNotNull()
             this.monthSaleGoalDetailsList = []
           }
+          this.reset()
         })
         .catch(_ => {
         });
@@ -833,6 +866,18 @@ export default {
       setCodeIsNotNull().then(response => {
         console.log(response);
       })
+    },
+    // 复制单据
+    copyGoalDetails(row) {
+      copyGoalDetails(row).then(response => {
+        this.getListDetails()
+      })
+    },
+    // 在修改页中修改明细时,修改数据库的数据
+    updateMainGoalSum(code) {
+      updateMainGoalSum(code).then(response => {
+
+      })
     }
   }
 };