Browse Source

目标管理-目标模板中重算周期名称改为范围;营销商机-拜访计划中更改开始时间其它的时间字段跟着一起改变

DongZ 1 year ago
parent
commit
4e879e174f

+ 42 - 2
src/views/business/spd/bo/plan/add.vue

@@ -54,8 +54,8 @@
             <el-form-item label="开始时间" prop="startDate"
               :rules="{ required: true, message: '请选择开始时间', trigger: 'blur' }">
               <el-date-picker v-model="basicForm.startDate" :disabled="sonDisable" clearable type="date"
-                value-format="yyyy-MM-dd 00:00:00" :picker-options="pickerOptionsStart" size="mini" style="width: 200px"
-                placeholder="选择开始时间">
+                @change="setDateRange(basicForm.startDate)" value-format="yyyy-MM-dd 00:00:00"
+                :picker-options="pickerOptionsStart" size="mini" style="width: 200px" placeholder="选择开始时间">
               </el-date-picker>
             </el-form-item>
           </el-col>
@@ -697,6 +697,46 @@
           h('span', ' ' + column.label)
         ];
       },
+      //改变开始时间时其它时间字段随之改变
+      setDateRange(startDate) {
+        console.log(startDate);
+        let newDate = new Date(startDate);
+        newDate.setDate(newDate.getDate() + this.basicForm.mkBoPlanItemList.length - 1);
+        this.basicForm.deadlineTime = this.formatDateTime(newDate, 'yyyy-MM-dd 00:00:00');
+        console.log(startDate);
+        let newDateGoal = new Date(startDate);
+        for (let i = 0; i < this.basicForm.mkBoPlanItemList.length; i++) {
+          this.basicForm.mkBoPlanItemList[i].date = this.formatDateTime(newDateGoal, 'yyyy-MM-dd 00:00:00');
+          newDateGoal.setDate(newDateGoal.getDate() + 1);
+        }
+      },
+      //日期名称格式化
+      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;
+      },
     }
   }
 

+ 7 - 5
src/views/business/spd/target/targetTemplate/detail.vue

@@ -127,12 +127,12 @@
                     <el-tab-pane label="周期" name="cycles">
                         <el-table :data="form.cycles" height="600px" size="size" v-horizontal-scroll>
                             <el-table-column label="序号" type="index" width="50" align="center" fixed/>
-                            <el-table-column show-overflow-tooltip label="周期" align="center" width="200" prop="name">
+                            <el-table-column show-overflow-tooltip label="周期" align="center" width="250" prop="name">
                                 <template slot-scope="scope">
                                     <el-input
                                         size="mini"
                                         v-model="scope.row.name"
-                                        style="width: 150px"
+                                        style="width: 200px"
                                         clearable
                                     />
                                 </template>
@@ -415,7 +415,7 @@ export default {
       deadline.setHours( 0, 0, 0);
       if(this.form.cycle == 'period'){
         cycles.push({
-          name:'目标期间',
+          name:this.formatDateTime(start, 'yyyy-MM-dd') + '到' + this.formatDateTime(deadline, 'yyyy-MM-dd'),
           startTime:this.formatDateTime(start, 'yyyy-MM-dd'),
           deadlineTime:this.formatDateTime(deadline, 'yyyy-MM-dd'),
         });
@@ -432,10 +432,11 @@ export default {
           }
           if(this.form.cycle == 'week'){
             var cy = {};
-            cy.name = this.formatDateTime(start, 'yyyy-MM-dd');
+            let date = this.formatDateTime(start, 'yyyy-MM-dd');
             cy.startTime = this.formatDateTime(start, 'yyyy-MM-dd');
             start.setDate(start.getDate()+6);
             cy.deadlineTime = this.formatDateTime(start, 'yyyy-MM-dd');
+            cy.name = date + '到' + this.formatDateTime(start, 'yyyy-MM-dd');
             cycles.push(cy);
             start.setDate(start.getDate()+1);
           }
@@ -452,10 +453,11 @@ export default {
           }
           if(this.form.cycle == 'season'){
             var cy = {};
-            cy.name = this.formatDateTime(start, 'yyyy-MM');
+            let date = this.formatDateTime(start, 'yyyy-MM');
             cy.startTime = this.formatDateTime(start, 'yyyy-MM-dd');
             start.setDate(start.getDate()+90);
             cy.deadlineTime = this.formatDateTime(start, 'yyyy-MM-dd');
+            cy.name = date + '到' + this.formatDateTime(start, 'yyyy-MM');
             cycles.push(cy);
             start.setDate(start.getDate()+1);
           }