|
|
@ -82,6 +82,16 @@ |
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div class="flex flex1" v-else-if="isRegent(col,'bodyType')"> |
|
|
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex" |
|
|
|
|
|
:fieldItemLabel="fieldItemLabel" :type="col.bodyType" class="body-clickable" |
|
|
|
|
|
sourceFrom = "customTable" |
|
|
|
|
|
:item="getBodyItem(col, rowIndex)" :value="row[col.prop]" |
|
|
|
|
|
:error="hasError(rowIndex, colIndex, col.prop)" |
|
|
|
|
|
@onRegentSubmit="(data)=>onRegentSubmit(data,col, rowIndex, colIndex, row)" |
|
|
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
|
|
|
</div> |
|
|
<template v-else-if="col.bodyType === 'span'"> |
|
|
<template v-else-if="col.bodyType === 'span'"> |
|
|
<div class="body-span"> |
|
|
<div class="body-span"> |
|
|
{{ row[col.prop] }} |
|
|
{{ row[col.prop] }} |
|
|
@ -162,6 +172,7 @@ import { isEqual } from "@/utils/index.js"; |
|
|
import { isShowOther } from "@/utils/formPackageCommon.js"; |
|
|
import { isShowOther } from "@/utils/formPackageCommon.js"; |
|
|
import { EventBus } from "@/utils/eventBus"; |
|
|
import { EventBus } from "@/utils/eventBus"; |
|
|
import { getuuid } from "@/utils/index.js"; |
|
|
import { getuuid } from "@/utils/index.js"; |
|
|
|
|
|
import { isRegent } from "@/utils/index.js"; |
|
|
import moment from "moment"; |
|
|
import moment from "moment"; |
|
|
import _ from "lodash"; |
|
|
import _ from "lodash"; |
|
|
export default { |
|
|
export default { |
|
|
@ -222,6 +233,7 @@ export default { |
|
|
isShowOther, |
|
|
isShowOther, |
|
|
oldLocalDataSource: [], |
|
|
oldLocalDataSource: [], |
|
|
uuid: getuuid(), |
|
|
uuid: getuuid(), |
|
|
|
|
|
isRegent, |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
|
@ -247,144 +259,14 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
EventBus.$on('onEditSignCallback', this.handleEditSignCallback); |
|
|
|
|
|
EventBus.$on('onFormEditSignCancel', this.handleEditSignCancel); |
|
|
|
|
|
}, |
|
|
}, |
|
|
unmounted() { |
|
|
unmounted() { |
|
|
this.oldLocalDataSource = []; |
|
|
this.oldLocalDataSource = []; |
|
|
EventBus.$off('onEditSignCallback', this.handleEditSignCallback); |
|
|
|
|
|
EventBus.$off('onFormEditSignCancel', this.handleEditSignCancel); |
|
|
|
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
handleEditSignCancel(data) { |
|
|
|
|
|
if (data.uuid === this.uuid) { |
|
|
|
|
|
this.resetRecord(); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
handleEditSignCallback(data) { |
|
|
|
|
|
if (data.uuid === this.uuid) { |
|
|
|
|
|
this.updateRecords(data); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
getRecords(data) { |
|
|
|
|
|
const records = []; |
|
|
|
|
|
const { nickName, name } = this.$store.getters; |
|
|
|
|
|
const { oldLocalDataSource, localDataSource, columns, prefixKey, fieldItemLabel } = this; |
|
|
|
|
|
|
|
|
|
|
|
localDataSource.forEach((row, rowIndex) => { |
|
|
|
|
|
const oldRow = oldLocalDataSource[rowIndex]; |
|
|
|
|
|
if (!oldRow) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
columns.forEach((col, colIndex) => { |
|
|
|
|
|
const oldValue = oldRow[col.prop]; |
|
|
|
|
|
const newValue = row[col.prop]; |
|
|
|
|
|
// 空值不提交 |
|
|
|
|
|
if(this.isValueEmpty(newValue) && this.isValueEmpty(oldValue)){ |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!isEqual(oldValue, newValue)) { |
|
|
|
|
|
const fieldLabelCn = this.$i18n.t(col.label, "zh_CN"); |
|
|
|
|
|
const fieldLabelEn = this.$i18n.t(col.label, "en_US"); |
|
|
|
|
|
const record = { |
|
|
|
|
|
userNameCn: nickName, |
|
|
|
|
|
userNameEn: name, |
|
|
|
|
|
key: prefixKey + '_' + col.prop + '_' + rowIndex, |
|
|
|
|
|
fieldCn: `${this.$i18n.t(fieldItemLabel, "zh_CN")}-${fieldLabelCn}`, |
|
|
|
|
|
fieldEn: `${this.$i18n.t(fieldItemLabel, "en_US")}-${fieldLabelEn}`, |
|
|
|
|
|
oldValue: oldValue, |
|
|
|
|
|
value: newValue, |
|
|
|
|
|
title: oldValue ? "修改" : "提交", |
|
|
|
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
|
|
|
}; |
|
|
|
|
|
if (data) { |
|
|
|
|
|
record.reason = data.remark |
|
|
|
|
|
} |
|
|
|
|
|
this.updateZdxgjl(record); |
|
|
|
|
|
records.push(record); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (col.bodySubKey) { |
|
|
|
|
|
const oldSubValue = oldRow[col.bodySubKey]; |
|
|
|
|
|
const newSubValue = row[col.bodySubKey]; |
|
|
|
|
|
if(this.isValueEmpty(newSubValue) && this.isValueEmpty(oldSubValue)){ |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (!isEqual(oldSubValue, newSubValue)) { |
|
|
|
|
|
const fieldLabelCn = this.$i18n.t(col.label, "zh_CN"); |
|
|
|
|
|
const fieldLabelEn = this.$i18n.t(col.label, "en_US"); |
|
|
|
|
|
const record = { |
|
|
|
|
|
userNameCn: nickName, |
|
|
|
|
|
userNameEn: name, |
|
|
|
|
|
key: prefixKey + '_' + col.bodySubKey + '_' + rowIndex, |
|
|
|
|
|
fieldCn: `${this.$i18n.t(fieldItemLabel, "zh_CN")}-${fieldLabelCn}单位`, |
|
|
|
|
|
fieldEn: `${this.$i18n.t(fieldItemLabel, "en_US")}-${fieldLabelEn}单位`, |
|
|
|
|
|
oldValue: oldSubValue, |
|
|
|
|
|
value: newSubValue, |
|
|
|
|
|
title: oldSubValue ? "修改" : "提交", |
|
|
|
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
|
|
|
}; |
|
|
|
|
|
if (data) { |
|
|
|
|
|
record.reason = data.remark |
|
|
|
|
|
} |
|
|
|
|
|
this.updateZdxgjl(record); |
|
|
|
|
|
records.push(record); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (col.otherCode) { |
|
|
|
|
|
const oldOtherValue = oldRow[col.otherCode]; |
|
|
|
|
|
const newOtherValue = row[col.otherCode]; |
|
|
|
|
|
|
|
|
|
|
|
if (!isEqual(oldOtherValue, newOtherValue)) { |
|
|
|
|
|
const fieldLabelCn = this.$i18n.t(col.label, "zh_CN"); |
|
|
|
|
|
const fieldLabelEn = this.$i18n.t(col.label, "en_US"); |
|
|
|
|
|
const otherLabelCn = col.otherLabel ? this.$i18n.t(col.otherLabel, "zh_CN") : this.$i18n.t("template.common.other", "zh_CN"); |
|
|
|
|
|
const otherLabelEn = col.otherLabel ? this.$i18n.t(col.otherLabel, "en_US") : this.$i18n.t("template.common.other", "en_US"); |
|
|
|
|
|
const record = { |
|
|
|
|
|
userNameCn: nickName, |
|
|
|
|
|
userNameEn: name, |
|
|
|
|
|
key: prefixKey + '_' + col.otherCode + '_' + rowIndex, |
|
|
|
|
|
fieldCn: `${this.$i18n.t(fieldItemLabel, "zh_CN")}-${fieldLabelCn}${otherLabelCn}`, |
|
|
|
|
|
fieldEn: `${this.$i18n.t(fieldItemLabel, "en_US")}-${fieldLabelEn}${otherLabelEn}`, |
|
|
|
|
|
oldValue: oldOtherValue, |
|
|
|
|
|
value: newOtherValue, |
|
|
|
|
|
title: oldOtherValue ? "修改" : "提交", |
|
|
|
|
|
time: moment().format("YYYY-MM-DD HH:mm:ss"), |
|
|
|
|
|
}; |
|
|
|
|
|
if (data) { |
|
|
|
|
|
record.reason = data.remark |
|
|
|
|
|
} |
|
|
|
|
|
this.updateZdxgjl(record); |
|
|
|
|
|
records.push(record); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return records; |
|
|
|
|
|
}, |
|
|
|
|
|
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); |
|
|
|
|
|
this.oldLocalDataSource = []; |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//取消按钮 重置记录 |
|
|
//取消按钮 重置记录 |
|
|
resetRecord(rowIndex, colIndex,) { |
|
|
resetRecord(rowIndex, colIndex,) { |
|
|
if (this.localDataSource.length) { |
|
|
if (this.localDataSource.length) { |
|
|
@ -422,6 +304,12 @@ export default { |
|
|
} |
|
|
} |
|
|
this.$emit("clickable", col, rowIndex, row) |
|
|
this.$emit("clickable", col, rowIndex, row) |
|
|
}, |
|
|
}, |
|
|
|
|
|
onRegentSubmit(data, col, rowIndex, colIndex, row){ |
|
|
|
|
|
if (this.templateFillType !== 'actFill') { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
this.$emit("onRegentSubmit", {selectInfo:data,key:col.prop, col, rowIndex, colIndex, rowData:row}) |
|
|
|
|
|
}, |
|
|
isShowAddRos() { |
|
|
isShowAddRos() { |
|
|
if (this.showAddRow !== undefined) { |
|
|
if (this.showAddRow !== undefined) { |
|
|
return this.showAddRow |
|
|
return this.showAddRow |
|
|
@ -744,11 +632,11 @@ export default { |
|
|
// 根据行索引更新数据 autoUpdateRecord 是否自动更新记录 |
|
|
// 根据行索引更新数据 autoUpdateRecord 是否自动更新记录 |
|
|
updateDataSourceByRowIndex(rowIndex, data, type) { |
|
|
updateDataSourceByRowIndex(rowIndex, data, type) { |
|
|
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); |
|
|
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); |
|
|
if (type === "clickable") {//如果是custom内部的clickable需要判断是否弹窗 |
|
|
|
|
|
this.showEditSignDialog(rowIndex,data); |
|
|
|
|
|
}else if(type === "blur"){ |
|
|
|
|
|
this.updateRecords(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 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]; |
|
|
this.checkCompareToOnDataLoad(); |
|
|
this.checkCompareToOnDataLoad(); |
|
|
|