linwe
2024-08-09 5e2aafeede13d337380f736567caf74f49713be7
src/views/gzll/components/ownersMemberManager.vue
@@ -1,33 +1,29 @@
<template>
  <el-row>
    <el-col :span="24">
      <basic-container>
        <avue-crud :option="option" :search.sync="search" :table-loading="loading" :data="data" ref="crud"
          v-model="form" :permission="permissionList" @row-del="rowDel" @row-update="rowUpdate" @row-save="rowSave"
          :before-open="beforeOpen" :page.sync="page" @search-change="searchChange" @search-reset="searchReset"
          @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
          @refresh-change="refreshChange">
          <template slot="menuLeft">
            <el-button type="danger" size="small" plain icon="el-icon-delete" v-if="permission.household_delete"
              @click="handleDelete">删 除
            </el-button>
          </template>
          <template slot-scope="{row}" slot="tenantName">
            <el-tag>{{ row.tenantName }}</el-tag>
          </template>
          <template slot-scope="{row}" slot="roleName">
            <el-tag>{{ row.roleName }}</el-tag>
          </template>
          <template slot-scope="{row}" slot="deptName">
            <el-tag>{{ row.deptName }}</el-tag>
          </template>
          <template slot-scope="{row}" slot="userTypeName">
            <el-tag>{{ row.userTypeName }}</el-tag>
          </template>
        </avue-crud>
      </basic-container>
    </el-col>
  </el-row>
  <basic-container>
    <avue-crud :option="option" :search.sync="search" :table-loading="loading" :data="data" ref="crud" v-model="form"
      :permission="permissionList" @row-del="rowDel" @row-update="rowUpdate" @row-save="rowSave"
      :before-open="beforeOpen" :page.sync="page" @search-change="searchChange" @search-reset="searchReset"
      @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
      @refresh-change="refreshChange">
      <template slot="menuLeft">
        <el-button type="danger" size="small" plain icon="el-icon-delete" v-if="permission.household_delete"
          @click="handleDelete">删 除
        </el-button>
      </template>
      <template slot-scope="{row}" slot="tenantName">
        <el-tag>{{ row.tenantName }}</el-tag>
      </template>
      <template slot-scope="{row}" slot="roleName">
        <el-tag>{{ row.roleName }}</el-tag>
      </template>
      <template slot-scope="{row}" slot="deptName">
        <el-tag>{{ row.deptName }}</el-tag>
      </template>
      <template slot-scope="{row}" slot="userTypeName">
        <el-tag>{{ row.userTypeName }}</el-tag>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
@@ -37,11 +33,11 @@
    add,
    update,
    getDetail
  } from "@/api/owners/ownersCommittee.js";
  } from "@/api/owners/ownersCommittee.js"
  import {
    getUserByDistrictId
  } from "@/api/system/user.js";
  } from "@/api/system/user.js"
  // import {
  //     update as committeeUpdate,
@@ -49,19 +45,19 @@
  import {
    mapGetters
  } from "vuex";
  } from "vuex"
  import {
    getToken
  } from '@/util/auth';
  } from '@/util/auth'
  import {
    downloadXls
  } from "@/util/util";
  } from "@/util/util"
  import {
    dateNow
  } from "@/util/date";
  import NProgress from 'nprogress';
  import 'nprogress/nprogress.css';
  import Qs from "qs";
  } from "@/util/date"
  import NProgress from 'nprogress'
  import 'nprogress/nprogress.css'
  import Qs from "qs"
  export default {
    data() {
@@ -80,11 +76,11 @@
          total: 0
        },
        option: {
          height: 420,
          height: 680,
          // calcHeight: 80,
          tip: false,
          searchShow: true,
          // searchMenuSpan: 6,
          searchMenuSpan: 8,
          border: true,
          index: true,
          // selection: true,
@@ -107,22 +103,30 @@
                value: 'id'
              },
              defaultExpandedKeys: [],
              change: ({
                value,
                column,
                item,
                dic
              }) => {
                this.form.mobile = ''
                if (value) {
                  this.form.mobile = item.phone
                  this.form.name = item.name
                }
              },
              rules: [{
                required: true,
                message: "请选择业委会成员",
                trigger: "blur",
              }, ],
              click({
                column,
                value
              }) {
                console.log(column, value)
              }
              }]
            }, {
              label: "名称",
              prop: "name",
              search: true,
              labelWidth: 120,
              display: false,
              // hide: true,
              rules: [{
                required: true,
@@ -139,7 +143,8 @@
                message: "请输入手机号",
                trigger: "blur",
              }, ],
            }, {
            },
            {
              label: "小区",
              prop: "areaId",
              searchSpan: 5,
@@ -295,9 +300,24 @@
            {
              label: "简介",
              prop: "profile",
              labelWidth: 120,
              component: "AvueUeditor",
              options: {
                action: "/api/blade-resource/oss/endpoint/put-file",
                props: {
                  res: "data",
                  url: "link",
                },
              },
              hide: true,
              minRows: 6,
              span: 24,
            },
            // {
            //   label: "简介",
            //   prop: "profile",
            //   labelWidth: 120,
            //   hide: true,
            // },
          ]
        },
        ownersId: "",
@@ -350,7 +370,7 @@
            }
          ]
        }
      };
      }
    },
    watch: {},
    computed: {
@@ -361,7 +381,7 @@
          viewBtn: this.vaildData(this.permission.household_view, true),
          delBtn: this.vaildData(this.permission.household_delete, true),
          editBtn: this.vaildData(this.permission.household_edit, true)
        };
        }
      }
    },
    mounted() {},
@@ -369,41 +389,41 @@
      init(data) {
        this.ownersId = data.id
        this.owners = data
        const column = this.findObject(this.option.column, "userId");
        const column = this.findObject(this.option.column, "userId")
        let arr = []
        arr.push(this.owners.areaId)
        column.defaultExpandedKeys = arr;
        column.defaultExpandedKeys = arr
        this.onLoad(this.page)
      },
      rowSave(row, done, loading) {
        row['ownersId'] = this.ownersId
        row['areaId'] = this.owners.areaId
        add(row).then(() => {
          this.initFlag = false;
          this.onLoad(this.page);
          this.initFlag = false
          this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
          })
          done()
        }, error => {
          // window.console.log(error);
          loading();
        });
          loading()
        })
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
          this.initFlag = false;
          this.onLoad(this.page);
          this.initFlag = false
          this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
          })
          done()
        }, error => {
          // window.console.log(error);
          loading();
        });
          loading()
        })
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
@@ -412,38 +432,38 @@
            type: "warning"
          })
          .then(() => {
            return remove(row.id);
            return remove(row.id)
          })
          .then(() => {
            this.onLoad(this.page);
            this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
            })
          })
      },
      searchReset() {
        this.query = {};
        this.treeDeptId = '';
        this.onLoad(this.page);
        this.query = {}
        this.treeDeptId = ''
        this.onLoad(this.page)
      },
      searchChange(params, done) {
        this.query = params;
        this.page.currentPage = 1;
        this.onLoad(this.page, params);
        done();
        this.query = params
        this.page.currentPage = 1
        this.onLoad(this.page, params)
        done()
      },
      selectionChange(list) {
        this.selectionList = list;
        this.selectionList = list
      },
      selectionClear() {
        this.selectionList = [];
        this.selectionList = []
        // this.$refs.crud.toggleSelection();
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
          this.$message.warning("请选择至少一条数据")
          return
        }
        this.$confirm("确定将选择数据删除?", {
            confirmButtonText: "确定",
@@ -451,24 +471,24 @@
            type: "warning"
          })
          .then(() => {
            return remove(this.ids);
            return remove(this.ids)
          })
          .then(() => {
            this.onLoad(this.page);
            this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            this.$refs.crud.toggleSelection();
          });
            })
            this.$refs.crud.toggleSelection()
          })
      },
      handleImport() {
        this.excelBox = true;
        this.excelBox = true
      },
      uploadAfter(res, done, loading, column) {
        this.excelBox = false;
        this.refreshChange();
        done();
        this.excelBox = false
        this.refreshChange()
        done()
      },
      handleExport() {
        this.$confirm("是否导出住户数据?", "提示", {
@@ -476,63 +496,63 @@
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          NProgress.start();
          NProgress.start()
          var data = {
            ...this.query
          }
          data = Qs.stringify(data);
          data = Qs.stringify(data)
          exportBlob(
            `/api/blade-household/household/export-household?${this.website.tokenHeader}=${getToken()}&` + data
          ).then(res => {
            downloadXls(res.data, `住户数据表${dateNow()}.xlsx`);
            NProgress.done();
            downloadXls(res.data, `住户数据表${dateNow()}.xlsx`)
            NProgress.done()
          })
        });
        })
      },
      handleTemplate() {
        exportBlob(`/api/blade-system/user/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
          downloadXls(res.data, "住户数据模板.xlsx");
          downloadXls(res.data, "住户数据模板.xlsx")
        })
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getDetail(this.form.id).then(res => {
            this.form = res.data.data;
            const column = this.findObject(this.option.column, "userId");
            this.form = res.data.data
            const column = this.findObject(this.option.column, "userId")
            console.table(this.userList)
            column.dicData = this.userList;
          });
            column.dicData = this.userList
          })
        }
        this.initFlag = true;
        done();
        this.initFlag = true
        done()
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage;
        this.page.currentPage = currentPage
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
        this.page.pageSize = pageSize
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
        this.onLoad(this.page, this.query)
      },
      onLoad(page, params = {}) {
        params['ownersId'] = this.ownersId
        this.loading = true;
        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;
          this.loading = false;
          this.selectionClear();
        });
          const data = res.data.data
          this.page.total = data.total
          this.data = data.records
          this.loading = false
          this.selectionClear()
        })
        getUserByDistrictId(this.owners.areaId).then(res => {
          const column = this.findObject(this.option.column, "userId");
          this.userList = res.data.data;
          column.dicData = res.data.data;
          const column = this.findObject(this.option.column, "userId")
          this.userList = res.data.data
          column.dicData = res.data.data
        })
      }
    }
  };
  }
</script>
<style>