Browse Source

优化新增产品的消息协议备选项,从维更的插件的接口获取,并在前端增加默认的mqtt的选项

yanglzh 2 năm trước cách đây
mục cha
commit
4d7815a9d1

+ 2 - 0
src/api/device/index.ts

@@ -17,6 +17,8 @@ export default {
     deploy: (data: object) => post('/product/deploy', data),
     undeploy: (data: object) => post('/product/undeploy', data),
     event: (data: object) => get('/product/tsl/event/all', data),
+    // 获取插件通信方式类型
+    getTypesAll: (data: object) => get('/system/plugins/getTypesAll', data),
   },
   category:{
     getList: (params: object) => get('/product/category/list', params),

+ 16 - 8
src/views/iot/device/product/component/editPro.vue

@@ -38,8 +38,10 @@
         </el-form-item> -->
 
 				<el-form-item label="消息协议" prop="messageProtocol">
-					<el-select v-model="ruleForm.messageProtocol" placeholder="请选择消息协议">
-						<el-option v-for="dict in network_protocols" :key="dict.value" :label="dict.label" :value="dict.value"> </el-option>
+					<el-select v-model="ruleForm.messageProtocol" placeholder="请选择消息协议" @change="changeMessageProtocol">
+						<el-option v-for="dict in messageData" :key="dict.types" :label="dict.title" :value="dict.types"> </el-option>
+						<!-- 增加系统默认的mqtt选项 -->
+						<el-option label="mqtt" value="mqtt"> </el-option>
 					</el-select>
 				</el-form-item>
 
@@ -102,13 +104,14 @@ export default defineComponent({
 		const baseURL: string | undefined | boolean = getOrigin(import.meta.env.VITE_API_URL)
 
 		const { proxy } = getCurrentInstance() as any
-		const { network_server_type, network_protocols } = proxy.useDict('network_server_type', 'network_protocols')
+		const { network_server_type } = proxy.useDict('network_server_type')
 
 		const state = reactive<DicState>({
 			isShowDialog: false,
 			cateData: [], // 分类数据
 			deptData: [], //
 			messageData: [], //
+			network_protocols: [], // 消息协议
 			tranData: [], //
 			imageUrl: '', //
 			singleImg: baseURL + '/product/icon/upload',
@@ -136,7 +139,7 @@ export default defineComponent({
 		})
 
 		const handleAvatarSuccess: UploadProps['onSuccess'] = (response) => {
-			console.log(response)
+			// console.log(response)
 
 			state.imageUrl = response
 			state.ruleForm.icon = response
@@ -151,9 +154,10 @@ export default defineComponent({
 			api.dept.getList({ status: -1 }).then((res: any) => {
 				state.deptData = res || []
 			})
-			// api.product.message_protocol_list({ status: -1 }).then((res: any) => {
-			//   state.messageData = res.data || [];
-			// });
+			api.product.getTypesAll({ handleType: 'protocol' }).then((res: any) => {
+				console.log(res)
+			  state.messageData = res || [];
+			});
 			// api.product.trunsport_protocol_list({ status: -1 }).then((res: any) => {
 			//   state.tranData = res.data || [];
 			// });
@@ -186,6 +190,10 @@ export default defineComponent({
 		const onCancel = () => {
 			closeDialog()
 		}
+		// 消息协议切换的时候,获取新的传输协议列表
+		const changeMessageProtocol = (handleType) => {
+			console.log(handleType)
+		}
 		// 新增
 		const onSubmit = () => {
 			const formWrap = unref(formRef) as any
@@ -218,8 +226,8 @@ export default defineComponent({
 			closeDialog,
 			onCancel,
 			onSubmit,
+			changeMessageProtocol,
 			network_server_type,
-			network_protocols,
 			formRef,
 			...toRefs(state),
 		}