|
@@ -15,12 +15,13 @@
|
|
}"
|
|
}"
|
|
:action-list="[
|
|
:action-list="[
|
|
{
|
|
{
|
|
- text: '添加用户',
|
|
|
|
|
|
+ text: '同步其他语种配置',
|
|
action: () => openModal('add'),
|
|
action: () => openModal('add'),
|
|
disabled: !sourceList.pagination.tenantId,
|
|
disabled: !sourceList.pagination.tenantId,
|
|
},
|
|
},
|
|
]"
|
|
]"
|
|
@get-list="getList"
|
|
@get-list="getList"
|
|
|
|
+
|
|
>
|
|
>
|
|
<template #slotName="{ item }">
|
|
<template #slotName="{ item }">
|
|
{{ item.createTime }}
|
|
{{ item.createTime }}
|
|
@@ -28,7 +29,7 @@
|
|
</byTable>
|
|
</byTable>
|
|
</div>
|
|
</div>
|
|
<el-dialog
|
|
<el-dialog
|
|
- :title="modalType == 'add' ? '添加用户' : '编辑用户'"
|
|
|
|
|
|
+ :title="modalType == 'add' ? '修改语言配置' : '修改语言配置'"
|
|
v-if="dialogVisible"
|
|
v-if="dialogVisible"
|
|
v-model="dialogVisible"
|
|
v-model="dialogVisible"
|
|
width="500"
|
|
width="500"
|
|
@@ -41,23 +42,6 @@
|
|
:rules="rules"
|
|
:rules="rules"
|
|
ref="byform"
|
|
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>
|
|
</byForm>
|
|
<template #footer>
|
|
<template #footer>
|
|
<el-button @click="dialogVisible = false" size="large"
|
|
<el-button @click="dialogVisible = false" size="large"
|
|
@@ -90,6 +74,7 @@ const sourceList = ref({
|
|
total: 3,
|
|
total: 3,
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
|
|
+ type:'web'
|
|
},
|
|
},
|
|
})
|
|
})
|
|
let dialogVisible = ref(false)
|
|
let dialogVisible = ref(false)
|
|
@@ -102,44 +87,50 @@ const validatePass = (rule, value, callback) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let rules = ref({
|
|
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 userId = ref('')
|
|
const { proxy } = getCurrentInstance()
|
|
const { proxy } = getCurrentInstance()
|
|
const password = ref('')
|
|
const password = ref('')
|
|
const selectConfig = computed(() => {
|
|
const selectConfig = computed(() => {
|
|
- return []
|
|
|
|
|
|
+ return [
|
|
|
|
+ {
|
|
|
|
+ label: "选择系统",
|
|
|
|
+ prop: "type",
|
|
|
|
+ data: [
|
|
|
|
+ {
|
|
|
|
+ label:'web',
|
|
|
|
+ id:'web'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label:'app',
|
|
|
|
+ id:'app'
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ ]
|
|
})
|
|
})
|
|
const config = computed(() => {
|
|
const config = computed(() => {
|
|
return [
|
|
return [
|
|
{
|
|
{
|
|
attrs: {
|
|
attrs: {
|
|
label: '中文名称',
|
|
label: '中文名称',
|
|
- prop: 'deptName',
|
|
|
|
|
|
+ prop: 'value',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
|
|
{
|
|
{
|
|
attrs: {
|
|
attrs: {
|
|
label: '英文名称',
|
|
label: '英文名称',
|
|
- prop: 'userName',
|
|
|
|
|
|
+ prop: 'enText',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
attrs: {
|
|
attrs: {
|
|
label: '对象索引',
|
|
label: '对象索引',
|
|
- prop: 'nickName',
|
|
|
|
|
|
+ prop: 'key',
|
|
align: 'left',
|
|
align: 'left',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -160,13 +151,6 @@ const config = computed(() => {
|
|
},
|
|
},
|
|
el: 'button',
|
|
el: 'button',
|
|
click() {
|
|
click() {
|
|
- if (!sourceList.value.pagination.tenantId) {
|
|
|
|
- ElMessage({
|
|
|
|
- message: '请选择租户',
|
|
|
|
- type: 'warning',
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
getDtl(row)
|
|
getDtl(row)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -189,154 +173,75 @@ const byform = ref(null)
|
|
const treeListData = ref([])
|
|
const treeListData = ref([])
|
|
const formConfig = computed(() => {
|
|
const formConfig = computed(() => {
|
|
return [
|
|
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',
|
|
type: 'input',
|
|
- prop: 'phonenumber',
|
|
|
|
- label: '手机号',
|
|
|
|
|
|
+ prop: 'value',
|
|
|
|
+ label: '中文名称',
|
|
required: true,
|
|
required: true,
|
|
- itemWidth: 50,
|
|
|
|
- //disabled:true,
|
|
|
|
itemType: 'text',
|
|
itemType: 'text',
|
|
|
|
+ disabled:true,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
type: 'input',
|
|
type: 'input',
|
|
- prop: 'jobNumber',
|
|
|
|
- label: '工号',
|
|
|
|
|
|
+ prop: 'enText',
|
|
|
|
+ label: '英文名称',
|
|
required: true,
|
|
required: true,
|
|
- itemWidth: 50,
|
|
|
|
- //disabled:true,
|
|
|
|
itemType: 'text',
|
|
itemType: 'text',
|
|
},
|
|
},
|
|
]
|
|
]
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+//根据resurl获取数据
|
|
|
|
+const getFormat = (formatStr, props) => {
|
|
|
|
+ if (!formatStr) return props;
|
|
|
|
+ return formatStr
|
|
|
|
+ .split(".")
|
|
|
|
+ .reduce((total, cur) => (!total ? "" : total[cur]), props);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const submitData = ref('')
|
|
|
|
+
|
|
const getList = async (req) => {
|
|
const getList = async (req) => {
|
|
sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
|
|
sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
|
|
|
|
+ console.log(sourceList.value.pagination.type)
|
|
loading.value = false
|
|
loading.value = false
|
|
proxy
|
|
proxy
|
|
- .get('/tenantUser/list', sourceList.value.pagination)
|
|
|
|
|
|
+ .get('/open/multilingual/getJson', {})
|
|
.then((message) => {
|
|
.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
|
|
|
|
|
|
+ submitData.value = JSON.parse(message.data)
|
|
|
|
+ const res = JSON.parse(message.data)
|
|
|
|
+ // proxy.post('/open/multilingual/setJson',{configValue:JSON.stringify(res)}).then((message) => {
|
|
|
|
+ // })
|
|
|
|
+ console.log(res[sourceList.value.pagination.type],12312312)
|
|
|
|
+ const tableData = getAllKeys(res.app.cn)
|
|
|
|
+ console.log(tableData)
|
|
|
|
+ //根据key获取res里其他语言的值
|
|
|
|
+ for (let i = 0; i < tableData.length; i++) {
|
|
|
|
+ const element = tableData[i];
|
|
|
|
+ element.enText = getFormat(element.key,res.app.en)
|
|
|
|
+ }
|
|
|
|
+ sourceList.value.data = tableData
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-//递归对象所有对象,将不是对象的属性放入数组,数组为对象类型,记录所有父级的key
|
|
|
|
|
|
+//递归对象所有对象,将不是对象的属性放入数组,数组为对象类型,记录所有父级的key以数组方式存储
|
|
const getAllKeys = (obj) => {
|
|
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
|
|
|
|
|
|
+ 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) => {
|
|
const treeChange = (e) => {
|
|
@@ -358,37 +263,34 @@ const openModal = () => {
|
|
const tree = ref(null)
|
|
const tree = ref(null)
|
|
const submitForm = () => {
|
|
const submitForm = () => {
|
|
byform.value.handleSubmit((valid) => {
|
|
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()
|
|
|
|
- })
|
|
|
|
|
|
+ console.log(formData.data)
|
|
|
|
+ //根据key修改submitData里的值
|
|
|
|
+ const key = formData.data.key
|
|
|
|
+ const value = formData.data.value
|
|
|
|
+ const enText = formData.data.enText
|
|
|
|
+ const keyArr = key.split('.')
|
|
|
|
+ let obj = submitData.value.app.en
|
|
|
|
+ for (let i = 0; i < keyArr.length; i++) {
|
|
|
|
+ const element = keyArr[i]
|
|
|
|
+ if (i == keyArr.length - 1) {
|
|
|
|
+ obj[element] = enText
|
|
|
|
+ } else {
|
|
|
|
+ obj = obj[element]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ proxy.post('/open/multilingual/setJson',{configValue:JSON.stringify(submitData.value)}).then((message) => {
|
|
|
|
+ console.log(message)
|
|
|
|
+ dialogVisible.value = false
|
|
|
|
+ getList()
|
|
|
|
+ })
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
const getDtl = (row) => {
|
|
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
|
|
|
|
- })
|
|
|
|
|
|
+ formData.data = { ...row}
|
|
|
|
+ modalType.value = 'edit'
|
|
|
|
+ dialogVisible.value = true
|
|
|
|
+
|
|
}
|
|
}
|
|
getList()
|
|
getList()
|
|
</script>
|
|
</script>
|