index.vue 15.2 KB
Newer Older
1 2 3 4 5 6
<template>

  <div>
    <el-dialog
      :title="brandName"
      :visible.sync="dialogVisible"
7
      width="1080px"
8 9
      :before-close="handleClose()">
      <el-tabs v-model="activeName">
我在何方's avatar
我在何方 committed
10
        <el-tab-pane :label="$t('未授权客户')" name="first">
我在何方's avatar
我在何方 committed
11 12
          <div class="brand">
            <el-radio-group v-model="productBrank.unauthChargingModel" @change="changeModel">
我在何方's avatar
我在何方 committed
13 14
              <el-radio label="0">{{$t('统一收费标准')}}</el-radio>
              <el-radio label="1">{{$t('针对客户收费标准')}}</el-radio>
我在何方's avatar
我在何方 committed
15 16 17
            </el-radio-group>
          </div>
         <div v-if="productBrank.unauthChargingModel==0" class="brand">
我在何方's avatar
我在何方 committed
18 19
           <span>{{$t('针对所有未授权客户的收费模式')}}</span>
           <el-select v-model="productBrank.unauthDefaultFeeType" :placeholder="$t('请选择')" size="small" style="margin-right: 10px;">
我在何方's avatar
我在何方 committed
20 21 22 23 24 25 26
                <el-option
                  v-for="(item,index) in feeType"
                  :key="index"
                  :label="item.label"
                  :value="item.value">
                </el-option>
             </el-select>
我在何方's avatar
我在何方 committed
27
             <el-button type="primary" @click="updateBrank">{{$t('确定修改')}}</el-button>
我在何方's avatar
我在何方 committed
28
         </div>
29
          <el-form :inline="true" class="demo-form-inline">
我在何方's avatar
我在何方 committed
30 31
            <el-form-item :label="$t('关键字')">
              <el-input v-model="list1QueryParams.customerKey" :placeholder="$t('请填入关键字')"></el-input>
32 33
            </el-form-item>
            <el-form-item>
我在何方's avatar
我在何方 committed
34
              <el-button type="primary" @click="filterCustomer">{{$t('查询')}}</el-button>
35 36 37 38 39 40 41 42
            </el-form-item>
          </el-form>

          <el-table
            :data="list1"
            style="width: 100%">
            <el-table-column
              prop="customerName"
我在何方's avatar
我在何方 committed
43
              :label="$t('客户名称')">
44 45
            </el-table-column>
            <el-table-column
我在何方's avatar
我在何方 committed
46
              :label="$t('客户号码')">
47
                <template v-slot="{row}">
邓春圆's avatar
邓春圆 committed
48
               <show-contacts :key="row.phone" :phone-string="row.phone" ></show-contacts>
49
                </template>
50 51
            </el-table-column>
            <el-table-column
我在何方's avatar
我在何方 committed
52
              prop="feeScale"
我在何方's avatar
我在何方 committed
53
              :label="$t('收费类型')">
我在何方's avatar
我在何方 committed
54
              <template slot-scope="scope">
55 56
                <dict-tag
                  :type="DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL" :value="scope.row.feeScale" />
我在何方's avatar
我在何方 committed
57 58 59 60
              </template>
            </el-table-column>
            <el-table-column
              width="200px"
我在何方's avatar
我在何方 committed
61
              :label="$t('操作')">
62
              <template v-slot="{row}">
我在何方's avatar
我在何方 committed
63 64
                <el-button type="primary" size="mini" @click="handleAdd(row)">{{$t('添加授权')}}</el-button>
                <el-button v-if="productBrank.unauthChargingModel=='1'" type="primary" size="mini" @click="editAdd(row)">{{$t('修改收费')}}</el-button>
65
              </template>
我在何方's avatar
我在何方 committed
66

67 68
            </el-table-column>
          </el-table>
黄卓's avatar
黄卓 committed
69 70 71

          <pagination v-show="total1 > 0" :total="total1" :page.sync="list1QueryParams.pageNo" :limit.sync="list1QueryParams.pageSize"
                      @pagination="getList1" style="height: 40px"/>
72
        </el-tab-pane>
我在何方's avatar
我在何方 committed
73
        <el-tab-pane :label="$t('已授权客户')" name="second">
74 75 76 77 78
          <el-table
            :data="list2"
            style="width: 100%">
            <el-table-column
              prop="customerName"
我在何方's avatar
我在何方 committed
79
              :label="$t('客户名称')">
80 81
            </el-table-column>
            <el-table-column
82
                    width="260"
我在何方's avatar
我在何方 committed
83
              :label="$t('客户号码')">
84
                <template v-slot="{row}">
邓春圆's avatar
邓春圆 committed
85
                    <show-contacts :key="row.phone" :phone-string="row.phone" ></show-contacts>
86
                </template>
87
            </el-table-column>
88 89
            <el-table-column
              prop="fileUrl"
我在何方's avatar
我在何方 committed
90
              :label="$t('授权证明')">
91 92 93
              <template v-slot="{row}">
                <div v-if="!!row.fileUrl && row.fileUrl.length > 0">
                  <span v-for="(item, index) in row.fileUrl.split(',')">
我在何方's avatar
我在何方 committed
94
                    <a :href="item" target="_blank">{{$t('附件')}}{{ index + 1 }}</a>,
95 96 97 98
                  </span>
                </div>
              </template>
            </el-table-column>
99

100 101 102
            <el-table-column
              prop="startTime"
              width="200px"
我在何方's avatar
我在何方 committed
103
              :label="$t('授权时间')">
104
              <template v-slot="{row}">
105
                <span >{{row.startTime?(parseTime(row.startTime, '{y}-{m}-{d}') + ' - ' + parseTime(row.endTime, '{y}-{m}-{d}')):'永久'}}</span>
106
              </template>
107
            </el-table-column>
108 109 110 111 112 113 114 115
            <el-table-column
              prop="startTime"
              width="200px"
              :label="$t('添加时间')">
              <template v-slot="{row}">
                <span >{{parseTime(row.createTime)}}</span>
              </template>
            </el-table-column>
116 117 118
            <el-table-column
              prop="feeScale"
              :formatter="(row) => getDictDataLabel(DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL, row.feeScale)"
我在何方's avatar
我在何方 committed
119
              :label="$t('收费标准')">
120 121 122
            </el-table-column>
            <el-table-column
              prop="createUsername"
我在何方's avatar
我在何方 committed
123
              :label="$t('添加人')">
124
            </el-table-column>
125 126
            <el-table-column
              width="100px"
我在何方's avatar
我在何方 committed
127
              :label="$t('操作')">
128
              <template v-slot="{row}">
我在何方's avatar
我在何方 committed
129
                <el-button type="danger" size="mini" @click="handleDelete(row.id)">{{$t('删除')}}</el-button>
130 131 132
              </template>
            </el-table-column>
          </el-table>
黄卓's avatar
黄卓 committed
133 134 135

          <pagination v-show="total2 > 0" :total="total2" :page.sync="list2QueryParams.pageNo" :limit.sync="list2QueryParams.pageSize"
                      @pagination="getList2" style="height: 40px"/>
136 137 138 139
        </el-tab-pane>
      </el-tabs>
    </el-dialog>

黄卓's avatar
黄卓 committed
140
<!--  添加弹窗  -->
Marcus's avatar
Marcus committed
141
    <el-dialog
我在何方's avatar
我在何方 committed
142
      :title="$t('添加')"
Marcus's avatar
Marcus committed
143
      :visible.sync="addDialog.dialogVisible"
我在何方's avatar
我在何方 committed
144
      width="600px">
145

Marcus's avatar
Marcus committed
146
      <el-form ref="form" :model="addDialog.form" label-width="80px">
我在何方's avatar
我在何方 committed
147
        <el-form-item :label="$t('客户名称')">{{ addDialog.form.customerName }}</el-form-item>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
148
        <el-form-item :label="$t('授权类型')">
149 150
          <dict-selector v-model="addDialog.form.authType" :type="DICT_TYPE.ECW_AUTH_TYPE"></dict-selector>
        </el-form-item>
我在何方's avatar
我在何方 committed
151
        <el-form-item :label="$t('授权时间')" v-if="addDialog.form.authType==1">
我在何方's avatar
我在何方 committed
152
 <!--         <el-date-picker
Marcus's avatar
Marcus committed
153 154 155 156 157 158 159
            v-model="addDialog.dateRange"
            @chang="handleDatePick"
            type="daterange"
            range-separator=""
            value-format="timestamp"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
我在何方's avatar
我在何方 committed
160 161
          </el-date-picker> -->
        <el-date-picker clearable v-model="addDialog.form.startTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss" type="datetime" :placeholder="$t('请选择开始日期')" />
我在何方's avatar
我在何方 committed
162
         <span style="margin: 0 8px;">{{$t('')}}</span>
我在何方's avatar
我在何方 committed
163
          <el-date-picker clearable v-model="addDialog.form.endTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss" type="datetime" :placeholder="$t('请选择结束日期')" />
Marcus's avatar
Marcus committed
164
        </el-form-item>
我在何方's avatar
我在何方 committed
165
        <el-form-item :label="$t('收费模式')">
Marcus's avatar
Marcus committed
166 167
          <dict-selector v-model="addDialog.form.feeScale" :type="DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL"></dict-selector>
        </el-form-item>
我在何方's avatar
我在何方 committed
168
        <el-form-item :label="$t('授权证明')">
黄卓's avatar
黄卓 committed
169 170
          <file-upload v-model="addDialog.form.fileUrl"></file-upload>
        </el-form-item>
Marcus's avatar
Marcus committed
171 172
      </el-form>
      <span slot="footer" class="dialog-footer">
我在何方's avatar
我在何方 committed
173 174
        <el-button @click="addDialog.dialogVisible = false">{{$t('取消')}}</el-button>
        <el-button type="primary" @click="handleAddSubmit">{{$t('确定')}}</el-button>
Marcus's avatar
Marcus committed
175 176
      </span>
    </el-dialog>
我在何方's avatar
我在何方 committed
177 178
    <!--  添加弹窗  -->
        <el-dialog
我在何方's avatar
我在何方 committed
179
          :title="$t('修改单个客户收费模式')"
我在何方's avatar
我在何方 committed
180 181 182
          :visible.sync="editDialog.dialogVisible"
          width="500px">
          <el-form ref="form" :model="editDialog.form" label-width="80px">
我在何方's avatar
我在何方 committed
183
            <el-form-item :label="$t('客户名称')">{{ editDialog.customerName }}</el-form-item>
我在何方's avatar
我在何方 committed
184

我在何方's avatar
我在何方 committed
185 186
            <el-form-item :label="$t('收费模式')">
              <el-select v-model="editDialog.form.feeScale" :placeholder="$t('请选择')" size="small" style="margin-right: 10px;">
我在何方's avatar
我在何方 committed
187 188 189 190 191 192 193 194 195 196 197
                 <el-option
                   v-for="item in feeType"
                   :key="item.value"
                   :label="item.label"
                   :value="item.value">
                 </el-option>
                </el-select>
              <!-- <dict-selector v-model="editDialog.form.feeScale" :type="DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL"></dict-selector> -->
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
我在何方's avatar
我在何方 committed
198 199
            <el-button type="primary" @click="handleEditSubmit">{{$t('确定修改')}}</el-button>
            <el-button @click="editDialog.dialogVisible = false">{{$t('关闭窗口')}}</el-button>
我在何方's avatar
我在何方 committed
200 201
          </span>
        </el-dialog>
202 203 204 205 206
  </div>
</template>

<script>
import {
Marcus's avatar
Marcus committed
207
  createProductBrandEmpower,
208 209 210 211
  deleteProductBrandEmpower,
  getProductBrandEmpowerPageAuth,
  getProductBrandEmpowerPageUnauth
} from "@/api/ecw/productBrandEmpower"
我在何方's avatar
我在何方 committed
212
import {getProductBrank,changeFeeModel,setUnauthCustomerFeeType} from "@/api/ecw/productBrank";
Marcus's avatar
Marcus committed
213
import DictSelector from "@/components/DictSelector"
214
import { DICT_TYPE, getDictDataLabel } from '@/utils/dict'
黄卓's avatar
黄卓 committed
215
import FileUpload from '@/components/FileUpload'
216
import { parseTime } from '@/utils/ruoyi'
217
import ShowContacts from "@/views/ecw/productBrank/Empower/components/showContacts.vue";
218 219 220

export default {
  name: "Empower",
Marcus's avatar
Marcus committed
221
  components: {
222
      ShowContacts,
黄卓's avatar
黄卓 committed
223 224
    DictSelector,
    FileUpload
Marcus's avatar
Marcus committed
225
  },
226 227 228 229 230 231 232 233 234 235 236 237 238
  props: {
    id: {
      type: Number,
      default: 0
    },
    brandName: String,
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
Marcus's avatar
Marcus committed
239
      DICT_TYPE,
240 241
      getDictDataLabel,
      parseTime,
242 243
      dialogVisible: false,
      activeName: 'first',
黄卓's avatar
黄卓 committed
244 245
      total1: 0,
      total2: 0,
246
      list1: [],
Marcus's avatar
Marcus committed
247
      list2: [],
我在何方's avatar
我在何方 committed
248
      feeType:[{
249 250 251
        label:this.$t('无牌价'),
        value:0
      },{
我在何方's avatar
我在何方 committed
252
        label:this.$t('有牌价'),
我在何方's avatar
我在何方 committed
253 254
        value:1
      },{
我在何方's avatar
我在何方 committed
255
        label:this.$t('中性价'),
我在何方's avatar
我在何方 committed
256 257 258
        value:2
      }],
      unauthChargingModel:0,
黄卓's avatar
黄卓 committed
259
      list1QueryParams: {
260
        pageNo: 1,
黄卓's avatar
黄卓 committed
261 262 263 264 265 266 267
        pageSize: 10,
        customerKey: undefined
      },
      list2QueryParams: {
        pageNo: 1,
        pageSize: 10,
      },
我在何方's avatar
我在何方 committed
268
      productBrank:{},
Marcus's avatar
Marcus committed
269 270 271 272 273 274 275
      addDialog: {
        dialogVisible: false,
        customerName: '',
        form: {
          "customerContactsId": 0,
          "customerId": 0,
          "endTime": "",
276
          "feeScale": '0',
Marcus's avatar
Marcus committed
277 278 279
          "fileUrl": "",
          "productBrandId": null,
          "startTime": "",
280 281
          "status": 0,
          "authType":'0'
Marcus's avatar
Marcus committed
282 283
        },
        dateRange: []
我在何方's avatar
我在何方 committed
284 285 286 287 288 289 290 291 292 293
      },
      editDialog: {
        dialogVisible: false,
        customerName: '',
        form: {
          "customerContactsId": 0,
          "customerId": 0,
          "feeScale":1,
          "productBrandId": null,
        }
Marcus's avatar
Marcus committed
294
      }
295 296
    }
  },
Marcus's avatar
Marcus committed
297
  mounted() {
298 299 300

  },
  methods: {
我在何方's avatar
我在何方 committed
301 302 303 304 305 306 307 308 309
    getBrank(){
      getProductBrank(this.id).then(r => {
        this.productBrank = r.data
        if(this.productBrank.unauthDefaultFeeType){
          this.productBrank.unauthDefaultFeeType = parseInt(this.productBrank.unauthDefaultFeeType)
        }
        this.unauthChargingModel = this.productBrank.unauthChargingModel
      })
    },
Marcus's avatar
Marcus committed
310 311 312 313 314 315
    handleAddSubmit(){
      this.addDialog.form.productBrandId = this.id
      createProductBrandEmpower(this.addDialog.form).then(() => {
        this.addDialog.dialogVisible = false
        this.getList1()
        this.getList2()
黄卓's avatar
黄卓 committed
316
        this.resetForm("form");
Marcus's avatar
Marcus committed
317 318
      })
    },
我在何方's avatar
我在何方 committed
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
    handleEditSubmit(){
      var data = {}
      data = this.editDialog.form
      data.productBrandId = this.id
      setUnauthCustomerFeeType(data).then(() => {
        this.getList1()
        this.editDialog = {
          dialogVisible: false,
          customerName: '',
          form: {
            "customerContactsId": 0,
            "customerId": 0,
            "feeScale":1,
            "productBrandId": null,
          }
        }
      })
    },
Marcus's avatar
Marcus committed
337 338 339
    handleDatePick(e){
      console.log(e)
    },
340
    handleClose() {},
黄卓's avatar
黄卓 committed
341 342 343 344
    filterCustomer() {
      this.list1QueryParams.pageNo = 1
      this.getList1()
    },
我在何方's avatar
我在何方 committed
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
    updateBrank(){
      let params = {}
       if(this.productBrank.unauthChargingModel==1){
         params = {
             id:this.productBrank.id,
             unauthChargingModel:this.productBrank.unauthChargingModel,
           }
       }else{
         params = {
             id:this.productBrank.id,
             unauthChargingModel:this.productBrank.unauthChargingModel,
             unauthDefaultFeeType:this.productBrank.unauthDefaultFeeType
           }
       }
       console.log(params)
       changeFeeModel(params).then(r=>{
         this.getList1()
         this.getList2()
         this.getBrank()
我在何方's avatar
我在何方 committed
364
         this.$modal.msgSuccess(this.$t("修改成功"));
我在何方's avatar
我在何方 committed
365 366 367 368 369 370 371
       })
    },
    changeModel(){
      if(this.productBrank.unauthChargingModel==1&&this.unauthChargingModel != this.productBrank.unauthChargingModel){
        this.updateBrank()
      }
    },
Marcus's avatar
Marcus committed
372 373 374 375 376
    handleAdd(row) {
      this.addDialog.form.customerId = row.customerId
      this.addDialog.form.customerName = row.customerName
      this.addDialog.dialogVisible = true
    },
我在何方's avatar
我在何方 committed
377 378
    editAdd(row){
      this.editDialog.form.customerId = row.customerId
邓春圆's avatar
邓春圆 committed
379
      this.editDialog.form.feeScale = row.feeScale;
我在何方's avatar
我在何方 committed
380 381 382 383 384 385
      if(row.customerContactsId){
          this.editDialog.form.customerContactsId = row.customerContactsId
      }
      this.editDialog.customerName = row.customerName
      this.editDialog.dialogVisible = true
    },
386
    handleDelete(id) {
我在何方's avatar
我在何方 committed
387 388 389
      this.$confirm(this.$t('确认删除该用户的授权')+'?', this.$t('提示'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
390 391 392 393 394 395 396
        type: 'warning'
      }).then(() => {
        deleteProductBrandEmpower(id).then(r => {
          this.getList1()
          this.getList2()
          this.$message({
            type: 'success',
我在何方's avatar
我在何方 committed
397
            message: this.$t('撤销授权成功')
398 399 400 401 402
          });
        })
      }).catch(() => {
        this.$message({
          type: 'info',
我在何方's avatar
我在何方 committed
403
          message: this.$t('已取消删除')
404 405
        });
      });
406 407
    },
    getList1(){
黄卓's avatar
黄卓 committed
408
      getProductBrandEmpowerPageUnauth({...this.list1QueryParams, productBrandId: this.id}).then(r => {
409
        this.list1 = r.data.list
黄卓's avatar
黄卓 committed
410
        this.total1 = r.data.total
411 412 413
      })
    },
    getList2() {
黄卓's avatar
黄卓 committed
414
      getProductBrandEmpowerPageAuth({...this.list2QueryParams, productBrandId: this.id}).then(r => {
415 416 417 418 419 420 421
        this.list2 = r.data.list
      })
    }
  },
  watch: {
    visible(v){
      if (v){
422 423
        this.list1QueryParams.pageNo = 1
        this.list2QueryParams.pageNo = 1
我在何方's avatar
我在何方 committed
424
        this.unauthDefaultFeeType = "1"
425
        this.list1QueryParams.customerKey = ''
426 427
        this.getList1()
        this.getList2()
我在何方's avatar
我在何方 committed
428
        this.getBrank()
429 430 431 432 433
      }
      this.dialogVisible = v
    },
    dialogVisible(v) {
      this.$emit('update:visible', v)
Marcus's avatar
Marcus committed
434 435 436 437 438
    },

    'addDialog.dateRange'(v) {
      this.addDialog.form.startTime = v[0]
      this.addDialog.form.endTime = v[1]
439 440 441 442 443 444
    }
  }
}
</script>

<style scoped>
我在何方's avatar
我在何方 committed
445 446 447
.brand{
  padding-bottom: 20px;
}
448
</style>