Commit 40c6b3790eec6617c26856db16f1765473a79637

Authored by ww
1 parent 8918bfcf

fix: DEFECT-1152 修复公共接口管理wobsocket连接池未取消订阅消息

... ... @@ -182,7 +182,7 @@
182 182 Reflect.set(params, 'scope', 'LATEST_TELEMETRY');
183 183 Reflect.set(params, 'entityType', 'DEVICE');
184 184 }
185   - socketMessage.sendValue.tsSubCmds.push(params);
  185 + socketMessage.sendValue.tsSubCmds = [params];
186 186 const { send, close } = useWebSocket(socketMessage.server, {
187 187 onConnected() {
188 188 send(JSON.stringify(socketMessage.sendValue));
... ...
... ... @@ -221,7 +221,7 @@
221 221 deviceProfileId,
222 222 });
223 223 entityOptions.value = res.map((item) => ({
224   - label: item.name,
  224 + label: item.alias || item.name,
225 225 value: item.tbDeviceId,
226 226 }));
227 227 };
... ...
1   -import { BasicColumn, FormSchema } from '/@/components/Table';
2   -import { h } from 'vue';
3   -import { Tag } from 'ant-design-vue';
4   -import { findDictItemByCode } from '/@/api/system/dict';
5   -import { USER_INFO_KEY } from '/@/enums/cacheEnum';
6   -import { getAuthCache } from '/@/utils/auth';
7   -import { isAdmin } from '/@/enums/roleEnum';
8   -
9   -// 表格配置
10   -export const columns: BasicColumn[] = [
11   - {
12   - title: '接口名称',
13   - dataIndex: 'interfaceName',
14   - width: 150,
15   - },
16   - {
17   - title: '接口类型',
18   - dataIndex: 'interfaceType',
19   - width: 80,
20   - format(text) {
21   - return text === 'SYSTEM' ? '系统默认' : '自定义';
22   - },
23   - },
24   - {
25   - title: '请求方式',
26   - dataIndex: 'requestContentType',
27   - width: 90,
28   - format(text) {
29   - return Number(text) === 0 ? '普通请求' : Number(text) === 1 ? 'SQL请求' : 'websocket请求';
30   - },
31   - },
32   - {
33   - title: '接口内容',
34   - dataIndex: 'content',
35   - width: 80,
36   - slots: { customRender: 'content' },
37   - },
38   - {
39   - title: '状态',
40   - dataIndex: 'state',
41   - width: 80,
42   - customRender: ({ record }) => {
43   - const color = record.state == 1 ? 'green' : 'red';
44   - const text = record.state == 1 ? '发布' : '未发布';
45   - return h(Tag, { color: color }, () => text);
46   - },
47   - },
48   -];
49   -
50   -// 查询配置
51   -export const searchFormSchema: FormSchema[] = [
52   - {
53   - field: 'name',
54   - label: '接口名称',
55   - component: 'Input',
56   - colProps: { span: 7 },
57   - componentProps: {
58   - maxLength: 36,
59   - placeholder: '请输入接口名称',
60   - },
61   - },
62   - {
63   - field: 'state',
64   - label: '发布状态',
65   - component: 'Select',
66   - colProps: { span: 7 },
67   - componentProps: {
68   - options: [
69   - {
70   - label: '发布',
71   - value: 1,
72   - },
73   - {
74   - label: '未发布',
75   - value: 0,
76   - },
77   - ],
78   - placeholder: '请选择发布状态',
79   - },
80   - },
81   - {
82   - field: 'interfaceType',
83   - label: '接口类型',
84   - component: 'Select',
85   - colProps: { span: 7 },
86   - componentProps: {
87   - options: [
88   - {
89   - label: '系统默认',
90   - value: 'SYSTEM',
91   - },
92   - {
93   - label: '自定义',
94   - value: 'CUSTOM',
95   - },
96   - ],
97   - placeholder: '请选择接口类型',
98   - },
99   - ifShow: ({}) => {
100   - const userInfo: any = getAuthCache(USER_INFO_KEY);
101   - const role: string = userInfo?.roles[0];
102   - if (isAdmin(role)) return true;
103   - else return false;
104   - },
105   - },
106   -];
107   -
108   -//表单配置
109   -export const schemas: FormSchema[] = [
110   - {
111   - field: 'interfaceName',
112   - label: '接口名称',
113   - colProps: { span: 24 },
114   - required: true,
115   - component: 'Input',
116   - componentProps: {
117   - maxLength: 255,
118   - placeholder: '请输入接口名称',
119   - },
120   - },
121   - // {
122   - // field: 'interfaceType',
123   - // component: 'ApiRadioGroup',
124   - // label: '接口类型',
125   - // required: true,
126   - // colProps: {
127   - // span: 8,
128   - // },
129   - // defaultValue: 'SYSTEM',
130   - // componentProps: {
131   - // api: findDictItemByCode,
132   - // params: {
133   - // dictCode: 'interface_Type',
134   - // },
135   - // labelField: 'itemText',
136   - // valueField: 'itemValue',
137   - // },
138   - // },
139   - {
140   - field: 'interfaceType',
141   - component: 'ApiRadioGroup',
142   - label: '接口类型',
143   - required: true,
144   - colProps: {
145   - span: 8,
146   - },
147   - defaultValue: 'CUSTOM',
148   - componentProps: {
149   - options: [
150   - {
151   - label: '系统默认',
152   - value: 'SYSTEM',
153   - },
154   - {
155   - label: '自定义',
156   - value: 'CUSTOM',
157   - },
158   - ],
159   - },
160   - ifShow: ({}) => {
161   - const userInfo: any = getAuthCache(USER_INFO_KEY);
162   - const role: string = userInfo?.roles[0];
163   - if (isAdmin(role)) return true;
164   - else return false;
165   - },
166   - },
167   - {
168   - field: 'requestContentType',
169   - label: '请求方式',
170   - component: 'ApiSelect',
171   - required: true,
172   - colProps: { span: 24 },
173   - defaultValue: '0',
174   - componentProps: ({ formActionType }) => {
175   - const { updateSchema, setFieldsValue } = formActionType;
176   - return {
177   - api: findDictItemByCode,
178   - params: {
179   - dictCode: 'dataview_select_methods',
180   - },
181   - placeholder: '请选择请求方式',
182   - labelField: 'itemText',
183   - valueField: 'itemValue',
184   - getPopupContainer: () => document.body,
185   - async onChange(e) {
186   - setFieldsValue({
187   - requestOriginUrl: '',
188   - requestHttpTypeAndUrl: {
189   - requestHttpType: undefined,
190   - requestUrl: '',
191   - },
192   - });
193   - updateSchema({
194   - field: 'requestHttpTypeAndUrl',
195   - componentProps: {
196   - type: e,
197   - },
198   - });
199   - updateSchema({
200   - field: 'requestOriginUrl',
201   - componentProps: {
202   - placeholder: `${
203   - e === '0' ? '示例:http://127.0.0.1' : e === '2' ? '示例:ws://127.0.0.1' : ''
204   - }`,
205   - },
206   - });
207   - },
208   - };
209   - },
210   - },
211   - {
212   - field: 'originUrlType',
213   - label: '地址类型',
214   - component: 'ApiSelect',
215   - required: true,
216   - colProps: { span: 24 },
217   - defaultValue: 'server_url',
218   - componentProps: ({ formActionType }) => {
219   - const { setFieldsValue } = formActionType;
220   - return {
221   - placeholder: '请选择地址类型',
222   - api: findDictItemByCode,
223   - params: {
224   - dictCode: 'dataview_select_origin_type',
225   - },
226   - labelField: 'itemText',
227   - valueField: 'itemValue',
228   - onChange: (e) => {
229   - if (e) {
230   - setFieldsValue({
231   - requestOriginUrl: '',
232   - });
233   - }
234   - },
235   - };
236   - },
237   - },
238   - {
239   - field: 'requestOriginUrl',
240   - label: '源地址',
241   - colProps: { span: 24 },
242   - required: true,
243   - component: 'Input',
244   - componentProps: ({ formActionType }) => {
245   - const { getFieldsValue } = formActionType;
246   - const type = getFieldsValue()?.requestContentType;
247   - return {
248   - placeholder: `${
249   - type === '0' ? '示例:http://127.0.0.1' : type === '2' ? '示例:ws://127.0.0.1' : ''
250   - }`,
251   - };
252   - },
253   - ifShow: ({ values }) => values['originUrlType'] === 'custom_url',
254   - },
255   - {
256   - field: 'requestHttpTypeAndUrl',
257   - label: '请求类型&地址',
258   - component: 'InputGroup',
259   - required: true,
260   - colProps: { span: 24 },
261   - componentProps: ({ formActionType }) => {
262   - const { getFieldsValue } = formActionType;
263   - return {
264   - type: getFieldsValue().requestContentType,
265   - };
266   - },
267   - },
268   - {
269   - field: 'fillAddress',
270   - label: '完整地址',
271   - component: 'Input',
272   - slot: 'slotFillAddress',
273   - colProps: { span: 24 },
274   - ifShow: ({ values }) => {
275   - return values['originUrlType'] === 'custom_url' && values['requestOriginUrl'];
276   - },
277   - },
278   - {
279   - field: 'slotServerAddress',
280   - label: '完整地址',
281   - component: 'Input',
282   - slot: 'slotServerAddress',
283   - colProps: { span: 24 },
284   - ifShow: ({ values }) => {
285   - return values['originUrlType'] === 'server_url';
286   - },
287   - },
288   - {
289   - field: 'requestSQLKey',
290   - label: '键名',
291   - colProps: { span: 6 },
292   - component: 'Input',
293   - defaultValue: 'sql',
294   - componentProps: {
295   - disabled: true,
296   - },
297   - ifShow: ({ values }) => values['requestContentType'] === '1',
298   - },
299   - {
300   - field: 'requestSQLContent',
301   - label: '键值',
302   - colProps: { span: 24 },
303   - component: 'InputTextArea',
304   - defaultValue: 'select * from where',
305   - componentProps: {
306   - maxLength: 255,
307   - placeholder: '请输入键值',
308   - rows: 6,
309   - },
310   - ifShow: ({ values }) => values['requestContentType'] === '1',
311   - },
312   - {
313   - field: 'slot',
314   - label: '参数设置',
315   - component: 'Input',
316   - slot: 'selectMethods',
317   - colProps: { span: 24 },
318   - ifShow: ({ values }) => values['requestContentType'] !== '1',
319   - },
320   - {
321   - field: 'testSlot',
322   - label: '',
323   - component: 'Input',
324   - slot: 'testSql',
325   - colProps: { span: 24 },
326   - ifShow: ({ values }) => values['requestContentType'] === '1',
327   - },
328   -];
329   -
330   -//表格表头配置
331   -export const editCellTableTHeadConfig = ['序号', '内置参数', '参数名', '是否必须', '操作'];
332   -export const editTestCellTableTHeadConfig = ['内置参数', '参数名', '参数值'];
333   -export const editTestCellTableTHeaderConfig = ['序号', '参数名', '参数值', '是否必须', '操作'];
  1 +import { BasicColumn, FormSchema } from '/@/components/Table';
  2 +import { h } from 'vue';
  3 +import { Tag } from 'ant-design-vue';
  4 +import { findDictItemByCode } from '/@/api/system/dict';
  5 +import { USER_INFO_KEY } from '/@/enums/cacheEnum';
  6 +import { getAuthCache } from '/@/utils/auth';
  7 +import { isAdmin } from '/@/enums/roleEnum';
  8 +
  9 +// 表格配置
  10 +export const columns: BasicColumn[] = [
  11 + {
  12 + title: '接口名称',
  13 + dataIndex: 'interfaceName',
  14 + width: 150,
  15 + },
  16 + {
  17 + title: '接口类型',
  18 + dataIndex: 'interfaceType',
  19 + width: 80,
  20 + format(text) {
  21 + return text === 'SYSTEM' ? '系统默认' : '自定义';
  22 + },
  23 + },
  24 + {
  25 + title: '请求方式',
  26 + dataIndex: 'requestContentType',
  27 + width: 90,
  28 + format(text) {
  29 + return Number(text) === 0 ? '普通请求' : Number(text) === 1 ? 'SQL请求' : 'websocket请求';
  30 + },
  31 + },
  32 + {
  33 + title: '接口内容',
  34 + dataIndex: 'content',
  35 + width: 80,
  36 + slots: { customRender: 'content' },
  37 + },
  38 + {
  39 + title: '状态',
  40 + dataIndex: 'state',
  41 + width: 80,
  42 + customRender: ({ record }) => {
  43 + const color = record.state == 1 ? 'green' : 'red';
  44 + const text = record.state == 1 ? '发布' : '未发布';
  45 + return h(Tag, { color: color }, () => text);
  46 + },
  47 + },
  48 +];
  49 +
  50 +// 查询配置
  51 +export const searchFormSchema: FormSchema[] = [
  52 + {
  53 + field: 'name',
  54 + label: '接口名称',
  55 + component: 'Input',
  56 + componentProps: {
  57 + maxLength: 36,
  58 + placeholder: '请输入接口名称',
  59 + },
  60 + },
  61 + {
  62 + field: 'state',
  63 + label: '发布状态',
  64 + component: 'Select',
  65 + componentProps: {
  66 + options: [
  67 + {
  68 + label: '发布',
  69 + value: 1,
  70 + },
  71 + {
  72 + label: '未发布',
  73 + value: 0,
  74 + },
  75 + ],
  76 + placeholder: '请选择发布状态',
  77 + },
  78 + },
  79 + {
  80 + field: 'interfaceType',
  81 + label: '接口类型',
  82 + component: 'Select',
  83 + colProps: { span: 7 },
  84 + componentProps: {
  85 + options: [
  86 + {
  87 + label: '系统默认',
  88 + value: 'SYSTEM',
  89 + },
  90 + {
  91 + label: '自定义',
  92 + value: 'CUSTOM',
  93 + },
  94 + ],
  95 + placeholder: '请选择接口类型',
  96 + },
  97 + ifShow: ({}) => {
  98 + const userInfo: any = getAuthCache(USER_INFO_KEY);
  99 + const role: string = userInfo?.roles[0];
  100 + if (isAdmin(role)) return true;
  101 + else return false;
  102 + },
  103 + },
  104 +];
  105 +
  106 +//表单配置
  107 +export const schemas: FormSchema[] = [
  108 + {
  109 + field: 'interfaceName',
  110 + label: '接口名称',
  111 + colProps: { span: 24 },
  112 + required: true,
  113 + component: 'Input',
  114 + componentProps: {
  115 + maxLength: 255,
  116 + placeholder: '请输入接口名称',
  117 + },
  118 + },
  119 + // {
  120 + // field: 'interfaceType',
  121 + // component: 'ApiRadioGroup',
  122 + // label: '接口类型',
  123 + // required: true,
  124 + // colProps: {
  125 + // span: 8,
  126 + // },
  127 + // defaultValue: 'SYSTEM',
  128 + // componentProps: {
  129 + // api: findDictItemByCode,
  130 + // params: {
  131 + // dictCode: 'interface_Type',
  132 + // },
  133 + // labelField: 'itemText',
  134 + // valueField: 'itemValue',
  135 + // },
  136 + // },
  137 + {
  138 + field: 'interfaceType',
  139 + component: 'ApiRadioGroup',
  140 + label: '接口类型',
  141 + required: true,
  142 + colProps: {
  143 + span: 8,
  144 + },
  145 + defaultValue: 'CUSTOM',
  146 + componentProps: {
  147 + options: [
  148 + {
  149 + label: '系统默认',
  150 + value: 'SYSTEM',
  151 + },
  152 + {
  153 + label: '自定义',
  154 + value: 'CUSTOM',
  155 + },
  156 + ],
  157 + },
  158 + ifShow: ({}) => {
  159 + const userInfo: any = getAuthCache(USER_INFO_KEY);
  160 + const role: string = userInfo?.roles[0];
  161 + if (isAdmin(role)) return true;
  162 + else return false;
  163 + },
  164 + },
  165 + {
  166 + field: 'requestContentType',
  167 + label: '请求方式',
  168 + component: 'ApiSelect',
  169 + required: true,
  170 + colProps: { span: 24 },
  171 + defaultValue: '0',
  172 + componentProps: ({ formActionType }) => {
  173 + const { updateSchema, setFieldsValue } = formActionType;
  174 + return {
  175 + api: findDictItemByCode,
  176 + params: {
  177 + dictCode: 'dataview_select_methods',
  178 + },
  179 + placeholder: '请选择请求方式',
  180 + labelField: 'itemText',
  181 + valueField: 'itemValue',
  182 + getPopupContainer: () => document.body,
  183 + async onChange(e) {
  184 + setFieldsValue({
  185 + requestOriginUrl: '',
  186 + requestHttpTypeAndUrl: {
  187 + requestHttpType: undefined,
  188 + requestUrl: '',
  189 + },
  190 + });
  191 + updateSchema({
  192 + field: 'requestHttpTypeAndUrl',
  193 + componentProps: {
  194 + type: e,
  195 + },
  196 + });
  197 + updateSchema({
  198 + field: 'requestOriginUrl',
  199 + componentProps: {
  200 + placeholder: `${
  201 + e === '0' ? '示例:http://127.0.0.1' : e === '2' ? '示例:ws://127.0.0.1' : ''
  202 + }`,
  203 + },
  204 + });
  205 + },
  206 + };
  207 + },
  208 + },
  209 + {
  210 + field: 'originUrlType',
  211 + label: '地址类型',
  212 + component: 'ApiSelect',
  213 + required: true,
  214 + colProps: { span: 24 },
  215 + defaultValue: 'server_url',
  216 + componentProps: ({ formActionType }) => {
  217 + const { setFieldsValue } = formActionType;
  218 + return {
  219 + placeholder: '请选择地址类型',
  220 + api: findDictItemByCode,
  221 + params: {
  222 + dictCode: 'dataview_select_origin_type',
  223 + },
  224 + labelField: 'itemText',
  225 + valueField: 'itemValue',
  226 + onChange: (e) => {
  227 + if (e) {
  228 + setFieldsValue({
  229 + requestOriginUrl: '',
  230 + });
  231 + }
  232 + },
  233 + };
  234 + },
  235 + },
  236 + {
  237 + field: 'requestOriginUrl',
  238 + label: '源地址',
  239 + colProps: { span: 24 },
  240 + required: true,
  241 + component: 'Input',
  242 + componentProps: ({ formActionType }) => {
  243 + const { getFieldsValue } = formActionType;
  244 + const type = getFieldsValue()?.requestContentType;
  245 + return {
  246 + placeholder: `${
  247 + type === '0' ? '示例:http://127.0.0.1' : type === '2' ? '示例:ws://127.0.0.1' : ''
  248 + }`,
  249 + };
  250 + },
  251 + ifShow: ({ values }) => values['originUrlType'] === 'custom_url',
  252 + },
  253 + {
  254 + field: 'requestHttpTypeAndUrl',
  255 + label: '请求类型&地址',
  256 + component: 'InputGroup',
  257 + required: true,
  258 + colProps: { span: 24 },
  259 + componentProps: ({ formActionType }) => {
  260 + const { getFieldsValue } = formActionType;
  261 + return {
  262 + type: getFieldsValue().requestContentType,
  263 + };
  264 + },
  265 + },
  266 + {
  267 + field: 'fillAddress',
  268 + label: '完整地址',
  269 + component: 'Input',
  270 + slot: 'slotFillAddress',
  271 + colProps: { span: 24 },
  272 + ifShow: ({ values }) => {
  273 + return values['originUrlType'] === 'custom_url' && values['requestOriginUrl'];
  274 + },
  275 + },
  276 + {
  277 + field: 'slotServerAddress',
  278 + label: '完整地址',
  279 + component: 'Input',
  280 + slot: 'slotServerAddress',
  281 + colProps: { span: 24 },
  282 + ifShow: ({ values }) => {
  283 + return values['originUrlType'] === 'server_url';
  284 + },
  285 + },
  286 + {
  287 + field: 'requestSQLKey',
  288 + label: '键名',
  289 + colProps: { span: 6 },
  290 + component: 'Input',
  291 + defaultValue: 'sql',
  292 + componentProps: {
  293 + disabled: true,
  294 + },
  295 + ifShow: ({ values }) => values['requestContentType'] === '1',
  296 + },
  297 + {
  298 + field: 'requestSQLContent',
  299 + label: '键值',
  300 + colProps: { span: 24 },
  301 + component: 'InputTextArea',
  302 + defaultValue: 'select * from where',
  303 + componentProps: {
  304 + maxLength: 255,
  305 + placeholder: '请输入键值',
  306 + rows: 6,
  307 + },
  308 + ifShow: ({ values }) => values['requestContentType'] === '1',
  309 + },
  310 + {
  311 + field: 'slot',
  312 + label: '参数设置',
  313 + component: 'Input',
  314 + slot: 'selectMethods',
  315 + colProps: { span: 24 },
  316 + ifShow: ({ values }) => values['requestContentType'] !== '1',
  317 + },
  318 + {
  319 + field: 'testSlot',
  320 + label: '',
  321 + component: 'Input',
  322 + slot: 'testSql',
  323 + colProps: { span: 24 },
  324 + ifShow: ({ values }) => values['requestContentType'] === '1',
  325 + },
  326 +];
  327 +
  328 +//表格表头配置
  329 +export const editCellTableTHeadConfig = ['序号', '内置参数', '参数名', '是否必须', '操作'];
  330 +export const editTestCellTableTHeadConfig = ['内置参数', '参数名', '参数值'];
  331 +export const editTestCellTableTHeaderConfig = ['序号', '参数名', '参数值', '是否必须', '操作'];
... ...
1 1 <template>
2 2 <div>
3   - <BasicTable @register="registerTable" :row-selection="rowSelection">
  3 + <BasicTable
  4 + @register="registerTable"
  5 + :row-selection="rowSelection"
  6 + class="bg-neutral-100 dark:bg-dark-700"
  7 + >
4 8 <template #content="{ record }">
5 9 <a-button type="link" class="ml-2" @click="handleRecordContent(record)"> 查看 </a-button>
6 10 </template>
... ... @@ -108,8 +112,10 @@
108 112 showTableSetting: true,
109 113 bordered: true,
110 114 formConfig: {
111   - labelWidth: 120,
  115 + labelWidth: 80,
112 116 schemas: searchFormSchema,
  117 + baseColProps: { span: 9 },
  118 + actionColOptions: { span: 6 },
113 119 },
114 120 useSearchForm: true,
115 121 actionColumn: {
... ...