mayf
2024-09-09 c5ed2b03fb6f53a6144cf4d3a18bf31a9075d67a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<template>
  <el-bus-crud ref="crud" v-bind="tableConfig" />
</template>
 
<script>
import { getPartnerListConfig } from '@/utils/form-item-config'
export default {
  data() {
    return {
      tableConfig: {
        url: 'flower/api/customer/page',
        hasNew: false,
        hasEdit: false,
        hasDelete: false,
        operationAttrs: {
          width: 150,
        },
        beforeOpen: (data, isNew) => {
          if (!isNew) {
            data.area = this.getDistrict(data)
          }
        },
        columns: [
          { label: '商户名称', prop: 'name', minWidth: 150, fixed: 'left' },
          { label: '商户昵称', prop: 'nickName', minWidth: 150 },
          { label: '所属合伙人', prop: 'partnerName', minWidth: 150 },
          {
            label: '地址',
            formatter: (row) => this.getDistrict(row),
            minWidth: 250,
          },
          { label: '联系方式', prop: 'tel', minWidth: 150 },
          { label: '注册时间', prop: 'createTime', minWidth: 180 },
        ],
        searchForm: [
          {
            type: 'row',
            items: [
              { label: '商户名称', id: 'name', type: 'input' },
              {
                ...getPartnerListConfig(),
                label: '合伙人',
              },
              {
                label: '所属地区',
                id: 'area',
                component: 'el-bus-select-area',
                commonFormat: true,
                commonFormatProps: ['province', 'city', 'region'],
                customClass: 'in-bus-form',
              },
              { label: '手机号', id: 'tel', type: 'input' },
            ],
          },
        ],
        form: [
          { label: '商户名称:', id: 'name', type: 'input' },
          { label: '商户昵称:', id: 'nickName', type: 'input' },
          { label: '所属合伙人:', id: 'partnerName', type: 'input' },
          { label: '地址:', id: 'area', type: 'input' },
          { label: '联系方式:', id: 'tel', type: 'input' },
        ],
        extraDialogs: [
          {
            title: '变更合伙人',
            hiddenReverseItems: [],
            form: [
              {
                ...getPartnerListConfig(),
                label: '所属合伙人:',
              },
            ],
            atConfirm: async (val) => {
              const { code } = await this.$elBusHttp.request(
                'flower/api/customer/change/partner',
                {
                  method: 'post',
                  data: val,
                }
              )
              if (code === 0) {
                this.$message.success('变更合伙人成功')
              }
            },
          },
        ],
        extraButtons: [
          {
            text: '变更合伙人',
            atClick: (row) => {
              this.$refs.crud.$refs.extraDialog[0].show(row)
              return false
            },
          },
        ],
      },
    }
  },
  head() {
    return {
      title: '商户列表',
    }
  },
  methods: {
    getDistrict(row) {
      return `${row.province || ''}${row.city || ''}${row.region || ''}${
        row.address || ''
      }`
    },
  },
}
</script>