Commit 09796c32fbeec47d1cb769268b14b1d0a10c8846

Authored by xp.Huang
2 parents 2ef6cb19 b285d2a2

Merge branch 'ft' into 'main_dev'

fix: DEFECT-1241 设备公开和私有使用效果(看图修改)

See merge request yunteng/thingskit-front!555
@@ -18,13 +18,13 @@ export const columns: BasicColumn[] = [ @@ -18,13 +18,13 @@ export const columns: BasicColumn[] = [
18 { 18 {
19 title: '设备图片', 19 title: '设备图片',
20 dataIndex: 'deviceInfo.avatar', 20 dataIndex: 'deviceInfo.avatar',
21 - width: 80, 21 + width: 70,
22 slots: { customRender: 'img' }, 22 slots: { customRender: 'img' },
23 }, 23 },
24 { 24 {
25 dataIndex: 'name', 25 dataIndex: 'name',
26 title: '设备名称/设备SN', 26 title: '设备名称/设备SN',
27 - width: 200, 27 + width: 210,
28 slots: { customRender: 'name', title: 'deviceTitle' }, 28 slots: { customRender: 'name', title: 'deviceTitle' },
29 customRender: ({ record }) => { 29 customRender: ({ record }) => {
30 return h( 30 return h(
@@ -32,10 +32,10 @@ export const columns: BasicColumn[] = [ @@ -32,10 +32,10 @@ export const columns: BasicColumn[] = [
32 { 32 {
33 style: { cursor: 'pointer', color: '#377dff' }, 33 style: { cursor: 'pointer', color: '#377dff' },
34 onClick: () => { 34 onClick: () => {
35 - handeleCopy(record.name || record.alias); 35 + handeleCopy(`${record.alias}/${record.name}`);
36 }, 36 },
37 }, 37 },
38 - record.name || record.alias 38 + `${record.alias}/${record.name}`
39 ); 39 );
40 }, 40 },
41 }, 41 },
@@ -124,7 +124,7 @@ @@ -124,7 +124,7 @@
124 ? { 124 ? {
125 label: '取消分配', 125 label: '取消分配',
126 icon: 'mdi:account-arrow-left', 126 icon: 'mdi:account-arrow-left',
127 - ifShow: authBtn(role), 127 + ifShow: authBtn(role) && !record?.customerAdditionalInfo?.isPublic,
128 popConfirm: { 128 popConfirm: {
129 title: '是否取消分配客户', 129 title: '是否取消分配客户',
130 confirm: handleCancelDispatchCustomer.bind(null, record), 130 confirm: handleCancelDispatchCustomer.bind(null, record),
@@ -58,6 +58,14 @@ @@ -58,6 +58,14 @@
58 <a-form-item label="脚本内容" :name="ifAdd ? 'convertJs' : 'script'"> 58 <a-form-item label="脚本内容" :name="ifAdd ? 'convertJs' : 'script'">
59 <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }"> 59 <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }">
60 <template #extra> 60 <template #extra>
  61 + <Button
  62 + v-show="ifAdd && !view"
  63 + @click="onHandleTestExample(scriptForm.scriptType)"
  64 + style="position: relative; top: -4rem; right: -6.6rem"
  65 + type="primary"
  66 + >
  67 + 测试用例</Button
  68 + >
61 <a-button @click="handleFormat" size="small">格式化</a-button> 69 <a-button @click="handleFormat" size="small">格式化</a-button>
62 <Tooltip 70 <Tooltip
63 v-if="scriptForm.scriptType !== 'TRANSPORT_TCP_UP'" 71 v-if="scriptForm.scriptType !== 'TRANSPORT_TCP_UP'"
@@ -115,7 +123,13 @@ @@ -115,7 +123,13 @@
115 import { useMessage } from '/@/hooks/web/useMessage'; 123 import { useMessage } from '/@/hooks/web/useMessage';
116 import { findDictItemByCode } from '/@/api/system/dict'; 124 import { findDictItemByCode } from '/@/api/system/dict';
117 import { QuestionCircleOutlined } from '@ant-design/icons-vue'; 125 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
118 - import { defaultAuthTitle, defaultUpTitle, defaultScriptTypeContent } from './config.data'; 126 + import {
  127 + defaultAuthTitle,
  128 + defaultUpTitle,
  129 + defaultScriptTypeContent,
  130 + defaultTestUpExample,
  131 + defaultTestAuthExample,
  132 + } from './config.data';
119 import { useAppStore } from '/@/store/modules/app'; 133 import { useAppStore } from '/@/store/modules/app';
120 import TestScriptModal from './TestScriptModal.vue'; 134 import TestScriptModal from './TestScriptModal.vue';
121 import { useModal } from '/@/components/Modal'; 135 import { useModal } from '/@/components/Modal';
@@ -207,6 +221,15 @@ @@ -207,6 +221,15 @@
207 aceEditor.value.setValue(defaultScriptTypeContent[type]); 221 aceEditor.value.setValue(defaultScriptTypeContent[type]);
208 }; 222 };
209 223
  224 + const onHandleTestExample = (example) => {
  225 + if (example === 'TRANSPORT_TCP_UP') {
  226 + aceEditor.value?.setValue(defaultTestUpExample);
  227 + } else {
  228 + aceEditor.value?.setValue(defaultTestAuthExample);
  229 + }
  230 + handleFormat();
  231 + };
  232 +
210 const handleCopy = () => { 233 const handleCopy = () => {
211 const valueRef = aceEditor.value.getValue(); 234 const valueRef = aceEditor.value.getValue();
212 const value = unref(valueRef); 235 const value = unref(valueRef);
@@ -303,10 +326,12 @@ @@ -303,10 +326,12 @@
303 const [registerModal, { openModal }] = useModal(); 326 const [registerModal, { openModal }] = useModal();
304 327
305 const onHandleClick = (o) => { 328 const onHandleClick = (o) => {
  329 + const getTestContent = aceEditor.value?.getValue();
306 openModal(true, { 330 openModal(true, {
307 isAuth: '', 331 isAuth: '',
308 - isUpdate: false, 332 + isUpdate: o,
309 record: o === 'add' ? null : getRecordId.value, 333 record: o === 'add' ? null : getRecordId.value,
  334 + testContent: getTestContent,
310 isTest: true, 335 isTest: true,
311 isText: 'test', 336 isText: 'test',
312 isTitle: 'test', 337 isTitle: 'test',
@@ -70,8 +70,9 @@ @@ -70,8 +70,9 @@
70 if (unref(isTitle) == 'test') { 70 if (unref(isTitle) == 'test') {
71 if (data.record) { 71 if (data.record) {
72 const res = await getScriptManageDetail(data.record); 72 const res = await getScriptManageDetail(data.record);
73 - converScriptRef.value?.setFormData(res); 73 + converScriptRef.value?.setFormData({ ...res, convertJs: data?.testContent });
74 } else { 74 } else {
  75 + converScriptRef.value?.setFormData({ convertJs: data?.testContent });
75 converScriptRef.value?.setDefaultRadio('true', 'TRANSPORT_TCP_UP'); 76 converScriptRef.value?.setDefaultRadio('true', 'TRANSPORT_TCP_UP');
76 } 77 }
77 } 78 }
@@ -90,3 +90,44 @@ export const defaultScriptTypeContent = { @@ -90,3 +90,44 @@ export const defaultScriptTypeContent = {
90 'var attrData = {};var teleData = {};teleData.source= params;out.datas = teleData;out.telemetry =true;out.ackMsg = params;out.deviceName = "sensor";out.ts = Date.now();', 90 'var attrData = {};var teleData = {};teleData.source= params;out.datas = teleData;out.telemetry =true;out.ackMsg = params;out.deviceName = "sensor";out.ts = Date.now();',
91 TRANSPORT_TCP_AUTH: 'out.password = params;out.success = params;', 91 TRANSPORT_TCP_AUTH: 'out.password = params;out.success = params;',
92 }; 92 };
  93 +
  94 +export const defaultTestUpExample = `
  95 +var teleData = {};
  96 +/**
  97 + * 物模型数据(可选):原始数据
  98 + */
  99 +teleData.source= params;
  100 +/**
  101 + * 直连设备:sensor是产品物模型中所定义属性的标识符
  102 + * 网关设备:sensor是网关子设备的设备名称/SN码
  103 + */
  104 +teleData.sensor= params+123;
  105 +out.datas = teleData;
  106 +/**
  107 + * 必填:true表示设备上报的遥测数据,false表示命令下发的响应数据
  108 + */
  109 +out.telemetry = true;
  110 +/**
  111 + * 必填:设备或命令下发的唯一标识,设备的唯一标识必须与设备信息的设备名称/SN码一致
  112 + */
  113 +out.identifier = "01";
  114 +/**
  115 + * 可选:服务端收到设备数据后,响应的消息内容
  116 + */
  117 +out.ackMsg = params;
  118 +/**
  119 + * 可选:默认使用服务器时间,可以使用数据内的时间
  120 + */
  121 +out.ts = Date.now();
  122 +`;
  123 +
  124 +export const defaultTestAuthExample = `
  125 +/**
  126 + * 必填:设备的访问令牌
  127 + */
  128 +out.password = params;
  129 +/**
  130 + * 选填:设备鉴权成功后响应给设备的信息
  131 + */
  132 +out.success = params;
  133 +`;