Commit e9fd77dde41b3791db27ec67589b3a97ab06cda0
Merge branch 'ww' into 'main'
fix: 修复产品详情物模型管理结构体类型能无限嵌套,修复后只能嵌套一层 See merge request yunteng/thingskit-front!492
Showing
11 changed files
with
387 additions
and
599 deletions
| ... | ... | @@ -179,6 +179,11 @@ export interface DeviceRecord { |
| 179 | 179 | profileId: string; |
| 180 | 180 | alias?: string; |
| 181 | 181 | brand?: string; |
| 182 | + deviceProfile: { | |
| 183 | + default: boolean; | |
| 184 | + name: string; | |
| 185 | + transportType: string; | |
| 186 | + }; | |
| 182 | 187 | } |
| 183 | 188 | |
| 184 | 189 | export interface DeviceModelOfMatterAttrs { | ... | ... |
| ... | ... | @@ -20,9 +20,11 @@ |
| 20 | 20 | defineProps<{ |
| 21 | 21 | value: ModelOfMatterParams[]; |
| 22 | 22 | disabled: boolean; |
| 23 | + hasStructForm?: boolean; | |
| 23 | 24 | }>(), |
| 24 | 25 | { |
| 25 | 26 | value: () => [], |
| 27 | + hasStructForm: false, | |
| 26 | 28 | } |
| 27 | 29 | ); |
| 28 | 30 | |
| ... | ... | @@ -106,6 +108,7 @@ |
| 106 | 108 | </div> |
| 107 | 109 | </div> |
| 108 | 110 | <StructFormModel |
| 111 | + :has-struct-form="$props.hasStructForm!" | |
| 109 | 112 | :disabled="$props.disabled" |
| 110 | 113 | @register="registerModal" |
| 111 | 114 | @submit="handleSaveStruct" | ... | ... |
| ... | ... | @@ -18,13 +18,13 @@ |
| 18 | 18 | mode: OpenModalMode.CREATE, |
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | - const props = defineProps<{ disabled: boolean }>(); | |
| 21 | + const props = defineProps<{ disabled: boolean; hasStructForm: boolean }>(); | |
| 22 | 22 | |
| 23 | 23 | const emit = defineEmits(['register', 'submit']); |
| 24 | 24 | |
| 25 | 25 | const [register, { validate, setFieldsValue, setProps }] = useForm({ |
| 26 | 26 | labelWidth: 100, |
| 27 | - schemas: formSchemas, | |
| 27 | + schemas: formSchemas(props.hasStructForm), | |
| 28 | 28 | actionColOptions: { |
| 29 | 29 | span: 14, |
| 30 | 30 | }, | ... | ... |
| ... | ... | @@ -27,272 +27,288 @@ export const validateJSON = (_rule, value: ModelOfMatterParams[], _callback) => |
| 27 | 27 | return Promise.reject('JSON对象不能为空'); |
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | -export const formSchemas: FormSchema[] = [ | |
| 31 | - { | |
| 32 | - field: FormField.FUNCTION_NAME, | |
| 33 | - label: '功能名称', | |
| 34 | - required: true, | |
| 35 | - component: 'Input', | |
| 36 | - colProps: { | |
| 37 | - span: 18, | |
| 38 | - }, | |
| 39 | - componentProps: { | |
| 40 | - maxLength: 255, | |
| 41 | - placeholder: '请输入功能名称', | |
| 42 | - }, | |
| 43 | - }, | |
| 44 | - { | |
| 45 | - field: FormField.IDENTIFIER, | |
| 46 | - label: '标识符', | |
| 47 | - required: true, | |
| 48 | - component: 'Input', | |
| 49 | - colProps: { | |
| 50 | - span: 18, | |
| 51 | - }, | |
| 52 | - componentProps: { | |
| 53 | - maxLength: 255, | |
| 54 | - placeholder: '请输入标识符', | |
| 55 | - }, | |
| 56 | - }, | |
| 57 | - { | |
| 58 | - field: FormField.TYPE, | |
| 59 | - label: '数据类型', | |
| 60 | - required: true, | |
| 61 | - component: 'ApiSelect', | |
| 62 | - colProps: { | |
| 63 | - span: 9, | |
| 64 | - }, | |
| 65 | - defaultValue: 'INT', | |
| 66 | - componentProps: { | |
| 67 | - placeholder: '请选择数据类型', | |
| 68 | - api: async (params: Recordable) => { | |
| 69 | - try { | |
| 70 | - const record = await findDictItemByCode(params); | |
| 71 | - return record.filter((item) => item.itemValue !== 'STRUCT'); | |
| 72 | - } catch (error) { | |
| 73 | - console.log(error); | |
| 74 | - return []; | |
| 75 | - } | |
| 30 | +export const formSchemas = (hasStructForm: boolean): FormSchema[] => { | |
| 31 | + return [ | |
| 32 | + { | |
| 33 | + field: FormField.FUNCTION_NAME, | |
| 34 | + label: '功能名称', | |
| 35 | + required: true, | |
| 36 | + component: 'Input', | |
| 37 | + colProps: { | |
| 38 | + span: 18, | |
| 76 | 39 | }, |
| 77 | - params: { | |
| 78 | - dictCode: 'data_type', | |
| 40 | + componentProps: { | |
| 41 | + maxLength: 255, | |
| 42 | + placeholder: '请输入功能名称', | |
| 79 | 43 | }, |
| 80 | - labelField: 'itemText', | |
| 81 | - valueField: 'itemValue', | |
| 82 | - getPopupContainer: () => document.body, | |
| 83 | - }, | |
| 84 | - }, | |
| 85 | - { | |
| 86 | - field: FormField.VALUE_RANGE, | |
| 87 | - label: '取值范围', | |
| 88 | - component: 'CustomMinMaxInput', | |
| 89 | - valueField: 'value', | |
| 90 | - changeEvent: 'update:value', | |
| 91 | - colProps: { | |
| 92 | - span: 18, | |
| 93 | 44 | }, |
| 94 | - ifShow: ({ values }) => | |
| 95 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 96 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 97 | - rules: [{ validator: validateValueRange }], | |
| 98 | - }, | |
| 99 | - { | |
| 100 | - field: FormField.STEP, | |
| 101 | - label: '步长', | |
| 102 | - component: 'InputNumber', | |
| 103 | - colProps: { | |
| 104 | - span: 18, | |
| 105 | - }, | |
| 106 | - componentProps: { | |
| 107 | - maxLength: 255, | |
| 108 | - placeholder: '请输入步长', | |
| 109 | - min: 1, | |
| 110 | - formatter: (value: number | string) => { | |
| 111 | - return value ? Math.floor(Number(value)) : value; | |
| 45 | + { | |
| 46 | + field: FormField.IDENTIFIER, | |
| 47 | + label: '标识符', | |
| 48 | + required: true, | |
| 49 | + component: 'Input', | |
| 50 | + colProps: { | |
| 51 | + span: 18, | |
| 52 | + }, | |
| 53 | + componentProps: { | |
| 54 | + maxLength: 255, | |
| 55 | + placeholder: '请输入标识符', | |
| 112 | 56 | }, |
| 113 | 57 | }, |
| 114 | - ifShow: ({ values }) => | |
| 115 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 116 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 117 | - dynamicRules: ({ model }) => { | |
| 118 | - const valueRange = model[FormField.VALUE_RANGE] || {}; | |
| 119 | - const { min = 0, max = 0 } = valueRange; | |
| 120 | - const step = model[FormField.STEP]; | |
| 121 | - return [ | |
| 122 | - { | |
| 123 | - validator: () => { | |
| 124 | - if (step > max - min) { | |
| 125 | - return Promise.reject('步长不能大于取值范围的差值'); | |
| 58 | + { | |
| 59 | + field: FormField.TYPE, | |
| 60 | + label: '数据类型', | |
| 61 | + required: true, | |
| 62 | + component: 'ApiSelect', | |
| 63 | + colProps: { | |
| 64 | + span: 9, | |
| 65 | + }, | |
| 66 | + defaultValue: 'INT', | |
| 67 | + componentProps: ({ formActionType }) => { | |
| 68 | + const { updateSchema } = formActionType; | |
| 69 | + return { | |
| 70 | + placeholder: '请选择数据类型', | |
| 71 | + api: async (params: Recordable) => { | |
| 72 | + try { | |
| 73 | + const record = await findDictItemByCode(params); | |
| 74 | + return hasStructForm | |
| 75 | + ? record.filter((item) => item.itemValue !== DataTypeEnum.IS_STRUCT) | |
| 76 | + : record; | |
| 77 | + } catch (error) { | |
| 78 | + console.log(error); | |
| 79 | + return []; | |
| 126 | 80 | } |
| 127 | - return Promise.resolve(); | |
| 128 | 81 | }, |
| 129 | - }, | |
| 130 | - ]; | |
| 131 | - }, | |
| 132 | - }, | |
| 133 | - { | |
| 134 | - field: FormField.UNIT_NAME, | |
| 135 | - label: '单位名称', | |
| 136 | - component: 'Input', | |
| 137 | - show: false, | |
| 138 | - }, | |
| 139 | - { | |
| 140 | - field: FormField.UNIT, | |
| 141 | - label: '单位', | |
| 142 | - component: 'ApiSelect', | |
| 143 | - colProps: { | |
| 144 | - span: 9, | |
| 145 | - }, | |
| 146 | - componentProps: ({ formActionType }) => { | |
| 147 | - const { setFieldsValue } = formActionType; | |
| 148 | - return { | |
| 149 | - placeholder: '请选择单位', | |
| 150 | - api: async (params) => { | |
| 151 | - const list = await findDictItemByCode(params); | |
| 152 | - list.map((item) => (item.itemText = `${item.itemText} / ${item.itemValue}`)); | |
| 153 | - return list; | |
| 154 | - }, | |
| 155 | - params: { | |
| 156 | - dictCode: 'attribute_unit', | |
| 157 | - }, | |
| 158 | - labelInValue: true, | |
| 159 | - labelField: 'itemText', | |
| 160 | - valueField: 'itemValue', | |
| 161 | - onChange(_, record: Record<'label' | 'value', string>) { | |
| 162 | - if (record) { | |
| 163 | - const { label } = record; | |
| 164 | - setFieldsValue({ [FormField.UNIT_NAME]: label }); | |
| 165 | - } | |
| 166 | - }, | |
| 167 | - getPopupContainer: () => document.body, | |
| 168 | - showSearch: true, | |
| 169 | - filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => { | |
| 170 | - let { label, value } = option; | |
| 171 | - label = label.toLowerCase(); | |
| 172 | - value = value.toLowerCase(); | |
| 173 | - inputValue = inputValue.toLowerCase(); | |
| 174 | - return label.includes(inputValue) || value.includes(inputValue); | |
| 175 | - }, | |
| 176 | - }; | |
| 177 | - }, | |
| 178 | - ifShow: ({ values }) => | |
| 179 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 180 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 181 | - }, | |
| 182 | - { | |
| 183 | - field: FormField.BOOL_CLOSE, | |
| 184 | - component: 'Input', | |
| 185 | - required: true, | |
| 186 | - label: '0 -', | |
| 187 | - colProps: { | |
| 188 | - span: 18, | |
| 82 | + params: { | |
| 83 | + dictCode: 'data_type', | |
| 84 | + }, | |
| 85 | + labelField: 'itemText', | |
| 86 | + valueField: 'itemValue', | |
| 87 | + getPopupContainer: () => document.body, | |
| 88 | + onChange: (value: string) => { | |
| 89 | + value === DataTypeEnum.IS_STRUCT && | |
| 90 | + updateSchema({ | |
| 91 | + field: FormField.SPECS_LIST, | |
| 92 | + componentProps: { | |
| 93 | + hasStructForm: true, | |
| 94 | + }, | |
| 95 | + }); | |
| 96 | + }, | |
| 97 | + }; | |
| 98 | + }, | |
| 189 | 99 | }, |
| 190 | - componentProps: { | |
| 191 | - placeholder: '如:关', | |
| 100 | + { | |
| 101 | + field: FormField.VALUE_RANGE, | |
| 102 | + label: '取值范围', | |
| 103 | + component: 'CustomMinMaxInput', | |
| 104 | + valueField: 'value', | |
| 105 | + changeEvent: 'update:value', | |
| 106 | + colProps: { | |
| 107 | + span: 18, | |
| 108 | + }, | |
| 109 | + ifShow: ({ values }) => | |
| 110 | + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 111 | + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 112 | + rules: [{ validator: validateValueRange }], | |
| 192 | 113 | }, |
| 193 | - defaultValue: '关', | |
| 194 | - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL, | |
| 195 | - dynamicRules: ({ model }) => { | |
| 196 | - const close = model[FormField.BOOL_CLOSE]; | |
| 197 | - const open = model[FormField.BOOL_OPEN]; | |
| 198 | - return [ | |
| 199 | - { | |
| 200 | - required: true, | |
| 114 | + { | |
| 115 | + field: FormField.STEP, | |
| 116 | + label: '步长', | |
| 117 | + component: 'InputNumber', | |
| 118 | + colProps: { | |
| 119 | + span: 18, | |
| 120 | + }, | |
| 121 | + componentProps: { | |
| 122 | + maxLength: 255, | |
| 123 | + placeholder: '请输入步长', | |
| 124 | + min: 1, | |
| 125 | + formatter: (value: number | string) => { | |
| 126 | + return value ? Math.floor(Number(value)) : value; | |
| 201 | 127 | }, |
| 202 | - { | |
| 203 | - validator() { | |
| 204 | - if (open === close) return Promise.reject('布尔值不能相同'); | |
| 205 | - return Promise.resolve(); | |
| 128 | + }, | |
| 129 | + ifShow: ({ values }) => | |
| 130 | + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 131 | + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 132 | + dynamicRules: ({ model }) => { | |
| 133 | + const valueRange = model[FormField.VALUE_RANGE] || {}; | |
| 134 | + const { min = 0, max = 0 } = valueRange; | |
| 135 | + const step = model[FormField.STEP]; | |
| 136 | + return [ | |
| 137 | + { | |
| 138 | + validator: () => { | |
| 139 | + if (step > max - min) { | |
| 140 | + return Promise.reject('步长不能大于取值范围的差值'); | |
| 141 | + } | |
| 142 | + return Promise.resolve(); | |
| 143 | + }, | |
| 206 | 144 | }, |
| 207 | - }, | |
| 208 | - ]; | |
| 145 | + ]; | |
| 146 | + }, | |
| 209 | 147 | }, |
| 210 | - }, | |
| 211 | - { | |
| 212 | - field: FormField.BOOL_OPEN, | |
| 213 | - component: 'Input', | |
| 214 | - required: true, | |
| 215 | - label: '1 -', | |
| 216 | - colProps: { | |
| 217 | - span: 18, | |
| 148 | + { | |
| 149 | + field: FormField.UNIT_NAME, | |
| 150 | + label: '单位名称', | |
| 151 | + component: 'Input', | |
| 152 | + show: false, | |
| 218 | 153 | }, |
| 219 | - componentProps: { | |
| 220 | - placeholder: '如:开', | |
| 154 | + { | |
| 155 | + field: FormField.UNIT, | |
| 156 | + label: '单位', | |
| 157 | + component: 'ApiSelect', | |
| 158 | + colProps: { | |
| 159 | + span: 9, | |
| 160 | + }, | |
| 161 | + componentProps: ({ formActionType }) => { | |
| 162 | + const { setFieldsValue } = formActionType; | |
| 163 | + return { | |
| 164 | + placeholder: '请选择单位', | |
| 165 | + api: async (params) => { | |
| 166 | + const list = await findDictItemByCode(params); | |
| 167 | + list.map((item) => (item.itemText = `${item.itemText} / ${item.itemValue}`)); | |
| 168 | + return list; | |
| 169 | + }, | |
| 170 | + params: { | |
| 171 | + dictCode: 'attribute_unit', | |
| 172 | + }, | |
| 173 | + labelInValue: true, | |
| 174 | + labelField: 'itemText', | |
| 175 | + valueField: 'itemValue', | |
| 176 | + onChange(_, record: Record<'label' | 'value', string>) { | |
| 177 | + if (record) { | |
| 178 | + const { label } = record; | |
| 179 | + setFieldsValue({ [FormField.UNIT_NAME]: label }); | |
| 180 | + } | |
| 181 | + }, | |
| 182 | + getPopupContainer: () => document.body, | |
| 183 | + showSearch: true, | |
| 184 | + filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => { | |
| 185 | + let { label, value } = option; | |
| 186 | + label = label.toLowerCase(); | |
| 187 | + value = value.toLowerCase(); | |
| 188 | + inputValue = inputValue.toLowerCase(); | |
| 189 | + return label.includes(inputValue) || value.includes(inputValue); | |
| 190 | + }, | |
| 191 | + }; | |
| 192 | + }, | |
| 193 | + ifShow: ({ values }) => | |
| 194 | + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 195 | + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 221 | 196 | }, |
| 222 | - defaultValue: '开', | |
| 223 | - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL, | |
| 224 | - dynamicRules: ({ model }) => { | |
| 225 | - const close = model[FormField.BOOL_CLOSE]; | |
| 226 | - const open = model[FormField.BOOL_OPEN]; | |
| 227 | - return [ | |
| 228 | - { | |
| 229 | - required: true, | |
| 230 | - }, | |
| 231 | - { | |
| 232 | - validator() { | |
| 233 | - if (open === close) return Promise.reject('布尔值不能相同'); | |
| 234 | - return Promise.resolve(); | |
| 197 | + { | |
| 198 | + field: FormField.BOOL_CLOSE, | |
| 199 | + component: 'Input', | |
| 200 | + required: true, | |
| 201 | + label: '0 -', | |
| 202 | + colProps: { | |
| 203 | + span: 18, | |
| 204 | + }, | |
| 205 | + componentProps: { | |
| 206 | + placeholder: '如:关', | |
| 207 | + }, | |
| 208 | + defaultValue: '关', | |
| 209 | + ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL, | |
| 210 | + dynamicRules: ({ model }) => { | |
| 211 | + const close = model[FormField.BOOL_CLOSE]; | |
| 212 | + const open = model[FormField.BOOL_OPEN]; | |
| 213 | + return [ | |
| 214 | + { | |
| 215 | + required: true, | |
| 235 | 216 | }, |
| 236 | - }, | |
| 237 | - ]; | |
| 217 | + { | |
| 218 | + validator() { | |
| 219 | + if (open === close) return Promise.reject('布尔值不能相同'); | |
| 220 | + return Promise.resolve(); | |
| 221 | + }, | |
| 222 | + }, | |
| 223 | + ]; | |
| 224 | + }, | |
| 238 | 225 | }, |
| 239 | - }, | |
| 240 | - { | |
| 241 | - field: FormField.LENGTH, | |
| 242 | - component: 'Input', | |
| 243 | - required: true, | |
| 244 | - label: '数据长度', | |
| 245 | - defaultValue: '10240', | |
| 246 | - colProps: { | |
| 247 | - span: 8, | |
| 226 | + { | |
| 227 | + field: FormField.BOOL_OPEN, | |
| 228 | + component: 'Input', | |
| 229 | + required: true, | |
| 230 | + label: '1 -', | |
| 231 | + colProps: { | |
| 232 | + span: 18, | |
| 233 | + }, | |
| 234 | + componentProps: { | |
| 235 | + placeholder: '如:开', | |
| 236 | + }, | |
| 237 | + defaultValue: '开', | |
| 238 | + ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL, | |
| 239 | + dynamicRules: ({ model }) => { | |
| 240 | + const close = model[FormField.BOOL_CLOSE]; | |
| 241 | + const open = model[FormField.BOOL_OPEN]; | |
| 242 | + return [ | |
| 243 | + { | |
| 244 | + required: true, | |
| 245 | + }, | |
| 246 | + { | |
| 247 | + validator() { | |
| 248 | + if (open === close) return Promise.reject('布尔值不能相同'); | |
| 249 | + return Promise.resolve(); | |
| 250 | + }, | |
| 251 | + }, | |
| 252 | + ]; | |
| 253 | + }, | |
| 248 | 254 | }, |
| 249 | - componentProps: { | |
| 250 | - placeholder: '请输入数据长度', | |
| 255 | + { | |
| 256 | + field: FormField.LENGTH, | |
| 257 | + component: 'Input', | |
| 258 | + required: true, | |
| 259 | + label: '数据长度', | |
| 260 | + defaultValue: '10240', | |
| 261 | + colProps: { | |
| 262 | + span: 8, | |
| 263 | + }, | |
| 264 | + componentProps: { | |
| 265 | + placeholder: '请输入数据长度', | |
| 266 | + }, | |
| 267 | + renderComponentContent: () => { | |
| 268 | + return { | |
| 269 | + suffix: () => '字节', | |
| 270 | + }; | |
| 271 | + }, | |
| 272 | + ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRING, | |
| 251 | 273 | }, |
| 252 | - renderComponentContent: () => { | |
| 253 | - return { | |
| 254 | - suffix: () => '字节', | |
| 255 | - }; | |
| 274 | + { | |
| 275 | + field: FormField.ACCESS_MODE, | |
| 276 | + component: 'ApiRadioGroup', | |
| 277 | + label: '读写类型', | |
| 278 | + required: true, | |
| 279 | + colProps: { | |
| 280 | + span: 24, | |
| 281 | + }, | |
| 282 | + defaultValue: 'r', | |
| 283 | + componentProps: { | |
| 284 | + placeholder: '请选择读写类型', | |
| 285 | + api: findDictItemByCode, | |
| 286 | + params: { | |
| 287 | + dictCode: 'read_write_type', | |
| 288 | + }, | |
| 289 | + labelField: 'itemText', | |
| 290 | + valueField: 'itemValue', | |
| 291 | + }, | |
| 256 | 292 | }, |
| 257 | - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRING, | |
| 258 | - }, | |
| 259 | - { | |
| 260 | - field: FormField.ACCESS_MODE, | |
| 261 | - component: 'ApiRadioGroup', | |
| 262 | - label: '读写类型', | |
| 263 | - required: true, | |
| 264 | - colProps: { | |
| 265 | - span: 24, | |
| 293 | + { | |
| 294 | + field: FormField.SPECS_LIST, | |
| 295 | + label: 'JSON对象', | |
| 296 | + component: 'StructForm', | |
| 297 | + valueField: 'value', | |
| 298 | + changeEvent: 'update:value', | |
| 299 | + colProps: { span: 24 }, | |
| 300 | + ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRUCT, | |
| 301 | + rules: [{ required: true, validator: validateJSON }], | |
| 266 | 302 | }, |
| 267 | - defaultValue: 'r', | |
| 268 | - componentProps: { | |
| 269 | - placeholder: '请选择读写类型', | |
| 270 | - api: findDictItemByCode, | |
| 271 | - params: { | |
| 272 | - dictCode: 'read_write_type', | |
| 303 | + { | |
| 304 | + field: FormField.REFARK, | |
| 305 | + label: '备注', | |
| 306 | + component: 'InputTextArea', | |
| 307 | + componentProps: { | |
| 308 | + rows: 4, | |
| 309 | + maxLength: 100, | |
| 310 | + placeholder: '请输入描述', | |
| 273 | 311 | }, |
| 274 | - labelField: 'itemText', | |
| 275 | - valueField: 'itemValue', | |
| 276 | - }, | |
| 277 | - }, | |
| 278 | - { | |
| 279 | - field: FormField.SPECS_LIST, | |
| 280 | - label: 'JSON对象', | |
| 281 | - component: 'StructForm', | |
| 282 | - valueField: 'value', | |
| 283 | - changeEvent: 'update:value', | |
| 284 | - colProps: { span: 24 }, | |
| 285 | - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRUCT, | |
| 286 | - rules: [{ required: true, validator: validateJSON }], | |
| 287 | - }, | |
| 288 | - { | |
| 289 | - field: FormField.REFARK, | |
| 290 | - label: '备注', | |
| 291 | - component: 'InputTextArea', | |
| 292 | - componentProps: { | |
| 293 | - rows: 4, | |
| 294 | - maxLength: 100, | |
| 295 | - placeholder: '请输入描述', | |
| 296 | 312 | }, |
| 297 | - }, | |
| 298 | -]; | |
| 313 | + ]; | |
| 314 | +}; | ... | ... |
| ... | ... | @@ -714,62 +714,67 @@ export const TokenSchemas: FormSchema[] = [ |
| 714 | 714 | }, |
| 715 | 715 | ]; |
| 716 | 716 | |
| 717 | -export const CommandSchemas: FormSchema[] = [ | |
| 718 | - { | |
| 719 | - field: 'commandType', | |
| 720 | - component: 'RadioGroup', | |
| 721 | - label: '下发类型', | |
| 722 | - colProps: { | |
| 723 | - span: 8, | |
| 724 | - }, | |
| 725 | - defaultValue: 'OneWay', | |
| 726 | - componentProps: { | |
| 727 | - options: [ | |
| 728 | - { | |
| 729 | - label: '单向', | |
| 730 | - value: 'OneWay', | |
| 731 | - }, | |
| 732 | - { | |
| 733 | - label: '双向', | |
| 734 | - value: 'TwoWay', | |
| 735 | - }, | |
| 736 | - ], | |
| 737 | - }, | |
| 738 | - }, | |
| 739 | - { | |
| 740 | - field: 'valueType', | |
| 741 | - label: '命令类型', | |
| 742 | - component: 'RadioGroup', | |
| 743 | - defaultValue: 'json', | |
| 744 | - componentProps: () => { | |
| 745 | - return { | |
| 717 | +export const CommandSchemas = (transportType: TransportTypeEnum): FormSchema[] => { | |
| 718 | + return [ | |
| 719 | + { | |
| 720 | + field: 'commandType', | |
| 721 | + component: 'RadioGroup', | |
| 722 | + label: '下发类型', | |
| 723 | + colProps: { | |
| 724 | + span: 8, | |
| 725 | + }, | |
| 726 | + defaultValue: 'OneWay', | |
| 727 | + componentProps: { | |
| 746 | 728 | options: [ |
| 747 | - { label: 'JSON', value: 'json' }, | |
| 748 | - { label: '字符串', value: 'string' }, | |
| 729 | + { | |
| 730 | + label: '单向', | |
| 731 | + value: 'OneWay', | |
| 732 | + }, | |
| 733 | + { | |
| 734 | + label: '双向', | |
| 735 | + value: 'TwoWay', | |
| 736 | + }, | |
| 749 | 737 | ], |
| 750 | - }; | |
| 738 | + }, | |
| 751 | 739 | }, |
| 752 | - }, | |
| 753 | - { | |
| 754 | - field: 'commandText', | |
| 755 | - label: '请输入命令内容', | |
| 756 | - ifShow: ({ model }) => { | |
| 757 | - return model['valueType'] === 'string'; | |
| 740 | + { | |
| 741 | + field: 'valueType', | |
| 742 | + label: '命令类型', | |
| 743 | + component: 'RadioGroup', | |
| 744 | + defaultValue: transportType === TransportTypeEnum.TCP ? 'string' : 'json', | |
| 745 | + componentProps: () => { | |
| 746 | + const options: Record<'label' | 'value', string>[] = []; | |
| 747 | + if (transportType === TransportTypeEnum.TCP) { | |
| 748 | + options.push({ label: '字符串', value: 'string' }); | |
| 749 | + } else { | |
| 750 | + options.push({ label: 'JSON', value: 'json' }); | |
| 751 | + } | |
| 752 | + return { | |
| 753 | + options, | |
| 754 | + }; | |
| 755 | + }, | |
| 758 | 756 | }, |
| 759 | - component: 'InputTextArea', | |
| 760 | - componentProps: { | |
| 761 | - autosize: { | |
| 762 | - minRows: 6, | |
| 757 | + { | |
| 758 | + field: 'commandText', | |
| 759 | + label: '请输入命令内容', | |
| 760 | + ifShow: ({ model }) => { | |
| 761 | + return model['valueType'] === 'string'; | |
| 762 | + }, | |
| 763 | + component: 'InputTextArea', | |
| 764 | + componentProps: { | |
| 765 | + autosize: { | |
| 766 | + minRows: 6, | |
| 767 | + }, | |
| 763 | 768 | }, |
| 764 | 769 | }, |
| 765 | - }, | |
| 766 | - { | |
| 767 | - field: 'commandValue', | |
| 768 | - label: '请输入命令内容', | |
| 769 | - slot: 'commandSlot', | |
| 770 | - component: 'InputTextArea', | |
| 771 | - show: ({ model }) => { | |
| 772 | - return model['valueType'] === 'json'; | |
| 770 | + { | |
| 771 | + field: 'commandValue', | |
| 772 | + label: '请输入命令内容', | |
| 773 | + slot: 'commandSlot', | |
| 774 | + component: 'InputTextArea', | |
| 775 | + show: ({ model }) => { | |
| 776 | + return model['valueType'] === 'json'; | |
| 777 | + }, | |
| 773 | 778 | }, |
| 774 | - }, | |
| 775 | -]; | |
| 779 | + ]; | |
| 780 | +}; | ... | ... |
| ... | ... | @@ -30,6 +30,8 @@ |
| 30 | 30 | import 'jsoneditor/dist/jsoneditor.min.css'; |
| 31 | 31 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; |
| 32 | 32 | import { Tooltip } from 'ant-design-vue'; |
| 33 | + import { DeviceRecord } from '/@/api/device/model/deviceModel'; | |
| 34 | + import { TransportTypeEnum } from '../../../profiles/components/TransportDescript/const'; | |
| 33 | 35 | |
| 34 | 36 | interface CommandParams { |
| 35 | 37 | additionalInfo: Recordable; |
| ... | ... | @@ -43,7 +45,7 @@ |
| 43 | 45 | components: { BasicForm, Button, QuestionCircleOutlined, Tooltip }, |
| 44 | 46 | props: { |
| 45 | 47 | deviceDetail: { |
| 46 | - type: Object, | |
| 48 | + type: Object as PropType<DeviceRecord>, | |
| 47 | 49 | required: true, |
| 48 | 50 | }, |
| 49 | 51 | }, |
| ... | ... | @@ -52,9 +54,12 @@ |
| 52 | 54 | const { createMessage } = useMessage(); |
| 53 | 55 | const jsonData = ref<CommandParams>({} as unknown as CommandParams); |
| 54 | 56 | const disable = ref(false); |
| 57 | + | |
| 55 | 58 | const [registerForm, { getFieldsValue, validate, resetFields }] = useForm({ |
| 56 | 59 | labelWidth: 100, |
| 57 | - schemas: CommandSchemas, | |
| 60 | + schemas: CommandSchemas( | |
| 61 | + props.deviceDetail.deviceProfile.transportType as TransportTypeEnum | |
| 62 | + ), | |
| 58 | 63 | labelAlign: 'right', |
| 59 | 64 | showSubmitButton: false, |
| 60 | 65 | showResetButton: false, | ... | ... |
| 1 | +import { Tag } from 'ant-design-vue'; | |
| 2 | +import { h } from 'vue'; | |
| 1 | 3 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 2 | 4 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
| 5 | +import { formatToDateTime } from '/@/utils/dateUtil'; | |
| 6 | + | |
| 7 | +enum EventType { | |
| 8 | + ERROR = 'ERROR', | |
| 9 | + INFO = 'INFO', | |
| 10 | + ALERT = 'ALERT', | |
| 11 | +} | |
| 12 | + | |
| 13 | +enum EventTypeColor { | |
| 14 | + ERROR = 'error', | |
| 15 | + INFO = 'warning', | |
| 16 | + ALERT = 'default', | |
| 17 | +} | |
| 18 | + | |
| 19 | +enum EventTypeName { | |
| 20 | + ERROR = '故障', | |
| 21 | + INFO = '信息', | |
| 22 | + ALERT = '告警', | |
| 23 | +} | |
| 3 | 24 | |
| 4 | 25 | export const columnSchema: BasicColumn[] = [ |
| 5 | 26 | { |
| 6 | 27 | title: '时间', |
| 7 | - dataIndex: 'time', | |
| 28 | + dataIndex: 'eventTime', | |
| 29 | + format(text) { | |
| 30 | + return formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss'); | |
| 31 | + }, | |
| 8 | 32 | }, |
| 9 | 33 | { |
| 10 | 34 | title: '标识符', |
| ... | ... | @@ -18,6 +42,15 @@ export const columnSchema: BasicColumn[] = [ |
| 18 | 42 | { |
| 19 | 43 | title: '事件类型', |
| 20 | 44 | dataIndex: 'eventType', |
| 45 | + customRender({ text }) { | |
| 46 | + return h( | |
| 47 | + Tag, | |
| 48 | + { | |
| 49 | + color: EventTypeColor[text as EventType], | |
| 50 | + }, | |
| 51 | + () => EventTypeName[text as EventType] | |
| 52 | + ); | |
| 53 | + }, | |
| 21 | 54 | }, |
| 22 | 55 | { |
| 23 | 56 | title: '输出参数', | ... | ... |
| ... | ... | @@ -29,11 +29,16 @@ |
| 29 | 29 | baseColProps: { span: 6 }, |
| 30 | 30 | labelWidth: 80, |
| 31 | 31 | schemas: formSchemas, |
| 32 | - fieldMapToTime: [['dateRange', ['startTime', 'endTime']]], | |
| 32 | + fieldMapToTime: [['dateRange', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | |
| 33 | 33 | }, |
| 34 | 34 | beforeFetch: (params: EventManageRequest) => { |
| 35 | + const page = params.page - 1 < 0 ? 0 : params.page - 1; | |
| 36 | + const _params = Object.keys(params) | |
| 37 | + .filter((key) => params[key]) | |
| 38 | + .reduce((prev, next) => ({ ...prev, [next]: params[next] }), {}); | |
| 35 | 39 | return { |
| 36 | - ...params, | |
| 40 | + ..._params, | |
| 41 | + page, | |
| 37 | 42 | startTime: params.startTime ? new Date(params.startTime).getTime() : params.startTime, |
| 38 | 43 | endTime: params.endTime ? new Date(params.endTime).getTime() : params.endTime, |
| 39 | 44 | tbDeviceId: props.tbDeviceId, |
| ... | ... | @@ -43,22 +48,16 @@ |
| 43 | 48 | |
| 44 | 49 | const [registerModal, { openModal }] = useModal(); |
| 45 | 50 | |
| 46 | - const handleViewDetail = () => { | |
| 47 | - outputData.value = JSON.stringify( | |
| 48 | - { | |
| 49 | - test: '123', | |
| 50 | - }, | |
| 51 | - null, | |
| 52 | - 2 | |
| 53 | - ); | |
| 51 | + const handleViewDetail = (record: Record<'eventValue', Recordable>) => { | |
| 52 | + outputData.value = JSON.stringify(record.eventValue, null, 2); | |
| 54 | 53 | openModal(true); |
| 55 | 54 | }; |
| 56 | 55 | </script> |
| 57 | 56 | |
| 58 | 57 | <template> |
| 59 | 58 | <BasicTable class="event-manage-table" @register="register"> |
| 60 | - <template #outputParams> | |
| 61 | - <span class="cursor-pointer text-blue-500" @click="handleViewDetail"> | |
| 59 | + <template #outputParams="{ record }"> | |
| 60 | + <span class="cursor-pointer text-blue-500" @click="handleViewDetail(record)"> | |
| 62 | 61 | <EyeOutlined class="svg:text-blue-500" /> |
| 63 | 62 | <span class="ml-2">详情</span> |
| 64 | 63 | </span> | ... | ... |
| ... | ... | @@ -9,15 +9,16 @@ |
| 9 | 9 | transfromToStructJSON, |
| 10 | 10 | excludeIdInStructJSON, |
| 11 | 11 | } from '/@/components/Form/src/externalCompns/components/StructForm/util'; |
| 12 | - import { FunctionType, attributeSchema } from './config'; | |
| 12 | + import { FunctionType } from './config'; | |
| 13 | 13 | import { isArray } from 'lodash'; |
| 14 | 14 | import { OpenModelMode } from '../types'; |
| 15 | + import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config'; | |
| 15 | 16 | |
| 16 | 17 | defineProps<{ openModalMode: OpenModelMode }>(); |
| 17 | 18 | |
| 18 | 19 | const [register, { validate, resetFields, setFieldsValue, setProps }] = useForm({ |
| 19 | 20 | labelWidth: 100, |
| 20 | - schemas: attributeSchema, | |
| 21 | + schemas: formSchemas(false), | |
| 21 | 22 | actionColOptions: { |
| 22 | 23 | span: 14, |
| 23 | 24 | }, | ... | ... |
| 1 | 1 | import { FormSchema } from '/@/components/Table'; |
| 2 | 2 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 3 | -import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | |
| 4 | - | |
| 5 | -export const validateValueRange = (_rule, value: Record<'min' | 'max', number>, _callback) => { | |
| 6 | - value = value || {}; | |
| 7 | - const { min, max } = value; | |
| 8 | - if (min >= max) { | |
| 9 | - return Promise.reject('最大值小于最小值'); | |
| 10 | - } | |
| 11 | - return Promise.resolve(); | |
| 12 | -}; | |
| 13 | - | |
| 14 | -export const validateJSON = (_rule, value: ModelOfMatterParams[], _callback) => { | |
| 15 | - if (value.length) { | |
| 16 | - return Promise.resolve(); | |
| 17 | - } | |
| 18 | - return Promise.reject('JSON对象不能为空'); | |
| 19 | -}; | |
| 20 | 3 | |
| 21 | 4 | export enum FormField { |
| 22 | 5 | FUNCTION_NAME = 'functionName', |
| ... | ... | @@ -375,265 +358,3 @@ export const addParamsSchemas: FormSchema[] = [ |
| 375 | 358 | ifShow: ({ values }) => isNumber(values[FormField.TYPE]), |
| 376 | 359 | }, |
| 377 | 360 | ]; |
| 378 | - | |
| 379 | -export const attributeSchema: FormSchema[] = [ | |
| 380 | - { | |
| 381 | - field: FormField.FUNCTION_NAME, | |
| 382 | - label: '功能名称', | |
| 383 | - required: true, | |
| 384 | - component: 'Input', | |
| 385 | - colProps: { | |
| 386 | - span: 18, | |
| 387 | - }, | |
| 388 | - componentProps: { | |
| 389 | - maxLength: 255, | |
| 390 | - placeholder: '请输入功能名称', | |
| 391 | - }, | |
| 392 | - }, | |
| 393 | - { | |
| 394 | - field: FormField.IDENTIFIER, | |
| 395 | - label: '标识符', | |
| 396 | - required: true, | |
| 397 | - component: 'Input', | |
| 398 | - colProps: { | |
| 399 | - span: 18, | |
| 400 | - }, | |
| 401 | - componentProps: { | |
| 402 | - maxLength: 255, | |
| 403 | - placeholder: '请输入标识符', | |
| 404 | - }, | |
| 405 | - }, | |
| 406 | - { | |
| 407 | - field: FormField.TYPE, | |
| 408 | - label: '数据类型', | |
| 409 | - required: true, | |
| 410 | - component: 'ApiSelect', | |
| 411 | - colProps: { | |
| 412 | - span: 9, | |
| 413 | - }, | |
| 414 | - defaultValue: 'INT', | |
| 415 | - componentProps: { | |
| 416 | - placeholder: '请选择数据类型', | |
| 417 | - api: findDictItemByCode, | |
| 418 | - params: { | |
| 419 | - dictCode: 'data_type', | |
| 420 | - }, | |
| 421 | - labelField: 'itemText', | |
| 422 | - valueField: 'itemValue', | |
| 423 | - getPopupContainer: () => document.body, | |
| 424 | - }, | |
| 425 | - }, | |
| 426 | - { | |
| 427 | - field: FormField.VALUE_RANGE, | |
| 428 | - label: '取值范围', | |
| 429 | - component: 'CustomMinMaxInput', | |
| 430 | - valueField: 'value', | |
| 431 | - changeEvent: 'update:value', | |
| 432 | - colProps: { | |
| 433 | - span: 18, | |
| 434 | - }, | |
| 435 | - ifShow: ({ values }) => | |
| 436 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 437 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 438 | - rules: [{ validator: validateValueRange }], | |
| 439 | - }, | |
| 440 | - { | |
| 441 | - field: FormField.STEP, | |
| 442 | - label: '步长', | |
| 443 | - component: 'InputNumber', | |
| 444 | - colProps: { | |
| 445 | - span: 18, | |
| 446 | - }, | |
| 447 | - componentProps: { | |
| 448 | - maxLength: 255, | |
| 449 | - placeholder: '请输入步长', | |
| 450 | - min: 1, | |
| 451 | - formatter: (value: number | string) => { | |
| 452 | - return value ? Math.floor(Number(value)) : value; | |
| 453 | - }, | |
| 454 | - }, | |
| 455 | - ifShow: ({ values }) => | |
| 456 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 457 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 458 | - dynamicRules: ({ model }) => { | |
| 459 | - const valueRange = model[FormField.VALUE_RANGE] || {}; | |
| 460 | - const { min = 0, max = 0 } = valueRange; | |
| 461 | - const step = model[FormField.STEP]; | |
| 462 | - return [ | |
| 463 | - { | |
| 464 | - validator: () => { | |
| 465 | - if (step > max - min) { | |
| 466 | - return Promise.reject('步长不能大于取值范围的差值'); | |
| 467 | - } | |
| 468 | - return Promise.resolve(); | |
| 469 | - }, | |
| 470 | - }, | |
| 471 | - ]; | |
| 472 | - }, | |
| 473 | - }, | |
| 474 | - { | |
| 475 | - field: FormField.UNIT_NAME, | |
| 476 | - label: '单位名称', | |
| 477 | - component: 'Input', | |
| 478 | - show: false, | |
| 479 | - }, | |
| 480 | - { | |
| 481 | - field: FormField.UNIT, | |
| 482 | - label: '单位', | |
| 483 | - component: 'ApiSelect', | |
| 484 | - colProps: { | |
| 485 | - span: 9, | |
| 486 | - }, | |
| 487 | - componentProps: ({ formActionType }) => { | |
| 488 | - const { setFieldsValue } = formActionType; | |
| 489 | - return { | |
| 490 | - placeholder: '请选择单位', | |
| 491 | - api: async (params) => { | |
| 492 | - const list = await findDictItemByCode(params); | |
| 493 | - list.map((item) => (item.itemText = `${item.itemText} / ${item.itemValue}`)); | |
| 494 | - return list; | |
| 495 | - }, | |
| 496 | - params: { | |
| 497 | - dictCode: 'attribute_unit', | |
| 498 | - }, | |
| 499 | - labelInValue: true, | |
| 500 | - labelField: 'itemText', | |
| 501 | - valueField: 'itemValue', | |
| 502 | - onChange(_, record: Record<'label' | 'value', string>) { | |
| 503 | - if (record) { | |
| 504 | - const { label } = record; | |
| 505 | - setFieldsValue({ [FormField.UNIT_NAME]: label }); | |
| 506 | - } | |
| 507 | - }, | |
| 508 | - getPopupContainer: () => document.body, | |
| 509 | - showSearch: true, | |
| 510 | - filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => { | |
| 511 | - let { label, value } = option; | |
| 512 | - label = label.toLowerCase(); | |
| 513 | - value = value.toLowerCase(); | |
| 514 | - inputValue = inputValue.toLowerCase(); | |
| 515 | - return label.includes(inputValue) || value.includes(inputValue); | |
| 516 | - }, | |
| 517 | - }; | |
| 518 | - }, | |
| 519 | - ifShow: ({ values }) => | |
| 520 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT || | |
| 521 | - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE, | |
| 522 | - }, | |
| 523 | - { | |
| 524 | - field: FormField.BOOL_CLOSE, | |
| 525 | - component: 'Input', | |
| 526 | - required: true, | |
| 527 | - label: '0 -', | |
| 528 | - colProps: { | |
| 529 | - span: 18, | |
| 530 | - }, | |
| 531 | - componentProps: { | |
| 532 | - placeholder: '如:关', | |
| 533 | - }, | |
| 534 | - defaultValue: '关', | |
| 535 | - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL, | |
| 536 | - dynamicRules: ({ model }) => { | |
| 537 | - const close = model[FormField.BOOL_CLOSE]; | |
| 538 | - const open = model[FormField.BOOL_OPEN]; | |
| 539 | - return [ | |
| 540 | - { | |
| 541 | - required: true, | |
| 542 | - }, | |
| 543 | - { | |
| 544 | - validator() { | |
| 545 | - if (open === close) return Promise.reject('布尔值不能相同'); | |
| 546 | - return Promise.resolve(); | |
| 547 | - }, | |
| 548 | - }, | |
| 549 | - ]; | |
| 550 | - }, | |
| 551 | - }, | |
| 552 | - { | |
| 553 | - field: FormField.BOOL_OPEN, | |
| 554 | - component: 'Input', | |
| 555 | - required: true, | |
| 556 | - label: '1 -', | |
| 557 | - colProps: { | |
| 558 | - span: 18, | |
| 559 | - }, | |
| 560 | - componentProps: { | |
| 561 | - placeholder: '如:开', | |
| 562 | - }, | |
| 563 | - defaultValue: '开', | |
| 564 | - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL, | |
| 565 | - dynamicRules: ({ model }) => { | |
| 566 | - const close = model[FormField.BOOL_CLOSE]; | |
| 567 | - const open = model[FormField.BOOL_OPEN]; | |
| 568 | - return [ | |
| 569 | - { | |
| 570 | - required: true, | |
| 571 | - }, | |
| 572 | - { | |
| 573 | - validator() { | |
| 574 | - if (open === close) return Promise.reject('布尔值不能相同'); | |
| 575 | - return Promise.resolve(); | |
| 576 | - }, | |
| 577 | - }, | |
| 578 | - ]; | |
| 579 | - }, | |
| 580 | - }, | |
| 581 | - { | |
| 582 | - field: FormField.LENGTH, | |
| 583 | - component: 'Input', | |
| 584 | - required: true, | |
| 585 | - label: '数据长度', | |
| 586 | - defaultValue: '10240', | |
| 587 | - colProps: { | |
| 588 | - span: 8, | |
| 589 | - }, | |
| 590 | - componentProps: { | |
| 591 | - placeholder: '请输入数据长度', | |
| 592 | - }, | |
| 593 | - renderComponentContent: () => { | |
| 594 | - return { | |
| 595 | - suffix: () => '字节', | |
| 596 | - }; | |
| 597 | - }, | |
| 598 | - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRING, | |
| 599 | - }, | |
| 600 | - { | |
| 601 | - field: FormField.ACCESS_MODE, | |
| 602 | - component: 'ApiRadioGroup', | |
| 603 | - label: '读写类型', | |
| 604 | - required: true, | |
| 605 | - colProps: { | |
| 606 | - span: 24, | |
| 607 | - }, | |
| 608 | - defaultValue: 'r', | |
| 609 | - componentProps: { | |
| 610 | - placeholder: '请选择读写类型', | |
| 611 | - api: findDictItemByCode, | |
| 612 | - params: { | |
| 613 | - dictCode: 'read_write_type', | |
| 614 | - }, | |
| 615 | - labelField: 'itemText', | |
| 616 | - valueField: 'itemValue', | |
| 617 | - }, | |
| 618 | - }, | |
| 619 | - { | |
| 620 | - field: FormField.SPECS_LIST, | |
| 621 | - label: 'JSON对象', | |
| 622 | - component: 'StructForm', | |
| 623 | - valueField: 'value', | |
| 624 | - changeEvent: 'update:value', | |
| 625 | - colProps: { span: 24 }, | |
| 626 | - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRUCT, | |
| 627 | - rules: [{ required: true, validator: validateJSON }], | |
| 628 | - }, | |
| 629 | - { | |
| 630 | - field: FormField.REFARK, | |
| 631 | - label: '备注', | |
| 632 | - component: 'InputTextArea', | |
| 633 | - componentProps: { | |
| 634 | - rows: 4, | |
| 635 | - maxLength: 100, | |
| 636 | - placeholder: '请输入描述', | |
| 637 | - }, | |
| 638 | - }, | |
| 639 | -]; | ... | ... |
| ... | ... | @@ -567,11 +567,11 @@ |
| 567 | 567 | //TODO fengtao |
| 568 | 568 | orgId.value = newValue; |
| 569 | 569 | //TODO fengtao |
| 570 | + const data = await getOrganizationAlarmConfig({ organizationId: newValue }); | |
| 571 | + alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); | |
| 570 | 572 | setFields(skipUnwrap.triggerItemRefs, true); |
| 571 | 573 | setFields(skipUnwrap.conditionItemRefs, true); |
| 572 | 574 | setFields(skipUnwrap.actionItemRefs, true); |
| 573 | - const data = await getOrganizationAlarmConfig({ organizationId: newValue }); | |
| 574 | - alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); | |
| 575 | 575 | // setFields(skipUnwrap.actionItemRefs, true); |
| 576 | 576 | // console.log(unref(organizationIdRef)); |
| 577 | 577 | // setAlarmConfig(skipUnwrap.actionItemRefs, true); | ... | ... |