OpportunityManagement.vue 26.9 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
<template>
  <div class="opportunity-management">
    <!-- 页面标题和统计卡片 -->
    <div class="page-header">
      <div class="title">
        <h1>全部管理</h1>
      </div>
    </div>

    <div class="stats-cards">
      <el-row :gutter="24">
        <el-col :span="6">
          <el-card class="dashboard-card">
            <div class="card-header">
              <span class="card-title">总计</span>
            </div>
            <div class="card-content">
              <div class="card-value">{{ statsStore.totalCount }}</div>
            </div>
            <img 
              src="../assets/icons/ad61df2f28f6b51d5f386829473ab1b592fd14e0.png" 
              alt="" 
              class="card-icon"
            >
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="dashboard-card">
            <div class="card-header">
              <span class="card-title">成单待审核</span>
            </div>
            <div class="card-content">
              <div class="card-value">{{ statsStore.pendingAuditCount }}</div>
            </div>
            <img 
              src="../assets/icons/1b66793397a66bf54212d266505eb98e3377a354.png" 
              alt="" 
              class="card-icon"
            >
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="dashboard-card">
            <div class="card-header">
              <span class="card-title">处理中</span>
            </div>
            <div class="card-content">
              <div class="card-value text-[rgb(10,10,10)]">{{ statsStore.processingCount }}</div>
            </div>
            <img 
              src="../assets/icons/eb05b4822d67dff64c5712d0777f069d241ecc13.png" 
              alt="" 
              class="card-icon"
            >
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="dashboard-card">
            <div class="card-header">
              <span class="card-title">已完结</span>
            </div>
            <div class="card-content">
              <div class="card-value text-[rgb(10,10,10)]">{{ statsStore.completedCount }}</div>
            </div>
            <img 
              src="../assets/icons/a8703fd7713f624a505aed79bcf30eb245a86d9c.png" 
              alt="" 
              class="card-icon"
            >
          </el-card>
        </el-col>
      </el-row>
    </div>

    <!-- 筛选条件 -->
    <el-card class="filter-card">
      <div class="filter-content">
        <el-row :gutter="24">
          <el-col :span="3">
            <div class="search-wrapper">
              <el-input
                v-model="formData.customerPhone"
                placeholder="用户账号"
                clearable
                style="padding-left: 0;"
              />
            </div>
          </el-col>
          <el-col :span="3">
            <div class="search-wrapper">
              <el-input
                v-model="formData.maintenanceStaffName"
                clearable
                placeholder="师傅名字"
                style="padding-left: 0;"
              />
            </div>
          </el-col>
          <el-col :span="3">
            <div class="search-wrapper">
              <el-input
                v-model="formData.marketingStaffName"
                clearable
                placeholder="支撑人员名字"
                style="padding-left: 0;"
              />
            </div>
          </el-col>
          
          <el-col :span="7">
            <el-date-picker
              v-model="formData.createTime"
              clearable
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              class="date-picker"
            />
          </el-col>

          <el-col :span="3">
            <el-select 
              v-model="formData.status" 
              placeholder="选择状态"
              clearable>
              <el-option label="全部状态" value="all"></el-option>
              <el-option 
                v-for="item in statusStore" 
                :key="item.key"
                :label="item.value"
                :value="item.key"
              ></el-option>
            </el-select>
          </el-col>
        </el-row>
      </div>

      <div class="filter-content" style="margin-top: 20px;">
        <el-row :gutter="24">
          <el-col :span="3" v-if="addressStore.cityArr.length>0">
            <el-select 
              v-model="addressStore.city" 
              placeholder="选择地市"
              @change="cityChange"
              :disabled="getData.city!=''"
              clearable>
              <el-option 
                v-for="item in addressStore.cityArr" 
                :key="item.areaCode"
                :label="item.areaName"
                :value="item.areaCode"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="3" v-if="addressStore.countyArr.length>0"> 
            <el-select 
              v-model="addressStore.county" 
              placeholder="选择区县"
              @change="countyChange"
              :disabled="getData.county!=''"
              clearable>
              <el-option 
                v-for="item in addressStore.countyArr" 
                :key="item.areaCode"
                :label="item.areaName"
                :value="item.areaCode"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="3" v-if="addressStore.gridArr.length>0">
            <el-select 
              v-model="addressStore.grid" 
              placeholder="选择网格"
              :disabled="getData.grid!=''"
              clearable>
              <el-option 
                v-for="item in addressStore.gridArr" 
                :key="item.gridCode"
                :label="item.gridName"
                :value="item.gridCode"
              ></el-option>
            </el-select>
          </el-col>

          <el-col :span="3">
            <el-button size="small" @click="handleFilter">
              <i class="el-icon-filter"></i>
              查询
            </el-button>
            <!-- <el-button size="small" @click="handleExport" type="default" disabled>
              <i class="el-icon-download"></i>
              导出数据
            </el-button> -->
          </el-col>
        </el-row>
      </div>

      
    </el-card>

    <!-- 商机列表 -->
    <el-card class="list-card">
      <div class="list-header">
        <h3 class="list-title">商机列表</h3>
        <div class="list-actions">
          <el-button 
            size="small" 
            @click="addNewBusi"
            type="primary"
          >
            <i class="el-icon-plus"></i>
            新增商机
          </el-button>
        </div>
      </div>

      <div class="list-content">
        <el-table
          :data="tableData" border
          v-loading="loading">
          <el-table-column prop="id" label="商机ID" width="150"></el-table-column>
          <el-table-column prop="createTime" label="创建时间" :formatter="timeRender" width="180"></el-table-column>
          <el-table-column prop="customerAddress" label="客户地址" width="230" :formatter="addressRender" show-overflow-tooltip></el-table-column>
          <el-table-column prop="customerPhone" label="用户账号" width="120"></el-table-column>
          <el-table-column prop="maintenanceStaffName" label="装维师傅姓名" width="120"></el-table-column>
          <el-table-column prop="marketingStaffName" label="支撑人员姓名" width="120"></el-table-column>
          <el-table-column label="商机标签" width="250">
            <template slot-scope="scope">
              <el-tag 
                v-for="tag in scope.row.tagNames" 
                :key="tag" 
                size="mini"
                type="info"
                style="margin-right: 4px; margin-bottom: 4px;"
              >
                {{ tag }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column label="当前状态" width="100" prop="status" :formatter="statusRender"></el-table-column>
          <el-table-column prop="latestFollowTime" label="最新跟进" width="180" :formatter="timeRender"></el-table-column>
          <el-table-column label="操作" min-width="200">
            <template slot-scope="scope">
              <el-button type="text" size="small"  @click="checkDetail(scope.row)">查看详情</el-button>
              <el-button type="text" size="small" @click="checkAudio(scope.row)" :disabled="scope.row.status!=3">审核</el-button>
            </template>
          </el-table-column>
        </el-table>

        <!-- 分页 -->
        <div class="pagination-container">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageStore.currentPage"
            :page-sizes="[20, 50, 100]"
            :page-size="pageStore.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pageStore.total"
          >
          </el-pagination>
        </div>
      </div>
    </el-card>

    <!-- 新增商机弹窗 -->
    <el-dialog
      title="新增商机"
      :visible.sync="newOpportunity.isShow"
      width="800px">
      <el-form  label-width="120px">
        <el-form-item label="用户账号" prop="customerPhone">
          <el-input v-model="newOpportunity.customerPhone" placeholder="请输入用户账号"></el-input>
        </el-form-item>
        <el-form-item label="客户地址" prop="city">
          <template v-if="newOpportunity.cityArr.length>0">
            <el-select 
              v-model="newOpportunity.city" 
              placeholder="选择地市"
              @change="addCityChange"
              style="margin-right: 10px"
              clearable>
              <el-option 
                v-for="item in newOpportunity.cityArr" 
                :key="item.code"
                :label="item.name"
                :value="item.code"
              ></el-option>
            </el-select>
          </template>
          <template v-if="newOpportunity.countyArr.length>0"> 
            <el-select 
              v-model="newOpportunity.county" 
              placeholder="选择区县"
              @change="addCountyChange"
              style="margin-right: 10px"
              clearable>
              <el-option 
                v-for="item in newOpportunity.countyArr" 
                :key="item.code"
                :label="item.name"
                :value="item.code"
              ></el-option>
            </el-select>
          </template>
          <template v-if="newOpportunity.streetsArr.length>0">
            <el-select 
              v-model="newOpportunity.streets" 
              placeholder="选择街道"
              @change="addStreetsChange"
              clearable>
              <el-option 
                v-for="item in newOpportunity.streetsArr" 
                :key="item.code"
                :label="item.name"
                :value="item.code"
              ></el-option>
            </el-select>
          </template>
          <el-input v-if="newOpportunity.streets" v-model="newOpportunity.detail" placeholder="请输入详细地址" style="margin-top: 10px;"></el-input>
        </el-form-item>
        <el-form-item label="装维人员工号" prop="maintenanceStaffNo">
          <el-input v-model="newOpportunity.maintenanceStaffNo" placeholder="请输入装维人员工号"></el-input>
        </el-form-item>
        <el-form-item label="业务类型" prop="tagIds">
          <el-select v-model="newOpportunity.tagIds" placeholder="请选择业务类型" style="width: 100%;" multiple>
            <el-option v-for="item in busiLabelStore" :label="item.tagName" :value="item.id" :disabled="isTagCanCho(item)"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="文字描述" prop="textDescription">
          <el-input 
            v-model="newOpportunity.textDescription" 
            type="textarea" 
            :rows="3"
            placeholder="请输入商机描述信息"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="newOpportunity.isShow = false">取消</el-button>
        <el-button type="primary" @click="addBusiSubmit">提交</el-button>
      </div>
    </el-dialog>

    <!-- 审核弹窗 -->
    <el-dialog
      title="商机审核"
      :visible.sync="isAuditDialogOpen"
      width="500px">
      <el-form :model="auditForm" label-width="100px">
        <el-form-item label="审核结果" required>
          <el-radio-group v-model="auditForm.result">
            <el-radio label="1">审核通过</el-radio>
            <el-radio label="0">审核不通过</el-radio>
          </el-radio-group>
        </el-form-item>
        
        <el-form-item v-if="auditForm.result == '0'" label="不通过理由" required>
          <el-input 
            v-model="auditForm.reason" 
            type="textarea" 
            :rows="4"
            placeholder="请输入审核不通过的理由"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="isAuditDialogOpen = false">取消</el-button>
        <el-button type="primary" @click="handleSubmitAudit">提交审核</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

// 商机状态映射
const statusMap = {
  'assigned': { label: '待跟进', color: 'blue' },
  'following': { label: '跟进中', color: 'orange' },
  'pending_review': { label: '成单待审核', color: 'purple' },
  'completed': { label: '已成单', color: 'green' },
  'closed': { label: '已关闭', color: 'gray' }
}

// 商机标签
const opportunityTags = [
  '网络升级', '家庭安防', '智能家居', '宽带套餐', '移动套餐', '融合套餐', '企业业务'
]
// 支撑人员列表
const mockSalesPersons = [
  { id: 'SALE001', name: '张营销', gridName: 'A网格', phone: '13812345001' },
  { id: 'SALE002', name: '陈营销', gridName: 'B网格', phone: '13812345002' },
  { id: 'SALE003', name: '刘营销', gridName: 'C网格', phone: '13812345003' },
  { id: 'SALE004', name: '赵营销', gridName: 'A网格', phone: '13812345004' },
  { id: 'SALE005', name: '王营销', gridName: 'B网格', phone: '13812345005' }
]

export default {
  name: 'OpportunityManagement',
  data() {
    return {
      formData:{
        customerPhone: '',
        maintenanceStaffName: '',
        marketingStaffName: '',
        createTime: '',
        status: '',
      },
      addressStore:{
        city: '',
        cityArr: '',
        county: '',
        countyArr: [],
        grid: '',
        gridArr: []
      },
      getData:{
        city: '',
        county: '',
        grid: '',
      },
      statsStore:{},
      statusStore:[],
      tableData: [],
      pageStore:{
        currentPage: 1,
        pageSize: 20,
        total: 0
      },
      newOpportunity: {
        isShow: false,

        customerPhone: '',

        city: '',
        cityName: '',
        cityArr: this.storesData.choAddressData,
        county: '',
        countyName: '',
        countyArr: [],
        streets: '',
        streetsName: '',
        streetsArr: [],
        detail: '',

        maintenanceStaffNo: '',
        tagIds: [],
        opportunityType: '',
        textDescription: ''
      },
      busiLabelStore: [],

      loading: false,
      statusMap,
      opportunityTags,
      mockSalesPersons,
      activeTab: 'all',
      searchTerm: '',
      selectedRegion: '',
      selectedStatus: '',
      selectedTag: '',
      dateRange: [],
      isAuditDialogOpen: false,
      auditForm: {
        result: '',
        reason: ''
      },
      auditOpportunityId: null,
      // 分页
      currentPage: 1,
      pageSize: 20,
    }
  },
  created(){
    let pa = JSON.parse(localStorage.getItem('accountInfo'))
    this.getData.city = pa.cityCode||''
    this.getData.county = pa.countyCode||''
    this.getData.grid = pa.gridCode||''
    this.queryArea()

    this.queryBusi()
    this.queryStatistics()
    this.queryStatus()
    this.queryAllBusiLabel()
  },
  methods: {
    addressRender(row,column){
      let value = row[column.property]

      if(!value){
        return '--'
      }
      return value.split(":")[1]
    },
    queryArea(){
      this.apiReq.queryLevelAllArea({
        areaLevel: 2,
        parentAreaCode: '320000'
      }).then(res=>{
        if(res.code == 200){
          this.addressStore.cityArr = res.data

          this.setAddressShow()
        }
      })
    },
    isTagCanCho(row){
      let arr = this.newOpportunity.tagIds

      if(arr.length == 0){
        return false
      }

      if(arr.includes(1) || arr.includes(2)){
        this.newOpportunity.opportunityType = 2
        if(row.id!=1 && row.id!=2){
          return true
        }else{
          return false
        }
      }else{
        this.newOpportunity.opportunityType = 1
        if(row.id==1 || row.id==2){
          return true
        }else{
          return false
        }
      }
    },
    addNewBusi(){
      let nd = this.newOpportunity

      nd.customerPhone = ''
      nd.city = ''
      nd.cityName = ''
      nd.county = ''
      nd.countyName = ''
      nd.streets = ''
      nd.streetsName = ''
      nd.maintenanceStaffNo = ''
      nd.tagIds = ''
      nd.textDescription = ''

      nd.isShow = true
    },
    queryAllBusiLabel(){
      this.apiReq.queryBusiLabelList({
        pageNum: 1,
        pageSize: 20,
      }).then(res=>{
        if(res.code == 200){
          this.busiLabelStore = res.data.records
        }
      })
    },
    timeRender(row,column){
      return this.common.detailTime(new Date(row[column.property]).getTime())
    },
    statusRender(row,column){
      return this.common.globalRender(row.status,this.statusStore)
    },
    setAddressShow(){
      let ad = this.addressStore
      let gd = this.getData

      if(gd.city){
        ad.city = gd.city
        this.cityChange(ad.city)

        if(gd.county){
          ad.county = gd.county
          this.countyChange(ad.county)

          if(gd.grid){
            ad.grid = gd.grid
          }
        }
      }

    },
    cityChange(value){
      let ad = this.addressStore
      ad.city = value
      ad.county = ''
      ad.grid = ''

      this.apiReq.queryLevelAllArea({
        areaLevel: 3,
        parentAreaCode: value
      }).then(res=>{
        if(res.code == 200){
          ad.countyArr = res.data
        }
      })
    },
    countyChange(value){
      let ad = this.addressStore
      ad.county = value
      ad.grid = ''

      this.apiReq.queryGridList({
        areaCode:value
      }).then(res=>{
        if(res.code == 200){
          ad.gridArr = res.data
        }
      })
    },
    addCityChange(value){
      let ad = this.newOpportunity
      ad.city = value
      ad.cityName = ad.cityArr.find(item => item.code == value).name

      ad.cityArr.forEach(item=>{
        if(item.code == ad.city){
          ad.countyArr = item.districts
        }
      })
    },
    addCountyChange(value){
      let ad = this.newOpportunity
      ad.county = value
      ad.countyName = ad.countyArr.find(item => item.code == value).name

      ad.countyArr.forEach(item=>{
        if(item.code == ad.county){
          ad.streetsArr = item.streets
        }
      })
    },
    addStreetsChange(value){
      let ad = this.newOpportunity
      ad.streets = value
      ad.streetsName = ad.streetsArr.find(item => item.code == value).name
    },
    queryBusi(){
      let d = this.formData

      if (d.createTime) {
        d.startDate = new Date(d.createTime[0]).getTime()
        d.endDate = new Date(d.createTime[1]).getTime() + 24 * 60 * 60 * 1000 - 1000
      } else {
        d.startDate  = ''
        d.endDate = ''
      }

      this.apiReq.queryAllBusi({
        pageNum: this.pageStore.currentPage,
        pageSize: this.pageStore.pageSize,
        areaCode: this.addressStore.county || this.addressStore.city,
        gridCode: this.addressStore.grid,
        ...d
      }).then(res=>{
        if(res.code == 200){
          this.tableData = res.data.records

          this.pageStore.total = res.data.total
        }else{
          this.$message.error(res.message)
        }
      })
    },
    handleSizeChange(size) {
      this.pageStore.pageSize = size
      
      this.handleFilter()
    },
    handleCurrentChange(page) {
      this.pageStore.currentPage = page

      this.queryBusi()
    },
    queryStatistics(){
      this.apiReq.queryAllBusiStatistics().then(res=>{
        if(res.code == 200){
          this.statsStore = res.data
        }
      })
    },
    queryStatus(){
      this.apiReq.queryBusiStatus().then(res=>{
        if(res.code == 200){
          this.statusStore = res.data
        }
      })
    },
    addBusiSubmit(){
      let nd = this.newOpportunity

      if(!nd.customerPhone){
        this.$message.error('请输入用户账号')
        return
      }


      if(!nd.city || !nd.county || !nd.streets || !nd.detail){
        this.$message.error('请补全客户地址信息')
        return
      }
      let address = nd.city+'|'+nd.county+'|'+nd.streets+":"+nd.cityName+nd.countyName+nd.streetsName+nd.detail

      if(!nd.maintenanceStaffNo){
        this.$message.error('请输入装维人员工号')
        return
      }
      if(!nd.tagIds){
        this.$message.error('请选择业务类型')
        return
      }

      this.apiReq.createBusi({
        customerAddress: address,
        ...nd
      }).then(res=>{
        let __this = this

        if(res.code == 200){
          this.$alert('添加成功', '温馨提示', {
            confirmButtonText: '确定',
            callback: () => {
              __this.handleFilter()
              __this.newOpportunity.isShow = false
            }
          });
        }else{
          this.$message.error(res.message)
        }
      })
    },





    getStatusType(status) {
      const typeMap = {
        'assigned': 'info',
        'following': 'warning',
        'pending_review': 'primary',
        'completed': 'success',
        'closed': 'info'
      }
      return typeMap[status] || 'info'
    },
    handleFilter() {
      // 重新计算筛选结果
      this.pageStore.currentPage = 1

      this.queryBusi()
    },
    clearFilters() {
      this.searchTerm = ''
      this.selectedRegion = ''
      this.selectedStatus = ''
      this.selectedTag = ''
      this.dateRange = []
      this.currentPage = 1
    },
    checkDetail(row){
      this.$router.push(`/opportunities/${row.id}`)
    },
    checkAudio(row){
      this.handleOpenAudit(row.id)
    },
    handleExport() {
      // 模拟导出功能
      this.$message.success('商机数据导出成功')
    },
    handleOpenAudit(opportunityId) {
      this.auditOpportunityId = opportunityId
      this.auditForm.result = ''
      this.auditForm.reason = ''
      this.isAuditDialogOpen = true
    },
    handleSubmitAudit() {
      if (!this.auditForm.result) {
        this.$message.error('请选择审核结果')
        return
      }

      if (this.auditForm.result == '0' && !this.auditForm.reason.trim()) {
        this.$message.error('审核不通过时必须填写理由')
        return
      }

     this.apiReq.audioBusi({
      auditStatus: this.auditForm.result,
      opportunityId: this.auditOpportunityId,
      reason: this.auditForm.reason
     }).then(res=>{
      if(res.code == 200){
        let __this = this
        this.$alert('审核完成', '温馨提示', {
          confirmButtonText: '确定',
          callback: () => {
            // 重置状态并关闭对话框
            __this.isAuditDialogOpen = false
            __this.auditOpportunityId = null
            __this.auditForm = {
              result: '',
              reason: ''
            }

            __this.queryBusi()
          }
        });
      }else{
        this.$message.error(res.message)
      }
     })
    }
  }
}
</script>

<style lang="scss" scoped>
.opportunity-management {
  .el-button.el-button--small{
    padding: 13px 12px;
  }

  .page-header {
    margin-bottom: 24px;

    .title {
      h1 {
        font-size: 24px;
        font-weight: 600;
        margin: 0;
        color: #303133;
      }
    }
  }

  .stats-cards {
    margin-bottom: 24px;
  }

  .dashboard-card {
    position: relative;
    height: 116px;
    
    .card-header {
      .card-title {
        font-size: 14px;
        font-weight: 600;
        font-weight: normal;
      }
    }
    
    .card-content {
      .card-value {
        font-size: 24px;
        font-weight: bold;
      }
    }
    
    .card-icon {
      position: absolute;
      right: 20px;
      top: 50%;
      transform: translateY(-50%);
      width: 88px;
      height: 88px;
    }
  }

  .filter-card {
    margin-bottom: 24px;

    .filter-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;

      .filter-title {
        font-size: 16px;
        font-weight: 600;
        margin: 0;
      }

      .filter-actions {
        display: flex;
        gap: 8px;
      }
    }

    .filter-content {
      .search-wrapper {
        position: relative;

        .search-icon {
          position: absolute;
          left: 10px;
          top: 50%;
          transform: translateY(-50%);
          color: #c0c4cc;
        }

        .el-input {
          padding-left: 30px;
        }
      }

      .date-picker {
        width: 100%;
      }
    }
  }

  .list-card {
    .list-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;

      .list-title {
        font-size: 16px;
        font-weight: 600;
        margin: 0;
      }

      .list-actions {
        display: flex;
        gap: 8px;
      }
    }

    .list-content {
      .pagination-container {
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
    }
  }
}
</style>