|
@@ -13,7 +13,7 @@
|
|
|
<text>{{item.label}}</text>
|
|
|
</view>
|
|
|
<view class="img-wrap" @click="checkModel(item)">
|
|
|
- <image :src="`../../static/check-${checkedItem.id === item.id
|
|
|
+ <image :src="`../../static/check-${checkPlan.checkedItem.id === item.id
|
|
|
? 'radio': 'no'}.png`"></image>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -23,8 +23,8 @@
|
|
|
<view>
|
|
|
<date-time-pick-group fields="day"
|
|
|
:startTime="startTime()"
|
|
|
- :startSelectValue="dateObj.start"
|
|
|
- :endSelectValue="dateObj.end"
|
|
|
+ :startSelectValue="checkPlan.dateObj.start"
|
|
|
+ :endSelectValue="checkPlan.dateObj.end"
|
|
|
v-on:changeDate="changeDate"></date-time-pick-group>
|
|
|
<image src="../../../static/incon-more.png"></image>
|
|
|
</view>
|
|
@@ -38,7 +38,7 @@
|
|
|
<view class="top-box">
|
|
|
<view class="result-box">
|
|
|
<text>开始日期</text>
|
|
|
- <text>{{dateObj.start}}</text>
|
|
|
+ <text>{{checkPlan.dateObj.start}}</text>
|
|
|
</view>
|
|
|
<view class="date-box">
|
|
|
<text>结束日期</text>
|
|
@@ -47,14 +47,14 @@
|
|
|
placeholder="请选择结束日期"
|
|
|
pickType="end"
|
|
|
:start="startTime()"
|
|
|
- :defaultValue="dateObj.end"
|
|
|
+ :defaultValue="checkPlan.dateObj.end"
|
|
|
v-on:change="changeDate"></date-time-picker>
|
|
|
<image src="../../../static/incon-more.png"></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="content2-list">
|
|
|
- <view class="item" v-for="(item, index) in checkList" :key="index">
|
|
|
+ <view class="item" v-for="(item, index) in checkPlan.checkList" :key="index">
|
|
|
<text>第{{index + 1}}次查核</text>
|
|
|
<view class="date-box">
|
|
|
<text>开始日期</text>
|
|
@@ -75,41 +75,35 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import {dateHandle} from "../../../utils/dateHandle.js";
|
|
|
import { mapState } from "vuex";
|
|
|
+ import {dateHandle} from "../../../utils/dateHandle.js";
|
|
|
const {dateDiff, getNewData, todayDate, compare} = dateHandle;
|
|
|
const list = [
|
|
|
- {id: 'week', label: '每周', model: 7},
|
|
|
- {id: 'month', label: '每月', model: 30},
|
|
|
- {id: 'twoMonth', label: '每两月', model: 60},
|
|
|
- {id: 'quarter', label: '每季度', model: 90},
|
|
|
- {id: 'halfAYear', label: '每半年', model: 180},
|
|
|
- {id: 'custom', label: '天', model: null},
|
|
|
+ {id: 'week', value: 1, label: '每周', model: 7},
|
|
|
+ {id: 'month', value: 2, label: '每月', model: 30},
|
|
|
+ {id: 'twoMonth', value: 3, label: '每两月', model: 60},
|
|
|
+ {id: 'quarter', value: 4, label: '每季度', model: 90},
|
|
|
+ {id: 'halfAYear', value: 5, label: '每半年', model: 180},
|
|
|
+ {id: 'custom', value: 6, label: '天', model: null},
|
|
|
];
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- list,
|
|
|
- checkedItem: list[1], // 选中的取模方式对象
|
|
|
- dateObj: { // 保存开始日期结束日期的对象
|
|
|
- start: todayDate(),
|
|
|
- end: '',
|
|
|
- dayNum: 0 // 两个日期间隔的天数
|
|
|
- },
|
|
|
- checkList: [], // 核查计划数组
|
|
|
+ list
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState({
|
|
|
showCheckPlan1: state => state.creatingSituations.showCheckPlan1,
|
|
|
+ checkPlan: state => state.creatingSituations.checkPlan,
|
|
|
}),
|
|
|
checkNumber: function() { // 查核频次
|
|
|
- return this.checkList.length;
|
|
|
+ return this.checkPlan.checkList.length;
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
checkModel: function(item) {
|
|
|
- this.checkedItem = item;
|
|
|
+ this.myCommit('checkedItem', item);
|
|
|
this.createList();
|
|
|
},
|
|
|
/**
|
|
@@ -118,10 +112,13 @@
|
|
|
* @param {Object} type 返回类型(start/end)
|
|
|
*/
|
|
|
changeDate: function(date, type) {
|
|
|
- this.dateObj[type] = date.f1;
|
|
|
- const {start, end} = this.dateObj;
|
|
|
+ let dateObj = {...this.checkPlan.dateObj};
|
|
|
+ dateObj[type] = date.f1;
|
|
|
+ this.myCommit('dateObj', dateObj);
|
|
|
+ const {start, end} = dateObj;
|
|
|
if(start && end) {
|
|
|
- this.dateObj.dayNum = dateDiff(start, end);
|
|
|
+ dateObj.dayNum = dateDiff(start, end);
|
|
|
+ this.myCommit('dateObj', dateObj);
|
|
|
this.createList();
|
|
|
}
|
|
|
},
|
|
@@ -129,51 +126,65 @@
|
|
|
* 构造计划列表
|
|
|
*/
|
|
|
createList: function() {
|
|
|
- const { model } = this.checkedItem;
|
|
|
- const {start, dayNum} = this.dateObj;
|
|
|
+ const { model } = this.checkPlan.checkedItem;
|
|
|
+ const {start, dayNum} = this.checkPlan.dateObj;
|
|
|
+ let checkList = [];
|
|
|
if(model && dayNum > 0) { // 确保前两步都做好了
|
|
|
let num = Math.floor(dayNum / model);
|
|
|
- this.checkList = [start];
|
|
|
+ checkList = [start];
|
|
|
for(let i = 0; i < num - 1; i++) {
|
|
|
- this.checkList[i+1] = getNewData(this.checkList[i], model);
|
|
|
+ checkList[i+1] = getNewData(checkList[i], model);
|
|
|
}
|
|
|
- } else {
|
|
|
- this.checkList = [];
|
|
|
}
|
|
|
+ this.myCommit('checkList', checkList);
|
|
|
},
|
|
|
/**
|
|
|
* 已经生成的计划日期变化
|
|
|
* @param {Object} date
|
|
|
*/
|
|
|
changeChildDate: function(date, index) {
|
|
|
- let newList = this.checkList.slice(0, index); // 不包括index
|
|
|
+ let newList = this.checkPlan.checkList.slice(0, index); // 不包括index
|
|
|
newList[index] = date.f1;
|
|
|
- const { model } = this.checkedItem;
|
|
|
+ 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.checkList = newList;
|
|
|
+ this.myCommit('checkList', newList);
|
|
|
},
|
|
|
startTime: function() { // 限制只能从今天开始
|
|
|
return this.formateStartEnd(todayDate());
|
|
|
},
|
|
|
endDate: function() { // 获取能选择的最大日期,取结束日期的前模天
|
|
|
- let day = -Number(this.checkedItem.model); // 使用负数能取前X天
|
|
|
- return getNewData(this.dateObj.end, day);
|
|
|
+ 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.checkedItem.model);
|
|
|
- return this.formateStartEnd(getNewData(this.checkList[index - 1], day));
|
|
|
+ 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';
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 更新condition数据
|
|
|
+ * @param {Object} key 要更新的属性
|
|
|
+ * @param {Object} value 值
|
|
|
+ */
|
|
|
+ myCommit: function(key, value) {
|
|
|
+ let data = {...this.checkPlan};
|
|
|
+ data[key] = value;
|
|
|
+ this.$store.commit({
|
|
|
+ type: 'creatingSituations/comChangeState',
|
|
|
+ key: 'checkPlan',
|
|
|
+ data
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|