瀏覽代碼

多语言配置

asd26269546 1 年之前
父節點
當前提交
1f97db5d0f
共有 3 個文件被更改,包括 416 次插入2 次删除
  1. 8 0
      src/router/index.js
  2. 2 2
      src/views/login.vue
  3. 406 0
      src/views/system/langConfig/index.vue

+ 8 - 0
src/router/index.js

@@ -67,9 +67,17 @@ export const constantRoutes = [
         component: () => import('@/views/index'),
         name: 'Index',
         meta: { title: '首页', icon: 'dashboard', affix: true }
+      },
+      {
+        path: '/platform_manage/process/processApproval',
+        component: () => import('@/views/process/processApproval/index.vue'),
+        name: 'processApproval',
+        meta: { title: '流程审批', icon: 'dashboard', affix: true }
       }
     ]
   },
+
+  
   {
     path: '/user',
     component: Layout,

+ 2 - 2
src/views/login.vue

@@ -9,7 +9,7 @@
 					<div class="swiper-text">
 						<el-carousel height="100px" direction="vertical" indicator-position='none' :autoplay="true">
 							<el-carousel-item>
-								<h3>为中小企业提供数字管理</h3>
+								<h3>为中小企业提供数字管理</h3>
 								<p>一站式定制解决方案</p>
 							</el-carousel-item>
 							<el-carousel-item>
@@ -18,7 +18,7 @@
 							</el-carousel-item>
 							<el-carousel-item>
 								<h3>数据驱动,助力决策</h3>
-								<p>loT SaaS定制全套解决方案</p>
+								<p>loT-SaaS定制全套解决方案</p>
 							</el-carousel-item>
 						</el-carousel>
 						

+ 406 - 0
src/views/system/langConfig/index.vue

@@ -0,0 +1,406 @@
+<template>
+	<div class="langConfig">
+		<div class="content">
+			<byTable
+				:source="sourceList.data"
+				:pagination="sourceList.pagination"
+				:config="config"
+				:loading="loading"
+				highlight-current-row
+				:selectConfig="selectConfig"
+				searchKey="userName"
+				:table-events="{
+					//element talbe事件都能传
+					select: select,
+				}"
+				:action-list="[
+					{
+						text: '添加用户',
+						action: () => openModal('add'),
+						disabled: !sourceList.pagination.tenantId,
+					},
+				]"
+				@get-list="getList"
+			>
+				<template #slotName="{ item }">
+					{{ item.createTime }}
+				</template>
+			</byTable>
+		</div>
+		<el-dialog
+			:title="modalType == 'add' ? '添加用户' : '编辑用户'"
+			v-if="dialogVisible"
+			v-model="dialogVisible"
+			width="500"
+			v-loading="loading"
+		>
+			<byForm
+				:formConfig="formConfig"
+				:formOption="formOption"
+				v-model="formData.data"
+				:rules="rules"
+				ref="byform"
+			>
+				<template #account>
+					<el-input
+						style="width: 150px; margin-right: 10px"
+						v-model="formData.data.userName"
+						placeholder="请输入用户名"
+					></el-input>
+					<el-input
+						style="width: 150px; margin-right: 10px"
+						v-model="formData.data.password"
+						placeholder="密码"
+					></el-input>
+					<span
+						style="color: #409eff; cursor: pointer"
+						@click="newPassword"
+						>随机生成</span
+					>
+				</template>
+			</byForm>
+			<template #footer>
+				<el-button @click="dialogVisible = false" size="large"
+					>取 消</el-button
+				>
+				<el-button
+					type="primary"
+					@click="submitForm('byform')"
+					size="large"
+					:loading="submitLoading"
+					>确 定</el-button
+				>
+			</template>
+		</el-dialog>
+	</div>
+</template>
+
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from 'element-plus'
+import byTable from '@/components/byTable/index'
+import byForm from '@/components/byForm/index'
+import treeList from '@/components/treeList/index'
+import { computed, defineComponent, ref } from 'vue'
+const loading = ref(false)
+const submitLoading = ref(false)
+const sourceList = ref({
+	data: [],
+	pagination: {
+		total: 3,
+		pageNum: 1,
+		pageSize: 10,
+	},
+})
+let dialogVisible = ref(false)
+let modalType = ref('add')
+const validatePass = (rule, value, callback) => {
+	if (!formData.data.password && modalType.value == 'add') {
+		callback(new Error('请输入账号和密码'))
+	} else {
+		callback()
+	}
+}
+let rules = ref({
+	roleKey: [{ required: true, message: '请选择部门', trigger: 'blur' }],
+	nickName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
+	userName: [
+		{
+			validator: validatePass,
+			required: true,
+			message: '请输入账号和密码',
+			trigger: 'blur',
+		},
+	],
+	password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
+})
+
+const userId = ref('')
+const { proxy } = getCurrentInstance()
+const password = ref('')
+const selectConfig = computed(() => {
+	return []
+})
+const config = computed(() => {
+	return [
+		{
+			attrs: {
+				label: '中文名称',
+				prop: 'deptName',
+			},
+		},
+
+		{
+			attrs: {
+				label: '英文名称',
+				prop: 'userName',
+			},
+		},
+		{
+			attrs: {
+				label: '对象索引',
+				prop: 'nickName',
+				align: 'left',
+			},
+		},
+		{
+			attrs: {
+				label: '操作',
+				width: '200',
+				align: 'right',
+			},
+			// 渲染 el-button,一般用在最后一列。
+			renderHTML(row) {
+				return [
+					{
+						attrs: {
+							label: '修改',
+							type: 'primary',
+							text: true,
+						},
+						el: 'button',
+						click() {
+							if (!sourceList.value.pagination.tenantId) {
+								ElMessage({
+									message: '请选择租户',
+									type: 'warning',
+								})
+								return
+							}
+							getDtl(row)
+						},
+					},
+				]
+			},
+		},
+	]
+})
+
+let formData = reactive({
+	data: {},
+})
+const formOption = reactive({
+	inline: true,
+	labelWidth: 100,
+	itemWidth: 100,
+	rules: [],
+})
+const byform = ref(null)
+const treeListData = ref([])
+const formConfig = computed(() => {
+	return [
+		{
+			type: 'treeSelect',
+			prop: 'deptId',
+			label: '部门名称',
+			data: [],
+		},
+		{
+			type: 'input',
+			prop: 'nickName',
+			label: '姓名',
+			required: true,
+			itemWidth: 50,
+			//disabled:true,
+			itemType: 'text',
+		},
+		{
+			type: 'slot',
+			prop: 'userName',
+			slotName: 'account',
+			label: '账户信息',
+		},
+		{
+			type: 'radio',
+			prop: 'userType',
+			label: '系统用户',
+			required: true,
+			disabled: true,
+			border: true,
+			data: [
+				{
+					label: '是',
+					id: 1,
+				},
+				{
+					label: '否',
+					id: 0,
+				},
+			],
+		},
+		{
+			type: 'select',
+			label: '角色',
+			prop: 'roleIds',
+			multiple: true,
+			data: [],
+			isLoad: {
+				url: `/tenantRole/list?pageNum=1&pageSize=10000&tenantId=${sourceList.value.pagination.tenantId}`,
+				labelKey: 'roleName',
+				labelVal: 'roleId',
+				method: 'get',
+				resUrl: 'rows',
+			},
+		},
+		{
+			type: 'input',
+			prop: 'phonenumber',
+			label: '手机号',
+			required: true,
+			itemWidth: 50,
+			//disabled:true,
+			itemType: 'text',
+		},
+		{
+			type: 'input',
+			prop: 'jobNumber',
+			label: '工号',
+			required: true,
+			itemWidth: 50,
+			//disabled:true,
+			itemType: 'text',
+		},
+	]
+})
+
+const getList = async (req) => {
+	sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
+	loading.value = false
+	proxy
+		.get('/tenantUser/list', sourceList.value.pagination)
+		.then((message) => {
+            const res = {
+                cn: {
+                    equipment:{
+                        stat:"状态",
+                        model:'产品型号',
+                        running:"运行中",
+                        offLine:"离线",
+                        standby:"待机",
+                        auxiliaryMachine:"辅助机器",
+                        yield:"产量",
+                        temperature:"平均温度",
+                        humidity:"平均湿度",
+                        equipmentStatus:"设备状态",
+                        operatingMode:"工作模式",
+                        productionData:"产量数据",
+                        ultimateOutput:"极限产量",
+                        actualOutput:{
+                            asd:'111',
+                        },
+                    },
+                },
+                en:{
+                    equipment:{
+                        stat:"123",
+                        model:'123',
+                        running:"5555",
+                        offLine:"离555线",
+                        standby:"5555",
+                        auxiliaryMachine:"辅助1232机器",
+                        yield:"3323",
+                        temperature:"43434",
+                        humidity:"4545",
+                        equipmentStatus:"6565",
+                        operatingMode:"76767",
+                        productionData:"878787",
+                        ultimateOutput:"9898",
+                        actualOutput:"9090",
+                    },
+                },
+            }
+            //将res转成数组
+            // const resArr = Object.keys(res).map((key) => {
+            //     return {
+            //         key,
+            //         value: res[key],
+            //     }
+            // })
+            console.log(getAllKeys(res.cn))
+			//sourceList.value.data = message.rows
+		})
+}
+//递归对象所有对象,将不是对象的属性放入数组,数组为对象类型,记录所有父级的key
+const getAllKeys = (obj) => {
+    let result = []
+    const getKeys = (obj, parentKey) => {
+        Object.keys(obj).forEach((key) => {
+            if (typeof obj[key] === 'object') {
+                getKeys(obj[key], parentKey ? `${parentKey}.${key}` : key)
+            } else {
+                result.push({
+                    key: parentKey ? `${parentKey}.${key}` : key,
+                    value: obj[key],
+                })
+            }
+        })
+    }
+    getKeys(obj)
+    return result
+}
+
+const treeChange = (e) => {
+	console.log(e)
+	sourceList.value.pagination.tenantId = e.id
+	getList({ tenantId: e.id })
+	getUserList()
+	getDept()
+}
+
+const openModal = () => {
+	dialogVisible.value = true
+	modalType.value = 'add'
+	formData.data = {
+		userType: 1,
+	}
+}
+
+const tree = ref(null)
+const submitForm = () => {
+	byform.value.handleSubmit((valid) => {
+		const method = modalType.value == 'add' ? 'POST' : 'PUT'
+		console.log(method)
+		proxy
+			.post(
+				'/tenantUser',
+				{
+					...formData.data,
+					tenantId: sourceList.value.pagination.tenantId,
+				},
+				method
+			)
+			.then((res) => {
+				ElMessage({
+					message: modalType.value == 'add' ? '添加成功' : '编辑成功',
+					type: 'success',
+				})
+				dialogVisible.value = false
+				getList()
+			})
+	})
+}
+
+const getDtl = (row) => {
+	//system/user/1
+	proxy.get(`/tenantUser/${row.userId}`).then((res) => {
+		console.log(res)
+		formData.data = { ...row, roleIds: res.roleIds }
+		modalType.value = 'edit'
+		console.log(modalType.value)
+		dialogVisible.value = true
+	})
+}
+getList()
+</script>
+
+<style lang="scss" scoped>
+.langConfig {
+	padding: 20px;
+	display: flex;
+	justify-content: space-between;
+
+	.content {
+		width: 100%;
+	}
+}
+</style>