fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
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
<template>
    <div class="dealerMgt">
        <list-condition-template ref="table" :isExistBtn="true" :form="listQuery" :formLabel="formLabel" :tableData="tableData" :total="total" @page-info-change="pageInfoChange">
            <template slot="otherElement">
              <el-col class="formLayout" :xs='12' :sm='12' :md='12' :lg='6' :offset="0">
                <el-form-item label="经销商城市:" prop="aeraId">
                    <address-component ref="addressComponent" :adressArr.sync='adressArray'></address-component>
                </el-form-item>
              </el-col>
              <el-col :span="24" :offset="0" class="buttonPosition">
                <el-button size="mini" type="primary" @click="queryData">查询</el-button>
                <el-button size="mini" @click="resetQuery">重置</el-button>
              </el-col>
            </template>
            <template slot="operationSection">
                <el-button size="mini" type="success" @click="addItem">新增</el-button>
            </template>
            <template slot="columns">
                <el-table-column label="经销商名称" prop="merchantName" width="160px" show-overflow-tooltip></el-table-column>
                <el-table-column label="所在地区" prop="aera" width="180px" show-overflow-tooltip>
                  <template slot-scope="scope">
                     {{scope.row.province}}{{scope.row.city}}{{scope.row.aera}}
                  </template>
                </el-table-column>
                <el-table-column label="经销商状态" prop="status" :formatter="statusFormatter" width="140px"></el-table-column>
                <el-table-column label="联系人" prop="contactName"></el-table-column>
                <el-table-column label="联系电话" prop="contactPhone" width="180px"></el-table-column>
                <el-table-column label="门店" prop="contactPhone">
                    <template slot-scope="scope">
                         <el-button type="text" v-if="scope.row.shopCount > 0" @click="$router.push({name:'shopMgtList',params:{merchantId:scope.row.merchantId}})">{{scope.row.shopCount}}</el-button>
                         <span v-else>{{scope.row.shopCount}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="创建时间" prop="createdOn" width="180px"></el-table-column>
                <el-table-column label="审核状态" prop="auditStatus">
                  <template slot-scope="scope">
                    <span v-if="scope.row.auditStatus == '0'">
                      <span class="statusTag" :style="{ background: '#d0931e'}"></span>
                      <span>待审核</span>
                    </span>
                    <span v-else-if="scope.row.auditStatus == '1'">
                      <span class="statusTag" :style="{ background: '#22d01e'}"></span>
                      <span>已通过</span>
                    </span>
                    <span v-else-if="scope.row.auditStatus == '2'">
                      <span class="statusTag" :style="{ background: '#d0261e'}"></span>
                      <span>已驳回</span>
                    </span>
                    <span v-else>
                      <span>-</span>
                    </span>
                  </template>
                </el-table-column>
                <el-table-column label="操作" :width="`${2 * $store.getters.colSize}px`">
                    <template slot-scope="scope">
                      <wly-btn @click="checkitem(scope.row,scope.$index)" >查看</wly-btn>
                      <!-- <wly-btn v-if="scope.row.sourceType === '1'" :type="'primary'" @click="updateItem(scope.row,scope.$index)" >编辑</wly-btn> -->
                      <wly-btn v-if="scope.row.auditStatus === '0'" :type="'warning'" @click="reviewItem(scope.row,scope.$index)" >审核</wly-btn>
                    </template>
                </el-table-column>
            </template>
        </list-condition-template>
        <el-dialog :visible.sync="dialogVisible" :title="title" :close-on-click-modal="false" :modal-append-to-body="false" v-if="dialogVisible" width="40%">
            <el-form size="mini" label-width="120px" :model="form" :rules="formRules" ref="form">
                   <el-form-item label="经销商名称:" prop="merchantName">
                      <el-input v-model="form.merchantName" placeholder="请输入经销商名称"></el-input>
                   </el-form-item>
                   <el-form-item label="经销商手机号:" prop="contactPhone">
                      <el-input v-model="form.contactPhone" placeholder="请输入经销商手机号"></el-input>
                   </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" type="primary" :loading="loading" @click="submit">保存</el-button>
                <el-button size="mini" @click="dialogVisible=false">关闭</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import { ecMarketMerchantQueryEcMarketMerchantList, ecMarketMerchantInsertSelective } from '../../../api/MarketingMgt/dealerMgt'
import { validateMobile } from '@/utils/validator'
import addressComponent from '@/components/formTemplate/addressComponent.vue'
var _this = null
export default {
  name: 'dealerMgtList',
  components: { addressComponent },
  data () {
    return {
      title: null,
      adressArray: [],
      form: {
        merchantName: null,
        contactPhone: null
      },
      dialogVisible: false,
      loading: false,
      formRules: {
        merchantName: [
          { required: true, message: '请输入经销商名称', trigger: 'change' },
          { message: '经销商名称最大长度为32', max: 32, trigger: 'change' }
        ],
        contactPhone: [
          { validator: validateMobile, required: true, trigger: 'change' }
        ]
      },
      tableData: [],
      total: 0,
      listQuery: {
        merchantName: '',
        startDate: '',
        endDate: null,
        auditStatus: '',
        status: null,
        aeraId: null
      },
      formLabel: [
        {
          model: 'startDate',
          label: '创建时间',
          type: 'date',
          pickerOptions: {
            disabledDate (time) {
              return _this.listQuery.endDate && time.getTime() >= new Date(_this.listQuery.endDate).getTime() + 86400000
            }
          },
          timeClass: 'start-time-style'
        },
        {
          model: 'endDate',
          label: '-',
          customLabel: '创建时间',
          type: 'date',
          labelWidth: '20px',
          pickerOptions: {
            disabledDate (time) {
              return _this.listQuery.startDate && time.getTime() <= new Date(_this.listQuery.startDate).getTime() - 86400000
            }
          },
          timeClass: 'end-time-style'
        },
        {
          model: 'merchantName',
          label: '经销商名称',
          type: 'input',
          labelWidth: '90px'
        },
        {
          model: 'auditStatus',
          label: '审核状态',
          type: 'select',
          opts: [
            {
              id: '0',
              name: '待审核'
            },
            {
              id: '1',
              name: '已通过'
            },
            {
              id: '2',
              name: '已驳回'
            }
          ]
        },
        {
          model: 'status',
          label: '经销商状态',
          labelWidth: '90px',
          type: 'select',
          opts: [
            {
              id: '0',
              name: '注册中'
            },
            {
              id: '1',
              name: '正常'
            },
            {
              id: '2',
              name: '停用'
            },
            {
              id: '3',
              name: '未完善'
            }
          ]
        }
      ]
    }
  },
  created () {
    _this = this
  },
  /**
   * 数据变化后刷新列表
   */
  activated () {
    this.queryList(this.$refs.table.getPageInfo())
  },
  methods: {
    disabledDate (time) {
      return time.getTime() > Date.now()
    },
    /**
     *保存经销商
   */
    submit () {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.loading = true
          ecMarketMerchantInsertSelective(this.form).then(res => {
            if (res.code === '0') {
              this.$message({
                message: '保存成功',
                type: 'success'
              })
              this.loading = false
              this.dialogVisible = false
              this.$refs.table.changeCondition()
            } else {
              this.loading = false
            }
          }).catch(() => {
            this.loading = false
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    statusFormatter (row, column, cellValue, index) {
      switch (row.status) {
        case '0': return '注册中'
        case '1': return '正常'
        case '2': return '停用'
        default: return '未完善'
      }
    },
    auditStatusFormatter (row, column, cellValue, index) {
      switch (row.auditStatus) {
        case '0': return '待审核'
        case '1': return '已通过'
        case '2': return '已驳回'
        default: return '-'
      }
    },
    /**
     * 新增
     */
    addItem () {
      this.dialogVisible = true
      this.title = '添加经销商'
      this.form.merchantName = null
      this.form.contactPhone = null
    //   this.$router.push({ name: 'dealerMgtAdd' })
    },
    /**
       *查看
       */
    checkitem (row, index) {
      this.$router.push({
        path: '/dash/dealerMgt/detail',
        query: {
          id: row.merchantId
        }
      })
    },
    /**
     * 修改
     */
    updateItem (row, index) {
      this.$router.push({
        path: '/dash/dealerMgt/edit',
        query: {
          id: row.merchantId
        }
      })
    },
    /**
     * 审核
     */
    reviewItem (row, index) {
      this.$router.push({
        path: '/dash/dealerMgt/review',
        query: {
          id: row.merchantId
        }
      })
    },
    /**
       * '分页信息改变时查询列表
       */
    pageInfoChange (pageInfo) {
      this.queryList(pageInfo)
    },
 
    /**
     * 重置
     */
    resetQuery () {
      this.adressArray = []
      this.$refs.table.reloadCurrent()
    },
    /**
     * 点击查询按钮
     */
    queryData () {
      this.$refs.table.changeCondition()
    },
    /**
     * 查询列表
     */
    queryList (pageInfo = { pageNum: 1, pageSize: 10 }) {
      const length = this.adressArray.length
      this.listQuery.aeraId = length ? this.adressArray[length - 1] : null
      this.listQuery.sourceType = this.listQuery.status === '3' ? '1' : null
      const param = JSON.parse(JSON.stringify(this.listQuery))
      param.status = this.listQuery.status === '3' ? null : this.listQuery.status
      ecMarketMerchantQueryEcMarketMerchantList(Object.assign({ param }, pageInfo)).then(res => {
        if (res.code === '0') {
          this.tableData = res.data.list
          this.total = res.data.total
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
.dealerMgt{
  .formLayout{
   display: flex;
   .el-form-item{
     flex-grow:1;
     /deep/.el-cascader{
       width:calc(100% - 97px);
     }
   }
  }
}
</style>