cloudroam
2025-03-28 cef2bb0eeeb91a22860cf5d23c7348af1ba921dc
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<template>
  <el-bus-crud ref="crud" v-bind="tableConfig" />
</template>
 
<script>
import {
  getStationListConfig,
  getAuditForm,
  getSupplierTypeListConfig,
} from '@/utils/form-item-config'
export default {
  data() {
    return {
      tableConfig: {
        url: 'flower/api/supplier/page',
        editUrl: 'flower/api/supplier/page/update',
        hasNew: false,
        hasDelete: false,
        operationAttrs: {
          width: '200px',
          fixed: 'right',
        },
        beforeOpen: (row, isNew) => {
          if (!isNew) {
            row.districtStr = this.getDistrict(row)
          }
        },
        columns: [
          { label: '供应商ID', prop: 'id', minWidth: '120px' },
          {
            label: '供应商名称',
            prop: 'name',
            minWidth: '120px',
            // fixed: 'left',
          },
          { label: '供应商类型', prop: 'typeName', minWidth: '100px' },
          {
            label: '地区',
            formatter: (row) =>
              `${row.province || ''}${row.city || ''}${row.region || ''}${
                row.address || ''
              }`,
            minWidth: '200px',
          },
          { label: '联系人', prop: 'contactName', minWidth: '100px' },
          { label: '联系方式', prop: 'contactTel', minWidth: '120px' },
          { label: '注册手机号', prop: 'registerTel', minWidth: '120px' },
          { label: '注册时间', prop: 'createTime', minWidth: '180px' },
          { label: '审核通过时间', prop: 'passTime', minWidth: '180px' },
          { label: '所属集货站', prop: 'stationName', minWidth: '120px' },
          { label: '状态', prop: 'statusStr', minWidth: '100px' },
          {
            label: '是否显示',
            formatter: (row) => (
              <el-switch
                value={row.showed}
                onChange={this.onShownChange.bind(this, row)}
              ></el-switch>
            ),
            minWidth: 120,
            fixed: 'right',
          },
          {
            label: '启用/禁用',
            formatter: (row) => (
              <el-switch
                value={row.isEnabled}
                onChange={this.onEnabledChange.bind(this, row)}
              ></el-switch>
            ),
            minWidth: 120,
            fixed: 'right',
          },
        ],
        searchForm: [
          {
            type: 'row',
            items: [
              {
                label: '供应商ID', id: 'id', type: 'input',
                rules: {
                  required: false,
                  pattern: /^\d*$/,
                  message: '请输入合法的供应商ID',
                  trigger: 'blur',
                },
              },
              { label: '供应商名称', id: 'name', type: 'input' },
              { label: '手机号', id: 'tel', type: 'input' },
              {
                label: '申请日期',
                id: 'createDateBeginStr',
                component: 'el-bus-date-range',
                commonFormat: true,
                commonFormatProps: ['createDateBeginStr', 'createDateEndStr'],
                customClass: 'in-bus-form',
              },
              {
                label: '审核状态',
                id: 'status',
                type: 'bus-select-dict',
                el: {
                  code: 'supplier_status',
                  clearable: true,
                  style: 'width:100%',
                },
              },
              {
                ...getStationListConfig(),
                label: '所属集货站',
              },
              {
                label: '启用/禁用',
                id: 'isEnabled',
                type: 'bus-select-dict',
                default: '1',
                el: {
                  code: 'USER_ENABLED_OR_DISABLED',
                  clearable: true,
                  style: 'width:100%',
                },
              },
            ],
          },
        ],
        form: [
          {
            type: 'row',
            span: 12,
            items: [
              {
                label: '供应商名称:',
                id: 'name',
                type: 'input',
                rules: {
                  required: true,
                  message: '请输入供应商名称',
                  trigger: 'blur',
                },
              },
              {
                ...getSupplierTypeListConfig(),
                str: true,
                strKey: 'typeName',
                rules: {
                  required: true,
                  message: '请选择供应商类型',
                },
              },
              {
                label: '供应商头像:',
                id: 'cover',
                type: 'bus-upload',
                el: {
                  listType: 'picture-card',
                  valueType: 'string',
                  limit: 1,
                  limitSize: 2,
                  tipText: '大小不超过2M',
                },
                forceDisabled: true,
                rules: {
                  required: true,
                  message: '请上传供应商头像',
                },
              },
              {
                label: '地区:',
                id: 'province',
                component: 'el-bus-select-area',
                span: 24,
                commonFormat: true,
                commonFormatProps: ['province', 'city', 'region'],
                str: true,
                strKey: 'districtStr',
                rules: { required: true, message: '请选择地区' },
              },
              {
                label: '详细地址:',
                id: 'address',
                type: 'input',
                span: 24,
                rules: {
                  required: true,
                  message: '请输入详细地址',
                  trigger: 'blur',
                },
              },
              {
                label: '联系人:',
                id: 'contactName',
                type: 'input',
                rules: {
                  required: true,
                  message: '请输入联系人',
                  trigger: 'blur',
                },
              },
              {
                label: '联系方式:',
                id: 'contactTel',
                type: 'input',
                rules: {
                  required: true,
                  message: '请输入联系方式',
                  trigger: 'blur',
                },
              },
              {
                ...getStationListConfig(),
                rules: { required: true, message: '请选择所属集货站' },
              },
              {
                label: '店铺简介:',
                id: 'description',
                type: 'input',
                el: {
                  type: 'textarea',
                  rows: 4,
                },
                span: 24,
                rules: {
                  required: true,
                  message: '请输入店铺简介',
                  trigger: 'blur',
                },
              },
              {
                id: 'idcardType',
                type: 'input',
                hidden: () => true,
              },
              {
                label: '身份证正反面:',
                id: 'idCards',
                component: 'el-bus-upload',
                el: {
                  listType: 'picture-card',
                },
                forceDisabled: true,
                commonFormat: true,
                span: 24,
                hidden: (row) => row.idcardType !== '1',
                rules: { required: true, message: '请上传身份证正反面' },
              },
              {
                label: '营业执照:',
                id: 'pictures',
                component: 'el-bus-upload',
                el: {
                  listType: 'picture-card',
                },
                forceDisabled: true,
                commonFormat: true,
                span: 24,
                hidden: (row) => row.idcardType !== '2',
                rules: { required: true, message: '请上传营业执照' },
              },
            ],
          },
          {
            label: '状态:',
            id: 'status',
            type: 'input',
            str: true,
            readonly: true,
            hidden: (row, item, mode) => mode !== 'view',
            span: 24,
          },
          {
            label: '不通过原因:',
            id: 'rejectReason',
            type: 'input',
            el: {
              type: 'textarea',
            },
            readonly: true,
            hidden: (row, item, mode) => mode !== 'view' || row.status !== 'R',
            span: 24,
          },
        ],
        extraButtons: [
          {
            text: '审核',
            show: (row) => row.status === 'U',
            atClick: (row) => {
              row.districtStr = this.getDistrict(row)
              this.$refs.crud.$refs.extraDialog[0].show(row)
              return false
            },
          },
          {
            text: '修改集货站',
            atClick: (row) => {
              this.$refs.crud.$refs.extraDialog[1].show(row)
              return false
            },
          },
        ],
        extraDialogs: [
          {
            title: '审核',
            readonly: true,
            form: getAuditForm(),
            atConfirm: async (val) => {
              const { code } = await this.$elBusHttp.request(
                'flower/api/supplier/audit',
                {
                  method: 'post',
                  data: {
                    ...val,
                    rejectReason: val.auditRejectReason,
                  },
                }
              )
              if (code === 0) {
                this.$message.success('操作成功')
              }
            },
          },
          {
            title: '修改集货站',
            hiddenReverseItems: [],
            form: [
              {
                ...getStationListConfig(),
              },
            ],
            atConfirm: async (val) => {
              const { code } = await this.$elBusHttp.request(
                'flower/api/supplier/change/station',
                {
                  method: 'post',
                  data: val,
                }
              )
              if (code === 0) {
                this.$message.success('操作成功')
              }
            },
          },
        ],
      },
    }
  },
  head() {
    return {
      title: '供应商列表',
    }
  },
  methods: {
    getDistrict(row) {
      return `${row.province || ''}${row.city || ''}${row.region || ''}`
    },
    onShownChange(row, e) {
      const url = 'flower/api/supplier/page/showed'
      const text = e ? '显示' : '隐藏'
      this.$elBusUtil
        .confirm(`确定要${text}这个供应商的商品吗?`)
        .then(async () => {
          const { code } = await this.$elBusHttp.request(url, {
            params: {
              id: row.id,
            },
          })
          if (code === 0) {
            this.$message.success(`${text}成功`)
            this.$refs.crud.getList()
          }
        })
        .catch(() => {})
    },
    onEnabledChange(row, e) {
      const url = 'flower/api/supplier/page/isEnable'
      const text = e ? '启用' : '禁用'
      this.$elBusUtil
        .confirm(`确定要${text}这个供应商吗?`)
        .then(async () => {
          const { code } = await this.$elBusHttp.request(url, {
            params: {
              id: row.id,
            },
          })
          if (code === 0) {
            this.$message.success(`${text}成功`)
            this.$refs.crud.getList()
          }
        })
        .catch(() => {})
    },
  },
}
</script>