Эх сурвалжийг харах

营销目标-根据制单人部门变动必填字段;科室字段改为枚举下拉;增加利润目标值(元)字段;修改字段宽度;一二级分类字段改为树形参照;修改模块名称。

DongZ 1 жил өмнө
parent
commit
4c39890d6b

+ 158 - 51
src/views/business/spd/target/MonthSaleGoal.vue

@@ -119,7 +119,7 @@
       <el-table-column label="销售区域" align="center" prop="saleZone" width="180" />
       <el-table-column label="销售区域" align="center" prop="saleZone" width="180" />
       <el-table-column label="制单人" align="center" prop="creator" width="180" />
       <el-table-column label="制单人" align="center" prop="creator" width="180" />
       <el-table-column label="部门" align="center" prop="dept" width="180" />
       <el-table-column label="部门" align="center" prop="dept" width="180" />
-      <el-table-column label="目标合计(元)" align="center" prop="goalSum" width="180" />
+      <el-table-column label="销售目标合计(元)" align="center" prop="goalSum" width="180" />
       <el-table-column label="备注" align="center" prop="notes" width="180" />
       <el-table-column label="备注" align="center" prop="notes" width="180" />
       <el-table-column show-overflow-tooltip label="状态" align="center" width="100" prop="status">
       <el-table-column show-overflow-tooltip label="状态" align="center" width="100" prop="status">
         <template slot-scope="scope">
         <template slot-scope="scope">
@@ -207,7 +207,7 @@
         </el-row>
         </el-row>
         <el-row :gutter="20">
         <el-row :gutter="20">
           <el-col :span="6">
           <el-col :span="6">
-            <el-form-item label="目标合计(元)" prop="goalSum" label-width="120px">
+            <el-form-item label="销售目标合计(元)" prop="goalSum" label-width="150px">
               <el-input v-model="form.goalSum" placeholder="目标合计自动计算" disabled />
               <el-input v-model="form.goalSum" placeholder="目标合计自动计算" disabled />
             </el-form-item>
             </el-form-item>
           </el-col>
           </el-col>
@@ -257,7 +257,7 @@
             </el-col>
             </el-col>
           </el-row>
           </el-row>
           <el-tabs v-model="activeName">
           <el-tabs v-model="activeName">
-            <el-tab-pane label="月销售目标明细" name="monthSaleGoalDetails">
+            <el-tab-pane label="月销售/月利润目标明细" name="monthSaleGoalDetails">
               <el-table max-height="560" show-summary :summary-method="getSummaries" v-loading="loading" size="mini"
               <el-table max-height="560" show-summary :summary-method="getSummaries" v-loading="loading" size="mini"
                 :data="monthSaleGoalDetailsList" @selection-change="handleSelectionChange" v-horizontal-scroll>
                 :data="monthSaleGoalDetailsList" @selection-change="handleSelectionChange" v-horizontal-scroll>
                 <el-table-column label="序号" type="index" width="70" align="center" fixed />
                 <el-table-column label="序号" type="index" width="70" align="center" fixed />
@@ -302,19 +302,23 @@
                     </el-popover-select-v2>
                     </el-popover-select-v2>
                   </template>
                   </template>
                 </el-table-column> -->
                 </el-table-column> -->
-                <el-table-column label="一级分类" align="center" width="180" :render-header="addRedStar">
+                <el-table-column label="一级分类" align="center" min-width="200" :render-header="addRedStar">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
-                    <el-input v-model="monthSaleGoalDetailsList[scope.$index].oneLevelClassify" placeholder="请输入一级分类"
-                      disabled></el-input>
+                    <el-select v-model="monthSaleGoalDetailsList[scope.$index].oneLevelClassify" clearable
+                      @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '一级物料分类', scope.$index)" :disabled="!isDept">
+                      <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
+                    </el-select>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
-                <el-table-column label="二级分类" align="center" width="180" :render-header="addRedStar">
+                <el-table-column label="二级分类" align="center" min-width="200" :render-header="addRedStar">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
-                    <el-input v-model="monthSaleGoalDetailsList[scope.$index].twoLevelClassify" placeholder="请输入二级分类"
-                      disabled></el-input>
+                    <el-select v-model="monthSaleGoalDetailsList[scope.$index].twoLevelClassify" clearable
+                      @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '二级物料分类', scope.$index)" :disabled="!isDept">
+                      <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
+                    </el-select>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
-                <el-table-column label="物料" align="center" width="180" :render-header="addRedStar">
+                <el-table-column label="物料" align="center" min-width="220" :render-header="addRedStarChange">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
                     <el-tooltip class="item" effect="dark" placement="top-start">
                     <el-tooltip class="item" effect="dark" placement="top-start">
                       <div slot="content">{{ scope.row.memo }}</div>
                       <div slot="content">{{ scope.row.memo }}</div>
@@ -328,31 +332,38 @@
                     </el-tooltip>
                     </el-tooltip>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
-                <el-table-column label="科室" align="center" width="180">
+                <el-table-column label="科室" align="center" prop="department" min-width="200">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
-                    <el-input v-model="monthSaleGoalDetailsList[scope.$index].department" placeholder="请输入科室">
-                    </el-input>
+                    <el-select v-model="monthSaleGoalDetailsList[scope.$index].department" placeholder="请选择科室">
+                      <el-option v-for="dict in dict.type.mk_bo_section" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
+                    </el-select>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
-                <el-table-column label="数量" align="center" prop="num" width="220">
+                <el-table-column label="数量" align="center" prop="num" min-width="220">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
                     <el-input-number v-model="monthSaleGoalDetailsList[scope.$index].num" :min="0"
                     <el-input-number v-model="monthSaleGoalDetailsList[scope.$index].num" :min="0"
                       @change="calculate(scope.row)"></el-input-number>
                       @change="calculate(scope.row)"></el-input-number>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
-                <el-table-column label="月份" align="center" width="250" :render-header="addRedStar">
+                <el-table-column label="月份" align="center" min-width="250">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
-                    <el-date-picker v-model="monthSaleGoalDetailsList[scope.$index].monthly" value-format="yyyy-MM"
+                    <el-date-picker v-model="monthSaleGoalDetailsList[scope.$index].monthly" value-format="yyyy-MM" disabled
                       type="month" placeholder="选择月份">
                       type="month" placeholder="选择月份">
                     </el-date-picker>
                     </el-date-picker>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
-                <el-table-column label="目标值(元)" align="center" prop="goalValue" width="220" :render-header="addRedStar">
+                <el-table-column label="销售目标值(元)" align="center" prop="goalValue" min-width="220" :render-header="addRedStar">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
                     <el-input-number @change="computeTotal" v-model="monthSaleGoalDetailsList[scope.$index].goalValue"
                     <el-input-number @change="computeTotal" v-model="monthSaleGoalDetailsList[scope.$index].goalValue"
                       :precision="2" :step="1" :min="0"></el-input-number>
                       :precision="2" :step="1" :min="0"></el-input-number>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
+                <el-table-column label="利润目标值(元)" align="center" prop="profitTargetValue" min-width="220" :render-header="addRedStar" v-if="isDept">
+                  <template slot-scope="scope">
+                    <el-input-number @change="computeTotal" v-model="monthSaleGoalDetailsList[scope.$index].profitTargetValue"
+                      :precision="2" :step="1" :min="0"></el-input-number>
+                  </template>
+                </el-table-column>
                 <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px"
                 <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px"
                   fixed="right">
                   fixed="right">
                   <template slot-scope="scope">
                   <template slot-scope="scope">
@@ -437,6 +448,7 @@
         <el-button type="primary" @click="dialogUpdateMoreSave">确 定</el-button>
         <el-button type="primary" @click="dialogUpdateMoreSave">确 定</el-button>
       </div>
       </div>
     </el-dialog>
     </el-dialog>
+  <TreeRefers ref="treeMain" @doSubmit="selectionsToInputForMain" :single="true" />
   </div>
   </div>
 </template>
 </template>
 
 
@@ -475,7 +487,7 @@
       TreeRefers,
       TreeRefers,
       ElPopoverSelectV2
       ElPopoverSelectV2
     },
     },
-    dicts: ["sys_status", "oa_templete_id"],
+    dicts: ["sys_status", "oa_templete_id", "mk_bo_section"],
     data() {
     data() {
       return {
       return {
         // 遮罩层
         // 遮罩层
@@ -490,7 +502,7 @@
         showSearch: false,
         showSearch: false,
         // 总条数
         // 总条数
         total: 0,
         total: 0,
-        // 月销售目标填报表格数据
+        // 月销售/月利润目标填报表格数据
         monthSaleGoalList: [],
         monthSaleGoalList: [],
         monthSaleGoalDetailsList: [],
         monthSaleGoalDetailsList: [],
         // 弹出层标题
         // 弹出层标题
@@ -688,13 +700,26 @@
         }],
         }],
         materialRange: '',
         materialRange: '',
         text: '',
         text: '',
+        // 判断操作用户是否属于湖南公司部门的标志
+        isDept: false,
+        // 物料分类数组
+        classOptions: [],
+        // 树形参照
+        referCondition: {
+          type: '',
+          isPage: true,
+          title: '',
+          index: null
+        },
+        index: null,
       };
       };
     },
     },
     created() {
     created() {
       this.getList();
       this.getList();
+      this.judge();
     },
     },
     methods: {
     methods: {
-      /** 查询月销售目标填报列表 */
+      /** 查询月销售/月利润目标填报列表 */
       getList() {
       getList() {
         this.loading = true;
         this.loading = true;
         listMonthSaleGoal(this.queryParams).then(response => {
         listMonthSaleGoal(this.queryParams).then(response => {
@@ -790,7 +815,7 @@
         this.reset();
         this.reset();
         this.monthSaleGoalDetailsList = []
         this.monthSaleGoalDetailsList = []
         this.open = true;
         this.open = true;
-        this.title = "添加--月销售目标填报";
+        this.title = "添加--月销售/月利润目标填报";
         this.form.documentDate = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString()
         this.form.documentDate = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString()
           .padStart(2, '0') + '-' + new Date().getDate().toString().padStart(2, '0')
           .padStart(2, '0') + '-' + new Date().getDate().toString().padStart(2, '0')
         this.form.annual = new Date().getFullYear().toString()
         this.form.annual = new Date().getFullYear().toString()
@@ -836,7 +861,7 @@
           this.form.goalSum = this.form.goalSum.toFixed(2)
           this.form.goalSum = this.form.goalSum.toFixed(2)
           this.monthSaleGoalDetailsList = JSON.parse(JSON.stringify(this.form.monthDetailsList))
           this.monthSaleGoalDetailsList = JSON.parse(JSON.stringify(this.form.monthDetailsList))
           this.open = true;
           this.open = true;
-          this.title = "修改--月销售目标填报";
+          this.title = "修改--月销售/月利润目标填报";
         });
         });
       },
       },
       useDoubleClick(row) {
       useDoubleClick(row) {
@@ -848,7 +873,7 @@
           this.form.goalSum = this.form.goalSum.toFixed(2)
           this.form.goalSum = this.form.goalSum.toFixed(2)
           this.monthSaleGoalDetailsList = JSON.parse(JSON.stringify(this.form.monthDetailsList))
           this.monthSaleGoalDetailsList = JSON.parse(JSON.stringify(this.form.monthDetailsList))
           this.open = true;
           this.open = true;
-          this.title = "修改--月销售目标填报";
+          this.title = "修改--月销售/月利润目标填报";
         });
         });
       },
       },
       // 复制按钮
       // 复制按钮
@@ -869,7 +894,7 @@
             element.code = null
             element.code = null
           }
           }
           this.open = true;
           this.open = true;
-          this.title = "新增--月销售目标填报";
+          this.title = "新增--月销售/月利润目标填报";
         })
         })
       },
       },
       /** 提交按钮 */
       /** 提交按钮 */
@@ -884,10 +909,12 @@
         if (this.justiceDetailsList()) {
         if (this.justiceDetailsList()) {
           return this.$message.error('子表中第' + this.text + '行有必填字段未填,或者目标值为0')
           return this.$message.error('子表中第' + this.text + '行有必填字段未填,或者目标值为0')
         }
         }
-        for (let i = 0; i < this.monthSaleGoalDetailsList.length; i++) {
-          for (let j = i + 1; j < this.monthSaleGoalDetailsList.length; j++) {
-            if (this.monthSaleGoalDetailsList[i].materialCode == this.monthSaleGoalDetailsList[j].materialCode) {
-              return this.$message.error('子表存在重复物料');
+        if (!this.isDept) {
+          for (let i = 0; i < this.monthSaleGoalDetailsList.length; i++) {
+            for (let j = i + 1; j < this.monthSaleGoalDetailsList.length - i; j++) {
+              if (this.monthSaleGoalDetailsList[i].materialCode == this.monthSaleGoalDetailsList[j].materialCode) {
+                return this.$message.error('子表存在重复物料');
+              }
             }
             }
           }
           }
         }
         }
@@ -895,19 +922,25 @@
           if (valid) {
           if (valid) {
             if (this.form.id != null) {
             if (this.form.id != null) {
               this.form.monthDetailsList = JSON.parse(JSON.stringify(this.monthSaleGoalDetailsList))
               this.form.monthDetailsList = JSON.parse(JSON.stringify(this.monthSaleGoalDetailsList))
+              this.$modal.loading("保存中...");
               updateMonthSaleGoal(this.form).then(response => {
               updateMonthSaleGoal(this.form).then(response => {
                 this.$modal.msgSuccess("修改成功");
                 this.$modal.msgSuccess("修改成功");
                 this.open = false;
                 this.open = false;
                 this.getList();
                 this.getList();
+              }).finally( e =>{
+                this.$modal.closeLoading();
               });
               });
             } else {
             } else {
               this.form.status = '0'
               this.form.status = '0'
               this.form.monthDetailsList = JSON.parse(JSON.stringify(this.monthSaleGoalDetailsList))
               this.form.monthDetailsList = JSON.parse(JSON.stringify(this.monthSaleGoalDetailsList))
               console.log(this.form);
               console.log(this.form);
+              this.$modal.loading("保存中...");
               addMonthSaleGoal(this.form).then(response => {
               addMonthSaleGoal(this.form).then(response => {
                 this.$modal.msgSuccess("新增成功");
                 this.$modal.msgSuccess("新增成功");
                 this.open = false;
                 this.open = false;
                 this.getList();
                 this.getList();
+              }).finally( e =>{
+                this.$modal.closeLoading();
               });
               });
             }
             }
           }
           }
@@ -916,7 +949,7 @@
       /** 删除按钮操作 */
       /** 删除按钮操作 */
       handleDelete(row) {
       handleDelete(row) {
         const ids = row.id || this.ids;
         const ids = row.id || this.ids;
-        this.$modal.confirm('是否确认删除月销售目标填报单据编号为"' + row.code + '"的数据项?').then(function () {
+        this.$modal.confirm('是否确认删除月销售/月利润目标填报单据编号为"' + row.code + '"的数据项?').then(function () {
           return delMonthSaleGoal(ids);
           return delMonthSaleGoal(ids);
         }).then(() => {
         }).then(() => {
           this.getList();
           this.getList();
@@ -929,7 +962,7 @@
           this.computeTotal()
           this.computeTotal()
         } else {
         } else {
           if (row.id !== null) {
           if (row.id !== null) {
-            this.$modal.confirm('是否确认删除月销售目标填报明细序号为"' + (index + 1) + '"的数据项?').then(function () {
+            this.$modal.confirm('是否确认删除月销售/月利润目标填报明细序号为"' + (index + 1) + '"的数据项?').then(function () {
               return delMonthSaleGoalDetails(row.id);
               return delMonthSaleGoalDetails(row.id);
             }).then(() => {
             }).then(() => {
               this.getListDetails();
               this.getListDetails();
@@ -1007,29 +1040,69 @@
           h('span', '' + column.label)
           h('span', '' + column.label)
         ]
         ]
       },
       },
+      // 子表table通过判断条件加必填标志
+      addRedStarChange(h, {
+        column
+      }) {
+        if (this.isDept) {
+          return[
+            h('span', '' + column.label)
+          ]
+        } else {
+        return [
+            h('span', {
+              style: 'color: #F56C6C'
+            }, '*'),
+            h('span', '' + column.label)
+          ]
+        }
+      },
       justiceDetailsList() {
       justiceDetailsList() {
         this.text = ' ';
         this.text = ' ';
         let isFlag = [];
         let isFlag = [];
         let count = 1;
         let count = 1;
         const arr = JSON.parse(JSON.stringify(this.monthSaleGoalDetailsList))
         const arr = JSON.parse(JSON.stringify(this.monthSaleGoalDetailsList))
-        for (const element of arr) {
-          const flag1 = (element.saleOrg !== null) && (element.saleZone !== null) && (element.custom !== null) && (
-            element.dept !== null) && (element.creator !== null) && (element.materialCode !== null) && (element
-            .material !== null) && (element.monthly !== null) && (element.goalValue !== 0)
-          const flag2 = (element.saleOrg !== undefined) && (element.saleZone !== undefined) && (element.custom !==
-            undefined) && (element.dept !== undefined) && (element.creator !== undefined) && (element.materialCode !==
-            undefined) && (element.material !== undefined) && (element.monthly !== undefined)
-          if (flag1 && flag2) {
-            isFlag.push(true);
-          } else {
-            this.text += '[' + count + '] ';
-            isFlag.push(false);
+        if (this.isDept) {
+          for (const element of arr) {
+            const flag1 = (element.saleOrg !== null) && (element.saleZone !== null) && (element.custom !== null) && (
+              element.dept !== null) && (element.creator !== null) && (element.oneLevelClassify !== null) && (element
+              .oneLevelClassifyCode !== null) && (element.monthly !== null) && (element.goalValue !== 0);
+            const flag2 = (element.saleOrg !== undefined) && (element.saleZone !== undefined) && (element.custom !==
+              undefined) && (element.dept !== undefined) && (element.creator !== undefined) && (element.oneLevelClassify !==
+              undefined) && (element.oneLevelClassifyCode !== undefined) && (element.monthly !== undefined);
+            if (flag1 && flag2) {
+              isFlag.push(true);
+            } else {
+              this.text += '[' + count + '] ';
+              isFlag.push(false);
+            }
+            count++;
           }
           }
-          count++;
-        }
-        for (const flag of isFlag) {
-          if (!flag) {
-            return true;
+          for (const flag of isFlag) {
+            if (!flag) {
+              return true;
+            }
+          }
+        } else {
+          for (const element of arr) {
+            const flag1 = (element.saleOrg !== null) && (element.saleZone !== null) && (element.custom !== null) && (
+              element.dept !== null) && (element.creator !== null) && (element.materialCode !== null) && (element
+              .material !== null) && (element.monthly !== null) && (element.goalValue !== 0);
+            const flag2 = (element.saleOrg !== undefined) && (element.saleZone !== undefined) && (element.custom !==
+              undefined) && (element.dept !== undefined) && (element.creator !== undefined) && (element.materialCode !==
+              undefined) && (element.material !== undefined) && (element.monthly !== undefined);
+            if (flag1 && flag2) {
+              isFlag.push(true);
+            } else {
+              this.text += '[' + count + '] ';
+              isFlag.push(false);
+            }
+            count++;
+          }
+          for (const flag of isFlag) {
+            if (!flag) {
+              return true;
+            }
           }
           }
         }
         }
       },
       },
@@ -1056,11 +1129,11 @@
       handleImport() {
       handleImport() {
         this.upload.open = true;
         this.upload.open = true;
         if (this.open) {
         if (this.open) {
-          this.upload.title = "月销售目标填报明细导入"
+          this.upload.title = "月销售/月利润目标填报明细导入"
           this.upload.url = process.env.VUE_APP_BASE_API + "goal_management/monthSaleGoalDetails/importData/" + this
           this.upload.url = process.env.VUE_APP_BASE_API + "goal_management/monthSaleGoalDetails/importData/" + this
             .form.id
             .form.id
         } else {
         } else {
-          this.upload.title = "月销售目标填报导入";
+          this.upload.title = "月销售/月利润目标填报导入";
           this.upload.url = process.env.VUE_APP_BASE_API + "goal_management/monthSaleGoal/importData"
           this.upload.url = process.env.VUE_APP_BASE_API + "goal_management/monthSaleGoal/importData"
         }
         }
       },
       },
@@ -1196,7 +1269,7 @@
       //模板下载
       //模板下载
       handleTemplateDownload() {
       handleTemplateDownload() {
         this.download('/goal_management/monthSaleGoalDetails/importTemplate', {},
         this.download('/goal_management/monthSaleGoalDetails/importTemplate', {},
-          `月销售目标填报明细导入模板_${new Date().getTime()}.xlsx`)
+          `月销售/月利润目标填报明细导入模板_${new Date().getTime()}.xlsx`)
       },
       },
       //导入
       //导入
       handleImport(file) {
       handleImport(file) {
@@ -1247,7 +1320,41 @@
       },
       },
       calculate(row) {
       calculate(row) {
         row.goalValue = row.num * row.price;
         row.goalValue = row.num * row.price;
-      }
+      },
+      judge() {
+        this.isDept = false;
+        if (this.$store.state.user.deptName.indexOf('湖南公司') >= 0) {
+          this.isDept = true;
+        }
+      },
+      // 树形参照
+      chooseTreeReferForMain(type, isPage, title, index) {
+        this.referCondition.type = type;
+        this.referCondition.isPage = isPage;
+        this.referCondition.title = title;
+        this.index = null;
+        this.index = index;
+        this.$refs.treeMain.init(this.referCondition);
+      },
+      selectionsToInputForMain(selection) {
+        this.classOptions = selection;
+        if (this.referCondition.title === '一级物料分类') {
+          if (this.classOptions[0].code.length > 2) {
+            return this.$message.info('请在一级分类下选择');
+          }
+          this.monthSaleGoalDetailsList[this.index].oneLevelClassifyCode = selection[0].code;
+          this.monthSaleGoalDetailsList[this.index].oneLevelClassify = selection[0].name;
+        } else if (this.referCondition.title === '二级物料分类') {
+          if (this.classOptions[0].code.lastIndexOf("-") == 3 || this.classOptions[0].code.indexOf("90") == 0) {
+            this.monthSaleGoalDetailsList[this.index].oneLevelClassifyCode = selection[0].parentCode;
+            this.monthSaleGoalDetailsList[this.index].oneLevelClassify = selection[0].parentName;
+            this.monthSaleGoalDetailsList[this.index].twoLevelClassifyCode = selection[0].code;
+            this.monthSaleGoalDetailsList[this.index].twoLevelClassify = selection[0].name;
+          } else {
+            return this.$message.info('请在二级分类下选择');
+          }
+        }
+      },
     }
     }
   }
   }