myFashionableOrder.vue 20 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 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
<template>
  <div class="order-container">
    <div class="tip_wrap flex_scb">
      <div class="tip_text">
        <p class="h14_title">合作了精品升级业务且开启了自动分账功能的商户,在“线上分账”列表中可查看分账明细,未开启线上自动分账或者因各种</p>
        <div style="height: 10px"></div>
        <p class="h14_title">其他因素导致未分账成功的,在线下对账中查看,统一下个月月初结算上个月订单。</p>
      </div>
      <div class="tip_btn flex_scb">
        <el-button size="small" :type="curDivisionType == 2 ? 'primary' : ''" @click="changDivisionType(2)">线上分账</el-button>
        <el-button size="small" :type="curDivisionType == 1 ? 'primary' : ''" @click="changDivisionType(1)">线下对账</el-button>
      </div>
    </div>
    <div class="tip_wrap_line"></div>

    <div v-if="curDivisionType == 2" class="pannel">
      <GLCombiForm ref="showSearch1" :key="refreshKey1" :formObj="searchForm" :formData="searchFormData1" @handleOk="handleOkFn" @handleRest="handleRestFn"></GLCombiForm>
    </div>
    <div v-if="curDivisionType == 1" class="pannel">
      <GLCombiForm ref="showSearch2" :key="refreshKey2" :formObj="searchForm" :formData="searchFormData2" @handleOk="handleOkFn" @handleRest="handleRestFn"></GLCombiForm>
    </div>
    <div class="tipper flex_scb">
      <div class="tip_text">
        <span>共</span>
        <sapn style="color: #5850ff">{{ mytotalNumData.orderCount }}</sapn>
        <span>笔订单,累计{{ curDivisionType == 1 ? '线下对账' : '线上分账' }}金额</span>
        <span style="color: #5850ff">{{ curDivisionType == 1 ? mytotalNumData.offlineDivisionMoneyCount : mytotalNumData.onlineDivisionMoneyCount }}</span>
        <template v-if="curDivisionType == 1">
          <span>元</span>
        </template>
        <template v-if="curDivisionType == 2">
          <span>元(分账成功金额</span>
          <span style="color: #5850ff">{{ mytotalNumData.divisionSuccessMoneyCount }}</span>
          <span>元,分账中金额</span>
          <span style="color: #5850ff">{{ mytotalNumData.inDivisionMoneyCount }}</span>
          <span>元,分账失败金额</span>
          <span style="color: #5850ff">{{ mytotalNumData.divisionFailureMoneyCount }}</span>
          <span>元,待分账金额</span>
          <span style="color: #5850ff">{{ mytotalNumData.waitingDivisionMoneyCount }}</span>
          <span>元)。</span>
        </template>
      </div>
      <GLButton size="small" plain fn="导出分账订单" @click="toExport">导出数据</GLButton>
    </div>

    <!-- 线上分账 -->
    <div :hidden="curDivisionType == 1" class="table_wrap">
      <GLTable ref="table2" :tableData="tableData" :tableTotal="tableTotal" :tableParams="tableParams" @refreshTable="toGetMyDivision"></GLTable>
    </div>

    <!-- 线下对账 -->
    <div :hidden="curDivisionType == 2" class="table_wrap">
      <GLTable ref="table1" :tableData="tableData" :tableTotal="tableTotal" :tableParams="tableParams1" @refreshTable="toGetMyDivision"></GLTable>
    </div>
  </div>
</template>
<script>
import { mydivision, exportMydivision, myAccountTotalNumOfJT, getMerchantList } from '../../api/modules/rules'
import { converterApi } from '../../api/modules/converter'
import utils from '../../util/util'
const divistionStatus = ['待分账', '分账中', '分账成功', '分账失败']
const SERCH_GOODSNAME = {
  label: '商品名称',
  name: 'goodsName',
  type: 'input',
  isClear: true
}
export default {
  name: '',
  props: {
    list: Array
  },
  data() {
    return {
      refreshKey1: new Date(),
      refreshKey2: new Date() + 1,
      tableTotal: 0,
      tableParams2: {
        tableOption: false,
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        tableColumns: [
          {
            label: '主订单编号',
            prop: 'orderCode',
            width: '200px'
          },
          // {
          //   label: '子订单编号',
          //   prop: 'subOrderCode',
          //   width: '200px'
          // },
          {
            label: '客户姓名',
            prop: 'customerName',
            width: '180px'
          },
          {
            label: '车架号',
            prop: 'standNo',
            width: '180px'
          },
          {
            label: '分账账户',
            prop: 'realityMerchantName',
            width: '200px'
          },
          {
            label: '总分账金额/元',
            prop: 'divisionMoney',
            align: 'right',
            width: '150px'
          },
          {
            label: '导流方名称',
            prop: 'merchantName',
            width: '200px'
          },
          {
            label: '园区店名',
            prop: 'yqMerchantName',
            width: '200px'
          },
          {
            label: '分账类型',
            prop: 'divisionTypeName',
            width: '110px'
          },
          {
            label: '分账状态',
            prop: 'divisionStatusName',
            width: '110px'
          },
          {
            label: '分账时间',
            prop: 'divisionDate',
            width: '200px'
          },
          {
            label: '支付时间',
            prop: 'successDate',
            width: '200px'
          },
          {
            label: '商品编号',
            prop: 'upgradeGoodsCommodityCode',
            width: '200px'
          },
          {
            label: '商品名称',
            prop: 'upgradeGoodsName',
            width: '200px'
          }
        ]
      },
      tableParams1: {
        tableOption: false,
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        tableColumns: [
          {
            label: '主订单编号',
            prop: 'orderCode',
            width: '200px'
          },
          // {
          //   label: '子订单编号',
          //   prop: 'subOrderCode',
          //   width: '200px'
          // },
          {
            label: '客户姓名',
            prop: 'customerName',
            width: '180px'
          },
          {
            label: '车架号',
            prop: 'standNo',
            width: '180px'
          },
          {
            label: '分账账户',
            prop: 'realityMerchantName',
            width: '200px'
          },
          {
            label: '总分账金额(元)',
            prop: 'divisionMoney',
            width: '150px',
            align: 'right'
          },
          {
            label: '导流方名称',
            prop: 'merchantName',
            width: '200px'
          },
          {
            label: '园区店名',
            prop: 'yqMerchantName',
            width: '200px'
          },
          {
            label: '分账类型',
            prop: 'divisionTypeName',
            width: '110px'
          },
          {
            label: '支付时间',
            prop: 'successDate',
            width: '200px'
          },
          {
            label: '商品编号',
            prop: 'upgradeGoodsCommodityCode',
            width: '200px'
          },
          {
            label: '商品名称',
            prop: 'upgradeGoodsName',
            width: '200px'
          }
        ]
      },
      curDivisionType: 2,
      tableData: [],
      tableParams: {},
      // 查询参数
      storeId: '',
      divisionTime: '',
      payTime: '',
      divisionTypeStatus: '',
      orderNum: '',
      tradeNum: '',
      goodsName: '',
      accountLevel: 1,
      mytotalNumData: {
        subOrderCount: 0
      },
      curMerchantNo: '',
      isAdmin: false,
      pickerOptions: {},
      /**新版搜索栏参数 */
      searchForm: {
        divisionTime: '',
        payTime: '',
        divisionTypeStatus: '',
        orderNum: '',
        goodsName: '',
        merchantIds: '',
        merchantIdss: '',
        merchantIdsss: ''
      },
      searchFormData1: [
        {
          label: '分账时间',
          name: 'divisionTime',
          type: 'datePicker',
          isClear: true
        },
        {
          label: '支付时间',
          name: 'payTime',
          type: 'datePicker',
          isClear: true
        },
        {
          label: '分账状态',
          name: 'divisionTypeStatus',
          type: 'select',
          optionId: 'confId',
          optionLabel: 'confName',
          isClear: true,
          noFilter: true,
          optionList: [
            {
              confId: 1,
              confName: '待分账'
            },
            {
              confId: 2,
              confName: '分账中'
            },
            {
              confId: 3,
              confName: '分账成功'
            },
            {
              confId: 4,
              confName: '分账失败'
            }
          ]
        },
        {
          label: '主订单编号',
          name: 'orderNum',
          type: 'input',
          isClear: true
        }
      ],
      searchFormData2: [
        {
          label: '支付时间',
          name: 'payTime',
          type: 'datePicker',
          isClear: true
        },
        {
          label: '主订单编号',
          name: 'orderNum',
          type: 'input',
          isClear: true
        }
      ],
      sizeList: [5, 10, 20, 30, 40]
    }
  },
  created() {
    this.tableParams = this.tableParams2
    const { session } = this.$globalState
    this.accountLevel = session.accountLevel
    this.isAdmin = session.admin
    // 1.工厂  2省代  3市代  4门店
    if (session.accountLevel < 4) {
      this.getMerchanListData(session.accountLevel)
    } else {
      this.searchFormData1.push(SERCH_GOODSNAME)
      this.searchFormData2.push(SERCH_GOODSNAME)
      this.refreshComponent()
    }
  },
  mounted() {
    this.newHttpParam = this.resetTime()
    this.toGetMyDivision()
  },
  methods: {
    /**获取商户列表 */
    getMerchanListData(accountLevel) {
      let merchantForm = {}
      getMerchantList({}).then(res => {
        this.merchants = res
        const levelName = ['工厂商户号', '省代商户号', '市代商户号', '门店商户号']
        merchantForm = {
          label: levelName[accountLevel],
          name: 'merchantIds',
          type: 'select',
          optionList: res,
          optionId: 'id',
          optionLabel: 'merchantName',
          isClear: true
        }
        if (accountLevel < 3) {
          merchantForm.changeAttr = (val, targetItem) => {
            let child = targetItem.optionList.filter(item => item.id == val)
            let newForm = {
              label: levelName[accountLevel + 1],
              name: 'merchantIdss',
              type: 'select',
              optionList: child[0] && child[0].children ? child[0].children : [],
              optionId: 'id',
              optionLabel: 'merchantName',
              isClear: true
            }
            if (accountLevel == 1) {
              newForm.changeAttr = (va, targetIte) => {
                let child2 = targetIte.optionList.filter(item => item.id == va)
                let newForm2 = {
                  label: levelName[accountLevel + 2],
                  name: 'merchantIdsss',
                  type: 'select',
                  optionList: child2[0] && child2[0].children ? child2[0].children : [],
                  optionId: 'id',
                  optionLabel: 'merchantName',
                  isClear: true
                }
                const isAdd1 = this.judgeAdd(newForm2, this.searchFormData1, 'name')
                const isAdd2 = this.judgeAdd(newForm2, this.searchFormData2, 'name')
                if (!isAdd1) {
                  this.searchFormData1.push(newForm2)
                }
                if (!isAdd2) {
                  this.searchFormData2.push(newForm2)
                }
                // this.searchFormData1.push(newForm2)
                // this.searchFormData2.push(newForm2)
                this.refreshComponent()
              }
            }
            this.rowNumber = 3
            const isAdd1 = this.judgeAdd(newForm, this.searchFormData1, 'name')
            const isAdd2 = this.judgeAdd(newForm, this.searchFormData2, 'name')
            if (!isAdd1) {
              this.searchFormData1.push(newForm)
            }
            if (!isAdd2) {
              this.searchFormData2.push(newForm)
            }
            // this.searchFormData1.push(newForm)
            // this.searchFormData2.push(newForm)
            this.refreshComponent()
          }
        }
        this.searchFormData1.push(merchantForm)
        this.searchFormData2.push(merchantForm)
        this.refreshComponent()
      })
    },
    refreshComponent() {
      this.refreshKey1 = Date.now()
      this.refreshKey2 = Date.now() + 1
    },
    // 判断是否需要添加下拉框
    judgeAdd(obj, objList, tag) {
      let flag = false
      objList.forEach(item => {
        if (item[tag] == obj[tag]) {
          flag = true
        }
      })
      return flag
    },
    handleOkFn() {
      this.handlerParams()
    },
    handleRestFn() {
      this.searchForm = {
        divisionTime: '',
        payTime: '',
        divisionTypeStatus: '',
        orderNum: '',
        goodsName: '',
        merchantIds: '',
        merchantIdss: '',
        merchantIdsss: ''
      }
      this.$refs[`table${this.curDivisionType}`].page.pageNum = 1
      this.newHttpParam = this.resetTime()
      this.toGetMyDivision()
    },
    // 重置时间
    resetTime() {
      let params = {}
      let openInfo = JSON.parse(localStorage.getItem('openInfo'))
      let startdate = utils.dateFormat(openInfo.openDate, 'YYYY-MM-DD 00:00:00')
      let endDate = utils.dateFormat(new Date(), 'YYYY-MM-DD 23:59:59')
      params.paySuccessDateStartDate = startdate
      params.paySuccessDateEndDate = endDate
      return params
    },
    getCurStoreId(e) {
      this.storeId = e
    },
    selectCurMechant(e) {
      this.$refs.myNewSelect.selectCurMechant(e)
    },
    // clearFind() {
    //   this.divisionTime = ''
    //   this.payTime = ''
    //   this.divisionTypeStatus = ''
    //   this.orderNum = ''
    //   this.goodsName = ''
    //   this.storeId = ''
    //   this.$refs.table.page.pageNum = 1
    //   this.curMerchantNo = ''
    //   let params = this.resetTime()
    //   this.toGetMyDivision(params)
    // },
    handlerParams() {
      let params = {}
      this.$refs[`table${this.curDivisionType}`].page.pageNum = 1
      if (this.searchForm.divisionTime) {
        let startDate = utils.dateFormat(this.searchForm.divisionTime[0], 'YYYY-MM-DD 00:00:00')
        let endDate = utils.dateFormat(this.searchForm.divisionTime[1], 'YYYY-MM-DD 23:59:59')
        params.divisionStartDate = startDate
        params.divisionEndDate = endDate
      } else {
        delete params.divisionStartDate
        delete params.divisionEndDate
      }
      if (this.searchForm.payTime) {
        let startDate = utils.dateFormat(this.searchForm.payTime[0], 'YYYY-MM-DD 00:00:00')
        let endDate = utils.dateFormat(this.searchForm.payTime[1], 'YYYY-MM-DD 23:59:59')
        params.paySuccessDateStartDate = startDate
        params.paySuccessDateEndDate = endDate
      } else {
        delete params.paySuccessDateStartDate
        delete params.paySuccessDateEndDate
      }
      if (!this.searchForm.divisionTime && !this.searchForm.payTime) {
        params = this.resetTime()
      }
      if (this.searchForm.divisionTypeStatus) {
        params.divisionStatus = this.searchForm.divisionTypeStatus
      } else {
        delete params.divisionStatus
      }
      //主订单编号---交易参考号
      if (this.searchForm.orderNum) {
        params.orderCode = this.searchForm.orderNum
      } else {
        delete params.orderCode
      }
      if (this.searchForm.tradeNum) {
        params.tradeNo = this.searchForm.orderNum
      } else {
        delete params.tradeNo
      }
      if (this.searchForm.goodsName) {
        params.upgradeGoodsName = this.searchForm.goodsName
      } else {
        delete params.upgradeGoodsName
      }
      if (this.searchForm.merchantIdsss || this.searchForm.merchantIdss || this.searchForm.merchantIds) {
        params['merchantIdList[0]'] = this.searchForm.merchantIdsss || this.searchForm.merchantIdss || this.searchForm.merchantIds
      } else {
        delete params['merchantIdList[0]']
      }
      this.newHttpParam = params
      this.toGetMyDivision()
    },

    changDivisionType(type) {
      this.curDivisionType = type
      this.tableParams = type == 1 ? this.tableParams1 : this.tableParams2
      this.handleRestFn()
    },
    toGetMyDivision() {
      let method = mydivision()
      let para = {
        routerMethod: method,
        currentPage: this.$refs[`table${this.curDivisionType}`].page.pageNum,
        pageSize: this.$refs[`table${this.curDivisionType}`].page.pageSize,
        divisionType: this.curDivisionType,
        ...this.newHttpParam
      }
      converterApi(para).then(res => {
        res.list.map(item => {
          item.divisionTypeName = item.divisionType == 1 ? '线下对账' : '线上分账'
          item.successDate = item.paySuccessDate ? utils.dateFormat(item.paySuccessDate, 'YYYY-MM-DD HH:mm:ss') : '--'
          item.divisionDate = item.divisionDate ? utils.dateFormat(item.divisionDate, 'YYYY-MM-DD HH:mm:ss') : '--'
          item.upgradeGoodsCommodityCode = this.toJoinString(item.goods, 'code')
          item.upgradeGoodsName = this.toJoinString(item.goods, 'name')
          item.divisionStatusName = divistionStatus[item.divisionStatus - 1]
          item.customerName = item.customerName || '--'
          item.standNo = item.standNo || '--'
          item.divisionMoney = item.divisionMoney || '--'
          return item
        })
        this.tableData = res.list
        this.tableTotal = res.total
        this.httpParam = {
          currentPage: this.$refs[`table${this.curDivisionType}`].page.pageNum,
          pageSize: this.$refs[`table${this.curDivisionType}`].page.pageSize,
          divisionType: this.curDivisionType,
          ...this.newHttpParam
        }
        this.getMyTotalData(this.httpParam)
      })
    },
    toJoinString(arr, type) {
      if (!arr) return ''
      let temp1 = [],
        temp2 = []
      arr.forEach(item => {
        temp1.push(item.upgradeGoodsName)
        temp2.push(item.upgradeGoodsCommodityCode)
      })
      if (type == 'code') return temp2.join('/')
      if (type == 'name') return temp1.join('/')
    },
    // 表格分页获取数据
    tableRefreshData() {
      let temp = this.httpParam
      delete temp.currentPage
      delete temp.pageSize
      delete temp.divisionType
      this.toGetMyDivision(temp)
    },
    // 获取我的分账统计-集团
    getMyTotalData(params) {
      delete params.currentPage
      delete params.pageSize
      let method = myAccountTotalNumOfJT()
      let para = {
        routerMethod: method,
        ...params
      }
      converterApi(para).then(res => {
        this.mytotalNumData = res
      })
    },
    toExport() {
      let method = exportMydivision()
      let para = {
        routerMethod: method,
        currentPage: this.$refs[`table${this.curDivisionType}`].page.pageNum,
        pageSize: this.$refs[`table${this.curDivisionType}`].page.pageSize,
        ...this.httpParam
      }
      converterApi(para).then(res => {
        let tempaa = utils.getExplorer()
        if (tempaa == 'QQ') {
          window.open(res)
        } else {
          let iframe = document.createElement('iframe')
          iframe.style.display = 'none'
          iframe.src = res
          document.body.appendChild(iframe)
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.tipper {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 15px;
  .tip_text {
    font-size: 12px;
    font-weight: 400;
    color: #000000;
    display: flex;
    align-items: center;
  }
  .right_select {
    width: 286rpx;
    overflow: hidden;
  }
}
.table_wrap {
  padding: 0 15px;
  padding-bottom: 10px;
}
// 我的分账
.tip_wrap {
  box-sizing: border-box;
  padding: 5px 15px 22px 15px;
}
.tip_wrap_line {
  margin: 0 15px;
  height: 1px;
  background: #e8e8ea;
  margin-bottom: 20px;
}
.pannel {
  padding: 0 15px;
}
</style>