linwei
2024-01-06 1d9ddccfc6d983fbf32e5bbba8ca3bba9342373f
src/views/article/components/discussionManageChild.vue
@@ -1,386 +1,420 @@
<template>
    <div>
        <el-dialog title="" append-to-body :visible.sync="dialogVisibles" width="60%" :before-close="handleClose">
            <avue-form ref="DisCussFrom" :option="option" v-model="disCussFrom" @submit="handleSubmit"></avue-form>
        </el-dialog>
    </div>
  <div>
    <el-dialog title="" append-to-body :visible.sync="dialogVisibles" width="60%" :before-close="handleClose">
      <avue-form ref="DisCussFrom" :option="option" v-model="disCussFrom" @submit="handleSubmit"></avue-form>
    </el-dialog>
  </div>
</template>
<script>
import {
  import {
    getListPd,
    getDetailPd,
    addPd,
    updatePd,
    removePd
} from "@/api/discuss/publicDiscuss"
  } from "@/api/discuss/publicDiscuss"
import {
  import {
    getPage
} from "@/api/discuss/userTopics"
  } from "@/api/discuss/userTopics"
import option from "@/option/discuss/publicDiscuss"
import {
  import option from "@/option/discuss/publicDiscuss"
  import {
    mapGetters
} from "vuex"
import {
  } from "vuex"
  import {
    getDictionary
} from '@/api/system/dict'
  } from '@/api/system/dict'
import {
  import {
    getList as getHouseholdList,
    getDetatils as getHouseholdDetail
} from "@/api/userHouse/list/houseHold"
  } from "@/api/userHouse/list/houseHold"
export default {
    data () {
        return {
            dialogVisibles: false,
            userParams: {},
            // 分页信息
            pageUser: {
                pageSize: 10,
                pageSizes: [10, 20, 30, 50, 100],
                currentPage: 1,
                total: 0
  export default {
    data() {
      return {
        dialogVisibles: false,
        userParams: {},
        // 分页信息
        pageUser: {
          pageSize: 10,
          pageSizes: [10, 20, 30, 50, 100],
          currentPage: 1,
          total: 0
        },
        discussForm: {},
        dialogVisiblesEdit: false,
        dialogVisiblesUser: false,
        editFlag: false,
        ontitle: '编辑议题',
        // 弹框标题
        title: '',
        // 是否展示弹框
        box: false,
        // 是否显示查询
        search: true,
        // 加载中
        loading: true,
        // 是否为查看模式
        view: false,
        // 查询信息
        query: {},
        // 分页信息
        page: {
          pageSize: 10,
          pageSizes: [10, 20, 30, 50, 100],
          currentPage: 1,
          total: 0
        },
        // 选择行
        selectionList: [],
        // 表单配置
        option: {
          height: "auto",
          calcHeight: 54,
          align: 'center',
          menuAlign: 'center',
          addBtn: false,
          searchMenuSpan: 3,
          menuWidth: 500,
          column: [{
              label: '标题',
              prop: 'title',
              searchSpan: 4,
              span: 6,
            },
            discussForm: {},
            dialogVisiblesEdit: false,
            dialogVisiblesUser: false,
            editFlag: false,
            ontitle: '编辑议题',
            // 弹框标题
            title: '',
            // 是否展示弹框
            box: false,
            // 是否显示查询
            search: true,
            // 加载中
            loading: true,
            // 是否为查看模式
            view: false,
            // 查询信息
            query: {},
            // 分页信息
            page: {
                pageSize: 10,
                pageSizes: [10, 20, 30, 50, 100],
                currentPage: 1,
                total: 0
            {
              label: '参与人数',
              prop: 'topsCount',
              searchSpan: 4,
              display: false,
              span: 6,
            },
            // 选择行
            selectionList: [],
            // 表单配置
            option: {
                height: "auto",
                calcHeight: 54,
                align: 'center',
                menuAlign: 'center',
                addBtn: false,
                searchMenuSpan: 3,
                menuWidth: 500,
            {
              label: '开启投票',
              prop: 'openFlag',
              type: 'radio',
              button: true,
              span: 6,
              value: 0,
              dicData: [{
                label: '开启',
                value: 0
              }, {
                label: '不开启',
                value: 1
              }],
              rules: [{
                required: true,
                message: "请选择开启状态",
                trigger: "blur",
              }, ],
            }, {
              label: '投票限制',
              prop: 'voteRestrictions',
              type: 'radio',
              button: true,
              span: 6,
              dicData: [{
                label: '一人一票',
                value: 0
              }, {
                label: '一户一票',
                value: 1
              }],
              rules: [{
                required: true,
                message: "请选择投票限制",
                trigger: "blur",
              }, ],
              value: 0
            }, {
              label: '签名',
              prop: 'signatureFlag',
              type: 'radio',
              button: true,
              span: 6,
              dicData: [{
                label: '不需要',
                value: 0
              }, {
                label: '需要',
                value: 1
              }],
              rules: [{
                required: true,
                message: "请选择是否签名",
                trigger: "blur",
              }, ],
              value: 0
            }, {
              label: '指定用户',
              prop: 'appointUser',
              type: 'radio',
              button: true,
              span: 6,
              dicData: [{
                label: '不限制',
                value: 0
              }, {
                label: '指定用户',
                value: 1
              }],
              rules: [{
                required: true,
                message: "请选择是否指定用户",
                trigger: "blur",
              }, ],
              value: 0
            },
            {
              label: "选择用户",
              prop: "userIds",
              hide: true,
              type: "table",
              display: false,
              span: 6,
              // labelWidth: 120,
              searchSpan: 4,
              search: true,
              children: {
                border: true,
                height: 400,
                searchShow: true,
                searchMenuSpan: 6,
                submitText: "确定",
                selection: true,
                column: [{
                    label: '标题',
                    prop: 'title',
                    searchSpan: 4,
                    span: 6,
                },
                {
                    label: '参与人数',
                    prop: 'topsCount',
                    searchSpan: 4,
                    display: false,
                    span: 6,
                },
                {
                    label: '开启投票',
                    prop: 'openFlag',
                    type: 'radio',
                    button: true,
                    span: 6,
                    value: 0,
                    dicData: [{
                        label: '开启',
                        value: 0
                    }, {
                        label: '不开启',
                        value: 1
                    }],
                    rules: [{
                        required: true,
                        message: "请选择开启状态",
                        trigger: "blur",
                    },],
                }, {
                    label: '投票限制',
                    prop: 'voteRestrictions',
                    type: 'radio',
                    button: true,
                    span: 6,
                    dicData: [{
                        label: '一人一票',
                        value: 0
                    }, {
                        label: '一户一票',
                        value: 1
                    }],
                    rules: [{
                        required: true,
                        message: "请选择投票限制",
                        trigger: "blur",
                    },],
                    value: 0
                }, {
                    label: '签名',
                    prop: 'signatureFlag',
                    type: 'radio',
                    button: true,
                    span: 6,
                    dicData: [{
                        label: '不需要',
                        value: 0
                    }, {
                        label: '需要',
                        value: 1
                    }],
                    rules: [{
                        required: true,
                        message: "请选择是否签名",
                        trigger: "blur",
                    },],
                    value: 0
                }, {
                    label: '指定用户',
                    prop: 'appointUser',
                    type: 'radio',
                    button: true,
                    span: 6,
                    dicData: [{
                        label: '不限制',
                        value: 0
                    }, {
                        label: '指定用户',
                        value: 1
                    }],
                    rules: [{
                        required: true,
                        message: "请选择是否指定用户",
                        trigger: "blur",
                    },],
                    value: 0
                },
                {
                    label: "选择用户",
                    prop: "userIds",
                    hide: true,
                    type: "table",
                    display: false,
                    span: 6,
                    // labelWidth: 120,
                    searchSpan: 4,
                    label: "社区",
                    prop: "neiName",
                    search: true,
                    children: {
                        border: true,
                        height: 400,
                        searchShow: true,
                        searchMenuSpan: 6,
                        submitText: "确定",
                        column: [{
                            label: "姓名",
                            prop: "name",
                            search: true,
                            searchSpan: 4,
                            rules: [{
                                required: true,
                                message: "请输入姓名",
                                trigger: "blur",
                            },],
                        },
                        {
                            label: "联系方式",
                            prop: "phoneNumber",
                            search: true,
                            searchSpan: 4,
                            rules: [{
                                required: true,
                                message: "请输入联系方式",
                                trigger: "blur",
                            },],
                        },
                        {
                            label: "地址",
                            search: true,
                            searchSpan: 8,
                            prop: "currentAddress",
                            display: false
                        },
                        ],
                    },
                    page: {
                        pageSize: 10,
                        currentPage: 1,
                        total: 0
                    },
                    formatter: (row) => {
                        // this.form.phoneNumber =  row.phoneNumber
                        return row.name
                    },
                    onLoad: ({
                        page,
                        value,
                        data
                    }, callback) => {
                        //首次加载去查询对应的值
                        if (value) {
                            getHouseholdDetail(value).then(res => {
                                var resData = res.data.data
                                // 查询对应行数据
                                callback(resData)
                                return
                            })
                        }
                        if (page) {
                            this.loading = true
                            var params = {
                                ...data,
                                townStreetCode: "361102005"
                            }
                            getHouseholdList(page.currentPage, page.pageSize, Object.assign(params)).then(res => {
                                const resData = res.data.data
                                var total = resData.total
                                var data = resData.records
                                this.loading = false
                                //分页查询信息
                                callback({
                                    total: total,
                                    data: data
                                })
                            })
                        }
                    },
                    props: {
                        label: 'name',
                        value: 'id'
                    }
                },
                {
                    label: "截止时间",
                    span: 6,
                    prop: "endTime",
                    type: "datetime",
                    format: "yyyy-MM-dd hh:mm:ss",
                    valueFormat: "yyyy-MM-dd hh:mm:ss",
                    // format: "yyyy-MM-dd hh:mm:ss",
                    // valueFormat: "yyyy-MM-dd hh:mm:ss",
                    searchSpan: 4,
                  }, {
                    label: "姓名",
                    prop: "name",
                    search: true,
                    searchSpan: 4,
                    rules: [{
                        required: true,
                        message: "请选择截止时间",
                        trigger: "blur",
                    },],
                      required: true,
                      message: "请输入姓名",
                      trigger: "blur",
                    }, ],
                  },
                  {
                    label: "小区",
                    prop: "aoiCode",
                    searchSpan: 5,
                    type: 'tree',
                    search: true,
                    parent: false,
                    dicUrl: `/api/blade-district/district/getDistrictTree`,
                    props: {
                      label: "name",
                      value: "aoiCode"
                    },
                    // defaultExpandedKeys: ["361102003"],
                    span: 12,
                    labelWidth: 120,
                    width: 220,
                    // overHidden: true,
                    rules: [{
                      required: true,
                      message: "请选择小区",
                      trigger: "blur",
                    }, ],
                    // disabled: true
                    display: true,
                    hide: true,
                  },
                  {
                    label: "楼栋",
                    prop: "building",
                    search: true,
                    searchSpan: 4,
                  },
                  {
                    label: "单元",
                    prop: "unit",
                    search: true,
                    searchSpan: 4,
                  },
                  {
                    label: "地址",
                    search: true,
                    searchSpan: 8,
                    prop: "currentAddress",
                    display: false
                  },
                ],
              },
              page: {
                pageSize: 10,
                currentPage: 1,
                total: 0
              },
              formatter: (row) => {
                // this.form.phoneNumber =  row.phoneNumber
                return row.name
              },
              onLoad: ({
                page,
                value,
                data
              }, callback) => {
                //首次加载去查询对应的值
                if (value) {
                  getHouseholdDetail(value).then(res => {
                    var resData = res.data.data
                    // 查询对应行数据
                    callback(resData)
                    return
                  })
                }
                ]
                if (page) {
                  this.loading = true
                  var params = {
                    ...data,
                    // townStreetCode: "361102005"
                  }
                  getHouseholdList(page.currentPage, page.pageSize, Object.assign(params)).then(res => {
                    const resData = res.data.data
                    var total = resData.total
                    var data = resData.records
                    this.loading = false
                    //分页查询信息
                    callback({
                      total: total,
                      data: data
                    })
                  })
                }
              },
              props: {
                label: 'name',
                value: 'id'
              }
            },
            // 表单列表
            disCussFrom: {},
            dialogVisibles: false,
            articleId: '',
            discussion: {},
        }
            {
              label: "截止时间",
              span: 6,
              prop: "endTime",
              type: "datetime",
              format: "yyyy-MM-dd hh:mm:ss",
              valueFormat: "yyyy-MM-dd hh:mm:ss",
              // format: "yyyy-MM-dd hh:mm:ss",
              // valueFormat: "yyyy-MM-dd hh:mm:ss",
              rules: [{
                required: true,
                message: "请选择截止时间",
                trigger: "blur",
              }, ],
            }
          ]
        },
        // 表单列表
        disCussFrom: {},
        dialogVisibles: false,
        articleId: '',
        discussion: {},
      }
    },
    mounted () {
    mounted() {
    },
    watch: {
        'disCussFrom.appointUser': {
            handler (newData) {
                const column = this.findObject(this.option.column, "userIds")
                if (newData == 1) {
                    column.display = true
                } else {
                    column.display = false
                }
            },
      'disCussFrom.appointUser': {
        handler(newData) {
          const column = this.findObject(this.option.column, "userIds")
          if (newData == 1) {
            column.display = true
          } else {
            column.display = false
          }
        },
        "disCussFrom.userIds": {
            // form是表单或者表格绑定的数据集,v-model='form'
            handler (val) {
                this.$nextTick(() => {
                    console.log(this.$refs, 66666)
                    // getHouseholdDetail(val).then(res => {
                    //   const data = res.data.data
                    //   this.form.phoneNumber = data.phoneNumber
                    //   this.form.currentAddress = data.currentAddress
                    // })
                })
            },
            immediate: true,
      },
      "disCussFrom.userIds": {
        // form是表单或者表格绑定的数据集,v-model='form'
        handler(val) {
          this.$nextTick(() => {
            console.log(this.$refs, 66666)
            // getHouseholdDetail(val).then(res => {
            //   const data = res.data.data
            //   this.form.phoneNumber = data.phoneNumber
            //   this.form.currentAddress = data.currentAddress
            // })
          })
        },
        immediate: true,
      },
    },
    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: {
        handleSubmit (row, done) {
            row.articleId = this.articleId
            row.eventType = 1
            addPd(row).then(
                () => {
                    this.onLoad(this.discussion)
                    this.$message({
                        type: "success",
                        message: "操作成功!",
                    })
                    done()
                    this.dialogVisibles = false
                },
                (error) => {
                    window.console.log(error)
                }
            )
        },
        init (data) {
            this.dialogVisibles = true
            this.disCussFrom = {}
            this.discussion = data
            this.articleId = data.id
            this.onLoad(data)
        },
        handleClose () {
            this.dialogVisibles = false
            this.$refs.DisCussFrom && this.$refs.DisCussFrom.resetForm()
            console.log(this.$refs, 90999)
        },
        onLoad (data, params = {
            eventType: 1,
            articleId: data.id
        }) {
            this.loading = true
            getListPd(1, 10, Object.assign(params, this.query)).then(res => {
                const data = res.data.data
                this.page.total = data.total
                this.disCussFrom = data.records[0]
                this.loading = false
      handleSubmit(row, done) {
        row.articleId = this.articleId
        row.eventType = 1
        addPd(row).then(
          () => {
            this.onLoad(this.discussion)
            this.$message({
              type: "success",
              message: "操作成功!",
            })
        }
            done()
            this.dialogVisibles = false
          },
          (error) => {
            window.console.log(error)
          }
        )
      },
      init(data) {
        this.dialogVisibles = true
        this.disCussFrom = {}
        this.discussion = data
        this.articleId = data.id
        this.onLoad(data)
      },
      handleClose() {
        this.dialogVisibles = false
        this.$refs.DisCussFrom && this.$refs.DisCussFrom.resetForm()
        console.log(this.$refs, 90999)
      },
      onLoad(data, params = {
        eventType: 1,
        articleId: data.id
      }) {
        this.loading = true
        getListPd(1, 10, Object.assign(params, this.query)).then(res => {
          const data = res.data.data
          this.page.total = data.total
          this.disCussFrom = data.records[0]
          this.loading = false
        })
      }
    }
}
  }
</script>
<style lang="scss" scoped>
.el-pagination {
  .el-pagination {
    margin-top: 20px;
}
  }
</style>