Commit 763a5927157e80af3f7bf4f4493973bd08c6212f

Authored by xp.Huang
2 parents d77a7571 79bfa2d0

Merge branch 'ft_local_dev' into 'main'

pref:优化Topic内容

See merge request huang/yun-teng-iot-front!414
... ... @@ -96,10 +96,6 @@ export function getTenantPage(params: TenantPageRequestParams) {
96 96 return getPageData<TenantDTO>(params, Api.tenantPage);
97 97 }
98 98
99   -// export function getTenantAdminPage(params: TenantAdminPageRequestParams) {
100   -// return getPageData<UserDTO>(params, Api.userPage);
101   -// }
102   -
103 99 //分页
104 100 export const getTenantAdminPage = (params: TenantAdminPageRequestParams) => {
105 101 return defHttp.get<TenantAdminPageRequestParams>({
... ...
... ... @@ -40,9 +40,8 @@ export interface TenantPageRequestParams extends BaseQueryParams {
40 40
41 41 export interface TenantAdminPageRequestParams extends BaseQueryParams {
42 42 realName?: string;
43   - // tenantCode: string;
44 43 tenantId?: string;
45   - // roleType?: string;
  44 + items?: string[];
46 45 }
47 46
48 47 export interface tenantProfileDTO {
... ...
... ... @@ -25,7 +25,7 @@
25 25 >
26 26 <div class="change-avatar" style="text-align: center">
27 27 <div class="mb-2" style="font-weight: 700">个人头像</div>
28   - <div style="display: flex; align-items: center; justify-content: center; width: 35.6rem">
  28 + <div style="display: flex; align-items: center; justify-content: center">
29 29 <div>
30 30 <Upload
31 31 name="avatar"
... ... @@ -265,7 +265,8 @@
265 265 transition: border-color 0.3s ease;
266 266 }
267 267 }
  268 +
268 269 .headSetPop :global(.ant-modal-header) {
269   - padding: 27px 0px !important;
  270 + padding: 27px 0 !important;
270 271 }
271 272 </style>
... ...
... ... @@ -18,10 +18,7 @@
18 18 <ListItem @click="go('/notice/myNotices')" class="cursor-pointer">
19 19 <ListItemMeta>
20 20 <template #avatar>
21   - <Avatar
22   - :src="item.sysNotice.avatar ?? defaultAvatar(item.receiverId)"
23   - size="large"
24   - />
  21 + <Avatar :src="item.sysNotice.avatar" size="large" />
25 22 </template>
26 23 <template #description>
27 24 <span class="cursor-pointer noticeTitle">{{ item.sysNotice.title }} </span>
... ... @@ -92,7 +89,7 @@
92 89 ? '#e6e6e5'
93 90 : index === 2
94 91 ? '#f8c296'
95   - : '#0b55f1;',
  92 + : '#0b55f1',
96 93 }"
97 94 >{{ index + 1 }}</span
98 95 >
... ... @@ -169,7 +166,6 @@
169 166 import { BasicTable, useTable } from '/@/components/Table';
170 167 import { isAdmin } from '/@/enums/roleEnum';
171 168 import { getTenantExpireTimeList, getTenantTop10 } from '/@/api/dashboard';
172   - import headerImg from '/@/assets/images/logo.png';
173 169
174 170 export default defineComponent({
175 171 components: {
... ... @@ -257,11 +253,6 @@
257 253 });
258 254
259 255 const userStore = useUserStore();
260   - const defaultAvatar = (uid) => {
261   - if (uid === userStore.getUserInfo?.userId) {
262   - return userStore.getUserInfo?.avatar || headerImg;
263   - }
264   - };
265 256 const getContacts = computed(() => {
266 257 return userStore.enterPriseInfo?.contacts;
267 258 });
... ... @@ -302,7 +293,6 @@
302 293 registerTable,
303 294 isAdmin,
304 295 Empty,
305   - defaultAvatar,
306 296 };
307 297 },
308 298 });
... ...
... ... @@ -199,6 +199,7 @@ export const step2Schemas: FormSchema[] = [
199 199 {
200 200 field: 'transportType',
201 201 component: 'Select',
  202 + required: true,
202 203 label: '接入协议',
203 204 defaultValue: 'DEFAULT',
204 205 componentProps() {
... ... @@ -454,13 +455,31 @@ export const topicTableColumn: BasicColumn[] = [
454 455 width: 100,
455 456 },
456 457 {
457   - title: 'Topic类',
458   - dataIndex: 'class',
  458 + title: '发布主题',
  459 + dataIndex: 'release',
459 460 width: 100,
460 461 },
  462 +
461 463 {
462   - title: '描述',
463   - dataIndex: 'description',
  464 + title: '订阅主题',
  465 + dataIndex: 'subscribe',
464 466 width: 100,
465 467 },
  468 + {
  469 + title: '平台',
  470 + dataIndex: 'platform',
  471 + width: 30,
  472 + },
  473 +
  474 + {
  475 + title: '设备',
  476 + dataIndex: 'device',
  477 + width: 30,
  478 + },
  479 +
  480 + // {
  481 + // title: '描述',
  482 + // dataIndex: 'description',
  483 + // width: 100,
  484 + // },
466 485 ];
... ...
1 1 <script lang="ts" setup>
2 2 import { topicTableColumn } from '../device.profile.data';
3 3 import { BasicTable, useTable } from '/@/components/Table';
4   - import { buildUUID } from '/@/utils/uuid';
5 4
6 5 const list = [
7   - { function: '遥测主题', class: 'v1/devices/me/telemetry' },
8   - { function: '属性主题', class: 'v1/devices/me/attributes' },
9   - { function: '设备上报事件主题', class: 'v1/devices/me/attributes' },
10   - { function: '服务控制设备(RPC)主题', class: 'v1/devices/me/attributes' },
  6 + {
  7 + function: '网关/直连设备遥测',
  8 + release: 'v1/devices/me/telemetry',
  9 + subscribe: 'v1/devices/me/telemetry',
  10 + platform: '订阅',
  11 + device: '发布',
  12 + },
  13 + {
  14 + function: '服务端命令下发到设备端',
  15 + release: 'v1/devices/me/rpc/request/$request_id',
  16 + subscribe: 'v1/devices/me/rpc/request/+',
  17 + platform: '发布',
  18 + device: '订阅',
  19 + },
  20 + {
  21 + function: '设备端响应命令到服务端',
  22 + release: 'v1/devices/me/rpc/response/$request_id',
  23 + subscribe: 'v1/devices/me/rpc/response/+',
  24 + platform: '订阅',
  25 + device: '发布',
  26 + },
  27 + {
  28 + function: '直连设备属性上报',
  29 + release: 'v1/devices/me/attributes',
  30 + subscribe: 'v1/devices/me/attributes',
  31 + platform: '订阅',
  32 + device: '发布',
  33 + },
  34 +
  35 + {
  36 + function: '设备端请求服务端共享属性及客户端属性',
  37 + release: 'vv1/devices/me/attributes/response/$request_id',
  38 + subscribe: 'v1/devices/me/attributes/response/+',
  39 + platform: '订阅',
  40 + device: '发布',
  41 + },
  42 + {
  43 + function: '服务端响应共享属性集客户端属性给设备端',
  44 + release: 'v1/devices/me/attributes/response/$request_id',
  45 + subscribe: 'v1/devices/me/attributes/response/+',
  46 + platform: '发布',
  47 + device: '订阅',
  48 + },
  49 + {
  50 + function: '设备端请求服务端子设备共享属性及客户端属性',
  51 + release: 'v1/gateway/attributes/request',
  52 + subscribe: 'v1/gateway/attributes/request',
  53 + platform: '订阅',
  54 + device: '发布',
  55 + },
  56 + {
  57 + function: '服务端响应子设备共享属性及客户端属性给设备端',
  58 + release: 'v1/gateway/attributes/response',
  59 + subscribe: 'v1/gateway/attributes/response',
  60 + platform: '发布',
  61 + device: '订阅',
  62 + },
  63 + {
  64 + function: '设备端上报子设备客户端属性',
  65 + release: 'v1/gateway/attributes',
  66 + subscribe: 'v1/gateway/attributes',
  67 + platform: '订阅',
  68 + device: '发布',
  69 + },
  70 + {
  71 + function: '网关子设备遥测',
  72 + release: 'v1/gateway/telemetry',
  73 + subscribe: 'v1/gateway/telemetry',
  74 + platform: '订阅',
  75 + device: '发布',
  76 + },
11 77 ];
12 78
13   - const dataSource = Array.from({ length: 10 }, (_, index) => {
14   - const record = list[index % 4];
15   - return {
16   - id: buildUUID(),
17   - ...record,
18   - description: record.function,
19   - };
20   - });
  79 + const dataSource = list;
21 80
22 81 const [register] = useTable({
23 82 title: 'Topic',
... ...
... ... @@ -37,11 +37,9 @@
37 37 import { SelectTypes } from 'ant-design-vue/es/select';
38 38 import { Select } from 'ant-design-vue';
39 39 import { useModal } from '/@/components/Modal';
40   - import { useMessage } from '/@/hooks/web/useMessage';
41 40 import { getScriptManageMeList } from '/@/api/scriptmanage/scriptManager';
42 41 import ConverScriptModal from '/@/views/scriptmanage/converscript/ConverScriptModal.vue';
43 42
44   - const { createMessage } = useMessage();
45 43 const selectScript = reactive<Record<'script', Nullable<string>>>({
46 44 script: null,
47 45 });
... ... @@ -91,6 +89,7 @@
91 89 openModal(true, {
92 90 isUpdate: false,
93 91 isTest: true,
  92 + record: selectScript.script,
94 93 isText: 'test',
95 94 isTitle: 'test',
96 95 });
... ... @@ -98,10 +97,6 @@
98 97 };
99 98
100 99 const getFormData = () => {
101   - if (!selectScript.script) {
102   - createMessage.error('请选择转换脚本');
103   - throw '请选择转换脚本';
104   - }
105 100 const value = {
106 101 ...{
107 102 scriptId: selectScript.script,
... ...
... ... @@ -29,10 +29,12 @@
29 29 } from '/@/api/stationnotification/stationnotifyApi';
30 30 import { useMessage } from '/@/hooks/web/useMessage';
31 31 import { Authority } from '/@/components/Authority';
  32 + import { useUserStore } from '/@/store/modules/user';
  33 + import headerImg from '/@/assets/images/logo.png';
32 34
33 35 export default defineComponent({
34 36 name: 'ConfigDrawer',
35   - components: { BasicDrawer, BasicForm,Authority },
  37 + components: { BasicDrawer, BasicForm, Authority },
36 38 emits: ['success', 'register'],
37 39 setup(_, { emit }) {
38 40 const draftDisable = ref(false);
... ... @@ -62,6 +64,9 @@
62 64 setFieldsValue(data.record);
63 65 }
64 66 });
  67 + const userStore = useUserStore();
  68 + const avatar = ref<string | undefined>('');
  69 + avatar.value = userStore.getUserInfo?.avatar || headerImg;
65 70 // 发布通知
66 71 const handleSend = async () => {
67 72 try {
... ... @@ -75,6 +80,7 @@
75 80 ...field,
76 81 pointId,
77 82 id: unref(isUpdate) ? unref(noticeId) : undefined,
  83 + avatar: avatar.value,
78 84 };
79 85 await notifyAddLeaseApi(editNotice);
80 86 emit('success');
... ... @@ -106,6 +112,7 @@
106 112 ...field,
107 113 pointId,
108 114 id: unref(noticeId),
  115 + avatar: avatar.value,
109 116 };
110 117 await notifyAddDraftApi(editDraft);
111 118 }
... ...
... ... @@ -14,7 +14,12 @@
14 14 :rules="[{ required: true, message: ifAdd ? '请输入脚本名称' : '请输入参数' }]"
15 15 >
16 16 <a-input v-if="ifAdd" v-model:value="scriptForm.name" placeholder="请输入脚本名称" />
17   - <a-input v-else v-model:value="scriptForm.params" placeholder="请输入参数" />
  17 + <a-input
  18 + @change="handleInputChange"
  19 + v-else
  20 + v-model:value="scriptForm.params"
  21 + placeholder="请输入参数"
  22 + />
18 23 </a-form-item>
19 24 <a-form-item
20 25 label="上报数据类型"
... ... @@ -25,6 +30,15 @@
25 30 <a-radio-group v-model:value="scriptForm.dataType" :options="typeOptions" />
26 31 </a-space>
27 32 </a-form-item>
  33 + <a-form-item
  34 + label="保存原始数据"
  35 + name="saveOriginalData"
  36 + :rules="[{ required: true, message: '请选择保存原始数据' }]"
  37 + >
  38 + <a-space direction="vertical">
  39 + <a-radio-group v-model:value="scriptForm.saveOriginalData" :options="originalOptions" />
  40 + </a-space>
  41 + </a-form-item>
28 42 <a-form-item label="脚本内容" :name="ifAdd ? 'convertJs' : 'script'">
29 43 <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }">
30 44 <template #extra>
... ... @@ -74,7 +88,8 @@
74 88 import { useMessage } from '/@/hooks/web/useMessage';
75 89 import { findDictItemByCode } from '/@/api/system/dict';
76 90 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
77   - import { defaultTitle, defaultScriptContent } from './config.data';
  91 + import { defaultTitle } from './config.data';
  92 + import { nextTick } from 'process';
78 93
79 94 defineEmits(['register']);
80 95 const props = defineProps({
... ... @@ -88,11 +103,13 @@
88 103 params: '',
89 104 output: '',
90 105 dataType: 'HEX',
  106 + saveOriginalData: 'false',
91 107 });
92 108 const reportTypeOptions = reactive({
93 109 typeOptions: [],
  110 + originalOptions: [],
94 111 });
95   - const { typeOptions } = toRefs(reportTypeOptions);
  112 + const { typeOptions, originalOptions } = toRefs(reportTypeOptions);
96 113 const { createMessage } = useMessage();
97 114 const { clipboardRef, copiedRef } = useCopyToClipboard();
98 115 const aceEditor = ref();
... ... @@ -101,10 +118,17 @@
101 118 const res: any = await findDictItemByCode({
102 119 dictCode: 'report_data_type',
103 120 });
  121 + const resOriginal: any = await findDictItemByCode({
  122 + dictCode: 'original_data',
  123 + });
104 124 reportTypeOptions.typeOptions = res.map((m) => {
105 125 return { label: m.itemText, value: m.itemValue };
106 126 });
  127 + reportTypeOptions.originalOptions = resOriginal.map((m) => {
  128 + return { label: m.itemText, value: m.itemValue };
  129 + });
107 130 scriptForm.dataType = 'HEX';
  131 + scriptForm.saveOriginalData = 'false';
108 132 });
109 133 // 初始化编辑器
110 134 const initEditor = (jsScript?: string) => {
... ... @@ -121,7 +145,7 @@
121 145 enableBasicAutocompletion: true,
122 146 enableLiveAutocompletion: true,
123 147 });
124   - aceEditor.value.setValue(jsScript ?? defaultScriptContent);
  148 + aceEditor.value.setValue(jsScript);
125 149 beautify(aceEditor.value.session);
126 150 scriptForm.convertJs = aceEditor.value.getValue();
127 151 };
... ... @@ -154,18 +178,35 @@
154 178 }
155 179 }
156 180 if (!value) return;
  181 + if (scriptForm.params) {
  182 + const trimParams = scriptForm.params.replace(/\s*/g, '');
  183 + Reflect.set(value, 'params', trimParams);
  184 + }
157 185 return {
158 186 ...value,
159 187 ...{ convertJs: props.ifAdd ? scriptForm.convertJs : null },
160 188 ...{ script: !props.ifAdd ? scriptForm.script : null },
  189 + ...{ saveOriginalData: scriptForm.saveOriginalData === 'false' ? false : true },
161 190 };
162 191 };
  192 + const handleInputChange = (e) => {
  193 + const trimParams = e.target.value.replace(/\s*/g, '');
  194 + Reflect.set(scriptForm, 'params', trimParams);
  195 + };
163 196 const setFormData = (v) => {
164   - for (let i in scriptForm) {
165   - Reflect.set(scriptForm, i, v[i]);
  197 + if (v) {
  198 + for (let i in scriptForm) {
  199 + Reflect.set(scriptForm, i, v[i]);
  200 + }
  201 + nextTick(() => {
  202 + setTimeout(() => {
  203 + scriptForm.saveOriginalData = v.saveOriginalData === false ? 'false' : 'true';
  204 + scriptForm.dataType = v.dataType;
  205 + }, 500);
  206 + });
  207 + aceEditor.value.setValue(v.convertJs);
  208 + handleFormat();
166 209 }
167   - aceEditor.value.setValue(v.convertJs);
168   - handleFormat();
169 210 };
170 211 const setScriptContentData = (v) => {
171 212 aceEditor.value.setValue(v);
... ...
... ... @@ -60,8 +60,10 @@
60 60 converScriptRef.value?.setFormData(data.record);
61 61 }
62 62 if (unref(isTitle) == 'test') {
63   - // converScriptRef.value?.setScriptContentData('');
64   - converScriptRef.value?.setFormData(data.record);
  63 + if (data.record) {
  64 + const res = await getScriptManageDetail(data.record);
  65 + converScriptRef.value?.setFormData(res);
  66 + }
65 67 }
66 68 setModalProps({ title, showOkBtn: true, showCancelBtn: true, okText });
67 69 if (!unref(isUpdate)) {
... ... @@ -96,15 +98,15 @@
96 98 setTimeout(() => {
97 99 closeModal();
98 100 }, 10);
  101 + emits('success', {
  102 + res,
  103 + text: isText.value,
  104 + });
99 105 } else {
100 106 if (res) {
101 107 converScriptRef.value?.setScriptOutputData(res?.output || res?.error);
102 108 }
103 109 }
104   - emits('success', {
105   - res,
106   - text: isText.value,
107   - });
108 110 } finally {
109 111 setModalProps({ confirmLoading: false });
110 112 }
... ...
1 1 import { BasicColumn, FormSchema } from '/@/components/Table';
2 2 import moment from 'moment';
  3 +import { h } from 'vue';
3 4
4 5 // 表格配置
5 6 export const columns: BasicColumn[] = [
... ... @@ -57,7 +58,20 @@ export const searchFormSchema: FormSchema[] = [
57 58 },
58 59 ];
59 60
60   -export const defaultScriptContent = `
61   - out.msg= "hello"+params;
62   - `;
63   -export const defaultTitle = '格式:' + defaultScriptContent;
  61 +export const defaultTitle = h('div', { style: 'background:#404040' }, [
  62 + h('h3', { style: 'color:white' }, '示例:'),
  63 + h('h3', { style: 'color:white' }, '输入参数:0103040150008D3BBB'),
  64 + h('h3', { style: 'color:white' }, [
  65 + h(
  66 + 'h3',
  67 + { style: 'color:white' },
  68 + "脚本内容:out.humidity = (parseInt('0x'+params.substr(6, 4))*0.1).toFixed(2);"
  69 + ),
  70 + h(
  71 + 'h3',
  72 + { style: 'color:white' },
  73 + "out.temperature = (parseInt('0x'+params.substr(10, 4))*0.1).toFixed(2);"
  74 + ),
  75 + h('h3', { style: 'color:white' }, "输出参数:{'humidity':'33.60','temperature':'14.10'}"),
  76 + ]),
  77 +]);
... ...
... ... @@ -115,6 +115,14 @@
115 115
116 116 const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } =
117 117 useBatchDelete(deleteScriptManage, handleSuccess, setProps);
  118 + selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
  119 + // Demo:status为1的选择框禁用
  120 + if (record.status === 1) {
  121 + return { disabled: true };
  122 + } else {
  123 + return { disabled: false };
  124 + }
  125 + };
118 126
119 127 nextTick(() => {
120 128 setProps(selectionOptions);
... ... @@ -147,7 +155,7 @@
147 155 if (record) {
148 156 openModal(true, {
149 157 isUpdate: false,
150   - record,
  158 + record: record.id,
151 159 isTest: true,
152 160 isText: 'test',
153 161 isTitle: 'test',
... ...
... ... @@ -12,10 +12,10 @@
12 12 >
13 13 <div>
14 14 <a-row type="flex">
15   - <a-col :span="2" style="margin-left: 5rem">
  15 + <a-col :span="3" style="">
16 16 <a-input v-model:value="searchInfo.jobName" placeholder="请输入任务名称" />
17 17 </a-col>
18   - <a-col :span="4" style="margin-left: 5rem">
  18 + <a-col :span="4" style="margin-left: 2rem">
19 19 <a-select
20 20 allowClear
21 21 v-model:value="searchInfo.jobGroup"
... ... @@ -23,8 +23,7 @@
23 23 placeholder="请选择任务组名"
24 24 style="width: 200px"
25 25 :options="optionGroup"
26   - >
27   - </a-select>
  26 + />
28 27 </a-col>
29 28 <a-col :span="4">
30 29 <a-select
... ... @@ -33,8 +32,7 @@
33 32 placeholder="请选择执行状态"
34 33 style="width: 200px"
35 34 :options="optionStatus"
36   - >
37   - </a-select>
  35 + />
38 36 </a-col>
39 37 <a-col :span="4">
40 38 <a-range-picker
... ...
... ... @@ -93,7 +93,6 @@
93 93 import TenantAdminFormDrawer from './TenantAdminFormDrawer.vue';
94 94 import { MessageTypeEnum, SendResetPasswordEmailMsg } from '/@/api/tenant/tenantInfo';
95 95 import { useMessage } from '/@/hooks/web/useMessage';
96   - import { RoleEnum } from '/@/enums/roleEnum';
97 96 import { Authority } from '/@/components/Authority';
98 97
99 98 export default defineComponent({
... ... @@ -113,17 +112,15 @@
113 112
114 113 const tenantId = ref('');
115 114 async function handleCreateTenantAdmin() {
116   - const { items: getPageData } = await getTenantAdminPage({
  115 + const { items } = await getTenantAdminPage({
117 116 page: 1,
118 117 pageSize: 1000,
119 118 tenantId: tenantId.value,
120   - roleType: RoleEnum.TENANT_ADMIN,
121   - tenantCode: '',
122 119 });
123 120 openTenantAdminFormDrawer(true, {
124 121 isUpdate: false,
125 122 tenantId: tenantId.value,
126   - judgeExistUserName: getPageData,
  123 + judgeExistUserName: items,
127 124 });
128 125 }
129 126
... ... @@ -192,7 +189,6 @@
192 189 showIndexColumn: false,
193 190 searchInfo: {
194 191 tenantId,
195   - // roleType: RoleEnum.TENANT_ADMIN,
196 192 },
197 193 actionColumn: {
198 194 width: 100,
... ...