From bce10b2db48c97a23543189368ceb6a8f3737fb3 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 03 四月 2024 14:24:46 +0800
Subject: [PATCH] 核算ui+考核结果ui

---
 src/views/system/calculate/rule/index.vue |  322 +++++++++++++++++++++++++----------------------------
 1 files changed, 154 insertions(+), 168 deletions(-)

diff --git a/src/views/system/calculate/rule/index.vue b/src/views/system/calculate/rule/index.vue
index fd45f98..3054654 100644
--- a/src/views/system/calculate/rule/index.vue
+++ b/src/views/system/calculate/rule/index.vue
@@ -1,36 +1,5 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
-      <el-form-item label="瑙勫垯鍚嶇О" prop="rulesName">
-        <el-input
-          v-model="queryParams.rulesName"
-          placeholder="璇疯緭鍏ヨ鍒欏悕绉�"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="鍚堝悓鍚嶇О" prop="contractName">
-        <el-input
-          v-model="queryParams.contractName"
-          placeholder="璇疯緭鍏ュ悎鍚屽悕绉�"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="閫昏緫鍒犻櫎" prop="deleted">
-        <el-input
-          v-model="queryParams.deleted"
-          placeholder="璇疯緭鍏ラ�昏緫鍒犻櫎"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
-        <el-button 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
@@ -39,54 +8,37 @@
           icon="el-icon-plus"
           size="mini"
           @click="handleAdd"
-        >鏂板
-        </el-button>
+          v-hasPermi="['system:rule:add']"
+        >鏂板</el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button
-          type="success"
+          type="info"
           plain
-          icon="el-icon-edit"
+          icon="el-icon-sort"
           size="mini"
-          :disabled="single"
-          @click="handleUpdate"
-        >淇敼
-        </el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="danger"
-          plain
-          icon="el-icon-delete"
-          size="mini"
-          :disabled="multiple"
-          @click="handleDelete"
-        >鍒犻櫎
-        </el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="warning"
-          plain
-          icon="el-icon-download"
-          size="mini"
-          @click="handleExport"
-        >瀵煎嚭
-        </el-button>
+          @click="toggleExpandAll"
+        >灞曞紑/鎶樺彔</el-button>
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="rulesList" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55" align="center"/>
-      <el-table-column label="瑙勫垯鍚嶇О" align="center" prop="rulesName"/>
-      <el-table-column label="鍚堝悓鍚嶇О" align="center" prop="contractName"/>
-      <el-table-column label="閲戦" align="center" prop="amount"/>
-      <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
+    <el-table
+      v-if="refreshTable"
+      v-loading="loading"
+      :data="ruleList"
+      row-key="id"
+      :default-expand-all="isExpandAll"
+      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
+    >
+      <el-table-column label="瑙勫垯鍚嶇О" prop="name" />
+      <el-table-column label="鍗曚綅id" align="center" prop="unitId" >
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
+          <div v-if="scope.row.unitId == 2">鎴愰兘x杩愮淮</div>
         </template>
       </el-table-column>
+      <el-table-column label="鎵e垎绯绘暟" align="center" prop="value" />
+      <el-table-column label="瑙勫垯鎻忚堪" align="center" prop="description" />
       <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -94,38 +46,46 @@
             type="text"
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
-          >淇敼
-          </el-button>
+            v-hasPermi="['system:rule:edit']"
+          >淇敼</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-plus"
+            @click="handleAdd(scope.row)"
+            v-hasPermi="['system:rule:add']"
+          >鏂板</el-button>
           <el-button
             size="mini"
             type="text"
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
-          >鍒犻櫎
-          </el-button>
+            v-hasPermi="['system:rule:remove']"
+          >鍒犻櫎</el-button>
         </template>
       </el-table-column>
     </el-table>
 
-    <pagination
-      v-show="total>0"
-      :total="total"
-      :page.sync="queryParams.pageNum"
-      :limit.sync="queryParams.pageSize"
-      @pagination="getList"
-    />
-
     <!-- 娣诲姞鎴栦慨鏀规牳绠楄鍒欏璇濇 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="瑙勫垯鍚嶇О" prop="rulesName">
-          <el-input v-model="form.rulesName" placeholder="璇疯緭鍏ヨ鍒欏悕绉�"/>
+        <el-form-item label="瑙勫垯鍚�" prop="name">
+          <el-input v-model="form.name" placeholder="璇疯緭鍏�" />
         </el-form-item>
-        <el-form-item label="鍚堝悓鍚嶇О" prop="contractName">
-          <el-input v-model="form.contractName" placeholder="璇疯緭鍏ュ悎鍚屽悕绉�"/>
+        <el-form-item label="妯℃澘鍚�" prop="templateId">
+          <el-input v-model="form.templateId" placeholder="璇疯緭鍏�" />
         </el-form-item>
-        <el-form-item label="閲戦" prop="amount">
-          <el-input v-model="form.amount" placeholder="璇疯緭鍏ラ噾棰�"/>
+        <el-form-item label="鐖惰鍒�" prop="parentId">
+          <treeselect v-model="form.parentId" :options="ruleOptions" :normalizer="normalizer" placeholder="璇烽�夋嫨" />
+        </el-form-item>
+        <el-form-item label="鑰冩牳瀵硅薄" prop="unitId">
+          <el-input v-model="form.unitId" placeholder="璇疯緭鍏ュ崟浣峣d" />
+        </el-form-item>
+        <el-form-item label="鎵e垎绯绘暟" prop="value">
+          <el-input v-model="form.value" placeholder="璇疯緭鍏ユ墸鍒嗙郴鏁�" />
+        </el-form-item>
+        <el-form-item label="瑙勫垯鎻忚堪" prop="description">
+          <el-input v-model="form.description" placeholder="璇疯緭鍏ヨ鍒欐弿杩�" />
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -137,144 +97,170 @@
 </template>
 
 <script>
-import { listRules, getRules, delRules, addRules, updateRules } from '@/api/platform/calculate-rule'
+import { listRule, getRule, delRule, addRule, updateRule } from "@/api/platform/calculate-rule";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 
 export default {
-  name: 'Rules',
+  name: "Rule",
+  components: {
+    Treeselect
+  },
   data() {
     return {
       // 閬僵灞�
       loading: true,
-      // 閫変腑鏁扮粍
-      ids: [],
-      // 闈炲崟涓鐢�
-      single: true,
-      // 闈炲涓鐢�
-      multiple: true,
       // 鏄剧ず鎼滅储鏉′欢
       showSearch: true,
-      // 鎬绘潯鏁�
-      total: 0,
       // 鏍哥畻瑙勫垯琛ㄦ牸鏁版嵁
-      rulesList: [],
+      ruleList: [],
+      // 鏍哥畻瑙勫垯鏍戦�夐」
+      ruleOptions: [],
       // 寮瑰嚭灞傛爣棰�
-      title: '',
+      title: "",
       // 鏄惁鏄剧ず寮瑰嚭灞�
       open: false,
+      // 鏄惁灞曞紑锛岄粯璁ゅ叏閮ㄥ睍寮�
+      isExpandAll: true,
+      // 閲嶆柊娓叉煋琛ㄦ牸鐘舵��
+      refreshTable: true,
       // 鏌ヨ鍙傛暟
       queryParams: {
-        pageNum: 1,
-        pageSize: 10,
-        rulesName: null,
-        contractName: null,
-        deleted: null
+        name: null,
+        templateId: null,
+        parentId: null,
+        unitId: null,
+        value: null,
+        description: null
       },
       // 琛ㄥ崟鍙傛暟
       form: {},
       // 琛ㄥ崟鏍¢獙
-      rules: {}
-    }
+      rules: {
+      }
+    };
   },
   created() {
-    this.getList()
+    this.getList();
   },
   methods: {
     /** 鏌ヨ鏍哥畻瑙勫垯鍒楄〃 */
     getList() {
-      this.loading = true
-      listRules(this.queryParams).then(response => {
-        this.rulesList = response.rows
-        this.total = response.total
-        this.loading = false
-      })
+      this.loading = true;
+      listRule(this.queryParams).then(response => {
+        this.ruleList = this.handleTree(response.data, "id", "parentId");
+        this.loading = false;
+      });
+    },
+    /** 杞崲鏍哥畻瑙勫垯鏁版嵁缁撴瀯 */
+    normalizer(node) {
+      if (node.children && !node.children.length) {
+        delete node.children;
+      }
+      return {
+        id: node.id,
+        label: node.name,
+        children: node.children
+      };
+    },
+	/** 鏌ヨ鏍哥畻瑙勫垯涓嬫媺鏍戠粨鏋� */
+    getTreeselect() {
+      listRule().then(response => {
+        this.ruleOptions = [];
+        const data = { id: 0, name: '椤剁骇鑺傜偣', children: [] };
+        data.children = this.handleTree(response.data, "id", "parentId");
+        this.ruleOptions.push(data);
+      });
     },
     // 鍙栨秷鎸夐挳
     cancel() {
-      this.open = false
-      this.reset()
+      this.open = false;
+      this.reset();
     },
     // 琛ㄥ崟閲嶇疆
     reset() {
       this.form = {
         id: null,
-        rulesName: null,
-        contractName: null,
-        amount: null,
-        createTime: null,
-        updateTime: null,
-        deleted: null
-      }
-      this.resetForm('form')
+        name: null,
+        templateId: null,
+        parentId: null,
+        unitId: null,
+        value: null,
+        description: null
+      };
+      this.resetForm("form");
     },
     /** 鎼滅储鎸夐挳鎿嶄綔 */
     handleQuery() {
-      this.queryParams.pageNum = 1
-      this.getList()
+      this.getList();
     },
     /** 閲嶇疆鎸夐挳鎿嶄綔 */
     resetQuery() {
-      this.resetForm('queryForm')
-      this.handleQuery()
-    },
-    // 澶氶�夋閫変腑鏁版嵁
-    handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.id)
-      this.single = selection.length !== 1
-      this.multiple = !selection.length
+      this.resetForm("queryForm");
+      this.handleQuery();
     },
     /** 鏂板鎸夐挳鎿嶄綔 */
-    handleAdd() {
-      this.reset()
-      this.open = true
-      this.title = '娣诲姞鏍哥畻瑙勫垯'
+    handleAdd(row) {
+      this.reset();
+      this.getTreeselect();
+      if (row != null && row.id) {
+        this.form.parentId = row.id;
+      } else {
+        this.form.parentId = 0;
+      }
+      this.open = true;
+      this.title = "娣诲姞鏍哥畻瑙勫垯";
+    },
+    /** 灞曞紑/鎶樺彔鎿嶄綔 */
+    toggleExpandAll() {
+      this.refreshTable = false;
+      this.isExpandAll = !this.isExpandAll;
+      this.$nextTick(() => {
+        this.refreshTable = true;
+      });
     },
     /** 淇敼鎸夐挳鎿嶄綔 */
     handleUpdate(row) {
-      this.reset()
-      const id = row.id || this.ids
-      getRules(id).then(response => {
-        this.form = response.data
-        this.open = true
-        this.title = '淇敼鏍哥畻瑙勫垯'
-      })
+      this.reset();
+      this.getTreeselect();
+      if (row != null) {
+        this.form.parentId = row.id;
+      }
+      getRule(row.id).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "淇敼鏍哥畻瑙勫垯";
+      });
     },
     /** 鎻愪氦鎸夐挳 */
     submitForm() {
-      this.$refs['form'].validate(valid => {
+      this.$refs["form"].validate(valid => {
         if (valid) {
           if (this.form.id != null) {
-            updateRules(this.form).then(response => {
-              this.$modal.msgSuccess('淇敼鎴愬姛')
-              this.open = false
-              this.getList()
-            })
+            updateRule(this.form).then(response => {
+              this.$modal.msgSuccess("淇敼鎴愬姛");
+              this.open = false;
+              this.getList();
+            });
           } else {
-            addRules(this.form).then(response => {
-              this.$modal.msgSuccess('鏂板鎴愬姛')
-              this.open = false
-              this.getList()
-            })
+            addRule(this.form).then(response => {
+              this.$modal.msgSuccess("鏂板鎴愬姛");
+              this.open = false;
+              this.getList();
+            });
           }
         }
-      })
+      });
     },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
-      const ids = row.id || this.ids
-      this.$modal.confirm('鏄惁纭鍒犻櫎鏍哥畻瑙勫垯缂栧彿涓�"' + ids + '"鐨勬暟鎹」锛�').then(function() {
-        return delRules(ids)
+      this.$modal.confirm('鏄惁纭鍒犻櫎鏍哥畻瑙勫垯缂栧彿涓�"' + row.id + '"鐨勬暟鎹」锛�').then(function() {
+        return delRule(row.id);
       }).then(() => {
-        this.getList()
-        this.$modal.msgSuccess('鍒犻櫎鎴愬姛')
-      }).catch(() => {
-      })
-    },
-    /** 瀵煎嚭鎸夐挳鎿嶄綔 */
-    handleExport() {
-      this.download('platform/rules/export', {
-        ...this.queryParams
-      }, `rules_${new Date().getTime()}.xlsx`)
+        this.getList();
+        this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+      }).catch(() => {});
     }
   }
-}
+};
 </script>

--
Gitblit v1.8.0