integralShopping.vue 37.7 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 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250
<!-- 积分商城列表 -->
<template>
  <div class="integralShopping-list">
    <d2-container class="m-t-40">
      <!-- 搜索 -->
      <div class="header"
           slot="header">
        <d2-search ref="showSearch"
                   class="show-search"
                   :search-form="searchForm"
                   :label-width="'150px'"
                   :form-data="searchFormData" />
        <div class="up-btns">
          <el-button @click="handleSearch"
                     size="small"
                     type="primary">
            查询
          </el-button>
          <el-button size="small"
                     @click="handleReset"> 重置 </el-button>
        </div>
      </div>
      <div class="tab-list">
        <div class="tabs">
          <el-tabs type="card"
                   v-model="tabClickVal"
                   @tab-click="handleTabClick">
            <template v-for="(i, index) in requestSourceList">
              <el-tab-pane :label="i"
                           :name="index + ''"
                           :key="index"></el-tab-pane>
            </template>
          </el-tabs>
        </div>
        <div class="btn-group">
          <template>
            <!-- <el-button class="default-blue-btn" type="primary" @click="handleExport">导出</el-button> -->
            <auth-button :show-btn-ids="['9040137']"
                         category="Button" />
          </template>
        </div>
        <!-- 表格区域 -->
        <d2-table ref="crowdfundTable"
                  :has-num="true"
                  :search-form="tableSearchForm"
                  :table-params="tableParams"
                  :get-list-api="getListApi"
                  :before-search-fn="beforeSearchFn"
                  :filter-list-data="true">
          <div slot="weChatName"
               class="flex-align"
               slot-scope="scope">
            <img v-if="scope.scope.weChatImageUrl"
                 class="img-36 pointer img-circle"
                 :src="scope.scope.weChatImageUrl" />
            <span class="m-l-10">{{ scope.scope.weChatName }}</span>
            <span v-if="!scope.scope.shareAvatar && !scope.scope.weChatName">-</span>
          </div>
          <div slot="orderStatus"
               slot-scope="scope">
            <span :class="[
              'table-circle',
              'm-r-8',
              [2, 10, 22].includes(scope.scope.orderStatus)
                ? 'back-green'
                : [9].includes(scope.scope.orderStatus)
                  ? 'back-blue'
                  : [1, 21, 6].includes(scope.scope.orderStatus)
                    ? 'back-orange'
                    : 'back-grey'
            ]"></span>
            <span>{{
              baseData.orderStatusList
                .map((item) => item.confId)
                .includes(scope.scope.orderStatus + "")
                ? baseData.orderStatusList.find(
                  (item) => item.confId == scope.scope.orderStatus
                ).confName
                : "-"
            }}</span>
          </div>
          <div slot="shareStaffName"
               class="table-image"
               slot-scope="scope">
            <div>
              <img v-if="scope.scope.shareStaffImageUrl"
                   class="img-36 pointer img-circle"
                   style="vertical-align: middle"
                   slot="reference"
                   :src="scope.scope.shareStaffImageUrl" />
              <span class="m-l-10">
                <span>{{ scope.scope.shareStaffName }}</span>
                <span class="txt-green"
                      v-if="scope.scope.shareStaffSource == 1">@个微</span>
                <span class="txt-orange"
                      v-if="scope.scope.shareStaffSource == 2">@企微</span>
                <span class="txt-blue"
                      v-if="scope.scope.shareStaffSource == 3">@员工</span>
              </span>
            </div>
            <span v-if="!scope.scope.shareStaffImageUrl && !scope.scope.shareStaffName
            ">-</span>
          </div>
          <div slot="assignName"
               slot-scope="scope">
            <div class="flex-align">
              <template v-if="scope.scope.assignStaffName">
                <img class="img-36 pointer img-circle"
                     v-if="scope.scope.assignStaffImageUrl"
                     :src="scope.scope.assignStaffImageUrl" />
                <span class="m-l-10">
                  <span>{{ scope.scope.assignStaffName }}</span>
                </span>
              </template>
              <template v-else-if="scope.scope.shareStaffName">
                <img class="img-36 pointer img-circle"
                     v-if="scope.scope.shareStaffImageUrl"
                     :src="scope.scope.shareStaffImageUrl" />
                <span class="m-l-10">
                  <span>{{ scope.scope.shareStaffName }}</span>
                </span>
              </template>
              <template v-else>
                <span>{{
                  scope.scope.assignStaffName ||
                    scope.scope.shareStaffName ||
                    "-"
                }}</span>
              </template>
            </div>
          </div>
          <div slot="auth-button"
               slot-scope="scope">
            <span style="margin-left: 10px;">
              <auth-button slot="auth-button"
                           :show-btn-ids="['9040146']"
                           :data="scope.scope" />
            </span>
            <!-- 仅预支付状态显示 -->
            <span v-if="scope.scope.tailOrderStatus == '3'">
              <!-- <el-button type="text" size="mini" style="margin-left: 10px" @click="record(scope.scope)">
                确认补录
              </el-button>
              <el-button type="text" size="mini" style="margin-left: 10px" @click="cancelRelat(scope.scope)">
                取消关联
              </el-button> -->
              <auth-button slot="auth-button"
                           :show-btn-ids="['9040138', '9040139']"
                           :data="scope.scope" />
            </span>
            <span v-if="scope.scope.ledgerStatus == '2'"
                  style="margin-left: 10px">
              <!-- <el-button type="text" size="mini" style="margin-left: 10px" @click="chooseRule(scope.scope)">
                发起分账
              </el-button> -->
              <auth-button slot="auth-button"
                           :show-btn-ids="['9040140']"
                           :data="scope.scope" />
            </span>
            <span v-if="scope.scope.ledgerStatus == '3'"
                  style="margin-left: 10px">
              <!-- <el-button type="text" size="mini" style="margin-left: 10px" @click="ruleHistory(scope.scope)">
                分账记录
              </el-button> -->
              <auth-button slot="auth-button"
                           :show-btn-ids="['9040141']"
                           :data="scope.scope" />
            </span>
            <!-- 取消分账 分账中状态 -->
            <span v-if="scope.scope.ledgerStatus == '4'"
                  style="margin-left: 10px">
              <!-- <el-button type="text" size="mini" style="margin-left: 10px" @click="cancelRule(scope.scope)">
                取消分账
              </el-button> -->
              <auth-button slot="auth-button"
                           :show-btn-ids="['9040142']"
                           :data="scope.scope" />
            </span>
            <!-- 尾款状态 0待支付 1已支付 2已退款 -->
            <span v-if="[1, 2].includes(scope.scope.tailOrderStatus) && signRefundFlag">
              <el-button type="text"
                         size="mini"
                         style="margin-left: 10px"
                         @click="refund(scope.scope)">
                标记已退款
              </el-button>
            </span>
            <!-- 核销 -->
            <span v-if="scope.scope.showVerf == '1'"
                  style="margin-left: 10px">
              <!-- <el-button type="text" size="mini" style="margin-left: 10px" @click="writeOff(scope.scope)">
                订单核销
              </el-button> -->
              <auth-button slot="auth-button"
                           :show-btn-ids="['9040143']"
                           :data="scope.scope" />
            </span>
            <!-- 商品发货 -->
            <span v-if="scope.scope.deliveryType == 2 && scope.scope.orderStatus == 6"
                  style="margin-left: 10px">
              <!-- <el-button type="text" size="mini" style="margin-left: 10px" @click="handleExpressInfo(scope.scope)">
                商品发货
              </el-button> -->
              <auth-button slot="auth-button"
                           :show-btn-ids="['9040144']"
                           :data="scope.scope" />
            </span>
            <!-- 退款 -->
            <!-- <span v-if="scope.scope.showRefund == '1'">
              <el-button type="text"
                         size="mini"
                         style="margin-left: 10px"
                         @click="setRefund(scope.scope)">
                退款
              </el-button>
            </span> -->
          </div>
        </d2-table>
      </div>
    </d2-container>
    <GLDialog v-if="isExpressVisible"
              width="640px"
              title="输入快递信息"
              mode="mid"
              ok-text="确定"
              cancel-text="取消"
              :visible.sync="isExpressVisible"
              @onOk="handleExpressConfirm"
              @onCancel="handleExpressClose">
      <glsx-combi-form class="small-content m-t-20"
                       ref="expressRef"
                       :is-block="true"
                       default-width="284px"
                       :is-edit="isEdit"
                       :form-ref="editChildRef"
                       :form-obj="expressForm"
                       :form-data="expressFormData"
                       :form-rules="expressRules"></glsx-combi-form>
    </GLDialog>
    <!-- 选择分账规则 -->
    <choose-rule-dialog :rule-visible="ruleVisible"
                        :record-info="recordInfo"
                        v-if="ruleVisible"
                        @dialogClose="ruleDialogClose" />
    <!-- 查看分账记录 -->
    <rule-info-dialog :rule-info-visible="ruleInfoVisible"
                      :record-info="recordInfo"
                      v-if="ruleInfoVisible"
                      @dialogClose="ruleInfoDialogClose" />
    <!-- 标记退款 -->
    <new-sign-refund-dialog :sign-refund-visible="signRefundVisible"
                            :detail="detail"
                            :order-type="1"
                            v-if="signRefundVisible"
                            @dialogClose="refundDialogClose" />
  </div>
</template>
<script>
import {
  businessType,
  orderManageStatusList_integral,
  afterSaleStatusList,
  orderSourceList,
  deliveryTypeList
} from "@/common/constants"
import { Util, deepClone } from "@/common/util"
import orderManage from "@api/orderManage"
import { batchUpdateToNotInput, batchUpdateConfirmInput, markAsRefunded, cancelDivideAccountsAPI, verification, refund } from '@api/order'
import chooseRuleDialog from './chooseRuleDialog'
import ruleInfoDialog from './ruleInfoDialog'
import newSignRefundDialog from './components/newSignRefundDialog'
export default {
  components: {
    chooseRuleDialog,
    ruleInfoDialog,
    newSignRefundDialog
  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      isExpressVisible: false,
      isEdit: true,
      editChildRef: 'editChildRef',
      expressForm: {
        deliveryCompany: '',
        deliveryNumber: ''
      },
      expressRules: {
        deliveryCompany: [{ required: true, message: '快递公司是必填项', trigger: 'change' }],
        deliveryNumber: [{ required: true, message: '快递单号是必填项', trigger: 'change' }]
      },
      expressFormData: [
        {
          label: '快递公司',
          name: 'deliveryCompany',
          type: 'input',
          maxlength: 20
        },
        {
          label: '快递单号',
          name: 'deliveryNumber',
          type: 'input',
          maxlength: 20
        }
      ],
      showNum: false,
      orderCode: "",
      merchantId: "",
      searchForm: {
        orderCode: "",
        orderStatuses: [],
        afterSaleStatuses: [],
        customerName: "",
        createDate: [],
        // orderSource: "6",
        orderSource: "7",
        requestType: "1", // 运营版 固定传值 实现筛选全部订单
        filterSelfSupportFlag: '2', // 过滤非嘀加的订单
        deliveryType: "",
        shareStaffName: "",
        shareStaffType: "",
        goodsName: "",
        requestSource: "0",
        payStatus: ''
      },
      statisticsInfo: {
        orderCount: "",
        payPriceTotal: "",
        refundTotal: ""
      },
      // 搜索
      searchFormData: [],
      tableSearchForm: {},
      selectList: [],
      selectTableParams: {
        tableColumns: [
          {
            label: "客户信息",
            prop: "customerName",
            width: 160,
            formatter: (cellValue) => {
              return cellValue.customerName || "-"
            }
          },
          {
            label: "推荐人",
            prop: "shareStaffName",
            width: 210,
            addHtml: "shareStaffName"
          },
          {
            label: "支付定金/元",
            prop: "orderPrice",
            // prop: "payPrice",
            width: "120",
            formatter: (cellValue) => {
              return cellValue.orderPrice || "0"
              // return cellValue.payPrice || "0"
            }
          },
          {
            label: "门店",
            prop: "merchantName",
            line: 1,
            width: 280
          },
          {
            label: "活动名称",
            prop: "activityName"
          }
        ]
      },
      getListApi: orderManage.getListApi,
      tableParams: {
        needUnique: true,
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: "list",
        tableOption: {
          width: "170"
        },
        tableColumns: []
      },
      requestSourceList: [
        "全部订单",
        "已付款",
        "未付款"
        // "已退款",
        // "售后订单"
        // "待审批"
      ],
      // 基本数据
      baseData: {
        searchOrderStatusList: orderManageStatusList_integral.filter((item) =>
          ["1", "3", "21", "22", "6", "9"].includes(item.confId)
        ),
        searchAfterSaleStatusList: afterSaleStatusList.filter((item) =>
          ["1", "6", "7"].includes(item.confId)
        ),
        orderStatusList: orderManageStatusList_integral,
        afterSaleStatusList: afterSaleStatusList,
        orderSourceList: orderSourceList,
        deliveryTypeList: deliveryTypeList,
        sourceList: [
          { confId: "0", confName: "云中鹤" },
          { confId: "1", confName: "嘀加智享" },
          { confId: "2", confName: "门店" }
        ],
        shareStaffSourceList: [
          { confId: "1", confName: "个微" },
          { confId: "2", confName: "企微" },
          { confId: "3", confName: "员工" }
        ],
        testSheetTypeList: [
          { confId: "0", confName: "否" },
          { confId: "1", confName: "是" }
        ],
        isOffSheetTypeList: [
          { confId: "0", confName: "是" },
          { confId: "1", confName: "否" }
        ],
        businessTypeList: deepClone(businessType),
        marketingStatusList: [
          { confId: "1", confName: "已完结" },
          { confId: "3", confName: "未完结" },
          { confId: "4", confName: "已取消" }
        ],
        tailOrderStatusList: [
          { confId: "0", confName: "待支付" },
          { confId: "1", confName: "已支付" },
          { confId: "2", confName: "已退款" },
          { confId: "3", confName: "预支付" }
        ],
        ledgerStatusList: [
          { confId: "0", confName: "未分账" },
          { confId: "1", confName: "待确认" },
          { confId: "2", confName: "待分账" },
          { confId: "3", confName: "已分账" },
          { confId: "4", confName: "分账中" }
        ]
      },
      ruleVisible: false,
      recordInfo: null,
      ruleInfoVisible: false,
      tabClickVal: '',
      signRefundFlag: false,
      detail: {},
      signRefundVisible: false
    }
  },
  name: "IntegralShopping",
  mounted() {
    this.getCrowdfundingOrderConfig()
    // this.getCount()
    const $store = this.$store.getters['d2admin/auth/curBtns']
    const signRefundBtnId = '9040145' // 标记退款权限ID
    const signRefundItem = $store.find(i => (i.authId === signRefundBtnId))
    if (signRefundItem) {
      this.signRefundFlag = true // 是否有标记退款权限
    }
  },
  methods: {
    ruleDialogClose(flag) {
      this.ruleVisible = !this.ruleVisible
      if (flag) {
        this.handleSearch()
      }
    },
    // 选择对账规则
    chooseRule(row) {
      this.recordInfo = deepClone(row)
      this.recordInfo.paySuccessDate = this.recordInfo.payDate
        ? Util.dateFormate(this.recordInfo.payDate, "YYYY-MM-DD HH:mm:ss")
        : ""
      this.recordInfo.totalPrice = this.recordInfo.finalPaymentAmount ? this.recordInfo.finalPaymentAmount / 100 : '0.00' // 接口数据来源不同因此这里取这个字段
      this.recordInfo.orderCode = this.recordInfo.mainOrderCode // 接口数据来源不同发起分账时实际需要的是主订单编号
      this.recordInfo.sceneType = 4 // 因为账户中心场景定义与蔡远明这边不一样,因此固定传4不能从列表拿,列表对应的场景映射值不统一
      console.log(this.recordInfo)

      this.ruleVisible = true
    },
    ruleInfoDialogClose(flag) {
      this.ruleInfoVisible = !this.ruleInfoVisible
      if (flag) {
        this.handleSearch()
      }
    },
    // 分账记录
    ruleHistory(row) {
      this.recordInfo = deepClone(row)
      this.recordInfo.paySuccessDate = this.recordInfo.payDate
        ? Util.dateFormate(this.recordInfo.payDate, "YYYY-MM-DD HH:mm:ss")
        : ""
      this.recordInfo.totalPrice = this.recordInfo.finalPaymentAmount ? this.recordInfo.finalPaymentAmount / 100 : '0.00' // 接口数据来源不同因此这里取这个字段
      this.recordInfo.orderCode = this.recordInfo.mainOrderCode // 接口数据来源不同发起分账时实际需要的是主订单编号
      this.ruleInfoVisible = true
    },
    // 标记已退款
    refund(row) {
      // this.$prompt('请输入退款备注', '提示', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   inputValidator: value => {
      //     if ((value ?? '') === '') return '请输入退款备注'
      //     if (value.length > 100) return '退款备注最多100字'
      //   },
      //   inputPlaceholder: '退款备注'
      // }).then(({ value }) => {
      //   markAsRefunded({
      //     orderCode: row?.mainOrderCode,
      //     refundRemark: value
      //   }).then(res => {
      //     this.notice.okTips()
      //     this.$refs.crowdfundTable.refreshTable()
      //     this.handleSearch()
      //   })
      // }).catch(() => { })
      this.signRefundVisible = !this.signRefundVisible
      this.detail.orderCode = row.mainOrderCode
      this.detail.totalPrice = row.finalPaymentAmount ? row.finalPaymentAmount / 100 : 0
    },
    refundDialogClose(flag) {
      this.signRefundVisible = !this.signRefundVisible
      if (flag) {
        this.handleSearch()
      }
    },
    // 取消分账
    cancelRule(row) {
      this.$confirm('取消分帐后,订单按线下对账方式计算分润,收款金额统一分账至嘀加智慧云,请谨慎操作。是否确定取消?', '提示', {
        confirmButtonText: '确定',
        type: 'warning'
      }).then(() => {
        cancelDivideAccountsAPI({ orderCode: row.orderCode }).then(res => {
          this.notice.okTips()
          this.handleSearch()
        })
      }).catch(() => { })
    },
    // 输入快递信息 - start
    handleExpressClose() {
      this.isExpressVisible = !this.isExpressVisible
      this.orderCode = ''
      this.expressForm = {
        deliveryCompany: '',
        deliveryNumber: ''
      }
    },
    handleExpressConfirm() {
      this.$refs.expressRef.$refs[this.editChildRef].validate(valid => {
        if (valid) {
          var params = deepClone(this.expressForm)
          params.orderCode = this.orderCode
          params.userName = this.userInfo.loginAccount.userName
          // console.log(params)
          // return
          orderManage.addDeliveryApi(params).then(res => {
            // this.$message({
            //   message: res.code == '0' ? '操作成功' : '操作失败',
            //   type: res.code == '0' ? 'success' : 'error',
            //   customClass: 'message-Z-zinde'
            // })
            // if (res.code == '0') {
            this.handleExpressClose()
            this.notice.okTips('操作成功')
            this.handleSearch()
            // }
          })
        }
      })
    },
    handleExpressInfo(row) {
      this.isExpressVisible = !this.isExpressVisible
      this.orderCode = row.orderCode
    },
    getCount() {
      var params = this.getParams()
      delete params.createDate
      orderManage.getCountApi(params).then((res) => {
        this.statisticsInfo = res || {
          orderCount: "",
          payPriceTotal: "",
          refundTotal: ""
        }
      })
    },
    // 查看订单
    handleDetail(row) {
      this.$router.push({
        path: "/configUpgradationDetail",
        query: {
          orderCode: row.orderCode,
          orderType: 'integralShopping'
        }
      })
    },
    handleSearch() {
      this.$refs.crowdfundTable.refreshTable()
      // this.getCount()
    },
    handleExport() {
      var params = this.getParams()
      orderManage.orderExportApi(params).then((res) => {
        window.location.href = res
      })
    },
    handleTabClick() {
      if (this.tabClickVal == 1) { // 查询已付款
        this.searchForm.payStatus = 2
        this.searchForm.requestSource = 0
      } else if (this.tabClickVal == 2) { // 查询未付款
        this.searchForm.payStatus = ''
        this.searchForm.requestSource = 2
      } else { // 查询全部订单
        this.searchForm.payStatus = ''
        this.searchForm.requestSource = 0
      }
      this.$refs.crowdfundTable.refreshTable()
      // this.getCount()
    },
    getParams() {
      var params = JSON.parse(JSON.stringify(this.searchForm))
      if (this.searchForm.createDate?.length) {
        params.createdStartDateStr =
          new Date(this.searchForm.createDate[0])
            .toLocaleDateString()
            .replace(/\//g, "-") + " 00:00:00"
        params.createdEndDateStr =
          new Date(this.searchForm.createDate[1])
            .toLocaleDateString()
            .replace(/\//g, "-") + " 23:59:59"
      }
      if (params.orderStatuses.includes("3") && params.requestSource == "0") { delete params.requestSource }
      delete params.createDate
      return params
    },

    beforeSearchFn() {
      return new Promise((resolve) => {
        this.tableSearchForm = this.getParams()
        delete this.tableSearchForm.createDate
        resolve()
      })
    },
    handleReset() {
      this.searchForm = {
        orderCode: "",
        orderStatuses: [],
        afterSaleStatuses: [],
        customerName: "",
        createDate: [],
        orderSource: "7",
        requestType: "1", // 运营版 固定传值 实现筛选全部订单
        deliveryType: "",
        shareStaffName: "",
        shareStaffType: "",
        goodsName: "",
        requestSource: "0",
        payStatus: ''
      }
      this.handleSearch()
    },
    async getCrowdfundingOrderConfig() {
      const tableColumns = [
        {
          label: "主订单编号",
          prop: "mainOrderCode",
          width: "140",
          formatter: (cellValue) => {
            return cellValue.mainOrderCode || "-"
          }
        },
        {
          label: "商品名称",
          prop: "customerName",
          width: 180,
          html: true,
          formatter: (cellValue) => {
            var html = '-'
            var list = []
            if (cellValue.orderGoods && cellValue.orderGoods.length > 0) {
              cellValue.orderGoods.map(item => {
                list.push(item.goodsName)
              })
              html = list.join('<br>')
            }
            return html
          }
        },
        {
          label: "单价(元)",
          prop: "goodsPrice",
          width: "120",
          html: true,
          formatter: (cellValue) => {
            var html = '-'
            var list = []
            if (cellValue.orderGoods && cellValue.orderGoods.length > 0) {
              cellValue.orderGoods.map(item => {
                list.push(item.activityPrice)
              })
              html = list.join('<br>')
            }
            return html
          }
        },
        {
          label: "数量",
          prop: "goodsNum",
          width: "120",
          html: true,
          formatter: (cellValue) => {
            var html = '-'
            var list = []
            if (cellValue.orderGoods && cellValue.orderGoods.length > 0) {
              cellValue.orderGoods.map(item => {
                list.push(item.goodsNumber)
              })
              html = list.join('<br>')
            }
            return html
          }
        },
        {
          label: "实收金额(元)",
          prop: "finalPaymentAmount",
          width: "160",
          formatter: (cellValue) => {
            return cellValue.finalPaymentAmount ? cellValue.finalPaymentAmount / 100 : "-"
          }
        },
        {
          label: "用户名称",
          prop: "customerName",
          width: 160,
          formatter: (cellValue) => {
            return cellValue.customerName || "-"
          }
        },
        {
          label: "手机号",
          prop: "customerPhone",
          width: 160,
          formatter: (cellValue) => {
            return cellValue.customerPhone || "-"
          }
        },
        {
          label: "来源",
          prop: "customerName",
          width: 160,
          formatter: (cellValue) => {
            return '嘀加智享' || "-"
          }
        },
        {
          label: "赠送积分",
          prop: "giveIntegral",
          width: 160,
          formatter: (cellValue) => {
            return cellValue.giveIntegral || "-"
          }
        },
        // {
        //   label: "使用积分",
        //   prop: "customerName",
        //   width: 160,
        //   formatter: (cellValue) => {
        //     return cellValue.customerName || "-"
        //   }
        // },
        {
          label: "订单状态",
          prop: "orderStatus",
          addHtml: "orderStatus",
          width: 160
        },
        {
          label: "订单编号",
          prop: "orderCode",
          width: "180"
        },
        {
          label: "下单时间",
          prop: "createdDate",
          width: "180",
          formatter: (cellValue) => {
            return Util.dateFormate(
              cellValue.createdDate,
              "YYYY-MM-DD HH:mm:ss"
            )
          }
        },
        {
          label: "交易参考号",
          prop: "transactionReferenceId",
          width: "160",
          formatter: (cellValue) => {
            return cellValue.transactionReferenceId || "-"
          }
        },
        {
          label: "分账状态",
          prop: "ledgerStatus",
          width: 100,
          formatter: (cellValue) => {
            return { 0: "未分账", 1: "待确认", 2: "待分账", 3: "已分账", 4: "分账中" }[cellValue.ledgerStatus] || "-"
          }
        },
        {
          label: "商户名称",
          prop: "merchantName",
          width: "180"
        }
      ]
      const searchFormData = [
        {
          label: "用户信息",
          name: "customerName",
          type: "input"
        },
        {
          label: "商品信息",
          name: "goodsName",
          labelWidth: 56,
          type: "input",
          maxlength: 100
        },
        {
          label: "主订单编号",
          name: "mainOrderCode",
          type: "input"
        },
        {
          label: "订单编号",
          name: "orderCode",
          type: "input"
        },
        {
          label: "下单时间",
          name: "createDate",
          type: "datePicker",
          labelWidth: 72,
          isClear: true,
          pickerOptions: "rangePickerOptions"
        },
        // {
        //   label: "来源",
        //   name: "source",
        //   type: "select",
        //   optionList: [],
        //   optionId: "confId",
        //   optionLabel: "confName",
        //   optionsName: "sourceList"
        // },
        {
          label: "订单状态",
          name: "orderStatuses",
          type: "select",
          multiple: true,
          optionList: [],
          optionId: "confId",
          optionLabel: "confName",
          optionsName: "searchOrderStatusList",
          changeAttr: (value, targetItem) => {
            var isAdd = value.length > this.oldVal.orderStatuses.length
            var targetVal = value[value.length - 1]
            var formIdx = this.searchFormData.findIndex(
              (item) => item.label == "订单状态"
            )
            if (!isAdd) {
              for (var i = 0; i < this.oldVal.orderStatuses.length; i++) {
                if (!value.includes(this.oldVal.orderStatuses[i])) {
                  targetVal = this.oldVal.orderStatuses[i]
                  break
                }
              }
            }
            !targetVal &&
              (this.searchForm.orderStatuses = isAdd
                ? this.searchFormData[formIdx].optionList.map(
                  (item) => item.confId
                )
                : [])
            if (targetVal) {
              var idx = value.findIndex((item) => item == "")
              if (
                idx != -1 &&
                this.searchForm.orderStatuses.length <
                this.searchFormData[formIdx].optionList.length
              ) {
                this.searchForm.orderStatuses.splice(idx, 1)
              } else if (
                idx == -1 &&
                this.searchForm.orderStatuses.length ==
                this.searchFormData[formIdx].optionList.length - 1
              ) {
                this.searchForm.orderStatuses.push("")
              }
            }
            this.oldVal.orderStatuses = deepClone(this.searchForm.orderStatuses)
          }
        },
        {
          label: "交易参考号",
          name: "transactionReferenceId",
          type: "input"
        }
      ]
      this.tableParams.tableColumns = tableColumns
      this.searchFormData = searchFormData
      this.getOptionsList("searchFormData")
    },
    getOptionsList(formName, hasAll = true, refreshSigle) {
      if (refreshSigle) {
        var item = this[formName].find((k) => k.name == refreshSigle)
        var index = this[formName].findIndex((k) => k.name == refreshSigle)
        this.$set(
          this[formName][index],
          "optionList",
          deepClone(this.baseData[item.optionsName])
        )
        if (
          hasAll &&
          this.baseData[item.optionsName].length &&
          this.baseData[item.optionsName][0][
          this[formName][index].optionLabel
          ] !== "全部"
        ) {
          const temp = {}
          temp[this[formName][index].optionId] = ""
          temp[this[formName][index].optionLabel] = "全部"
          this[formName][index].optionList.unshift(temp)
        }
      } else {
        this[formName].forEach((item, index) => {
          if (item.type === "select") {
          }
          if (
            item.type === "select" &&
            this.baseData[item.optionsName]?.length
          ) {
            this.$set(
              this[formName][index],
              "optionList",
              deepClone(this.baseData[item.optionsName])
            )
            if (
              hasAll &&
              this.baseData[item.optionsName].length &&
              this.baseData[item.optionsName][0][
              this[formName][index].optionLabel
              ] !== "全部"
            ) {
              const temp = {}
              temp[this[formName][index].optionId] = ""
              temp[this[formName][index].optionLabel] = "全部"
              this[formName][index].optionList.unshift(temp)
            }
          }
        })
      }
    },

    // 订单核销
    writeOff(row) {
      this.$confirm('请确定是否核销此订单?', '提示', {
        confirmButtonText: '确定',
        type: 'warning'
      }).then(() => {
        verification({ orderCode: row.orderCode }).then(res => {
          this.notice.okTips()
          this.handleSearch()
        })
      }).catch(() => { })
    },

    // 退款
    setRefund(row) {
      this.$confirm('请确定是否发起退款?', '提示', {
        confirmButtonText: '确定',
        type: 'warning'
      }).then(() => {
        refund({ orderCode: row.orderCode }).then(res => {
          this.notice.okTips()
          this.handleSearch()
        })
      }).catch(() => { })
    },

    // 确认补录
    record(row) {
      var selectedData = []
      selectedData.push(row)
      this.record_commit(selectedData)
    },

    record_commit(selectedData) {
      var orderCodeList = selectedData.map((item) => {
        return item.orderCode
      })
      this.$confirm('确认补录后,系统会自动对该订单执行分账,且不可撤回,是否确认补录?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        batchUpdateConfirmInput({ orderCodeList: orderCodeList }).then(res => {
          this.notice.okTips()
          this.handleSearch()
        })
      }).catch(err => {
        console.log(err)
      })
    },

    // 取消关联
    cancelRelat(row) {
      this.$confirm('取消关联后,若订单已核销,系统会自动进行线下对账计算;若订单未核销,可继续关联其他流水;是否确认取消关联?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const orderCodeList = [row.orderCode]
        batchUpdateToNotInput({ orderCodeList: orderCodeList }).then(res => {
          this.notice.okTips()
          this.handleSearch()
        })
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.integralShopping-list {
  .table-tips {
    width: 100%;
    height: 54px;
    background: #e4eeff;
    border-radius: 3px;
    line-height: 54px;
    padding-left: 26px;
    display: flex;
    align-items: center;

    &-text {
      font-size: 14px;
      color: #000000e6;
      line-height: 22px;
      margin-left: 9px;
    }
  }

  .tab-list {
    background: #fff;
    width: 100%;
    margin-top: 16px;
    padding: 20px 40px;
    position: relative;
    box-sizing: border-box;
  }

  .tabs {
    ::v-deep .el-tabs__header {
      padding: 0 !important;
    }

    padding-bottom: 16px;
  }

  .btn-group {
    position: absolute;
    right: 41px;
    top: 16px;
    z-index: 999;
  }

  .assignLabel {
    color: #5850ff;

    &:hover {
      cursor: pointer;
    }
  }

  .refund-dialog {
    .refund-item {
      padding-top: 14px;
    }

    .refund-tips {
      font-size: 14px;
      margin: 8px 0 6px 0;
      color: #999999;
    }

    .refund-dialog-tips-close {
      margin-left: auto;
      cursor: pointer;
    }

    .tips-img {
      margin: 0 8px 0 0 !important;
    }
  }

  .tips-img {
    width: 17.5px;
    height: 17.5px;
  }

  .switchStyle ::v-deep .el-switch__label {
    position: absolute;
    display: none;
    color: #fff;
  }

  .el-switch__core {
    background-color: rgba(166, 166, 166, 1);
  }

  .switchStyle ::v-deep .el-switch__label--left {
    z-index: 9;
    left: 20px;
  }

  .switchStyle ::v-deep .el-switch__label--right {
    z-index: 9;
    left: 4px;
  }

  .switchStyle ::v-deep .el-switch__label.is-active {
    display: block;
  }

  .switchStyle ::v-deep .el-switch .el-switch__core,
  .el-switch .el-switch__label {
    width: 50px !important;
  }

  .approvalInfoTips {
    font-weight: 500;
    font-size: 16px;
    color: #1d1d1d;
    margin-bottom: 16px;
  }

  .approvalInfoItem {
    margin-left: 20px;
    margin-bottom: 10px;
  }
}

.list-tips {
  background: #e4e3ff;
  border-radius: 4px;
  border: none;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.65);
  padding: 10px 16px;
  height: 20px;
  line-height: 20px;
}

.m-t-40 {
  margin-top: 40px;
}

.integralShopping-list .upload-wrap {
  display: flex;
}

// .integralShopping-list
.integralShopping-list .import-btn {
  position: relative;
}

.integralShopping-list .import-input {
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 98px;
  height: 36px;
  cursor: pointer;
  font-size: 0;
}

.integralShopping-list .import-template {
  position: absolute;
  height: 20px;
  top: 50px;
  left: 0;
}

.m-l-md {
  margin-left: 20px;
}

.upload-statistics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 30px 70px;

  .quantity {
    font-size: 14px;
    color: #333333;
    text-align: center;

    .success {
      font-size: 26px;
      color: #2cca74;
      text-align: center;
      margin-bottom: 4px;
    }

    .err {
      font-size: 26px;
      color: #eb4e4e;
      text-align: center;
      margin-bottom: 4px;
    }
  }

  .line {
    width: 1px;
    height: 56px;
    background: #e8e8ea;
  }
}

.abnormal {
  width: 100%;
  background: #f5f7fa;
  border-radius: 4px;
  padding: 8px 16px;
  box-sizing: border-box;
  font-size: 14px;
  color: #666666;

  .color-33 {
    color: #333333;
    margin-left: 8px;
    line-height: 20px;
  }
}
</style>