shuishen
2024-01-09 626af15b65701197a33ad0d1384bae8d56c169ce
src/views/property/propertyCharge.vue
@@ -1,360 +1,358 @@
<template>
  <basic-container>
    <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" v-model="form"
               :permission="permissionList" @search-change="searchChange" @search-reset="searchReset"
               @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
               :before-open="beforeOpen"
               @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
               @refresh-change="refreshChange" @on-load="onLoad">
    </avue-crud>
  </basic-container>
    <basic-container>
        <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" v-model="form"
            :permission="permissionList" @search-change="searchChange" @search-reset="searchReset" @row-update="rowUpdate"
            @row-save="rowSave" @row-del="rowDel" :before-open="beforeOpen" @selection-change="selectionChange"
            @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
        </avue-crud>
    </basic-container>
</template>
<script>
import {mapGetters} from "vuex";
import {getDetail,getList,add,update,remove} from "@/api/property/propertyCharge";
import website from "@/config/website";
import func from "@/util/func";
import {validatePhone} from "@/util/validate";
import { mapGetters } from "vuex"
import { getDetail, getList, add, update, remove } from "@/api/property/propertyCharge"
import website from "@/config/website"
import func from "@/util/func"
import { validatePhone } from "@/util/validate"
const searchSpan = 4
const labelWidth=110
const labelWidth = 110
export default {
  name: "propertyCharge",
  data () {
    return {
      form: {},
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      datetime: "",
      selectionList: [],
      memberFlag: false,
      option: {
        // menu: false,
        // addBtn: false,
        border: true,
        index: true,
        selection: false,
        height: "auto",
        calcHeight: 54,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 3,
        //stripe:true,
        viewBtn: true,
        excelBtn: true,
        dialogClickModal: false,
        column: [
          {
            label: "物业公司",
            labelWidth:labelWidth,
            prop: "propertyId",
            checkStrictly: true,
            dicUrl: "/api/blade-propertyCompany/propertyCompany/getPropertyCompanyList",
            props: {
              label: "name",
              value: "deptId",
    name: "propertyCharge",
    data () {
        return {
            form: {},
            query: {},
            loading: true,
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            search:true,
            disabled:false,
            type: "select",
            rules: [{
              required: true,
              message: "请选择物业公司",
              trigger: ["blur","change"]
            }, ],
          },
          {
            label: "类型",
            labelWidth:labelWidth,
            prop: "payType",
            checkStrictly: true,
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=payType",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            type: "select",
            rules: [{
              required: true,
              message: "请选择类型",
              trigger: ["blur","change"]
            }, ],
          },
            datetime: "",
            selectionList: [],
            memberFlag: false,
            option: {
                labelWidth: 96,
                searchLabelWidth: 96,
                searchShow: true,
                searchMenuSpan: 3,
                menuWidth: 210,
          {
            label: "收费项名称",
            labelWidth:labelWidth,
            prop: "name",
            searchSpan: searchSpan,
            searchLabelWidth: labelWidth,
            search: true,
            rules: [{
              required: true,
              message: "请输入收费项名称",
              trigger: ["blur","change"]
            },],
          },
          {
            label: "计算方式",
            labelWidth:labelWidth,
            prop: "calculationFormula",
            checkStrictly: true,
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=payCalculationFormula",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            type: "select",
            rules: [{
              required: true,
              message: "请选择计算方式",
              trigger: ["blur","change"]
            }, ],
          },
          {
            label: "单价(元)",
            labelWidth:labelWidth,
            prop: "unitPrice",
            type:'number',
            precision:2,
            rules: [{
              required: true,
              message: "请输入单价",
              trigger: ["blur","change"]
            }]
          },
          {
            label: "缴费周期",
            labelWidth:labelWidth,
            placeholder:"几个月收费一次",
            prop: "payPeriod",
            checkStrictly: true,
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=payPeriod",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            type: "select",
            rules: [{
              required: true,
              message: "请选择缴费周期",
              trigger: ["blur","change"]
            }, ],
          },
                // menu: false,
                // addBtn: false,
                border: true,
                index: true,
                selection: false,
                height: "auto",
                calcHeight: 54,
                dialogWidth: 950,
                tip: false,
                //stripe:true,
                viewBtn: true,
                excelBtn: true,
                dialogClickModal: false,
                column: [
                    {
                        label: "物业公司",
                        labelWidth: labelWidth,
                        prop: "propertyId",
                        checkStrictly: true,
                        dicUrl: "/api/blade-propertyCompany/propertyCompany/getPropertyCompanyList",
                        props: {
                            label: "name",
                            value: "deptId",
                        },
                        searchSpan: 4,
                        search: true,
                        disabled: false,
                        type: "select",
                        rules: [{
                            required: true,
                            message: "请选择物业公司",
                            trigger: ["blur", "change"]
                        },],
                    },
                    {
                        label: "类型",
                        labelWidth: labelWidth,
                        prop: "payType",
                        checkStrictly: true,
                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=payType",
                        props: {
                            label: "dictValue",
                            value: "dictKey",
                        },
                        type: "select",
                        rules: [{
                            required: true,
                            message: "请选择类型",
                            trigger: ["blur", "change"]
                        },],
                    },
        ],
      },
      data: [],
    }
  },
  watch: {},
  computed: {
    ...mapGetters(["permission", "userInfo"]),
    permissionList () {
      return {
        addBtn: this.vaildData(this.permission.gridWorkLog_add, true),
        viewBtn: this.vaildData(this.permission.gridWorkLog_view, true),
        delBtn: this.vaildData(this.permission.gridWorkLog_delete, true),
        editBtn: this.vaildData(this.permission.gridWorkLog_edit, true),
      }
    },
    ids () {
      let ids = []
      this.selectionList.forEach((ele) => {
        ids.push(ele.id)
      })
      return ids.join(",")
    },
    textDispose () {
      return (row, flag, type) => {
        if (row[flag] || row[type] == null) {
          return row[type]
        } else {
          if (type == 'idCard') {
            return row[type].replace(/^(.{6})(?:\d+)(.{4})$/, "$1******$2")
          } else {
            return row[type].replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
          }
                    {
                        label: "收费项名称",
                        labelWidth: labelWidth,
                        prop: "name",
                        searchSpan: searchSpan,
                        searchLabelWidth: labelWidth,
                        search: true,
                        rules: [{
                            required: true,
                            message: "请输入收费项名称",
                            trigger: ["blur", "change"]
                        },],
                    },
                    {
                        label: "计算方式",
                        labelWidth: labelWidth,
                        prop: "calculationFormula",
                        checkStrictly: true,
                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=payCalculationFormula",
                        props: {
                            label: "dictValue",
                            value: "dictKey",
                        },
                        type: "select",
                        rules: [{
                            required: true,
                            message: "请选择计算方式",
                            trigger: ["blur", "change"]
                        },],
                    },
                    {
                        label: "单价(元)",
                        labelWidth: labelWidth,
                        prop: "unitPrice",
                        type: 'number',
                        precision: 2,
                        rules: [{
                            required: true,
                            message: "请输入单价",
                            trigger: ["blur", "change"]
                        }]
                    },
                    {
                        label: "缴费周期",
                        labelWidth: labelWidth,
                        placeholder: "几个月收费一次",
                        prop: "payPeriod",
                        checkStrictly: true,
                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=payPeriod",
                        props: {
                            label: "dictValue",
                            value: "dictKey",
                        },
                        type: "select",
                        rules: [{
                            required: true,
                            message: "请选择缴费周期",
                            trigger: ["blur", "change"]
                        },],
                    },
                ],
            },
            data: [],
        }
      }
    },
  },
  methods: {
    showStringDispose (row, type) {
      row[type] = !row[type]
    },
    manageMember (row) {
      this.memberFlag = true
      var that = this
      this.$nextTick(() => {
        that.$refs.partyOrganizationMember.init(row)
      })
    },
    rowSave (row, done, loading) {
      add(row).then(
        () => {
          this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!",
          })
          done()
    watch: {},
    computed: {
        ...mapGetters(["permission", "userInfo"]),
        permissionList () {
            return {
                addBtn: this.vaildData(this.permission.gridWorkLog_add, true),
                viewBtn: this.vaildData(this.permission.gridWorkLog_view, true),
                delBtn: this.vaildData(this.permission.gridWorkLog_delete, true),
                editBtn: this.vaildData(this.permission.gridWorkLog_edit, true),
            }
        },
        (error) => {
          window.console.log(error)
          loading()
        }
      )
    },
    rowUpdate (row, index, done, loading) {
      if (row.urls.length > 0) {
        var urls = []
        var split = row.urls.split(",")
        split.forEach(url => {
          var names = url.split("jczz/")
          urls.push(names[1])
        })
        row.urls = urls.join(",")
      }
      update(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()
        textDispose () {
            return (row, flag, type) => {
                if (row[flag] || row[type] == null) {
                    return row[type]
                } else {
                    if (type == 'idCard') {
                        return row[type].replace(/^(.{6})(?:\d+)(.{4})$/, "$1******$2")
                    } else {
                        return row[type].replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
                    }
                }
            }
        },
    },
    methods: {
        showStringDispose (row, type) {
            row[type] = !row[type]
        },
        manageMember (row) {
            this.memberFlag = true
            var that = this
            this.$nextTick(() => {
                that.$refs.partyOrganizationMember.init(row)
            })
        },
        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) {
            if (row.urls.length > 0) {
                var urls = []
                var split = row.urls.split(",")
                split.forEach(url => {
                    var names = url.split("jczz/")
                    urls.push(names[1])
                })
                row.urls = urls.join(",")
            }
            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: "操作成功!",
                    })
                })
        },
        // handleDelete() {
        //   if (this.selectionList.length === 0) {
        //     this.$message.warning("请选择至少一条数据");
        //     return;
        //   }
        //   this.$confirm("确定将选择数据删除?", {
        //       confirmButtonText: "确定",
        //       cancelButtonText: "取消",
        //       type: "warning",
        //     })
        //     .then(() => {
        //       return remove(this.ids);
        //     })
        //     .then(() => {
        //       this.onLoad(this.page);
        //       this.$message({
        //         type: "success",
        //         message: "操作成功!",
        //       });
        //       this.$refs.crud.toggleSelection();
        //     });
        // },
        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, "principalId")
                    let arr = []
                    arr.push(this.form.areaId)
                    column.defaultExpandedKeys = arr
                })
            }
            // //如果当前角色为物业管理员,则默认物业公司为该用户的物业公司
            // if (this.userInfo.role_name.indexOf("wygly")>-1){
            //   let column = this.findObject(this.option.column, "propertyId")
            //   column.disabled = true
            //   column.search = false
            //   this.form.propertyId = this.userInfo.dept_id
            // }
            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
            //如果当前角色为物业管理员,则默认筛选该物业公司
            if (this.userInfo.role_name.indexOf("wygly") > -1) {
                let column = this.findObject(this.option.column, "propertyId")
                column.disabled = true
                column.search = false
                this.form.propertyId = this.userInfo.dept_id
                params.propertyId = this.userInfo.dept_id
            }
            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()
            })
        }
      )
    },
    rowDel (row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id)
        })
        .then(() => {
          this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!",
          })
        })
    },
    // handleDelete() {
    //   if (this.selectionList.length === 0) {
    //     this.$message.warning("请选择至少一条数据");
    //     return;
    //   }
    //   this.$confirm("确定将选择数据删除?", {
    //       confirmButtonText: "确定",
    //       cancelButtonText: "取消",
    //       type: "warning",
    //     })
    //     .then(() => {
    //       return remove(this.ids);
    //     })
    //     .then(() => {
    //       this.onLoad(this.page);
    //       this.$message({
    //         type: "success",
    //         message: "操作成功!",
    //       });
    //       this.$refs.crud.toggleSelection();
    //     });
    // },
    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, "principalId")
          let arr = []
          arr.push(this.form.areaId)
          column.defaultExpandedKeys = arr
        })
      }
      // //如果当前角色为物业管理员,则默认物业公司为该用户的物业公司
      // if (this.userInfo.role_name.indexOf("wygly")>-1){
      //   let column = this.findObject(this.option.column, "propertyId")
      //   column.disabled = true
      //   column.search = false
      //   this.form.propertyId = this.userInfo.dept_id
      // }
      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
      //如果当前角色为物业管理员,则默认筛选该物业公司
      if (this.userInfo.role_name.indexOf("wygly")>-1){
        let column = this.findObject(this.option.column, "propertyId")
        column.disabled = true
        column.search = false
        this.form.propertyId = this.userInfo.dept_id
        params.propertyId = this.userInfo.dept_id
      }
      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()
      })
    }
  },
}
</script>
<style scoped>
</style>
<style scoped></style>