Browse Source

多选框加开关控制提交后也能显示所有选项-----子表

lwx_v27
liwenxuan 1 month ago
parent
commit
3054fbea17
  1. 72
      src/components/DesignForm/public/form/childTable.vue
  2. 2
      src/components/DesignForm/public/form/formItem.vue

72
src/components/DesignForm/public/form/childTable.vue

@ -190,8 +190,50 @@ const timeToString = (timeVal: any, types: int) => {
};
//
const formatNumber = (val: any) => {
//
if (typeof val === 'string' && /^\d+(\.\d+)?$/.test(val.toString())) {
//
return Number(val)
} else {
return val
}
}
const config = computed(() => {
return props.data.config || {};
});
const transformOption = (val: string | number, type?: string) => {
switch (config.value.transformData || type) {
case "none":
return val;
case "string":
try {
return val.toString();
} catch (e) {
return val;
}
}
return formatNumber(val);
};
const judgeCheckbox = (val: any, list: any) => {
let valAry = [];
if (Array.isArray(val)) {
if (val.length > 0) {
if (Array.isArray(list)) {
val.forEach((item) => {
list.forEach((ltem) => {
if (item == ltem.value) {
valAry.push(ltem.label);
}
});
});
}
}
}
return valAry.join(',');;
};
let associatedFormsIndexTablekey = 0;
/* const emits = defineEmits<{
@ -248,6 +290,34 @@ function optionsValue3Get1(data: any, fieldName: string) {
v-else-if="item.type == 'datePicker'"
v-html="timeToString(scope.row[item.name], item.control.type)"
></div>
<div
v-else-if="item.type == 'checkbox'"
>
<div v-if="item.control.showAll">
<el-checkbox-group
v-bind="item.control"
:disabled="true"
v-model="scope.row[item.name]"
>
<el-checkbox
v-for="(item1, index) in item.options"
:key="index"
:label="transformOption(item1.value)"
>
<span >{{ item1.label }}</span>
</el-checkbox>
</el-checkbox-group>
</div>
<div v-else>
{{ judgeCheckbox(scope.row[item.name], item.options) }}
</div>
</div>
<div v-else-if="item.type == 'associatedForms'">
<AssociatedForms
:data="item"

2
src/components/DesignForm/public/form/formItem.vue

@ -1180,6 +1180,7 @@ const diGuiJilian = (val: any, options: any[]) => {
>
<div v-if="!data.control.showAll">{{ judgeCheckbox(value, data.options) }}</div>
<el-checkbox-group
v-else
v-bind="control"
@ -1188,6 +1189,7 @@ const diGuiJilian = (val: any, options: any[]) => {
@change="onValueChange(data.type)"
:style="getFormItemInputStyle(configStyle, 4)"
>
<el-checkbox
v-for="(item, index) in props.data.options"
:key="index"

Loading…
Cancel
Save