Browse Source

feat:[模板管理][sp0020]

ouqian
luojie 1 month ago
parent
commit
f4d6a613ce
7 changed files with 220 additions and 155 deletions
  1. +16
    -4
      src/components/Template/BaseInfoFormPackage.vue
  2. +73
    -130
      src/components/Template/HandleFormItem.vue
  3. +29
    -17
      src/components/Template/mixins/formPackageMixins.js
  4. +1
    -1
      src/utils/formPackageCommon.js
  5. +1
    -1
      src/utils/index.js
  6. +25
    -2
      src/views/business/comps/template/comps/sp/SP0020.vue
  7. +75
    -0
      src/views/business/comps/template/formConfig/sp/SP0020.js

+ 16
- 4
src/components/Template/BaseInfoFormPackage.vue View File

@ -78,9 +78,9 @@
<div class="grid-container gap2"> <div class="grid-container gap2">
<div v-for="(sItem, key) in item.config" class="c-Item" :class="getSpanClass(sItem)" :key="key"> <div v-for="(sItem, key) in item.config" class="c-Item" :class="getSpanClass(sItem)" :key="key">
<div class="form-title" v-if="sItem.label">{{ $t(sItem.label) }}</div> <div class="form-title" v-if="sItem.label">{{ $t(sItem.label) }}</div>
<div v-if="sItem.type === 'dateTime'" class="flex1">
<div v-if="sItem.type === 'dateTime' || sItem.type === 'datePicker'" class="flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key" <HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key"
type="dateTime" :item="sItem" v-model="formFields[key]" @copy="onCopy(sItem, key)"
:type="sItem.type" :item="sItem" v-model="formFields[key]" @copy="onCopy(sItem, key)"
:error="errors[key]" @update:error="errors[key] = false" :error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" /> :orange-bg="orangeBgFields[key]" />
</div> </div>
@ -303,15 +303,23 @@
<div class="form-title fs-16" v-if="item.label">{{ $t(item.label) }}</div> <div class="form-title fs-16" v-if="item.label">{{ $t(item.label) }}</div>
<div v-for="(sItem, key) in item.config" class="c-Item grid-container"> <div v-for="(sItem, key) in item.config" class="c-Item grid-container">
<div class="p-r-20 item-center" :class="sItem.span == 1 ? 'full-row' : ''"> <div class="p-r-20 item-center" :class="sItem.span == 1 ? 'full-row' : ''">
<div class="form-title mr-20">{{ $t(sItem.label) }}</div>
<div class="form-title mr-20 checkboxList-title">{{ $t(sItem.label) }}</div>
<div class="flex flex1"> <div class="flex flex1">
<HandleFormItem <HandleFormItem
v-if="sItem.type === 'checkboxList' || sItem.type === 'checkboxTree'"
v-if="sItem.type === 'checkboxTree'"
:field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key" :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key"
:type="sItem.type" :item="sItem" :value="formFields[key]" :type="sItem.type" :item="sItem" :value="formFields[key]"
@change="(e) => onAttachmentChange(key, e)" @change="(e) => onAttachmentChange(key, e)"
:error="errors[key]" @update:error="errors[key] = false" :error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" /> :orange-bg="orangeBgFields[key]" />
<HandleFormItem v-else-if="sItem.type === 'textarea'" :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key"
@blur="onBlur(key, $event)" type="textarea" :item="sItem" v-model="formFields[key]"
@copy="onCopy(sItem, key)" :error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" />
<HandleFormItem v-else-if="sItem.type === 'input'" :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key"
@blur="onBlur(key, $event)" type="input" :item="sItem" v-model="formFields[key]"
@copy="onCopy(sItem, key)" :error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" />
</div> </div>
</div> </div>
</div> </div>
@ -571,4 +579,8 @@ export default {
border-radius: 4px; border-radius: 4px;
border: 1px solid #ff5d5d; border: 1px solid #ff5d5d;
} }
.checkboxList-title{
width: 120px;
text-align: center;
}
</style> </style>

+ 73
- 130
src/components/Template/HandleFormItem.vue View File

@ -33,25 +33,10 @@
{{ option.label }} {{ option.label }}
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
<div v-else-if="type === 'checkboxList'" class="flex1 checkbox-list-container"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')">
<el-checkbox-group v-model="checkboxListValue.checkboxValues" @change="onCheckboxListChange">
<div v-for="option in item.options" :key="option.value" class="checkbox-item">
<el-checkbox :label="option.value" :disabled="getDisabled()">
{{ option.label }}
</el-checkbox>
<div v-if="isShowCheckboxListOther(option)">
<el-input v-model="checkboxListValue.otherValues[option.otherCode]"
:class="{ 'error-border': isOtherInputError(option.otherCode) }"
:placeholder="option.otherPlaceholder || '请输入'"
@blur="onCheckboxListOtherBlur($event, option.otherCode)" />
</div>
</div>
</el-checkbox-group>
</div>
<div v-else-if="type === 'checkboxTree'" class="flex1 checkbox-list-container" <div v-else-if="type === 'checkboxTree'" class="flex1 checkbox-list-container"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')">
<div v-for="group in item.options" :key="group.value" class="checkbox-tree-group" :class="{'item-center': isShowOtherByCheckboxTree(group.value)}">
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '') + (error ? ' form-error-border' : '')">
<div v-for="group in item.options" :key="group.value" class="checkbox-tree-group"
:class="{ 'item-center': isShowOtherByCheckboxTree(group.value) }">
<el-checkbox :label="group.value" :disabled="getDisabled()" <el-checkbox :label="group.value" :disabled="getDisabled()"
:value="getCheckboxTreeChecked(group.value)" :value="getCheckboxTreeChecked(group.value)"
:indeterminate="getCheckboxTreeIndeterminate(group.value)" :indeterminate="getCheckboxTreeIndeterminate(group.value)"
@ -67,27 +52,26 @@
</el-checkbox> </el-checkbox>
<div v-if="isShowOtherByCheckboxTree(child.value) && isCheckboxTreeChecked(child.value)" <div v-if="isShowOtherByCheckboxTree(child.value) && isCheckboxTreeChecked(child.value)"
class="checkbox-tree-input-container"> class="checkbox-tree-input-container">
<el-input maxlength = "100" v-model="inputValue.otherValues[child.value]"
placeholder="请输入" @blur="onCheckboxTreeOtherBlur(child.value, $event)" />
<el-input maxlength="100" v-model="inputValue.otherValues[child.value]"
:disabled="getDisabled()" placeholder="请输入"
@blur="onCheckboxTreeOtherBlur(child.value, $event)" />
</div> </div>
</div> </div>
</div> </div>
<div v-if="isShowOtherByCheckboxTree(group.value) && isCheckboxTreeChecked(group.value)" <div v-if="isShowOtherByCheckboxTree(group.value) && isCheckboxTreeChecked(group.value)"
class="checkbox-tree-input-container"> class="checkbox-tree-input-container">
<el-input maxlength = "100" v-model="inputValue.otherValues[group.value]"
placeholder="请输入" @blur="onCheckboxTreeOtherBlur(group.value, $event)" />
<el-input maxlength="100" v-model="inputValue.otherValues[group.value]"
:disabled="getDisabled()" placeholder="请输入"
@blur="onCheckboxTreeOtherBlur(group.value, $event)" />
</div> </div>
</div> </div>
</div> </div>
<el-date-picker v-else-if="type === 'dateTime'" type="datetime" class="flex1"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue"
:disabled="getDisabled()" format="yyyy/MM/dd HH:mm:ss" :placeholder="getPlaceholder()"
@change="(val) => onDateChange(val, 'yyyy/MM/DD HH:mm:ss')">
</el-date-picker>
<el-date-picker v-else-if="type === 'datePicker'" class="flex1"
<el-date-picker v-else-if="type === 'dateTime' || type === 'datePicker'"
:type="type === 'dateTime' ? 'datetime' : 'date'" class="flex1"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue"
:disabled="getDisabled()" format="yyyy/MM/dd" :placeholder="getPlaceholder()"
@change="(val) => onDateChange(val, 'yyyy/MM/DD')">
:picker-options="pickerOptions" :disabled="getDisabled()"
:format="type === 'dateTime' ? 'yyyy/MM/dd HH:mm:ss' : 'yyyy/MM/dd'" :placeholder="getPlaceholder()"
@change="(val) => onDateChange(val, type === 'dateTime' ? 'yyyy/MM/DD HH:mm:ss' : 'yyyy/MM/DD')">
</el-date-picker> </el-date-picker>
<el-button v-else-if="type === 'button'" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" <el-button v-else-if="type === 'button'" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"
:disabled="getDisabled()" type="primary" @click="handleClickButton(item)"> :disabled="getDisabled()" type="primary" @click="handleClickButton(item)">
@ -229,7 +213,7 @@ import Question from "./icons/Question.vue";
import DecimalInput from "./DecimalInput.vue"; import DecimalInput from "./DecimalInput.vue";
import { EventBus } from "@/utils/eventBus"; import { EventBus } from "@/utils/eventBus";
import moment from "moment"; import moment from "moment";
import { getuuid,isEqual ,deepClone,getDefaultValueByOptions,isValueEmpty} from "@/utils/index.js";
import { getuuid, isEqual, deepClone, getDefaultValueByOptions, isValueEmpty } from "@/utils/index.js";
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import { isShowOtherByCheckboxTree } from "@/utils/formPackageCommon"; import { isShowOtherByCheckboxTree } from "@/utils/formPackageCommon";
@ -293,13 +277,7 @@ export default {
console.log(this.value, "check value"); console.log(this.value, "check value");
let initialOtherValues = {}, checkboxTagList = []; let initialOtherValues = {}, checkboxTagList = [];
if (this.type === 'checkboxList' && !this.value) {
initialValue = {
checkboxValues: [],
otherValues: {}
};
} else if (this.type === 'checkboxTag' && Array.isArray(this.value)) {
if (this.type === 'checkboxTag' && Array.isArray(this.value)) {
// checkboxTagvalue // checkboxTagvalue
checkboxTagList = this.value.map(tag => ({ checkboxTagList = this.value.map(tag => ({
checked: tag.checked, checked: tag.checked,
@ -327,8 +305,6 @@ export default {
oldCheckboxTagList: JSON.parse(JSON.stringify(checkboxTagList)), // checkboxTagList oldCheckboxTagList: JSON.parse(JSON.stringify(checkboxTagList)), // checkboxTagList
fqyqValue: initialValue, // fqyq fqyqValue: initialValue, // fqyq
oldFqyqValue: { ...initialValue }, // fqyq oldFqyqValue: { ...initialValue }, // fqyq
checkboxListValue: initialValue, // checkboxList
oldCheckboxListValue: JSON.parse(JSON.stringify(initialValue)), // checkboxList
uuid: getuuid(), // EventBus uuid: getuuid(), // EventBus
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], //// regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], ////
selectRegentInfo: {},//// selectRegentInfo: {},////
@ -343,17 +319,26 @@ export default {
currentHandleType: '',// currentHandleType: '',//
currentOtherCode: '',//otherCode currentOtherCode: '',//otherCode
currentCheckboxTreeValue: '',//checkboxTree currentCheckboxTreeValue: '',//checkboxTree
isShowOtherByCheckboxTree
isShowOtherByCheckboxTree,
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
shortcuts: [{
text: '今天',
onClick(picker) {
picker.$emit('pick', new Date());
}
}]
}
} }
}, },
watch: { watch: {
value(newVal) { value(newVal) {
console.log(newVal, "newVal") console.log(newVal, "newVal")
if (this.type === 'checkboxList' && newVal && typeof newVal === 'object') {
this.checkboxListValue = JSON.parse(JSON.stringify(newVal));
} else if (this.type === 'checkboxTag' && Array.isArray(newVal)) {
if (this.type === 'checkboxTag' && Array.isArray(newVal)) {
// checkboxTagvalue // checkboxTagvalue
this.checkboxTagList = newVal.map(tag => ({ this.checkboxTagList = newVal.map(tag => ({
checked: tag.checked, checked: tag.checked,
@ -864,20 +849,6 @@ export default {
this.emitCheckboxTagValue(); this.emitCheckboxTagValue();
this.onCommonHandleSaveRecord(); this.onCommonHandleSaveRecord();
}, },
// checkboxList
isShowCheckboxListOther(option) {
const { checkboxValues } = this.checkboxListValue
if (!checkboxValues) {
return false;
}
return option.otherCode && checkboxValues.includes(option.value);
},
// checkboxListcheckbox
onCheckboxListChange(val) {
this.currentHandleType = 'checkboxListValue';
this.checkboxListValue.checkboxValues = val;
this.onCommonHandleSaveRecord();
},
// tag // tag
onTagBlur(tagIndex) { onTagBlur(tagIndex) {
@ -918,13 +889,6 @@ export default {
onBlur(e) { onBlur(e) {
this.onCommonHandleSaveRecord(e.target.value); this.onCommonHandleSaveRecord(e.target.value);
}, },
// checkboxList
onCheckboxListOtherBlur(e, otherCode) {
this.currentHandleType = "checkboxListOther";
this.currentOtherCode = otherCode;
this.checkboxListValue.otherValues[otherCode] = e.target.value;
this.onCommonHandleSaveRecord(e.target.value);
},
// checkboxTree // checkboxTree
isCheckboxTreeChecked(value) { isCheckboxTreeChecked(value) {
@ -964,11 +928,11 @@ export default {
onCheckboxTreeParentChange(group, checked) { onCheckboxTreeParentChange(group, checked) {
this.currentHandleType = 'checkboxTreeCheckbox'; this.currentHandleType = 'checkboxTreeCheckbox';
this.currentCheckboxTreeValue = group.value; this.currentCheckboxTreeValue = group.value;
// //
const parentItem = this.getOrCreateCheckedItem(group.value); const parentItem = this.getOrCreateCheckedItem(group.value);
parentItem.checked = checked; parentItem.checked = checked;
// //
if (group.children && group.children.length > 0) { if (group.children && group.children.length > 0) {
group.children.forEach(child => { group.children.forEach(child => {
@ -980,7 +944,7 @@ export default {
} }
}); });
} }
this.onCommonHandleSaveRecord(); this.onCommonHandleSaveRecord();
}, },
@ -988,40 +952,40 @@ export default {
onCheckboxTreeChildChange(group, childValue, checked) { onCheckboxTreeChildChange(group, childValue, checked) {
this.currentHandleType = 'checkboxTreeCheckbox'; this.currentHandleType = 'checkboxTreeCheckbox';
this.currentCheckboxTreeValue = childValue; this.currentCheckboxTreeValue = childValue;
// //
const childItem = this.getOrCreateCheckedItem(childValue); const childItem = this.getOrCreateCheckedItem(childValue);
childItem.checked = checked; childItem.checked = checked;
// otherValues // otherValues
if (!checked) { if (!checked) {
delete this.inputValue.otherValues[childValue]; delete this.inputValue.otherValues[childValue];
} }
// //
this.updateParentState(group); this.updateParentState(group);
this.onCommonHandleSaveRecord(); this.onCommonHandleSaveRecord();
}, },
// //
updateParentState(group) { updateParentState(group) {
if (!group.children || group.children.length === 0) return; if (!group.children || group.children.length === 0) return;
const parentItem = this.getOrCreateCheckedItem(group.value); const parentItem = this.getOrCreateCheckedItem(group.value);
const childValues = group.children.map(child => child.value); const childValues = group.children.map(child => child.value);
// //
let checkedCount = 0; let checkedCount = 0;
let totalCount = childValues.length; let totalCount = childValues.length;
childValues.forEach(childValue => { childValues.forEach(childValue => {
const childItem = this.inputValue.checkedValues.find(item => item.label === childValue); const childItem = this.inputValue.checkedValues.find(item => item.label === childValue);
if (childItem && childItem.checked) { if (childItem && childItem.checked) {
checkedCount++; checkedCount++;
} }
}); });
// //
if (checkedCount === 0) { if (checkedCount === 0) {
// //
@ -1038,23 +1002,23 @@ export default {
if (!this.inputValue || !this.inputValue.checkedValues) { if (!this.inputValue || !this.inputValue.checkedValues) {
return false; return false;
} }
// group // group
const group = this.item.options.find(opt => opt.value === groupValue); const group = this.item.options.find(opt => opt.value === groupValue);
if (!group || !group.children || group.children.length === 0) { if (!group || !group.children || group.children.length === 0) {
return false; return false;
} }
const childValues = group.children.map(child => child.value); const childValues = group.children.map(child => child.value);
let checkedCount = 0; let checkedCount = 0;
childValues.forEach(childValue => { childValues.forEach(childValue => {
const childItem = this.inputValue.checkedValues.find(item => item.label === childValue); const childItem = this.inputValue.checkedValues.find(item => item.label === childValue);
if (childItem && childItem.checked) { if (childItem && childItem.checked) {
checkedCount++; checkedCount++;
} }
}); });
// //
return checkedCount > 0 && checkedCount < childValues.length; return checkedCount > 0 && checkedCount < childValues.length;
}, },
@ -1095,15 +1059,6 @@ export default {
this.visible = true; this.visible = true;
} }
}, },
getCheckboxListInfo() {
const { otherValues, checkboxValues } = this.checkboxListValue;
const { otherValues: oldOtherValues, checkboxValues: oldCheckboxValues } = this.oldCheckboxListValue;
const o = {
"checkboxListValue": { oldValue: oldCheckboxValues, newValue: checkboxValues, des: "" },
"checkboxListOther": { oldValue: oldOtherValues[this.currentOtherCode], newValue: otherValues[this.currentOtherCode], des: "样品信息:" },
}
return o[this.currentHandleType];
},
getFqyqInfo() { getFqyqInfo() {
const { mainRadio, inputValue, subRadio } = this.fqyqValue; const { mainRadio, inputValue, subRadio } = this.fqyqValue;
const { mainRadio: oldMainRadio, inputValue: oldInputValue, subRadio: oldSubRadio } = this.oldFqyqValue; const { mainRadio: oldMainRadio, inputValue: oldInputValue, subRadio: oldSubRadio } = this.oldFqyqValue;
@ -1172,17 +1127,12 @@ export default {
// //
let isSame = true, isOldValueEmpty = true; let isSame = true, isOldValueEmpty = true;
const { currentHandleType } = this; const { currentHandleType } = this;
// checkboxListotherValues
if (this.type === 'checkboxList') {
const current = this.getCheckboxListInfo();
isSame = isEqual(current.oldValue, current.newValue);
isOldValueEmpty = isValueEmpty(current.oldValue);
} else if (this.type === "checkboxTag") {
if (this.type === "checkboxTag") {
// checkboxTagtagIndex // checkboxTagtagIndex
const currentTag = this.checkboxTagList[this.currentTagIndex]; const currentTag = this.checkboxTagList[this.currentTagIndex];
const oldTag = this.oldCheckboxTagList[this.currentTagIndex] || {}; const oldTag = this.oldCheckboxTagList[this.currentTagIndex] || {};
isSame = isEqual(oldTag.checked, currentTag.checked); isSame = isEqual(oldTag.checked, currentTag.checked);
isOldValueEmpty = oldTag.checked===undefined;
isOldValueEmpty = oldTag.checked === undefined;
} else if (this.type === "fqyq") { } else if (this.type === "fqyq") {
const current = this.getFqyqInfo(); const current = this.getFqyqInfo();
isSame = isEqual(current.oldValue, current.newValue); isSame = isEqual(current.oldValue, current.newValue);
@ -1192,7 +1142,7 @@ export default {
const { oldValue, newValue } = current; const { oldValue, newValue } = current;
if (currentHandleType === "checkboxTreeCheckbox") { if (currentHandleType === "checkboxTreeCheckbox") {
isSame = isEqual(oldValue.checked, newValue.checked); isSame = isEqual(oldValue.checked, newValue.checked);
isOldValueEmpty = oldValue.checked===undefined;
isOldValueEmpty = oldValue.checked === undefined;
} else { } else {
isSame = isEqual(current.oldValue, current.newValue); isSame = isEqual(current.oldValue, current.newValue);
isOldValueEmpty = isValueEmpty(current.oldValue); isOldValueEmpty = isValueEmpty(current.oldValue);
@ -1219,12 +1169,7 @@ export default {
resetRecord() { resetRecord() {
// //
let oldValue = this.oldValue; let oldValue = this.oldValue;
if (this.type === 'checkboxList') {
oldValue = {
checkboxValues: this.oldCheckboxListValue.checkboxValues,
otherValues: this.oldCheckboxListValue.otherValues
};
} else if (this.type === "checkboxTag") {
if (this.type === "checkboxTag") {
// checkboxTag退tagIndex // checkboxTag退tagIndex
if (this.currentTagIndex >= 0 && this.currentTagIndex < this.oldCheckboxTagList.length) { if (this.currentTagIndex >= 0 && this.currentTagIndex < this.oldCheckboxTagList.length) {
const oldTag = this.oldCheckboxTagList[this.currentTagIndex]; const oldTag = this.oldCheckboxTagList[this.currentTagIndex];
@ -1269,11 +1214,6 @@ export default {
recordOldVlaue = `${current.des + current.oldValue}`; recordOldVlaue = `${current.des + current.oldValue}`;
recordValue = `${current.des + current.newValue}`; recordValue = `${current.des + current.newValue}`;
isModify = !!this.oldFqyqValue.mainRadio isModify = !!this.oldFqyqValue.mainRadio
} else if (this.type === "checkboxList") {
const current = this.getCheckboxListInfo();
recordOldVlaue = `${current.des + (current.oldValue || '')}`;
recordValue = `${current.des + (current.newValue || '')}`;
isModify = !!current.oldValue;
} else if (this.type === "checkboxTree") { } else if (this.type === "checkboxTree") {
// checkboxTree // checkboxTree
const current = this.getCheckboxTreeInfo(); const current = this.getCheckboxTreeInfo();
@ -1283,7 +1223,7 @@ export default {
recordValue = `${newValue.label || ''}:${newValue.checked ? '勾选' : '未勾选'}`; recordValue = `${newValue.label || ''}:${newValue.checked ? '勾选' : '未勾选'}`;
isModify = newValue.checked !== undefined; isModify = newValue.checked !== undefined;
} else { } else {
recordOldVlaue = `${current.des +( current.oldValue || '')}`;
recordOldVlaue = `${current.des + (current.oldValue || '')}`;
recordValue = `${current.des + (current.newValue || '')}`; recordValue = `${current.des + (current.newValue || '')}`;
isModify = !!current.oldValue; isModify = !!current.oldValue;
} }
@ -1306,9 +1246,7 @@ export default {
} }
// oldValueoldOtherValues // oldValueoldOtherValues
if (this.type === 'checkboxList') {
this.oldCheckboxListValue = JSON.parse(JSON.stringify(this.checkboxListValue));
} else if (this.type === "checkboxTag") {
if (this.type === "checkboxTag") {
// checkboxTagtagIndex // checkboxTagtagIndex
if (this.currentTagIndex >= 0 && this.currentTagIndex < this.checkboxTagList.length) { if (this.currentTagIndex >= 0 && this.currentTagIndex < this.checkboxTagList.length) {
this.oldCheckboxTagList[this.currentTagIndex] = { ...this.checkboxTagList[this.currentTagIndex] }; this.oldCheckboxTagList[this.currentTagIndex] = { ...this.checkboxTagList[this.currentTagIndex] };
@ -1321,12 +1259,7 @@ export default {
this.oldFqyqValue = JSON.parse(JSON.stringify(this.fqyqValue)); this.oldFqyqValue = JSON.parse(JSON.stringify(this.fqyqValue));
} }
let value = this.inputValue; let value = this.inputValue;
if (this.type === 'checkboxList') {
value = {
checkboxValues: this.checkboxListValue.checkboxValues,
otherValues: this.checkboxListValue.otherValues
};
} else if (this.type === "checkboxTag") {
if (this.type === "checkboxTag") {
value = [...this.checkboxTagList]; value = [...this.checkboxTagList];
} else if (this.type === "fqyq") { } else if (this.type === "fqyq") {
value = { ...this.fqyqValue }; value = { ...this.fqyqValue };
@ -1380,14 +1313,6 @@ export default {
} }
return commonInfo; return commonInfo;
}, },
// checkboxListotherCode
isOtherInputError(otherCode) {
if (!this.error) {
return false;
}
// otherCode
return isValueEmpty(this.otherValues[otherCode]);
},
handleClickable(item, event) { handleClickable(item, event) {
if (this.templateFillType !== 'actFill') { if (this.templateFillType !== 'actFill') {
return return
@ -1443,7 +1368,7 @@ export default {
return this.$t("template.common.pleaseSelect") return this.$t("template.common.pleaseSelect")
} }
let prex = "template.common.pleaseFillIn" let prex = "template.common.pleaseFillIn"
if (type === "select" || type === "dateTime") {
if (type === "select" || type === "dateTime" || type === "datePicker") {
prex = "template.common.pleaseSelect" prex = "template.common.pleaseSelect"
} }
return placeholder ? this.$t(placeholder) : (this.$t(prex) + this.$t(label)) return placeholder ? this.$t(placeholder) : (this.$t(prex) + this.$t(label))
@ -1938,6 +1863,11 @@ export default {
} }
} }
.el-checkbox__input.is-indeterminate .el-checkbox__inner {
background-color: #f9c588;
border-color: #f9c588;
}
.el-radio { .el-radio {
&.is-checked { &.is-checked {
.el-radio__label { .el-radio__label {
@ -2038,12 +1968,25 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.checkbox-tree-input-container{
.checkbox-tree-input-container {
margin-left: 10px; margin-left: 10px;
width: 500px; width: 500px;
} }
.item-center{
.item-center {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.checkbox-tree-group {
padding: 5px 0;
}
.form-error-border {
box-shadow: 0 0 6px #ffc3c3;
padding: 8px;
border-radius: 4px;
border: 1px solid #ff5d5d;
}
</style> </style>

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

@ -1,7 +1,6 @@
import _ from "lodash"; import _ from "lodash";
import { getuuid, isEqual } from "@/utils/index.js";
import { EventBus } from "@/utils/eventBus";
import moment from "moment";
import { getuuid, isEqual, isValueEmpty } from "@/utils/index.js";
import { isShowOtherByCheckboxTree } from "@/utils/formPackageCommon.js";
export default { export default {
inject: ["getZdxgjl", "updateZdxgjl"], inject: ["getZdxgjl", "updateZdxgjl"],
watch: { watch: {
@ -361,8 +360,34 @@ export default {
} }
continue continue
}else if(o.type === "checkboxTree"){
const checkboxTreeValue = formFields[key] || {};
const {checkedValues=[],otherValues = {}} = checkboxTreeValue;;
const {options = []} = o;
//需要校验第一层是否有选中项
const parentOptions = options.map(item => item.label);
const isChecked = parentOptions.some(option => {
var found = checkedValues.find(item => item.label === option);
return found && found.checked === true;
});
//获取所有选中的选项
const allCheckedOptions = checkedValues.filter(item => item.checked).map(item => item.label);
//再筛选出需要显示其他输入框的选项
const otherOptions = allCheckedOptions.filter((label)=>isShowOtherByCheckboxTree(label))
const isHasOtherInfo = otherOptions.every(item => otherValues[item]);
console.log(otherOptions,allCheckedOptions,isHasOtherInfo,"otherOptions")
console.log(o,checkedValues,otherValues,options,isChecked,"checkboxTreeValue")
if (!isChecked || !isHasOtherInfo) {
errors.push({
field: key,
label: o.label,
error: "请选择方法学验证"
});
this.$set(this.errors, key, true);
}
continue
} }
if (this.isValueEmpty(formFields[key])) {
if (isValueEmpty(formFields[key])) {
// 其他字段需要判断是否显示再校验 // 其他字段需要判断是否显示再校验
if (o.label === "template.common.other" && !this.isShowOther(formFields[o.parentKey]) && o.parentType !== "radioAndOther") { if (o.label === "template.common.other" && !this.isShowOther(formFields[o.parentKey]) && o.parentType !== "radioAndOther") {
continue continue
@ -399,19 +424,6 @@ export default {
errors: errors 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() { getFormData() {
// 同时执行数据校验和子组件校验 // 同时执行数据校验和子组件校验
const validateResult = this.validateFormData(); const validateResult = this.validateFormData();

+ 1
- 1
src/utils/formPackageCommon.js View File

@ -20,6 +20,6 @@ export const isShowOtherByRadioAndOther = (v = '', col) => {
//checkboxTree判断是否显示其他输入框 //checkboxTree判断是否显示其他输入框
export const isShowOtherByCheckboxTree = (v = "")=>{ export const isShowOtherByCheckboxTree = (v = "")=>{
const otherArr = ['其他', '样品信息', '样品']
const otherArr = ['其他', '样品信息', '样品','部分接受']
return otherArr.includes(v) return otherArr.includes(v)
} }

+ 1
- 1
src/utils/index.js View File

@ -432,7 +432,7 @@ export function getuuid() {
// 判断值是否为空 // 判断值是否为空
export function isValueEmpty(value) { export function isValueEmpty(value) {
if (value === null || value === undefined || value === '') {
if (value === null || value === undefined || value === '' || value === false) {
return true return true
} }
if (typeof value === 'string' && value.trim() === '') { if (typeof value === 'string' && value.trim() === '') {

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

@ -10,6 +10,12 @@
:ref="refConfig.baseInfoRef" :formConfig="baseInfoFormConfig" :formData="formData" /> :ref="refConfig.baseInfoRef" :formConfig="baseInfoFormConfig" :formData="formData" />
<BaseInfoFormPackage fieldItemLabel="试验内容" label="试验内容" <BaseInfoFormPackage fieldItemLabel="试验内容" label="试验内容"
:ref="refConfig.synrRef" :formConfig="synrFormConfig" :formData="formData" /> :ref="refConfig.synrRef" :formConfig="synrFormConfig" :formData="formData" />
<BaseInfoFormPackage fieldItemLabel="仪器结果" label="仪器结果"
:ref="refConfig.yqjgRef" :formConfig="yqjgFormConfig" :formData="formData" />
<BaseInfoFormPackage fieldItemLabel="采集日期" label="采集日期"
:ref="refConfig.cjrqRef" :formConfig="cjrqFormConfig" :formData="formData" />
<BaseInfoFormPackage fieldItemLabel="分析批数据文件" label="分析批数据文件"
:ref="refConfig.fxpsjwjRef" :formConfig="fxpsjwjFormConfig" :formData="formData" />
<BaseInfoFormPackage fieldItemLabel="template.common.remark" label="template.common.remark" <BaseInfoFormPackage fieldItemLabel="template.common.remark" label="template.common.remark"
:ref="refConfig.remarkRef" :formConfig="remarkConig" :formData="formData" /> :ref="refConfig.remarkRef" :formConfig="remarkConig" :formData="formData" />
</div> </div>
@ -29,12 +35,15 @@ import CustomTable from '@/components/Template/CustomTable.vue';
import TableOpertaionDelete from "@/components/Template/operation/TableOpertaionDelete.vue" import TableOpertaionDelete from "@/components/Template/operation/TableOpertaionDelete.vue"
import { getBaseInfoFormConfig} from "../../formConfig/sp/SP0019"; import { getBaseInfoFormConfig} from "../../formConfig/sp/SP0019";
import { getSynrFormConfig} from "../../formConfig/sp/SP0020";
import { getSynrFormConfig, getYqjgFormConfig, getCjrqFormConfig, getFxpsjwjFormConfig} from "../../formConfig/sp/SP0020";
const refConfig = { const refConfig = {
baseInfoRef: "baseInfoRef", baseInfoRef: "baseInfoRef",
remarkRef: "remarkRef", remarkRef: "remarkRef",
synrRef: "synrRef", synrRef: "synrRef",
yqjgRef: "yqjgRef",
cjrqRef: "cjrqRef",
fxpsjwjRef: "fxpsjwjRef",
} }
const compRefs = Object.values(refConfig); const compRefs = Object.values(refConfig);
@ -50,6 +59,19 @@ export default {
}, },
}, },
computed: { computed: {
//
fxpsjwjFormConfig(){
return getFxpsjwjFormConfig(this);
},
//
cjrqFormConfig(){
return getCjrqFormConfig(this);
},
//
yqjgFormConfig(){
return getYqjgFormConfig(this);
},
//
synrFormConfig(){ synrFormConfig(){
return getSynrFormConfig(this); return getSynrFormConfig(this);
}, },
@ -113,7 +135,8 @@ export default {
}, },
// //
async onSave() { async onSave() {
const formData = await this.getFormData();
console.log(formData)
}, },
} }
}; };

+ 75
- 0
src/views/business/comps/template/formConfig/sp/SP0020.js View File

@ -56,4 +56,79 @@ export const getSynrFormConfig = ()=>{
} }
}, },
] ]
}
//仪器结果
export const getYqjgFormConfig = ()=>{
return [
{
type: 'checkboxList',
config: {
jg: {
type: 'checkboxTree',
label: '结果',
options:[
{ label: '分析批接受', value: '分析批接受' },
{ label: '分析批拒绝', value: '分析批拒绝' },
{ label: '部分接受', value: '部分接受' },
],
span:1,
fillType:"actFill"
},
yzkcjg: {
type: 'textarea',
label: '验证考察结果',
span:1,
fillType:"actFill",
maxlength: 1000,
rows: 5
},
}
},
]
}
//分析批数据文件
export const getFxpsjwjFormConfig = ()=>{
return [
{
type: 'checkboxList',
config: {
fxpsjwjm: {
type: 'input',
label: '分析批数据文件名',
span:1,
fillType:"actFill",
maxlength: 100,
},
fxpsjlj: {
type: 'input',
label: '分析批数据路径',
span:1,
fillType:"actFill",
maxlength: 150,
},
}
},
]
}
//采集日期
export const getCjrqFormConfig = ()=>{
return [
{
type: 'cellItem',
config: {
cjksrq: {
type: 'datePicker',
label: '采集开始日期',
fillType:"actFill"
},
cjjsrq: {
type: 'datePicker',
label: '采集结束日期',
fillType:"actFill"
},
}
},
]
} }

Loading…
Cancel
Save