accountList.vue 13 KB
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 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
<!-- 虚拟账户成本 -->
<template>
  <div>
    <div class="d2-container-content" style="padding: 10px 20px;">
      <div class=" header" slot="header">
        <d2-search ref="showSearch" :search-form="searchForm" :form-data="showFormData">
          <!-- :slot-scope="item" -->
          <template slot="channelType">
            <el-cascader style="width: 50%;" :options="merchantLevelOptions[nameToOption[searchForm.channelType]]"
                         :props="{ checkStrictly: true, value: 'id', label: 'merchantName' }" :show-all-levels="false"
                         v-model="merchantLevelVal" clearable filterable />
          </template>
        </d2-search>
        <div class="up-btns">
          <el-button :id="tableParams.btnId" size="small" type="primary">
            查询
          </el-button>
          <el-button size="small" @click="handleReset">
            重置
          </el-button>
        </div>
      </div>
    </div>
    <div class="d2-container-content">
      <span slot="left">
        <auth-button category="Button" :show-btn-ids="['9061003']" />
      </span>
      <d2-table ref="merchantTable" :get-list-api="getListApi" :search-form="searchFormSearch" :table-params="tableParams"
                :before-search-fn="beforeSearchFn">
        <!-- <auth-button slot="auth-button" slot-scope="scope" :data="scope.scope" /> -->
        <div slot="auth-button" slot-scope="scope" class="btnClass">
          <template v-if="scope.scope.ysemRefedFlag == 'Y'">
            <auth-button slot="auth-button" :show-btn-ids="['9061007']"
                       :data="scope.scope" />
            <auth-button v-if="!scope.scope.ineffectiveReceiptMode" slot="auth-button" :show-btn-ids="['9061008']" :data="scope.scope" />
          </template>
          <auth-button v-else slot="auth-button" :show-btn-ids="['9061001']" :data="scope.scope" />
        </div>
      </d2-table>
    </div>
    <baseDialog :is-show.sync="accountDetailVisible" :config="dialogConfig.setting" :dialog-config="dialogConfig.config"
                @closeDialog="handleDetailClose">
      <account-detail v-if="accountDetailVisible" :account-detail-visible="accountDetailVisible"
                      :merchant-row="merchantRow" />
    </baseDialog>
    <baseDialog :is-show.sync="receiptModeVisible" :dialog-config="modeDialogConfig.config"
                @closeDialog="handleModeClose" @handleClick="handleModeConfirm">
      <edit-account-mode ref="editAccountModeForm" v-if="receiptModeVisible" @handleModeClose="handleModeClose" :merchant-row="merchantRow" />
    </baseDialog>
    <!-- <settingDetail :show="settingDetailVisible"></settingDetail> -->
  </div>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { getListApi, getMerchantLevelApi, synchronizeBusinessInformation } from '@api/publicAccount'
import { mapActions } from 'vuex'
import accountDetail from './accountDetail'
import editAccountMode from './components/editAccountMode.vue'
import { BaseData, merchantStoreServiceList, receiptModeList } from '@/common/constants.js'
// import baseDialog from '@/components/baseDialog/baseDialog'
// import settingDetail from './settingDetail.vue'
export default {
  name: 'AccountList',
  data() {
    return {
      // 账户详情
      accountDetailVisible: false,
      // 修改到账模式
      receiptModeVisible: false,
      // settingDetailVisible: false,
      merchantRow: {},
      nameToOption: {
        1: 'dj',
        2: 'gh',
        8: 'zy'
      },
      merchantLevelOptions: {
        dj: [],
        gh: [],
        zy: []
      },
      // 搜索
      merchantLevelVal: [],
      searchForm: {
        merchantType: '',
        channelType: '',
        merchantName: '',
        accountStatus: '',
        merchantId: '',
        yseUserCode: '',
        ysemRefedFlag: '',
        receiptMode: ''
      },
      searchFormSearch: {},
      showFormData: [{
        label: '商户分类',
        name: 'merchantType',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confLabel',
        optionsName: 'merchantStoreServiceList'
      }, {
        label: '渠道',
        name: 'channelType',
        addHtml: 'channelType',
        type: 'select',
        width: '50%',
        optionList: [],
        optionId: 'value',
        optionLabel: 'name',
        optionsName: 'channelTypeList',
        changeAttr: (value, targetItem) => {
          this.merchantLevelVal = []
        }
      }, {
        label: '商户名称',
        name: 'merchantName',
        type: 'input',
        isClear: true,
        placeholder: '请输入4S店/服务商/园区店名称',
        keyFn: this.keyDowmGetList
      }, {
        label: '账户状态',
        name: 'accountStatus',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confLabel',
        optionsName: 'statusList'
      }, {
        label: '商户号',
        name: 'merchantId',
        type: 'input',
        inputType: 'number',
        maxlength: '9',
        isClear: true,
        placeholder: '请输入4S店/服务商/园区店商户号',
        keyFn: this.keyDowmGetList
      }, {
        label: '虚账编码',
        name: 'yseUserCode',
        type: 'input',
        maxlength: '20',
        isClear: true,
        placeholder: '请输入虚账编码',
        keyFn: this.keyDowmGetList
      }, {
        label: "关联状态",
        name: "ysemRefedFlag",
        type: "select",
        // noDataText: "请先选择订单来源",
        optionList: [],
        optionId: "confId",
        optionLabel: "confLabel",
        optionsName: "ysemRefedFlagList"
      }, {
        label: '到账模式',
        name: "receiptMode",
        type: "select",
        optionList: [],
        optionId: "confId",
        optionLabel: "confValue",
        optionsName: "receiptModeList"
      }],
      // 表格
      getListApi: getListApi,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [{
          label: '名称',
          prop: 'merchantName'
        }, {
          label: '商户号',
          prop: 'merchantId'
        }, {
          label: '商户分类',
          prop: 'merchantType',
          formatter: (cellValue) => {
            var html = ''
            if (cellValue.merchantType) {
              if (cellValue.merchantType == '6' || cellValue.merchantType == '9') {
                html = '园区店'
              } else if (cellValue.merchantType == '7') {
                html = '服务商'
              } else {
                html = '4S店'
              }
            }
            return html
          }
        }, {
          label: '渠道',
          prop: '',
          formatter: cellValue => {
            // return cellValue.channelType === 1 ? '嘀加' : '广汇'
            return this.baseData.channelTypeShow[cellValue.channelType]
          }
        }, {
          label: '账户状态',
          prop: 'accountStatus',
          formatter: (cellValue) => {
            return this.baseData.statusList.find(item => item.confId === cellValue.accountStatus).confLabel
          }
        },
        {
          label: '关联状态',
          prop: 'ysemRefedFlag',
          formatter: (cellValue) => {
            return cellValue.ysemRefedFlag == "Y" ? '已关联' : '未关联'
          }
        },
        {
          label: '到账模式',
          prop: 'receiptMode',
          formatter: (cellValue) => {
            return cellValue.receiptMode == '1' ? 'T+1' : cellValue.receiptMode == '2' ? 'D+1' : '-'
          }
        },
        {
          label: '虚账编码',
          prop: 'yseUserCode'
        },
        {
          label: '最近更新时间',
          prop: 'updatedDate',
          formatter: (cellValue) => {
            return Util.dateFormate(cellValue.updatedDate, 'YYYY-MM-DD HH:mm:ss')
          }
        }]
      },
      baseData: {
        channelTypeList: [],
        statusList: [{
          confId: 1,
          confLabel: '未申请'
        }, {
          confId: 2,
          confLabel: '审核中'
        }, {
          confId: 3,
          confLabel: '生效'
        }, {
          confId: 4,
          confLabel: '失败'
        }],
        channelTypeShow: {
          1: '嘀加',
          2: '广汇',
          8: '直营'
        },
        ysemRefedFlagList: [{
          confLabel: '已关联',
          confId: 'Y'
        },
        {
          confLabel: '未关联',
          confId: 'N'
        }],
        merchantStoreServiceList: merchantStoreServiceList,
        receiptModeList: JSON.parse(JSON.stringify(receiptModeList)),
      },
      dialogConfig: {
        setting: {
          showClose: true,
          appendToBody: false,
          // width: '720px',
          btnList: [
          ]
        },
        config: {
          title: '查看详情',
          width: '720px'
        }

      },
      modeDialogConfig: {
        config: {
          title: '修改到账模式',
          width: '600px'
        }
      }
    }
  },
  components: {
    accountDetail,
    editAccountMode
    // baseDialog,
    // settingDetail
  },

  mounted() {
    this.getBaseData()
    // 1-嘀加;2-广汇; 8-直营
    this.getMerchantLevel(1)
    this.getMerchantLevel(2)
    this.getMerchantLevel(8)
    // console.log(this.merchantLevelOptions)
  },

  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    // associationSettings() {
    //   this.settingDetailVisible = true
    // },
    async getBaseData() {
      this.baseData.channelTypeList = await this.get(BaseData.channelType)
      this.getOptionsList()
    },

    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
            const temp = {}
            temp[this.showFormData[index].optionId] = ''
            temp[this.showFormData[index].optionLabel] = '全部'
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
      console.log(this.showFormData, 'showFormData')
    },

    getMerchantLevel(channelType) {
      // channelType:1-嘀加;2-广汇;8-直营
      getMerchantLevelApi({ channelType: channelType }).then(res => {
        // this.merchantLevelOptions[this.nameToOption[channelType]] = JSON.parse(res)
        this.merchantLevelOptions[this.nameToOption[channelType]] = res
      })
    },

    // 账户状态不同,会有不同的操作
    // 1/4 - 待申请/失败(编辑);2 - 审核中(置灰); 3 - 生效中(详情)
    handleApply(cellValue) {
      // 查看详情
      if (cellValue.accountStatus === 3 || cellValue.accountStatus === 5 || cellValue.ysemRefedFlag == 'Y') {
        this.merchantRow = cellValue
        this.handleDetailClose()
        return true
      }
      // 编辑
      this.close({ tagName: '/applyAccount_new' })
      this.$router.push({
        name: 'applyAccount_new',
        params: cellValue
      })
    },

    // 修改到账模式
    handleEditAccountMode(row) {
      this.merchantRow = row
      this.handleModeClose()
    },

    // 修改到账模式确认
    handleModeConfirm() {
      this.$refs.editAccountModeForm.submitForm()
    },
    // 修改到账模式 关闭弹窗
    handleModeClose(isRefreshTable = false) {
      this.receiptModeVisible = !this.receiptModeVisible
      if (isRefreshTable) this.$refs.merchantTable.refreshTable() // 只刷新页面 保留当前分页数据
    },
    handleReset() {
      this.searchForm = {
        merchantType: '',
        channelType: '',
        merchantName: '',
        accountStatus: '',
        merchantId: '',
        yseUserCode: '',
        ysemRefedFlag: '',
        receiptMode: ''
      }
      this.merchantLevelVal = []
      this.$refs.merchantTable.resetRefreshTable()
    },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        this.searchFormSearch.merchantTypeList = this.searchForm.merchantType ? [this.searchForm.merchantType] : [2, 7, -1]
        this.searchFormSearch.merchantId = this.searchForm.merchantId ? this.searchForm.merchantId : this.merchantLevelVal[this.merchantLevelVal.length - 1]
        delete this.searchFormSearch.merchantType
        resolve()
      })
    },

    keyDowmGetList() {
      this.$refs.merchantTable.refreshTable()
    },

    handleDetailClose() {
      // console.log('visible')
      this.accountDetailVisible = !this.accountDetailVisible
    },

    // 同步
    synchronization() {
      synchronizeBusinessInformation({}).then(res => {
        this.notice.okTips('同步数据成功')
      })
    }
  }
}

</script>
<style>
.header {
  background-color: #fff;
}

.el-cascader-panel .el-cascader-menu {
  width: 260px;
}
.btnClass span{
  margin-right: 5px;
}
</style>