Commit 83e269fe43562a8302fe2530264add3226c19d05

Authored by xp.Huang
2 parents 17b96695 92067c0f

Merge branch 'ft' into 'main_dev'

fix: 修改Teambiton上的问题

See merge request yunteng/thingskit-front!558
@@ -408,7 +408,7 @@ @@ -408,7 +408,7 @@
408 :key="item.value" 408 :key="item.value"
409 > 409 >
410 <span> 410 <span>
411 - {{ item.label }} 411 + {{ item.alias + '/' + item.name }}
412 </span> 412 </span>
413 </Tag> 413 </Tag>
414 <Tag class="!px-2 !py-1 !bg-gray-50 !border-gray-100" v-if="getSurplusOptionsLength"> 414 <Tag class="!px-2 !py-1 !bg-gray-50 !border-gray-100" v-if="getSurplusOptionsLength">
@@ -162,7 +162,7 @@ export const step1Schemas: FormSchema[] = [ @@ -162,7 +162,7 @@ export const step1Schemas: FormSchema[] = [
162 transportType, 162 transportType,
163 }, 163 },
164 valueField: 'tbDeviceId', 164 valueField: 'tbDeviceId',
165 - labelField: 'name', 165 + labelField: 'alias',
166 }; 166 };
167 }, 167 },
168 }, 168 },
@@ -18,10 +18,12 @@ @@ -18,10 +18,12 @@
18 v-show="current === 0" 18 v-show="current === 0"
19 ref="DevConStRef" 19 ref="DevConStRef"
20 @next="handleStepNext(true, null)" 20 @next="handleStepNext(true, null)"
  21 + @emitDeviceType="handleGetDeviceType"
21 /> 22 />
22 <TransportConfigurationStep 23 <TransportConfigurationStep
23 v-show="current === 1" 24 v-show="current === 1"
24 ref="TransConStRef" 25 ref="TransConStRef"
  26 + :deviceTypeStr="deviceTypeStr"
25 @prev="handleStepPrev" 27 @prev="handleStepPrev"
26 /> 28 />
27 </div> 29 </div>
@@ -68,7 +70,7 @@ @@ -68,7 +70,7 @@
68 </div> 70 </div>
69 </template> 71 </template>
70 <script lang="ts" setup> 72 <script lang="ts" setup>
71 - import { ref, unref, reactive } from 'vue'; 73 + import { ref, unref, reactive, nextTick } from 'vue';
72 import { BasicModal, useModalInner } from '/@/components/Modal'; 74 import { BasicModal, useModalInner } from '/@/components/Modal';
73 import { deviceConfigAddOrEdit, deviceConfigGetDetail } from '/@/api/device/deviceConfigApi'; 75 import { deviceConfigAddOrEdit, deviceConfigGetDetail } from '/@/api/device/deviceConfigApi';
74 import { useMessage } from '/@/hooks/web/useMessage'; 76 import { useMessage } from '/@/hooks/web/useMessage';
@@ -134,6 +136,13 @@ @@ -134,6 +136,13 @@
134 setTransConfEditFormData(data); 136 setTransConfEditFormData(data);
135 } 137 }
136 }; 138 };
  139 + const deviceTypeStr = ref('');
  140 + const handleGetDeviceType = async (e) => {
  141 + console.log(e);
  142 + deviceTypeStr.value = e;
  143 + await nextTick();
  144 + TransConStRef.value?.updateDisabled(e);
  145 + };
137 const handleStepPrev = () => { 146 const handleStepPrev = () => {
138 current.value--; 147 current.value--;
139 }; 148 };
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 import { useMessage } from '/@/hooks/web/useMessage'; 37 import { useMessage } from '/@/hooks/web/useMessage';
38 import type { FileItem } from '/@/components/Upload/src/typing'; 38 import type { FileItem } from '/@/components/Upload/src/typing';
39 39
40 - const emits = defineEmits(['next']); 40 + const emits = defineEmits(['next', 'emitDeviceType']);
41 const loading = ref(false); 41 const loading = ref(false);
42 const { createMessage } = useMessage(); 42 const { createMessage } = useMessage();
43 const deviceConfigPic = ref(''); 43 const deviceConfigPic = ref('');
@@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
94 const values = await validate(); 94 const values = await validate();
95 if (!values) return; 95 if (!values) return;
96 emits('next', true, null); 96 emits('next', true, null);
  97 + emits('emitDeviceType', values?.deviceType);
97 } 98 }
98 //回显数据 99 //回显数据
99 const setFormData = (v) => { 100 const setFormData = (v) => {
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 <SnmpCpns ref="snmpRef" /> 32 <SnmpCpns ref="snmpRef" />
33 </div> 33 </div>
34 <div style="margin-top: 5vh; margin-left: -102px" v-else-if="isMqttType == 'TCP'"> 34 <div style="margin-top: 5vh; margin-left: -102px" v-else-if="isMqttType == 'TCP'">
35 - <TcpCpns ref="tcpRef" /> 35 + <TcpCpns :deviceTypeStr="deviceTypeStr" ref="tcpRef" />
36 </div> 36 </div>
37 <div v-if="ifShowBtn" class="btn-style"> 37 <div v-if="ifShowBtn" class="btn-style">
38 <div style="display: flex; width: 4vw; height: 4vh; margin-top: 1.65vh; margin-left: 44px"> 38 <div style="display: flex; width: 4vw; height: 4vh; margin-top: 1.65vh; margin-left: 44px">
@@ -58,6 +58,7 @@ @@ -58,6 +58,7 @@
58 const emits = defineEmits(['prev']); 58 const emits = defineEmits(['prev']);
59 const props = defineProps({ 59 const props = defineProps({
60 ifShowBtn: { type: Boolean, default: true }, 60 ifShowBtn: { type: Boolean, default: true },
  61 + deviceTypeStr: { type: String, default: '' },
61 }); 62 });
62 const mqttRef = ref<InstanceType<typeof MqttCpns>>(); 63 const mqttRef = ref<InstanceType<typeof MqttCpns>>();
63 const coapRef = ref<InstanceType<typeof CoapCpns>>(); 64 const coapRef = ref<InstanceType<typeof CoapCpns>>();
@@ -166,11 +167,16 @@ @@ -166,11 +167,16 @@
166 }, 167 },
167 }); 168 });
168 }; 169 };
  170 + const updateDisabled = async (e) => {
  171 + await nextTick();
  172 + tcpRef.value?.updateDisabled(e);
  173 + };
169 defineExpose({ 174 defineExpose({
170 getFormData, 175 getFormData,
171 resetFormData, 176 resetFormData,
172 setFormData, 177 setFormData,
173 editOrAddTransportTypeStatus, 178 editOrAddTransportTypeStatus,
  179 + updateDisabled,
174 }); 180 });
175 </script> 181 </script>
176 <style lang="less" scoped> 182 <style lang="less" scoped>
1 <template> 1 <template>
2 <div> 2 <div>
3 - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="register">  
4 - <template #authScriptId="{ model, field }"> 3 + <a-form
  4 + ref="formRef"
  5 + :model="scriptForm"
  6 + name="basic"
  7 + :label-col="{ span: 4 }"
  8 + :wrapper-col="{ span: 16 }"
  9 + style="margin-left: 2.4rem"
  10 + autocomplete="off"
  11 + >
  12 + <a-form-item
  13 + v-if="deviceTypeStr !== 'SENSOR'"
  14 + label="鉴权脚本"
  15 + name="'params'"
  16 + :rules="[{ required: true, message: '请选择鉴权脚本' }]"
  17 + >
5 <div style="display: flex; align-items: center"> 18 <div style="display: flex; align-items: center">
6 <div> 19 <div>
7 <Select 20 <Select
8 @change="handleAuthChange" 21 @change="handleAuthChange"
9 placeholder="请选择" 22 placeholder="请选择"
10 - v-model:value="model[field]" 23 + v-model:value="scriptForm.authScriptId"
11 style="width: 305px" 24 style="width: 305px"
12 show-search 25 show-search
13 :options="selectAuthOptions" 26 :options="selectAuthOptions"
@@ -28,14 +41,18 @@ @@ -28,14 +41,18 @@
28 <a-button @click="handleCreateOrEditAuth('test')" class="mt-4" type="primary" 41 <a-button @click="handleCreateOrEditAuth('test')" class="mt-4" type="primary"
29 >测试脚本</a-button 42 >测试脚本</a-button
30 > 43 >
31 - </template>  
32 - <template #upScriptId="{ model, field }"> 44 + </a-form-item>
  45 + <a-form-item
  46 + label="上行脚本"
  47 + name="'params'"
  48 + :rules="[{ required: true, message: '请选择上行脚本' }]"
  49 + >
33 <div style="display: flex; align-items: center"> 50 <div style="display: flex; align-items: center">
34 <div> 51 <div>
35 <Select 52 <Select
36 @change="handleUpChange" 53 @change="handleUpChange"
37 placeholder="请选择" 54 placeholder="请选择"
38 - v-model:value="model[field]" 55 + v-model:value="scriptForm.upScriptId"
39 style="width: 305px" 56 style="width: 305px"
40 show-search 57 show-search
41 :options="selectUpOptions" 58 :options="selectUpOptions"
@@ -56,16 +73,14 @@ @@ -56,16 +73,14 @@
56 <a-button @click="handleCreateOrEdit('test')" class="mt-4" type="primary" 73 <a-button @click="handleCreateOrEdit('test')" class="mt-4" type="primary"
57 >测试脚本</a-button 74 >测试脚本</a-button
58 > 75 >
59 - </template>  
60 - </BasicForm> 76 + </a-form-item>
  77 + </a-form>
61 <ConverScriptModal @register="registerModal" @success="handleSuccess" /> 78 <ConverScriptModal @register="registerModal" @success="handleSuccess" />
62 <ConverScriptModal @register="registerAuthModal" @success="handleAuthSuccess" /> 79 <ConverScriptModal @register="registerAuthModal" @success="handleAuthSuccess" />
63 </div> 80 </div>
64 </template> 81 </template>
65 <script lang="ts" setup name="index"> 82 <script lang="ts" setup name="index">
66 - import { ref, Ref, onMounted } from 'vue';  
67 - import { BasicForm, useForm } from '/@/components/Form';  
68 - import { tcpSchemas } from './config'; 83 + import { ref, Ref, onMounted, reactive } from 'vue';
69 import { SelectTypes } from 'ant-design-vue/es/select'; 84 import { SelectTypes } from 'ant-design-vue/es/select';
70 import { Select } from 'ant-design-vue'; 85 import { Select } from 'ant-design-vue';
71 import { useModal } from '/@/components/Modal'; 86 import { useModal } from '/@/components/Modal';
@@ -73,6 +88,14 @@ @@ -73,6 +88,14 @@
73 import ConverScriptModal from '/@/views/scriptmanage/converscript/ConverScriptModal.vue'; 88 import ConverScriptModal from '/@/views/scriptmanage/converscript/ConverScriptModal.vue';
74 import { useMessage } from '/@/hooks/web/useMessage'; 89 import { useMessage } from '/@/hooks/web/useMessage';
75 90
  91 + const props = defineProps({
  92 + deviceTypeStr: { type: String, default: '' },
  93 + });
  94 +
  95 + const scriptForm = reactive({
  96 + authScriptId: '',
  97 + upScriptId: '',
  98 + });
76 const selectUpOptions: Ref<SelectTypes['options']> = ref([]); 99 const selectUpOptions: Ref<SelectTypes['options']> = ref([]);
77 100
78 const selectAuthOptions: Ref<SelectTypes['options']> = ref([]); 101 const selectAuthOptions: Ref<SelectTypes['options']> = ref([]);
@@ -97,7 +120,7 @@ @@ -97,7 +120,7 @@
97 if (text !== 'test') { 120 if (text !== 'test') {
98 const rest = await getAllScriptType('TRANSPORT_TCP_UP'); 121 const rest = await getAllScriptType('TRANSPORT_TCP_UP');
99 selectUpOptions.value = rest; 122 selectUpOptions.value = rest;
100 - setFieldsValue({ upScriptId: res?.id }); 123 + scriptForm.upScriptId = res?.id;
101 upScriptIdStr.value = res?.id; 124 upScriptIdStr.value = res?.id;
102 } 125 }
103 }; 126 };
@@ -106,22 +129,20 @@ @@ -106,22 +129,20 @@
106 if (text !== 'test') { 129 if (text !== 'test') {
107 const rest = await getAllScriptType('TRANSPORT_TCP_AUTH'); 130 const rest = await getAllScriptType('TRANSPORT_TCP_AUTH');
108 selectAuthOptions.value = rest; 131 selectAuthOptions.value = rest;
109 - setFieldsValue({ authScriptId: res?.id }); 132 + scriptForm.authScriptId = res?.id;
110 authScriptIdStr.value = res?.id; 133 authScriptIdStr.value = res?.id;
111 } 134 }
112 }; 135 };
113 136
114 - const [register, { validate, resetFields, setFieldsValue }] = useForm({  
115 - labelWidth: 180,  
116 - schemas: tcpSchemas,  
117 - actionColOptions: {  
118 - span: 14,  
119 - },  
120 - });  
121 -  
122 - const handleUpChange = (v) => (upScriptIdStr.value = v); 137 + const handleUpChange = (v) => {
  138 + upScriptIdStr.value = v;
  139 + scriptForm.upScriptId = v;
  140 + };
123 141
124 - const handleAuthChange = (v) => (authScriptIdStr.value = v); 142 + const handleAuthChange = (v) => {
  143 + authScriptIdStr.value = v;
  144 + scriptForm.authScriptId = v;
  145 + };
125 146
126 const [registerModal, { openModal }] = useModal(); 147 const [registerModal, { openModal }] = useModal();
127 148
@@ -172,20 +193,35 @@ @@ -172,20 +193,35 @@
172 }; 193 };
173 194
174 const getFormData = async () => { 195 const getFormData = async () => {
175 - const values = await validate();  
176 - if (!values) return; 196 + if (props.deviceTypeStr === 'SENSOR') {
  197 + if (!scriptForm.upScriptId) {
  198 + createMessage.error('请先选择对应脚本');
  199 + throw new Error('请先选择对应脚本');
  200 + }
  201 + } else {
  202 + if (!scriptForm.authScriptId) {
  203 + createMessage.error('请先选择对应脚本');
  204 + throw new Error('请先选择对应脚本');
  205 + }
  206 + if (!scriptForm.upScriptId) {
  207 + createMessage.error('请先选择对应脚本');
  208 + throw new Error('请先选择对应脚本');
  209 + }
  210 + }
177 return { 211 return {
178 - ...values, 212 + ...scriptForm,
179 type: 'TCP', 213 type: 'TCP',
180 }; 214 };
181 }; 215 };
182 216
183 const resetFormData = () => { 217 const resetFormData = () => {
184 - resetFields(); 218 + // resetFields();
185 }; 219 };
186 220
187 const setFormData = (v) => { 221 const setFormData = (v) => {
188 - setFieldsValue(v); 222 + scriptForm.authScriptId = v?.authScriptId;
  223 + scriptForm.upScriptId = v?.upScriptId;
  224 + // setFieldsValue(v);
189 upScriptIdStr.value = v?.upScriptId; 225 upScriptIdStr.value = v?.upScriptId;
190 authScriptIdStr.value = v?.authScriptId; 226 authScriptIdStr.value = v?.authScriptId;
191 }; 227 };
@@ -123,10 +123,10 @@ const deviceTableColumn: BasicColumn[] = [ @@ -123,10 +123,10 @@ const deviceTableColumn: BasicColumn[] = [
123 { 123 {
124 title: '设备名称/设备SN', 124 title: '设备名称/设备SN',
125 dataIndex: 'name', 125 dataIndex: 'name',
126 - customRender: ({ text, record }) => { 126 + customRender: ({ record }) => {
127 return h('div', [ 127 return h('div', [
128 - h('div', text),  
129 - h('div', { class: 'text-blue-400 truncate', title: record.sn }, record.sn), 128 + h('div', `${record.alias}/${record.name}`),
  129 + // h('div', { class: 'text-blue-400 truncate', title: record.sn }, record.sn),
130 ]); 130 ]);
131 }, 131 },
132 }, 132 },