|
@@ -92,6 +92,8 @@ export default window.$crudCommon({
|
|
|
},
|
|
},
|
|
|
defaultColumns: [],
|
|
defaultColumns: [],
|
|
|
|
|
|
|
|
|
|
+ oldMonthData: [],
|
|
|
|
|
+
|
|
|
wideTableColumns: [],
|
|
wideTableColumns: [],
|
|
|
printTitle: "",
|
|
printTitle: "",
|
|
|
};
|
|
};
|
|
@@ -111,6 +113,10 @@ export default window.$crudCommon({
|
|
|
this.option.column = deepClone(this.defaultColumns);
|
|
this.option.column = deepClone(this.defaultColumns);
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ handleBeforeOpen(done, type) {
|
|
|
|
|
+ this.oldMonthData = this.form.dailyAttendances || [];
|
|
|
|
|
+ done();
|
|
|
|
|
+ },
|
|
|
refreshTableCol(yearAndMonth) {
|
|
refreshTableCol(yearAndMonth) {
|
|
|
let yearMonth = moment(yearAndMonth).format("YYYY-MM").split("-");
|
|
let yearMonth = moment(yearAndMonth).format("YYYY-MM").split("-");
|
|
|
const monthDays = getMonthDatesWithMarkers(Number(yearMonth[0]), Number(yearMonth[1]));
|
|
const monthDays = getMonthDatesWithMarkers(Number(yearMonth[0]), Number(yearMonth[1]));
|
|
@@ -172,18 +178,32 @@ export default window.$crudCommon({
|
|
|
getFormData() {
|
|
getFormData() {
|
|
|
const newFormData = { ...this.form, yearAndMonth: this.params.yearAndMonth };
|
|
const newFormData = { ...this.form, yearAndMonth: this.params.yearAndMonth };
|
|
|
let dailyAttendances = [];
|
|
let dailyAttendances = [];
|
|
|
|
|
+ let _oldMonthData = this.oldMonthData;
|
|
|
Object.keys(this.form).forEach(key => {
|
|
Object.keys(this.form).forEach(key => {
|
|
|
if (key.indexOf(this.params.yearAndMonth) > -1) {
|
|
if (key.indexOf(this.params.yearAndMonth) > -1) {
|
|
|
- if (this.form[key]) {
|
|
|
|
|
|
|
+ let oldObj = _oldMonthData.find(old => old.workDate == key) || {};
|
|
|
|
|
+ if (this.form[key] || oldObj.workHours) {
|
|
|
dailyAttendances.push({
|
|
dailyAttendances.push({
|
|
|
workDate: key,
|
|
workDate: key,
|
|
|
- workHours: this.form[key]
|
|
|
|
|
|
|
+ workHours: this.form[key] || ''
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
delete newFormData[key];
|
|
delete newFormData[key];
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- newFormData.dailyAttendances = dailyAttendances;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 获取最新修改过的数据
|
|
|
|
|
+ let updatedMonthData = [];
|
|
|
|
|
+ dailyAttendances.forEach(item => {
|
|
|
|
|
+ let oldObj = _oldMonthData.find(old => item.workDate === old.workDate);
|
|
|
|
|
+ if (!!oldObj && Number(item.workHours) !== Number(oldObj.workHours)) {
|
|
|
|
|
+ updatedMonthData.push(item);
|
|
|
|
|
+ } else if (!oldObj) {
|
|
|
|
|
+ updatedMonthData.push(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ newFormData.dailyAttendances = updatedMonthData;
|
|
|
return newFormData;
|
|
return newFormData;
|
|
|
},
|
|
},
|
|
|
getDelParams(row) {
|
|
getDelParams(row) {
|