Browse Source

feat:[模板管理][update]

lkf
luojie 3 months ago
parent
commit
7c44ebb35d
3 changed files with 131 additions and 58 deletions
  1. +4
    -4
      src/components/Template/BaseInfoFormPcakge.vue
  2. +120
    -53
      src/components/Template/CustomTable.vue
  3. +7
    -1
      src/views/business/comps/template/formConfig/paralleAndLadderConfig.js

+ 4
- 4
src/components/Template/BaseInfoFormPcakge.vue View File

@ -39,7 +39,7 @@
</div>
<div class="p-l-20">
<div v-show="isShowOther(formFields[key])">
<div class="form-title">{{ $t("template.common.other") }}</div>
<div class="form-title">{{ sItem.otherLabel ? $t(sItem.otherLabel) : $t("template.common.other") }}</div>
<div class="flex flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+sItem.otherCode" @blur="onBlur(key, $event)" :item="getOtherItem(sItem)"
v-model="formFields[sItem.otherCode]" @copy="onCopy(sItem, key)"
@ -107,7 +107,7 @@
@change="onSelectChange(key, $event)" :error="errors[key]"
@update:error="errors[key] = false" :orange-bg="orangeBgFields[key]" />
<div v-show="isShowOther(formFields[key])" class="flex flex1">
<div class="other-title">{{ $t("template.common.other") }}</div>
<div class="other-title">{{sItem.otherLabel ? $t(sItem.otherLabel) : $t("template.common.other") }}</div>
<div class="flex">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+sItem.otherCode" @blur="onBlur(key, $event)" :item="getOtherItem(sItem)"
v-model="formFields[sItem.otherCode]" @copy="onCopy(sItem, key)"
@ -131,7 +131,7 @@
:error="errors[sItem.subKey]" @update:error="errors[sItem.subKey] = false"
:value="formFields[sItem.subKey]" />
<div v-show="isShowOther(formFields[sItem.subKey])" class="flex flex1">
<div class="other-title">{{ $t("template.common.other") }}</div>
<div class="other-title">{{sItem.otherLabel ? $t(sItem.otherLabel) : $t("template.common.other") }}</div>
<div class="flex flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+sItem.otherCode" @blur="onBlur(key, $event)" :item="getOtherItem(sItem)"
v-model="formFields[sItem.otherCode]" @copy="onCopy(sItem, key)"
@ -302,7 +302,7 @@ export default {
//
getOtherItem(sItem) {
return {
label: "template.common.other",
label: sItem.otherLabel ? this.$t(sItem.otherLabel) : this.$t("template.common.other"),
fillType: sItem.fillType,
maxlength: sItem.otherMaxlength || 50,
parentLabel: sItem.label,

+ 120
- 53
src/components/Template/CustomTable.vue View File

@ -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>

+ 7
- 1
src/views/business/comps/template/formConfig/paralleAndLadderConfig.js View File

@ -150,10 +150,16 @@ export const getParallelColumnsConfig = ($this) => {
label: '目标溶液编号',
prop: 'targetSolutionCode',
bodyType: 'select',
bodyOptions: $this.getDictOptions('business_sp_jmdyzqdyp'),
bodyOptions: [
{label: '目标溶液1',value:'目标溶液1'},
{label: '目标溶液2',value:'目标溶液2'},
{label: '其他',value:-1},
],
subType: 'span',
subKey: 'subTargetSolutionCode',
bodyFillType: 'preFill',
otherCode: 'targetSolutionCodeOther',
width: 280
},
{

Loading…
Cancel
Save