Browse Source

Merge branch 'master' of http://36.137.93.232:3000/hf/byte-sailing-new

lxf 1 year ago
parent
commit
b5c8a2923d
6 changed files with 378 additions and 196 deletions
  1. 1 0
      package.json
  2. 125 0
      src/lang/cn.js
  3. 124 0
      src/lang/en.js
  4. 27 0
      src/lang/index.js
  5. 4 1
      src/main.js
  6. 97 195
      src/views/system/langConfig/index.vue

+ 1 - 0
package.json

@@ -45,6 +45,7 @@
     "typescript": "^5.0.4",
     "typescript": "^5.0.4",
     "vue": "3.2.45",
     "vue": "3.2.45",
     "vue-cropper": "1.0.3",
     "vue-cropper": "1.0.3",
+    "vue-i18n": "^9.3.0-beta.17",
     "vue-router": "4.1.4",
     "vue-router": "4.1.4",
     "vue-super-flow": "^1.3.8"
     "vue-super-flow": "^1.3.8"
   },
   },

+ 125 - 0
src/lang/cn.js

@@ -0,0 +1,125 @@
+
+export const lang = {
+	equipment:{
+		stat:"状态",
+		model:'产品型号',
+		running:"运行中",
+		offLine:"离线",
+		standby:"待机",
+		auxiliaryMachine:"辅助机器",
+		yield:"产量",
+		temperature:"平均温度",
+		humidity:"平均湿度",
+		equipmentStatus:"设备状态",
+		operatingMode:"工作模式",
+		productionData:"产量数据",
+		ultimateOutput:"极限产量",
+		actualOutput:"实际产量",
+	},
+	sterilization:{
+		name:"灭菌柜",
+		pressure:"气压",
+		gasTemp:"Gas Temp",
+		EO:"E.O.温度",
+		waterTemperature:"水温",
+		humidity:"湿度",
+		averageTemperature:"平均温度",
+		hotbox:"温箱",
+	},
+	threadedHead:{
+		name:"螺纹头",
+		converterStartup:"变频器启动",
+		mainCompressedAirValve:"压缩空气总阀",
+		separatingDisc:"分离盘",
+		injectionValve:"喷油阀",
+		stationVibrationDisk:"工位振动盘",
+	},
+	rollPrinting:{
+		name:"滚印机",
+		frequencyOfMainMotor:"主电机频率",
+		injectionValve:"喷油阀",
+		variableFrequencyMotor:"变频电机",
+		frequency:"频率",
+		heatingMotor:"加热电机",
+		firstCurrentTemperature:"第一当前温度",
+		secondCurrentTemperature:"第二当前温度",
+		fuelInjectionMotor:"喷油电机",
+		oilPumpMotor:"油泵电机",
+		storageMotor:"蓄料电机",
+		centrifugalMotor:"离心电机",
+		
+	},
+	injection:{
+		name:"注塑机",
+		MoldStatus:"模具状态",
+		hydraulicPress:"液压机",
+		hydraulicOilTemperature:"液压油温度",
+		cylinderTemperature:"简体温度",
+		channel:"通道",
+		pressure:"压力",
+		speed:"速度",
+		videoInstruction:"视频说明书"
+	},
+	assemblingMachine:{
+		name:'组装机',
+		mainMotor:"主电机",
+		valve:"气阀",
+		centrifuge:"离心机",
+		frequencyOfMainMotor:"主电机频率",
+		stopperRate:"胶塞速率",
+		tipVelocity:"针尖速率",
+		rubberStopperSentHorizontally:"胶塞平送",
+		needleTipFlatFeeding:"针尖平送",
+	},
+	warpKnitting:{
+		name:'经编机',
+		spindleSpeed:'主轴转速',
+		jaca:'贾卡',
+		traverse:'横移',
+		currentClothLength:'当前布长',
+		setClothLength:'设定布长',
+		density:'密度',
+		warpLetOffAxis:'送经轴',
+		remainingTurns:'剩余圈数',
+		timeRemaining:'剩余时间',
+		traction:'牵拉',
+		crimp:'卷曲',
+		processwidth:'工艺宽度',
+		processHeight:'工艺高度',
+		totalNumberOfAxles:'总轴数',
+	},
+	packer:{
+		name:'包装机',
+		production:'12小时产量',
+		plannedOutput:"计划产量",
+		versionsPerMinute:"每分钟版数",
+		numberOfModules:"每模个数",
+		singleModeDistance:'单模距离',
+		alignmentDistance:"对版距离",
+		jogSpeed:"点动速度",
+		chainSpeed:'链条速度',
+		alignmentSpeed:"对版速度"
+	},
+	login:{
+		deviceInformation:"设备信息",
+		switchLanguage:'switch English',
+		logOut:'退出登录',
+		title:"ByteSailing管理系统",
+		form:{
+			tenantId:"请输入租户ID",
+			username:"请输入账号",
+			password:"请输入密码",
+			
+		},
+		loginText:'登录',
+		demo:"demo",
+		agreement:{
+			text:"已阅读并同意:Bytesailing",
+			clause:"服务条款",
+			agreement:"隐私协议",
+			and:"和"
+		},
+	},
+}
+//导出
+export default lang

+ 124 - 0
src/lang/en.js

@@ -0,0 +1,124 @@
+export const lang = {
+	equipment:{
+		stat:"状态",
+		model:'产品型号',
+		running:"运行中",
+		offLine:"离线",
+		standby:"待机",
+		auxiliaryMachine:"辅助机器",
+		yield:"产量",
+		temperature:"平均温度",
+		humidity:"平均湿度",
+		equipmentStatus:"设备状态",
+		operatingMode:"工作模式",
+		productionData:"产量数据",
+		ultimateOutput:"极限产量",
+		actualOutput:"实际产量",
+	},
+	sterilization:{
+		name:"灭菌柜",
+		pressure:"气压",
+		gasTemp:"Gas Temp",
+		EO:"E.O.温度",
+		waterTemperature:"水温",
+		humidity:"湿度",
+		averageTemperature:"平均温度",
+		hotbox:"温箱",
+	},
+	threadedHead:{
+		name:"螺纹头",
+		converterStartup:"变频器启动",
+		mainCompressedAirValve:"压缩空气总阀",
+		separatingDisc:"分离盘",
+		injectionValve:"喷油阀",
+		stationVibrationDisk:"工位振动盘",
+	},
+	rollPrinting:{
+		name:"滚印机",
+		frequencyOfMainMotor:"主电机频率",
+		injectionValve:"喷油阀",
+		variableFrequencyMotor:"变频电机",
+		frequency:"频率",
+		heatingMotor:"加热电机",
+		firstCurrentTemperature:"第一当前温度",
+		secondCurrentTemperature:"第二当前温度",
+		fuelInjectionMotor:"喷油电机",
+		oilPumpMotor:"油泵电机",
+		storageMotor:"蓄料电机",
+		centrifugalMotor:"离心电机",
+		
+	},
+	injection:{
+		name:"注塑机",
+		MoldStatus:"模具状态",
+		hydraulicPress:"液压机",
+		hydraulicOilTemperature:"液压油温度",
+		cylinderTemperature:"简体温度",
+		channel:"通道",
+		pressure:"压力",
+		speed:"速度",
+		videoInstruction:"视频说明书"
+	},
+	assemblingMachine:{
+		name:'组装机',
+		mainMotor:"主电机",
+		valve:"气阀",
+		centrifuge:"离心机",
+		frequencyOfMainMotor:"主电机频率",
+		stopperRate:"胶塞速率",
+		tipVelocity:"针尖速率",
+		rubberStopperSentHorizontally:"胶塞平送",
+		needleTipFlatFeeding:"针尖平送",
+	},
+	warpKnitting:{
+		name:'经编机',
+		spindleSpeed:'主轴转速',
+		jaca:'贾卡',
+		traverse:'横移',
+		currentClothLength:'当前布长',
+		setClothLength:'设定布长',
+		density:'密度',
+		warpLetOffAxis:'送经轴',
+		remainingTurns:'剩余圈数',
+		timeRemaining:'剩余时间',
+		traction:'牵拉',
+		crimp:'卷曲',
+		processwidth:'工艺宽度',
+		processHeight:'工艺高度',
+		totalNumberOfAxles:'总轴数',
+	},
+	packer:{
+		name:'包装机',
+		production:'12小时产量',
+		plannedOutput:"计划产量",
+		versionsPerMinute:"每分钟版数",
+		numberOfModules:"每模个数",
+		singleModeDistance:'单模距离',
+		alignmentDistance:"对版距离",
+		jogSpeed:"点动速度",
+		chainSpeed:'链条速度',
+		alignmentSpeed:"对版速度"
+	},
+	login:{
+		deviceInformation:"设备信息",
+		switchLanguage:'switch English',
+		logOut:'退出登录',
+		title:"ByteSailing管理系统",
+		form:{
+			tenantId:"请输入租户ID",
+			username:"请输入账号",
+			password:"请输入密码",
+			
+		},
+		loginText:'登录',
+		demo:"demo",
+		agreement:{
+			text:"已阅读并同意:Bytesailing",
+			clause:"服务条款",
+			agreement:"隐私协议",
+			and:"和"
+		},
+	},
+}
+//导出
+export default lang

+ 27 - 0
src/lang/index.js

@@ -0,0 +1,27 @@
+import { createI18n } from 'vue-i18n'
+import cn from '@/lang/cn'
+import en from '@/lang/en'
+console.log(cn,123987129378192379127389127)
+import {
+  download,
+  post,
+  get
+} from '@/utils/request'
+const i18n = createI18n({ 
+  legacy: false, // 让 setup 函数可以通过 t 访问
+  globalInjection: true, // 让 template 可以像 vue2 那样使用 $t 来访问
+  locale: 'zh-cn',
+  fallbackLocale: 'zh-cn',
+  
+  messages: {
+    'zh-cn': cn,
+    'en-us': en
+  }
+})
+get('/open/multilingual/getJson',{}).then(res=>{
+  console.log(JSON.parse(res.data),'下载')
+  window.localStorage.setItem('lang',res.data)
+  i18n.global.setLocaleMessage('zh-cn', cn)
+})
+
+export default i18n

+ 4 - 1
src/main.js

@@ -71,7 +71,8 @@ import ImagePreview from "@/components/ImagePreview"
 import TreeSelect from '@/components/TreeSelect'
 import TreeSelect from '@/components/TreeSelect'
 // 字典标签组件
 // 字典标签组件
 import DictTag from '@/components/DictTag'
 import DictTag from '@/components/DictTag'
-
+// 多语言
+import i18n from "@/lang/index";
 const app = createApp(App)
 const app = createApp(App)
 
 
 // 全局方法挂载
 // 全局方法挂载
@@ -110,6 +111,8 @@ app.component('RightToolbar', RightToolbar)
 app.use(router)
 app.use(router)
 app.use(store)
 app.use(store)
 app.use(plugins)
 app.use(plugins)
+
+app.use(i18n)
 app.use(elementIcons)
 app.use(elementIcons)
 app.component('svg-icon', SvgIcon)
 app.component('svg-icon', SvgIcon)
 
 

+ 97 - 195
src/views/system/langConfig/index.vue

@@ -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>