Browse Source

feat:[模板管理][新增radioAndOther类型]

lkf
luojie 1 month ago
parent
commit
0899b194db
8 changed files with 149 additions and 32 deletions
  1. +20
    -1
      src/components/Template/BaseInfoFormPackage.vue
  2. +35
    -12
      src/components/Template/HandleFormItem.vue
  3. +21
    -3
      src/components/Template/mixins/formPackageMixins.js
  4. +9
    -1
      src/utils/formPackageCommon.js
  5. +12
    -0
      src/views/business/comps/template/comps/sp/SP0019.vue
  6. +48
    -9
      src/views/business/comps/template/comps/yp/YP002.vue
  7. +0
    -3
      src/views/business/comps/template/dialog/SelectMixReagentDialog.vue
  8. +4
    -3
      src/views/business/comps/template/formConfig/sp/SP0019.js

+ 20
- 1
src/components/Template/BaseInfoFormPackage.vue View File

@ -130,6 +130,23 @@
@onRegentSubmit="(data, inputValue) => onRegentSubmit(data, inputValue, key, sItem)" @onRegentSubmit="(data, inputValue) => onRegentSubmit(data, inputValue, key, sItem)"
:item="sItem" :value="formFields[key]" /> :item="sItem" :value="formFields[key]" />
</div> </div>
<!-- 勾选某些选项时出现其他输入框 -->
<div v-else-if="sItem.type === 'radioAndOther'" class="item-center">
<HandleFormItem
:field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key" type="radio"
:error="errors[key]"
@update:error="errors[key] = false"
@change="(e,type) => onSelectChange(key, e, type)"
:item="sItem" :value="formFields[key]" />
<div v-show="isShowOtherByRadioAndOther(formFields[key], sItem)" class="flex1 ml-10">
<HandleFormItem :field-item-label="fieldItemLabel"
:field-key="prefixKey + '_' + sItem.otherCode" @blur="onBlur(key, $event)"
:item="getRadioOtherItem(sItem)" v-model="formFields[sItem.otherCode]"
@copy="onCopy(sItem, key)" :error="errors[sItem.otherCode]"
@update:error="errors[sItem.otherCode] = false"
:orange-bg="orangeBgFields[sItem.otherCode]" />
</div>
</div>
</div> </div>
@ -296,7 +313,7 @@
<script> <script>
import HandleFormItem from "./HandleFormItem.vue"; import HandleFormItem from "./HandleFormItem.vue";
import LineLabel from "./LineLabel.vue"; import LineLabel from "./LineLabel.vue";
import { isShowOther } from "@/utils/formPackageCommon.js";
import { isShowOther,isShowOtherByRadioAndOther } from "@/utils/formPackageCommon.js";
import { isRegent } from "@/utils/index.js"; import { isRegent } from "@/utils/index.js";
import formPackageMixins from '@/components/Template/mixins/formPackageMixins.js' import formPackageMixins from '@/components/Template/mixins/formPackageMixins.js'
@ -339,6 +356,7 @@ export default {
orangeBgFields: {},// orangeBgFields: {},//
oldFormFields: {},// oldFormFields: {},//
isShowOther, isShowOther,
isShowOtherByRadioAndOther,
isRegent isRegent
}; };
}, },
@ -359,6 +377,7 @@ export default {
fillType: sItem.subFillType || sItem.fillType fillType: sItem.subFillType || sItem.fillType
} }
}, },
} }
} }
</script> </script>

+ 35
- 12
src/components/Template/HandleFormItem.vue View File

@ -1,6 +1,6 @@
<template> <template>
<div class="flex flex1">
<div class="flex1 flex">
<div class="flex " :class="type !=='radio' ? 'flex1' : ''">
<div class="flex" :class="type !=='radio' ? 'flex1' : ''">
<el-input v-if="type === 'input'" :maxlength="item.maxlength || 50" :disabled="getDisabled()" <el-input v-if="type === 'input'" :maxlength="item.maxlength || 50" :disabled="getDisabled()"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" @blur="onBlur" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" @blur="onBlur"
:placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" /> :placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" />
@ -24,6 +24,15 @@
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue"
:disabled="getDisabled()" :placeholder="getPlaceholder()" @change="onItemCheckboxChange"> :disabled="getDisabled()" :placeholder="getPlaceholder()" @change="onItemCheckboxChange">
</el-checkbox> </el-checkbox>
<el-radio-group v-else-if="type === 'radio'" v-model="inputValue"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"
:disabled="getDisabled()"
@change="onItemCheckboxChange"
>
<el-radio v-for="option in item.options" :key="option.value" :label="option.value" :disabled="getDisabled()">
{{ option.label }}
</el-radio>
</el-radio-group>
<div v-else-if="type === 'checkboxList'" class="flex1 checkbox-list-container" <div v-else-if="type === 'checkboxList'" class="flex1 checkbox-list-container"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"> :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')">
<el-checkbox-group v-model="inputValue" @change="onInputChange"> <el-checkbox-group v-model="inputValue" @change="onInputChange">
@ -480,9 +489,10 @@ export default {
executeReagentSubmit(data) { executeReagentSubmit(data) {
this.inputValue = data.selectedId; this.inputValue = data.selectedId;
const {filledCodes=[]} = this.item; const {filledCodes=[]} = this.item;
const {selectInfo} = data;
console.log(filledCodes,"filledCodes")
const {selectInfo,row} = data;
if(filledCodes.length>0){ if(filledCodes.length>0){
this.inputValue = selectInfo[filledCodes[0]]+"("+selectInfo[filledCodes[1]]+")";
this.inputValue = row[filledCodes[0]]+"("+row[filledCodes[1]]+")";
} }
this.selectRegentInfo = data; this.selectRegentInfo = data;
EventBus.$emit("hideSelectMixReagentDialog"); EventBus.$emit("hideSelectMixReagentDialog");
@ -1515,6 +1525,18 @@ export default {
} }
} }
}
.orange-border {
.checkbox-list-container {
border-color: #f9c588;
&:hover {
border-color: #f79b31;
}
}
.el-checkbox { .el-checkbox {
&.is-checked { &.is-checked {
.el-checkbox__label { .el-checkbox__label {
@ -1527,16 +1549,17 @@ export default {
} }
} }
} }
}
.orange-border {
.checkbox-list-container {
border-color: #f9c588;
.el-radio {
&.is-checked {
.el-radio__label {
color: #606266;
}
&:hover {
border-color: #f79b31;
.el-radio__inner {
background-color: #f9c588;
border-color: #f9c588;
}
} }
} }
} }

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

@ -68,6 +68,7 @@ export default {
}, },
getRegentItem(item,fieldCode="type"){ getRegentItem(item,fieldCode="type"){
const type = item[fieldCode] ; const type = item[fieldCode] ;
console.log(item,"type")
return { return {
label: "", label: "",
type, type,
@ -153,6 +154,14 @@ export default {
parentLabel: sItem.label, parentLabel: sItem.label,
} }
}, },
getRadioOtherItem(sItem) {
return {
// label: sItem.otherLabel ? this.$t(sItem.otherLabel) : this.$t("template.common.other"),
fillType: sItem.fillType,
maxlength: sItem.otherMaxlength || 50,
parentLabel: sItem.label,
}
},
getClickableItem(sItem) { getClickableItem(sItem) {
return { return {
label: "", label: "",
@ -206,14 +215,14 @@ export default {
// 处理特殊字段 - "其他"字段 // 处理特殊字段 - "其他"字段
if (currentConfig.otherCode) { if (currentConfig.otherCode) {
const { otherCode } = currentConfig;
const { otherCode,type } = currentConfig;
//如果是更新的话,优先使用formFields中的值 //如果是更新的话,优先使用formFields中的值
if (update) { if (update) {
result[otherCode] = formFields[otherCode] || formData[otherCode] || ''; result[otherCode] = formFields[otherCode] || formData[otherCode] || '';
} else { } else {
result[otherCode] = formData[otherCode] || formFields[otherCode] || ''; result[otherCode] = formData[otherCode] || formFields[otherCode] || '';
} }
config[otherCode] = { label: "template.common.other", parentKey: key, type: "input", fillType: currentConfig.fillType }
config[otherCode] = { label: "template.common.other",parentType:type, parentKey: key, type: "input", fillType: currentConfig.fillType }
} }
if (currentConfig.subKey) { if (currentConfig.subKey) {
const { subKey } = currentConfig; const { subKey } = currentConfig;
@ -252,6 +261,7 @@ export default {
selectInfoKeys.forEach(key => { selectInfoKeys.forEach(key => {
result[key] = formData[key]; result[key] = formData[key];
}) })
console.log(config,"allConfig")
// 更新表单字段 // 更新表单字段
this.formFields = result; this.formFields = result;
this.allFieldsConfig = config; this.allFieldsConfig = config;
@ -302,6 +312,11 @@ export default {
if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段 if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段
formFields[o.otherCode] = ""; formFields[o.otherCode] = "";
} }
}else if(o.type === "radioAndOther"){
const isSelectedOther = this.isShowOtherByRadioAndOther(formFields[key]);
if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段
formFields[o.otherCode] = "";
}
} }
} }
@ -318,7 +333,10 @@ export default {
} }
if (this.isValueEmpty(formFields[key])) { if (this.isValueEmpty(formFields[key])) {
// 其他字段需要判断是否显示再校验 // 其他字段需要判断是否显示再校验
if (o.label === "template.common.other" && !this.isShowOther(formFields[o.parentKey])) {
if (o.label === "template.common.other" && !this.isShowOther(formFields[o.parentKey]) && o.parentType !== "radioAndOther") {
continue
}
if (o.type === "radioAndOther" &&o.label === "template.common.other" && !this.isShowOtherByRadioAndOther(formFields[o.parentKey])) {
continue continue
} }
//span的字段不校验 //span的字段不校验

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

@ -6,6 +6,14 @@ export const isShowOther = (v = [], col) => {
// 确保v是数组类型,以避免类型错误 // 确保v是数组类型,以避免类型错误
const arr = Array.isArray(v) ? v : [v] const arr = Array.isArray(v) ? v : [v]
const otherArr = ['其他', '遮光', 'CA-QC Dilution-', '拒绝', '部分接受'] const otherArr = ['其他', '遮光', 'CA-QC Dilution-', '拒绝', '部分接受']
//和凡哥商量,只要value为负数都显示其他
return arr.some((item) => otherArr.includes(item)) return arr.some((item) => otherArr.includes(item))
} }
//radioAndOther判断是否显示其他输入框
export const isShowOtherByRadioAndOther = (v = '', col) => {
if (col && !col.otherCode) {
return false
}
const otherArr = ['其他', '异常', '不一致']
return otherArr.includes(v)
}

+ 12
- 0
src/views/business/comps/template/comps/sp/SP0019.vue View File

@ -28,6 +28,7 @@
<CustomTable <CustomTable
:columns="ryColumns" :columns="ryColumns"
ref = "ryTableRef" ref = "ryTableRef"
@onRegentSubmit = "(e)=>onRegentSubmit(e)"
:showOperation = "fillType === 'preFill'" :showOperation = "fillType === 'preFill'"
:formData="{stepTableFormData:formData.stepTableFormData_1,headerSelectFields:{}}" :prefixKey="`ryTable`" :formData="{stepTableFormData:formData.stepTableFormData_1,headerSelectFields:{}}" :prefixKey="`ryTable`"
> >
@ -118,6 +119,17 @@ export default {
}, },
methods: { methods: {
onRegentSubmit(e){
const {selectInfo, key, col, rowIndex, colIndex, rowData} = e;
const {row} = selectInfo;
if(key === "rymc"){
const params = {
pzrq: row.pzrq,
sxr: row.sxr,
}
this.$refs.ryTableRef.updateDataSourceByRowIndex(rowIndex, params);
}
},
onYqSubmit(data, col, rowIndex, colIndex, row){ onYqSubmit(data, col, rowIndex, colIndex, row){
console.log(data, col, rowIndex, colIndex, row,"onRegentSubmit") console.log(data, col, rowIndex, colIndex, row,"onRegentSubmit")
}, },

+ 48
- 9
src/views/business/comps/template/comps/yp/YP002.vue View File

@ -10,8 +10,6 @@
<BaseInfoFormPackage fieldItemLabel="template.yp.yp002.swypyjjlbxx" label="template.yp.yp002.swypyjjlbxx" <BaseInfoFormPackage fieldItemLabel="template.yp.yp002.swypyjjlbxx" label="template.yp.yp002.swypyjjlbxx"
ref="swypyjInfoRef" :formConfig="swypyjInfoFormConfig" :formData="formData" ref="swypyjInfoRef" :formConfig="swypyjInfoFormConfig" :formData="formData"
@onRegentSubmit="onRegentSubmit"
@beforeReagentSubmit="beforeReagentSubmit"
/> />
<BaseInfoFormPackage fieldItemLabel="template.yp.yp002.qbjsxx" label="template.yp.yp002.qbjsxx" <BaseInfoFormPackage fieldItemLabel="template.yp.yp002.qbjsxx" label="template.yp.yp002.qbjsxx"
@ -96,6 +94,7 @@ export default {
label: 'template.yp.yp002.qxbd', label: 'template.yp.yp002.qxbd',
type: 'qxbd', type: 'qxbd',
fillType: 'actFill', fillType: 'actFill',
filledCodes:['bdmc','bdbh'],
}, },
} }
}, },
@ -145,7 +144,47 @@ export default {
buttonName:"获取时间" buttonName:"获取时间"
}, },
} }
}
},
{
type: "cellItem",
label: 'template.yp.yp002.jsqk',
config: {
mcysl: {
label: 'template.yp.yp002.mcysl',
type: 'radioAndOther',
fillType: 'actFill',
span:1,
otherCode:'mcyslOther',
options:[
{label:'一致',value:'一致'},
{label:'不一致',value:'不一致'},
]
},
ypgzk: {
label: 'template.yp.yp002.ypgzk',
type: 'radioAndOther',
fillType: 'actFill',
span:1,
otherCode:'ypgzkOther',
options:[
{label:'正常',value:'正常'},
{label:'异常',value:'异常'},
]
},
zyhxx: {
label: 'template.yp.yp002.zyhxx',
type: 'radioAndOther',
fillType: 'actFill',
span:1,
otherCode:'zyhxxOther',
options:[
{label:'空转运盒',value:'空转运盒'},
{label:'给药组转运盒',value:'给药组转运盒'},
{label:'其他',value:'其他'},
]
},
}
},
] ]
}, },
}, },
@ -198,12 +237,12 @@ export default {
this.yqResourceTmp = [] this.yqResourceTmp = []
return this.resourceTmp; return this.resourceTmp;
}, },
onRegentSubmit(val,val1,val2){
debugger
},
beforeReagentSubmit(val,val1,val2){
debugger
},
// onRegentSubmit(val,val1,val2){
// debugger
// },
// beforeReagentSubmit(val,val1,val2){
// debugger
// },
// //
async onSave() { async onSave() {
const formData = this.getStepResource(); const formData = this.getStepResource();

+ 0
- 3
src/views/business/comps/template/dialog/SelectMixReagentDialog.vue View File

@ -181,9 +181,6 @@ export default {
// //
handleSelect(code, row) { handleSelect(code, row) {
this.selectedId = code; this.selectedId = code;
if(this.currentType==15){//idbdmc
this.selectedId = row.bdmc+'('+row.bdbh+')'
}
this.currentRow = row; this.currentRow = row;
}, },
} }

+ 4
- 3
src/views/business/comps/template/formConfig/sp/SP0019.js View File

@ -110,21 +110,22 @@ export const getRyColumns = () => {
{ {
label: '溶液名称(编号)', label: '溶液名称(编号)',
prop: "rymc", prop: "rymc",
bodyType: "input",
disabled: true,
bodyType: "sj",
bodyFillType: 'actFill', bodyFillType: 'actFill',
filledCodes:['mc','bh'],
}, },
{ {
label: '配置日期', label: '配置日期',
prop: "pzrq", prop: "pzrq",
bodyType: "input", bodyType: "input",
disabled: true,
bodyDisabled: true,
bodyFillType: 'actFill', bodyFillType: 'actFill',
}, },
{ {
label: '失效日', label: '失效日',
prop: "sxr", prop: "sxr",
bodyType: "input", bodyType: "input",
bodyDisabled: true,
bodyFillType: 'actFill', bodyFillType: 'actFill',
}, },
] ]

Loading…
Cancel
Save