Commit 11c4bd5089e8b2b40f5515816a8a119a760e4dc2

Authored by loveumiko
2 parents 33e2cd6b 4a03bcbc

Merge branch 'main_dev' of http://git.yunteng.com/yunteng/thingskit-front into fix/DEFECT-1389

@@ -51,14 +51,6 @@ @@ -51,14 +51,6 @@
51 'update:searchValue', 51 'update:searchValue',
52 ], 52 ],
53 setup(props, { attrs, slots, emit, expose }) { 53 setup(props, { attrs, slots, emit, expose }) {
54 - // /**  
55 - // * 作者自带Tree组件  
56 - // * 新增显示隐藏  
57 - // * ft  
58 - // */  
59 - // //ft  
60 - // const isFlod = ref(false);  
61 - //ft  
62 const state = reactive<State>({ 54 const state = reactive<State>({
63 checkStrictly: props.checkStrictly, 55 checkStrictly: props.checkStrictly,
64 expandedKeys: props.expandedKeys || [], 56 expandedKeys: props.expandedKeys || [],
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 if (!props.value?.withUnit) return record; 34 if (!props.value?.withUnit) return record;
35 35
36 if (value > 10 ** 6) return { unit: 'M', value: value / 10 ** 6 }; 36 if (value > 10 ** 6) return { unit: 'M', value: value / 10 ** 6 };
37 - if (value > 10 ** 3) return { unit: 'K', value: value / 10 ** 4 }; 37 + if (value > 10 ** 3) return { unit: 'K', value: value / 10 ** 3 };
38 38
39 return record; 39 return record;
40 }; 40 };
@@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
59 if (!valid) return; 59 if (!valid) return;
60 // 收集表单数据 60 // 收集表单数据
61 const field = getFieldsValue(); 61 const field = getFieldsValue();
62 - let command = { 62 + let command: Recordable = {
63 persistent: true, 63 persistent: true,
64 method: 'methodThingskit', 64 method: 'methodThingskit',
65 params: field[CommandFieldsEnum.COMMAND_TEXT], 65 params: field[CommandFieldsEnum.COMMAND_TEXT],
@@ -76,6 +76,7 @@ @@ -76,6 +76,7 @@
76 transportType === TransportTypeEnum.TCP 76 transportType === TransportTypeEnum.TCP
77 ? field[CommandFieldsEnum.TCP_SERVICE] 77 ? field[CommandFieldsEnum.TCP_SERVICE]
78 : field[CommandFieldsEnum.MODEL_INPUT]; 78 : field[CommandFieldsEnum.MODEL_INPUT];
  79 + command.additionalInfo = { cmdType: 1 };
79 } 80 }
80 81
81 commandIssuanceApi( 82 commandIssuanceApi(
1 -import { FormSchema } from '/@/components/Form';  
2 -import { findDictItemByCode } from '/@/api/system/dict';  
3 -import { h, unref } from 'vue';  
4 -import { getDeviceProfile } from '/@/api/alarm/position';  
5 -import { BasicColumn, BasicTableProps } from '/@/components/Table';  
6 -import { devicePage } from '/@/api/device/deviceManager';  
7 -import { Tag } from 'ant-design-vue';  
8 -import { DeviceRecord } from '/@/api/device/model/deviceModel';  
9 -import { FETCH_SETTING } from '/@/components/Table/src/const';  
10 -import { useMessage } from '/@/hooks/web/useMessage';  
11 -import {  
12 - BasicInfoFormField,  
13 - DataSourceType,  
14 - DeviceStatusEnum,  
15 - DeviceStatusNameEnum,  
16 - DeviceTypeNameEnum,  
17 -} from '../enum';  
18 -import { useClipboard } from '@vueuse/core';  
19 -  
20 -export const stepConfig = ['选择流转方式', '完善配置参数'];  
21 -  
22 -export const removeFieldByModeForm = ['name', 'description'];  
23 -  
24 -//表单通用配置  
25 -export const modelFormPublicConfig = {  
26 - labelWidth: 120,  
27 - actionColOptions: {  
28 - span: 14,  
29 - },  
30 - showResetButton: false,  
31 - showSubmitButton: false,  
32 -};  
33 -  
34 -const handleGroupDevice = (options: DeviceRecord[]) => {  
35 - const map = new Map<string, string[]>();  
36 - options.forEach((item) => {  
37 - if (map.has(item.profileId)) {  
38 - const deviceList = map.get(item.profileId)!;  
39 - deviceList.push(item.tbDeviceId);  
40 - } else {  
41 - map.set(item.profileId, [item.tbDeviceId]);  
42 - }  
43 - });  
44 - const value = Array.from(map.entries()).map(([product, devices]) => ({ product, devices }));  
45 -  
46 - return value;  
47 -};  
48 -  
49 -const deviceTableFormSchema: FormSchema[] = [  
50 - {  
51 - field: 'name',  
52 - label: '设备名称',  
53 - component: 'Input',  
54 - colProps: { span: 9 },  
55 - componentProps: {  
56 - placeholder: '请输入设备名称',  
57 - },  
58 - },  
59 - {  
60 - field: 'deviceType',  
61 - label: '设备类型',  
62 - component: 'ApiSelect',  
63 - colProps: { span: 9 },  
64 - componentProps: {  
65 - placeholder: '请选择设备类型',  
66 - api: findDictItemByCode,  
67 - params: {  
68 - dictCode: 'device_type',  
69 - },  
70 - labelField: 'itemText',  
71 - valueField: 'itemValue',  
72 - },  
73 - },  
74 -];  
75 -  
76 -const { copied, copy } = useClipboard({ legacy: true });  
77 -  
78 -const { createMessage } = useMessage();  
79 -  
80 -const deviceTableColumn: BasicColumn[] = [  
81 - {  
82 - title: '状态',  
83 - dataIndex: 'deviceState',  
84 - customRender: ({ text }) => {  
85 - return h(  
86 - Tag,  
87 - {  
88 - color:  
89 - text === DeviceStatusEnum.INACTIVE  
90 - ? 'warning'  
91 - : text === DeviceStatusEnum.OFFLINE  
92 - ? 'error'  
93 - : 'success',  
94 - },  
95 - () => DeviceStatusNameEnum[text]  
96 - );  
97 - },  
98 - },  
99 - {  
100 - title: '别名/设备名称',  
101 - dataIndex: 'name',  
102 - customRender: ({ record }) => {  
103 - return h('div', [  
104 - h(  
105 - 'div',  
106 - {  
107 - class: 'cursor-pointer',  
108 - onClick: async () => {  
109 - await copy(record.name);  
110 - if (unref(copied)) createMessage.success('复制成功~');  
111 - },  
112 - },  
113 - [  
114 - record.alias && h('div', { class: 'truncate' }, record.alias),  
115 - h('div', { class: 'text-blue-400 truncate' }, record.name),  
116 - ]  
117 - ),  
118 - ]);  
119 - },  
120 - },  
121 - {  
122 - title: '设备类型',  
123 - dataIndex: 'deviceType',  
124 - customRender: ({ text }) => {  
125 - return h(Tag, { color: 'success' }, () => DeviceTypeNameEnum[text]);  
126 - },  
127 - },  
128 - {  
129 - title: '所属产品',  
130 - dataIndex: 'deviceProfile.name',  
131 - },  
132 - {  
133 - title: '所属组织',  
134 - dataIndex: 'organizationDTO.name',  
135 - },  
136 -];  
137 -  
138 -const TransferTableProps: BasicTableProps = {  
139 - formConfig: {  
140 - layout: 'inline',  
141 - labelWidth: 80,  
142 - schemas: deviceTableFormSchema,  
143 - actionColOptions: { span: 6 },  
144 - },  
145 - size: 'small',  
146 - maxHeight: 240,  
147 - useSearchForm: true,  
148 - columns: deviceTableColumn,  
149 - showIndexColumn: false,  
150 - fetchSetting: FETCH_SETTING,  
151 -} as BasicTableProps;  
152 -  
153 -export const modeForm = (submitFn?: Function): FormSchema[] => {  
154 - return [  
155 - {  
156 - field: BasicInfoFormField.CONVERT_CONFIG_ID,  
157 - label: '',  
158 - component: 'Input',  
159 - show: false,  
160 - },  
161 - {  
162 - field: BasicInfoFormField.DATA_SOURCE_TYPE,  
163 - label: '数据源',  
164 - component: 'RadioGroup',  
165 - defaultValue: DataSourceType.ALL,  
166 - componentProps: {  
167 - options: [  
168 - { label: '全部', value: DataSourceType.ALL },  
169 - { label: '产品', value: DataSourceType.PRODUCT },  
170 - { label: '设备', value: DataSourceType.DEVICE },  
171 - ],  
172 - },  
173 - },  
174 - {  
175 - field: BasicInfoFormField.DATA_SOURCE_PRODUCT,  
176 - label: '数据源产品',  
177 - component: 'TransferModal',  
178 - ifShow: ({ model }) => {  
179 - return model[BasicInfoFormField.DATA_SOURCE_TYPE] !== DataSourceType.ALL;  
180 - },  
181 - valueField: 'value',  
182 - changeEvent: 'update:value',  
183 - componentProps: ({ formActionType }) => {  
184 - const { setFieldsValue } = formActionType;  
185 - return {  
186 - api: getDeviceProfile,  
187 - labelField: 'name',  
188 - valueField: 'tbProfileId',  
189 - transferProps: {  
190 - listStyle: { height: '400px' },  
191 - showSearch: true,  
192 - filterOption: (inputValue: string, option: Recordable) => {  
193 - const upperCaseInputValue = inputValue.toUpperCase();  
194 - const upperCaseOptionValue = option.name.toUpperCase();  
195 - return upperCaseOptionValue.includes(upperCaseInputValue);  
196 - },  
197 - },  
198 - onChange: () => {  
199 - setFieldsValue({ [BasicInfoFormField.DATA_SOURCE_DEVICE]: [] });  
200 - },  
201 - };  
202 - },  
203 - },  
204 - {  
205 - field: BasicInfoFormField.DATA_SOURCE_DEVICE,  
206 - label: '数据源设备',  
207 - component: 'TransferTableModal',  
208 - ifShow: ({ model }) => {  
209 - return model[BasicInfoFormField.DATA_SOURCE_TYPE] === DataSourceType.DEVICE;  
210 - },  
211 - valueField: 'value',  
212 - changeEvent: 'update:value',  
213 - componentProps: ({ formActionType }) => {  
214 - const { getFieldsValue } = formActionType;  
215 - const values = getFieldsValue();  
216 - const convertConfigId = Reflect.get(values, BasicInfoFormField.CONVERT_CONFIG_ID);  
217 - const devices = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_DEVICE);  
218 -  
219 - return {  
220 - labelField: 'name',  
221 - valueField: 'tbDeviceId',  
222 - primaryKey: 'tbDeviceId',  
223 - pendingTableProps: {  
224 - ...TransferTableProps,  
225 - api: devicePage,  
226 - beforeFetch: (params) => {  
227 - const values = getFieldsValue();  
228 - const deviceProfileIds = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_PRODUCT);  
229 - const convertConfigId = Reflect.get(values, BasicInfoFormField.CONVERT_CONFIG_ID);  
230 - if (convertConfigId) {  
231 - Object.assign(params, { convertConfigId, selected: false });  
232 - }  
233 - return { ...params, deviceProfileIds };  
234 - },  
235 - } as BasicTableProps,  
236 - selectedTableProps: {  
237 - ...TransferTableProps,  
238 - // api  
239 - api: !!(convertConfigId && devices) ? devicePage : undefined,  
240 - beforeFetch: (params) => {  
241 - const values = getFieldsValue();  
242 - const deviceProfileIds = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_PRODUCT);  
243 - const convertConfigId = Reflect.get(values, BasicInfoFormField.CONVERT_CONFIG_ID);  
244 - if (convertConfigId) {  
245 - Object.assign(params, { convertConfigId, selected: true });  
246 - }  
247 - return { ...params, deviceProfileIds };  
248 - },  
249 - } as BasicTableProps,  
250 - initSelectedOptions: async ({ setSelectedTotal }) => {  
251 - const values = getFieldsValue();  
252 - const convertConfigId = Reflect.get(values, BasicInfoFormField.CONVERT_CONFIG_ID);  
253 - const deviceProfileIds = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_PRODUCT);  
254 - const devices = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_DEVICE);  
255 - if (convertConfigId && devices) {  
256 - const { items, total } = await devicePage({  
257 - page: 1,  
258 - pageSize: 10,  
259 - convertConfigId: values[BasicInfoFormField.CONVERT_CONFIG_ID],  
260 - deviceProfileIds,  
261 - selected: true,  
262 - });  
263 - setSelectedTotal(total);  
264 - return items;  
265 - }  
266 - return [];  
267 - },  
268 - onSelectedAfter: async () => {  
269 - submitFn && (await submitFn(false));  
270 - },  
271 - onRemoveAfter: async ({ reloadSelected }) => {  
272 - submitFn && (await submitFn(false));  
273 - reloadSelected();  
274 - },  
275 - transformValue: (_selectedRowKeys: string[], selectedRows: DeviceRecord[]) => {  
276 - return handleGroupDevice(selectedRows);  
277 - },  
278 - };  
279 - },  
280 - },  
281 - {  
282 - field: 'type',  
283 - label: '转换方式',  
284 - component: 'ApiSelect',  
285 - required: true,  
286 - colProps: {  
287 - span: 24,  
288 - },  
289 - componentProps({}) {  
290 - return {  
291 - api: findDictItemByCode,  
292 - params: {  
293 - dictCode: 'convert_data_to',  
294 - },  
295 - labelField: 'itemText',  
296 - valueField: 'itemValue',  
297 - };  
298 - },  
299 - },  
300 - {  
301 - field: 'remark',  
302 - label: '描述',  
303 - colProps: { span: 24 },  
304 - component: 'Input',  
305 - componentProps: {  
306 - maxLength: 255,  
307 - placeholder: '请输入描述',  
308 - },  
309 - },  
310 - ];  
311 -}; 1 +import { FormSchema } from '/@/components/Form';
  2 +import { findDictItemByCode } from '/@/api/system/dict';
  3 +import { h, unref } from 'vue';
  4 +import { getDeviceProfile } from '/@/api/alarm/position';
  5 +import { BasicColumn, BasicTableProps } from '/@/components/Table';
  6 +import { devicePage } from '/@/api/device/deviceManager';
  7 +import { Tag } from 'ant-design-vue';
  8 +import { DeviceRecord } from '/@/api/device/model/deviceModel';
  9 +import { FETCH_SETTING } from '/@/components/Table/src/const';
  10 +import { useMessage } from '/@/hooks/web/useMessage';
  11 +import {
  12 + BasicInfoFormField,
  13 + DataSourceType,
  14 + DeviceStatusEnum,
  15 + DeviceStatusNameEnum,
  16 + DeviceTypeNameEnum,
  17 +} from '../enum';
  18 +import { useClipboard } from '@vueuse/core';
  19 +
  20 +export const stepConfig = ['选择流转方式', '完善配置参数'];
  21 +
  22 +export const removeFieldByModeForm = ['name', 'description'];
  23 +
  24 +//表单通用配置
  25 +export const modelFormPublicConfig = {
  26 + labelWidth: 120,
  27 + actionColOptions: {
  28 + span: 14,
  29 + },
  30 + showResetButton: false,
  31 + showSubmitButton: false,
  32 +};
  33 +
  34 +const handleGroupDevice = (options: DeviceRecord[]) => {
  35 + const map = new Map<string, string[]>();
  36 + options.forEach((item) => {
  37 + if (map.has(item.profileId)) {
  38 + const deviceList = map.get(item.profileId)!;
  39 + deviceList.push(item.tbDeviceId);
  40 + } else {
  41 + map.set(item.profileId, [item.tbDeviceId]);
  42 + }
  43 + });
  44 + const value = Array.from(map.entries()).map(([product, devices]) => ({ product, devices }));
  45 +
  46 + return value;
  47 +};
  48 +
  49 +const deviceTableFormSchema: FormSchema[] = [
  50 + {
  51 + field: 'name',
  52 + label: '设备名称',
  53 + component: 'Input',
  54 + colProps: { span: 9 },
  55 + componentProps: {
  56 + placeholder: '请输入设备名称',
  57 + },
  58 + },
  59 + {
  60 + field: 'deviceType',
  61 + label: '设备类型',
  62 + component: 'ApiSelect',
  63 + colProps: { span: 9 },
  64 + componentProps: {
  65 + placeholder: '请选择设备类型',
  66 + api: findDictItemByCode,
  67 + params: {
  68 + dictCode: 'device_type',
  69 + },
  70 + labelField: 'itemText',
  71 + valueField: 'itemValue',
  72 + },
  73 + },
  74 +];
  75 +
  76 +const { copied, copy } = useClipboard({ legacy: true });
  77 +
  78 +const { createMessage } = useMessage();
  79 +
  80 +const deviceTableColumn: BasicColumn[] = [
  81 + {
  82 + title: '状态',
  83 + dataIndex: 'deviceState',
  84 + customRender: ({ text }) => {
  85 + return h(
  86 + Tag,
  87 + {
  88 + color:
  89 + text === DeviceStatusEnum.INACTIVE
  90 + ? 'warning'
  91 + : text === DeviceStatusEnum.OFFLINE
  92 + ? 'error'
  93 + : 'success',
  94 + },
  95 + () => DeviceStatusNameEnum[text]
  96 + );
  97 + },
  98 + },
  99 + {
  100 + title: '别名/设备名称',
  101 + dataIndex: 'name',
  102 + customRender: ({ record }) => {
  103 + return h('div', [
  104 + h(
  105 + 'div',
  106 + {
  107 + class: 'cursor-pointer',
  108 + onClick: async () => {
  109 + await copy(record.name);
  110 + if (unref(copied)) createMessage.success('复制成功~');
  111 + },
  112 + },
  113 + [
  114 + record.alias && h('div', { class: 'truncate' }, record.alias),
  115 + h('div', { class: 'text-blue-400 truncate' }, record.name),
  116 + ]
  117 + ),
  118 + ]);
  119 + },
  120 + },
  121 + {
  122 + title: '设备类型',
  123 + dataIndex: 'deviceType',
  124 + customRender: ({ text }) => {
  125 + return h(Tag, { color: 'success' }, () => DeviceTypeNameEnum[text]);
  126 + },
  127 + },
  128 + {
  129 + title: '所属产品',
  130 + dataIndex: 'deviceProfile.name',
  131 + },
  132 + {
  133 + title: '所属组织',
  134 + dataIndex: 'organizationDTO.name',
  135 + },
  136 +];
  137 +
  138 +const TransferTableProps: BasicTableProps = {
  139 + formConfig: {
  140 + layout: 'inline',
  141 + labelWidth: 80,
  142 + schemas: deviceTableFormSchema,
  143 + actionColOptions: { span: 6 },
  144 + },
  145 + size: 'small',
  146 + maxHeight: 240,
  147 + useSearchForm: true,
  148 + columns: deviceTableColumn,
  149 + showIndexColumn: false,
  150 + fetchSetting: FETCH_SETTING,
  151 +} as BasicTableProps;
  152 +
  153 +export const modeForm = (submitFn?: Function): FormSchema[] => {
  154 + return [
  155 + {
  156 + field: BasicInfoFormField.CONVERT_CONFIG_ID,
  157 + label: '',
  158 + component: 'Input',
  159 + show: false,
  160 + },
  161 + {
  162 + field: BasicInfoFormField.DATA_SOURCE_TYPE,
  163 + label: '数据源',
  164 + component: 'RadioGroup',
  165 + defaultValue: DataSourceType.ALL,
  166 + componentProps: {
  167 + options: [
  168 + { label: '全部', value: DataSourceType.ALL },
  169 + { label: '产品', value: DataSourceType.PRODUCT },
  170 + { label: '设备', value: DataSourceType.DEVICE },
  171 + ],
  172 + },
  173 + },
  174 + {
  175 + field: BasicInfoFormField.DATA_SOURCE_PRODUCT,
  176 + label: '数据源产品',
  177 + component: 'TransferModal',
  178 + rules: [{ required: true, message: '数据源产品为必选项', type: 'array' }],
  179 + ifShow: ({ model }) => {
  180 + return model[BasicInfoFormField.DATA_SOURCE_TYPE] !== DataSourceType.ALL;
  181 + },
  182 + valueField: 'value',
  183 + changeEvent: 'update:value',
  184 + componentProps: ({ formActionType }) => {
  185 + const { setFieldsValue } = formActionType;
  186 + return {
  187 + api: getDeviceProfile,
  188 + labelField: 'name',
  189 + valueField: 'tbProfileId',
  190 + transferProps: {
  191 + listStyle: { height: '400px' },
  192 + showSearch: true,
  193 + filterOption: (inputValue: string, option: Recordable) => {
  194 + const upperCaseInputValue = inputValue.toUpperCase();
  195 + const upperCaseOptionValue = option.name.toUpperCase();
  196 + return upperCaseOptionValue.includes(upperCaseInputValue);
  197 + },
  198 + },
  199 + onChange: () => {
  200 + setFieldsValue({ [BasicInfoFormField.DATA_SOURCE_DEVICE]: [] });
  201 + },
  202 + };
  203 + },
  204 + },
  205 + {
  206 + field: BasicInfoFormField.DATA_SOURCE_DEVICE,
  207 + label: '数据源设备',
  208 + component: 'TransferTableModal',
  209 + ifShow: ({ model }) => {
  210 + return model[BasicInfoFormField.DATA_SOURCE_TYPE] === DataSourceType.DEVICE;
  211 + },
  212 + valueField: 'value',
  213 + changeEvent: 'update:value',
  214 + rules: [{ required: true, message: '数据源设备为必选项', type: 'array' }],
  215 + componentProps: ({ formActionType }) => {
  216 + const { getFieldsValue } = formActionType;
  217 + const values = getFieldsValue();
  218 + const convertConfigId = Reflect.get(values, BasicInfoFormField.CONVERT_CONFIG_ID);
  219 + const devices = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_DEVICE);
  220 +
  221 + return {
  222 + labelField: 'name',
  223 + valueField: 'tbDeviceId',
  224 + primaryKey: 'tbDeviceId',
  225 + pendingTableProps: {
  226 + ...TransferTableProps,
  227 + api: devicePage,
  228 + beforeFetch: (params) => {
  229 + const values = getFieldsValue();
  230 + const deviceProfileIds = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_PRODUCT);
  231 + const convertConfigId = Reflect.get(values, BasicInfoFormField.CONVERT_CONFIG_ID);
  232 + if (convertConfigId) {
  233 + Object.assign(params, { convertConfigId, selected: false });
  234 + }
  235 + return { ...params, deviceProfileIds };
  236 + },
  237 + } as BasicTableProps,
  238 + selectedTableProps: {
  239 + ...TransferTableProps,
  240 + // api
  241 + api: !!(convertConfigId && devices) ? devicePage : undefined,
  242 + beforeFetch: (params) => {
  243 + const values = getFieldsValue();
  244 + const deviceProfileIds = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_PRODUCT);
  245 + const convertConfigId = Reflect.get(values, BasicInfoFormField.CONVERT_CONFIG_ID);
  246 + if (convertConfigId) {
  247 + Object.assign(params, { convertConfigId, selected: true });
  248 + }
  249 + return { ...params, deviceProfileIds };
  250 + },
  251 + } as BasicTableProps,
  252 + initSelectedOptions: async ({ setSelectedTotal }) => {
  253 + const values = getFieldsValue();
  254 + const convertConfigId = Reflect.get(values, BasicInfoFormField.CONVERT_CONFIG_ID);
  255 + const deviceProfileIds = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_PRODUCT);
  256 + const devices = Reflect.get(values, BasicInfoFormField.DATA_SOURCE_DEVICE);
  257 + if (convertConfigId && devices) {
  258 + const { items, total } = await devicePage({
  259 + page: 1,
  260 + pageSize: 10,
  261 + convertConfigId: values[BasicInfoFormField.CONVERT_CONFIG_ID],
  262 + deviceProfileIds,
  263 + selected: true,
  264 + });
  265 + setSelectedTotal(total);
  266 + return items;
  267 + }
  268 + return [];
  269 + },
  270 + onSelectedAfter: async () => {
  271 + submitFn && (await submitFn(false));
  272 + },
  273 + onRemoveAfter: async ({ reloadSelected }) => {
  274 + submitFn && (await submitFn(false));
  275 + reloadSelected();
  276 + },
  277 + transformValue: (_selectedRowKeys: string[], selectedRows: DeviceRecord[]) => {
  278 + return handleGroupDevice(selectedRows);
  279 + },
  280 + };
  281 + },
  282 + },
  283 + {
  284 + field: 'type',
  285 + label: '转换方式',
  286 + component: 'ApiSelect',
  287 + required: true,
  288 + colProps: {
  289 + span: 24,
  290 + },
  291 + componentProps({}) {
  292 + return {
  293 + api: findDictItemByCode,
  294 + params: {
  295 + dictCode: 'convert_data_to',
  296 + },
  297 + labelField: 'itemText',
  298 + valueField: 'itemValue',
  299 + };
  300 + },
  301 + },
  302 + {
  303 + field: 'remark',
  304 + label: '描述',
  305 + colProps: { span: 24 },
  306 + component: 'Input',
  307 + componentProps: {
  308 + maxLength: 255,
  309 + placeholder: '请输入描述',
  310 + },
  311 + },
  312 + ];
  313 +};
@@ -626,6 +626,7 @@ export const actionSchema: FormSchema[] = [ @@ -626,6 +626,7 @@ export const actionSchema: FormSchema[] = [
626 inputData: selected?.functionJson.inputData, 626 inputData: selected?.functionJson.inputData,
627 }, 627 },
628 }); 628 });
  629 + selected && setFieldsValue({ callType: selected.callType });
629 return record; 630 return record;
630 } catch (error) { 631 } catch (error) {
631 console.error(error); 632 console.error(error);
@@ -641,8 +642,9 @@ export const actionSchema: FormSchema[] = [ @@ -641,8 +642,9 @@ export const actionSchema: FormSchema[] = [
641 onChange: (_, options: ModelOfMatterParams) => { 642 onChange: (_, options: ModelOfMatterParams) => {
642 if (options) { 643 if (options) {
643 // setFieldsValue({ doContext: { ...options.functionJson, callType: options.callType } }); 644 // setFieldsValue({ doContext: { ...options.functionJson, callType: options.callType } });
  645 + const record = { callType: options.callType };
644 transportType === TransportTypeEnum.TCP 646 transportType === TransportTypeEnum.TCP
645 - ? setFieldsValue({ 647 + ? Object.assign(record, {
646 tcpServiceCommand: options.functionJson?.inputData?.[0]?.serviceCommand, 648 tcpServiceCommand: options.functionJson?.inputData?.[0]?.serviceCommand,
647 }) 649 })
648 : updateSchema({ 650 : updateSchema({
@@ -651,6 +653,8 @@ export const actionSchema: FormSchema[] = [ @@ -651,6 +653,8 @@ export const actionSchema: FormSchema[] = [
651 inputData: options.functionJson.inputData, 653 inputData: options.functionJson.inputData,
652 }, 654 },
653 }); 655 });
  656 +
  657 + setFieldsValue(record);
654 } 658 }
655 }, 659 },
656 }; 660 };
@@ -152,12 +152,14 @@ @@ -152,12 +152,14 @@
152 const { createMessage } = useMessage(); 152 const { createMessage } = useMessage();
153 try { 153 try {
154 const values = await validate(); 154 const values = await validate();
  155 + const treeCheckedKeys: string[] = (unref(treeRef)?.getCheckedKeys() as string[]) || [];
  156 + const menu = [...new Set([...unref(checkedKeysWithHalfChecked), ...treeCheckedKeys])];
155 const req = { 157 const req = {
156 id: roleId.value, 158 id: roleId.value,
157 name: values.name, 159 name: values.name,
158 remark: values.remark, 160 remark: values.remark,
159 status: values.status, 161 status: values.status,
160 - menu: unref(checkedKeysWithHalfChecked), 162 + menu,
161 }; 163 };
162 if (req.menu == undefined) return createMessage.error('请勾选权限菜单'); 164 if (req.menu == undefined) return createMessage.error('请勾选权限菜单');
163 saveOrUpdateRoleInfoWithMenu(req).then(() => { 165 saveOrUpdateRoleInfoWithMenu(req).then(() => {
@@ -86,12 +86,8 @@ export const columnSchedue: BasicColumn[] = [ @@ -86,12 +86,8 @@ export const columnSchedue: BasicColumn[] = [
86 title: '任务组名', 86 title: '任务组名',
87 dataIndex: 'jobGroup', 87 dataIndex: 'jobGroup',
88 width: 120, 88 width: 120,
89 - format: (_text: string, record: Recordable) => {  
90 - return record.jobGroup === EJobGroup.DEFAULT  
91 - ? '默认'  
92 - : record.jobGroup === EJobGroup.SYSTEM  
93 - ? '系统'  
94 - : '报表'; 89 + format: (text: string) => {
  90 + return EJobGroupName[text] || EJobGroupName.REPORT;
95 }, 91 },
96 }, 92 },
97 { 93 {
@@ -185,7 +185,7 @@ export const formSchemas: FormSchema[] = [ @@ -185,7 +185,7 @@ export const formSchemas: FormSchema[] = [
185 { 185 {
186 label: TaskTypeNameEnum.MODBUS_RTU, 186 label: TaskTypeNameEnum.MODBUS_RTU,
187 value: TaskTypeEnum.MODBUS_RTU, 187 value: TaskTypeEnum.MODBUS_RTU,
188 - disabled: transportType && transportType !== PushWayEnum.TCP, 188 + disabled: transportType ? transportType && transportType !== PushWayEnum.TCP : true,
189 }, 189 },
190 ], 190 ],
191 onChange(value: TaskTypeEnum) { 191 onChange(value: TaskTypeEnum) {
@@ -201,7 +201,7 @@ export const formSchemas: FormSchema[] = [ @@ -201,7 +201,7 @@ export const formSchemas: FormSchema[] = [
201 field: FormFieldsEnum.PUSH_WAY, 201 field: FormFieldsEnum.PUSH_WAY,
202 component: 'RadioGroup', 202 component: 'RadioGroup',
203 label: '推送方式', 203 label: '推送方式',
204 - defaultValue: PushWayEnum.TCP, 204 + defaultValue: PushWayEnum.MQTT,
205 show: false, 205 show: false,
206 componentProps: { 206 componentProps: {
207 options: [ 207 options: [
@@ -131,6 +131,8 @@ @@ -131,6 +131,8 @@
131 async function handleSubmit() { 131 async function handleSubmit() {
132 setDrawerProps({ loading: true, confirmLoading: true }); 132 setDrawerProps({ loading: true, confirmLoading: true });
133 const { createMessage } = useMessage(); 133 const { createMessage } = useMessage();
  134 + const treeCheckedKeys: string[] = (unref(treeRef)?.getCheckedKeys() as string[]) || [];
  135 + const menu = [...new Set([...unref(checkedKeysWithHalfChecked), ...treeCheckedKeys])];
134 try { 136 try {
135 const values = await validate(); 137 const values = await validate();
136 const req = { 138 const req = {
@@ -139,7 +141,7 @@ @@ -139,7 +141,7 @@
139 remark: values.remark, 141 remark: values.remark,
140 status: values.status, 142 status: values.status,
141 roleType: RoleEnum.TENANT_ADMIN, 143 roleType: RoleEnum.TENANT_ADMIN,
142 - menu: unref(checkedKeysWithHalfChecked), 144 + menu,
143 }; 145 };
144 if (req.menu == undefined) return createMessage.error('请勾选权限菜单'); 146 if (req.menu == undefined) return createMessage.error('请勾选权限菜单');
145 const res = await saveOrUpdateRoleInfoWithMenu(req); 147 const res = await saveOrUpdateRoleInfoWithMenu(req);
@@ -42,10 +42,10 @@ @@ -42,10 +42,10 @@
42 const { customCommand } = record; 42 const { customCommand } = record;
43 return setFieldsValue({ 43 return setFieldsValue({
44 ...record, 44 ...record,
45 - transportType: customCommand?.transportType,  
46 - service: customCommand?.service,  
47 - command: customCommand?.command,  
48 - commandType: customCommand?.commandType, 45 + transportType: customCommand?.transportType || (record as Recordable).transportType,
  46 + service: customCommand?.service || (record as Recordable).service,
  47 + command: customCommand?.command || (record as Recordable).command,
  48 + commandType: customCommand?.commandType || (record as Recordable).commandType,
49 } as unknown as Partial<CommonDataSourceBindValueType>); 49 } as unknown as Partial<CommonDataSourceBindValueType>);
50 }; 50 };
51 51
@@ -42,10 +42,10 @@ @@ -42,10 +42,10 @@
42 const { customCommand } = record; 42 const { customCommand } = record;
43 return setFieldsValue({ 43 return setFieldsValue({
44 ...record, 44 ...record,
45 - transportType: customCommand?.transportType,  
46 - service: customCommand?.service,  
47 - command: customCommand?.command,  
48 - commandType: customCommand?.commandType, 45 + transportType: customCommand?.transportType || (record as Recordable).transportType,
  46 + service: customCommand?.service || (record as Recordable).service,
  47 + command: customCommand?.command || (record as Recordable).command,
  48 + commandType: customCommand?.commandType || (record as Recordable).commandType,
49 } as unknown as Partial<CommonDataSourceBindValueType>); 49 } as unknown as Partial<CommonDataSourceBindValueType>);
50 }; 50 };
51 51
@@ -42,10 +42,10 @@ @@ -42,10 +42,10 @@
42 const { customCommand } = record; 42 const { customCommand } = record;
43 return setFieldsValue({ 43 return setFieldsValue({
44 ...record, 44 ...record,
45 - transportType: customCommand?.transportType,  
46 - service: customCommand?.service,  
47 - command: customCommand?.command,  
48 - commandType: customCommand?.commandType, 45 + transportType: customCommand?.transportType || (record as Recordable).transportType,
  46 + service: customCommand?.service || (record as Recordable).service,
  47 + command: customCommand?.command || (record as Recordable).command,
  48 + commandType: customCommand?.commandType || (record as Recordable).commandType,
49 } as unknown as Partial<CommonDataSourceBindValueType>); 49 } as unknown as Partial<CommonDataSourceBindValueType>);
50 }; 50 };
51 51