Browse Source

form组件升级,产品库新增字段添加

asd26269546 2 years ago
parent
commit
c2010c0806

+ 1 - 1
src/assets/styles/element-ui.scss

@@ -121,7 +121,7 @@
 }
 }
 
 
 .el-form-item{
 .el-form-item{
-  padding: 0 10px!important;
+  padding: 0!important;
 }
 }
 
 
 .el-form-item__label{
 .el-form-item__label{

+ 31 - 3
src/components/byForm/index.vue

@@ -127,11 +127,24 @@
                     v-else-if="i.type == 'slot'">
                     v-else-if="i.type == 'slot'">
                     {{i.slotName}}插槽占位符
                     {{i.slotName}}插槽占位符
                 </slot>
                 </slot>
+				<div v-else-if="i.type == 'json'">
+					<byForm
+						:formConfig="i.json"
+						:formOption="formOption"
+						v-model="formData[i.prop]"
+						ref="byform"
+					>
+					</byForm>
+				</div>
 			</el-form-item>
 			</el-form-item>
 		</el-form>
 		</el-form>
 	</div>
 	</div>
 </template>
 </template>
-  
+<script>
+	export default {
+	  name: "byForm", 
+	}
+</script>
 <script  setup>
 <script  setup>
 import { set } from '@vueuse/shared'
 import { set } from '@vueuse/shared'
 import { reactive } from 'vue'
 import { reactive } from 'vue'
@@ -166,6 +179,7 @@ const formData = computed(() => {
 })
 })
 const formDataReset = ref({...proxy.modelValue})
 const formDataReset = ref({...proxy.modelValue})
 const commonsEmit = (prop,item) => {
 const commonsEmit = (prop,item) => {
+	console.log(formData)
 	if(item.fn) {
 	if(item.fn) {
 		item.fn(prop)
 		item.fn(prop)
 	}
 	}
@@ -191,7 +205,7 @@ const dateFormatInit = ((itemType) => {
 		datetimerange:"YYYY-MM-DD hh:mm:ss",
 		datetimerange:"YYYY-MM-DD hh:mm:ss",
 		daterange:"YYYY-MM-DD hh:mm:ss",
 		daterange:"YYYY-MM-DD hh:mm:ss",
 	}
 	}
-
+	console.log(formatObj)
 	return formatObj[itemType]
 	return formatObj[itemType]
 })
 })
 
 
@@ -260,7 +274,10 @@ const getFormat = (formatStr, props) => {
 }
 }
 
 
 //初始化所有表单
 //初始化所有表单
+
 const formDataInit = () => {
 const formDataInit = () => {
+	
+	
 	var map = {
 	var map = {
 		input: '',
 		input: '',
 		radio: null,
 		radio: null,
@@ -280,26 +297,37 @@ const formDataInit = () => {
 		Upload: { path: null, id: null, name: null },
 		Upload: { path: null, id: null, name: null },
 		password:'',
 		password:'',
 		treeSelect:'',
 		treeSelect:'',
+		json:{},
 	}
 	}
 	const formDataCopy = { ...formData.value }
 	const formDataCopy = { ...formData.value }
 	for (let i = 0; i < proxy.formConfig.length; i++) {
 	for (let i = 0; i < proxy.formConfig.length; i++) {
 		const element = proxy.formConfig[i]
 		const element = proxy.formConfig[i]
 		
 		
 		if(formDataCopy[element.prop] || element.type === 'slot') {
 		if(formDataCopy[element.prop] || element.type === 'slot') {
-			break;
+			continue
 		}
 		}
+			
 		if(map[element.itemType] != undefined){
 		if(map[element.itemType] != undefined){
 			formData.value[element.prop] = map[element.itemType]
 			formData.value[element.prop] = map[element.itemType]
 		}else{
 		}else{
 			formData.value[element.prop] = element.multiple ? [] :  map[element.type]
 			formData.value[element.prop] = element.multiple ? [] :  map[element.type]
 		}
 		}
+		
 	}
 	}
+	
 	emit('update:modelValue', formData.value)
 	emit('update:modelValue', formData.value)
 }
 }
 
 
 const handleSubmit = (onSubmit) => {
 const handleSubmit = (onSubmit) => {
 	proxy.$refs['byForm'].validate((valid) => {
 	proxy.$refs['byForm'].validate((valid) => {
 		if (valid) {
 		if (valid) {
+			const form = { ...formData.value }
+			proxy.formConfig.map(item => {
+				if(item.type == 'json') {
+					form[item.prop] = JSON.stringify(form[item.prop])
+				}
+			})
+			emit('update:modelValue', form)
 			onSubmit()
 			onSubmit()
 		} else {
 		} else {
 			ElMessage({
 			ElMessage({

+ 38 - 11
src/components/byTable/demo.vue

@@ -14,8 +14,8 @@
 				:table-events="{
 				:table-events="{
 					//element talbe事件都能传
 					//element talbe事件都能传
 					'row-click': handleRowClick,
 					'row-click': handleRowClick,
-					'cell-contextmenu':handleRowClick.apply,
+					'cell-contextmenu': handleRowClick.apply,
-					'select-all':select
+					'select-all': select,
 				}"
 				}"
 				:action-list="[
 				:action-list="[
 					{
 					{
@@ -27,7 +27,7 @@
 				]"
 				]"
 				@get-list="getList"
 				@get-list="getList"
 			>
 			>
-				<template  #slotName='{item}'>
+				<template #slotName="{ item }">
 					{{ item.createTime }}
 					{{ item.createTime }}
 				</template>
 				</template>
 			</byTable>
 			</byTable>
@@ -69,7 +69,7 @@ const align = ref('center')
 const tableHeight = ref(null)
 const tableHeight = ref(null)
 const border = ref(true)
 const border = ref(true)
 const sourceList = ref({
 const sourceList = ref({
-	data:[],
+	data: [],
 	pagination: {
 	pagination: {
 		total: 3,
 		total: 3,
 		pageNum: 1,
 		pageNum: 1,
@@ -85,7 +85,7 @@ const selectConfig = computed(() => {
 		{
 		{
 			label: '合同状态1',
 			label: '合同状态1',
 			prop: 'tdaProductId',
 			prop: 'tdaProductId',
-			
+
 			data: [
 			data: [
 				{
 				{
 					label: '已关闭',
 					label: '已关闭',
@@ -108,7 +108,7 @@ const selectConfig = computed(() => {
 const config = computed(() => {
 const config = computed(() => {
 	return [
 	return [
 		{
 		{
-			type:"selection",
+			type: 'selection',
 			attrs: {
 			attrs: {
 				label: '角色名称',
 				label: '角色名称',
 				prop: 'remark',
 				prop: 'remark',
@@ -148,10 +148,10 @@ const config = computed(() => {
 						name: 'el-switch',
 						name: 'el-switch',
 						data: row.menuCheckStrictly,
 						data: row.menuCheckStrictly,
 						change: (e) => {
 						change: (e) => {
-							console.log(e,'change事件')
+							console.log(e, 'change事件')
 						},
 						},
 						click: (e) => {
 						click: (e) => {
-							console.log(e,'click事件')
+							console.log(e, 'click事件')
 						},
 						},
 					},
 					},
 				]
 				]
@@ -163,7 +163,7 @@ const config = computed(() => {
 				align: align.value,
 				align: align.value,
 				width: 200,
 				width: 200,
 				prop: 'createTime',
 				prop: 'createTime',
-				slot:"slotName"
+				slot: 'slotName',
 			},
 			},
 		},
 		},
 		{
 		{
@@ -308,6 +308,34 @@ const formConfig = computed(() => {
 			slotName: 'slot',
 			slotName: 'slot',
 			label: '插槽',
 			label: '插槽',
 		},
 		},
+		
+		{
+			//使用此功能需要初始化prop数据至少是对象
+			type: 'json',
+			prop: 'standardJson',
+			json: [
+				{
+					type: 'input',
+					prop: 'englishName',
+					label: '英文名',
+				},
+				{
+					type: 'input',
+					prop: 'code',
+					label: '备注',
+				},
+				{
+					type: 'input',
+					prop: 'netWeight',
+					label: '净重',
+				},
+				{
+					type: 'input',
+					prop: 'customhouse',
+					label: '海关编码',
+				},
+			],
+		},
 	]
 	]
 })
 })
 
 
@@ -316,7 +344,7 @@ const sleep = (time = 1000) => {
 }
 }
 const getList = async (res) => {
 const getList = async (res) => {
 	console.log(sourceList.value)
 	console.log(sourceList.value)
-	console.log({...sourceList.value.pagination,...res})
+	console.log({ ...sourceList.value.pagination, ...res })
 	loading.value = true
 	loading.value = true
 	proxy.get('/system/role/list?pageNum=1&pageSize=10').then((message) => {
 	proxy.get('/system/role/list?pageNum=1&pageSize=10').then((message) => {
 		console.log(message)
 		console.log(message)
@@ -334,7 +362,6 @@ const select = (row, column, cell) => {
 		dangerouslyUseHTMLString: true, // Be careful :)
 		dangerouslyUseHTMLString: true, // Be careful :)
 		message: `点了全选`,
 		message: `点了全选`,
 	})
 	})
-
 }
 }
 const handleRowClick = (row, column, cell) => {
 const handleRowClick = (row, column, cell) => {
 	ElMessage({
 	ElMessage({

+ 31 - 1
src/views/product/product/index.vue

@@ -279,7 +279,9 @@ const fileList = ref([]);
 const fileListCopy = ref([]);
 const fileListCopy = ref([]);
 
 
 let formData = reactive({
 let formData = reactive({
-  data: {},
+  data: {
+  },
+  
 });
 });
 const formOption = reactive({
 const formOption = reactive({
   inline: true,
   inline: true,
@@ -351,6 +353,32 @@ const formConfig = computed(() => {
       label: "备注",
       label: "备注",
       itemType: "textarea",
       itemType: "textarea",
     },
     },
+    {
+			type: 'json',
+			prop: 'standardJson',
+			json: [
+				{
+					type: 'input',
+					prop: 'englishName',
+					label: '英文名',
+				},
+        {
+					type: 'input',
+					prop: 'code',
+					label: '备注',
+				},
+        {
+					type: 'input',
+					prop: 'netWeight',
+					label: '净重',
+				},
+        {
+					type: 'input',
+					prop: 'customhouse',
+					label: '海关编码',
+				},
+			],
+		},
   ];
   ];
 });
 });
 const newPassword = () => {
 const newPassword = () => {
@@ -411,6 +439,7 @@ const openModal = () => {
     definition: "1",
     definition: "1",
     type: "1",
     type: "1",
     fileList: [],
     fileList: [],
+    standardJson:{},
   };
   };
 
 
   fileList.value = [];
   fileList.value = [];
@@ -474,6 +503,7 @@ const getDtl = (row) => {
     fileListCopy.value = [...fileList.value];
     fileListCopy.value = [...fileList.value];
     res.type = res.type + ""; //type回显
     res.type = res.type + ""; //type回显
     res.definition = "1"; //产品
     res.definition = "1"; //产品
+    res.standardJson = JSON.parse(res.standardJson);
     formData.data = res;
     formData.data = res;
     dialogVisible.value = true;
     dialogVisible.value = true;
   });
   });

+ 478 - 411
src/views/system/user2/index.vue

@@ -1,453 +1,520 @@
 <template>
 <template>
-  <div class="user">
+	<div class="user">
-    <div class="tree">
+		<div class="tree">
-      <treeList :data="treeListData" v-model="sourceList.pagination.tenantId" node-key="id" @change="treeChange">
+			<treeList
-      </treeList>
+				:data="treeListData"
-    </div>
+				v-model="sourceList.pagination.tenantId"
-    <div class="content">
+				node-key="id"
-      <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading"
+				@change="treeChange"
-        highlight-current-row :selectConfig="selectConfig" searchKey="userName" :table-events="{
+			>
-          //element talbe事件都能传
+			</treeList>
-          select: select,
+		</div>
-        }" :action-list="[
+		<div class="content">
-  {
+			<byTable
-    text: '添加用户',
+				:source="sourceList.data"
-    action: () => openModal('add'),
+				:pagination="sourceList.pagination"
-    disabled: !sourceList.pagination.tenantId,
+				:config="config"
-  },
+				:loading="loading"
-]" @get-list="getList">
+				highlight-current-row
-        <template #slotName="{ item }">
+				:selectConfig="selectConfig"
-          {{ item.createTime }}
+				searchKey="userName"
-        </template>
+				:table-events="{
-      </byTable>
+					//element talbe事件都能传
-    </div>
+					select: select,
-    <el-dialog :title="modalType == 'add' ? '新增' : '编辑'" v-model="dialogVisible" width="500" v-loading="loading">
+				}"
-      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
+				:action-list="[
-        <template #account>
+					{
-          <el-input style="width: 150px; margin-right: 10px" v-model="formData.data.userName"
+						text: '添加用户',
-            placeholder="请输入用户名"></el-input>
+						action: () => openModal('add'),
-          <el-input style="width: 150px; margin-right: 10px" v-model="formData.data.password" placeholder="密码"></el-input>
+						disabled: !sourceList.pagination.tenantId,
-          <span style="color: #409eff; cursor: pointer" @click="newPassword">随机生成</span>
+					},
-        </template>
+				]"
-      </byForm>
+				@get-list="getList"
-      <template #footer>
+			>
-        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+				<template #slotName="{ item }">
-        <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading">
+					{{ item.createTime }}
-          确 定
+				</template>
-        </el-button>
+			</byTable>
-      </template>
+		</div>
-    </el-dialog>
+		<el-dialog
-    <el-dialog title="修改密码" v-model="roomDialogVisible" width="300" :before-close="handleClose" v-loading="loading">
+			:title="modalType == 'add' ? '新增' : '编辑'"
-      <template #footer>
+			v-model="dialogVisible"
-        <el-input v-model="password" type="password" placeholder="请输入新密码" show-password style="margin-bottom:20px" />
+			width="500"
-        <el-button @click="roomDialogVisible = false" size="large">取 消</el-button>
+			v-loading="loading"
-        <el-button type="primary" @click="submitPassword(password)" size="large" :loading="submitLoading">
+		>
-          确 定
+			<byForm
-        </el-button>
+				:formConfig="formConfig"
-      </template>
+				:formOption="formOption"
-    </el-dialog>
+				v-model="formData.data"
-  </div>
+				: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>
+		<el-dialog
+			title="修改密码"
+			v-model="roomDialogVisible"
+			width="300"
+			:before-close="handleClose"
+			v-loading="loading"
+		>
+			<template #footer>
+				<el-input
+					v-model="password"
+					type="password"
+					placeholder="请输入新密码"
+					show-password
+					style="margin-bottom: 20px"
+				/>
+				<el-button @click="roomDialogVisible = false" size="large"
+					>取 消</el-button
+				>
+				<el-button
+					type="primary"
+					@click="submitPassword(password)"
+					size="large"
+					:loading="submitLoading"
+				>
+					确 定
+				</el-button>
+			</template>
+		</el-dialog>
+	</div>
 </template>
 </template>
   
   
 <script setup>
 <script setup>
 /* eslint-disable vue/no-unused-components */
 /* eslint-disable vue/no-unused-components */
-import { ElMessage, ElMessageBox } from "element-plus";
+import { ElMessage, ElMessageBox } from 'element-plus'
-import byTable from "@/components/byTable/index";
+import byTable from '@/components/byTable/index'
-import byForm from "@/components/byForm/index";
+import byForm from '@/components/byForm/index'
-import treeList from "@/components/treeList/index";
+import treeList from '@/components/treeList/index'
-import { computed, defineComponent, ref } from "vue";
+import { computed, defineComponent, ref } from 'vue'
-const loading = ref(false);
+const loading = ref(false)
-const submitLoading = ref(false);
+const submitLoading = ref(false)
 const sourceList = ref({
 const sourceList = ref({
-  data: [],
+	data: [],
-  pagination: {
+	pagination: {
-    total: 3,
+		total: 3,
-    pageNum: 1,
+		pageNum: 1,
-    pageSize: 10,
+		pageSize: 10,
-  },
+	},
-});
+})
-let dialogVisible = ref(false);
+let dialogVisible = ref(false)
-let modalType = ref("add");
+let modalType = ref('add')
 let rules = ref({
 let rules = ref({
-  roleKey: [{ required: true, message: "请选择部门", trigger: "blur" }],
+	roleKey: [{ required: true, message: '请选择部门', trigger: 'blur' }],
-  nickName: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
+	nickName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
-  userName: [{ required: true, message: "用户名不能为空", trigger: "blur" }],
+	userName: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
-});
+})
-const userId = ref("");
+const userId = ref('')
-const { proxy } = getCurrentInstance();
+const { proxy } = getCurrentInstance()
-const password = ref("");
+const password = ref('')
 const roomDialogVisible = ref(false)
 const roomDialogVisible = ref(false)
 const selectConfig = computed(() => {
 const selectConfig = computed(() => {
-  return [];
+	return []
-});
+})
 const config = computed(() => {
 const config = computed(() => {
-  return [
+	return [
-    {
+		{
-      attrs: {
+			attrs: {
-        label: "部门",
+				label: '部门',
-        prop: "deptName",
+				prop: 'deptName',
-      },
+			},
-    },
+		},
-    {
+		{
-      attrs: {
+			attrs: {
-        label: "姓名",
+				label: '姓名',
-        prop: "nickName",
+				prop: 'nickName',
-        align: "left",
+				align: 'left',
-      },
+			},
-    },
+		},
-    {
+		{
-      attrs: {
+			attrs: {
-        label: "用户名",
+				label: '用户名',
-        prop: "userName",
+				prop: 'userName',
-      },
+			},
-    },
+		},
-    {
+		{
-      attrs: {
+			attrs: {
-        label: "系统用户",
+				label: '系统用户',
-        prop: "userType",
+				prop: 'userType',
-      },
+			},
-      render(userType) {
+			render(userType) {
-        return userType == 1 ? "是" : "否";
+				return userType == 1 ? '是' : '否'
-      },
+			},
-    },
+		},
-    {
+		{
-      attrs: {
+			attrs: {
-        label: "手机号",
+				label: '手机号',
-        prop: "phonenumber",
+				prop: 'phonenumber',
-      },
+			},
-    },
+		},
-    {
+		{
-      attrs: {
+			attrs: {
-        label: "工号",
+				label: '工号',
-        prop: "jobNumber",
+				prop: 'jobNumber',
-      },
+			},
-    },
+		},
-    {
+		{
-      attrs: {
+			attrs: {
-        label: "操作",
+				label: '操作',
-        width: "200",
+				width: '200',
-        align: "right",
+				align: 'right',
-      },
+			},
-      // 渲染 el-button,一般用在最后一列。
+			// 渲染 el-button,一般用在最后一列。
-      renderHTML(row) {
+			renderHTML(row) {
-        return [
+				return [
-          {
+					{
-            attrs: {
+						attrs: {
-              label: "修改密码",
+							label: '修改密码',
-              type: "primary",
+							type: 'primary',
-              text: true,
+							text: true,
-            },
+						},
-            el: "button",
+						el: 'button',
-            click() {
+						click() {
-              userId.value = row.userId;
+							userId.value = row.userId
-              roomDialogVisible.value = true
+							roomDialogVisible.value = true
-            },
+						},
-          },
+					},
-          {
+					{
-            attrs: {
+						attrs: {
-              label: "修改",
+							label: '修改',
-              type: "primary",
+							type: 'primary',
-              text: true,
+							text: true,
-            },
+						},
-            el: "button",
+						el: 'button',
-            click() {
+						click() {
-              if (!sourceList.value.pagination.tenantId) {
+							if (!sourceList.value.pagination.tenantId) {
-                ElMessage({
+								ElMessage({
-                  message: '请选择租户',
+									message: '请选择租户',
-                  type: 'warning',
+									type: 'warning',
-                });
+								})
-                return
+								return
-              }
+							}
-              getDtl(row);
+							getDtl(row)
-            },
+						},
-          },
+					},
-          {
+					{
-            attrs: {
+						attrs: {
-              label: "删除",
+							label: '删除',
-              type: "danger",
+							type: 'danger',
-              text: true,
+							text: true,
-            },
+						},
-            el: "button",
+						el: 'button',
-            click() {
+						click() {
-              // 弹窗提示是否删除
+							// 弹窗提示是否删除
-              ElMessageBox.confirm(
+							ElMessageBox.confirm(
-                "此操作将永久删除该数据, 是否继续?",
+								'此操作将永久删除该数据, 是否继续?',
-                "提示",
+								'提示',
-                {
+								{
-                  confirmButtonText: "确定",
+									confirmButtonText: '确定',
-                  cancelButtonText: "取消",
+									cancelButtonText: '取消',
-                  type: "warning",
+									type: 'warning',
-                }
+								}
-              ).then(() => {
+							).then(() => {
-                // 删除
+								// 删除
-                proxy
+								proxy
-                  .post(
+									.post(
-                    "/tenantUser/" + row.userId,
+										'/tenantUser/' + row.userId,
-                    {
+										{
-                      id: row.userId,
+											id: row.userId,
-                    },
+										},
-                    "delete"
+										'delete'
-                  )
+									)
-                  .then((res) => {
+									.then((res) => {
-                    ElMessage({
+										ElMessage({
-                      message: "删除成功",
+											message: '删除成功',
-                      type: "success",
+											type: 'success',
-                    });
+										})
-                    getList();
+										getList()
-                  });
+									})
-              });
+							})
-            },
+						},
-          },
+					},
-        ];
+				]
-      },
+			},
-    },
+		},
-  ];
+	]
-});
+})
 
 
 let formData = reactive({
 let formData = reactive({
-  data: {},
+	data: {},
-});
+})
 const formOption = reactive({
 const formOption = reactive({
-  inline: true,
+	inline: true,
-  labelWidth: 100,
+	labelWidth: 100,
-  itemWidth: 100,
+	itemWidth: 100,
-  rules: [],
+	rules: [],
-});
+})
-const byform = ref(null);
+const byform = ref(null)
-const treeListData = ref([]);
+const treeListData = ref([])
 const formConfig = computed(() => {
 const formConfig = computed(() => {
-  return [
+	return [
-    {
+		{
-      type: "treeSelect",
+			type: 'treeSelect',
-      prop: "deptId",
+			prop: 'deptId',
-      label: "部门名称",
+			label: '部门名称',
-      data: [],
+			data: [],
-    },
+		},
-    {
+		{
-      type: "input",
+			type: 'input',
-      prop: "nickName",
+			prop: 'nickName',
-      label: "姓名",
+			label: '姓名',
-      required: true,
+			required: true,
-      itemWidth: 50,
+			itemWidth: 50,
-      //disabled:true,
+			//disabled:true,
-      itemType: "text",
+			itemType: 'text',
-    },
+		},
-    {
+		{
-      type: "slot",
+			type: 'slot',
-      prop: "userName",
+			prop: 'userName',
-      slotName: "account",
+			slotName: 'account',
-      label: "账户信息",
+			label: '账户信息',
-    },
+		},
-    {
+		{
-      type: "radio",
+			type: 'radio',
-      prop: "userType",
+			prop: 'userType',
-      label: "系统用户",
+			label: '系统用户',
-      required: true,
+			required: true,
-      disabled: true,
+			disabled: true,
-      border: true,
+			border: true,
-      data: [
+			data: [
-        {
+				{
-          label: "是",
+					label: '是',
-          id: 1,
+					id: 1,
-        },
+				},
-        {
+				{
-          label: "否",
+					label: '否',
-          id: 0,
+					id: 0,
-        },
+				},
-      ],
+			],
-    },
+		},
-    {
+		{
-      type: "select",
+			type: 'select',
-      label: "角色",
+			label: '角色',
-      prop: "roleIds",
+			prop: 'roleIds',
-      multiple: true,
+			multiple: true,
-      isLoad: {
+			isLoad: {
-        url: `/tenantRole/list?pageNum=1&pageSize=10000&tenantId=${sourceList.value.pagination.tenantId}`,
+				url: `/tenantRole/list?pageNum=1&pageSize=10000&tenantId=${sourceList.value.pagination.tenantId}`,
-        labelKey: "roleName",
+				labelKey: 'roleName',
-        labelVal: "roleId",
+				labelVal: 'roleId',
-        method: "get",
+				method: 'get',
-        resUrl: "rows",
+				resUrl: 'rows',
-      },
+			},
-    },
+		},
-    {
+		{
-      type: "input",
+			type: 'input',
-      prop: "phonenumber",
+			prop: 'phonenumber',
-      label: "手机号",
+			label: '手机号',
-      required: true,
+			required: true,
-      itemWidth: 50,
+			itemWidth: 50,
-      //disabled:true,
+			//disabled:true,
-      itemType: "text",
+			itemType: 'text',
-    },
+		},
-    {
+		{
-      type: "input",
+			type: 'input',
-      prop: "jobNumber",
+			prop: 'jobNumber',
-      label: "工号",
+			label: '工号',
-      required: true,
+			required: true,
-      itemWidth: 50,
+			itemWidth: 50,
-      //disabled:true,
+			//disabled:true,
-      itemType: "text",
+			itemType: 'text',
-    },
+		},
-  ];
+	]
-});
+})
 const newPassword = () => {
 const newPassword = () => {
-  formData.data.password = generatePassword();
+	formData.data.password = generatePassword()
-};
+}
 const generatePassword = () => {
 const generatePassword = () => {
-  var length = 12,
+	var length = 12,
-    charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+		charset =
-    password = "";
+			'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
-  for (var i = 0, n = charset.length; i < length; ++i) {
+		password = ''
-    password += charset.charAt(Math.floor(Math.random() * n));
+	for (var i = 0, n = charset.length; i < length; ++i) {
-  }
+		password += charset.charAt(Math.floor(Math.random() * n))
-  return password;
+	}
-};
+	return password
+}
 
 
 const getTreeList = () => {
 const getTreeList = () => {
-  proxy.post("/tenantInfo/list").then((message) => {
+	proxy.post('/tenantInfo/list').then((message) => {
-    message.map((item) => {
+		message.map((item) => {
-      item.label = item.enterpriseName;
+			item.label = item.enterpriseName
-      item.id = item.tenantId;
+			item.id = item.tenantId
-      item.children = [];
+			item.children = []
-    });
+		})
 
 
-    treeListData.value = message;
+		treeListData.value = message
-    console.log(treeListData.value);
+		console.log(treeListData.value)
-  });
+	})
-};
+}
 const getList = async (req) => {
 const getList = async (req) => {
-  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+	sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
-  loading.value = true;
+	loading.value = true
-  proxy.get("/tenantUser/list", sourceList.value.pagination).then((message) => {
+	proxy
-    message.rows.map((item) => {
+		.get('/tenantUser/list', sourceList.value.pagination)
-      item.deptName = item.dept ? item.dept.deptName : item.dept;
+		.then((message) => {
-    });
+			message.rows.map((item) => {
-    sourceList.value.data = message.rows;
+				item.deptName = item.dept ? item.dept.deptName : item.dept
-    sourceList.value.pagination.total = message.total;
+			})
-    setTimeout(() => {
+			sourceList.value.data = message.rows
-      loading.value = false;
+			sourceList.value.pagination.total = message.total
-    }, 200);
+			setTimeout(() => {
-  });
+				loading.value = false
-};
+			}, 200)
+		})
+}
 
 
 const treeChange = (e) => {
 const treeChange = (e) => {
-  console.log(e);
+	console.log(e)
-  sourceList.value.pagination.tenantId = e.id;
+	sourceList.value.pagination.tenantId = e.id
-  getList({ tenantId: e.id });
+	getList({ tenantId: e.id })
-  getDept()
+	getDept()
-
+}
-};
 
 
 const openModal = () => {
 const openModal = () => {
-  dialogVisible.value = true;
+	dialogVisible.value = true
-  modalType.value = "add";
+	modalType.value = 'add'
-  formData.data = {
+	formData.data = {
-    userType: 1,
+		userType: 1,
-  };
+	}
-};
+}
-const TreetenantId = ref("");
+const TreetenantId = ref('')
 const selection = ref({
 const selection = ref({
-  data: [],
+	data: [],
-});
+})
 const select = (_selection, row) => {
 const select = (_selection, row) => {
-  selection.value.data = _selection;
+	selection.value.data = _selection
-  console.log(_selection.length);
+	console.log(_selection.length)
-};
+}
 
 
-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";
+		const method = modalType.value == 'add' ? 'POST' : 'PUT'
-    console.log(method);
+		console.log(method)
-    proxy
+		proxy
-      .post(
+			.post(
-        "/tenantUser",
+				'/tenantUser',
-        {
+				{
-          ...formData.data,
+					...formData.data,
-          tenantId: sourceList.value.pagination.tenantId,
+					tenantId: sourceList.value.pagination.tenantId,
-        },
+				},
-        method
+				method
-      )
+			)
-      .then((res) => {
+			.then((res) => {
-        ElMessage({
+				ElMessage({
-          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+					message: modalType.value == 'add' ? '添加成功' : '编辑成功',
-          type: "success",
+					type: 'success',
-        });
+				})
-        dialogVisible.value = false;
+				dialogVisible.value = false
-        getList();
+				getList()
-      });
+			})
-  });
+	})
-};
+}
 const recursive = (data) => {
 const recursive = (data) => {
-  data.map((item) => {
+	data.map((item) => {
-    item.label = item.deptName;
+		item.label = item.deptName
-    item.id = item.deptId;
+		item.id = item.deptId
-    if (item.children) {
+		if (item.children) {
-      recursive(item.children);
+			recursive(item.children)
-    } else {
+		} else {
-      item.children = [];
+			item.children = []
-    }
+		}
-  });
+	})
-};
+}
 const getDept = () => {
 const getDept = () => {
-  proxy.get("/tenantDept/list", {
+	proxy
-    pageNum: 1,
+		.get('/tenantDept/list', {
-    tenantId: sourceList.value.pagination.tenantId,
+			pageNum: 1,
-  }).then((message) => {
+			tenantId: sourceList.value.pagination.tenantId,
-    recursive(message.data);
+		})
-    formConfig.value[0].data = proxy.handleTree(message.data, "deptId");
+		.then((message) => {
-    console.log(formConfig.value[0].data)
+			recursive(message.data)
-  });
+			formConfig.value[0].data = proxy.handleTree(message.data, 'deptId')
-};
+			console.log(formConfig.value[0].data)
+		})
+}
 
 
 const submitPassword = (password1) => {
 const submitPassword = (password1) => {
-  if (!password1) {
+	if (!password1) {
-    ElMessage({
+		ElMessage({
-      message: "请输入新密码",
+			message: '请输入新密码',
-      type: "warning",
+			type: 'warning',
-    });
+		})
-    return;
+		return
-  }
+	}
-  proxy
+	proxy
-    .post(
+		.post(
-      "/tenantUser/resetPwd",
+			'/tenantUser/resetPwd',
-      {
+			{
-        password: password1,
+				password: password1,
-        userId: userId.value,
+				userId: userId.value,
-      },
+			},
-      "PUT"
+			'PUT'
-    )
+		)
-    .then((res) => {
+		.then((res) => {
-      ElMessage({
+			ElMessage({
-        message: "重置成功",
+				message: '重置成功',
-        type: "success",
+				type: 'success',
-      });
+			})
-      roomDialogVisible.value = false;
+			roomDialogVisible.value = false
-      password.value = "";
+			password.value = ''
-    });
+		})
-};
+}
 
 
 const getDtl = (row) => {
 const getDtl = (row) => {
-  formData.data = { ...row };
+	formData.data = { ...row }
-  modalType.value = "edit";
+	modalType.value = 'edit'
-  console.log(modalType.value);
+	console.log(modalType.value)
-  dialogVisible.value = true;
+	dialogVisible.value = true
-};
+}
-getTreeList();
+getTreeList()
-getList();
+getList()
 </script>
 </script>
   
   
 <style lang="scss" scoped>
 <style lang="scss" scoped>
 .user {
 .user {
-  padding: 20px;
+	padding: 20px;
-  display: flex;
+	display: flex;
-  justify-content: space-between;
+	justify-content: space-between;
 
 
-  .tree {
+	.tree {
-    width: 300px;
+		width: 300px;
-  }
+	}
 
 
-  .content {
+	.content {
-    width: calc(100% - 320px);
+		width: calc(100% - 320px);
-  }
+	}
 }
 }
 </style>
 </style>