liuyg
2021-07-21 aedf54d825771471a208663bc8d627c71521864d
src/views/securityCompany/dispatch.vue
@@ -6,275 +6,285 @@
 * menu-name 派遣公司查询
 */
<template>
    <basic-container>
        <avue-crud :option="option"
                   :table-loading="loading"
                   :data="data"
                   :page.sync="page"
                   :permission="permissionList"
                   :before-open="beforeOpen"
                   v-model="form"
                   ref="crud"
                   @row-update="rowUpdate"
                   @row-save="rowSave"
                   @row-del="rowDel"
                   @search-change="searchChange"
                   @search-reset="searchReset"
                   @selection-change="selectionChange"
                   @current-change="currentChange"
                   @size-change="sizeChange"
                   @refresh-change="refreshChange"
                   @row-click="handleRowClick"
                   @on-load="onLoad">
        </avue-crud>
    </basic-container>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      :permission="permissionList"
      :before-open="beforeOpen"
      v-model="form"
      ref="crud"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @row-del="rowDel"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @row-click="handleRowClick"
      @on-load="onLoad"
    >
    </avue-crud>
  </basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove } from "@/api/securityCompany/dispatch";
import {
  getList,
  getDetail,
  add,
  update,
  remove,
} from "@/api/securityCompany/dispatch";
import { mapGetters } from "vuex";
export default {
    data () {
        return {
            form: {},
            query: {},
            loading: true,
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0
  data() {
    return {
      form: {},
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        // 操作栏多余按钮去除
        delBtn: false,
        editBtn: false,
        addBtn: false,
        selection: false,
        menu: false,
        align: "center",
        height: "auto",
        calcHeight: 30,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        index: true,
        searchShowBtn: false,
        viewBtn: true,
        dialogClickModal: false,
        column: [
          {
            label: "公司名称",
            prop: "enterprisename",
            search: true,
            searchSpan: 4,
            display: false,
          },
          {
            label: "法定代表人",
            prop: "representative",
            display: false,
            width: 120,
          },
          {
            label: "成立日期",
            prop: "establishtime",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            mock: {
              type: "datetime",
              format: "yyyy-MM-dd",
            },
            selectionList: [],
            option: {
                // 操作栏多余按钮去除
                delBtn: false,
                editBtn: false,
                addBtn: false,
                selection: false,
                menu: false,
                align: 'center',
                height: 'auto',
                calcHeight: 30,
                tip: false,
                searchShow: true,
                searchMenuSpan: 6,
                index: true,
                viewBtn: true,
                dialogClickModal: false,
                column: [
                    {
                        label: "公司名称",
                        prop: "enterprisename",
                        search: true,
                        searchSpan: 4,
                        display: false,
                    },
                    {
                        label: "法定代表人",
                        prop: "representative",
                        display: false,
                        width: 120
                    },
                    {
                        label: "成立日期",
                        prop: "establishtime",
                        type: "date",
                        format: 'yyyy-MM-dd',
                        valueFormat: 'yyyy-MM-dd',
                        mock: {
                            type: 'datetime',
                            format: 'yyyy-MM-dd'
                        },
                        search: true,
                        searchSpan: 4,
                        display: false,
                        width: 180
                    },
                    {
                        label: "注册资金",
                        prop: "registeredcapital",
                        display: false,
                        width: 200
                    },
                    {
                        label: "实缴资金",
                        prop: "capital",
                        display: false,
                        width: 200
                    },
                    {
                        label: "公司类型",
                        prop: "enterprises",
                        display: false,
                    },
                    {
                        label: "注册地址",
                        prop: "address",
                        display: false,
                        width: 200
                    }
                ]
                ,
                group: [
                    {
                        label: '详细信息',
                        prop: 'baseInfo',
                        icon: 'el-icon-user-solid',
                        column: [
                            {
                                label: "公司名称",
                                prop: "enterprisename",
                                display: false,
                            },
                        ]
                    },
                    {
                        label: '详细信息',
                        prop: 'detailInfo',
                        icon: 'el-icon-s-order',
                        column: [
                        ]
                    },
                    {
                        label: '职责信息',
                        prop: 'dutyInfo',
                        icon: 'el-icon-s-custom',
                        column: [
                        ]
                    },
                ]
            },
            data: []
        };
            search: true,
            searchSpan: 4,
            display: false,
            width: 180,
          },
          {
            label: "注册资金",
            prop: "registeredcapital",
            display: false,
            width: 200,
          },
          {
            label: "实缴资金",
            prop: "capital",
            display: false,
            width: 200,
          },
          {
            label: "公司类型",
            prop: "enterprises",
            display: false,
          },
          {
            label: "注册地址",
            prop: "address",
            display: false,
            width: 200,
          },
        ],
        group: [
          {
            label: "详细信息",
            prop: "baseInfo",
            icon: "el-icon-user-solid",
            column: [
              {
                label: "公司名称",
                prop: "enterprisename",
                display: false,
              },
            ],
          },
          {
            label: "详细信息",
            prop: "detailInfo",
            icon: "el-icon-s-order",
            column: [],
          },
          {
            label: "职责信息",
            prop: "dutyInfo",
            icon: "el-icon-s-custom",
            column: [],
          },
        ],
      },
      data: [],
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.post_add, false),
        viewBtn: this.vaildData(this.permission.post_view, false),
        delBtn: this.vaildData(this.permission.post_delete, false),
        editBtn: this.vaildData(this.permission.post_edit, false),
      };
    },
    computed: {
        ...mapGetters(["permission"]),
        permissionList () {
            return {
                addBtn: this.vaildData(this.permission.post_add, false),
                viewBtn: this.vaildData(this.permission.post_view, false),
                delBtn: this.vaildData(this.permission.post_delete, false),
                editBtn: this.vaildData(this.permission.post_edit, false)
            };
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  methods: {
    rowSave(row, done, loading) {
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        ids () {
            let ids = [];
            this.selectionList.forEach(ele => {
                ids.push(ele.id);
            });
            return ids.join(",");
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    methods: {
        rowSave (row, done, loading) {
            add(row).then(() => {
                this.onLoad(this.page);
                this.$message({
                    type: "success",
                    message: "操作成功!"
                });
                done();
            }, error => {
                window.console.log(error);
                loading();
            });
    rowUpdate(row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        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(() => {
                    return remove(row.id);
                })
                .then(() => {
                    this.onLoad(this.page);
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    });
                });
        },
        beforeOpen (done, type) {
            if (["edit", "view"].includes(type)) {
                getDetail(this.form.id).then(res => {
                    this.form = res.data.data;
                });
            }
            done();
        },
        searchReset () {
            this.query = {};
            this.onLoad(this.page);
        },
        searchChange (params, done) {
            this.query = params;
            this.page.currentPage = 1;
            this.onLoad(this.page, params);
            done();
        },
        selectionChange (list) {
            this.selectionList = list;
        },
        selectionClear () {
            this.selectionList = [];
            this.$refs.crud.toggleSelection();
        },
        currentChange (currentPage) {
            this.page.currentPage = currentPage;
        },
        sizeChange (pageSize) {
            this.page.pageSize = pageSize;
        },
        refreshChange () {
            this.onLoad(this.page, this.query);
        },
        onLoad (page, params = {}) {
            this.loading = true;
            getList(page.currentPage, page.pageSize, Object.assign(params, this.query), 4).then(res => {
                const data = res.data.data;
                this.page.total = data.total;
                this.data = data.records;
                this.loading = false;
                this.selectionClear();
            });
        },
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then((res) => {
          this.form = res.data.data;
        });
      }
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query),
        4
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
        // 行单击
        handleRowClick (row) {
            // delete (row["name"]);
            var obj = row
            obj["name"] = "保安公司详细资料"
            this.$router.push({
                path: `/securityCompany/index`,
                query: obj,
            });
        },
    }
    // 行单击
    handleRowClick(row) {
      // delete (row["name"]);
      var obj = row;
      obj["name"] = "保安公司详细资料";
      this.$router.push({
        path: `/securityCompany/index`,
        query: obj,
      });
    },
  },
};
</script>