|
@@ -45,10 +45,9 @@
|
|
|
<view>
|
|
|
<date-time-picker fields="day"
|
|
|
placeholder="请选择结束日期"
|
|
|
- pickType="end"
|
|
|
- :start="checkPlan.dateObj.start"
|
|
|
+ :start="endStart"
|
|
|
:defaultValue="checkPlan.dateObj.end"
|
|
|
- v-on:change="changeDate"></date-time-picker>
|
|
|
+ v-on:change="changeDateEnd"></date-time-picker>
|
|
|
<image src="../../../static/incon-more.png"></image>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -61,7 +60,7 @@
|
|
|
<view>
|
|
|
<date-time-picker fields="day"
|
|
|
:start="startDate(index)"
|
|
|
- :end="formateStartEnd(endDate())"
|
|
|
+ :end="endDate(index)"
|
|
|
placeholder="请选择开始日期"
|
|
|
:defaultValue="item"
|
|
|
v-on:change="changeChildDate($event, index)"></date-time-picker>
|
|
@@ -85,7 +84,8 @@
|
|
|
return {
|
|
|
list: checkPlanList,
|
|
|
start: todayDate(),
|
|
|
- end: ''
|
|
|
+ end: '',
|
|
|
+ timer: null
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -95,7 +95,41 @@
|
|
|
}),
|
|
|
checkNumber: function() { // 查核频次
|
|
|
return this.checkPlan.checkList.length;
|
|
|
- }
|
|
|
+ },
|
|
|
+ endStart() {
|
|
|
+ const {checkList, checkedItem} = this.checkPlan;
|
|
|
+ let date = '';
|
|
|
+ if(checkList.length>0) {
|
|
|
+ date = getNewData(checkList[checkList.length-1], checkedItem.model)
|
|
|
+ } else {
|
|
|
+ date = this.start;
|
|
|
+ }
|
|
|
+ return date + ' 00:00';
|
|
|
+ },
|
|
|
+ endDate() { // 获取能选择的最大日期,取结束日期的前模天
|
|
|
+ return function(index) {
|
|
|
+ let day = -Number(this.checkPlan.checkedItem.model); // 使用负数能取前X天
|
|
|
+ let date = '';
|
|
|
+ if(index < this.checkPlan.checkList.length -1) {
|
|
|
+ date = getNewData(this.checkPlan.checkList[index+1], day);
|
|
|
+ } else {
|
|
|
+ date = getNewData(this.end, day+1);
|
|
|
+ }
|
|
|
+ return date + ' 23:59';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ startDate() { // 子级能选择的最早开始时间
|
|
|
+ return function(index) {
|
|
|
+ let date = '';
|
|
|
+ if(index > 0) {
|
|
|
+ let day = Number(this.checkPlan.checkedItem.model);
|
|
|
+ date = getNewData(this.checkPlan.checkList[index - 1], day);
|
|
|
+ } else {
|
|
|
+ date = this.start;
|
|
|
+ }
|
|
|
+ return date + ' 00:00';
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
created: function() {
|
|
|
const {start,end} = this.checkPlan.dateObj;
|
|
@@ -137,6 +171,13 @@
|
|
|
this.myCommit('dateObj', dateObj);
|
|
|
}
|
|
|
},
|
|
|
+ changeDateEnd(date) {
|
|
|
+ let dateObj = JSON.parse(JSON.stringify(this.checkPlan.dateObj));
|
|
|
+ dateObj.end = date.f1;
|
|
|
+ this.end = date.f1;
|
|
|
+ this.myCommit('dateObj', dateObj);
|
|
|
+ this.changeList(this.checkPlan.checkList);
|
|
|
+ },
|
|
|
/**
|
|
|
* 构造计划列表
|
|
|
*/
|
|
@@ -158,32 +199,27 @@
|
|
|
* @param {Object} date
|
|
|
*/
|
|
|
changeChildDate: function(date, index) {
|
|
|
- let newList = this.checkPlan.checkList.slice(0, index); // 不包括index
|
|
|
+ let newList = [...this.checkPlan.checkList];
|
|
|
newList[index] = date.f1;
|
|
|
- const { model } = this.checkPlan.checkedItem;
|
|
|
- let i = index;
|
|
|
- // 判断下一个计划开始时间日期不能大于结束的前X(模)天
|
|
|
- while(compare(this.endDate(), getNewData(newList[i], model))) {
|
|
|
- newList[i+1] = getNewData(newList[i], model);
|
|
|
- i++;
|
|
|
- }
|
|
|
- this.myCommit('checkList', newList);
|
|
|
+ // const { model } = this.checkPlan.checkedItem;
|
|
|
+ // let i = index;
|
|
|
+ // // 判断下一个计划开始时间日期不能大于结束的前X(模)天
|
|
|
+ // while(compare(this.endDate(), getNewData(newList[i], model))) {
|
|
|
+ // newList[i+1] = getNewData(newList[i], model);
|
|
|
+ // i++;
|
|
|
+ // }
|
|
|
+ this.changeList(newList);
|
|
|
+ },
|
|
|
+ changeList(checkList){
|
|
|
+ if(this.timer) clearTimeout(this.timer);
|
|
|
+ this.myCommit('checkList', []);
|
|
|
+ this.timer = setTimeout(()=>{
|
|
|
+ this.myCommit('checkList', checkList);
|
|
|
+ },0);
|
|
|
},
|
|
|
startTime: function() { // 限制只能从今天开始
|
|
|
return this.formateStartEnd(todayDate());
|
|
|
},
|
|
|
- endDate: function() { // 获取能选择的最大日期,取结束日期的前模天
|
|
|
- let day = -Number(this.checkPlan.checkedItem.model); // 使用负数能取前X天
|
|
|
- return getNewData(this.checkPlan.dateObj.end, day);
|
|
|
- },
|
|
|
- startDate: function(index) { // 子级能选择的最早开始时间
|
|
|
- if(index > 0) {
|
|
|
- let day = Number(this.checkPlan.checkedItem.model);
|
|
|
- return this.formateStartEnd(getNewData(this.checkPlan.checkList[index - 1], day));
|
|
|
- } else {
|
|
|
- return this.startTime();
|
|
|
- }
|
|
|
- },
|
|
|
formateStartEnd: function(str) {
|
|
|
return str + ' 00:00';
|
|
|
},
|