huangguoce 5 месяцев назад
Родитель
Сommit
acd8ca45b4
3 измененных файлов с 37 добавлено и 18 удалено
  1. 17 0
      src/api/test/dd/dd.js
  2. 16 18
      src/views/dd/DeptForm.vue
  3. 4 0
      src/views/dd/DeptList.vue

+ 17 - 0
src/api/test/dd/dd.js

@@ -47,4 +47,21 @@ export default {
 			data: data,
 		});
 	},
+
+	// 修改部门
+	updateDept(data) {
+		return request({
+			url: prefix + "/test/addressBook/updateDept",
+			method: "post",
+			data: data,
+		});
+	},
+
+	queryById(params) {
+		return request({
+			url: prefix + "/test/addressBook/queryById",
+			method: "get",
+			params: params,
+		});
+	},
 };

+ 16 - 18
src/views/dd/DeptForm.vue

@@ -103,14 +103,13 @@ export default {
 			if (method === 'add') {
 				this.title = `创建部门`
 			} else if (method === 'edit') {
-				this.inputForm.id = id
-				this.title = '修改附件'
+				this.inputForm.deptId = id
+				this.title = '修改部门'
 			}
-			this.loading = false
 			this.visible = true
 			this.$nextTick(() => {
-				this.$refs.inputForm.resetFields()
 				this.loading = true
+				this.$refs.inputForm.resetFields()
 				ddService.deptList().then(res => {
 					res.result.unshift({
 						deptId: 1,
@@ -118,12 +117,20 @@ export default {
 						isLeaf: true
 					})
 					this.deptList = res.result
+					if (this.commonJS.isNotEmpty(this.inputForm.deptId)) {
+						ddService.queryById({
+							deptId: this.inputForm.deptId
+						}).then(res => {
+							this.inputForm.name = res.result.name
+							this.inputForm.parentId = res.result.parentId
+							this.loading = false
+						})
+					} else {
+						this.loading = false
 
+					}
 				})
-				if (this.commonJS.isNotEmpty(this.inputForm.id)) {
 
-				}
-				this.loading = false
 			})
 		},
 		// 表单提交
@@ -132,8 +139,8 @@ export default {
 			this.$refs['inputForm'].validate((valid) => {
 				if (valid) {
 					this.loading = true
-					if (this.inputForm.id) {
-						ddService.updateById(this.inputForm).then((data) => {
+					if (this.inputForm.deptId) {
+						ddService.updateDept(this.inputForm).then((data) => {
 							this.visible = false
 							this.$emit('refreshList')
 						}).catch(() => {
@@ -141,8 +148,6 @@ export default {
 							this.loading = false
 						})
 					} else {
-						console.log(this.inputForm);
-
 						ddService.addDept(this.inputForm).then((data) => {
 							this.visible = false
 							this.$emit('refreshList')
@@ -162,13 +167,6 @@ export default {
 			}
 			this.visible = false
 		},
-		async updateStatusById(type, callback) {
-			this.loading = true
-			workCollectAccessoryService.updateStatusById(param).then(() => {
-				this.loading = false
-				callback()
-			})
-		},
 	}
 
 }

+ 4 - 0
src/views/dd/DeptList.vue

@@ -35,6 +35,7 @@
                     </vxe-column>
                     <vxe-column fixed="right" align="center" width="320" title="操作">
                         <template #default="scope">
+                            <el-button type="success" text @click="handleEdit(scope.row)">修改</el-button>
                             <el-button type="danger" text @click="handleDel(scope.row)">删除</el-button>
                         </template>
                     </vxe-column>
@@ -201,6 +202,9 @@ export default {
             console.log(id);
             this.$refs.workCollectAccessoryRef.init("edit", id)
         },
+        handleEdit(row) {
+            this.$refs.deptRef.init("edit", row.deptId)
+        },
         // 查看
         view(id) {
             id =