index.vue 9.27 KB
<!-- 开店审核 -->
<template>
  <div>
    <d2-container>
      <div class="header" slot="header" style="padding: 10px 20px;">
        <d2-search ref="showSearch" class="show-search" label-width="100px" :search-form="searchForm"
          :form-data="showFormData" />
        <div class="up-btns">
          <el-button :id="tableParams.btnId" size="small" type="primary">
            查询
          </el-button>
          <el-button size="small" @click="handleReset">
            重置
          </el-button>
        </div>
      </div>
      <div class="d2-container-content">
        <d2-table-header>
          <auth-button category="Button" />
        </d2-table-header>
        <d2-table ref="recordTable" :get-list-api="getListApi" :search-form="searchFormSearch"
          :table-params="tableParams" :before-search-fn="beforeSearchFn">
          <auth-button slot="auth-button" slot-scope="scope" :data="scope.scope" />
        </d2-table>
      </div>
      <baseDialog :is-show.sync="rejectVisible" :dialog-config="rejectConfig.config" @handleClick="handleRejectConfirm">
        <div class="reject-dialog">
          <el-form :rules="rejectRules" :model="rejectData" label-width="150px" ref="delivery-dialog-form">
            <el-form-item label="驳回原因:" prop="rejectedReason">
              <el-input type="textarea" placeholder="请输入驳回原因" maxlength="50" :rows="3" show-word-limit
                v-model.trim="rejectData.rejectedReason" class="dis-in-block reject-input" />
            </el-form-item>
          </el-form>
        </div>
        <!-- <div class="footer">
        <el-button @click="handleRejectClose">取消</el-button>
        <el-button @click="handleRejectConfirm" type="primary" v-preventReClick
          :loading="$store.state.d2admin.loading.value">确认</el-button>
      </div> -->
        <!-- </d2-dialog> -->
      </baseDialog>
    </d2-container>

  </div>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { createMerchantReviewPage, createMerchantReviewApprove, createMerchantReviewReject } from '@/api/openshopProcess.js'
import { applyStatus } from '@/common/constants.js'
export default {
  name: 'OpenshopProcessIndex',
  components: {

  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      searchForm: {
        merchantName: '',
        partnerMerchantName: '',
        reviewStatus: ''
      },
      searchFormSearch: {},
      showFormData: [{
        label: '商户名称',
        name: 'merchantName',
        type: 'input',
        maxlength: '20',
        isClear: true
      },
      {
        label: '所属服务商',
        name: 'partnerMerchantName',
        type: 'input',
        maxlength: '20',
        isClear: true
      }, {
        label: '申请状态',
        name: 'reviewStatus',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confName',
        optionsName: 'applyStatus'
      }],
      getListApi: createMerchantReviewPage,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [{
          label: '商户名称',
          prop: 'merchantName',
          width: '200px'
        }, {
          label: '联系人',
          prop: 'contactName',
          width: '150px'
        }, {
          label: '联系电话',
          prop: 'phone',
          width: '120px'
        }, {
          label: '商户地址',
          prop: '',
          width: '200px',
          formatter: (cellValue) => {
            return (cellValue.provinceName || '') + (cellValue.cityName || '') + (cellValue.merchantAddress || '')
          }
        }, {
          label: '主营品牌',
          prop: '',
          width: '200px',
          formatter: (cellValue) => {
            return cellValue.merchantBrandNameList ? cellValue.merchantBrandNameList.join('/') : '-'
          }
        }, {
          label: '商户类型',
          prop: 'merchantType',
          width: '100px',
          formatter: (cellValue) => {
            return {
              1: '服务中心',
              2: '客户'
            }[cellValue.merchantType]
          }
        }, {
          label: '所属服务中心',
          prop: 'yqMerchantName',
          width: '150px'
        }, {
          label: '所属服务商',
          prop: 'partnerMerchantName',
          width: '150px'
        }, {
          label: '申请时间',
          prop: 'createdDate',
          width: '150px',
          formatter: (cellValue) => {
            return cellValue.createdDate ? Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss') : ''
          }
        }, {
          label: '申请状态',
          prop: 'reviewStatus',
          formatter: (cellValue) => {
            return this.baseData.applyStatus.find(item => item.confId === cellValue.reviewStatus)?.confName
          },
          className: (cellValue) => {
            return {
              1: 'yellowSpot',
              2: 'greenSpot',
              3: 'redSpot'
            }[cellValue.reviewStatus]
          }
        }, {
          label: '审核人',
          prop: 'reviewer',
          width: '150px'
        }, {
          label: '审核时间',
          prop: 'reviewDate',
          width: '150px',
          formatter: (cellValue) => {
            return cellValue.reviewDate ? Util.dateFormate(cellValue.reviewDate, 'YYYY-MM-DD HH:mm:ss') : ''
          }
        }
        ]
      },
      baseData: {
        applyStatus: applyStatus
      },
      recordInfo: null,
      rejectVisible: false,
      rejectData: {
        rejectedReason: ''
      },
      // 驳回
      rejectConfig: {
        setting: {
          showClose: true,
          appendToBody: true,
          btnList: [
          ]
        },
        config: {
          title: '驳回提示',
          width: '750px'
        }
      },
      rejectRules: {
        rejectedReason: [{ required: true, message: '请输入驳回原因', trigger: 'blur' }]
      }
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.getBaseData()
  },

  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    ...mapActions('d2admin/user', ['actionSetDownloadList']),

    async getBaseData() {
      this.getOptionsList()
    },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        if (this.searchFormSearch.deliveryDate) {
          this.searchFormSearch.deliveryDateStart = Util.dateFormate(this.searchFormSearch.deliveryDate[0], 'YYYY-MM-DD 00:00:00')
          this.searchFormSearch.deliveryDateEnd = Util.dateFormate(this.searchFormSearch.deliveryDate[1], 'YYYY-MM-DD 23:59:59')
          delete this.searchFormSearch.deliveryDate
        }
        resolve()
      })
    },

    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
            const temp = {}
            temp[this.showFormData[index].optionId] = ''
            temp[this.showFormData[index].optionLabel] = '全部'
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
    },

    // handleSearch() {
    //   this.$refs.recordTable.refreshTable()
    // },
    handleReset() {
      this.searchForm = {
        merchantName: '',
        partnerMerchantName: '',
        reviewStatus: ''
      }
      this.$refs.recordTable.refreshTable()
    },

    // 审核
    handleCheck(row) {
      this.$confirm(`审核通过后,系统会自动创建对应的商户;是否确定审核?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        dangerouslyUseHTMLString: true
      }).then(() => {
        createMerchantReviewApprove({
          id: row.id
        }).then(() => {
          this.notice.okTips()
          this.$refs.recordTable.refreshTable()
        }).catch(() => { })
      })
    },

    // 驳回
    handleRejectClose() {
      this.rejectVisible = !this.rejectVisible
    },
    handleReject(row) {
      this.rejectData.id = row.id
      this.rejectData.rejectedReason = ''
      this.handleRejectClose()
    },
    handleRejectConfirm() {
      this.$refs['delivery-dialog-form'].validate(valid => {
        if (valid) {
          createMerchantReviewReject({ ...this.rejectData }).then(res => {
            this.handleRejectClose()
            this.notice.okTips()
            this.$refs.recordTable.refreshTable()
          }).catch(() => {
            this.handleRejectClose()
          })
        }
      })
    }
  }
}

</script>
<style lang="scss" scoped>
.reject-dialog {
  margin: 65px 0;

  .reject-input .el-textarea__inner {
    height: 79px;
    width: 432px;
  }

  .el-textarea .el-input__count {
    right: 90px;
    bottom: -10px;
    font-size: 12px;
    color: #999999;
  }

  .tips {
    color: #999999;
  }
}

.footer {
  display: flex;
  justify-content: flex-end;
}
</style>