Browse Source

feat:[模板管理][update]

lkf
luojie 2 months ago
parent
commit
1152343d98
5 changed files with 64 additions and 43 deletions
  1. +1
    -1
      src/components/Template/Step.vue
  2. +52
    -34
      src/components/Template/StepComponents/ZLSubPackage.vue
  3. +6
    -3
      src/components/Template/StepFormPackage.vue
  4. +3
    -3
      src/components/Template/mixins/formPackageMixins.js
  5. +2
    -2
      src/views/business/comps/template/comps/sp/SP001.vue

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

@ -114,7 +114,7 @@ const stepTypes = [
{ label: '灭菌', value: 'mj' }, { label: '灭菌', value: 'mj' },
{ label: '复苏', value: 'fs' }, { label: '复苏', value: 'fs' },
{ label: '封板', value: 'fb' }, { label: '封板', value: 'fb' },
// { label: '', value: 'zlfz' },
{ label: '质量分装', value: 'zlfz' },
]; ];

+ 52
- 34
src/components/Template/StepComponents/ZLSubPackage.vue View File

@ -94,9 +94,9 @@ export default {
fzList: [],// fzList: [],//
// //
formErrors: { formErrors: {
mybh: false,
fzsl: false, fzsl: false,
dw: false, dw: false,
mfbzl: false,
}, },
fzListErrors: [], // fzListErrors: [], //
uuid:"",//id uuid:"",//id
@ -105,7 +105,6 @@ export default {
watch: { watch: {
subData:{ subData:{
handler(newVal) { handler(newVal) {
console.log(newVal,"fff");
if(newVal.formData){ if(newVal.formData){
this.formData = newVal.formData; this.formData = newVal.formData;
} }
@ -157,46 +156,65 @@ export default {
validateFormData() { validateFormData() {
let isValid = true; let isValid = true;
//
if (!this.formData.mybh) {
this.formErrors.mybh = true;
isValid = false;
}
//
if (!this.formData.fzsl) {
this.formErrors.fzsl = true;
isValid = false;
}
//
const baseFieldConfigs = [
{
field: 'fzsl',
errorField: 'fzsl',
itemConfig: this.integerInputNumberItem
},
{
field: 'dw',
errorField: 'dw',
itemConfig: this.unitItem
},
{
field: 'mfbzl',
errorField: 'mfbzl',
itemConfig: this.inputNumberItem
}
];
//
if (!this.formData.dw) {
this.formErrors.dw = true;
isValid = false;
}
//
baseFieldConfigs.forEach(config => {
if (config.itemConfig.fillType === this.templateFillType) {
if (!this.formData[config.field]) {
this.formErrors[config.errorField] = true;
isValid = false;
}
}
});
//
// - fillTypetemplateFillType
if (this.fzList && this.fzList.length > 0) { if (this.fzList && this.fzList.length > 0) {
for (let i = 0; i < this.fzList.length; i++) { for (let i = 0; i < this.fzList.length; i++) {
if (isValueEmpty(this.fzList[i].prenum)) {
this.fzListErrors.push({
rowIndex: i,
field: "prenum",
error: "请输入预填分装数量",
})
isValid = false;
//
if (this.preInputNumberItem.fillType === this.templateFillType) {
if (isValueEmpty(this.fzList[i].prenum)) {
this.fzListErrors.push({
rowIndex: i,
field: "prenum",
error: "请输入预填分装数量",
})
isValid = false;
}
} }
if (isValueEmpty(this.fzList[i].actnum)) {
this.fzListErrors.push({
rowIndex: i,
field: "actnum",
error: "请输入实际分装数量",
})
isValid = false;
//
if (this.inputNumberItem.fillType === this.templateFillType) {
if (isValueEmpty(this.fzList[i].actnum)) {
this.fzListErrors.push({
rowIndex: i,
field: "actnum",
error: "请输入实际分装数量",
})
isValid = false;
}
} }
} }
} }
return isValid;
return {valid: isValid,error:""};
}, },
resetErrors() { resetErrors() {
// //

+ 6
- 3
src/components/Template/StepFormPackage.vue View File

@ -125,7 +125,7 @@ export default {
this.formFields[key] = data; this.formFields[key] = data;
}, },
// ZLSubPackage // ZLSubPackage
async validateSubComponents() {
validateSubComponents() {
const refs = []; const refs = [];
// formConfigtypezlfz // formConfigtypezlfz
for (const item of this.formConfig) { for (const item of this.formConfig) {
@ -145,8 +145,11 @@ export default {
} }
} }
} }
const result = await Promise.all(refs.map(ref => ref[0].validateFormData()));
return result[0]
if(refs.length === 0){
return {valid: true, error: ''};
}else{//
return refs[0][0].validateFormData();
}
}, },
getSjResource(){ getSjResource(){
const {allFieldsConfig,formFields} = this; const {allFieldsConfig,formFields} = this;

+ 3
- 3
src/components/Template/mixins/formPackageMixins.js View File

@ -411,10 +411,10 @@ export default {
getFormData() { getFormData() {
// 同时执行数据校验和子组件校验 // 同时执行数据校验和子组件校验
const validateResult = this.validateFormData(); const validateResult = this.validateFormData();
// const subComponentValidateResult = this.validateSubComponents();
const subComponentValidateResult = {valid: true, error: ''};
const subComponentValidateResult = this.validateSubComponents();
// const subComponentValidateResult = {valid: true, error: ''};
console.log(subComponentValidateResult,"subComponentValidateResult")
console.log(subComponentValidateResult,validateResult,"subComponentValidateResult")
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (validateResult.valid && subComponentValidateResult.valid) { if (validateResult.valid && subComponentValidateResult.valid) {
resolve(this.formFields); resolve(this.formFields);

+ 2
- 2
src/views/business/comps/template/comps/sp/SP001.vue View File

@ -27,7 +27,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <button @click="onSave">保存</button> -->
<button @click="onSave">保存</button>
</div> </div>
</template> </template>
@ -314,7 +314,7 @@ export default {
}, },
// //
async onSave() { async onSave() {
let content = this.$refs.stepRef.getStepResource();
let content =await this.$refs.stepRef.getFormData();
console.log(content); console.log(content);
}, },

Loading…
Cancel
Save