|
|
|
@ -9,7 +9,8 @@ |
|
|
|
<div>{{ $t(col.label) }}</div> |
|
|
|
<template |
|
|
|
v-if="col.headerSelectKey && col.headerOptions && (showHeaderSelect || templateFillType === 'preFill')"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey+'_'+col.headerSelectKey" :fieldItemLabel="fieldItemLabel" type="select" class="header-select" :item="getHeaderItem(col)" |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.headerSelectKey" :fieldItemLabel="fieldItemLabel" |
|
|
|
type="select" class="header-select" :item="getHeaderItem(col)" |
|
|
|
v-model="headerSelectFields[col.headerSelectKey]" @change="onHeaderSelectChange(col, $event)" |
|
|
|
:error="hasError(-1, index, col.headerSelectKey)" |
|
|
|
@update:error="onErrorUpdate(-1, index, col.headerSelectKey, $event)" /> |
|
|
|
@ -36,34 +37,52 @@ |
|
|
|
<div class="inner-table-cell"> |
|
|
|
<div class="flex1"> |
|
|
|
<template v-if="col.bodyType === 'input'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey+'_'+col.prop+'_'+rowIndex" :fieldItemLabel="fieldItemLabel" type="input" @blur="onBlur(rowIndex, col.prop, $event)" @copy="onCopy(rowIndex, col)" |
|
|
|
class="body-input" :item="getBodyItem(col, rowIndex)" v-model="row[col.prop]" |
|
|
|
@change="onBodyValueChange(rowIndex, colIndex, $event)" |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="input" @blur="onBlur(rowIndex, col.prop, $event)" |
|
|
|
@copy="onCopy(rowIndex, col)" class="body-input" :item="getBodyItem(col, rowIndex)" |
|
|
|
v-model="row[col.prop]" @change="onBodyValueChange(rowIndex, colIndex, $event)" |
|
|
|
:error="hasError(rowIndex, colIndex, col.prop)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
|
</template> |
|
|
|
<template v-else-if="col.bodyType === 'inputNumber'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey+'_'+col.prop+'_'+rowIndex" :fieldItemLabel="fieldItemLabel" type="inputNumber" @copy="onCopy(rowIndex, col)" class="body-input-number" |
|
|
|
:item="getBodyItem(col, rowIndex)" v-model="row[col.prop]" @blur="onBlur(rowIndex, col.prop, $event)" |
|
|
|
@change="onBodyValueChange(rowIndex, colIndex, $event)" |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="inputNumber" @copy="onCopy(rowIndex, col)" |
|
|
|
class="body-input-number" :item="getBodyItem(col, rowIndex)" v-model="row[col.prop]" |
|
|
|
@blur="onBlur(rowIndex, col.prop, $event)" @change="onBodyValueChange(rowIndex, colIndex, $event)" |
|
|
|
:error="hasError(rowIndex, colIndex, col.prop)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
|
</template> |
|
|
|
<template v-else-if="col.bodyType === 'select'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey+'_'+col.prop+'_'+rowIndex" :fieldItemLabel="fieldItemLabel" type="select" class="body-select" @blur="onBlur(rowIndex, col.prop, $event)" |
|
|
|
:item="getBodyItem(col, rowIndex)" v-model="row[col.prop]" |
|
|
|
@change="onBodyValueChange(rowIndex, colIndex, $event)" |
|
|
|
:error="hasError(rowIndex, colIndex, col.prop)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
|
<div class="flex flex1"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="select" class="body-select" |
|
|
|
@blur="onBlur(rowIndex, col.prop, $event)" :item="getBodyItem(col, rowIndex)" |
|
|
|
v-model="row[col.prop]" @change="onBodyValueChange(rowIndex, colIndex, $event)" |
|
|
|
:error="hasError(rowIndex, colIndex, col.prop)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
|
<div v-show="isShowOther(row[col.prop])" class="flex flex1"> |
|
|
|
<div class="other-title">{{ col.otherLabel ? $t(col.otherLabel) : $t("template.common.other") }} |
|
|
|
</div> |
|
|
|
<div class="flex flex1"> |
|
|
|
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + col.otherCode" |
|
|
|
@blur="onBlur(rowIndex, col.prop, $event)" :item="getOtherItem(col)" v-model="row[col.otherCode]" |
|
|
|
:error="hasError(rowIndex, colIndex, col.otherCode)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.otherCode, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.otherCode)" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</template> |
|
|
|
<div class="flex flex1" v-else-if="col.bodyType === 'clickable'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey+'_'+col.prop+'_'+rowIndex" :fieldItemLabel="fieldItemLabel" type="clickable" class="body-clickable" |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="clickable" class="body-clickable" |
|
|
|
:item="getBodyItem(col, rowIndex)" :value="row[col.prop]" |
|
|
|
:error="hasError(rowIndex, colIndex, col.prop)" |
|
|
|
@clickable="handleClickable(col,rowIndex,colIndex)" |
|
|
|
@clickable="handleClickable(col, rowIndex, colIndex)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
|
</div> |
|
|
|
@ -71,24 +90,27 @@ |
|
|
|
{{ row[col.prop] }} |
|
|
|
</template> |
|
|
|
</div> |
|
|
|
<div class="m-l-5" v-if="isShowBodySub(col)"> |
|
|
|
<div class="m-l-5 flex1" v-if="isShowBodySub(col)"> |
|
|
|
<template v-if="col.bodySubType === 'inputNumber'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey+'_'+col.bodySubKey+'_'+rowIndex" :fieldItemLabel="fieldItemLabel" type="inputNumber" @blur="onSubBlur(rowIndex, col.bodySubKey, $event)" |
|
|
|
@copy="onCopy(rowIndex, col)" :item="getBodySubItem(col)" v-model="row[col.bodySubKey]" |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.bodySubKey + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="inputNumber" |
|
|
|
@blur="onSubBlur(rowIndex, col.bodySubKey, $event)" @copy="onCopy(rowIndex, col)" |
|
|
|
:item="getBodySubItem(col)" v-model="row[col.bodySubKey]" |
|
|
|
@change="onBodySubValueChange(rowIndex, colIndex, $event)" |
|
|
|
:error="hasError(rowIndex, colIndex, col.bodySubKey)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.bodySubKey, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.bodySubKey)" /> |
|
|
|
</template> |
|
|
|
<template v-else-if="col.bodySubType === 'select'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey+'_'+col.bodySubKey+'_'+rowIndex" :fieldItemLabel="fieldItemLabel" type="select" class="body-select" @blur="onSubBlur(rowIndex, col.bodySubKey, $event)" |
|
|
|
:item="getBodySubItem(col, rowIndex)" v-model="row[col.bodySubKey]" |
|
|
|
@change="onBodySubValueChange(rowIndex, colIndex, $event)" |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.bodySubKey + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="select" class="body-select" |
|
|
|
@blur="onSubBlur(rowIndex, col.bodySubKey, $event)" :item="getBodySubItem(col, rowIndex)" |
|
|
|
v-model="row[col.bodySubKey]" @change="onBodySubValueChange(rowIndex, colIndex, $event)" |
|
|
|
:error="hasError(rowIndex, colIndex, col.bodySubKey)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.bodySubKey, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.bodySubKey)" /> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<template v-else> |
|
|
|
{{ row[col.bodySubKey] }} |
|
|
|
</template> |
|
|
|
@ -161,11 +183,11 @@ export default { |
|
|
|
type: String, |
|
|
|
default: '', |
|
|
|
}, |
|
|
|
//循环组件的情况下需要用这个来区分字段 |
|
|
|
prefixKey:{ |
|
|
|
type: String, |
|
|
|
default: "", |
|
|
|
} |
|
|
|
//循环组件的情况下需要用这个来区分字段 |
|
|
|
prefixKey: { |
|
|
|
type: String, |
|
|
|
default: "", |
|
|
|
} |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
@ -185,10 +207,10 @@ export default { |
|
|
|
this.headerSelectFields = JSON.parse(JSON.stringify(headerSelectFields)) |
|
|
|
} |
|
|
|
}, |
|
|
|
localDataSource:{ |
|
|
|
localDataSource: { |
|
|
|
immediate: true, |
|
|
|
deep: true, |
|
|
|
handler(newVal,oldVal){ |
|
|
|
handler(newVal, oldVal) { |
|
|
|
// if(newVal.length == 0){ |
|
|
|
// return |
|
|
|
// } |
|
|
|
@ -200,22 +222,40 @@ export default { |
|
|
|
// this.initHeaderSelectValues(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
//获取其他下拉框的配置 |
|
|
|
getOtherItem(sItem) { |
|
|
|
console.log(sItem, "other sItem") |
|
|
|
return { |
|
|
|
label: sItem.otherLabel ? this.$t(sItem.otherLabel) : this.$t("template.common.other"), |
|
|
|
fillType: sItem.bodyFillType, |
|
|
|
maxlength: sItem.otherMaxlength || 50, |
|
|
|
parentLabel: sItem.label, |
|
|
|
type:"input" |
|
|
|
} |
|
|
|
}, |
|
|
|
//判断是否显示其他输入框 |
|
|
|
isShowOther(v = []) { |
|
|
|
// 确保v是数组类型,以避免类型错误 |
|
|
|
const arr = Array.isArray(v) ? v : [v]; |
|
|
|
//和凡哥商量,只要value为负数都显示其他 |
|
|
|
return arr.some(item => item < 0); |
|
|
|
}, |
|
|
|
isShowBodySub(col) { |
|
|
|
if(col.hasOwnProperty("disabled")){ |
|
|
|
if (col.hasOwnProperty("disabled")) { |
|
|
|
return col.showBodySub |
|
|
|
} |
|
|
|
return col.bodySubType && col.bodySubKey; |
|
|
|
}, |
|
|
|
// 点击事件 |
|
|
|
handleClickable(col, rowIndex, colIndex) { |
|
|
|
console.log("clickable",rowIndex,colIndex, col) |
|
|
|
if (this.templateFillType !== 'actFill') { |
|
|
|
// return |
|
|
|
} |
|
|
|
this.$emit("clickable", col,rowIndex) |
|
|
|
console.log("clickable", rowIndex, colIndex, col) |
|
|
|
if (this.templateFillType !== 'actFill') { |
|
|
|
// return |
|
|
|
} |
|
|
|
this.$emit("clickable", col, rowIndex) |
|
|
|
}, |
|
|
|
isShowAddRos() { |
|
|
|
if(this.showAddRow !== undefined){ |
|
|
|
if (this.showAddRow !== undefined) { |
|
|
|
return this.showAddRow |
|
|
|
} |
|
|
|
return this.templateFillType === 'preFill'; |
|
|
|
@ -244,9 +284,9 @@ export default { |
|
|
|
// 直接获取表单数据,不做校验 |
|
|
|
getFilledFormData() { |
|
|
|
return { |
|
|
|
stepTableFormData: [...this.localDataSource], |
|
|
|
headerSelectFields: this.headerSelectFields, |
|
|
|
}; |
|
|
|
stepTableFormData: [...this.localDataSource], |
|
|
|
headerSelectFields: this.headerSelectFields, |
|
|
|
}; |
|
|
|
}, |
|
|
|
// 获取最新数据 |
|
|
|
getFormData() { |
|
|
|
@ -301,7 +341,7 @@ export default { |
|
|
|
if (col.bodyFillType === this.templateFillType || col.bodySubFillType === this.templateFillType) { |
|
|
|
// 检查主字段 |
|
|
|
const mainValue = row[col.prop]; |
|
|
|
if (this.isValueEmpty(mainValue) && !col.bodyDisabled && col.bodyType!=='span') { |
|
|
|
if (this.isValueEmpty(mainValue) && !col.bodyDisabled && col.bodyType !== 'span') { |
|
|
|
const errorItem = { |
|
|
|
rowIndex, |
|
|
|
colIndex, |
|
|
|
@ -314,7 +354,7 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
// 检查子字段(如果有) |
|
|
|
if (col.bodySubKey && !col.bodySubDisabled && col.bodySubType!=='span') { |
|
|
|
if (col.bodySubKey && !col.bodySubDisabled && col.bodySubType !== 'span') { |
|
|
|
const subValue = row[col.bodySubKey]; |
|
|
|
console.log(col, subValue, "subValue") |
|
|
|
if (this.isValueEmpty(subValue)) { |
|
|
|
@ -329,10 +369,27 @@ export default { |
|
|
|
this.formErrors.push(errorItem); |
|
|
|
} |
|
|
|
} |
|
|
|
// 检查其他输入框 |
|
|
|
if (col.otherCode) { |
|
|
|
const otherValue = row[col.otherCode]; |
|
|
|
|
|
|
|
if (this.isValueEmpty(otherValue)) { |
|
|
|
const errorItem = { |
|
|
|
rowIndex, |
|
|
|
colIndex, |
|
|
|
field: col.bodySubKey, |
|
|
|
label: `${this.$t(col.label)}单位`, |
|
|
|
error: `请填写${this.$t(col.otherLabel) ? this.$t(col.otherLabel) : '其他'}信息` |
|
|
|
}; |
|
|
|
errors.push(errorItem); |
|
|
|
this.formErrors.push(errorItem); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
console.log(errors,this.localDataSource,"errors") |
|
|
|
console.log(errors, this.localDataSource, "errors") |
|
|
|
return { |
|
|
|
valid: errors.length === 0, |
|
|
|
errors: errors |
|
|
|
@ -398,7 +455,7 @@ export default { |
|
|
|
options: col.bodyOptions, |
|
|
|
maxlength: col.bodyMaxlength, |
|
|
|
label: this.$t(col.label), |
|
|
|
precision: currentItem[col.bodyPrecisionKey] || col.precision , |
|
|
|
precision: currentItem[col.bodyPrecisionKey] || col.precision, |
|
|
|
copyFrom: col.copyFrom || "", |
|
|
|
compareTo: col.bodyCompareTo, // 添加 compareTo 字段 |
|
|
|
type: col.bodyType || "input", |
|
|
|
@ -436,10 +493,10 @@ export default { |
|
|
|
}, |
|
|
|
onAddRow() { |
|
|
|
this.addRow({ |
|
|
|
actSolutionVolumePrecision: 3,//小数点精度默认为3 |
|
|
|
actSolutionConcentrationPrecision: 3,//小数点精度默认为3 |
|
|
|
targetDiluentVolumePrecision: 3,//小数点精度默认为3 |
|
|
|
targetStartSolutionVolumePrecision: 3,//小数点精度默认为3 |
|
|
|
actSolutionVolumePrecision: 3,//小数点精度默认为3 |
|
|
|
actSolutionConcentrationPrecision: 3,//小数点精度默认为3 |
|
|
|
targetDiluentVolumePrecision: 3,//小数点精度默认为3 |
|
|
|
targetStartSolutionVolumePrecision: 3,//小数点精度默认为3 |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 添加行 |
|
|
|
@ -487,12 +544,12 @@ export default { |
|
|
|
}, |
|
|
|
onBlur(rowIndex, colKey) { |
|
|
|
const value = this.localDataSource[rowIndex][colKey]; |
|
|
|
|
|
|
|
|
|
|
|
// 查找对应的列配置 |
|
|
|
const col = this.columns.find(c => c.prop === colKey); |
|
|
|
if (col && col.bodyFillType === "actFill" && col.bodyCompareTo) { |
|
|
|
const compareToValue = this.localDataSource[rowIndex][col.bodyCompareTo]; |
|
|
|
|
|
|
|
|
|
|
|
// 比较当前值和compareTo值,如果不相等则设置橙色背景 |
|
|
|
if (value !== compareToValue) { |
|
|
|
this.setOrangeBg(rowIndex, this.columns.findIndex(c => c.prop === colKey), colKey, true); |
|
|
|
@ -501,7 +558,7 @@ export default { |
|
|
|
this.setOrangeBg(rowIndex, this.columns.findIndex(c => c.prop === colKey), colKey, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.$emit("blur", { rowIndex, colKey, value, item: this.localDataSource[rowIndex] }); |
|
|
|
}, |
|
|
|
onSubBlur(rowIndex, colKey, value) { |
|
|
|
@ -509,7 +566,7 @@ export default { |
|
|
|
const col = this.columns.find(c => c.bodySubKey === colKey); |
|
|
|
if (col && col.bodySubFillType === "actFill" && col.bodySubCompareTo) { |
|
|
|
const compareToValue = this.localDataSource[rowIndex][col.bodySubCompareTo]; |
|
|
|
|
|
|
|
|
|
|
|
// 比较当前值和compareTo值,如果不相等则设置橙色背景 |
|
|
|
if (value !== compareToValue) { |
|
|
|
this.setOrangeBg(rowIndex, this.columns.findIndex(c => c.bodySubKey === colKey), colKey, true); |
|
|
|
@ -518,7 +575,7 @@ export default { |
|
|
|
this.setOrangeBg(rowIndex, this.columns.findIndex(c => c.bodySubKey === colKey), colKey, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.$emit("blur", { rowIndex, colKey, value, item: this.localDataSource[rowIndex] }); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -664,10 +721,20 @@ export default { |
|
|
|
padding: 20px 0; |
|
|
|
margin-top: 20px; |
|
|
|
} |
|
|
|
|
|
|
|
.flex1 { |
|
|
|
flex: 1; |
|
|
|
} |
|
|
|
.flex{ |
|
|
|
|
|
|
|
.flex { |
|
|
|
display: flex; |
|
|
|
} |
|
|
|
|
|
|
|
.other-title { |
|
|
|
text-align: right; |
|
|
|
margin: 0 10px; |
|
|
|
font-size: 14px; |
|
|
|
font-weight: normal; |
|
|
|
color: #606266; |
|
|
|
} |
|
|
|
</style> |