From dacd3a1471c378af02fa241ebe4f47afb168409e Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 01 Mar 2022 17:39:04 +0800
Subject: [PATCH] 新增合同管理

---
 src/views/securityGuard/securityGuard.vue |    1 
 src/views/contract/contract.vue           |  379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/api/contract/contract.js              |   39 +++++
 3 files changed, 418 insertions(+), 1 deletions(-)

diff --git a/src/api/contract/contract.js b/src/api/contract/contract.js
new file mode 100644
index 0000000..79e7cf9
--- /dev/null
+++ b/src/api/contract/contract.js
@@ -0,0 +1,39 @@
+import request from '@/router/axios';
+
+export const getList = (current, size, params) => {
+    return request({
+        url: '/api/contract/page',
+        method: 'get',
+        params: {
+            ...params,
+            current,
+            size,
+        }
+    })
+}
+
+export const add = (row) => {
+    return request({
+        url: '/api/contract/save',
+        method: 'post',
+        data: row
+    })
+}
+
+export const update = (row) => {
+    return request({
+        url: '/api/contract/update',
+        method: 'post',
+        data: row
+    })
+}
+
+export const remove = (ids) => {
+    return request({
+        url: '/api/contract/remove',
+        method: 'post',
+        params: {
+            ids,
+        }
+    })
+}
\ No newline at end of file
diff --git a/src/views/contract/contract.vue b/src/views/contract/contract.vue
new file mode 100644
index 0000000..fb16e24
--- /dev/null
+++ b/src/views/contract/contract.vue
@@ -0,0 +1,379 @@
+<template>
+  <basic-container
+    :class="[
+      'securityUnit',
+      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
+      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
+    ]"
+  >
+    <avue-crud
+      class="tablesss"
+      :option="option"
+      :data="data"
+      :page.sync="page"
+      ref="crud"
+      :permission="permissionList"
+      @on-load="onLoad"
+      :table-loading="loading"
+      @row-save="rowSave"
+      @search-change="searchChange"
+      @search-reset="searchReset"
+      @row-update="rowUpdate"
+      @row-del="rowDel"
+      @selection-change="selectionChange"
+      @refresh-change="refreshChange"
+    >
+      <template slot="menuLeft">
+        <el-button
+          type="danger"
+          size="small"
+          plain
+          icon="el-icon-delete"
+          v-if="permission.contract_delete"
+          @click="handleDelete"
+          >删 除
+        </el-button>
+      </template>
+    </avue-crud>
+  </basic-container>
+</template>
+
+<script>
+import {
+  getList,
+  add,
+  update,
+  remove
+} from "@/api/contract/contract";
+import { mapGetters } from "vuex";
+import { getToken } from "@/util/auth";
+export default {
+  data() {
+    return {
+      loading: true,
+      selectionList: [],
+      page: {
+        pageSize: 10,
+        currentPage: 1,
+        total: 0,
+        ...this.$store.state.control.changePageSize
+      },
+      query: {},
+      data: [],
+      option: {
+        index: true,
+        tip:false,
+        addBtn: true,
+        searchSize: "mini",
+        searchMenuSpan: 6,
+        height: 583,
+        menuWidth: 180,
+        border: true,
+        align: "center",
+        selection: true,
+        column: [
+          {
+            label: "合同名称",
+            prop: "name",
+            search: true,
+            searchSpan: 4,
+            labelWidth: 145,
+            minWidth: 160,
+            span:24,
+            rules: [
+              {
+                required: true,
+                message: "请选择合同名称",
+                trigger: "click"
+              }
+            ],
+            overHidden: true
+          },
+          
+          {
+            label: "合同甲方",
+            prop: "partya",
+            span: 12,
+            labelWidth: 145,
+            disabled: false,
+            rules: [
+              {
+                required: true,
+                message: "请输入合同甲方",
+                trigger: "blur"
+              }
+            ]
+          },
+          {
+            label: "合同乙方",
+            prop: "partyb",
+            span: 12,
+            labelWidth: 145,
+            disabled: false,
+            rules: [
+              {
+                required: true,
+                message: "请输入合同乙方",
+                trigger: "blur"
+              }
+            ]
+          },
+          {
+            label: "合同金额",
+            prop: "money",
+            span: 12,
+            labelWidth: 145,
+            disabled: false,
+            rules: [
+              {
+                required: true,
+                message: "请输入合同金额",
+                trigger: "blur"
+              }
+            ]
+          },
+          {
+            label: "签订日期",
+            prop: "signedTime",
+            labelWidth: 145,
+            type: "date",
+            format: "yyyy-MM-dd",
+            valueFormat: "yyyy-MM-dd",
+            rules: [
+              {
+                required: true,
+                message: "请选择签订日期",
+                trigger: "blur"
+              }
+            ]
+          },
+          {
+            label: "纸质合同图片",
+            prop: "urls",
+            labelWidth: 145,
+            type: "upload",
+            dataType: "string",
+            span: 24,
+            limit: 5,
+            listType: "picture-card",
+            tip: "只能上传jpg/png文件,最多上传5张",
+            propsHttp: {
+              res: "data",
+              url: "url"
+            },
+            action: "/api/blade-resource/oss/endpoint/put-files"
+          }
+        ],
+        ...this.$store.state.control.clearOtherBut
+      }
+    };
+  },
+  created() {
+  },
+  computed: {
+    ...mapGetters(["userInfo", "permission"]),
+    permissionList() {
+      return {
+        addBtn: this.vaildData(this.permission.contract_add, false),
+        viewBtn: this.vaildData(this.permission.contract_view, false),
+        delBtn: this.vaildData(this.permission.contract_delete, false),
+        editBtn: this.vaildData(this.permission.contract_edit, false)
+      };
+    },
+    ids() {
+      let ids = [];
+      this.selectionList.forEach(ele => {
+        ids.push(ele.id);
+      });
+      return ids.join(",");
+    },
+  },
+  mounted() {
+    this.$store.commit("setWindowSizeHeightAdd");
+  },
+  methods: {
+    sizeChange(val) {
+      this.page1.currentPage = 1;
+      this.page1.pageSize = val;
+      this.onLoad(this.page, this.query);
+    },
+    currentChange(val) {
+      this.page1.currentPage = val;
+      // this.getData();
+      this.onLoad(this.page, this.query);
+    },
+    rowSave(form, done, loading) {
+      add(form).then(res => {
+        if (res.data.success) {
+          this.$message({
+            message: "操作成功",
+            type: "success"
+          });
+          this.refreshChange();
+          done();
+        } else {
+          this.$message({
+            message: "操作失败",
+            type: "warning"
+          });
+          done();
+        }
+      });
+    },
+    searchChange(params, done) {
+      this.query = params;
+      this.page.currentPage = 1;
+      this.onLoad(this.page, params);
+      done();
+    },
+    searchReset() {
+      this.query = {};
+      this.onLoad(this.page);
+    },
+    rowUpdate(row, index, done, loading) {
+      update(row).then(
+        () => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+        },
+        error => {
+          window.console.log(error);
+          loading();
+        }
+      );
+    },
+    rowDel(row) {
+      this.$confirm(
+        "确定删除当前合同信息数据?",
+        {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }
+      )
+        .then(() => {
+          console.log(row);
+          return remove(row.id);
+        })
+        .then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+        });
+    },
+    selectionChange(list) {
+      this.selectionList = list;
+    },
+    handleDelete() {
+      if (this.selectionList.length === 0) {
+        this.$message.warning("请选择至少一条数据");
+        return;
+      }
+      this.$confirm("确定批量将选择数据删除?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          return remove(this.ids).then(res => {
+            this.refreshChange();
+          });
+        })
+        .then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          this.$refs.crudrec.toggleSelection();
+        })
+        .catch(res => {});
+    },
+    refreshChange() {
+      this.onLoad(this.page, this.query);
+    },
+    onLoad(page, params = {}) {
+      if(this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警" || this.userInfo.role_name == "administrator"){
+        params["jurisdiction"] = this.userInfo.jurisdiction;
+      }
+      this.loading = true;
+      getList(
+        page.currentPage,
+        page.pageSize,
+        Object.assign(params, this.query)
+      ).then(res => {
+        const data = res.data.data;
+        this.page.total = data.total;
+        this.data = data.records;
+        window.localStorage.setItem("danweidataS", JSON.stringify(this.data));
+        this.$store.commit("setWindowSizeHeightAdd");
+        this.loading = false;
+      });
+    }
+  },
+};
+</script>
+
+<style lang="scss">
+.securityUnit {
+  width: 100%;
+  height: 100%;
+  //   border: 1px solid #000;
+  box-sizing: border-box;
+}
+// .el-card__body {
+//   padding-bottom: 5px !important;
+// }
+// .avue-crud__tip,
+// .el-tag,
+// .el-tag--light {
+//   padding: 0 !important;
+// }
+
+.lod {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  background-color: rgba($color: #000000, $alpha: 0.5);
+  padding: 100px 0 0 0;
+  z-index: 1500 !important;
+  display: flex;
+  // align-items: center;
+  justify-content: center;
+  .trees {
+    z-index: 501 !important;
+    position: absolute;
+    width: 15%;
+    top: 100px;
+    left: 0;
+    // display: none;
+  }
+  .lod-in {
+    width: 70%;
+    height: auto;
+    background-color: transparent;
+
+    // padding: 10px 0 0 0;
+  }
+
+  .el-collapse-item {
+    padding-top: 15px !important;
+  }
+}
+.el-collapse {
+  border-top: 1px solid transparent !important;
+}
+.rowClickSelf {
+  &:hover {
+    cursor: pointer;
+  }
+}
+</style>
diff --git a/src/views/securityGuard/securityGuard.vue b/src/views/securityGuard/securityGuard.vue
index ade9f96..d535f26 100644
--- a/src/views/securityGuard/securityGuard.vue
+++ b/src/views/securityGuard/securityGuard.vue
@@ -1572,7 +1572,6 @@
   beforeCreate() {},
   created() {
     var that = this;
-    // console.log(this.userInfo, 9999);
     if (this.userInfo.role_name == "办证管理员") {
       this.search["userType"] = 7;
       this.search["hold"] = "1";

--
Gitblit v1.9.3