Parcourir la source

feat: 更新系统信息接口返回的加密值格式

yanglzh il y a 1 mois
Parent
commit
304537981b

+ 37 - 0
src/i18n/pages/property/en.ts

@@ -100,4 +100,41 @@ export default {
       deleteItemConfirm: 'Are you sure to delete the item with name: “{name}”?',
     },
   },
+  relationship: {
+    form: {
+      keyword: 'Name',
+      keywordPlaceholder: 'Please enter name',
+    },
+    actions: {
+      add: 'Add Asset Relationship',
+      unbind: 'Unbind',
+    },
+    columns: {
+      deviceName: 'Device Name',
+      deviceKey: 'Device KEY',
+      deviceNumber: 'Device Code',
+      deviceCategory: 'Device Type',
+      installTime: 'Install Time',
+      status: 'Status',
+    },
+    switch: {
+      enableShort: 'On',
+      disableShort: 'Off',
+    },
+    status: {
+      enable: 'Enable',
+      disable: 'Disable',
+    },
+    messages: {
+      tips: 'Tips',
+      warning: 'Warning',
+      confirm: 'Confirm',
+      cancel: 'Cancel',
+      statusChangeConfirm: 'Are you sure to {text}?',
+      statusChangeSuccess: '{text} successfully',
+      unbindConfirm: 'Are you sure to unbind?',
+      unbindSuccess: 'Unbound successfully',
+      batchUnbindConfirm: 'Are you sure to batch unbind these data?',
+    },
+  },
 };

+ 37 - 0
src/i18n/pages/property/zh-cn.ts

@@ -100,4 +100,41 @@ export default {
       deleteItemConfirm: '是否确认删除名称为:“{name}”的数据项?',
     },
   },
+  relationship: {
+    form: {
+      keyword: '名称',
+      keywordPlaceholder: '请输入名称',
+    },
+    actions: {
+      add: '新增资产关系',
+      unbind: '解绑',
+    },
+    columns: {
+      deviceName: '设备名称',
+      deviceKey: '设备KEY',
+      deviceNumber: '设备编码',
+      deviceCategory: '设备类型',
+      installTime: '安装时间',
+      status: '状态',
+    },
+    switch: {
+      enableShort: '启',
+      disableShort: '禁',
+    },
+    status: {
+      enable: '启用',
+      disable: '停用',
+    },
+    messages: {
+      tips: '提示',
+      warning: '警告',
+      confirm: '确定',
+      cancel: '取消',
+      statusChangeConfirm: '确认要【{text}】吗?',
+      statusChangeSuccess: '{text}成功',
+      unbindConfirm: '是否确认解绑',
+      unbindSuccess: '解绑成功',
+      batchUnbindConfirm: '是否确认要批量解绑这些数据吗?',
+    },
+  },
 };

+ 37 - 0
src/i18n/pages/property/zh-tw.ts

@@ -100,4 +100,41 @@ export default {
       deleteItemConfirm: '是否確認刪除名稱為:「{name}」的資料項?',
     },
   },
+  relationship: {
+    form: {
+      keyword: '名稱',
+      keywordPlaceholder: '請輸入名稱',
+    },
+    actions: {
+      add: '新增資產關係',
+      unbind: '解绑',
+    },
+    columns: {
+      deviceName: '設備名稱',
+      deviceKey: '設備KEY',
+      deviceNumber: '設備編碼',
+      deviceCategory: '設備類型',
+      installTime: '安裝時間',
+      status: '狀態',
+    },
+    switch: {
+      enableShort: '啟',
+      disableShort: '禁',
+    },
+    status: {
+      enable: '啟用',
+      disable: '停用',
+    },
+    messages: {
+      tips: '提示',
+      warning: '警告',
+      confirm: '確定',
+      cancel: '取消',
+      statusChangeConfirm: '確認要【{text}】嗎?',
+      statusChangeSuccess: '{text}成功',
+      unbindConfirm: '是否確認解绑',
+      unbindSuccess: '解绑成功',
+      batchUnbindConfirm: '是否確認要批量解绑這些資料嗎?',
+    },
+  },
 };

+ 8 - 8
src/utils/auth.ts

@@ -16,23 +16,23 @@ export function removeToken() {
 
 export function setSystemInfo(data: any) {
   localStorage.setItem('sysinfo', JSON.stringify(data));
-  // 使用的事base64加密的,解决之后的值  sysPasswordChangePeriod + "|" + isSecurityControlEnabled + "|" + isRsaEnabled+ "|" + _tag+ "|" + isSSOEnabled
+  // 使用的事base64加密的,解决之后的值  
   // 顺序是,密码变更周期,是否启动安全控制,是否启用rsa,中间你需要根据 | 切割一下
   // console.log(window.atob(data.target).split('|'))
-  const [sysPasswordChangePeriod, isSecurityControlEnabled, isRsaEnabled, _tag, isSSOEnabled, isEnterprise, btnEnabled, colEnabled, uploadFileWay] = window.atob(data.target).split('|')
+  const { passwordChangePeriod, isSecurityControlEnabled, isRsaEnabled, isSsoEnabled, isEnterprise, buttonSwitch, columnSwitch, uploadFileWay } = JSON.parse(window.atob(data.target))
   // isEnterprise 是否为企业版,0代表专业版  1代表企业版
   // 安全开关是否开启 按钮权限,列表权限,rsa权限在开启安全权限下才使用
-  console.log('安全开关是否开启', isSecurityControlEnabled)
-  console.log('密码是否加密', isRsaEnabled)
+  // console.log('安全开关是否开启', isSecurityControlEnabled)
+  // console.log('密码是否加密', isRsaEnabled)
   const enabled = Number(isSecurityControlEnabled)
   sessionStorage.setItem('isSecurityControlEnabled', enabled ? '1' : '');
   sessionStorage.setItem('isRsaEnabled', (enabled && Number(isRsaEnabled)) ? '1' : '');
-  sessionStorage.setItem('sysPasswordChangePeriod', sysPasswordChangePeriod);
-  sessionStorage.setItem('isSSOEnabled', Number(isSSOEnabled) ? '1' : '');
+  sessionStorage.setItem('sysPasswordChangePeriod', passwordChangePeriod);
+  sessionStorage.setItem('isSSOEnabled', Number(isSsoEnabled) ? '1' : '');
   sessionStorage.setItem('isEnterprise', Number(isEnterprise) ? '1' : '');
 
-  localStorage.setItem('btnNoAuth', (enabled && Number(btnEnabled)) ? '' : '1');
-  localStorage.setItem('colNoAuth', (enabled && Number(colEnabled)) ? '' : '1');
+  localStorage.setItem('btnNoAuth', (enabled && Number(buttonSwitch)) ? '' : '1');
+  localStorage.setItem('colNoAuth', (enabled && Number(columnSwitch)) ? '' : '1');
   localStorage.setItem('uploadFileWay', uploadFileWay || '0');
 }
 

+ 56 - 73
src/views/iot/property/relationship/index.vue

@@ -1,15 +1,15 @@
 <template>
 	<div class="page page-full border bg padding">
 		<el-form inline ref="queryRef" @keyup.enter="getList(1)">
-			<el-form-item label="名称" prop="keyWord">
-				<el-input v-model="params.keyWord" placeholder="请输入名称" clearable style="width: 240px" />
+			<el-form-item :label="$t('message.property.relationship.form.keyword') + ':'" prop="keyWord">
+				<el-input v-model="params.keyWord" :placeholder="$t('message.property.relationship.form.keywordPlaceholder')" clearable style="width: 240px" />
 			</el-form-item>
 			<el-form-item>
 				<el-button type="primary" class="ml10" @click="getList(1)">
 					<el-icon>
 						<ele-Search />
 					</el-icon>
-					查询
+					{{ $t('message.tableI18nAction.query') }}
 				</el-button>
 			</el-form-item>
 			<el-form-item>
@@ -17,20 +17,20 @@
 					<el-icon>
 						<ele-FolderAdd />
 					</el-icon>
-					新增资产关系
+					{{ $t('message.property.relationship.actions.add') }}
 				</el-button>
 				<el-button type="info" @click="batchUnbind()" v-auth="'batchUnbind'" :disabled="!ids.length">
 					<el-icon>
 						<ele-FolderAdd />
 					</el-icon>
-					解绑
+					{{ $t('message.property.relationship.actions.unbind') }}
 				</el-button>
 			</el-form-item>
 		</el-form>
 		<div class="page page-full-part flex-row gap-4">
 			<el-card style="width: 250px;" shadow="never">
 				<el-tree :data="treeData" :props="defaultProps" accordion default-expand-all @node-click="handleNodeClick" :node-key="'id'" highlight-current>
-					<template #default="{ node, data }">
+					<template #default="{ data }">
 						<div class="custom-tree-node">
 							<span class="tree-label">{{ data.name }}</span>
 						</div>
@@ -41,21 +41,20 @@
 				<div class="page page-full">
 					<el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange" row-key="id" v-loading="loading">
 						<el-table-column type="selection" width="55" align="center" />
-						<el-table-column prop="assetInfo.deviceName" v-col="'deviceName'" label="设备名称" min-width="100" show-overflow-tooltip></el-table-column>
-						<el-table-column prop="assetInfo.deviceKey" v-col="'deviceKey'" label="设备KEY" min-width="90" show-overflow-tooltip></el-table-column>
-						<el-table-column prop="assetInfo.deviceNumber" v-col="'deviceNumber'" label="设备编码" show-overflow-tooltip></el-table-column>
-						<el-table-column prop="assetInfo.deviceCategory" v-col="'deviceCategory'" label="设备类型" show-overflow-tooltip></el-table-column>
-						<el-table-column prop="assetInfo.installTime" v-col="'installTime'" label="安装时间" width="160" align="center"></el-table-column>
-						<el-table-column prop="status" label="状态" width="70" v-col="'status'" align="center">
+						<el-table-column prop="assetInfo.deviceName" v-col="'deviceName'" :label="$t('message.property.relationship.columns.deviceName')" min-width="100" show-overflow-tooltip></el-table-column>
+						<el-table-column prop="assetInfo.deviceKey" v-col="'deviceKey'" :label="$t('message.property.relationship.columns.deviceKey')" min-width="90" show-overflow-tooltip></el-table-column>
+						<el-table-column prop="assetInfo.deviceNumber" v-col="'deviceNumber'" :label="$t('message.property.relationship.columns.deviceNumber')" show-overflow-tooltip></el-table-column>
+						<el-table-column prop="assetInfo.deviceCategory" v-col="'deviceCategory'" :label="$t('message.property.relationship.columns.deviceCategory')" show-overflow-tooltip></el-table-column>
+						<el-table-column prop="assetInfo.installTime" v-col="'installTime'" :label="$t('message.property.relationship.columns.installTime')" width="160" align="center"></el-table-column>
+						<el-table-column prop="status" :label="$t('message.property.relationship.columns.status')" width="70" v-col="'status'" align="center">
 							<template #default="scope">
-								<el-switch v-model="scope.row.status" v-auth="'change-status'" inline-prompt :active-value="1" :inactive-value="0" active-text="启" inactive-text="禁" @change="handleStatusChange(scope.row)">
+								<el-switch v-model="scope.row.status" v-auth="'change-status'" inline-prompt :active-value="1" :inactive-value="0" :active-text="$t('message.property.relationship.switch.enableShort')" :inactive-text="$t('message.property.relationship.switch.disableShort')" @change="handleStatusChange(scope.row)">
 								</el-switch>
 							</template>
 						</el-table-column>
-						<el-table-column label="操作" width="170" v-col="'handle'" align="center">
+						<el-table-column :label="$t('message.tableI18nColumn.operation')" width="170" v-col="'handle'" align="center">
 							<template #default="scope">
-								<el-button size="small" text type="warning" v-auth="'unbind'" @click="unbind(scope.row)">解绑</el-button>
-								<!-- <el-button size="small" text type="primary" v-auth="'set'" @click="set(scope.row)">设置筛选条件</el-button> -->
+								<el-button size="small" text type="warning" v-auth="'unbind'" @click="unbind(scope.row)">{{ $t('message.property.relationship.actions.unbind') }}</el-button>
 							</template>
 						</el-table-column>
 					</el-table>
@@ -69,15 +68,17 @@
 </template>
 
 <script lang="ts" setup>
+import { useI18n } from 'vue-i18n'
+import { ref } from 'vue'
 import api from '/@/api/system'
 import device from '/@/api/device'
 import { useSearch } from '/@/hooks/useCommon'
-
-import { ElMessageBox, ElMessage } from 'element-plus'
 import EditForm from './edit.vue'
 import FilterVue from './filter.vue'
+import { ElMessageBox, ElMessage } from 'element-plus'
+
+const { t } = useI18n()
 
-import { ref, onMounted } from 'vue'
 const defaultProps = {
 	children: 'children',
 	label: 'name',
@@ -95,6 +96,7 @@ api.role.getList({ status: 1 }).then((res: any) => {
 
 const { params, tableData, getList, loading } = useSearch<any[]>(device.assetRelationship.getList, 'Data', { keyWord: '', roleId: -1 })
 getList()
+
 const handleSelectionChange = (selection: any[]) => {
 	ids.value = selection.map((item) => item.id);
 };
@@ -103,83 +105,64 @@ const addOrEdit = () => {
 	editFormRef.value.open(params.roleId)
 }
 
-const set = (row: any) => {
-	filterRef.value.open(row)
-}
-
 const handleNodeClick = (data: any) => {
 	params.roleId = data.id
 	getList()
 }
 
-// const batchdel = () => {
-// 	ElMessageBox.confirm('是否确认要批量删除这些数据吗?', '提示', {
-// 		confirmButtonText: '确认',
-// 		cancelButtonText: '取消',
-// 		type: 'warning',
-// 	}).then(async () => {
-// 		await device.assetRelationship.delete(ids.value)
-// 		ElMessage.success('删除成功')
-// 		getList()
-// 	})
-// }
-
-// const del = (row: any) => {
-// 	ElMessageBox.confirm('是否确认删除该设备档案', '提示', {
-// 		confirmButtonText: '确认',
-// 		cancelButtonText: '取消',
-// 		type: 'warning',
-// 	}).then(async () => {
-// 		await device.assetRelationship.delete([row.id])
-// 		ElMessage.success('删除成功')
-// 		getList()
-// 	})
-// }
-
-// 状态修改
 const handleStatusChange = (row: any) => {
-	let text = row.status === 1 ? '启用' : '停用';
-	ElMessageBox.confirm('确认要【' + text + '】吗?', '警告', {
-		confirmButtonText: '确定',
-		cancelButtonText: '取消',
-		type: 'warning',
-	})
+	const text = row.status === 1 ? t('message.property.relationship.status.enable') : t('message.property.relationship.status.disable')
+	ElMessageBox.confirm(
+		t('message.property.relationship.messages.statusChangeConfirm', { text }),
+		t('message.property.relationship.messages.warning'),
+		{
+			confirmButtonText: t('message.property.relationship.messages.confirm'),
+			cancelButtonText: t('message.property.relationship.messages.cancel'),
+			type: 'warning',
+		}
+	)
 		.then(function () {
-			return device.assetRelationship.editStatus(row.id, row.status);
+			return device.assetRelationship.editStatus(row.id, row.status)
 		})
 		.then(() => {
-			ElMessage.success(text + '成功');
+			ElMessage.success(t('message.property.relationship.messages.statusChangeSuccess', { text }))
 		})
 		.catch(function () {
-			row.status = row.status === 0 ? 1 : 0;
-		});
-};
+			row.status = row.status === 0 ? 1 : 0
+		})
+}
 
 const unbind = (row: any) => {
-	ElMessageBox.confirm('是否确认解绑', '提示', {
-		confirmButtonText: '确认',
-		cancelButtonText: '取消',
-		type: 'warning',
-	}).then(async () => {
+	ElMessageBox.confirm(
+		t('message.property.relationship.messages.unbindConfirm'),
+		t('message.property.relationship.messages.tips'),
+		{
+			confirmButtonText: t('message.property.relationship.messages.confirm'),
+			cancelButtonText: t('message.property.relationship.messages.cancel'),
+			type: 'warning',
+		}
+	).then(async () => {
 		await device.assetRelationship.unBind([row.id])
-		ElMessage.success('解绑成功')
+		ElMessage.success(t('message.property.relationship.messages.unbindSuccess'))
 		getList()
 	})
 }
 
 const batchUnbind = () => {
-	ElMessageBox.confirm('是否确认要批量解绑这些数据吗?', '提示', {
-		confirmButtonText: '确认',
-		cancelButtonText: '取消',
-		type: 'warning',
-	}).then(async () => {
+	ElMessageBox.confirm(
+		t('message.property.relationship.messages.batchUnbindConfirm'),
+		t('message.property.relationship.messages.tips'),
+		{
+			confirmButtonText: t('message.property.relationship.messages.confirm'),
+			cancelButtonText: t('message.property.relationship.messages.cancel'),
+			type: 'warning',
+		}
+	).then(async () => {
 		await device.assetRelationship.unBind(ids.value)
-		ElMessage.success('解绑成功')
+		ElMessage.success(t('message.property.relationship.messages.unbindSuccess'))
 		getList()
 	})
 }
-
-// getCateList()
 </script>
 <style scoped lang="scss">
 .custom-tree-node {