Commit b5e1bd47a09eab6c380496b3daddafbc60328354

Authored by xp.Huang
2 parents fccc2e0a 3b794b79

Merge branch 'ft' into 'main'

fix:修复告警管理启用不能批量删除

See merge request huang/yun-teng-iot-front!176
... ... @@ -6,7 +6,13 @@
6 6 @select="handleSelect"
7 7 ref="organizationIdTreeRef"
8 8 />
9   - <BasicTable @register="registerTable" :searchInfo="searchInfo" class="w-3/4 xl:w-4/5">
  9 + <BasicTable
  10 + @selection-change="useSelectionChange"
  11 + @register="registerTable"
  12 + :searchInfo="searchInfo"
  13 + :rowSelection="{ type: 'checkbox' }"
  14 + class="w-3/4 xl:w-4/5"
  15 + >
10 16 <template #toolbar>
11 17 <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增告警配置 </a-button>
12 18 <a-button
... ... @@ -61,7 +67,7 @@
61 67 </template>
62 68
63 69 <script lang="ts">
64   - import { defineComponent, reactive, ref, computed, h } from 'vue';
  70 + import { defineComponent, reactive, ref, h } from 'vue';
65 71 import { BasicTable, useTable, TableAction } from '/@/components/Table';
66 72 import { PageWrapper } from '/@/components/Page';
67 73 import { useMessage } from '/@/hooks/web/useMessage';
... ... @@ -84,16 +90,12 @@
84 90 ContactDrawer,
85 91 },
86 92 setup() {
87   - let selectedRowIds = ref<string[]>([]);
88   - const hasBatchDelete = computed(() => selectedRowIds.value.length <= 0);
89   - // 复选框事件
90   - const onSelectRowChange = (selectedRowKeys: string[]) => {
91   - selectedRowIds.value = selectedRowKeys;
92   - };
  93 + const selectArray: any = ref([]);
  94 + const hasBatchDelete = ref(true);
93 95 const searchInfo = reactive<Recordable>({});
94 96 const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo);
95 97 // 表格hooks
96   - const [registerTable, { reload }] = useTable({
  98 + const [registerTable, { reload, getSelectRows }] = useTable({
97 99 title: '告警配置列表',
98 100 api: queryAlarmConfig,
99 101 columns,
... ... @@ -107,10 +109,6 @@
107 109 useSearchForm: true,
108 110 showTableSetting: true,
109 111 bordered: true,
110   - rowSelection: {
111   - onChange: onSelectRowChange,
112   - type: 'checkbox',
113   - },
114 112 rowKey: 'id',
115 113 actionColumn: {
116 114 width: 200,
... ... @@ -141,6 +139,19 @@
141 139 });
142 140 }
143 141 };
  142 + const useSelectionChange = () => {
  143 + selectArray.value = getSelectRows()
  144 + .filter((f) => f.status !== 1)
  145 + .map((m) => m.id);
  146 + if (selectArray.value.length > 0) {
  147 + hasBatchDelete.value = false;
  148 + } else {
  149 + hasBatchDelete.value = true;
  150 + }
  151 + // const isJude = getSelectRows().some((s) => {
  152 + // if (s.status == 1) return createMessage.error('不能删除已经启用的,请选择未启用的');
  153 + // });
  154 + };
144 155 // 删除或批量删除
145 156 const handleDeleteOrBatchDelete = async (record: Recordable | null) => {
146 157 if (record) {
... ... @@ -148,17 +159,18 @@
148 159 await deleteAlarmConfig([record.id]);
149 160 createMessage.success('删除成功');
150 161 handleSuccess();
151   - } catch (e) {
152   - createMessage.error('删除失败');
  162 + } catch (e: any) {
  163 + createMessage.error(e.msg);
153 164 }
154 165 } else {
155 166 try {
156   - await deleteAlarmConfig(selectedRowIds.value);
  167 + await deleteAlarmConfig(selectArray.value);
157 168 createMessage.success('批量删除成功');
158   - selectedRowIds.value = [];
159 169 handleSuccess();
160   - } catch (e) {
161   - createMessage.info('删除失败');
  170 + selectArray.value.length = 0;
  171 + } catch (e: any) {
  172 + createMessage.error(e.msg);
  173 + selectArray.value.length = 0;
162 174 }
163 175 }
164 176 };
... ... @@ -210,6 +222,7 @@
210 222 });
211 223 };
212 224 return {
  225 + useSelectionChange,
213 226 searchInfo,
214 227 hasBatchDelete,
215 228 handleCreateOrEdit,
... ...
... ... @@ -39,6 +39,7 @@
39 39 import { Button } from '/@/components/Button';
40 40 import MqttCpns from '../step/cpns/mqtt/Mqtt.vue';
41 41 import CoapCpns from '../step/cpns/coap/Coap.vue';
  42 + import Lwm2mCpns from '../step/cpns/lwm2m/index.vue';
42 43
43 44 export default defineComponent({
44 45 components: {
... ...
... ... @@ -29,32 +29,392 @@ export const serverSchemas: FormSchema[] = [
29 29 defaultValue: 123,
30 30 colProps: { span: 8 },
31 31 },
  32 + {
  33 + field: '3',
  34 + component: 'InputNumber',
  35 + label: 'Minimum period between two',
  36 + required: true,
  37 + defaultValue: 123,
  38 + colProps: { span: 8 },
  39 + },
  40 + {
  41 + field: '4',
  42 + component: 'Select',
  43 + label: 'Binding',
  44 + defaultValue: 'UQ: UDP connection in queue mode',
  45 + componentProps: {
  46 + options: [
  47 + {
  48 + label: 'U: UDP connection in standard mode',
  49 + value: 'U: UDP connection in standard mode',
  50 + },
  51 + {
  52 + label: 'UQ: UDP connection in queue mode',
  53 + value: 'UQ: UDP connection in queue mode',
  54 + },
  55 + {
  56 + label: 'T: TCP connection in standard mode',
  57 + value: 'T: TCP connection in standard mode',
  58 + },
  59 + {
  60 + label: 'TQ: TCP connection in queue mode',
  61 + value: 'TQ: TCP connection in queue mode',
  62 + },
  63 + {
  64 + label: 'S: SMS connection in standard mode',
  65 + value: 'S: SMS connection in standard mode',
  66 + },
  67 + {
  68 + label: 'SQ: SMS connection in queue mode',
  69 + value: 'SQ: SMS connection in queue mode',
  70 + },
  71 + {
  72 + label: 'US: both UDP and SMS connections active, both in standard mode',
  73 + value: 'US: both UDP and SMS connections active, both in standard mode',
  74 + },
  75 + {
  76 + label: 'TS: both TCP and SMS connections active, both in standard mode',
  77 + value: 'TS: both TCP and SMS connections active, both in standard mode',
  78 + },
  79 + {
  80 + label:
  81 + 'UQS: both UDP and SMS connections active; UDP in queue mode, SMS in standard mode',
  82 + value:
  83 + 'UQS: both UDP and SMS connections active; UDP in queue mode, SMS in standard mode',
  84 + },
  85 + {
  86 + label:
  87 + 'TQS: both TCP and SMS connections active; TCP in queue mode, SMS in standard mode',
  88 + value:
  89 + 'TQS: both TCP and SMS connections active; TCP in queue mode, SMS in standard mode',
  90 + },
  91 + ],
  92 + },
  93 + colProps: { span: 8 },
  94 + },
  95 + {
  96 + field: '5',
  97 + label: '启用',
  98 + colProps: { span: 22 },
  99 + component: 'Checkbox',
  100 + renderComponentContent: 'Notification storing when disabled or offline',
  101 + },
  102 + {
  103 + field: '6',
  104 + component: 'Select',
  105 + label: 'Security config mode',
  106 + defaultValue: 'No Security',
  107 + componentProps: {
  108 + options: [
  109 + {
  110 + label: 'No Security',
  111 + value: 'No Security',
  112 + },
  113 + {
  114 + label: 'Pre-Shared Key',
  115 + value: 'Pre-Shared Key',
  116 + },
  117 + {
  118 + label: 'Raw Public Key',
  119 + value: 'Raw Public Key',
  120 + },
  121 + {
  122 + label: 'X.509 Certificate',
  123 + value: 'X.509 Certificate',
  124 + },
  125 + ],
  126 + },
  127 + colProps: { span: 8 },
  128 + },
  129 + {
  130 + field: '7',
  131 + component: 'Input',
  132 + label: 'Host',
  133 + required: true,
  134 + defaultValue: '0.0.0.0',
  135 + colProps: { span: 8 },
  136 + },
  137 + {
  138 + field: '8',
  139 + component: 'InputNumber',
  140 + label: 'Port',
  141 + required: true,
  142 + defaultValue: 5688,
  143 + colProps: { span: 8 },
  144 + },
  145 + {
  146 + field: '9',
  147 + component: 'InputNumber',
  148 + label: 'Short ID',
  149 + required: true,
  150 + defaultValue: 111,
  151 + colProps: { span: 8 },
  152 + },
  153 + {
  154 + field: '10',
  155 + component: 'InputNumber',
  156 + label: 'Hold Off Time',
  157 + required: true,
  158 + defaultValue: 1,
  159 + colProps: { span: 8 },
  160 + },
  161 + {
  162 + field: '11',
  163 + component: 'InputNumber',
  164 + label: 'Account after the timeout',
  165 + required: true,
  166 + defaultValue: 0,
  167 + colProps: { span: 8 },
  168 + },
  169 + {
  170 + field: '12',
  171 + component: 'InputTextArea',
  172 + label: 'Account after the timeout',
  173 + required: true,
  174 + defaultValue: `3059301306072a8648ce3d020106082a8648ce3d03010703420004e353af009b814ee2f9ab393a975e0c39
  175 + e2fff60e3603fd6ee54a43b89a4f56258a7aa9c7e4a577760edb289dc955d91968473ee8a1bfc2b9c423563796113009`,
  176 + colProps: { span: 22 },
  177 + componentProps: {
  178 + autoSize: {
  179 + maxRows: 10,
  180 + },
  181 + },
  182 + },
  183 +
  184 + {
  185 + field: '61',
  186 + component: 'Select',
  187 + label: 'Security config mode',
  188 + defaultValue: 'No Security',
  189 + componentProps: {
  190 + options: [
  191 + {
  192 + label: 'No Security',
  193 + value: 'No Security',
  194 + },
  195 + {
  196 + label: 'Pre-Shared Key',
  197 + value: 'Pre-Shared Key',
  198 + },
  199 + {
  200 + label: 'Raw Public Key',
  201 + value: 'Raw Public Key',
  202 + },
  203 + {
  204 + label: 'X.509 Certificate',
  205 + value: 'X.509 Certificate',
  206 + },
  207 + ],
  208 + },
  209 + colProps: { span: 8 },
  210 + },
  211 + {
  212 + field: '71',
  213 + component: 'Input',
  214 + label: 'Host',
  215 + required: true,
  216 + defaultValue: '0.0.0.0',
  217 + colProps: { span: 8 },
  218 + },
  219 + {
  220 + field: '81',
  221 + component: 'InputNumber',
  222 + label: 'Port',
  223 + required: true,
  224 + defaultValue: 5688,
  225 + colProps: { span: 8 },
  226 + },
  227 + {
  228 + field: '91',
  229 + component: 'InputNumber',
  230 + label: 'Short ID',
  231 + required: true,
  232 + defaultValue: 111,
  233 + colProps: { span: 8 },
  234 + },
  235 + {
  236 + field: '101',
  237 + component: 'InputNumber',
  238 + label: 'Hold Off Time',
  239 + required: true,
  240 + defaultValue: 1,
  241 + colProps: { span: 8 },
  242 + },
  243 + {
  244 + field: '111',
  245 + component: 'InputNumber',
  246 + label: 'Account after the timeout',
  247 + required: true,
  248 + defaultValue: 0,
  249 + colProps: { span: 8 },
  250 + },
  251 + {
  252 + field: '121',
  253 + component: 'InputTextArea',
  254 + label: 'Account after the timeout',
  255 + required: true,
  256 + defaultValue: `3059301306072a8648ce3d020106082a8648ce3d03010703420004e353af009b814ee2f9ab393a975e0c39
  257 + e2fff60e3603fd6ee54a43b89a4f56258a7aa9c7e4a577760edb289dc955d91968473ee8a1bfc2b9c423563796113009`,
  258 + colProps: { span: 22 },
  259 + componentProps: {
  260 + autoSize: {
  261 + maxRows: 10,
  262 + },
  263 + },
  264 + },
32 265 ];
33 266
34 267 export const settingsSchemas: FormSchema[] = [
35 268 {
36   - field: 'deviceTelemetryTopic',
  269 + field: '1',
  270 + component: 'Select',
  271 + label: 'Firmware update strategy',
  272 + defaultValue: 'Push firmware update as binary file using Object 5 and Resource 0 (Package)',
  273 + componentProps: {
  274 + options: [
  275 + {
  276 + label: 'Push firmware update as binary file using Object 5 and Resource 0 (Package)',
  277 + value: 'Push firmware update as binary file using Object 5 and Resource 0 (Package)',
  278 + },
  279 + {
  280 + label:
  281 + 'Auto-generate unique CoAP URL to download the package and push firmware update as Object 5 and ',
  282 + value:
  283 + 'Auto-generate unique CoAP URL to download the package and push firmware update as Object 5 and ',
  284 + },
  285 + {
  286 + label: 'Push firmware update as binary file using Object 19 and Resource 0 (Data)',
  287 + value: 'Push firmware update as binary file using Object 19 and Resource 0 (Data)',
  288 + },
  289 + ],
  290 + },
  291 + colProps: { span: 22 },
  292 + },
  293 + {
  294 + field: '2',
  295 + component: 'Select',
  296 + label: 'Firmware update strategy',
  297 + defaultValue: 'Push firmware update as binary file using Object 5 and Resource 0 (Package)',
  298 + componentProps: {
  299 + options: [
  300 + {
  301 + label: 'Push binary file using Object 9 and Resource 2 (Package)',
  302 + value: 'Push binary file using Object 9 and Resource 2 (Package)',
  303 + },
  304 + {
  305 + label:
  306 + 'Auto-generate unique CoAP URL to download the package and push software update using Object 9 and ',
  307 + value:
  308 + 'Auto-generate unique CoAP URL to download the package and push software update using Object 9 and ',
  309 + },
  310 + ],
  311 + },
  312 + colProps: { span: 22 },
  313 + },
  314 + {
  315 + field: '3',
37 316 component: 'Input',
38   - label: '筛选器',
  317 + label: 'Software update CoAP resource',
39 318 required: true,
40   - defaultValue: 'v1/devices/me/telemetry',
  319 + defaultValue: 'coap://localhost:5685',
41 320 componentProps: {
42   - placeholder: '请输入遥测数据 topic 筛选器',
  321 + placeholder: '请输入',
43 322 },
44 323 colProps: { span: 11 },
45 324 },
  325 + {
  326 + field: '4',
  327 + component: 'Select',
  328 + label: 'Discontinuous Reception (DRX)',
  329 + defaultValue: 'Push firmware update as binary file using Object 5 and Resource 0 (Package)',
  330 + componentProps: {
  331 + options: [
  332 + {
  333 + label: 'Discontinuous Reception (DRX)',
  334 + value: 'Discontinuous Reception (DRX)',
  335 + },
  336 + {
  337 + label: 'Power Saving Mode (PSM) ',
  338 + value: 'Power Saving Mode (PSM) ',
  339 + },
  340 + {
  341 + label: 'Extended Discontinuous Reception (eDRX) ',
  342 + value: 'Extended Discontinuous Reception (eDRX) ',
  343 + },
  344 + ],
  345 + },
  346 + colProps: { span: 22 },
  347 + },
  348 + {
  349 + field: '5',
  350 + label: '启用',
  351 + colProps: { span: 22 },
  352 + component: 'Checkbox',
  353 + renderComponentContent: 'Supports composite Read/Write/Observe operations',
  354 + },
46 355 ];
47 356
48 357 export const deviceSchemas: FormSchema[] = [
49 358 {
50   - field: 'deviceTelemetryTopic',
51   - component: 'Input',
52   - label: '筛选器',
53   - required: true,
54   - defaultValue: 'v1/devices/me/telemetry',
  359 + field: '1',
  360 + label: 'LWM2M',
  361 + colProps: { span: 22 },
  362 + component: 'InputTextArea',
55 363 componentProps: {
56   - placeholder: '请输入遥测数据 topic 筛选器',
  364 + autoSize: {
  365 + maxRows: 30,
  366 + },
57 367 },
58   - colProps: { span: 11 },
  368 + defaultValue: `
  369 + {
  370 + "observeAttr": {
  371 + "observe": [],
  372 + "attribute": [],
  373 + "telemetry": [],
  374 + "keyName": {},
  375 + "attributeLwm2m": {}
  376 + },
  377 + "bootstrap": {
  378 + "servers": {
  379 + "binding": "UQ",
  380 + "shortId": 123,
  381 + "lifetime": 300,
  382 + "notifIfDisabled": true,
  383 + "defaultMinPeriod": 1
  384 + },
  385 + "bootstrapServer": {
  386 + "bootstrapServerIs": true,
  387 + "host": "0.0.0.0",
  388 + "port": 5687,
  389 + "securityHost": "0.0.0.0",
  390 + "securityPort": 5688,
  391 + "serverId": 111,
  392 + "clientHoldOffTime": 1,
  393 + "serverPublicKey": "",
  394 + "bootstrapServerAccountTimeout": 0
  395 + },
  396 + "lwm2mServer": {
  397 + "bootstrapServerIs": false,
  398 + "host": "0.0.0.0",
  399 + "port": 5685,
  400 + "securityHost": "0.0.0.0",
  401 + "securityPort": 5686,
  402 + "serverId": 123,
  403 + "clientHoldOffTime": 1,
  404 + "serverPublicKey": "",
  405 + "bootstrapServerAccountTimeout": 0
  406 + }
  407 + },
  408 + "clientLwM2mSettings": {
  409 + "clientOnlyObserveAfterConnect": 1,
  410 + "fwUpdateStrategy": 1,
  411 + "swUpdateStrategy": 2,
  412 + "swUpdateResource": "coap://localhost:5685",
  413 + "powerMode": "DRX",
  414 + "compositeOperationsSupport": false
  415 + },
  416 + "type": "LWM2M"
  417 + }
  418 + `,
59 419 },
60 420 ];
... ...