Browse Source

设备接入的账号密码如果是管理员就显示,非管理员显示请联系管理员

yanglzh 2 years ago
parent
commit
4db24cba57

+ 7 - 10
src/views/iot/device/instance/component/edit.vue

@@ -39,7 +39,7 @@
               <el-input v-model="ruleForm.authUser" placeholder="请输入用户名" />
             </el-form-item>
             <el-form-item label="密码" prop="authPasswd">
-              <el-input v-model="ruleForm.authPasswd" placeholder="请输入密码" />
+              <el-input type="password" v-model="ruleForm.authPasswd" placeholder="请输入密码" />
             </el-form-item>
           </template>
           <template v-else>
@@ -243,20 +243,17 @@ export default defineComponent({
         });
       });
     }
-    // 通过设备所属产品的传输协议来确定认证方式
-    const transportProtocolChange = (type: string) => {
-      if (type === 'mqtt_server') {
-        state.ruleForm.authType = 1
-      } else {
-        state.ruleForm.authType = 3
-      }
-    }
     // 所属产品变化的时候,更新产品详情
     const productIdChange = (productId: number) => {
       api.product.detail(productId).then((res: any) => {
         // console.log(res.data)
+        const { authType, authUser, authPasswd, accessToken, certificateId } = res.data
         state.product = res.data
-        transportProtocolChange(res.data.transportProtocol)
+        state.ruleForm.authType = authType
+        state.ruleForm.authUser = authUser
+        state.ruleForm.authPasswd = authPasswd
+        state.ruleForm.accessToken = accessToken
+        state.ruleForm.certificateId = certificateId
       })
     }
 

+ 3 - 2
src/views/iot/device/product/component/deviceIn.vue

@@ -9,7 +9,8 @@
 	<div class="text">{{ data.link }}</div>
 	<div class="title">认证配置</div>
 
-	<template v-if="data.authType === 1 || data.authType === 2">
+	<template v-if="!isAdmin">请联系管理员</template>
+	<template v-else-if="data.authType === 1 || data.authType === 2">
 		<el-form-item label="认证方式" prop="authType" label-width="80px" style="margin-bottom: 0;">
 			{{ data.authType === 1 ? 'Basic' : 'AccessToken' }}
 		</el-form-item>
@@ -41,7 +42,7 @@ import { useRoute } from 'vue-router';
 
 const route = useRoute();
 
-const certList = ref([])
+const isAdmin = localStorage.userId == '1'
 const data = reactive({
 	"name": "",
 	"protocol": "",

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

@@ -58,7 +58,7 @@
 							<el-input v-model="ruleForm.authUser" placeholder="请输入用户名" />
 						</el-form-item>
 						<el-form-item label="密码" prop="authPasswd">
-							<el-input v-model="ruleForm.authPasswd" placeholder="请输入密码" />
+							<el-input type="password" v-model="ruleForm.authPasswd" placeholder="请输入密码" />
 						</el-form-item>
 					</template>
 					<template v-else>