index.vue 27.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
<template>
  <div class="app-container">
    <!-- 筛选条件 -->
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      label-width="80px"
    >
      <el-form-item label="车主姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入车主"
          clearable
          style="width: 220px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车牌号码" prop="licensePlate">
        <el-input
          v-model="queryParams.licensePlate"
          placeholder="请输入车牌号"
          clearable
          style="width: 220px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="识别代码" prop="frameNumber">
        <el-input
          v-model="queryParams.frameNumber"
          placeholder="请输入车辆识别代码"
          clearable
          style="width: 220px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="时间范围" prop="timeFrame">
        <el-date-picker
          v-model="timeFrame"
          type="datetimerange"
          range-separator="To"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          @change="handleTime"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >查询</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="policyList">
      <el-table-column label="序号" width="55" type="index" />
      <el-table-column
        label="登记时间"
        prop="createTime"
        width="160"
        align="center"
      />
      <el-table-column
        label="车牌号"
        prop="licensePlateNumber"
        width="150"
        align="center"
      />
      <el-table-column
        label="车辆识别代号"
        width="180"
        prop="frameNumber"
        align="center"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="发动机号"
        width="180"
        prop="engineNumber"
        align="center"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="是否新能源"
        prop="isNewEnergy"
        width="150"
        align="center"
      />
      <el-table-column
        label="车主姓名"
        prop="name"
        width="100"
        align="center"
      />
      <el-table-column
        label="保险需求"
        prop="requirements"
        align="center"
        width="150"
      />
      <el-table-column
        label="联系电话"
        prop="phone"
        width="150"
        align="center"
      />
      <el-table-column
        label="上年承保公司"
        prop="sysDeptName"
        width="150"
        align="center"
      />
      <el-table-column
        v-hasRole="['associationemployee']"
        label="保单状态"
        width="100"
        prop="statue"
      >
        <template #default="{ row }">
          {{ row.policyStatus || "待处理" }}
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        min-width="300"
        fixed="right"
      >
        <template #default="{ row }">
          <el-button
            type="primary"
            v-hasPermi="['policy:pending:continue']"
            @click="handleContinue(row)"
            >{{
              row.orderProgress === "已承接" ? "承接回馈" : "承接"
            }}</el-button
          >
          <el-button
            type="primary"
            v-hasRole="['companyemployee']"
            @click="lookRemark(row)"
            >查询备注</el-button
          >
          <el-button
            type="primary"
            v-show="
              row.policyStatus !== '问题件' && row.orderProgress === '已承接'
            "
            v-hasPermi="['policy:pending:troubleshooting']"
            @click="handleTroubleshooting(row.taskId)"
            >问题件</el-button
          >
          <el-button
            type="primary"
            v-hasRole="['companyadmin']"
            @click="handleSharing(row.taskId)"
            >分配</el-button
          >
          <el-button
            type="primary"
            v-show="row.orderProgress !== '已承接'"
            v-hasPermi="['policy:pending:transfer']"
            @click="handleSharing(row.taskId)"
            >转办</el-button
          >
          <el-button
            type="primary"
            v-show="
              row.policyStatus !== '问题件' &&
              checkRole(['associationemployee'])
            "
            @click="handleUpdate(row)"
            >审核</el-button
          >
          <el-button
            type="primary"
            v-show="
              row.policyStatus === '问题件' &&
              checkRole(['associationemployee'])
            "
            @click="lookReason(row)"
            >查询</el-button
          >
          <el-button
            type="primary"
            v-show="
              row.policyStatus === '问题件' &&
              checkRole(['associationemployee'])
            "
            @click="handleVoid('2', row.taskId)"
            >作废</el-button
          >
          <el-button
            type="primary"
            v-show="
              row.policyStatus === '问题件' &&
              checkRole(['associationemployee'])
            "
            @click="handleAuthCompany('0', row.taskId)"
            >分配</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <!-- 页码 -->
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 通过备注对话框 -->
    <el-dialog
      v-model="successShow"
      title="通过备注"
      width="500"
      append-to-body
    >
      <QuillEditor v-model="successMsg" :min-height="192" />
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="successShow = false">取消</el-button>
          <el-button type="primary" @click="handleSuccess">确定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 分配备注对话框 -->
    <el-dialog
      v-model="sharingShow"
      title="分配备注"
      width="500"
      append-to-body
    >
      <QuillEditor v-model="sharingMsg" :min-height="192" />
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="sharingShow = false">取消</el-button>
          <el-button type="primary" @click="submitForm">确定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 表单作废,退回。问题件对话框 -->
    <el-dialog
      v-model="deprecatedShow"
      :title="activeTitle"
      width="500"
      append-to-body
    >
      <QuillEditor
        v-model="deprecatedForm.deprecatedReason"
        :min-height="192"
      />
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="deprecatedShow = false">取消</el-button>
          <el-button type="primary" @click="sunmitDeprecated">确定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 分配承保公司对话框 -->
    <el-dialog
      v-model="companyShow"
      title="分配承保公司:"
      width="500"
      append-to-body
    >
      <div class="company_box">
        <div class="header_top">
          <el-input
            v-model="companyQueryParams.deptName"
            style="width: 380px"
            placeholder="请输入承保公司名称(支持模糊查询)"
            prefix-icon="Search"
          />
          <el-button type="primary" @click="getDeptList">查询</el-button>
        </div>
        <div class="company_content">
          <el-radio-group v-model="companyForm.deptId">
            <el-radio
              v-for="item in deptOptions"
              :key="item.deptId"
              :label="item.deptId"
              v-show="item.deptName !== '无'"
              >{{ item.deptName }}</el-radio
            >
          </el-radio-group>
        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="companyShow = false">取消</el-button>
          <el-button type="primary" @click="sharingShow = true">确定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 转办分配对话框 -->
    <el-dialog
      v-model="transferShow"
      title="请选择人员:"
      width="500"
      append-to-body
    >
      <div class="company_box">
        <el-radio-group v-model="transferForm.username">
          <el-radio
            v-for="item in transferOptions"
            :key="item.userName"
            :label="item.userName"
            >{{ item.nickName }}</el-radio
          >
        </el-radio-group>
        <div v-show="transferOptions.length === 0">暂无其他员工</div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="transferShow = false">取消</el-button>
          <el-button type="primary" @click="submitTransfer">确定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 承接回馈对话框 -->
    <el-dialog
      v-model="showFeedback"
      title="填写承接回馈"
      width="500"
      append-to-body
    >
      <p style="margin-bottom: 10px; color: red">请根据实际情况填写保单号</p>
      <el-form
        :model="FeedbackForm"
        ref="policyRef"
        label-width="100px"
        label-position="top"
      >
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="商业险保单号" prop="progress">
              <el-input
                v-model="FeedbackForm.commercialinsurancepolicynumber"
                placeholder="请输入保单号"
                :disabled="hasRole"
                style="width: 220px"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="交强险保单号" prop="progress">
              <el-input
                v-model="FeedbackForm.stronginsurancepolicynumber"
                placeholder="请输入保单号"
                :disabled="hasRole"
                style="width: 220px"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item prop="progress" label="保单回馈内容">
              <QuillEditor v-model="FeedbackForm.message" :min-height="192" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="showFeedback = false">取消</el-button>
          <el-button type="primary" @click="submit">提交回馈</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 查询问题件弹出框 -->
    <el-dialog v-model="showIssue" title="保单信息" width="700" append-to-body>
      <div style="margin-bottom: 10px">
        <span style="margin-right: 20px"
          >问题件退回公司:{{ issueReturenCompany }}</span
        >
        <span style="margin-right: 20px"
          >操作人员:{{ issueCompanyPerson }}</span
        >
        <span>联系电话: {{ issueCompanyPersonPhone }}</span>
      </div>
      <el-form :model="IssueForm" ref="policyRef" label-width="100px">
        <el-form-item label="问题件原因" prop="progress">
          <QuillEditor
            v-model="IssueForm.deprecatedReason"
            :readOnly="true"
            :min-height="192"
          />
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 查询通过备注弹出框 -->
    <el-dialog
      v-model="lookSuccessShow"
      title="通过备注"
      width="700"
      append-to-body
    >
      <QuillEditor
        v-model="lookSuccessMsg"
        :readOnly="true"
        :min-height="192"
      />
    </el-dialog>

    <!-- 编辑对话框 -->
    <el-dialog v-model="open" title="保单信息" width="700" append-to-body>
      <el-form :model="form" ref="policyRef" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="车牌号" prop="licensePlateNumber">
              <el-input
                v-model="form.licensePlateNumber"
                placeholder="请输入车牌号"
                :disabled="!hasRole"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆识别号" prop="frameNumber">
              <el-input
                v-model="form.frameNumber"
                :disabled="!hasRole"
                placeholder="请输入车架号"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="车主姓名" prop="name">
              <el-input
                v-model="form.name"
                :disabled="!hasRole"
                placeholder="请输入车主姓名"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="phone">
              <el-input
                v-model="form.phone"
                :disabled="!hasRole"
                placeholder="请输入联系电话"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="上年承保公司" prop="sysDeptId">
              <el-select
                v-model="form.sysDeptId"
                :disabled="!hasRole"
                style="width: 230px"
              >
                <el-option
                  v-for="item in deptOptions"
                  :key="item.deptId"
                  :label="item.deptName"
                  :value="item.deptId"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆使用性质" prop="vehicleNature">
              <el-select
                v-model="form.vehicleNatureId"
                :disabled="!hasRole"
                style="width: 230px"
              >
                <el-option
                  v-for="item in carNatureOption"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="发动机号" prop="engineNumber">
              <el-input
                v-model="form.engineNumber"
                :disabled="!hasRole"
                placeholder="请输入发动机号"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否新能源" prop="isNewEnergy">
              <el-select
                v-model="form.isNewEnergy"
                :disabled="!hasRole"
                style="width: 230px"
              >
                <el-option
                  v-for="item in NewEnergyOption"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="保险需求" prop="requirements">
              <el-select
                v-model="form.requirementsId"
                :disabled="!hasRole"
                style="width: 230px"
              >
                <el-option
                  v-for="item in needOption"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 流转提示 -->
        <div class="transferTip">
          <span>自动订单流转:{{ transferTip }}</span>
          <el-button :loading="loadingBtn" @click="getTransferTip(1000)"
            >刷新</el-button
          >
        </div>
      </el-form>
      <template #footer>
        <div
          class="dialog-footer"
          style="
            display: flex;
            justify-content: space-around;
            width: 65%;
            margin-left: auto;
          "
        >
          <el-button
            type="primary"
            v-hasRole="['associationemployee']"
            @click="submitUpdate"
            >修改保存</el-button
          >
          <el-button
            type="primary"
            v-hasRole="['associationemployee']"
            @click.stop="successShow = true"
          >
            通过
          </el-button>
          <el-button
            type="primary"
            v-hasRole="['associationemployee']"
            @click="handleVoid('2', taskId)"
            >作废</el-button
          >
          <el-button
            type="primary"
            v-hasRole="['associationemployee']"
            @click="handleFallback('1')"
            >退回</el-button
          >
          <el-button
            type="primary"
            v-hasRole="['associationemployee']"
            @click.stop="handleAuthCompany('0', taskId)"
            >人工分配</el-button
          >
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import {
  queryMyList,
  disposeUser,
  transfer,
  getUserList,
  updateCarInfo,
  getCarDetail,
  getCompanyTip,
  queryDefeatContent,
} from "@/api/policy/index";
import { checkRole } from "@/utils/permission"; // 权限判断函数
import useSelectData from "@/hooks/useSelectData.js";
import { listDept } from "@/api/system/dept";
import { ref } from "vue";
const { proxy } = getCurrentInstance();
const activeTitle = ref(""); // 弹窗标题
const taskId = ref(""); // 任务ID

const open = ref(false); // 编辑弹窗显示变量
const form = ref({}); // 编辑表单数据
/** 修改按钮操作 */
const handleUpdate = async (row) => {
  reset();
  const { data } = await getCarDetail(row.businessKey);
  getTransferTip(0);
  form.value = data;
  open.value = true;
  taskId.value = row.taskId;
};
// 提交修改
const submitUpdate = () => {
  updateCarInfo(form.value).then((response) => {
    proxy.$modal.msgSuccess("修改成功");
    getList();
  });
};
/** 重置操作表单 */
function reset() {
  proxy.resetForm("policyRef");
}

// 判断是否有权限
const hasRole = computed(() => {
  return proxy.$auth.hasRole("associationemployee");
});

// 获取选择数据列表
const { carNatureOption, needOption, NewEnergyOption } = useSelectData();

// table数据列表
const policyList = ref([]);
const total = ref(0); // 总条数
// table加载动画
const loading = ref(false);
// 获取待办列表
const getList = async () => {
  loading.value = true;
  const { data } = await queryMyList(queryParams);
  policyList.value = data.rows;
  total.value = data.total;
  loading.value = false;
};

// 回馈弹窗显示变量
const showFeedback = ref(false);
// 承接
const handleContinue = (row) => {
  if (row.orderProgress === "待承接") {
    proxy.$modal
      .confirm("是否要承接该保单")
      .then(function () {})
      .then(() => {
        disposeUser({}, row.taskId).then((res) => {
          proxy.$modal.msgSuccess("承接成功");
          getList();
        });
      })
      .catch(() => {
        proxy.$modal.msg("已取消");
      });
  } else {
    reset();
    FeedbackForm.value.taskId = row.taskId;
    showFeedback.value = true;
  }
};
// 承接回馈内容表单
const FeedbackForm = ref({
  stronginsurancepolicynumber: "", // 交强险
  commercialinsurancepolicynumber: "", // 商业险
  message: "", // 备注
});
// 提交承接回馈
const submit = () => {
  const data = {
    policystatus: "2",
    message: FeedbackForm.value.message,
    commercialinsurancepolicynumber:
      FeedbackForm.value.commercialinsurancepolicynumber,
    stronginsurancepolicynumber: FeedbackForm.value.stronginsurancepolicynumber,
  };
  disposeUser(data, FeedbackForm.value.taskId).then((res) => {
    getList();
    proxy.$modal.msgSuccess("回馈成功");
    showFeedback.value = false;
  });
};

const successShow = ref(false); // 通过备注显示变量
const successMsg = ref(""); // 通过备注
const lookSuccessShow = ref(false); // 查看通过备注显示变量
const lookSuccessMsg = ref(""); // 查看通过备注
// 提交通过保单
const handleSuccess = async () => {
  await disposeUser(
    {
      associationapprove: "0",
      associationapprovetype: "0",
      deptid: transferDeptId.value,
      comment: successMsg.value,
    },
    taskId.value
  );
  proxy.$modal.msgSuccess("保单已通过");
  open.value = false;
  successShow.value = false;
  getList();
};
// 查阅通过备注
const lookRemark = async (row) => {
  const { data } = await queryDefeatContent({
    processInstanceId: row.processInstanceId,
    type: 3,
  });
  lookSuccessMsg.value = data.message;
  lookSuccessShow.value = true;
};

const typeId = ref(0); // 判断类型 0 问题件 1 退回 2 作废
// 表单作废,退回。问题件对话框显示
const deprecatedShow = ref(false);
// 表单作废,退回。问题件对话框内容表单
const deprecatedForm = ref({
  deprecatedReason: "",
  associationapprove: "",
});
// 退回保单
const handleFallback = (associationapprove) => {
  deprecatedForm.value = {
    associationapprove,
    taskId: taskId.value,
  };
  deprecatedForm.value.deprecatedReason = "";
  typeId.value = 1;
  activeTitle.value = "退回后用户需修改后重新提交";
  deprecatedShow.value = true;
};
// 作废保单
const handleVoid = (associationapprove, taskId) => {
  deprecatedForm.value = {
    associationapprove,
    taskId,
  };
  deprecatedForm.value.deprecatedReason = "";
  typeId.value = 2;
  activeTitle.value =
    "温馨提示:该保单作废后车牌号、车架号在本自然年度无法重新提交";
  deprecatedShow.value = true;
};
const showIssue = ref(false); // 问题件原因显示变量
const issueReturenCompany = ref(""); // 问题件退回公司
const issueCompanyPerson = ref(""); // 问题件退回操作人员
const issueCompanyPersonPhone = ref(""); // 问题件退回操作人员手机号
// 问题件退回原因
const IssueForm = ref({
  deprecatedReason: "",
});
// 问题件
const handleTroubleshooting = (taskId) => {
  deprecatedForm.value.taskId = taskId;
  activeTitle.value = "问题件退回至协会";
  typeId.value = 0;
  deprecatedShow.value = true;
};
// 查询问题件原因
const lookReason = async (row) => {
  const { data } = await queryDefeatContent({
    processInstanceId: row.processInstanceId,
    type: 0,
  });
  IssueForm.value.deprecatedReason = data.message;
  showIssue.value = true;
  issueReturenCompany.value = row.companyName;
  issueCompanyPerson.value = row.companyEmployeeUserName;
  issueCompanyPersonPhone.value = row.companyEmployeePhone;
};
// 提交作废,退回,问题件表单
const sunmitDeprecated = () => {
  let data = {};
  if (typeId.value === 0) {
    data = {
      policystatus: "1",
      comment: deprecatedForm.value.deprecatedReason,
    };
  } else {
    data = {
      associationapprove: deprecatedForm.value.associationapprove,
      comment: deprecatedForm.value.deprecatedReason,
    };
  }
  const taskId = deprecatedForm.value.taskId;
  // 办理一个业务
  disposeUser(data, taskId).then((res) => {
    getList();
    open.value = false;
    deprecatedShow.value = false;
    proxy.$modal.msgSuccess("操作成功");
  });
};

const transferShow = ref(false); // 转办弹窗显示变量
const transferForm = ref({}); // 转办分配表单数据
// 转办,分配人员列表数据
const transferOptions = ref([]);
// 获取人员列表
const getUser = async () => {
  const { data } = await getUserList();
  transferOptions.value = data;
};
// 转办或分配
const handleSharing = (id) => {
  transferForm.value.taskId = id;
  getUser();
  transferShow.value = true;
};
/** 提交通过分配转办人员 */
function submitTransfer() {
  const data = {
    username: transferForm.value.username,
  };
  const taskId = transferForm.value.taskId;
  transfer(data, taskId).then((res) => {
    transferShow.value = false;
    getList();
    proxy.$modal.msgSuccess("保单已分配成功");
  });
}

// 分配承保公司弹窗显示
const companyShow = ref(false);
// 分配承保公司查询参数
const companyQueryParams = reactive({
  deptName: undefined,
  status: undefined,
});
// 分配承保公司列表数据
const deptOptions = ref([
  {
    deptId: "0",
    deptName: "无",
  },
]);
// 确认选择的承保公司数据表单
const companyForm = ref({});
const sharingShow = ref(false); // 分配备注显示变量
const sharingMsg = ref(""); // 分配备注
// 分配承保公司
const handleAuthCompany = (associationapprove, taskId) => {
  companyForm.value = {
    associationapprove,
    taskId: taskId,
  };
  companyShow.value = true;
};
/** 提交通过分配承保公司 */
function submitForm() {
  const data = {
    associationapprove: companyForm.value.associationapprove,
    associationapprovetype: "1",
    deptid: companyForm.value.deptId.toString(),
    comment: sharingMsg.value,
  };
  const taskId = companyForm.value.taskId;
  disposeUser(data, taskId).then((res) => {
    companyShow.value = false;
    sharingShow.value = false;
    getList();
    proxy.$modal.msgSuccess("保单已分配成功");
  });
}
/** 查询承保公司列表 */
const getDeptList = () => {
  listDept(companyQueryParams).then((response) => {
    let newArr = [];
    newArr = response.data.filter((item) => item.parentId === 100);
    let arrNew = newArr.map((child) => {
      return {
        deptId: child.deptId.toString(),
        deptName: child.deptName,
      };
    });
    deptOptions.value.push(...arrNew);
  });
};

const loadingBtn = ref(false); // 刷新流转公司加载按钮
const transferTip = ref(""); //流转下一家名称
const transferDeptId = ref(""); // 流转的部门公司ID
// 获取流转下一家分配公司
const getTransferTip = async (timers) => {
  if (!loadingBtn.value) {
    loadingBtn.value = true;
    const { data } = await getCompanyTip();
    let timer = setTimeout(() => {
      transferTip.value = data.deptName;
      transferDeptId.value = data.deptId.toString();
      loadingBtn.value = false;
      clearTimeout(timer);
    }, timers);
  }
};

// 筛选时间范围
const timeFrame = ref(null);
// 选择时间范围
const handleTime = (valu) => {
  if (valu !== null) {
    queryParams.startTime = proxy.parseTime(valu[0]);
    queryParams.endTime = proxy.parseTime(valu[1]);
  } else {
    queryParams.startTime = "";
    queryParams.endTime = "";
  }
};
// 查询参数
const queryParams = reactive({
  pageNum: 1,
  pageSize: 10,
  name: "",
  licensePlate: "",
  type: 0,
  frameNumber: "",
  startTime: "",
  endTime: "",
});
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.pageNum = 1;
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  queryParams.startTime = "";
  queryParams.endTime = "";
  handleQuery();
}

onMounted(() => {
  getList();
});

// 判断是否为协会员工,协会员工可分配承保公司
if (checkRole(["associationemployee"])) {
  getDeptList();
}
</script>

<style lang="scss" scoped>
::v-deep(.el-radio-group) {
  align-items: start;
  flex-direction: column;
}
.header_top {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-bottom: 20px;
}
.transferTip {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
  color: #666;
}
.company_content {
  width: 100%;
  height: 200px;
  overflow-y: scroll;
}
</style>