shuishen
2024-04-18 4522ab3fe8bd45ee753ef187448c1e884bbc601f
src/views/article/components/publicSignUpChild.vue
@@ -1,42 +1,13 @@
<template>
  <basicContainer>
    <avue-crud :data="data" ref="crud" :table-loading="loading" @current-change="currentChange"
      @search-change="searchChange" @search-reset="searchReset" @size-change="sizeChange" :option="option"
      v-model="data" :page="page" @selection-change="selectionChange" @row-del="rowDel" @refresh-change="refreshChange"
      @on-load="onLoad">
      <template slot="menuLeft">
        <!-- <el-button size="small" icon="el-icon-delete" plain v-if="permission.article_delete" @click="handleDelete">删 除
        </el-button> -->
        <el-button type="danger" size="small" plain icon="el-icon-delete" v-if="permission.user_delete"
          @click="handleDelete">批量删除
        </el-button>
      </template>
      <template slot-scope="scope" slot="menu">
        <el-button type="text" icon="el-icon-s-custom" size="small" @click.stop="openDilog(scope.row,0)">
          编辑
        </el-button>
        <el-button type="primary" icon="el-icon-s-custom" size="small" @click.stop="openUser(scope.row,0)">
          参与用户
        </el-button>
      </template>
    </avue-crud>
    <el-dialog title="" append-to-body :visible.sync="dialogVisibles" width="50%" :before-close="handleClose">
      <avue-form @submit="handleSubmit" :option="optionEnroll" v-model="discussForm">
      </avue-form>
  <div>
    <el-dialog title="" append-to-body :visible.sync="dialogVisiblesUser" width="80%" :before-close="userHandleClose">
      <avue-crud ref="DataUser" :option="userOption" :data="dataUser" v-model="dataUser" :page="pageUser"
        @search-change="searchChange" @search-reset="searchReset"></avue-crud>
    </el-dialog>
  </div>
    <el-dialog title="" append-to-body :visible.sync="dialogVisiblesUser" width="50%" :before-close="userHandleClose">
      <!-- <span slot="title" class="dialog-footer">
        {{discussForm.ontitle}}
      </span> -->
      <avue-crud :data="dataUser" :page="pageUser" :option="option1" @on-load="getUser"></avue-crud>
    </el-dialog>
  </basicContainer>
  <!-- </basicContainer> -->
</template>
<script>
@@ -46,17 +17,19 @@
    addPd,
    updatePd,
    removePd,
  } from "@/api/discuss/publicDiscuss";
  } from "@/api/discuss/publicDiscuss"
  import {
    getPageUser,
  } from "@/api/discuss/userPublicEnroll";
  import option from "@/option/discuss/publicDiscuss";
  } from "@/api/discuss/userPublicEnroll"
  import option from "@/option/discuss/publicDiscuss"
  import {
    mapGetters
  } from "vuex";
  } from "vuex"
  import {
    getDictionary
  } from '@/api/system/dict'
  import website from '@/config/website'
  export default {
    data() {
@@ -74,7 +47,9 @@
            label: '手机',
            prop: 'phone'
          }, {
            label: '小区',
            width: 220,
            overHidden: true,
            label: '小区名称',
            prop: 'aoiName'
          }, {
            label: '地址',
@@ -102,60 +77,7 @@
          userIds: '',
          eventType: 1,
        },
        optionEnroll: {
          column: [{
              label: "",
              type: 'title',
              prop: "title",
              span: 24,
              row: true,
              offset: 2,
              styles: {
                fontSize: '24px'
              }
            }, {
              labelWidth: 100,
              label: '开启',
              prop: 'openFlag',
              type: 'radio',
              button: true,
              row: true,
              offset: 6,
              dicData: [{
                label: '开启',
                value: 0
              }, {
                label: '不开启',
                value: 1
              }]
            },
            {
              labelWidth: 100,
              label: '开启投票',
              prop: 'openFlag',
              type: 'radio',
              button: true,
              row: true,
              offset: 6,
              dicData: [{
                label: '开启',
                value: 0
              }, {
                label: '不开启',
                value: 1
              }]
            },
            {
              label: "截止时间",
              row: true,
              offset: 6,
              prop: "endTime",
              type: "datetime",
              format: "yyyy-MM-dd hh:mm:ss",
              valueFormat: "timestamp",
            },
          ]
        },
        dialogVisibles: false,
        dialogVisiblesUser: false,
        // 弹框标题
@@ -189,41 +111,58 @@
        form: {},
        // 选择行
        selectionList: [],
        // 表单配置
        option: {
          selection: true,
        userOption: {
          labelWidth: 96,
          searchLabelWidth: 96,
          searchShow: true,
          searchMenuSpan: 3,
          // menuWidth: 500,
          menu: false,
          height: "auto",
          calcHeight: 54,
          align: 'center',
          menuAlign: 'center',
          addBtn: false,
          dialogWidth: 950,
          tip: false,
          border: true,
          //stripe:true,
          index: true,
          editBtn: false,
          searchMenuSpan: 3,
          searchBtn: true,
          menuWidth: 500,
          addBtn: false,
          viewBtn: false,
          selection: true,
          delBtn: false,
          excelBtn: true,
          dialogClickModal: false,
          header: false,
          column: [{
              label: 'ID',
              prop: 'id',
              searchSpan: 4,
              // search: true,
              label: '姓名',
              prop: 'name',
              search: true,
            }, {
              label: '头像',
              type: 'upload',
              listType: "picture-img",
              prop: 'avatar'
            },
            {
              label: '标题',
              prop: 'title',
              searchSpan: 4,
              search: true,
              label: '签名',
              type: 'upload',
              listType: "picture-img",
              prop: 'signaturePath'
            },
            {
              label: '参与人数',
              prop: 'enrollCount',
              searchSpan: 4,
              label: '手机',
              prop: 'phone',
              search: true,
            },
            {
              label: '截止时间',
              prop: 'endTime',
              searchSpan: 4,
              search: true,
            }, {
              label: '小区',
              prop: 'aoiName'
            }, {
              label: '地址',
              prop: 'addressName'
            }, {
              label: '时间',
              prop: 'createTime'
            }
          ]
        },
@@ -239,38 +178,67 @@
    computed: {
      ...mapGetters(["permission"]),
      ids() {
        let ids = [];
        let ids = []
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
          ids.push(ele.id)
        })
        return ids.join(",")
      }
    },
    methods: {
      searchReset() {
        this.query = {}
        this.getUser(this.userPage)
      },
      searchChange(params, done) {
        this.query = params
        this.userPage.currentPage = 1
        this.getUser(this.userPage, params)
        done()
      },
      init(data) {
        this.houseCode = data.houseCode
        this.onLoad(this.page)
      },
      getUser(page, params = {}) {
      getUser(page, params) {
        getPageUser(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
          const data = res.data.data;
          this.pageUser.total = data.total;
          this.dataUser = data.records;
          this.loading = false;
          this.selectionClear();
        });
          const data = res.data.data
          this.pageUser.total = data.total
          this.dataUser = data.records
          this.dataUser.forEach(item => {
            if (item.avatar) {
              item.avatar = website.minioUrl + item.avatar
              console.log("=avatar====>", item.avatar)
            }
            if (item.signaturePath && item.signaturePath.length > 0) {
              item.signaturePath = website.minioUrl + item.signaturePath
              console.log("=====>", item.signaturePath)
            }
          })
          this.loading = false
          // this.selectionClear()
        })
      },
      userHandleClose() {
        this.dialogVisiblesUser = false
        this.dataUser = []
        // this.$refs.DataUser && this.$refs.DataUser.resetForm()
        // console.log(this.$refs, 90999)
      },
      openUser(row) {
        this.dialogVisiblesUser = true
        this.getUser(this.pageUser, params = {})
        let params = {
          articleId: row.id
        }
        this.getUser(this.pageUser, params)
      },
      openDilog(row, type) {
        this.dialogVisibles = true
        this.discussForm = row
        let times = new Date(row.endTime).getTime();
        let times = new Date(row.endTime).getTime()
        this.discussForm.endTime = times
        console.table(this.discussForm)
        if (type == 0) {
@@ -281,35 +249,35 @@
      },
      searchHide() {
        this.search = !this.search;
        this.search = !this.search
      },
      searchChange() {
        this.onLoad(this.page);
        this.onLoad(this.page)
      },
      searchReset() {
        this.query = {};
        this.page.currentPage = 1;
        this.onLoad(this.page);
        this.query = {}
        this.page.currentPage = 1
        this.onLoad(this.page)
      },
      handleSubmit(form, done) {
        done()
        if (!this.discussForm.id) {
          addPd(this.discussForm).then(() => {
            this.dialogVisibles = false
            this.onLoad(this.page);
            this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
            })
          })
        } else {
          updatePd(this.discussForm).then(() => {
            this.dialogVisibles = false
            this.onLoad(this.page);
            this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            })
          })
        }
      },
@@ -322,21 +290,21 @@
        this.title = '编辑'
        this.box = true
        getDetailPd(row.id).then(res => {
          this.form = res.data.data;
        });
          this.form = res.data.data
        })
      },
      handleView(row) {
        this.title = '查看'
        this.view = true;
        this.box = true;
        this.view = true
        this.box = true
        getDetailPd(row.id).then(res => {
          this.form = res.data.data;
        });
          this.form = res.data.data
        })
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
          this.$message.warning("请选择至少一条数据")
          return
        }
        this.$confirm("确定将选择数据删除?", {
            confirmButtonText: "确定",
@@ -344,16 +312,16 @@
            type: "warning"
          })
          .then(() => {
            return removePd(this.ids);
            return removePd(this.ids)
          })
          .then(() => {
            this.selectionClear();
            this.onLoad(this.page);
            this.selectionClear()
            this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
            })
          })
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
@@ -362,50 +330,50 @@
            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: "操作成功!"
            });
          });
            })
          })
      },
      beforeClose(done) {
        done()
        this.form = {};
        this.view = false;
        this.form = {}
        this.view = false
      },
      selectionChange(list) {
        this.selectionList = list;
        this.selectionList = list
      },
      selectionClear() {
        this.selectionList = [];
        this.selectionList = []
        // this.$refs.table.clearSelection();
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage;
        this.onLoad(this.page);
        this.page.currentPage = currentPage
        this.onLoad(this.page)
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
        this.onLoad(this.page);
        this.page.pageSize = pageSize
        this.onLoad(this.page)
      },
      onLoad(page, params = {
        eventType: 0
      }) {
        this.loading = true;
        this.loading = true
        getListPd(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()
        })
      }
    }
  };
  }
</script>
<style lang="scss" scoped>