浏览代码

Merge branch 'dev' of http://172.16.100.139/new-business/drp-web into dev

002390 1 年之前
父节点
当前提交
61346d023c

+ 9 - 5
src/views/business/spd/target/MonthSaleGoal.vue

@@ -163,7 +163,7 @@
           </el-col>
           <el-col :span="6">
             <el-form-item label="单据日期" prop="documentDate">
-              <el-date-picker clearable v-model="form.documentDate" type="date" value-format="yyyy-MM-dd"
+              <el-date-picker clearable v-model="form.documentDate" type="date" value-format="yyyy-MM-dd" @change="setItemMonthly"
                 placeholder="请选择单据日期">
               </el-date-picker>
             </el-form-item>
@@ -852,8 +852,7 @@
           material: null,
           department: null,
           num: null,
-          monthly: new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString().padStart(2,
-            '0'),
+          monthly: this.form.documentDate.substring(0, 7),
           goalValue: 0,
           profitTargetValue: 0
         }
@@ -1327,8 +1326,7 @@
             item.custom = this.form.custom;
             item.dept = this.form.dept;
             item.creator = this.form.creator;
-            item.monthly = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString()
-              .padStart(2, '0');
+            item.monthly = this.form.documentDate.substring(0, 7);
           }
         }).catch((e) => {
           this.$message.error(e.message)
@@ -1381,6 +1379,12 @@
           }
         }
       },
+      // 当单据日期改变时改变明细月份
+      setItemMonthly() {
+        for (let i = 0; i < this.monthSaleGoalDetailsList.length; i++) {
+          this.monthSaleGoalDetailsList[i].monthly = this.form.documentDate.substring(0, 7);
+        }
+      },
     }
   }
 

+ 28 - 0
src/views/business/spd/target/targetMk/add.vue

@@ -113,6 +113,7 @@ export default {
     return {
       template:{},
       form:{
+        date: this.formatDateTime(new Date(), 'yyyy-MM-dd'),
         template: null,
       },
       //表单校验
@@ -240,6 +241,33 @@ export default {
         }
       })
     },
+    // 日期名称格式化
+    formatDateTime(date, format) {
+      const o = {
+        'M+': date.getMonth() + 1, // 月份
+        'd+': date.getDate(), // 日
+        'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12, // 小时
+        'H+': date.getHours(), // 小时
+        'm+': date.getMinutes(), // 分
+        's+': date.getSeconds(), // 秒
+        'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
+        S: date.getMilliseconds(), // 毫秒
+        a: date.getHours() < 12 ? '上午' : '下午', // 上午/下午
+        A: date.getHours() < 12 ? 'AM' : 'PM', // AM/PM
+      };
+      if (/(y+)/.test(format)) {
+        format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
+      }
+      for (let k in o) {
+        if (new RegExp('(' + k + ')').test(format)) {
+          format = format.replace(
+            RegExp.$1,
+            RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
+          );
+        }
+      }
+      return format;
+    },
   }
 }
 </script>

+ 1 - 1
src/views/business/spd/target/targetMk/item.vue

@@ -30,7 +30,7 @@
               />
               <el-popover-tree-select 
                 size="mini" 
-                v-else-if="scope.row[head.prop].model == 'MATERIALCLASSIFY_PARAM' || scope.row[head.prop].model == 'PROFITCENTER'"
+                v-else-if="scope.row[head.prop].model == 'MATERIALCLASSIFY_PARAM' || scope.row[head.prop].model == 'PROFITCENTER' || scope.row[head.prop].model == 'PRODUCTLINE'"
                 v-model="scope.row[head.prop].valueName" 
                 valueKey='name'
                 title="参照选择"