4 Commits

12 changed files with 300 additions and 338 deletions
Unified View
  1. +50
    -29
      src/components/Template/BaseInfoFormPcakge.vue
  2. +181
    -110
      src/components/Template/CustomTable.vue
  3. +24
    -4
      src/components/Template/HandleFormItem.vue
  4. +4
    -4
      src/components/Template/Step.vue
  5. +1
    -7
      src/views/business/comps/template/comps/dl/SYWZPZJHB.vue
  6. +2
    -29
      src/views/business/comps/template/comps/gy/MJYLQSQD.vue
  7. +3
    -29
      src/views/business/comps/template/comps/gy/SYWZPZJHB.vue
  8. +6
    -48
      src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue
  9. +1
    -28
      src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue
  10. +3
    -39
      src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue
  11. +1
    -10
      src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue
  12. +24
    -1
      src/views/business/comps/template/mixins/templateMixin.js

+ 50
- 29
src/components/Template/BaseInfoFormPcakge.vue View File

@ -210,7 +210,7 @@ export default {
}) })
}, },
handleClickable(sItem,event){ handleClickable(sItem,event){
if(this.fillType !== 'actFill'){
if(this.$store.state.template.templateStatus !== 'actFill'){
return return
} }
this.$emit("clickable",sItem) this.$emit("clickable",sItem)
@ -273,7 +273,6 @@ export default {
formFields[key] !== ''&& formFields[key] !== ''&&
typeof formFields[key] !== 'object' typeof formFields[key] !== 'object'
) { ) {
console.log(key,formData,formFields[key],"kkk")
// 使formData // 使formData
result[key] = formFields[key]; result[key] = formFields[key];
} else { } else {
@ -321,51 +320,73 @@ export default {
} }
} }
}, },
validateFormData(){
},
getFormData() {
//
validateFormData() {
const { formFields, allFieldsConfig } = this; const { formFields, allFieldsConfig } = this;
const { templateStatus } = this.$store.state.template; const { templateStatus } = this.$store.state.template;
const errors = [];
//
//
this.errors = {}; this.errors = {};
const errors = {};
let firstError = null;
for (const key in allFieldsConfig) { for (const key in allFieldsConfig) {
if (!formFields[key]) {
if (this.isValueEmpty(formFields[key])) {
const o = allFieldsConfig[key]; const o = allFieldsConfig[key];
// //
if (o.label === "其他" && !this.isShowOther(formFields[o.parentKey])) { if (o.label === "其他" && !this.isShowOther(formFields[o.parentKey])) {
continue continue
} }
//span
if(o.type === "span"){
continue
}
if (o.fillType == templateStatus && !o.disabled) { if (o.fillType == templateStatus && !o.disabled) {
//
errors[key] = true;
if (!firstError) {
let prefix = "";
if (o.type === "input" || o.type === "inputNumber" || o.type === "textarea") {
prefix = "填写";
} else {
prefix = "选择";
}
firstError = { label: o.label, prefix };
let prefix = "";
if (o.type === "input" || o.type === "inputNumber" || o.type === "textarea") {
prefix = "填写";
} else {
prefix = "选择";
} }
const errorItem = {
field: key,
label: o.label,
error: `${prefix}${o.label}`
};
errors.push(errorItem);
this.$set(this.errors, key, true);
} }
} }
} }
//
this.errors = errors;
return {
valid: errors.length === 0,
errors: errors
};
},
//
isValueEmpty(value) {
if (value === null || value === undefined || value === '') {
return true;
}
if (typeof value === 'string' && value.trim() === '') {
return true;
}
if (Array.isArray(value) && value.length === 0) {
return true;
}
return false;
},
getFormData() {
//
const validateResult = this.validateFormData();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (Object.keys(errors).length > 0) {
//
this.$message.error(`表单内容未填完,请填写后再提交`);
reject(`${firstError.label}还未${firstError.prefix}`);
if (validateResult.valid) {
resolve(this.formFields);
} else { } else {
resolve(formFields);
// this.$message.error(",");
reject(validateResult.errors[0].error);
} }
}); });
}, },

+ 181
- 110
src/components/Template/CustomTable.vue View File

@ -1,71 +1,96 @@
<template> <template>
<div class="custom-table-wrapper">
<div class="custom-table-header">
<div class="custom-table-row">
<div v-for="(col, index) in columns" :key="index" class="custom-table-cell header-cell"
:style="{ width: col.width ? col.width + 'px' : 'auto' }">
<div class="header-cell-content">
<div>{{ col.label }}</div>
<template v-if="col.headerSelectKey && col.headerOptions&&showHeaderSelect">
<HandleFormItem type="select" class="header-select" :item="getHeaderItem(col)"
v-model="headerSelectFields[col.headerSelectKey]" @change="onHeaderSelectChange(col, $event)" />
</template>
<span v-else-if ="headerSelectFields[col.headerSelectKey]" class="fill-type-icon">({{ headerSelectFields[col.headerSelectKey] }})</span>
<div>
<div class="custom-table-wrapper">
<div class="custom-table-header">
<div class="custom-table-row">
<div v-for="(col, index) in columns" :key="index" class="custom-table-cell header-cell"
:style="{ width: col.width ? col.width + 'px' : 'auto' }">
<div class="header-cell-content">
<div>{{ col.label }}</div>
<template
v-if="col.headerSelectKey && col.headerOptions && (showHeaderSelect || $store.state.template.templateStatus === 'preFill')">
<HandleFormItem 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)" />
</template>
<span v-else-if="headerSelectFields[col.headerSelectKey]" class="fill-type-icon">({{
headerSelectFields[col.headerSelectKey] }})</span>
</div>
</div>
</div>
<!-- 默认操作栏 -->
<div class="custom-table-cell header-cell" :style="{ width: '180px' }" v-if="showOperation">
<div class="header-cell-content">
<div>操作</div>
</div>
<!-- 默认操作栏 -->
<div class="custom-table-cell header-cell" :style="{ width: '180px' }" v-if="showOperation">
<div class="header-cell-content">
<div>操作</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="custom-table-body">
<div v-for="(row, rowIndex) in localDataSource" :key="rowIndex" class="custometable-row">
<div v-for="(col, colIndex) in columns" :key="colIndex" class="custom-table-cell body-cell"
:style="{ width: col.width ? col.width + 'px' : 'auto' }">
<div class="inner-table-cell">
<div>
<template v-if="col.bodyType === 'input'">
<HandleFormItem 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)" />
</template>
<template v-else-if="col.bodyType === 'inputNumber'">
<HandleFormItem 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)" />
</template>
<template v-else-if="col.bodyType === 'select'">
<HandleFormItem 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)" />
</template>
<template v-else>
{{ row[col.prop] }}
</template>
</div>
<div class="m-l-5" v-if="col.showBodySub">
<template v-if="col.bodySubType === 'inputNumber'">
<HandleFormItem 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)" />
</template>
<template v-else>
{{ row[col.bodySubKey] }}
</template>
<div class="custom-table-body">
<div v-for="(row, rowIndex) in localDataSource" :key="rowIndex" class="custometable-row">
<div v-for="(col, colIndex) in columns" :key="colIndex" class="custom-table-cell body-cell"
:style="{ width: col.width ? col.width + 'px' : 'auto' }">
<div class="inner-table-cell">
<div>
<template v-if="col.bodyType === 'input'">
<HandleFormItem 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)" />
</template>
<template v-else-if="col.bodyType === 'inputNumber'">
<HandleFormItem 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)" />
</template>
<template v-else-if="col.bodyType === 'select'">
<HandleFormItem 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)" />
</template>
<template v-else>
{{ row[col.prop] }}
</template>
</div>
<div class="m-l-5" v-if="col.showBodySub">
<template v-if="col.bodySubType === 'inputNumber'">
<HandleFormItem 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)" />
</template>
<template v-else>
{{ row[col.bodySubKey] }}
</template>
</div>
</div> </div>
</div> </div>
</div>
<!-- 默认操作栏 -->
<div class="custom-table-cell body-cell" :style="{ width: '180px' }" v-if="showOperation">
<div class="inner-table-cell">
<slot name="operation" :row="row" :rowIndex="rowIndex" ></slot>
<!-- 默认操作栏 -->
<div class="custom-table-cell body-cell" :style="{ width: '180px' }" v-if="showOperation">
<div class="inner-table-cell">
<slot name="operation" :row="row" :rowIndex="rowIndex"></slot>
</div>
</div> </div>
</div> </div>
</div> </div>
<div v-if="localDataSource.length == 0">
<div class="no-data">暂无数据</div>
</div>
</div> </div>
<div v-if = "localDataSource.length==0">
<div class="no-data">暂无数据</div>
<div class="add-row" v-if="isShowAddRos()">
<el-button type="primary" plain @click="addRow">添加行</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -81,6 +106,10 @@ export default {
// //
showHeaderSelect: { showHeaderSelect: {
type: Boolean, type: Boolean,
default: false,
},
showAddRow: {
type: Boolean,
default: true, default: true,
}, },
// //
@ -99,7 +128,7 @@ export default {
}, },
formData: { formData: {
type: Object, type: Object,
default:()=>{
default: () => {
return { return {
stepTableFormData: [], stepTableFormData: [],
headerSelectFields: {} headerSelectFields: {}
@ -115,27 +144,34 @@ export default {
} }
}, },
watch: { watch: {
formData:{
formData: {
immediate: true, immediate: true,
handler(newData) { handler(newData) {
console.log(newData,"newData")
const {stepTableFormData = [], headerSelectFields = {}} = newData;
console.log(newData, "newData")
const { stepTableFormData = [], headerSelectFields = {} } = newData;
this.updateDataSource(stepTableFormData); this.updateDataSource(stepTableFormData);
this.headerSelectFields = JSON.parse(JSON.stringify(headerSelectFields)) this.headerSelectFields = JSON.parse(JSON.stringify(headerSelectFields))
} }
}, },
}, },
mounted() { mounted() {
this.initHeaderSelectValues();
// this.initHeaderSelectValues();
console.log(this.$store.state.template.templateStatus, "this.$store.state.template.templateStatus")
}, },
methods: { methods: {
isShowAddRos() {
if(!this.showAddRow) {
return false;
}
return this.$store.state.template.templateStatus === 'preFill';
},
// //
onCopy(rowIndex, col){
if(col.copyFrom){
if(!this.localDataSource[rowIndex][col.copyFrom]){//
return
}
onCopy(rowIndex, col) {
if (col.copyFrom) {
if (!this.localDataSource[rowIndex][col.copyFrom]) {//
return
}
this.$set(this.localDataSource[rowIndex], col.prop, this.localDataSource[rowIndex][col.copyFrom]) this.$set(this.localDataSource[rowIndex], col.prop, this.localDataSource[rowIndex][col.copyFrom])
} }
}, },
@ -143,7 +179,7 @@ export default {
initHeaderSelectValues() { initHeaderSelectValues() {
const headerSelectObj = {}; const headerSelectObj = {};
this.columns.map(col => { this.columns.map(col => {
if(col.headerSelectKey){
if (col.headerSelectKey) {
headerSelectObj[col.headerSelectKey] = col.defaultValue || col.headerOptions[0].value || "" headerSelectObj[col.headerSelectKey] = col.defaultValue || col.headerOptions[0].value || ""
} }
}); });
@ -152,18 +188,18 @@ export default {
// //
getFormData() { getFormData() {
// columns // columns
// //
const validateResult = this.validateFormData(); const validateResult = this.validateFormData();
return new Promise((resolve,reject)=>{
if(validateResult.valid){
return new Promise((resolve, reject) => {
if (validateResult.valid) {
resolve({ resolve({
stepTableFormData: [...this.localDataSource], stepTableFormData: [...this.localDataSource],
headerSelectFields: this.headerSelectFields, headerSelectFields: this.headerSelectFields,
}) })
}else{
this.$message.error("表单内容未填完,请填写后再提交");
} else {
// this.$message.error(",");
reject(validateResult.errors[0].error) reject(validateResult.errors[0].error)
} }
}) })
@ -173,10 +209,28 @@ export default {
validateFormData() { validateFormData() {
const templateStatus = this.$store.state.template.templateStatus; const templateStatus = this.$store.state.template.templateStatus;
const errors = []; const errors = [];
// //
this.formErrors = []; this.formErrors = [];
// HandleFormItem
this.columns.forEach((col, colIndex) => {
if (col.headerSelectKey && col.headerOptions && col.fillType === templateStatus) {
const headerValue = this.headerSelectFields[col.headerSelectKey];
if (this.isValueEmpty(headerValue)) {
const errorItem = {
rowIndex: -1, //
colIndex,
field: col.headerSelectKey,
label: col.label,
error: `请选择${col.label}`
};
errors.push(errorItem);
this.formErrors.push(errorItem);
}
}
});
// //
this.localDataSource.forEach((row, rowIndex) => { this.localDataSource.forEach((row, rowIndex) => {
// //
@ -196,11 +250,11 @@ export default {
errors.push(errorItem); errors.push(errorItem);
this.formErrors.push(errorItem); this.formErrors.push(errorItem);
} }
// //
if (col.bodySubKey&& !col.bodySubDisabled) {
if (col.bodySubKey && !col.bodySubDisabled) {
const subValue = row[col.bodySubKey]; const subValue = row[col.bodySubKey];
console.log(col,subValue,"subValue")
console.log(col, subValue, "subValue")
if (this.isValueEmpty(subValue)) { if (this.isValueEmpty(subValue)) {
const errorItem = { const errorItem = {
rowIndex, rowIndex,
@ -216,7 +270,7 @@ export default {
} }
}); });
}); });
return { return {
valid: errors.length === 0, valid: errors.length === 0,
errors: errors errors: errors
@ -238,15 +292,20 @@ export default {
// //
onHeaderSelectChange(col, value) { onHeaderSelectChange(col, value) {
this.headerSelectFields[col.headerSelectKey] = value; this.headerSelectFields[col.headerSelectKey] = value;
//
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === -1 &&
error.field === col.headerSelectKey)
);
}, },
// //
onBodyValueChange(rowIndex, colIndex, value) { onBodyValueChange(rowIndex, colIndex, value) {
const col = this.columns[colIndex]; const col = this.columns[colIndex];
this.localDataSource[rowIndex][col.prop] = value; this.localDataSource[rowIndex][col.prop] = value;
// //
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
error.field === col.prop) error.field === col.prop)
); );
this.$emit('body-value-change', rowIndex, colIndex, value); this.$emit('body-value-change', rowIndex, colIndex, value);
@ -256,9 +315,9 @@ export default {
const col = this.columns[colIndex]; const col = this.columns[colIndex];
this.localDataSource[rowIndex][col.bodySubKey] = value; this.localDataSource[rowIndex][col.bodySubKey] = value;
// //
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
error.field === col.bodySubKey) error.field === col.bodySubKey)
); );
this.$emit('body-sub-value-change', rowIndex, colIndex, value); this.$emit('body-sub-value-change', rowIndex, colIndex, value);
@ -270,9 +329,9 @@ export default {
label: "" label: ""
} }
}, },
getBodyItem(col,rowIndex) {
getBodyItem(col, rowIndex) {
const currentItem = this.localDataSource[rowIndex]; const currentItem = this.localDataSource[rowIndex];
const item = {
const item = {
fillType: col.bodyFillType, fillType: col.bodyFillType,
options: col.bodyOptions, options: col.bodyOptions,
maxlength: col.bodyMaxlength, maxlength: col.bodyMaxlength,
@ -280,21 +339,21 @@ export default {
precision: currentItem[col.bodyPrecisionKey] || col.precision || 0, precision: currentItem[col.bodyPrecisionKey] || col.precision || 0,
copyFrom: col.copyFrom || "", copyFrom: col.copyFrom || "",
}; };
if(col.bodyDisabled){
if (col.bodyDisabled) {
item.disabled = col.bodyDisabled; item.disabled = col.bodyDisabled;
} }
return item return item
}, },
getBodySubItem(col) { getBodySubItem(col) {
const item = {
const item = {
fillType: col.bodySubFillType, fillType: col.bodySubFillType,
options: col.bodySubOptions, options: col.bodySubOptions,
maxlength: col.bodySubMaxlength || 10, maxlength: col.bodySubMaxlength || 10,
label: "", label: "",
placeholder:col.bodySubPlaceholder||"请输入",
placeholder: col.bodySubPlaceholder || "请输入",
precision: col.subPrecision || 0, precision: col.subPrecision || 0,
} }
if(col.bodySubDisabled){
if (col.bodySubDisabled) {
item.disabled = col.bodySubDisabled; item.disabled = col.bodySubDisabled;
} }
return item return item
@ -310,42 +369,42 @@ export default {
this.localDataSource = JSON.parse(JSON.stringify(dataSource || [])); this.localDataSource = JSON.parse(JSON.stringify(dataSource || []));
}, },
// //
addRow(row) {
addRow(row = {}) {
this.localDataSource.push(row); this.localDataSource.push(row);
}, },
getDataSource(){
getDataSource() {
return this.localDataSource; return this.localDataSource;
}, },
// //
updateDataSourceByRowIndex(rowIndex,data){
this.localDataSource[rowIndex] = {...this.localDataSource[rowIndex],...data};
console.log(this.localDataSource,"this.localDataSource")
updateDataSourceByRowIndex(rowIndex, data) {
this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data };
console.log(this.localDataSource, "this.localDataSource")
this.localDataSource = [...this.localDataSource]; this.localDataSource = [...this.localDataSource];
}, },
// //
hasError(rowIndex, colIndex, field) { hasError(rowIndex, colIndex, field) {
return this.formErrors.some(error =>
error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
return this.formErrors.some(error =>
error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
error.field === field error.field === field
); );
}, },
// //
onErrorUpdate(rowIndex, colIndex, field, isError) { onErrorUpdate(rowIndex, colIndex, field, isError) {
if (!isError) { if (!isError) {
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
error.field === field) error.field === field)
); );
} }
}, },
onSubBlur(rowIndex, colKey, value) { onSubBlur(rowIndex, colKey, value) {
this.$emit("blur", {rowIndex, colKey, value,item:this.localDataSource[rowIndex]});
this.$emit("blur", { rowIndex, colKey, value, item: this.localDataSource[rowIndex] });
}, },
onBlur(rowIndex, colKey) { onBlur(rowIndex, colKey) {
const value = this.localDataSource[rowIndex][colKey]; const value = this.localDataSource[rowIndex][colKey];
this.$emit("blur", {rowIndex, colKey, value,item:this.localDataSource[rowIndex]});
this.$emit("blur", { rowIndex, colKey, value, item: this.localDataSource[rowIndex] });
} }
} }
}; };
@ -361,17 +420,20 @@ export default {
margin-top: 20px; margin-top: 20px;
} }
.inner-table-cell{
.inner-table-cell {
display: flex; display: flex;
align-items: center;
align-items: center;
justify-content: center; justify-content: center;
} }
.m-l-5{
.m-l-5 {
margin-left: 5px; margin-left: 5px;
} }
.sub-input-number{
.sub-input-number {
width: 145px; width: 145px;
.el-input-number--mini{
.el-input-number--mini {
width: 145px; width: 145px;
} }
} }
@ -406,6 +468,7 @@ export default {
display: table; display: table;
width: 100%; width: 100%;
table-layout: fixed; table-layout: fixed;
&:not(:last-child) { &:not(:last-child) {
border-bottom: 1px solid #ebeef5; border-bottom: 1px solid #ebeef5;
} }
@ -473,9 +536,17 @@ export default {
width: 100px; width: 100px;
margin-left: 5px; margin-left: 5px;
} }
.no-data{
.no-data {
text-align: center; text-align: center;
padding: 20px 0; padding: 20px 0;
color: rgb(144, 147, 153) color: rgb(144, 147, 153)
} }
.add-row {
display: flex;
justify-content: center;
padding: 20px 0;
margin-top: 20px;
}
</style> </style>

+ 24
- 4
src/components/Template/HandleFormItem.vue View File

@ -115,11 +115,28 @@ export default {
const value = val !== undefined ? val : this.inputValue; const value = val !== undefined ? val : this.inputValue;
this.$emit('input', value); this.$emit('input', value);
this.$emit('change', value); this.$emit('change', value);
//
if (this.error) {
//
const isEmpty = this.isValueEmpty(value);
if (this.error && !isEmpty) {
this.$emit('update:error', false); this.$emit('update:error', false);
} else if (!this.error && isEmpty) {
this.$emit('update:error', true);
} }
}, },
//
isValueEmpty(value) {
if (value === null || value === undefined || value === '') {
return true;
}
if (typeof value === 'string' && value.trim() === '') {
return true;
}
if (Array.isArray(value) && value.length === 0) {
return true;
}
return false;
},
handleClickable(item,event){ handleClickable(item,event){
if(item.fillType !== 'actFill'){ if(item.fillType !== 'actFill'){
return return
@ -176,9 +193,12 @@ export default {
this.$emit("copy") this.$emit("copy")
}, },
onBlur(val) { onBlur(val) {
//
if (this.error) {
//
const isEmpty = this.isValueEmpty(this.inputValue);
if (this.error && !isEmpty) {
this.$emit('update:error', false); this.$emit('update:error', false);
} else if (!this.error && isEmpty) {
this.$emit('update:error', true);
} }
this.$emit("blur", val) this.$emit("blur", val)
}, },

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

@ -233,15 +233,15 @@ export default {
// //
const validation = this.validateSteps() const validation = this.validateSteps()
if (!validation.isValid) { if (!validation.isValid) {
this.$message.error(validation.errors[0])
// this.$message.error(validation.errors[0])
reject(validation.errors[0]) reject(validation.errors[0])
return return
} }
// //
if (this.steps.length === 0) { if (this.steps.length === 0) {
this.$message.error(this.$t('template.common.addStepError'))
reject(this.$t('template.common.addStepError'))
// this.$message.error(this.$t('template.common.addStepError'))
reject({errorType:"step"});
return return
} }
@ -249,7 +249,7 @@ export default {
type: step.type, type: step.type,
...step.formData ...step.formData
})) }))
resolve(stepData)
resolve({stepData})
}) })
}, },

+ 1
- 7
src/views/business/comps/template/comps/dl/SYWZPZJHB.vue View File

@ -186,13 +186,7 @@ export default {
}; };
}, },
mounted() { mounted() {
this.formData = {
headerSelectFields: {
preparationVolumeUnit: "ml",
preparationConcentrationUnit: "ul",
}
}
console.log("mounted")
}, },
methods: { methods: {

+ 2
- 29
src/views/business/comps/template/comps/gy/MJYLQSQD.vue View File

@ -18,9 +18,6 @@
<TableOpertaion :fillType="fillType" :row="row" :rowIndex="rowIndex" @deleteRow="deleteRow"></TableOpertaion> <TableOpertaion :fillType="fillType" :row="row" :rowIndex="rowIndex" @deleteRow="deleteRow"></TableOpertaion>
</template> </template>
</CustomTable> </CustomTable>
<div class="add-row">
<el-button type="primary" plain @click="addRow">添加行</el-button>
</div>
</div> </div>
<BaseInfoFormPcakge label="特别说明" ref="remarkRef" :formConfig="remarkConig" :formData="formData" /> <BaseInfoFormPcakge label="特别说明" ref="remarkRef" :formConfig="remarkConig" :formData="formData" />
@ -186,31 +183,11 @@ export default {
}; };
}, },
mounted() { mounted() {
this.formData = {
headerSelectFields: {
preparationVolumeUnit: "ml",
preparationConcentrationUnit: "ul",
}
}
}, },
methods: { methods: {
async getFormData() { async getFormData() {
const baseData = await this.$refs.baseInfoRef.getFormData();
const stepFormData = await this.$refs.stepFormPackageRef.getFormData();
const stepTableFormData = await this.$refs.stepTableRef.getFormData();
const remarkData = await this.$refs.remarkRef.getFormData();
if(!stepTableFormData.stepTableFormData.length){
this.$message.error("请添加计划信息");
return;
}
return {
...baseData,
...stepFormData,
...remarkData,
...stepTableFormData
}
return await this.validFormFields(["baseInfoRef", "stepFormPackageRef","stepTableRef","remarkRef"]);
}, },
async onSave() { async onSave() {
const formData = await this.getFormData(); const formData = await this.getFormData();
@ -232,9 +209,5 @@ export default {
.mt-20 { .mt-20 {
margin-top: 20px; margin-top: 20px;
} }
.add-row{
display: flex;
justify-content: center;
padding: 20px 0;
}
</style> </style>

+ 3
- 29
src/views/business/comps/template/comps/gy/SYWZPZJHB.vue View File

@ -18,9 +18,6 @@
<TableOpertaion :fillType="fillType" :row="row" :rowIndex="rowIndex" @deleteRow="deleteRow"></TableOpertaion> <TableOpertaion :fillType="fillType" :row="row" :rowIndex="rowIndex" @deleteRow="deleteRow"></TableOpertaion>
</template> </template>
</CustomTable> </CustomTable>
<div class="add-row">
<el-button type="primary" plain @click="addRow">添加行</el-button>
</div>
</div> </div>
<BaseInfoFormPcakge label="特别说明" ref="remarkRef" :formConfig="remarkConig" :formData="formData" /> <BaseInfoFormPcakge label="特别说明" ref="remarkRef" :formConfig="remarkConig" :formData="formData" />
@ -186,31 +183,12 @@ export default {
}; };
}, },
mounted() { mounted() {
this.formData = {
headerSelectFields: {
preparationVolumeUnit: "ml",
preparationConcentrationUnit: "ul",
}
}
}, },
methods: { methods: {
async getFormData() { async getFormData() {
const baseData = await this.$refs.baseInfoRef.getFormData();
const stepFormData = await this.$refs.stepFormPackageRef.getFormData();
const stepTableFormData = await this.$refs.stepTableRef.getFormData();
const remarkData = await this.$refs.remarkRef.getFormData();
if(!stepTableFormData.stepTableFormData.length){
this.$message.error("请添加计划信息");
return;
}
return {
...baseData,
...stepFormData,
...remarkData,
...stepTableFormData
}
return await this.validFormFields(["baseInfoRef", "stepFormPackageRef","stepTableRef","remarkRef"]);
}, },
async onSave() { async onSave() {
const formData = await this.getFormData(); const formData = await this.getFormData();
@ -232,9 +210,5 @@ export default {
.mt-20 { .mt-20 {
margin-top: 20px; margin-top: 20px;
} }
.add-row{
display: flex;
justify-content: center;
padding: 20px 0;
}
</style> </style>

+ 6
- 48
src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue View File

@ -16,7 +16,7 @@
<div class="template-form-item"> <div class="template-form-item">
<BaseInfoFormPcakge @clickable="handleClickable" ref="stepFormPackageRef" :formConfig="stepFormConfig" @blur="onHandleBlur" <BaseInfoFormPcakge @clickable="handleClickable" ref="stepFormPackageRef" :formConfig="stepFormConfig" @blur="onHandleBlur"
:formData="formData" /> :formData="formData" />
<CustomTable @blur="onHandleTableBlur" :showOperation="fillType === 'actFillill'" ref="stepTableRef" :columns="stepColumns"
<CustomTable :showAddRow="false" @blur="onHandleTableBlur" :showOperation="fillType === 'actFillill'" ref="stepTableRef" :columns="stepColumns"
:formData="formData" > :formData="formData" >
<template slot="operation" slot-scope="{ row, rowIndex}"> <template slot="operation" slot-scope="{ row, rowIndex}">
<TableOpertaion :fillType="fillType" :row="row" :rowIndex="rowIndex" @deleteRow="deleteRow"></TableOpertaion> <TableOpertaion :fillType="fillType" :row="row" :rowIndex="rowIndex" @deleteRow="deleteRow"></TableOpertaion>
@ -53,22 +53,12 @@ export default {
components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion }, components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion },
mixins: [templateMixin], mixins: [templateMixin],
props: { props: {
value: {
type: {},
default: () => { },
},
fillType: { fillType: {
type: String, type: String,
default: 'preFill', default: 'preFill',
}, },
}, },
watch: { watch: {
value: {
immediate: true,
handler(v) {
}
},
fillType: { fillType: {
immediate: true, immediate: true,
handler(v) { handler(v) {
@ -438,24 +428,7 @@ export default {
}; };
}, },
mounted() { mounted() {
if (this.fillType === "preFill") {
this.formData = {
effectivePeriodUnit: "days",//
createTime: "2026-01-02 18:05:36",//
versionNum:1,
stepTableFormData: [],
headerSelectFields: {
targetStartSolutionVolumeUnit: "mg",
actStartSolutionVolumeUnit: "mg",
targetDiluentVolumeUnit: "mg",
actDiluentVolumeUnit: "mg",
targetSolutionConcentrationUnit: "mg",
actSolutionConcentrationUnit: "mg",
targetSolutionVolumeUnit: "mg",
actSolutionVolumeUnit: "mg",
}
}
}
}, },
methods: { methods: {
handleClickable(item) { handleClickable(item) {
@ -463,6 +436,7 @@ export default {
// return; // return;
} }
const {subKey = ""} = item; const {subKey = ""} = item;
console.log(subKey,"subKey")
if(subKey === "subStartSolution" || subKey === "subSolution"){// if(subKey === "subStartSolution" || subKey === "subSolution"){//
this.selectReagentVisible = true; this.selectReagentVisible = true;
this.currentSubKey = subKey; this.currentSubKey = subKey;
@ -474,28 +448,12 @@ export default {
this.selectReagentVisible = false; this.selectReagentVisible = false;
}, },
async getFormData() { async getFormData() {
const baseData = await this.$refs.baseInfoRef.getFormData();
const conditionData = await this.$refs.storageConditionRef.getFormData();
const stepFormData = await this.$refs.stepFormPackageRef.getFormData();
const stepTableFormData = await this.$refs.stepTableRef.getFormData();
const stepData = await this.$refs.stepRef.getFormData();
if (!stepData.length) {
this.$message.error("请添加步骤");
return;
}
const remarkData = await this.$refs.remarkRef.getFormData();
return {
...baseData,
...conditionData,
stepData,
...stepFormData,
...remarkData,
...stepTableFormData
}
return await this.validFormFields(["baseInfoRef", "storageConditionRef","stepFormPackageRef","stepTableRef","stepRef","remarkRef"]);
}, },
async onSave() { async onSave() {
// const formData = await this.getFormData(); // const formData = await this.getFormData();
const formData = await this.$refs.stepTableRef.getFormData();
const formData = await this.validFormFields(["baseInfoRef", "storageConditionRef","stepFormPackageRef","stepTableRef","stepRef","remarkRef"]);
console.log(formData, "formData") console.log(formData, "formData")
} }
} }

+ 1
- 28
src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue View File

@ -41,23 +41,11 @@ export default {
components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable }, components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable },
mixins: [templateMixin], mixins: [templateMixin],
props: { props: {
value: {
type: {},
default: () => { },
},
fillType: { fillType: {
type: String, type: String,
default: 'preFill', default: 'preFill',
}, },
}, },
watch: {
value: {
immediate: true,
handler(v) {
}
}
},
computed: { computed: {
storageFormConfig() { storageFormConfig() {
return [ return [
@ -257,22 +245,7 @@ export default {
}, },
methods: { methods: {
async getFormData() { async getFormData() {
const baseData = await this.$refs.baseInfoRef.getFormData();
const conditionData = await this.$refs.storageConditionRef.getFormData();
const stepFormData = await this.$refs.stepFormPackageRef.getFormData();
const stepData = await this.$refs.stepRef.getFormData();
if (!stepData.length) {
this.$message.error("请添加步骤");
return;
}
const remarkData = await this.$refs.remarkRef.getFormData();
return {
...baseData,
...conditionData,
stepData,
...stepFormData,
...remarkData
}
return await this.validFormFields(["baseInfoRef", "storageConditionRef","stepFormPackageRef","stepRef","remarkRef"]);
}, },
async onSave() { async onSave() {
const formData = await this.getFormData(); const formData = await this.getFormData();

+ 3
- 39
src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue View File

@ -41,23 +41,11 @@ export default {
components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable }, components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable },
mixins: [templateMixin], mixins: [templateMixin],
props: { props: {
value: {
type: {},
default: () => { },
},
fillType: { fillType: {
type: String, type: String,
default: 'preFill', default: 'preFill',
}, },
}, },
watch: {
value: {
immediate: true,
handler(v) {
}
}
},
computed: { computed: {
storageFormConfig() { storageFormConfig() {
return [ return [
@ -260,39 +248,15 @@ export default {
}; };
}, },
mounted() { mounted() {
if(this.fillType === "preFill"){
this.formData = {
effectivePeriodUnit:"days",//
createTime: "2026-01-02 18:05:36",//
}
}
}, },
methods: { methods: {
async getFormData() { async getFormData() {
const baseData = await this.$refs.baseInfoRef.getFormData();
const conditionData = await this.$refs.storageConditionRef.getFormData();
const stepFormData = await this.$refs.stepFormPackageRef.getFormData();
const stepData = await this.$refs.stepRef.getFormData();
if (!stepData.length) {
this.$message.error(this.$t('template.common.addStepError'));
return;
}
const remarkData = await this.$refs.remarkRef.getFormData();
return {
...baseData,
...conditionData,
stepData,
...stepFormData,
...remarkData
}
return await this.validFormFields(["baseInfoRef", "storageConditionRef","stepFormPackageRef","stepRef","remarkRef"]);
}, },
async onSave() { async onSave() {
// const formData = await this.getFormData(); // const formData = await this.getFormData();
const result = await Promise.all([this.$refs.baseInfoRef.getFormData(), this.$refs.storageConditionRef.getFormData()]).catch(()=>{
console.log("error")
});
console.log(result,"res")
// console.log(formData, "formData") // console.log(formData, "formData")
}, },

+ 1
- 10
src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue View File

@ -144,10 +144,6 @@ export default {
components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion }, components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion },
mixins: [templateMixin], mixins: [templateMixin],
props: { props: {
value: {
type: {},
default: () => { },
},
fillType: { fillType: {
type: String, type: String,
default: 'preFill', default: 'preFill',
@ -973,12 +969,7 @@ export default {
.config-header .el-button:hover { .config-header .el-button:hover {
color: #f78989; color: #f78989;
} }
.add-row {
display: flex;
align-items: center;
padding: 20px 0;
border-bottom: 1px solid #ebeef5;
}
.mt-0{ .mt-0{
margin-top: 0; margin-top: 0;
} }

+ 24
- 1
src/views/business/comps/template/mixins/templateMixin.js View File

@ -37,7 +37,30 @@ export default {
this.setTemplateData({}); this.setTemplateData({});
}, },
methods: { methods: {
//统一校验form表单是否填写
async validFormFields(refArr = []) {
let result = {};
const refs = refArr.map(ref => {
const refData = this.$refs[ref].getFormData();
return refData;
});
const validFormData = await Promise.all(refs).catch(err => {
// this.$message.error(err);
if(err.errorType && err.errorType === "step"){
this.$message.error("请添加步骤");
return
}
console.log(err,"err")
this.$message.error("表单内容未填完,请填写后再提交");
});
if(validFormData){
validFormData.forEach(item => {
result = {...result,...item}
})
return result;
}
return false;
},
//试验配制条件options //试验配制条件options
getDictOptions(dictType) { getDictOptions(dictType) {
return this.dict.type[dictType] || []; return this.dict.type[dictType] || [];

Loading…
Cancel
Save