Browse Source

feat:[公共组件][customTabel增加checkbox-待测试]

ouqian
ouqian 1 month ago
parent
commit
2cd71524d0
5 changed files with 116 additions and 8 deletions
  1. +51
    -0
      src/components/Template/CustomTable.vue
  2. +6
    -1
      src/lang/en/template/dl.js
  3. +6
    -1
      src/lang/zh/template/dl.js
  4. +53
    -5
      src/views/business/comps/template/comps/dl/DL008.vue
  5. +0
    -1
      src/views/business/comps/template/comps/dl/DL009.vue

+ 51
- 0
src/components/Template/CustomTable.vue View File

@ -122,6 +122,19 @@
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" />
</div>
</template>
<template v-else-if="col.bodyType === 'checkbox'">
<div class="flex flex-wrap">
<HandleFormItem
:fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex"
:fieldItemLabel="fieldItemLabel"
type="checkbox"
v-model="row[col.prop]"
:item="getBodyItem(col, rowIndex)"
@change="onCheckboxChange(rowIndex, colIndex, col, $event)"
:error="hasError(rowIndex, colIndex, col.prop)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" />
</div>
</template>
</div>
<div v-show="isShowOther(row[col.prop], col)" class="flex flex1">
@ -342,6 +355,18 @@ export default {
this.onErrorUpdate(rowIndex, colIndex, col.prop, !isValid);
this.$emit("onCheckboxTagChange", rowIndex, col, value)
},
// checkbox
onCheckboxChange(rowIndex, colIndex, col, value) {
this.localDataSource[rowIndex][col.prop] = value;
//
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === rowIndex &&
error.colIndex === colIndex &&
error.field === col.prop)
);
this.$emit("onCheckboxChange", rowIndex, col, value);
this.justUpdateFilledFormData();
},
handleClickButton(e, data, key, rowIndex, colIndex) {
this.$emit("clickButton", key, rowIndex, colIndex, e, data,)
},
@ -524,6 +549,23 @@ export default {
this.formErrors.push(errorItem);
}
}
} else if (col.bodyType === "checkbox") {
// checkbox - checkbox
//
if (col.required && !col.bodyDisabled) {
const hasChecked = Array.isArray(mainValue) ? mainValue.length > 0 : mainValue;
if (!hasChecked) {
const errorItem = {
rowIndex,
colIndex,
field: col.prop,
label: this.$t(col.label),
error: `请选择${this.$t(col.label)}`
};
errors.push(errorItem);
this.formErrors.push(errorItem);
}
}
} else {
if (isValueEmpty(mainValue) && !col.bodyDisabled && col.bodyType !== 'span' && col.bodyType !== 'button') {
const errorItem = {
@ -735,6 +777,15 @@ export default {
if (col.bodyDisabled) {
item.disabled = col.bodyDisabled;
}
// checkboxLabel -
const dynamicLabelKey = col.prop + 'Label';
if (currentItem && currentItem[dynamicLabelKey]) {
// labeljzbh1Label
item.checkboxLabel = currentItem[dynamicLabelKey];
} else if (col.checkboxLabel !== undefined && col.checkboxLabel !== '') {
// 使checkboxLabel
item.checkboxLabel = this.$t(col.checkboxLabel);
}
return item
},
getBodyButtonItem(col,) {

+ 6
- 1
src/lang/en/template/dl.js View File

@ -40,7 +40,12 @@ export default {
dl008: {
...common,
cxqk: 'Imaging Status',
wrqk: 'Contamination Status'
wrqk: 'Contamination Status',
jlzb: 'Dose Group',
jzbh1: 'Strain Number',
jzbh2: 'Strain Number',
jzbh3: 'Strain Number',
jzbh4: 'Strain Number'
},
dl009: {
...common,

+ 6
- 1
src/lang/zh/template/dl.js View File

@ -40,7 +40,12 @@ export default {
dl008: {
...common,
cxqk: '成像情况',
wrqk: '污染情况'
wrqk: '污染情况',
jlzb: '剂量组别',
jzbh1: '菌种编号',
jzbh2: '菌种编号',
jzbh3: '菌种编号',
jzbh4: '菌种编号'
},
dl009: {
...common,

+ 53
- 5
src/views/business/comps/template/comps/dl/DL008.vue View File

@ -52,9 +52,12 @@
:columns="cxqkColumns"
:ref="refConf.cxqk"
@onRegentSubmit="(e) => onRegentSubmit(e)"
:showOperation="fillType === 'actFill'"
:formData="formData"
:showOperation="false"
:showAddRow="false"
:formData="cxqkFormData"
:prefixKey="`cxqkTable`"
:isBorder="true"
:showSort="false"
>
</CustomTable>
<BaseInfoFormPackage
@ -114,6 +117,13 @@ export default {
}
},
computed: {
//
cxqkFormData() {
return {
stepTableFormData: this.formData.stepTableFormData_1 || [],
headerSelectFields: {}
}
},
//
remarkConfig() {
return [
@ -203,9 +213,45 @@ export default {
}
]
},
// - TODO:
// -checkbox
cxqkColumns() {
return []
return [
{
label: 'template.dl.dl008.jlzb',
prop: 'jlzb',
bodyType: 'input',
bodyFillType: 'actFill',
width: 100
},
{
label: 'template.dl.dl008.jzbh1',
prop: 'jzbh1',
bodyType: 'checkbox',
bodyFillType: 'actFill',
width: 150
},
{
label: 'template.dl.dl008.jzbh2',
prop: 'jzbh2',
bodyType: 'checkbox',
bodyFillType: 'actFill',
width: 150
},
{
label: 'template.dl.dl008.jzbh3',
prop: 'jzbh3',
bodyType: 'checkbox',
bodyFillType: 'actFill',
width: 150
},
{
label: 'template.dl.dl008.jzbh4',
prop: 'jzbh4',
bodyType: 'checkbox',
bodyFillType: 'actFill',
width: 150
}
]
},
// 使
yqsyColumns() {
@ -266,7 +312,9 @@ export default {
refConf
}
},
mounted() {},
mounted() {
// 使
},
methods: {
//
deleteTableRow(rowIndex, refName) {

+ 0
- 1
src/views/business/comps/template/comps/dl/DL009.vue View File

@ -91,7 +91,6 @@ import LineLabel from '@/components/Template/LineLabel'
import TableList from '@/components/Template/Table'
import Step from '@/components/Template/Step'
import templateMixin from '../../mixins/templateMixin'
import moment from 'moment'
const refConf = {
base: 'baseInfoRef',

Loading…
Cancel
Save