MemberProfileDialog.vue 31.5 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
<template>
  <el-dialog
    :visible.sync="visibleProxy"
    :show-close="false"
    :close-on-click-modal="true"
    :close-on-press-escape="true"
    custom-class="member-dialog"
    append-to-body
  >
    <div class="member-dialog-inner">
      <!-- 头部:姓名 + 等级 + 手机 + 门店 + 状态 -->
      <div class="member-header">
        <div class="member-avatar"><span>{{ initials }}</span></div>
        <div class="member-basic">
          <div class="name-line">
            <span class="name">{{ displayName }}</span>
            <span v-if="member.consumeLevelName || member.levelName" class="level-tag">{{ member.consumeLevelName || member.levelName }}</span>
          </div>
          <div class="sub-line">
            <span v-if="member.xb">{{ member.xb }}</span>
            <span v-if="member.sjh"> · {{ member.sjh }}</span>
            <span v-if="member.gsmdName || member.storeName"> · {{ member.gsmdName || member.storeName }}</span>
          </div>
          <div class="status-sub">最后到店:{{ member.lastVisitTime || member.lastVisit || '—' }}</div>
          <div v-if="Array.isArray(member.tags) && member.tags.length" class="tag-row">
            <span v-for="tag in member.tags" :key="tag" class="member-tag">{{ tag }}</span>
          </div>
        </div>
      </div>

      <div class="member-body">
        <div class="row-one">
          <div class="block basic-info">
            <div class="section-title"><i class="el-icon-user section-icon"></i><span>基本信息</span></div>
            <div class="info-grid">
              <div class="info-cell"><span class="l">客户编码</span><span class="v">{{ member.id || '—' }}</span></div>
              <div class="info-cell"><span class="l">档案号</span><span class="v">{{ member.dah || '—' }}</span></div>
              <div class="info-cell"><span class="l">客户名称</span><span class="v">{{ member.khmc || '—' }}</span></div>
              <div class="info-cell"><span class="l">手机号</span><span class="v">{{ member.sjh || '—' }}</span></div>
              <div class="info-cell"><span class="l">性别</span><span class="v">{{ member.xb || '—' }}</span></div>
              <div class="info-cell"><span class="l">归属门店</span><span class="v">{{ member.gsmdName || member.storeName || '—' }}</span></div>
              <div class="info-cell"><span class="l">客户类型</span><span class="v">{{ member.khlxName || '—' }}</span></div>
              <div class="info-cell"><span class="l">注册时间</span><span class="v">{{ member.zcsj || '—' }}</span></div>
              <div class="info-cell"><span class="l">进店渠道</span><span class="v">{{ member.jdqd || '—' }}</span></div>
              <div class="info-cell"><span class="l">推荐人</span><span class="v">{{ member.tjrName || '—' }}</span></div>
              <div class="info-cell"><span class="l">健康师</span><span class="v">{{ member.mainHealthUserName || '—' }}</span></div>
              <div class="info-cell"><span class="l">负责顾问</span><span class="v">{{ member.subHealthUserName || '—' }}</span></div>
              <div class="info-cell"><span class="l">拓客人员</span><span class="v">{{ member.expandUserName || '—' }}</span></div>
              <div class="info-cell"><span class="l">联系地址</span><span class="v">{{ member.lxdz || member.address || '—' }}</span></div>
              <div class="info-cell remark-cell"><span class="l">备注</span><span class="v">{{ member.bz || member.remark || '—' }}</span></div>
            </div>
          </div>
          <div class="block stats-block">
            <div class="section-title"><i class="el-icon-wallet section-icon"></i><span>消费与到店</span></div>
            <div class="stats-mini">
              <div class="s"><span class="sl">耗卡总金额</span><span class="sv">¥{{ formatMoney(member.totalConsumeAmount) }}</span></div>
              <div class="s"><span class="sl">开卡总金额</span><span class="sv">¥{{ formatMoney(member.totalBillingAmount) }}</span></div>
              <div class="s"><span class="sl">剩余权益总金额</span><span class="sv primary">¥{{ formatMoney(member.remainingRightsAmount) }}</span></div>
              <div class="s"><span class="sl">到店天数</span><span class="sv">{{ member.visitDays || 0 }} 天</span></div>
              <div class="s"><span class="sl">沉睡天数</span><span class="sv">{{ member.sleepDays || 0 }} 天</span></div>
              <div class="s"><span class="sl">最后到店</span><span class="sv">{{ member.lastVisitTime || member.lastVisit || '—' }}</span></div>
            </div>
            <div class="section-title section-gap"><i class="el-icon-trophy section-icon"></i><span>等级与生日</span></div>
            <div class="stats-mini">
              <div class="s"><span class="sl">消费等级</span><span class="sv">{{ member.consumeLevelName || member.consumeLevel || '—' }}</span></div>
              <div class="s"><span class="sl">阳历生日</span><span class="sv">{{ member.yanglsr || '—' }}</span></div>
              <div class="s"><span class="sl">阴历生日</span><span class="sv">{{ member.yinlsr || '—' }}</span></div>
              <div class="s"><span class="sl">生美/医美/科技/教育</span><span class="sv">{{ memberTypeSummary }}</span></div>
            </div>
          </div>
        </div>

        <div class="records-area block">
          <div class="records-tabs-header">
            <div class="records-tab-list">
              <div class="records-tab-indicator" :style="recordsTabIndicatorStyle" />
              <button
                v-for="tab in recordTabs"
                :key="tab.key"
                class="records-tab"
                :class="{ 'records-tab--active': recordsTab === tab.key }"
                @click="recordsTab = tab.key"
              >
                <span class="records-tab-label">{{ tab.label }}</span>
              </button>
            </div>
            <div class="records-tabs-search">
              <el-input
                v-model="currentSearch"
                size="mini"
                clearable
                :placeholder="currentSearchPlaceholder"
                class="records-search"
              >
                <i slot="prefix" class="el-icon-search"></i>
              </el-input>
            </div>
          </div>

          <div v-if="recordsTab === 'invite'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredInviteRecords" border size="mini" class="record-table" empty-text="暂无邀约记录">
                <el-table-column prop="inviteTime" label="邀约时间" width="150" align="center" />
                <el-table-column prop="inviteContent" label="邀约内容" min-width="140" align="center" />
                <el-table-column prop="inviter" label="邀约人" width="90" align="center" />
                <el-table-column prop="status" label="状态" width="80" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="inviteTotalCount"
                  :current-page.sync="invitePage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'booking'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredBookingRecords" border size="mini" class="record-table" empty-text="暂无预约记录">
                <el-table-column prop="bookingTime" label="预约时间" width="150" align="center" />
                <el-table-column prop="projectName" label="预约项目" min-width="120" align="center" />
                <el-table-column prop="staffName" label="服务人员" width="90" align="center" />
                <el-table-column prop="status" label="状态" width="80" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="bookingTotalCount"
                  :current-page.sync="bookingPage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'billing'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredBillingRecords" border size="mini" class="record-table" empty-text="暂无开单记录">
                <el-table-column prop="orderNo" label="单号" min-width="120" align="center" />
                <el-table-column prop="billingTime" label="开单时间" width="150" align="center" />
                <el-table-column prop="productName" label="项目/产品" min-width="120" align="center" />
                <el-table-column prop="amount" label="金额" width="90" align="center">
                  <template slot-scope="scope">¥{{ formatMoney(scope.row.amount) }}</template>
                </el-table-column>
                <el-table-column prop="operator" label="操作人" width="90" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="billingTotalCount"
                  :current-page.sync="billingPage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'consume'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredConsumeRecords" border size="mini" class="record-table" empty-text="暂无消耗记录">
                <el-table-column prop="consumeTime" label="消耗时间" width="150" align="center" />
                <el-table-column prop="itemName" label="项目名称" min-width="120" align="center" />
                <el-table-column prop="count" label="消耗次数" width="88" align="center" />
                <el-table-column prop="operator" label="操作人" width="90" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="consumeTotalCount"
                  :current-page.sync="consumePage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'refund'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredRefundRecords" border size="mini" class="record-table" empty-text="暂无退卡记录">
                <el-table-column prop="refundTime" label="退卡时间" width="150" align="center" />
                <el-table-column prop="orderNo" label="退卡单号" min-width="130" align="center" />
                <el-table-column prop="projectName" label="退卡项目" min-width="120" align="center" />
                <el-table-column prop="amount" label="退卡金额" width="90" align="center">
                  <template slot-scope="scope">¥{{ formatMoney(scope.row.amount) }}</template>
                </el-table-column>
                <el-table-column prop="operator" label="操作人" width="90" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="refundTotalCount"
                  :current-page.sync="refundPage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'rights'" class="records-panel">
            <div class="rights-table-wrap">
              <el-table
                :data="filteredRemainingItems"
                border
                size="mini"
                class="rights-table"
                empty-text="暂无权益"
              >
                <el-table-column prop="ItemName" label="项目名称" min-width="110" align="center" />
                <el-table-column prop="ItemPrice" label="单价" width="88" align="center">
                  <template slot-scope="scope">¥{{ formatMoney(scope.row.ItemPrice) }}</template>
                </el-table-column>
                <el-table-column prop="SourceType" label="来源" width="72" align="center" />
                <el-table-column prop="TotalPurchased" label="总购买" width="72" align="center" />
                <el-table-column prop="ConsumedCount" label="已消费" width="72" align="center" />
                <el-table-column prop="RemainingCount" label="剩余" width="72" align="center">
                  <template slot-scope="scope">
                    <span class="num-remaining">{{ scope.row.RemainingCount ?? scope.row.remainingCount ?? 0 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="剩余合计" width="100" align="center">
                  <template slot-scope="scope">
                    <span class="num-total">¥{{ formatMoney(remainingItemTotal(scope.row)) }}</span>
                  </template>
                </el-table-column>
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="rightsTotalCount"
                  :current-page.sync="rightsPage"
                  small
                  background
                />
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="member-footer">
        <span class="records-op-btn records-op-btn--ghost records-op-btn--invite" @click="emitAction('invite')">去邀约</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--booking" @click="emitAction('booking')">去预约</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--billing" @click="emitAction('billing')">去开单</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--consume" @click="emitAction('consume')">去耗卡</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--refund" @click="emitAction('refund')">去退卡</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--close" @click="close">关闭</span>
      </div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'MemberProfileDialog',
  props: {
    visible: { type: Boolean, default: false },
    member: { type: Object, default: () => ({}) }
  },
  data() {
    return {
      recordsTab: 'invite',
      searchRights: '',
      searchBilling: '',
      searchConsume: '',
      searchInvite: '',
      searchBooking: '',
      searchRefund: '',
      pageSize: 5,
      rightsPage: 1,
      billingPage: 1,
      consumePage: 1,
      invitePage: 1,
      bookingPage: 1,
      refundPage: 1
    }
  },
  computed: {
    visibleProxy: {
      get() { return this.visible },
      set(val) { this.$emit('update:visible', val) }
    },
    displayName() {
      return this.member.khmc || this.member.name || '会员'
    },
    initials() {
      const n = this.displayName
      return n ? n[0] : '会'
    },
    // 兼容 RemainingItems(PC 接口)与 remainingItems
    remainingItems() {
      const list = this.member.RemainingItems || this.member.remainingItems || []
      return Array.isArray(list) ? list : []
    },
    remainingRightsTotal() {
      const list = this.remainingItems
      return list.reduce((sum, row) => sum + (Number(row.RemainingCount ?? row.remainingCount ?? 0) * Number(row.ItemPrice ?? row.itemPrice ?? 0)), 0)
    },
    memberTypeSummary() {
      const t = []
      if (this.member.isBeautyMember === 1) t.push('生美')
      if (this.member.isMedicalMember === 1) t.push('医美')
      if (this.member.isTechMember === 1) t.push('科技')
      if (this.member.isEducationMember === 1) t.push('教育')
      return t.length ? t.join(' / ') : '—'
    },
    filteredRightsAll() {
      const kw = (this.searchRights || '').trim()
      const list = this.remainingItems
      if (!kw) return list
      return list.filter(row => {
        const name = String(row.ItemName || row.itemName || '')
        return name.includes(kw)
      })
    },
    rightsTotalCount() {
      return this.filteredRightsAll.length
    },
    filteredRemainingItems() {
      const list = this.filteredRightsAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.rightsPage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    billingRecords() {
      const list = this.member.billingRecords || this.member.BillingRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredBillingAll() {
      const kw = (this.searchBilling || '').trim()
      const list = this.billingRecords
      if (!kw) return list
      return list.filter(row => {
        const orderNo = String(row.orderNo || '')
        const product = String(row.productName || '')
        return orderNo.includes(kw) || product.includes(kw)
      })
    },
    billingTotalCount() {
      return this.filteredBillingAll.length
    },
    filteredBillingRecords() {
      const list = this.filteredBillingAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.billingPage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    consumeRecords() {
      const list = this.member.consumeRecords || this.member.ConsumeRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredConsumeAll() {
      const kw = (this.searchConsume || '').trim()
      const list = this.consumeRecords
      if (!kw) return list
      return list.filter(row => {
        const name = String(row.itemName || '')
        return name.includes(kw)
      })
    },
    consumeTotalCount() {
      return this.filteredConsumeAll.length
    },
    filteredConsumeRecords() {
      const list = this.filteredConsumeAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.consumePage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    inviteRecords() {
      const list = this.member.inviteRecords || this.member.InviteRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredInviteAll() {
      const kw = (this.searchInvite || '').trim()
      const list = this.inviteRecords
      if (!kw) return list
      return list.filter(row => {
        const txt = String(row.inviteContent || '')
        const inviter = String(row.inviter || '')
        return txt.includes(kw) || inviter.includes(kw)
      })
    },
    inviteTotalCount() {
      return this.filteredInviteAll.length
    },
    filteredInviteRecords() {
      const list = this.filteredInviteAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.invitePage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    bookingRecords() {
      const list = this.member.bookingRecords || this.member.BookingRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredBookingAll() {
      const kw = (this.searchBooking || '').trim()
      const list = this.bookingRecords
      if (!kw) return list
      return list.filter(row => {
        const project = String(row.projectName || '')
        const staff = String(row.staffName || '')
        return project.includes(kw) || staff.includes(kw)
      })
    },
    bookingTotalCount() {
      return this.filteredBookingAll.length
    },
    filteredBookingRecords() {
      const list = this.filteredBookingAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.bookingPage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    refundRecords() {
      const list = this.member.refundRecords || this.member.RefundRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredRefundAll() {
      const kw = (this.searchRefund || '').trim()
      const list = this.refundRecords
      if (!kw) return list
      return list.filter(row => {
        const orderNo = String(row.orderNo || '')
        const project = String(row.projectName || '')
        return orderNo.includes(kw) || project.includes(kw)
      })
    },
    refundTotalCount() {
      return this.filteredRefundAll.length
    },
    filteredRefundRecords() {
      const list = this.filteredRefundAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.refundPage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    recordTabs() {
      return [
        { key: 'invite', label: '邀约记录' },
        { key: 'booking', label: '预约记录' },
        { key: 'billing', label: '开单记录' },
        { key: 'consume', label: '消耗记录' },
        { key: 'refund', label: '退卡记录' },
        { key: 'rights', label: '剩余权益' }
      ]
    },
    currentSearch: {
      get() {
        switch (this.recordsTab) {
          case 'invite': return this.searchInvite
          case 'booking': return this.searchBooking
          case 'billing': return this.searchBilling
          case 'consume': return this.searchConsume
          case 'refund': return this.searchRefund
          case 'rights': return this.searchRights
          default: return ''
        }
      },
      set(val) {
        switch (this.recordsTab) {
          case 'invite': this.searchInvite = val; break
          case 'booking': this.searchBooking = val; break
          case 'billing': this.searchBilling = val; break
          case 'consume': this.searchConsume = val; break
          case 'refund': this.searchRefund = val; break
          case 'rights': this.searchRights = val; break
        }
      }
    },
    currentSearchPlaceholder() {
      switch (this.recordsTab) {
        case 'invite': return '按内容 / 邀约人搜索'
        case 'booking': return '按项目 / 服务人员搜索'
        case 'billing': return '按单号 / 项目搜索'
        case 'consume': return '按项目名称搜索'
        case 'refund': return '按单号 / 项目搜索'
        case 'rights': return '按项目名称搜索'
        default: return '输入关键字搜索'
      }
    },
    recordsTabIndicatorStyle() {
      const tabs = this.recordTabs
      const count = tabs.length || 1
      const index = Math.max(0, tabs.findIndex(t => t.key === this.recordsTab))
      const width = 100 / count
      return {
        width: `${width}%`,
        // translateX 百分比基于自身宽度,移动一个 tab 宽度用 100% 为一步
        transform: `translateX(${index * 100}%)`
      }
    }
  },
  methods: {
    formatMoney(val) {
      if (val == null || val === '') return '0.00'
      const n = Number(val)
      if (isNaN(n)) return '0.00'
      return n.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
    },
    remainingItemTotal(row) {
      const c = Number(row.RemainingCount ?? row.remainingCount ?? 0)
      const p = Number(row.ItemPrice ?? row.itemPrice ?? 0)
      return c * p
    },
    emitAction(type) {
      this.$emit('action', { type, member: this.member })
    },
    close() {
      this.visibleProxy = false
    }
  }
}
</script>

<style lang="scss" scoped>
.member-dialog-inner {
  padding: 20px 24px 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

.member-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.member-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  margin-bottom: 14px;
}

.member-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(145deg, #6366f1, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 500;
  font-size: 20px;
}

.member-basic {
  flex: 1;
  .name-line { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
  .name { font-size: 17px; font-weight: 600; color: #0f172a; }
  .level-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #fef3c7; color: #c05621; }
  .sub-line { font-size: 12px; color: #64748b; }
  .status-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }
}

.tag-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.member-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(148, 163, 184, 0.16);
  color: #475569;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 10px;
  .section-icon { font-size: 14px; color: #6366f1; }
  &.section-gap { margin-top: 12px; }
}

/* 第一行:基本信息(左) + 消费到店(右) */
.row-one {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  margin-bottom: 16px;
}

.block {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.98));
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 8px;
}

.info-cell {
  display: flex;
  align-items: center;
  font-size: 12px;
  .l {
    color: #64748b;
    flex: 0 0 72px;
    display: flex;
    align-items: center;
    white-space: nowrap;
  }
  .v { color: #111827; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.remark-cell {
  grid-column: 1 / -1;
  align-items: flex-start;
}

.remark-cell .v {
  white-space: normal;
}

.stats-mini {
  .s { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 12px; }
  .sl { color: #64748b; }
  .sv { color: #111827; font-weight: 500; }
  .sv.primary { color: #2563eb; }
}

.rights-table-wrap {
  max-height: 260px;
  overflow-y: auto;
}

.rights-block {
  margin-bottom: 0;
}

.rights-table {
  font-size: 12px;
}

.rights-table ::v-deep .el-table th {
  padding: 6px 0;
  font-size: 12px;
  background: #f8fafc;
}

.rights-table ::v-deep .el-table td {
  padding: 5px 0;
}

.num-remaining { font-weight: 600; color: #2563eb; }
.num-total { font-weight: 600; color: #2563eb; }

.records-area {
  margin-top: 4px;
}

.records-tabs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.records-tab-list {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 520px;
  background: rgba(229, 231, 235, 0.82);
  border-radius: 999px;
  padding: 2px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.records-tab {
  border: none;
  outline: none;
  background: transparent;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  color: #4b5563;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  flex: 1 1 0;
  text-align: center;
  height: 28px;
  line-height: 28px;
  position: relative;
  z-index: 1;
}

.records-tab--active {
  color: #1d4ed8;
  font-weight: 600;
}

.records-tab-indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 6px 16px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(255,255,255,0.8);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform 0.24s ease;
  z-index: 0;
}

.records-tab-icon {
  font-size: 14px;
  margin-right: 4px;
}

.records-tab-label {
  white-space: nowrap;
}

.member-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(129, 140, 248, 0.12);
  color: #4f46e5;
}

.records-toolbar {
  position: absolute;
  top: 2px;
  right: 10px;
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

.records-title {
  font-size: 12px;
  color: #111827;
}

.records-search {
  width: 220px;
}

.records-search ::v-deep .el-input__inner {
  border-radius: 999px;
  height: 28px;
  line-height: 28px;
}

.records-search ::v-deep .el-input__prefix {
  display: flex;
  align-items: center;
  height: 100%;
}

.records-table-wrap {
  max-height: 260px;
  overflow-y: auto;
}

.records-pagination {
  margin-top: 6px;
  text-align: right;
}

.records-op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}

.records-op-btn--ghost {
  background: rgba(239, 246, 255, 0.9);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.records-op-btn:hover {
  transform: translateY(-0.5px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}
.records-op-btn--ghost:hover {
  color: #ffffff;
}

.records-op-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-size: 200% 100%;
  background-position: 0% 0;
  opacity: 0.9;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: -1;
}

.records-op-btn:hover::before {
  transform: translateX(0);
}

.records-op-btn--invite::before {
  background-image: linear-gradient(135deg, #0ea5e9, #22c55e);
}

.records-op-btn--booking::before {
  background-image: linear-gradient(135deg, #f97316, #facc15);
}

.records-op-btn--billing::before {
  background-image: linear-gradient(135deg, #3b82f6, #2563eb);
}

.records-op-btn--consume::before {
  background-image: linear-gradient(135deg, #22c55e, #16a34a);
}

.records-op-btn--refund::before {
  background-image: linear-gradient(135deg, #f97316, #ef4444);
}

.records-op-btn--close::before {
  background-image: linear-gradient(135deg, #e5e7eb, #cbd5f5);
}
.record-table { font-size: 12px; }
.record-table ::v-deep .el-table th {
  padding: 6px 0;
  font-size: 12px;
  background: #f8fafc;
}
.record-table ::v-deep .el-table td {
  padding: 5px 0;
}

.member-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

::v-deep .el-dialog {
  width: 1040px;
  max-width: 96vw;
  max-height: 86vh;
  margin-top: 5vh !important;
  border-radius: 24px;
  padding: 0;
  background: radial-gradient(circle at top left, rgba(255,255,255,0.96) 0, rgba(248,250,252,0.98) 38%, rgba(241,245,249,0.98) 100%);
  box-shadow:
    0 32px 60px rgba(15, 23, 42, 0.22),
    0 0 0 0.5px rgba(148, 163, 184, 0.35);
  border: 1px solid rgba(226, 232, 240, 0.9);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  display: flex;
  flex-direction: column;
}

::v-deep .el-dialog__header { display: none; }
::v-deep .el-dialog__body {
  padding: 0;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 768px) {
  .row-one { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}
</style>