shuishen
2024-01-05 aca8d06f5a0b8eea2e4f30c7fe8366b2dc42bffc
src/views/article/components/publicSignUpChild.vue
@@ -1,415 +1,417 @@
<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">删 除
    <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>
                <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>
            <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>
    </el-dialog>
        <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>
        </el-dialog>
    <el-dialog title="" append-to-body :visible.sync="dialogVisiblesUser" width="50%" :before-close="userHandleClose">
      <!-- <span slot="title" class="dialog-footer">
        <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>
            <avue-crud :data="dataUser" :page="pageUser" :option="option1" @on-load="getUser"></avue-crud>
        </el-dialog>
  </basicContainer>
    </basicContainer>
</template>
<script>
  import {
import {
    getListPd,
    getDetailPd,
    addPd,
    updatePd,
    removePd,
  } from "@/api/discuss/publicDiscuss";
  import {
} from "@/api/discuss/publicDiscuss"
import {
    getPageUser,
  } from "@/api/discuss/userPublicEnroll";
  import option from "@/option/discuss/publicDiscuss";
  import {
} from "@/api/discuss/userPublicEnroll"
import option from "@/option/discuss/publicDiscuss"
import {
    mapGetters
  } from "vuex";
  import {
} from "vuex"
import {
    getDictionary
  } from '@/api/system/dict'
} from '@/api/system/dict'
  export default {
    data() {
      return {
        option1: {
          menu: false,
          addBtn: false,
          column: [{
            label: '姓名',
            prop: 'name'
          }, {
            label: '头像',
            prop: 'avatar'
          }, {
            label: '手机',
            prop: 'phone'
          }, {
            label: '小区',
            prop: 'aoiName'
          }, {
            label: '地址',
            prop: 'addressName'
          }, {
            label: '时间',
            prop: 'createTime'
          }]
        },
        discussForm: {
          ontitle: '',
          title: '',
          openFlag: 0,
          numberRestrictions: 0,
          voteRestrictions: 0,
          userRestrictions: 0,
          endTime: '',
          articleId: '',
          createTime: '',
          updateTime: '',
          deleteFlag: '',
          repeatVote: 0,
          voteNumberPublic: 0,
          appointUser: '',
          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
              }]
export default {
    data () {
        return {
            option1: {
                menu: false,
                addBtn: false,
                column: [{
                    label: '姓名',
                    prop: 'name'
                }, {
                    label: '头像',
                    prop: 'avatar'
                }, {
                    label: '手机',
                    prop: 'phone'
                }, {
                    width: 220,
                    overHidden: true,
                    label: '小区名称',
                    prop: 'aoiName'
                }, {
                    label: '地址',
                    prop: 'addressName'
                }, {
                    label: '时间',
                    prop: 'createTime'
                }]
            },
            {
              labelWidth: 100,
              label: '开启投票',
              prop: 'openFlag',
              type: 'radio',
              button: true,
              row: true,
              offset: 6,
              dicData: [{
                label: '开启',
                value: 0
              }, {
                label: '不开启',
                value: 1
              }]
            discussForm: {
                ontitle: '',
                title: '',
                openFlag: 0,
                numberRestrictions: 0,
                voteRestrictions: 0,
                userRestrictions: 0,
                endTime: '',
                articleId: '',
                createTime: '',
                updateTime: '',
                deleteFlag: '',
                repeatVote: 0,
                voteNumberPublic: 0,
                appointUser: '',
                userIds: '',
                eventType: 1,
            },
            {
              label: "截止时间",
              row: true,
              offset: 6,
              prop: "endTime",
              type: "datetime",
              format: "yyyy-MM-dd hh:mm:ss",
              valueFormat: "timestamp",
            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,
        // 弹框标题
        title: '',
        // 是否展示弹框
        box: false,
        // 是否显示查询
        search: true,
        // 加载中
        loading: true,
        // 是否为查看模式
        view: false,
        // 查询信息
        query: {},
        // 分页信息
        page: {
          pageSize: 10,
          pageSizes: [10, 20, 30, 50, 100],
          currentPage: 1,
          total: 0
        },
            dialogVisibles: false,
            dialogVisiblesUser: false,
            // 弹框标题
            title: '',
            // 是否展示弹框
            box: false,
            // 是否显示查询
            search: true,
            // 加载中
            loading: true,
            // 是否为查看模式
            view: false,
            // 查询信息
            query: {},
            // 分页信息
            page: {
                pageSize: 10,
                pageSizes: [10, 20, 30, 50, 100],
                currentPage: 1,
                total: 0
            },
        // 分页信息
        pageUser: {
          pageSize: 10,
          pageSizes: [10, 20, 30, 50, 100],
          currentPage: 1,
          total: 0
        },
        // 表单数据
        form: {},
        // 选择行
        selectionList: [],
        // 表单配置
        option: {
          selection: true,
          height: "auto",
          calcHeight: 54,
          align: 'center',
          menuAlign: 'center',
          addBtn: false,
          editBtn: false,
          searchMenuSpan: 3,
          searchBtn: true,
          menuWidth: 500,
          column: [{
              label: 'ID',
              prop: 'id',
              searchSpan: 4,
              // search: true,
            // 分页信息
            pageUser: {
                pageSize: 10,
                pageSizes: [10, 20, 30, 50, 100],
                currentPage: 1,
                total: 0
            },
            {
              label: '标题',
              prop: 'title',
              searchSpan: 4,
              search: true,
            // 表单数据
            form: {},
            // 选择行
            selectionList: [],
            // 表单配置
            option: {
                selection: true,
                height: "auto",
                calcHeight: 54,
                align: 'center',
                menuAlign: 'center',
                addBtn: false,
                editBtn: false,
                searchMenuSpan: 3,
                searchBtn: true,
                menuWidth: 500,
                column: [{
                    label: 'ID',
                    prop: 'id',
                    searchSpan: 4,
                    // search: true,
                },
                {
                    label: '标题',
                    prop: 'title',
                    searchSpan: 4,
                    search: true,
                },
                {
                    label: '参与人数',
                    prop: 'enrollCount',
                    searchSpan: 4,
                    search: true,
                },
                {
                    label: '截止时间',
                    prop: 'endTime',
                    searchSpan: 4,
                    search: true,
                }
                ]
            },
            {
              label: '参与人数',
              prop: 'enrollCount',
              searchSpan: 4,
              search: true,
            },
            {
              label: '截止时间',
              prop: 'endTime',
              searchSpan: 4,
              search: true,
            }
          ]
        },
        // 表单列表
        data: [],
        dataUser: [],
      }
            // 表单列表
            data: [],
            dataUser: [],
        }
    },
    mounted() {
      // this.init();
      // this.onLoad(this.page);
    mounted () {
        // this.init();
        // this.onLoad(this.page);
    },
    computed: {
      ...mapGetters(["permission"]),
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
        ...mapGetters(["permission"]),
        ids () {
            let ids = []
            this.selectionList.forEach(ele => {
                ids.push(ele.id)
            })
            return ids.join(",")
        }
    },
    methods: {
      init(data) {
        this.houseCode = data.houseCode
        this.onLoad(this.page)
      },
      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();
        });
      },
      userHandleClose() {
        this.dialogVisiblesUser = false
      },
      openUser(row) {
        this.dialogVisiblesUser = true
        this.getUser(this.pageUser, params = {})
      },
      openDilog(row, type) {
        this.dialogVisibles = true
        this.discussForm = row
        let times = new Date(row.endTime).getTime();
        this.discussForm.endTime = times
        console.table(this.discussForm)
        if (type == 0) {
          this.discussForm.ontitle = '公益报名'
        } else {
          this.discussForm.ontitle = '创建议题'
        }
      },
        init (data) {
            this.houseCode = data.houseCode
            this.onLoad(this.page)
        },
        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()
            })
        },
        userHandleClose () {
            this.dialogVisiblesUser = false
        },
        openUser (row) {
            this.dialogVisiblesUser = true
            this.getUser(this.pageUser, params = {})
        },
        openDilog (row, type) {
            this.dialogVisibles = true
            this.discussForm = row
            let times = new Date(row.endTime).getTime()
            this.discussForm.endTime = times
            console.table(this.discussForm)
            if (type == 0) {
                this.discussForm.ontitle = '公益报名'
            } else {
                this.discussForm.ontitle = '创建议题'
            }
        },
      searchHide() {
        this.search = !this.search;
      },
      searchChange() {
        this.onLoad(this.page);
      },
      searchReset() {
        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.$message({
              type: "success",
              message: "操作成功!"
            });
          });
        } else {
          updatePd(this.discussForm).then(() => {
            this.dialogVisibles = false
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          })
        searchHide () {
            this.search = !this.search
        },
        searchChange () {
            this.onLoad(this.page)
        },
        searchReset () {
            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.$message({
                        type: "success",
                        message: "操作成功!"
                    })
                })
            } else {
                updatePd(this.discussForm).then(() => {
                    this.dialogVisibles = false
                    this.onLoad(this.page)
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    })
                })
            }
        },
        handleAdd () {
            this.title = '新增'
            this.form = {}
            this.box = true
        },
        handleEdit (row) {
            this.title = '编辑'
            this.box = true
            getDetailPd(row.id).then(res => {
                this.form = res.data.data
            })
        },
        handleView (row) {
            this.title = '查看'
            this.view = true
            this.box = true
            getDetailPd(row.id).then(res => {
                this.form = res.data.data
            })
        },
        handleDelete () {
            if (this.selectionList.length === 0) {
                this.$message.warning("请选择至少一条数据")
                return
            }
            this.$confirm("确定将选择数据删除?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(() => {
                    return removePd(this.ids)
                })
                .then(() => {
                    this.selectionClear()
                    this.onLoad(this.page)
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    })
                })
        },
        rowDel (row) {
            this.$confirm("确定将选择数据删除?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(() => {
                    return remove(row.id)
                })
                .then(() => {
                    this.onLoad(this.page)
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    })
                })
        },
        beforeClose (done) {
            done()
            this.form = {}
            this.view = false
        },
        selectionChange (list) {
            this.selectionList = list
        },
        selectionClear () {
            this.selectionList = []
            // this.$refs.table.clearSelection();
        },
        currentChange (currentPage) {
            this.page.currentPage = currentPage
            this.onLoad(this.page)
        },
        sizeChange (pageSize) {
            this.page.pageSize = pageSize
            this.onLoad(this.page)
        },
        onLoad (page, params = {
            eventType: 0
        }) {
            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()
            })
        }
      },
      handleAdd() {
        this.title = '新增'
        this.form = {}
        this.box = true
      },
      handleEdit(row) {
        this.title = '编辑'
        this.box = true
        getDetailPd(row.id).then(res => {
          this.form = res.data.data;
        });
      },
      handleView(row) {
        this.title = '查看'
        this.view = true;
        this.box = true;
        getDetailPd(row.id).then(res => {
          this.form = res.data.data;
        });
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        this.$confirm("确定将选择数据删除?", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          })
          .then(() => {
            return removePd(this.ids);
          })
          .then(() => {
            this.selectionClear();
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
      beforeClose(done) {
        done()
        this.form = {};
        this.view = false;
      },
      selectionChange(list) {
        this.selectionList = list;
      },
      selectionClear() {
        this.selectionList = [];
        // this.$refs.table.clearSelection();
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage;
        this.onLoad(this.page);
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
        this.onLoad(this.page);
      },
      onLoad(page, params = {
        eventType: 0
      }) {
        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();
        });
      }
    }
  };
}
</script>
<style lang="scss" scoped>
  .el-pagination {
.el-pagination {
    margin-top: 20px;
  }
}
</style>