Эх сурвалжийг харах

岗位管理新增弹框标题修改

wangyani 8 сар өмнө
parent
commit
70dc25ca76
1 өөрчлөгдсөн 283 нэмэгдсэн , 218 устгасан
  1. 283 218
      src/views/system/mars/index.vue

+ 283 - 218
src/views/system/mars/index.vue

@@ -1,15 +1,21 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
-<!--      <el-form-item label="岗位编码" prop="workstationCode">-->
-<!--        <el-input-->
-<!--          v-model="queryParams.workstationCode"-->
-<!--          placeholder="请输入部门编码"-->
-<!--          clearable-->
-<!--          @keyup.enter.native="handleQuery"-->
-<!--        />-->
+    <el-form
+      :model="queryParams"
+      ref="queryForm"
+      size="small"
+      :inline="true"
+      v-show="showSearch"
+    >
+      <!--      <el-form-item label="岗位编码" prop="workstationCode">-->
+      <!--        <el-input-->
+      <!--          v-model="queryParams.workstationCode"-->
+      <!--          placeholder="请输入部门编码"-->
+      <!--          clearable-->
+      <!--          @keyup.enter.native="handleQuery"-->
+      <!--        />-->
 
-<!--      </el-form-item>-->
+      <!--      </el-form-item>-->
       <el-form-item label="岗位名称" prop="workstationName">
         <el-input
           v-model="queryParams.workstationName"
@@ -34,34 +40,50 @@
         </el-select>
       </el-form-item>
       <el-form-item>
-        <el-button v-no-more-click type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
+        <el-button
+          v-no-more-click
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+          >搜索
         </el-button>
-        <el-button v-no-more-click icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+        <el-button
+          v-no-more-click
+          icon="el-icon-refresh"
+          size="mini"
+          @click="resetQuery"
+          >重置</el-button
+        >
       </el-form-item>
     </el-form>
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button v-no-more-click
-                   type="primary"
-                   plain
-                   icon="el-icon-plus"
-                   size="mini"
-                   @click="handleAdd"
-                   v-hasPermi="['iscs:workstation:add']"
-        >新增
+        <el-button
+          v-no-more-click
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['iscs:workstation:add']"
+          >新增
         </el-button>
       </el-col>
-<!--      <el-col :span="1.5">-->
-<!--        <el-button v-no-more-click-->
-<!--                   type="info"-->
-<!--                   plain-->
-<!--                   icon="el-icon-sort"-->
-<!--                   size="mini"-->
-<!--                   @click="toggleExpandAll"-->
-<!--        >展开/折叠-->
-<!--        </el-button>-->
-<!--      </el-col>-->
-      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+      <!--      <el-col :span="1.5">-->
+      <!--        <el-button v-no-more-click-->
+      <!--                   type="info"-->
+      <!--                   plain-->
+      <!--                   icon="el-icon-sort"-->
+      <!--                   size="mini"-->
+      <!--                   @click="toggleExpandAll"-->
+      <!--        >展开/折叠-->
+      <!--        </el-button>-->
+      <!--      </el-col>-->
+      <right-toolbar
+        :showSearch.sync="showSearch"
+        @queryTable="getList"
+      ></right-toolbar>
     </el-row>
 
     <el-table
@@ -70,11 +92,19 @@
       :data="deptList"
       row-key="workstationId"
       :default-expand-all="isExpandAll"
-      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
+      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
     >
-<!--      <el-table-column prop="workstationCode" label="岗位编码" width="260"></el-table-column>-->
-      <el-table-column prop="workstationName" label="岗位名称" width="300"></el-table-column>
-      <el-table-column prop="orderNum" label="排序" width="260"></el-table-column>
+      <!--      <el-table-column prop="workstationCode" label="岗位编码" width="260"></el-table-column>-->
+      <el-table-column
+        prop="workstationName"
+        label="岗位名称"
+        width="300"
+      ></el-table-column>
+      <el-table-column
+        prop="orderNum"
+        label="排序"
+        width="260"
+      ></el-table-column>
       <el-table-column prop="status" label="状态" width="260">
         <template slot-scope="scope">
           <el-switch
@@ -87,103 +117,121 @@
       </el-table-column>
       <el-table-column prop="workstationType" label="岗位人员" width="100">
         <template slot-scope="scope">
-          <el-button type="text" @click="HandleLookWorkStation(scope.row)">查看</el-button>
+          <el-button type="text" @click="HandleLookWorkStation(scope.row)"
+            >查看</el-button
+          >
         </template>
       </el-table-column>
-<!--      <el-table-column label="创建时间" align="center" prop="createTime" width="200">-->
-<!--        <template slot-scope="scope">-->
-<!--          <span>{{ parseTime(scope.row.createTime) }}</span>-->
-<!--        </template>-->
-<!--      </el-table-column>-->
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+      <!--      <el-table-column label="创建时间" align="center" prop="createTime" width="200">-->
+      <!--        <template slot-scope="scope">-->
+      <!--          <span>{{ parseTime(scope.row.createTime) }}</span>-->
+      <!--        </template>-->
+      <!--      </el-table-column>-->
+      <el-table-column
+        label="操作"
+        align="center"
+        class-name="small-padding fixed-width"
+      >
         <template slot-scope="scope">
-          <el-button v-no-more-click
-                     size="mini"
-                     type="text"
-                     icon="el-icon-edit"
-                     @click="handleUpdate(scope.row)"
-                     v-hasPermi="['iscs:workstation:edit']"
-          >修改
+          <el-button
+            v-no-more-click
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['iscs:workstation:edit']"
+            >修改
           </el-button>
-          <el-button v-no-more-click
-                     size="mini"
-                     type="text"
-                     icon="el-icon-plus"
-                     @click="handleAdd(scope.row)"
-                     v-hasPermi="['iscs:workstation:add']"
-          >新增
+          <el-button
+            v-no-more-click
+            size="mini"
+            type="text"
+            icon="el-icon-plus"
+            @click="handleAdd(scope.row)"
+            v-hasPermi="['iscs:workstation:add']"
+            >新增
           </el-button>
-<!--          v-if="scope.row.parentId != 0"-->
-          <el-button v-no-more-click
-
-                     size="mini"
-                     type="text"
-                     icon="el-icon-delete"
-                     @click="handleDelete(scope.row)"
-                     v-hasPermi="['iscs:workstation:remove']"
-          >删除
+          <!--          v-if="scope.row.parentId != 0"-->
+          <el-button
+            v-no-more-click
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['iscs:workstation:remove']"
+            >删除
           </el-button>
         </template>
       </el-table-column>
     </el-table>
-<!--    <pagination-->
-<!--      v-show="total > 0"-->
-<!--      :total="total"-->
-<!--      :page.sync="queryParams.pages"-->
-<!--      :limit.sync="queryParams.size"-->
-<!--      @pagination="getList"-->
-<!--    />-->
+    <!--    <pagination-->
+    <!--      v-show="total > 0"-->
+    <!--      :total="total"-->
+    <!--      :page.sync="queryParams.pages"-->
+    <!--      :limit.sync="queryParams.size"-->
+    <!--      @pagination="getList"-->
+    <!--    />-->
     <!-- 添加或修改部门对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="480px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-
         <el-form-item label="上级" prop="parentId" v-if="form.parentId !== 0">
-          <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级"/>
+          <treeselect
+            v-model="form.parentId"
+            :options="deptOptions"
+            :normalizer="normalizer"
+            placeholder="选择上级"
+          />
         </el-form-item>
 
         <el-form-item label="岗位名称" prop="workstationName">
-          <el-input v-model="form.workstationName" placeholder="请输入岗位名称"/>
+          <el-input
+            v-model="form.workstationName"
+            placeholder="请输入岗位名称"
+          />
+        </el-form-item>
+        <!--        <el-row>-->
+        <!--          <el-col :span="18">-->
+        <!--            <el-form-item label="岗位编号" prop="workstationCode">-->
+        <!--              <el-input-->
+        <!--                v-model="form.workstationCode"-->
+        <!--                placeholder="请输入岗位编号"-->
+        <!--              />-->
+        <!--            </el-form-item>-->
+        <!--          </el-col>-->
+        <!--          <el-col :span="6">-->
+        <!--            <el-form-item label-width="30">-->
+        <!--              <el-switch-->
+        <!--                v-model="autoGenFlag"-->
+        <!--                active-color="#13ce66"-->
+        <!--                active-text="自动生成"-->
+        <!--                @change="handleAutoGenChange(autoGenFlag)"-->
+        <!--              >-->
+        <!--              </el-switch>-->
+        <!--            </el-form-item>-->
+        <!--          </el-col>-->
+        <!--        </el-row>-->
+        <el-form-item label="排序" prop="orderNum">
+          <el-input-number type="number" v-model="form.orderNum" />
         </el-form-item>
-<!--        <el-row>-->
-<!--          <el-col :span="18">-->
-<!--            <el-form-item label="岗位编号" prop="workstationCode">-->
-<!--              <el-input-->
-<!--                v-model="form.workstationCode"-->
-<!--                placeholder="请输入岗位编号"-->
-<!--              />-->
-<!--            </el-form-item>-->
-<!--          </el-col>-->
-<!--          <el-col :span="6">-->
-<!--            <el-form-item label-width="30">-->
-<!--              <el-switch-->
-<!--                v-model="autoGenFlag"-->
-<!--                active-color="#13ce66"-->
-<!--                active-text="自动生成"-->
-<!--                @change="handleAutoGenChange(autoGenFlag)"-->
-<!--              >-->
-<!--              </el-switch>-->
-<!--            </el-form-item>-->
-<!--          </el-col>-->
-<!--        </el-row>-->
-                <el-form-item label="排序" prop="orderNum">
-                  <el-input-number type="number" v-model="form.orderNum" />
-                </el-form-item>
 
-          <el-form-item label="状态" prop="status">
-            <el-radio-group v-model="form.status">
-              <el-radio
-                v-for="dict in dict.type.sys_normal_disable"
-                :key="dict.value"
-                :label="dict.value"
-              >{{dict.label}}</el-radio>
-            </el-radio-group>
-          </el-form-item>
-<!--        <el-form-item label="岗位类型" prop="workstationType">-->
-<!--          <el-input v-model="form.workstationType" placeholder="请输入岗位类型" maxlength="20"/>-->
-<!--        </el-form-item>-->
+        <el-form-item label="状态" prop="status">
+          <el-radio-group v-model="form.status">
+            <el-radio
+              v-for="dict in dict.type.sys_normal_disable"
+              :key="dict.value"
+              :label="dict.value"
+              >{{ dict.label }}</el-radio
+            >
+          </el-radio-group>
+        </el-form-item>
+        <!--        <el-form-item label="岗位类型" prop="workstationType">-->
+        <!--          <el-input v-model="form.workstationType" placeholder="请输入岗位类型" maxlength="20"/>-->
+        <!--        </el-form-item>-->
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button v-no-more-click type="primary" @click="submitForm">确 定</el-button>
+        <el-button v-no-more-click type="primary" @click="submitForm"
+          >确 定</el-button
+        >
         <el-button v-no-more-click @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
@@ -197,16 +245,17 @@ import {
   getMarsDept,
   addMarsDept,
   updateMarsDept,
-  delMarsDept, updateMarsDeptStatus
-} from '@/api/system/marsdept'
-import Treeselect from '@riophae/vue-treeselect'
-import '@riophae/vue-treeselect/dist/vue-treeselect.css'
-import { genCode } from '@/api/system/autocode/rule'
-import { listUnit } from '@/api/system/unit'
+  delMarsDept,
+  updateMarsDeptStatus,
+} from "@/api/system/marsdept";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import { genCode } from "@/api/system/autocode/rule";
+import { listUnit } from "@/api/system/unit";
 
 export default {
-  name: 'Dept',
-  dicts: ['sys_normal_disable'],
+  name: "Dept",
+  dicts: ["sys_normal_disable"],
   components: { Treeselect },
   data() {
     return {
@@ -216,13 +265,13 @@ export default {
       autoGenFlag: false,
       // 显示搜索条件
       showSearch: true,
-      total:0,//
+      total: 0, //
       // 表格树数据
       deptList: [],
       // 部门树选项
       deptOptions: [],
       // 弹出层标题
-      title: '',
+      title: "",
       // 是否显示弹出层
       open: false,
       // 是否展开,默认全部展开
@@ -231,87 +280,94 @@ export default {
       refreshTable: true,
       // 查询参数
       queryParams: {
-        current:1,
-        size:-1,
+        current: 1,
+        size: -1,
         workstationName: undefined,
         status: undefined,
-        userId:undefined,//勿删
+        userId: undefined, //勿删
       },
       // 表单参数
       form: {},
       // 表单校验
       rules: {
         parentId: [
-          { required: true, message: '上级部门不能为空', trigger: 'blur' }
+          { required: true, message: "上级部门不能为空", trigger: "blur" },
         ],
         workstationName: [
-          { required: true, message: '部门名称不能为空', trigger: 'blur' }
+          { required: true, message: "部门名称不能为空", trigger: "blur" },
         ],
-      }
-    }
+      },
+    };
   },
-watch: {
-  "$route.query.userId": {
-    immediate: true,
-    handler(val) {
-      console.log(val,'用户id')
+  watch: {
+    "$route.query.userId": {
+      immediate: true,
+      handler(val) {
+        console.log(val, "用户id");
 
         this.queryParams.userId = val;
-      this.getList();
-
-    }
-  }
-},
+        this.getList();
+      },
+    },
+  },
 
   created() {
-    this.getList()
+    this.getList();
   },
   methods: {
     // 用户状态修改
     handleStatusChange(row) {
       let text = row.status === "0" ? "启用" : "停用";
-      this.$modal.confirm('确认要"' + text + '""' + row.workstationName + '"岗位吗?').then(function() {
-        const data={
-          workstationId:row.workstationId,
-          status:row.status,
-        }
-        return updateMarsDeptStatus(data);
-      }).then(() => {
-        this.$modal.msgSuccess(text + "成功");
-      }).catch(function() {
-        row.status = row.status === "0" ? "1" : "0";
-      });
+      this.$modal
+        .confirm('确认要"' + text + '""' + row.workstationName + '"岗位吗?')
+        .then(function () {
+          const data = {
+            workstationId: row.workstationId,
+            status: row.status,
+          };
+          return updateMarsDeptStatus(data);
+        })
+        .then(() => {
+          this.$modal.msgSuccess(text + "成功");
+        })
+        .catch(function () {
+          row.status = row.status === "0" ? "1" : "0";
+        });
     },
     /** 查询部门列表 */
     getList() {
-      this.loading = true
-      listMarsDept(this.queryParams).then(response => {
+      this.loading = true;
+      listMarsDept(this.queryParams).then((response) => {
         debugger;
-        this.deptList = this.handleTree(response.data.records,"workstationId","parentId")
-        console.log(this.deptList,'岗位列表')
-        this.loading = false
-        this.total=response.data.total
-      })
+        this.deptList = this.handleTree(
+          response.data.records,
+          "workstationId",
+          "parentId"
+        );
+        console.log(this.deptList, "岗位列表");
+        this.loading = false;
+        this.total = response.data.total;
+      });
     },
     /** 转换部门数据结构 */
     normalizer(node) {
       if (node.children && !node.children.length) {
-        delete node.children
+        delete node.children;
       }
       return {
         id: node.workstationId,
         label: node.workstationName,
-        children: node.children
-      }
+        children: node.children,
+      };
     },
     // 岗位人员查看页面跳转
-    HandleLookWorkStation(row){
-      this.$router.push('/user/user?workstationId='+row.workstationId)
+    HandleLookWorkStation(row) {
+      this.$router.push("/user/user?workstationId=" + row.workstationId);
     },
     // 取消按钮
     cancel() {
-      this.open = false
-      this.reset()
+      this.open = false;
+      this.reset();
     },
     // 表单重置
     reset() {
@@ -320,15 +376,15 @@ watch: {
         parentId: undefined,
         workstationName: undefined,
         userId: undefined,
-      }
+      };
       this.autoGenFlag = false;
-      this.resetForm('form')
+      this.resetForm("form");
     },
     //自动生成编码
     handleAutoGenChange(autoGenFlag) {
       if (autoGenFlag) {
         genCode("MARS_WORKSTATION").then((response) => {
-          console.log(response,'玛氏编码');
+          console.log(response, "玛氏编码");
           this.form.workstationCode = response;
         });
       } else {
@@ -337,83 +393,92 @@ watch: {
     },
     /** 搜索按钮操作 */
     handleQuery() {
-      this.getList()
+      this.getList();
     },
     /** 重置按钮操作 */
     resetQuery() {
-      this.queryParams.userId = undefined
-      this.queryParams.unitName= ''
-      this.queryParams.status = undefined
-      this.resetForm('queryForm')
-      this.handleQuery()
-      this.$router.push('/user/mars')
-
+      this.queryParams.userId = undefined;
+      this.queryParams.unitName = "";
+      this.queryParams.status = undefined;
+      this.resetForm("queryForm");
+      this.handleQuery();
+      this.$router.push("/user/mars");
     },
     /** 新增按钮操作 */
     handleAdd(row) {
-      this.reset()
+      this.reset();
       if (row != null && row.workstationId) {
         this.form.parentId = row.workstationId;
       } else {
         this.form.parentId = 0;
       }
-      this.open = true
-      this.title = '添加岗位'
-      listMarsDept(this.queryParams).then(response => {
-        this.deptOptions = this.handleTree(response.data.records,"workstationId","parentId")
-      })
+      this.open = true;
+      this.title = "新增岗位";
+      listMarsDept(this.queryParams).then((response) => {
+        this.deptOptions = this.handleTree(
+          response.data.records,
+          "workstationId",
+          "parentId"
+        );
+      });
     },
     /** 展开/折叠操作 */
     toggleExpandAll() {
-      this.refreshTable = false
-      this.isExpandAll = !this.isExpandAll
+      this.refreshTable = false;
+      this.isExpandAll = !this.isExpandAll;
       this.$nextTick(() => {
-        this.refreshTable = true
-      })
+        this.refreshTable = true;
+      });
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
-      this.reset()
-      listMarsDept(row.workstationId).then(response => {
-        this.deptOptions = this.handleTree(response.data.records,"workstationId","parentId")
-      })
-      getMarsDept(row.workstationId).then(response => {
-        this.form=response.data
-        this.open = true
-        this.title = '修改岗位'
-      })
-
+      this.reset();
+      listMarsDept(row.workstationId).then((response) => {
+        this.deptOptions = this.handleTree(
+          response.data.records,
+          "workstationId",
+          "parentId"
+        );
+      });
+      getMarsDept(row.workstationId).then((response) => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改岗位";
+      });
     },
     /** 提交按钮 */
-    submitForm: function() {
-      this.$refs['form'].validate(valid => {
+    submitForm: function () {
+      this.$refs["form"].validate((valid) => {
         if (valid) {
           if (this.form.workstationId != undefined) {
-            updateMarsDept(this.form).then(response => {
-              this.$modal.msgSuccess('修改成功')
-              this.open = false
-              this.getList()
-            })
+            updateMarsDept(this.form).then((response) => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
           } else {
-            addMarsDept(this.form).then(response => {
-              this.$modal.msgSuccess('新增成功')
-              this.open = false
-              this.getList()
-            })
+            addMarsDept(this.form).then((response) => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
           }
         }
-      })
+      });
     },
     /** 删除按钮操作 */
     handleDelete(row) {
-      this.$modal.confirm('是否确认删除名称为"' + row.workstationName + '"的数据项?').then(function() {
-        return delMarsDept(row.workstationId)
-      }).then(() => {
-        this.getList()
-        this.$modal.msgSuccess('删除成功')
-      }).catch(() => {
-      })
-    }
-  }
-}
+      this.$modal
+        .confirm('是否确认删除名称为"' + row.workstationName + '"的数据项?')
+        .then(function () {
+          return delMarsDept(row.workstationId);
+        })
+        .then(() => {
+          this.getList();
+          this.$modal.msgSuccess("删除成功");
+        })
+        .catch(() => {});
+    },
+  },
+};
 </script>