浏览代码

新增添加岗位到指定部门

DYaiu 4 年之前
父节点
当前提交
b97e8b345f
共有 2 个文件被更改,包括 30 次插入1 次删除
  1. 12 0
      src/api/treeAndTable.js
  2. 18 1
      src/views/treeAndTable/tree_and_table.vue

+ 12 - 0
src/api/treeAndTable.js

@@ -55,4 +55,16 @@ export function getJob(parent) {
         method: 'get',
         params: parent
     })
+}
+
+/**
+ * 新增岗位到对应部门接口
+ * {"dept_id":"33","name":"舍长"}
+ */
+export function postJob(data) {
+    return request({
+        url: url.Job,
+        method: 'post',
+        data
+    })
 }

+ 18 - 1
src/views/treeAndTable/tree_and_table.vue

@@ -39,7 +39,7 @@
 
 <script>
 import tree from "@/views/treeAndTable/components/tree";
-import { getJob } from "@/api/treeAndTable.js";
+import { getJob, postJob } from "@/api/treeAndTable.js";
 
 export default {
   name: "tree_table",
@@ -88,6 +88,23 @@ export default {
       this.dialog.name = "";
       this.dialog.visible = false;
     },
+    dataFormSubmitHandle: function () {
+      if (this.dialog.type == 2) {
+        postJob({
+          dept_id: this.dept_id,
+          name: this.dialog.name,
+        }).then((res) => {
+          this.dialog.visible = false;
+          if (res.data.msg == "success") {
+            this.$message({
+              message: "新增岗位成功",
+              type: "success",
+            });
+            this.tabClick({ name: "job" });
+          }
+        });
+      }
+    },
   },
 };
 </script>