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

履职内容库管理调试

jiawuxian 2 жил өмнө
parent
commit
678d8ee3ee

+ 3 - 3
src/api/resumption/ruleManager.js

@@ -9,9 +9,9 @@ export function treeData() {
 }
 
 // 查询【请填写功能名称】列表
-export function list(query) {
+export function page(query) {
   return request({
-    url: '/core/resumption/ruleItem/list',
+    url: '/core/resumption/ruleItem/page',
     method: 'get',
     params: query
   })
@@ -37,7 +37,7 @@ export function get(id) {
 // 修改【请填写功能名称】
 export function update(data) {
   return request({
-    url: '/core/resumption/ruleItem',
+    url: '/core/resumption/ruleItem/edit',
     method: 'post',
     data: data
   })

+ 29 - 21
src/views/resumption/ruleManager/dialog.editItem.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="rule-type">
     <el-dialog
-      :title="!formData.id ? '新增检查项' : '编辑检查项'"
+      :title="!formData.id ? '新增履职项' : '编辑履职项'"
       :visible.sync="dialogVisible"
       width="60%"
       :show-close="true"
@@ -30,13 +30,12 @@
         <div class="box">
           <p>履职内容</p>
           <div style="margin-bottom: 10px">
-            <el-button type="primary" @click="onAddPoint(-1)">新增</el-button>
+            <el-button type="primary" @click="onEdit(-1)">新增</el-button>
           </div>
-          <el-table :data="formData.pointDtoList" border style="width: 100%">            
-            <el-table-column prop="name" label="履职要点">
-            </el-table-column>
+          <el-table :data="formData.pointDtoList" border style="width: 100%">
+            <el-table-column prop="name" label="履职要点"> </el-table-column>
             <el-table-column prop="areaName" label="履职区域">
-            </el-table-column>            
+            </el-table-column>
             <el-table-column label="操作" width="140">
               <template slot-scope="scope">
                 <el-button
@@ -45,11 +44,11 @@
                   @click="onEdit(scope.$index, scope.row)"
                   >编辑</el-button
                 >
-                <k-btn-tip
+                <el-button
                   type="text"
-                  :tip="'确定删除该条履职内容?'"
+                  size="small"
                   @click="delitem(scope.$index)"
-                  >删除</k-btn-tip
+                  >删除</el-button
                 >
               </template>
             </el-table-column>
@@ -62,7 +61,12 @@
         <el-button type="primary" @click="onSubmit()">保 存</el-button>
       </span>
     </el-dialog>
-    <EditPoint ref="editDialog" @submit="onPointSubmit"></EditPoint>
+    <EditPoint
+      ref="editDialog"
+      @submit="onPointSubmit"
+      :rule="rule"
+      v-bind="$attrs"
+    ></EditPoint>
   </div>
 </template>
 
@@ -76,12 +80,16 @@ export default {
     return {
       dialogVisible: false,
       formData: this.reset(),
-      formDataRules:{
-      name: [{ required: true, message: "请输入履职项" }],
-      }
+      formDataRules: {
+        name: [{ required: true, message: "请输入履职项" }],
+      },
     };
   },
-  props: {},
+  props: {
+    rule: {
+      type: Object,
+    },
+  },
   watch: {},
   computed: {
     ...mapState([]),
@@ -91,14 +99,14 @@ export default {
     reset() {
       return {
         id: null,
-        nme: null,
+        name: null,
         ruleId: null,
         pointDtoList: [],
       };
     },
 
     async show(id) {
-      const data = id ? await get(id) : this.reset();
+      const data = id ? (await get(id)).data : this.reset();
       this.formData = data;
       this.dialogVisible = true;
     },
@@ -107,29 +115,29 @@ export default {
       this.formData = this.reset();
     },
     async onSubmit() {
-      this.formData.ruleId = this.formruleID;
+      this.formData.ruleId = this.rule.id;
       await update(this.formData).then((v) => {
         console.log(v);
         this.formData = this.reset();
         this.dialogVisible = false;
-        this.getlist();
+        this.$emit("success");
       });
     },
     onclose() {
       this.dataVisible = false;
     },
     onEdit(index, row) {
-      this.$refs.editDialog.show(index, row);
+      this.$refs.editDialog.show(index, { ...row });
     },
     onPointSubmit(index, point) {
       if (index >= 0) {
-        this.$set(this.formData.pointDtoList, i, point);
+        this.$set(this.formData.pointDtoList, index, point);
       } else {
         this.formData.pointDtoList.push(point);
       }
     },
     delitem(val) {
-      this.formdetail.pointDtoList.splice(val, 1);
+      this.formData.pointDtoList.splice(val, 1);
     },
   },
   mounted() {},

+ 38 - 19
src/views/resumption/ruleManager/dialog.editPoint.vue

@@ -1,10 +1,11 @@
 <template>
   <div class="rule-type">
     <el-dialog
-      width="50%"
+      width="600px"
       :title="index >= 0 ? '编辑履职内容' : '新增履职内容'"
       :visible.sync="dataVisible"
       :show-close="false"
+      @close="()=>{this.$refs.form.resetFields();}"
       append-to-body
     >
       <div>
@@ -24,11 +25,10 @@
               @input="formData.pointNum = Number(formData.pointNum)"
             ></el-input>
           </el-form-item> -->
-          <el-form-item label="履职内容" prop="pointName">
+          <el-form-item label="履职内容" prop="name">
             <el-input
-              v-model="formData.pointName"
+              v-model="formData.name"
               placeholder="请输入履职内容"
-              @blur="check()"
               maxlength="100"
             ></el-input>
           </el-form-item>
@@ -36,6 +36,7 @@
             <el-select
               v-model="formData.areaId"
               placeholder="请选择履职区域"
+              @change="onAreaChanged"
               clearable
             >
               <el-option
@@ -53,10 +54,10 @@
               clearable
             >
               <el-option
-                v-for="item in dict.type.point_data_source"
-                :key="item.id"
-                :label="item.name"
-                :value="item.id"
+                v-for="item in pointDataSource"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
               ></el-option>
             </el-select>
           </el-form-item>
@@ -65,6 +66,7 @@
               type="textarea"
               v-model="formData.remark"
               maxlength="200"
+              :rows="3"
               clearable
             ></el-input>
           </el-form-item>
@@ -72,7 +74,7 @@
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="dataVisible = false">取 消</el-button>
-        <el-button type="primary" @click="onSubmit()" v-if="index>=0">{{
+        <el-button type="primary" @click="onSubmit()">{{
           index >= 0 ? "保 存" : "添 加"
         }}</el-button>
       </span>
@@ -82,9 +84,8 @@
 
 <script>
 import { mapState, mapMutations } from "vuex";
-import {allAreaByOrgtype} from '@/api/system/area'
+import { allAreaByOrgtype } from "@/api/system/area";
 export default {
-  dicts:['point_data_source'],
   data() {
     return {
       index: null,
@@ -94,13 +95,18 @@ export default {
         name: [{ required: true, message: "请输入履职内容" }],
         areaId: [{ required: true, message: "请选择履职区域" }],
       },
-      areas:[]
+      currentOrgType: null,
+      areas: [],
     };
   },
   props: {
-    orgType:{
-      type:String
-    }
+    rule: {
+      type: Object,
+    },
+    pointDataSource: {
+      type: Array,
+      default: [],
+    },
   },
   watch: {},
   computed: {
@@ -113,11 +119,13 @@ export default {
         id: null,
         name: null,
         areaId: null,
+        areaName: null,
         businessType: null,
         remark: null,
       };
     },
     async show(index, data) {
+      
       if (index >= 0) {
         this.index = index;
         this.formData = data;
@@ -125,9 +133,14 @@ export default {
         this.index = -1;
         this.formData = this.reset();
       }
-      allAreaByOrgtype(this.orgType).then(d=>{
-        this.areas=d;
-      })
+
+      // if (this.currentOrgType != this.rule.orgType) {
+      allAreaByOrgtype(this.rule.orgType).then((d) => {
+        this.currentOrgType = this.rule.orgType;
+        this.areas = d.data;
+      });
+      // }
+
       this.dataVisible = true;
     },
     onSubmit() {
@@ -135,7 +148,7 @@ export default {
         if (!isValidate) return;
         let obj = {};
         obj = { ...this.formData };
-        this.$emit("submit", obj);
+        this.$emit("submit", this.index, obj);
         this.dataVisible = false;
       });
     },
@@ -143,6 +156,12 @@ export default {
     onHide() {
       this.isShow = false;
     },
+    onAreaChanged(val) {
+      let area = this.areas.find((a) => a.id === val);
+      if (area) {
+        this.formData.areaName = area.name;
+      }
+    },
   },
   mounted() {},
   components: {},

+ 70 - 35
src/views/resumption/ruleManager/index.vue

@@ -8,10 +8,10 @@
         <el-tree
           class="filter-tree"
           :data="treedata"
-          node-key="value"
+          node-key="id"
           highlight-current
-          default-expand-all
-          :expand-on-click-node="false"
+          :expand-on-click-node="true"
+          :default-expanded-keys="topItemKeys"
           :filter-node-method="filterNode"
           accordion
           @node-click="clicktreenode"
@@ -35,7 +35,7 @@
         >
           <el-form-item prop="ruleItemName" label="履职项">
             <el-input
-              v-model="queryParams.ruleItemName"
+              v-model="queryParams.itemName"
               placeholder="请输入内容"
               maxlength="50"
               clearable
@@ -67,10 +67,18 @@
         <!--    按纽    -->
         <el-row :gutter="10" class="mb8">
           <el-col :span="1.5">
-            <el-button type="primary" @click="onEdit()">新 增</el-button>
-            <el-button type="warning" @click="dakai">{{
-              expandAll ? "收起所有行" : "展开所有行"
-            }}</el-button>
+            <el-button
+              type="primary"
+              @click="onAddItem()"
+              :disabled="rule ? false : true"
+              >新 增</el-button
+            >
+            <el-button
+              type="warning"
+              @click="dakai"
+              :disabled="rule ? false : true"
+              >{{ expandAll ? "收起所有行" : "展开所有行" }}</el-button
+            >
           </el-col>
           <!-- <el-col :span="1.5">
             <el-button
@@ -137,16 +145,13 @@
             </template>
           </el-table-column>
           <el-table-column
-            prop="itemNum"
+            prop="order"
             label="序号"
+            width="80"
             v-if="columns[0].visible"
           >
           </el-table-column>
-          <el-table-column
-            prop="itemName"
-            label="履职项"
-            v-if="columns[1].visible"
-          >
+          <el-table-column prop="name" label="履职项" v-if="columns[1].visible">
           </el-table-column>
           <!-- <el-table-column prop="itemDesc" label="标准及要求">
           </el-table-column> -->
@@ -161,15 +166,17 @@
               <el-button
                 type="text"
                 size="small"
-                @click="showdialog(scope.row.id)"
+                icon="el-icon-edit"
+                @click="onEditItem(scope.row.id)"
                 >编辑</el-button
+              > 
+                    
+              <el-popconfirm
+                title="将删除履职项及其下所有履职内容,确定删除?"
+                @confirm="deldata(scope.row.id)"
               >
-              <k-btn-tip
-                type="text"
-                :tip="'将删除履职项及其下所有履职内容,确定删除?'"
-                @click="deldata(scope.row.id)"
-                >删除</k-btn-tip
-              >
+                <el-button type="text" size="small" slot="reference" icon="el-icon-delete">删除</el-button>
+              </el-popconfirm>
             </template>
           </el-table-column>
         </el-table>
@@ -186,30 +193,37 @@
         </el-pagination>
       </el-col>
     </el-row>
-    <dialog-edit ref="dialogEdit" :rule="rule"></dialog-edit>
+    <dialog-edit
+      ref="dialogEdit"
+      :rule="rule"
+      :pointDataSource="dict.type.point_data_source"
+      @success="onSuccess"
+    ></dialog-edit>
   </div>
 </template>
 
 <script>
 import { mapState, mapMutations } from "vuex";
-import { list, treeData,del } from "@/api/resumption/ruleManager.js";
+import { page, treeData, del } from "@/api/resumption/ruleManager.js";
 import DialogEdit from "./dialog.editItem.vue";
 
 export default {
   name: "resumptionRuleManager",
   props: [],
+  dicts: ["point_data_source"],
   data() {
     return {
       queryParams: {
         ruleId: null,
-        ruleItemName: null,
+        itemName: null,
         pointName: null,
         currentPage: 1,
         pagesize: 10,
       },
-      filterText:null,
+      filterText: null,
       showSearch: true,
       rule: null, //选中的内容库
+
       expandAll: false,
       fresh: true,
       // checked: false,
@@ -221,7 +235,7 @@ export default {
       tableData: [],
 
       total: 0,
-
+      topItemKeys: [],
       // defaultProps: {
       //   children: "children",
       //   label: "label",
@@ -276,14 +290,19 @@ export default {
       this.getList();
     },
     async getList() {
-      const data = await list(this.queryParams);
+      if (!this.rule) {
+        this.$message.warning("请先选择一个履职内容库定义");
+        return;
+      }
+      const data = await page(this.queryParams);
       this.tableData = data.rows;
       this.total = data.total;
       this.expandAll = false;
     },
     async gettreelist() {
       await treeData().then((v) => {
-        this.treedata = v;
+        this.treedata = v.data;
+        this.topItemKeys = v.data.map((d) => d.id);
       });
     },
     handleSizeChange(val) {
@@ -295,17 +314,20 @@ export default {
       this.getList();
     },
     clicktreenode(data) {
+      if (!data.isRule) {
+        return;
+      }
+
       this.expandAll = false;
       this.fresh = false;
       this.$nextTick(() => {
         this.fresh = true;
       });
-      if (data.isRule) {
-        this.queryParams.ruleId = data.id;
-        this.rule = data;
-        this.refresh();
-      }
-    },   
+
+      this.queryParams.ruleId = data.id;
+      this.rule = data;
+      this.refresh();
+    },
     async deldata(val) {
       await del(val);
       this.getList();
@@ -317,13 +339,26 @@ export default {
       this.$refs.tree.setCurrentKey(null);
       this.tableData = [];
     },
+    onAddItem() {
+      if (!this.rule) {
+        this.$message.warning("请先选择履职内容库");
+        return;
+      }
+      this.$refs.dialogEdit.show(null);
+    },
+    onEditItem(itemId) {
+      this.$refs.dialogEdit.show(itemId);
+    },
+    onSuccess(){
+      this.refresh();
+    }
   },
 };
 </script>
 <style lang="scss" scoped>
 .show-ellipsis {
   display: block;
-  width: 150px;
+  width: 180px;
   overflow: hidden;
   white-space: nowrap;
   text-overflow: ellipsis;