Commit 775670ce36676d3c2f8ef153d19cbbb0c9257499

Authored by ww
1 parent 6aca1fc4

fix: 修复TCP转换脚本表格组件冗余筛选条件

1   -import { BasicColumn, BasicTableProps, FormSchema } from '/@/components/Table';
2   -import moment from 'moment';
3   -import { h } from 'vue';
4   -
5   -//业务权限配置
6   -export enum PermissionConvertScriptEnum {
7   - PERMISSION_POST = 'api:yt:js:post',
8   - PERMISSION_DELETE = 'api:yt:js:delete',
9   - PERMISSION_TEST = 'api:yt:js:test',
10   - PERMISSION_UPDATE = 'api:yt:js:update',
11   - PERMISSION_UPDATE_STATUS = 'api:yt:js:update:status',
12   -}
13   -
14   -//业务文字描述配置
15   -export enum BusinessConvertScriptTextEnum {
16   - BUSINESS_ENABLE_SUCCESS = '启用成功',
17   - BUSINESS_DISABLE_SUCCESS = '禁用成功',
18   - BUSINESS_ADD_TEXT = '新增转换脚本',
19   - BUSINESS_DELETE_TEXT = '批量删除',
20   - BUSINESS_VIEW_TEXT = '查看转换脚本',
21   - BUSINESS_TEST_TEXT = '测试转换脚本',
22   - BUSINESS_EDIT_TEXT = '编辑转换脚本',
23   - BUSINESS_SUBMIT_TEXT = '确定',
24   -}
25   -
26   -//业务脚本类型枚举
27   -export enum ScriptTypeEnum {
28   - //上行脚本
29   - TRANSPORT_TCP_UP = 'TRANSPORT_TCP_UP',
30   - //设备鉴权
31   - TRANSPORT_TCP_AUTH = 'TRANSPORT_TCP_AUTH',
32   -}
33   -
34   -//Ace编辑器通用配置
35   -export const aceEditorAttribtes = {
36   - maxLines: 16, // 最大行数,超过会自动出现滚动条
37   - minLines: 12, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
38   - fontSize: 14, // 编辑器内字体大小
39   - theme: 'ace/theme/chrome', // 默认设置的主题
40   - mode: 'ace/mode/javascript', // 默认设置的语言模式
41   - tabSize: 2, // 制表符设置为 4 个空格大小
42   -};
43   -
44   -export const aceEditorOptions = {
45   - enableBasicAutocompletion: true,
46   - enableLiveAutocompletion: true,
47   - enableSnippets: true,
48   - enableEmmet: true,
49   -};
50   -
51   -// 表格配置
52   -export const columns: BasicColumn[] = [
53   - {
54   - title: '脚本名称',
55   - dataIndex: 'name',
56   - width: 80,
57   - },
58   - {
59   - title: '脚本状态',
60   - dataIndex: 'status',
61   - width: 120,
62   - slots: { customRender: 'status' },
63   - },
64   - {
65   - title: '脚本内容',
66   - dataIndex: 'convertJs',
67   - width: 120,
68   - slots: { customRender: 'convertJs' },
69   - },
70   - {
71   - title: '备注',
72   - dataIndex: 'description',
73   - width: 120,
74   - },
75   - {
76   - title: '创建时间',
77   - dataIndex: 'createTime',
78   - width: 180,
79   - },
80   -];
81   -
82   -//表格通用属性配置
83   -export const defaultTableAttribtes: BasicTableProps = {
84   - columns,
85   - title: '转换脚本列表',
86   - showIndexColumn: false,
87   - clickToRowSelect: false,
88   - useSearchForm: true,
89   - showTableSetting: true,
90   - bordered: true,
91   - rowKey: 'id',
92   - actionColumn: {
93   - width: 200,
94   - title: '操作',
95   - dataIndex: 'action',
96   - slots: { customRender: 'action' },
97   - fixed: 'right',
98   - },
99   -};
100   -
101   -// 表格查询配置
102   -export const searchFormSchema: FormSchema[] = [
103   - {
104   - field: 'name',
105   - label: '脚本名称',
106   - component: 'Input',
107   - colProps: { span: 6 },
108   - componentProps: {
109   - maxLength: 36,
110   - placeholder: '请输入配置名称',
111   - },
112   - },
113   - {
114   - field: 'sendTime',
115   - label: '创建时间',
116   - component: 'RangePicker',
117   - componentProps: {
118   - showTime: {
119   - defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
120   - },
121   - },
122   - colProps: { span: 6 },
123   - },
124   -];
125   -
126   -//示例配置
127   -export const defaultAuthTitle = h('div', { style: 'background:#404040' }, [
128   - h('h3', { style: 'color:white' }, '设备鉴权示例'),
129   - h('h3', { style: 'color:white' }, '输入参数:为16进制字符串'),
130   - h('h3', { style: 'color:white' }, '输出参数:{"password":"","success":""}'),
131   - h('h3', { style: 'color:white' }, 'password为设备鉴权信息,success为鉴权成功后响应给设备的内容'),
132   -]);
133   -
134   -export const defaultUpTitle = h('div', { style: 'background:#404040' }, [
135   - h('h3', { style: 'color:white' }, '上行数据解析示例'),
136   - h('h3', { style: 'color:white' }, '输入参数:为字符串'),
137   - h(
138   - 'h3',
139   - { style: 'color:white' },
140   - `输出参数:{"datas":{"source":""},"telemetry":true,"ackMsg":"","deviceName":"","ts":1681701034289}`
141   - ),
142   - h(
143   - 'h3',
144   - { style: 'color:white' },
145   - `datas:json对象,属性名为遥测指标或子设备名称
146   - telemetry: datas内容是否为遥测数据
147   - ackMsg: 响应给设备的确认消息
148   - deviceName: 设备名称
149   - ts: 数据采集时间`
150   - ),
151   -]);
152   -
153   -//用例配置
154   -export const defaultScriptTypeContent = {
155   - TRANSPORT_TCP_UP: `/*网关上行脚本*/
156   -var teleData = {};
157   -/*物模型数据(可选):原始数据*/
158   -teleData.source = params;
159   -/*网关设备:slaveDevice是网关子设备的“设备标识”*/
160   -slaveDevice = params.substr(0, 2);
161   -teleData[slaveDevice] = params;
162   -out.datas = teleData;
163   -out.telemetry = true;
164   -/*必填:true表示设备上报的遥测数据,false表示命令下发的响应数据*/
165   - `,
166   - TRANSPORT_TCP_AUTH: `/*必填:设备的访问令牌*/
167   -out.password = params;
168   -/*选填:设备鉴权成功后响应给设备的信息*/
169   -out.success = params;
170   - `,
171   -};
172   -
173   -export const defaultTestUpExample = defaultScriptTypeContent['TRANSPORT_TCP_UP'];
174   -
175   -export const defaultTestAuthExample = defaultScriptTypeContent['TRANSPORT_TCP_AUTH'];
176   -
177   -export const defaultTestSubGatewayUpExample = `/*params为TCP上报的标准ModBus数据,实际使用或测试时请删除*/
178   -var params = "010304026C00883BF0"
179   -var teleData = {};
180   -/*物模型数据(可选):原始数据*/
181   -teleData.source = params;
182   -/*直连设备:tempVal是产品物模型中所定义属性的标识符*/
183   -tempVal = params;
184   -/*物模型温度标识符*/
185   -teleData.temperature = (parseInt('0x'+tempVal.substr(10, 4))*0.1).toFixed(2);
186   -/*物模型湿度标识符*/
187   -teleData.humidity = (parseInt('0x'+tempVal.substr(6, 4))*0.1).toFixed(2);
188   -out.datas = teleData;
189   -/*必填:true表示设备上报的遥测数据,false表示命令下发的响应数据*/
190   -out.telemetry = true;`;
  1 +import { BasicColumn, BasicTableProps, FormSchema } from '/@/components/Table';
  2 +import moment from 'moment';
  3 +import { h } from 'vue';
  4 +
  5 +//业务权限配置
  6 +export enum PermissionConvertScriptEnum {
  7 + PERMISSION_POST = 'api:yt:js:post',
  8 + PERMISSION_DELETE = 'api:yt:js:delete',
  9 + PERMISSION_TEST = 'api:yt:js:test',
  10 + PERMISSION_UPDATE = 'api:yt:js:update',
  11 + PERMISSION_UPDATE_STATUS = 'api:yt:js:update:status',
  12 +}
  13 +
  14 +//业务文字描述配置
  15 +export enum BusinessConvertScriptTextEnum {
  16 + BUSINESS_ENABLE_SUCCESS = '启用成功',
  17 + BUSINESS_DISABLE_SUCCESS = '禁用成功',
  18 + BUSINESS_ADD_TEXT = '新增转换脚本',
  19 + BUSINESS_DELETE_TEXT = '批量删除',
  20 + BUSINESS_VIEW_TEXT = '查看转换脚本',
  21 + BUSINESS_TEST_TEXT = '测试转换脚本',
  22 + BUSINESS_EDIT_TEXT = '编辑转换脚本',
  23 + BUSINESS_SUBMIT_TEXT = '确定',
  24 +}
  25 +
  26 +//业务脚本类型枚举
  27 +export enum ScriptTypeEnum {
  28 + //上行脚本
  29 + TRANSPORT_TCP_UP = 'TRANSPORT_TCP_UP',
  30 + //设备鉴权
  31 + TRANSPORT_TCP_AUTH = 'TRANSPORT_TCP_AUTH',
  32 +}
  33 +
  34 +//Ace编辑器通用配置
  35 +export const aceEditorAttribtes = {
  36 + maxLines: 16, // 最大行数,超过会自动出现滚动条
  37 + minLines: 12, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
  38 + fontSize: 14, // 编辑器内字体大小
  39 + theme: 'ace/theme/chrome', // 默认设置的主题
  40 + mode: 'ace/mode/javascript', // 默认设置的语言模式
  41 + tabSize: 2, // 制表符设置为 4 个空格大小
  42 +};
  43 +
  44 +export const aceEditorOptions = {
  45 + enableBasicAutocompletion: true,
  46 + enableLiveAutocompletion: true,
  47 + enableSnippets: true,
  48 + enableEmmet: true,
  49 +};
  50 +
  51 +// 表格配置
  52 +export const columns: BasicColumn[] = [
  53 + {
  54 + title: '脚本名称',
  55 + dataIndex: 'name',
  56 + width: 80,
  57 + },
  58 + {
  59 + title: '脚本状态',
  60 + dataIndex: 'status',
  61 + width: 120,
  62 + slots: { customRender: 'status' },
  63 + },
  64 + {
  65 + title: '脚本内容',
  66 + dataIndex: 'convertJs',
  67 + width: 120,
  68 + slots: { customRender: 'convertJs' },
  69 + },
  70 + {
  71 + title: '备注',
  72 + dataIndex: 'description',
  73 + width: 120,
  74 + },
  75 + {
  76 + title: '创建时间',
  77 + dataIndex: 'createTime',
  78 + width: 180,
  79 + },
  80 +];
  81 +
  82 +//表格通用属性配置
  83 +export const defaultTableAttribtes: BasicTableProps = {
  84 + columns,
  85 + title: '转换脚本列表',
  86 + showIndexColumn: false,
  87 + clickToRowSelect: false,
  88 + // useSearchForm: true,
  89 + showTableSetting: true,
  90 + bordered: true,
  91 + rowKey: 'id',
  92 + actionColumn: {
  93 + width: 200,
  94 + title: '操作',
  95 + dataIndex: 'action',
  96 + slots: { customRender: 'action' },
  97 + fixed: 'right',
  98 + },
  99 +};
  100 +
  101 +// 表格查询配置
  102 +export const searchFormSchema: FormSchema[] = [
  103 + {
  104 + field: 'name',
  105 + label: '脚本名称',
  106 + component: 'Input',
  107 + colProps: { span: 6 },
  108 + componentProps: {
  109 + maxLength: 36,
  110 + placeholder: '请输入配置名称',
  111 + },
  112 + },
  113 + {
  114 + field: 'sendTime',
  115 + label: '创建时间',
  116 + component: 'RangePicker',
  117 + componentProps: {
  118 + showTime: {
  119 + defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
  120 + },
  121 + },
  122 + colProps: { span: 6 },
  123 + },
  124 +];
  125 +
  126 +//示例配置
  127 +export const defaultAuthTitle = h('div', { style: 'background:#404040' }, [
  128 + h('h3', { style: 'color:white' }, '设备鉴权示例'),
  129 + h('h3', { style: 'color:white' }, '输入参数:为16进制字符串'),
  130 + h('h3', { style: 'color:white' }, '输出参数:{"password":"","success":""}'),
  131 + h('h3', { style: 'color:white' }, 'password为设备鉴权信息,success为鉴权成功后响应给设备的内容'),
  132 +]);
  133 +
  134 +export const defaultUpTitle = h('div', { style: 'background:#404040' }, [
  135 + h('h3', { style: 'color:white' }, '上行数据解析示例'),
  136 + h('h3', { style: 'color:white' }, '输入参数:为字符串'),
  137 + h(
  138 + 'h3',
  139 + { style: 'color:white' },
  140 + `输出参数:{"datas":{"source":""},"telemetry":true,"ackMsg":"","deviceName":"","ts":1681701034289}`
  141 + ),
  142 + h(
  143 + 'h3',
  144 + { style: 'color:white' },
  145 + `datas:json对象,属性名为遥测指标或子设备名称
  146 + telemetry: datas内容是否为遥测数据
  147 + ackMsg: 响应给设备的确认消息
  148 + deviceName: 设备名称
  149 + ts: 数据采集时间`
  150 + ),
  151 +]);
  152 +
  153 +//用例配置
  154 +export const defaultScriptTypeContent = {
  155 + TRANSPORT_TCP_UP: `/*网关上行脚本*/
  156 +var teleData = {};
  157 +/*物模型数据(可选):原始数据*/
  158 +teleData.source = params;
  159 +/*网关设备:slaveDevice是网关子设备的“设备标识”*/
  160 +slaveDevice = params.substr(0, 2);
  161 +teleData[slaveDevice] = params;
  162 +out.datas = teleData;
  163 +out.telemetry = true;
  164 +/*必填:true表示设备上报的遥测数据,false表示命令下发的响应数据*/
  165 + `,
  166 + TRANSPORT_TCP_AUTH: `/*必填:设备的访问令牌*/
  167 +out.password = params;
  168 +/*选填:设备鉴权成功后响应给设备的信息*/
  169 +out.success = params;
  170 + `,
  171 +};
  172 +
  173 +export const defaultTestUpExample = defaultScriptTypeContent['TRANSPORT_TCP_UP'];
  174 +
  175 +export const defaultTestAuthExample = defaultScriptTypeContent['TRANSPORT_TCP_AUTH'];
  176 +
  177 +export const defaultTestSubGatewayUpExample = `/*params为TCP上报的标准ModBus数据,实际使用或测试时请删除*/
  178 +var params = "010304026C00883BF0"
  179 +var teleData = {};
  180 +/*物模型数据(可选):原始数据*/
  181 +teleData.source = params;
  182 +/*直连设备:tempVal是产品物模型中所定义属性的标识符*/
  183 +tempVal = params;
  184 +/*物模型温度标识符*/
  185 +teleData.temperature = (parseInt('0x'+tempVal.substr(10, 4))*0.1).toFixed(2);
  186 +/*物模型湿度标识符*/
  187 +teleData.humidity = (parseInt('0x'+tempVal.substr(6, 4))*0.1).toFixed(2);
  188 +out.datas = teleData;
  189 +/*必填:true表示设备上报的遥测数据,false表示命令下发的响应数据*/
  190 +out.telemetry = true;`;
... ...
... ... @@ -108,7 +108,6 @@
108 108 } from '/@/api/scriptmanage/scriptManager';
109 109 import {
110 110 PermissionConvertScriptEnum,
111   - searchFormSchema,
112 111 defaultTableAttribtes,
113 112 BusinessConvertScriptTextEnum,
114 113 } from './config';
... ... @@ -127,11 +126,6 @@
127 126 beforeFetch: (params: Recordable) => {
128 127 return { ...unref(props.searchInfo), ...params };
129 128 },
130   - formConfig: {
131   - labelWidth: 120,
132   - schemas: searchFormSchema,
133   - fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'x']],
134   - },
135 129 });
136 130
137 131 const handleSuccess = () => {
... ...