|
|
@ -165,7 +165,7 @@ import { getuuid } from "@/utils/index.js"; |
|
|
import moment from "moment"; |
|
|
import moment from "moment"; |
|
|
import _ from "lodash"; |
|
|
import _ from "lodash"; |
|
|
export default { |
|
|
export default { |
|
|
inject: ['templateFillType', 'getZdxgjl'], |
|
|
|
|
|
|
|
|
inject: ['templateFillType', 'getZdxgjl', 'updateZdxgjl'], |
|
|
name: 'CustomTable', |
|
|
name: 'CustomTable', |
|
|
components: { |
|
|
components: { |
|
|
HandleFormItem |
|
|
HandleFormItem |
|
|
@ -246,15 +246,15 @@ export default { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
|
|
|
EventBus.$on('onEditSignCallback', this.handleEditSignCallback); |
|
|
|
|
|
EventBus.$on('onFormEditSignCancel', this.handleEditSignCancel); |
|
|
|
|
|
}, |
|
|
|
|
|
unmounted() { |
|
|
|
|
|
|
|
|
mounted() { |
|
|
|
|
|
EventBus.$on('onEditSignCallback', this.handleEditSignCallback); |
|
|
|
|
|
EventBus.$on('onFormEditSignCancel', this.handleEditSignCancel); |
|
|
|
|
|
}, |
|
|
|
|
|
unmounted() { |
|
|
this.oldLocalDataSource = []; |
|
|
this.oldLocalDataSource = []; |
|
|
EventBus.$off('onEditSignCallback', this.handleEditSignCallback); |
|
|
|
|
|
EventBus.$off('onFormEditSignCancel', this.handleEditSignCancel); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
EventBus.$off('onEditSignCallback', this.handleEditSignCallback); |
|
|
|
|
|
EventBus.$off('onFormEditSignCancel', this.handleEditSignCancel); |
|
|
|
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
handleEditSignCancel(data) { |
|
|
handleEditSignCancel(data) { |
|
|
if (data.uuid === this.uuid) { |
|
|
if (data.uuid === this.uuid) { |
|
|
@ -263,7 +263,7 @@ export default { |
|
|
}, |
|
|
}, |
|
|
handleEditSignCallback(data) { |
|
|
handleEditSignCallback(data) { |
|
|
if (data.uuid === this.uuid) { |
|
|
if (data.uuid === this.uuid) { |
|
|
this.updateRecord(); |
|
|
|
|
|
|
|
|
this.updateRecords(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
getRecords() { |
|
|
getRecords() { |
|
|
@ -295,8 +295,9 @@ export default { |
|
|
title: oldValue ? "修改" : "提交", |
|
|
title: oldValue ? "修改" : "提交", |
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
}; |
|
|
}; |
|
|
this.getZdxgjl().unshift(record); |
|
|
|
|
|
|
|
|
this.updateZdxgjl(record); |
|
|
records.push(record); |
|
|
records.push(record); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (col.bodySubKey) { |
|
|
if (col.bodySubKey) { |
|
|
@ -317,7 +318,7 @@ export default { |
|
|
title: oldSubValue ? "修改" : "提交", |
|
|
title: oldSubValue ? "修改" : "提交", |
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
}; |
|
|
}; |
|
|
this.getZdxgjl().unshift(record); |
|
|
|
|
|
|
|
|
this.updateZdxgjl(record); |
|
|
records.push(record); |
|
|
records.push(record); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -342,7 +343,7 @@ export default { |
|
|
title: oldOtherValue ? "修改" : "提交", |
|
|
title: oldOtherValue ? "修改" : "提交", |
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
}; |
|
|
}; |
|
|
this.getZdxgjl().unshift(record); |
|
|
|
|
|
|
|
|
this.updateZdxgjl(record); |
|
|
records.push(record); |
|
|
records.push(record); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -351,21 +352,27 @@ export default { |
|
|
|
|
|
|
|
|
return records; |
|
|
return records; |
|
|
}, |
|
|
}, |
|
|
updateRecord() { |
|
|
|
|
|
const records = this.getRecords(); |
|
|
|
|
|
const params = { |
|
|
|
|
|
type: "fieldChanged", |
|
|
|
|
|
newRecord: records, |
|
|
|
|
|
resourceList: this.getZdxgjl(), |
|
|
|
|
|
} |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
|
updateRecords() { |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
const records = this.getRecords(); |
|
|
|
|
|
const params = { |
|
|
|
|
|
type: "fieldChanged", |
|
|
|
|
|
newRecord: records, |
|
|
|
|
|
resourceList: this.getZdxgjl(), |
|
|
|
|
|
source: "customTable", |
|
|
|
|
|
} |
|
|
|
|
|
if (records.length == 0) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
console.log(records, "records") |
|
|
EventBus.$emit('onModifyRecord', params); |
|
|
EventBus.$emit('onModifyRecord', params); |
|
|
}, 0); |
|
|
|
|
|
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); |
|
|
|
|
|
|
|
|
this.oldLocalDataSource = []; |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
//取消按钮 重置记录 |
|
|
//取消按钮 重置记录 |
|
|
resetRecord(rowIndex, colIndex,) { |
|
|
resetRecord(rowIndex, colIndex,) { |
|
|
if(this.localDataSource.length){ |
|
|
|
|
|
|
|
|
if (this.localDataSource.length) { |
|
|
this.localDataSource = [...this.oldLocalDataSource]; |
|
|
this.localDataSource = [...this.oldLocalDataSource]; |
|
|
this.oldLocalDataSource = []; |
|
|
this.oldLocalDataSource = []; |
|
|
} |
|
|
} |
|
|
@ -561,7 +568,7 @@ export default { |
|
|
}, |
|
|
}, |
|
|
// 表头选择器变化 |
|
|
// 表头选择器变化 |
|
|
onHeaderSelectChange(col, value) { |
|
|
onHeaderSelectChange(col, value) { |
|
|
if(col.headerSelectTo){ |
|
|
|
|
|
|
|
|
if (col.headerSelectTo) { |
|
|
this.headerSelectFields[col.headerSelectTo] = value; |
|
|
this.headerSelectFields[col.headerSelectTo] = value; |
|
|
} |
|
|
} |
|
|
this.headerSelectFields[col.headerSelectKey] = value; |
|
|
this.headerSelectFields[col.headerSelectKey] = value; |
|
|
@ -719,50 +726,54 @@ export default { |
|
|
this.localDataSource = JSON.parse(JSON.stringify(dataSource || [])); |
|
|
this.localDataSource = JSON.parse(JSON.stringify(dataSource || [])); |
|
|
}, |
|
|
}, |
|
|
// 根据行索引更新数据 autoUpdateRecord 是否自动更新记录 |
|
|
// 根据行索引更新数据 autoUpdateRecord 是否自动更新记录 |
|
|
updateDataSourceByRowIndex(rowIndex, data,autoUpdateRecord = true) { |
|
|
|
|
|
|
|
|
updateDataSourceByRowIndex(rowIndex, data, type) { |
|
|
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); |
|
|
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); |
|
|
if(autoUpdateRecord){//如果formpackage联动table的情况,不需要自动更新,不然会出现多个弹窗的问题。 |
|
|
|
|
|
this.showEditSignDialog(rowIndex,data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (type === "clickable") {//如果是custom内部的clickable需要判断是否弹窗 |
|
|
|
|
|
this.showEditSignDialog(rowIndex,data); |
|
|
|
|
|
}else if(type === "blur"){ |
|
|
|
|
|
this.updateRecords(); |
|
|
|
|
|
} |
|
|
this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data }; |
|
|
this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data }; |
|
|
this.localDataSource = [...this.localDataSource]; |
|
|
this.localDataSource = [...this.localDataSource]; |
|
|
}, |
|
|
}, |
|
|
showEditSignDialog: _.debounce(function(rowIndex,data){ |
|
|
|
|
|
|
|
|
showEditSignDialog: _.debounce(function (rowIndex, data) { |
|
|
const oldData = this.oldLocalDataSource[rowIndex]; |
|
|
const oldData = this.oldLocalDataSource[rowIndex]; |
|
|
let isFirst = false;//是否是第一次添加,是否和旧数据相同 |
|
|
let isFirst = false;//是否是第一次添加,是否和旧数据相同 |
|
|
const isSame = this.compareOldAndCurrentFormFields(data,oldData); |
|
|
|
|
|
|
|
|
const isSame = this.compareOldAndCurrentFormFields(data, oldData); |
|
|
// 遍历data对象,和oldData比较,判断data的key值在对应oldData里面是否有值 |
|
|
// 遍历data对象,和oldData比较,判断data的key值在对应oldData里面是否有值 |
|
|
for(const key in data) { |
|
|
|
|
|
if(!oldData[key]&&oldData[key]!=0){ |
|
|
|
|
|
|
|
|
for (const key in data) { |
|
|
|
|
|
if (!oldData[key] && oldData[key] != 0) { |
|
|
isFirst = true; |
|
|
isFirst = true; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(!isFirst &&!isSame && this.templateFillType === "actFill"){ |
|
|
|
|
|
|
|
|
if (!isFirst && !isSame && this.templateFillType === "actFill") { |
|
|
console.log("showww") |
|
|
console.log("showww") |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
EventBus.$emit('showEditSignDialog', { uuid: this.uuid }); |
|
|
EventBus.$emit('showEditSignDialog', { uuid: this.uuid }); |
|
|
}, 100); |
|
|
}, 100); |
|
|
}else{ |
|
|
|
|
|
this.updateRecord(rowIndex,data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
console.log("not show") |
|
|
|
|
|
this.updateRecords(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, 100), |
|
|
}, 100), |
|
|
// 比较newData和oldData的值是否相等,只要有一对不相等就返回false |
|
|
|
|
|
compareOldAndCurrentFormFields(newData,oldData) { |
|
|
|
|
|
for (const key in newData) { |
|
|
|
|
|
|
|
|
// 比较newData和oldData的值是否相等,只要有一对不相等就返回false |
|
|
|
|
|
compareOldAndCurrentFormFields(newData, oldData) { |
|
|
|
|
|
for (const key in newData) { |
|
|
const oldValue = newData[key]; |
|
|
const oldValue = newData[key]; |
|
|
const currentValue = oldData[key]; |
|
|
const currentValue = oldData[key]; |
|
|
if (JSON.stringify(oldValue) !== JSON.stringify(currentValue)) { |
|
|
if (JSON.stringify(oldValue) !== JSON.stringify(currentValue)) { |
|
|
return false; |
|
|
return false; |
|
|
} else { |
|
|
} else { |
|
|
return false; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
}, |
|
|
onAddRow() { |
|
|
onAddRow() { |
|
|
this.addRow({ |
|
|
this.addRow({ |
|
|
actSolutionVolumePrecision: 3,//小数点精度默认为3 |
|
|
actSolutionVolumePrecision: 3,//小数点精度默认为3 |
|
|
@ -778,7 +789,7 @@ export default { |
|
|
getDataSource() { |
|
|
getDataSource() { |
|
|
return this.localDataSource; |
|
|
return this.localDataSource; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断表单项是否有错误 |
|
|
// 判断表单项是否有错误 |
|
|
hasError(rowIndex, colIndex, field) { |
|
|
hasError(rowIndex, colIndex, field) { |
|
|
return this.formErrors.some(error => |
|
|
return this.formErrors.some(error => |
|
|
|