Commit 547ecf959bd771356ce7155f098a919b8da55c82

Authored by ww
1 parent e491f16a

perf: product model of matter unit select show unit in label

1 -import { h } from 'vue';  
2 import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; 1 import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
3 import { findDictItemByCode } from '/@/api/system/dict'; 2 import { findDictItemByCode } from '/@/api/system/dict';
4 import { FormSchema } from '/@/components/Table'; 3 import { FormSchema } from '/@/components/Table';
@@ -141,10 +140,15 @@ export const formSchemas: FormSchema[] = [ @@ -141,10 +140,15 @@ export const formSchemas: FormSchema[] = [
141 const { setFieldsValue } = formActionType; 140 const { setFieldsValue } = formActionType;
142 return { 141 return {
143 placeholder: '请选择单位', 142 placeholder: '请选择单位',
144 - api: findDictItemByCode, 143 + api: async (params) => {
  144 + const list = await findDictItemByCode(params);
  145 + list.map((item) => (item.itemText = `${item.itemText} / ${item.itemValue}`));
  146 + return list;
  147 + },
145 params: { 148 params: {
146 dictCode: 'attribute_unit', 149 dictCode: 'attribute_unit',
147 }, 150 },
  151 + labelInValue: true,
148 labelField: 'itemText', 152 labelField: 'itemText',
149 valueField: 'itemValue', 153 valueField: 'itemValue',
150 onChange(_, record: Record<'label' | 'value', string>) { 154 onChange(_, record: Record<'label' | 'value', string>) {
@@ -165,14 +169,6 @@ export const formSchemas: FormSchema[] = [ @@ -165,14 +169,6 @@ export const formSchemas: FormSchema[] = [
165 ifShow: ({ values }) => 169 ifShow: ({ values }) =>
166 values[FormField.TYPE] === DateTypeEnum.IS_NUMBER_INT || 170 values[FormField.TYPE] === DateTypeEnum.IS_NUMBER_INT ||
167 values[FormField.TYPE] === DateTypeEnum.IS_NUMBER_DOUBLE, 171 values[FormField.TYPE] === DateTypeEnum.IS_NUMBER_DOUBLE,
168 - renderComponentContent: () => {  
169 - return {  
170 - option: (params: Record<'label' | 'value', string>) => {  
171 - const { label, value } = params;  
172 - return h('span', `${label} / ${value}`);  
173 - },  
174 - };  
175 - },  
176 }, 172 },
177 { 173 {
178 field: FormField.BOOL_CLOSE, 174 field: FormField.BOOL_CLOSE,