customer.vue 2.81 KB
<!-- 客户管理 -->
<template>
  <d2-container>
    <d2-table-header title="客户列表"></d2-table-header>
    <d2-table
      ref="customerTable"
      :hasNum="false"
      :searchForm="searchForm"
      :tableParams="tableParams"
      :getListApi="getListApi"
    >
      <auth-button
        slot="auth-button"
        slot-scope="scope"
        :data="scope.scope"
      ></auth-button>
    </d2-table>
  </d2-container>
</template>

<script>
import { customerList, resetPassword, customerChangeStatus } from '@api/api'
export default {
  name: 'customer',
  data() {
    return {
      searchForm: {},
      getListApi: customerList,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [{
          label: 'id',
          prop: 'id',
          width: '80px'
        }, {
          label: '客户名称',
          prop: 'customerName'
        }, {
          label: '联系人',
          prop: 'contactPerson'
        }, {
          label: '联系电话',
          prop: 'contactNumber',
          width: '100px'
        }, {
          label: '省份',
          prop: 'provinceName'
        }, {
          label: '城市',
          prop: 'cityName'
        }, {
          label: '详细地址',
          prop: 'address',
          width: '280px'
        }, {
          label: '账号状态',
          prop: 'status',
          width: '80px',
          formatter: (cellValue) => {
            return {
              0: '停用',
              1: '正常',
              2: '待审核'
            }[cellValue.status]
          }
        }]
      }
    }
  },

  mounted() { },

  methods: {
    messageConfirm(txt, fn, title = '提示', type) {
      this.$confirm(txt, title, {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: type || 'warning'
      }).then(() => {
        fn()
      })
    },
    handleResetPassword(row) {
      this.messageConfirm('是否重置密码?', () => {
        resetPassword({ id: row.id }).then(res => {
          this.notice.okTips()
        })
      })
    },
    // 停用/启用
    handleUpOrDown(row) {
      this.messageConfirm('是否' + (row.status ? '停用' : '启用') + '?', () => {
        customerChangeStatus({
          id: row.id,
          status: row.status === 1 ? 0 : 1
        }).then(res => {
          this.notice.okTips()
          this.$refs.customerTable.refreshTable()
        })
      })
    },
    // 审核
    handleExamine(row) {
      this.messageConfirm('是否审核通过?', () => {
        customerChangeStatus({
          id: row.id,
          status: 1
        }).then(res => {
          this.notice.okTips()
          this.$refs.customerTable.refreshTable()
        })
      })
    }
  }
}

</script>
<style scoped>
</style>