index.vue 34.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
<!-- 合同管理 -->
<template>
    <d2-container class="contract-wrap">
        <template #header>
            <div class="header">
                <d2-search ref="showSearch"
                           class="show-search"
                           :form-data="showFormData"
                           label-width="120px"
                           :search-form="searchForm">
                    <template #contractPriceHtml>
                        <div>
                            <InputRange :display-value="searchForm.contractPrice"
                                        end-placeholder="最大价格"
                                        start-placeholder="最小价格">
                            </InputRange>
                        </div>
                    </template>
                </d2-search>
                <div class="up-btns">
                    <el-button size="small"
                               type="primary"
                               @click="handleSearch">
                        查询
                    </el-button>
                    <el-button size="small" @click="handleReset">
                        重置
                    </el-button>
                </div>
            </div>
        </template>
        <div class="d2-container-content">
            <d2-table-header>
                <span data-event-code="contract_management_list_export"
                      style="margin-right: 10px">
                    <auth-button category="Button" :show-btn-ids="['9200309']" />
                </span>
                <span data-event-code="contract_management_list_export">
                    <auth-button category="Button" :show-btn-ids="['9200303']" />
                </span>
            </d2-table-header>
            <d2-table ref="table"
                      :before-search-fn="beforeSearchFn"
                      :get-list-api="getListApi"
                      :search-form="searchFormSearch"
                      :table-params="tableParams">
                <template #vehicleImgUrl="scope">
                    <div class="vehicleImgUrl-preview">
                        <GlsxPreview :image-url-arr="
                                         scope.scope.vehicleImgUrl
                                             ? [scope.scope.vehicleImgUrl]
                                             : [noDataUrl]
                                     "
                                     limit="1"
                                     :pic-options="picOptions">
                        </GlsxPreview>
                    </div>
                </template>
                <!-- 付款状态 -->
                <template #oaFlowPaymentStatusHtml="scope">
                    <div>
                        <div class="online-status">
                            <span class="dot"
                                  :style="{
                                      background: scope.scope.oaFlowPaymentStatus
                                          ? baseData.oaFlowPaymentStatusOpt.find(
                                              (item) => item.confId == scope.scope.oaFlowPaymentStatus,
                                          ).color
                                          : '',
                                  }">
                            </span>
                            {{
                                scope.scope.oaFlowPaymentStatus
                                    ? baseData.oaFlowPaymentStatusOpt.find(
                                        (item) => item.confId == scope.scope.oaFlowPaymentStatus,
                                    ).confValue
                                    : "-"
                            }}
                        </div>
                    </div>
                </template>
                <!-- 企微审批状态 -->
                <template #oaFlowStatusHtml="scope">
                    <div>
                        <div class="online-status">
                            <span class="dot"
                                  :style="{
                                      background: scope.scope.oaFlowStatus
                                          ? baseData.oaFlowStatusOpt.find(
                                              (item) => item.confId == scope.scope.oaFlowStatus,
                                          ).color
                                          : '',
                                  }">
                            </span>
                            {{
                                scope.scope.oaFlowStatus
                                    ? baseData.oaFlowStatusOpt.find(
                                        (item) => item.confId == scope.scope.oaFlowStatus,
                                    ).confValue
                                    : "-"
                            }}
                        </div>
                    </div>
                </template>
                <!-- 合同来源 -->
                <template #sourceHtml="scope">
                    <div>
                        <div class="online-status">
                            {{
                                scope.scope.source
                                    ? baseData.electronicContractOpt.find(
                                        (item) => item.confId == scope.scope.source,
                                    ).confValue
                                    : "-"
                            }}
                        </div>
                    </div>
                </template>
                <!-- 付款方式 -->
                <template #paymentMethodHtml="scope">
                    <div>
                        <div class="online-status">
                            {{
                                scope.scope.paymentMethod
                                    ? baseData.paymentMethodOpt.find(
                                        (item) => item.confId == scope.scope.paymentMethod,
                                    ).confValue
                                    : "-"
                            }}
                        </div>
                    </div>
                </template>
                <!-- 签署人类型 -->
                <template #signerTypeHtml="scope">
                    <div>
                        <div class="online-status">
                            {{
                                scope.scope.signerType === 0
                                    || scope.scope.signerType === "0"
                                    || (scope.scope.signerType !== null
                                        && scope.scope.signerType !== undefined
                                        && scope.scope.signerType !== "")
                                    ? (
                                        baseData.signerTypeOpt.find(
                                            (item) =>
                                                item.confId != null
                                                && item.confId !== ""
                                                && String(item.confId) === String(scope.scope.signerType),
                                        ) || {}
                                    ).confValue || "-"
                                    : "-"
                            }}
                        </div>
                    </div>
                </template>
                <!-- 内部主体 -->
                <template #contractOrgHtml="scope">
                    <div>
                        <div class="online-status">
                            {{
                                scope.scope.contractOrg !== null
                                    && scope.scope.contractOrg !== undefined
                                    && scope.scope.contractOrg !== ""
                                    ? (
                                        baseData.contractOrgOpt.find(
                                            (item) =>
                                                item.confId != null
                                                && item.confId !== ""
                                                && String(item.confId) === String(scope.scope.contractOrg),
                                        ) || {}
                                    ).confValue || "-"
                                    : "-"
                            }}
                        </div>
                    </div>
                </template>
                <template #auth-button="scope">
                    <div>
                        <span style="margin-right: 10px">
                            <auth-button :data="scope.scope" :show-btn-ids="['9200301']" />
                        </span>
                        <span v-if="scope.scope.electronicContractStatus == 2"
                              data-event-code="contract_management_download"
                              :data-track="
                                  JSON.stringify({
                                      id: scope.scope.id,
                                  })
                              "
                              style="margin-right: 10px">
                            <auth-button :data="scope.scope" :show-btn-ids="['9200302']" />
                        </span>
                        <el-button v-if="scope.scope.contractProcessNode"
                                   size="mini"
                                   type="text"
                                   @click="jumpDetail(scope.scope)">
                            合同编辑
                        </el-button>
                    </div>
                </template>
            </d2-table>
        </div>
        <el-dialog :close-on-click-modal="false"
                   title="合同导入"
                   :visible.sync="fileVisible"
                   width="480px">
            <div class="activity-info-container">
                <el-form ref="fileRuleForm"
                         label-width="120px"
                         :model="fileForm"
                         :rules="fileRules">
                    <el-form-item label="合同信息表:" prop="fileName">
                        <div>
                            <el-button class="import-btn1">
                                <i class="el-icon-plus"></i>添加附件
                                <input id="fileUpload"
                                       accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
                                       class="import-input"
                                       type="file"
                                       @change="importFile($event)" />
                            </el-button>
                            <el-link class="import-template"
                                     icon="el-icon-link"
                                     type="primary"
                                     @click="exportTemplate">
                                下载模板
                            </el-link>
                        </div>
                        <div style="margin-top: 10px">
                            <div v-if="!fileForm.fileName">
                                请选择需要导入的合同信息表格
                            </div>
                            <div v-else class="flex">
                                <div class="fileName">
                                    {{ fileForm.fileName }}
                                </div>
                                <i class="el-icon-delete" @click="removeFile"></i>
                            </div>
                        </div>
                    </el-form-item>
                </el-form>
                <div v-if="fileInfo && !uploadFlag"
                     class="result-box"
                     style="margin-top: 10px">
                    <div>
                        <span style="color: #666666">操作结果:</span>
                        <span style="margin-right: 10px">
                            成功记录
                            <span style="color: #2cca74; margin-left: 10px">
                                {{
                                    fileForm.succ
                                }}
                            </span>
                        </span>
                        <span style="margin-right: 10px">
                            失败记录
                            <span style="color: #eb4e4e; margin-left: 10px">
                                {{
                                    fileForm.fail
                                }}
                            </span>
                        </span>
                    </div>
                    <el-button v-if="fileForm.failDownloadUrl"
                               type="text"
                               @click.stop="exportError(fileForm.failDownloadUrl)">
                        导出失败记录
                    </el-button>
                </div>
            </div>
            <template #footer>
                <div>
                    <el-button v-preventReClick @click="fileVisible = false">
                        取消
                    </el-button>
                    <el-button :loading="uploadFlag"
                               type="primary"
                               @click="fileVisible = false">
                        确定
                    </el-button>
                </div>
            </template>
        </el-dialog>
    </d2-container>
</template>

<script>
import GlOssApi from "glsk-oss-jssdk";
import { mapActions, mapState } from "vuex";
import {
	checkContract,
	exportContractImageZipAsync,
	getContractDownload,
	getContractList,
	importContract,
} from "@/api/usedCarManagement.js";
import {
	contractOrgOpt,
	electronicContractOpt,
	electronicContractStatusOpt,
	electronicContractTypeOpt,
	docTemplateTypeOpt,
	evaluationStatusOpt,
	evaluationStatusOptMap,
	oaFlowPaymentStatusOpt,
	oaFlowStatusOpt,
	paymentMethodOpt,
	payStatusOpt,
	signerTypeOpt,
	splitPayOpt,
	wechatTypeOpt,
} from "@/common/constants.js";
import { deepClone, Util } from "@/common/util";
import { baseConfig } from "@/main";
import reportTrackPageMixin from "@/mixins/reportTrackPageMixin";
import preview from "../../../components/preview";
import inputRange from "../inputRange";

export default {
	components: {
		GlsxPreview: preview,
		InputRange: inputRange,
	},
	mixins: [reportTrackPageMixin],
	data() {
		return {
			getListApi: getContractList,
			noDataUrl: require("@/assets/noData.png"),
			picOptions: {
				width: "138px",
				height: "54px",
				isClose: false,
			},
			tableParams: {
				listName: "records",
				mutiSelectUniqueKey: "id",
				mutiSelectName: "mutiSelectIndex",
				tableOption: {
					width: "170",
				},
				tableColumns: [
					{
						label: "车辆照片",
						prop: "vehicleImgUrl",
						width: "138px",
						addHtml: "vehicleImgUrl",
					},
					{
						label: "车牌号",
						prop: "licensePlate",
						width: "100px",
						width: "100px",
					},
					{
						label: "车架号",
						prop: "vin",
						width: 160,
					},
					{
						label: "车型",
						prop: "carTypeName",
						minWidth: 150,
						formatter: (cellValue) => {
							const carBrand = cellValue.carBrand ? cellValue.carBrand : "";
							const carSeriesName = cellValue.carSeriesName
								? cellValue.carSeriesName
								: "";
							const carTypeName = cellValue.carTypeName
								? cellValue.carTypeName
								: "";
							return carBrand || carSeriesName || carTypeName
								? carBrand + " " + carSeriesName + " " + carTypeName
								: "-";
						},
					},
					{
						label: "签约时间",
						prop: "signTime",
						minWidth: 150,
					},
					{
						label: "评估单编号",
						prop: "evalOrderNo",
						width: 170,
					},

					{
						label: "合同类型",
						prop: "electronicContractType",
						minWidth: 150,
						formatter: (cellValue) => {
							const statusItem = this.getStatusItem(
								this.baseData,
								"electronicContractTypeOpt",
								cellValue,
								"electronicContractType",
							);
							return statusItem ? statusItem.confValue : "-";
						},
					},
					{
						label: "合同模版",
						prop: "docTemplateName",
						minWidth: 150,
						formatter: (cellValue) => {
							return cellValue.docTemplateName || "-";
						},
					},
					{
						label: "合同流转状态",
						prop: "electronicContractStatus",
						minWidth: 120,
						formatter: (cellValue) => {
							const statusItem = this.getStatusItem(
								this.baseData,
								"electronicContractStatusOpt",
								cellValue,
								"electronicContractStatus",
							);
							return statusItem ? statusItem.confValue : "-";
						},
					},

					{
						label: "驻店人员",
						prop: "createdBy",
					},
					{
						label: "支付方式",
						prop: "paymentType",
						minWidth: 120,
						formatter: (cellValue) => {
							const statusItem = this.getStatusItem(
								this.baseData,
								"payStatusOpt",
								cellValue,
								"paymentType",
							);
							return statusItem ? statusItem.confValue : "-";
						},
					},
					{
						label: "支付状态",
						prop: "oaFlowPaymentStatus",
						minWidth: 120,
						addHtml: "oaFlowPaymentStatusHtml",
					},
					{
						label: "企微审批单号",
						prop: "lastOaFlowCode",
						minWidth: 150,
					},
					{
						label: "企微审批状态",
						prop: "oaFlowStatus",
						minWidth: 120,
						addHtml: "oaFlowStatusHtml",
					},
					{
						label: "车主姓名",
						prop: "previousOwnerName",
					},
					{
						label: "车主联系方式",
						prop: "previousOwnerPhone",
						minWidth: 120,
					},
					{
						label: "是否拆分付款",
						prop: "splitPay",
						minWidth: 150,
						formatter: (row) => {
							return row.splitPay == 1 ? "是" : "否";
						},
					},
					{
						label: "合同来源",
						prop: "source",
						minWidth: 120,
						addHtml: "sourceHtml",
					},
					{
						label: "付款方式",
						prop: "paymentMethod",
						minWidth: 120,
						addHtml: "paymentMethodHtml",
					},
					{
						label: "签署人类型",
						prop: "signerType",
						minWidth: 120,
						addHtml: "signerTypeHtml",
					},
					{
						label: "内部主体",
						prop: "contractOrg",
						minWidth: 120,
						addHtml: "contractOrgHtml",
					},
				],
			},
			searchFormSearch: {},
			searchForm: {
				contractPrice: [],
				licensePlate: "",
				vin: "",
				carTypeName: "",
				signTime: [],
				evalOrderNo: "",
				electronicContractType: "", // 合同类型
				docTemplateType: "", // 合同模版类型
				electronicContractStatus: "", // 合同流转状态
				createdBy: "", // 驻店人员
				lastOaFlowCode: "",
				previousOwnerName: "",
				previousOwnerPhone: "",
				oaFlowStatus: "",
				splitPay: "",
				oaFlowPaymentStatus: "",
				paymentType: "",
				source: "",
				paymentMethod: "",
				signerType: "",
				contractOrg: "",
			},
			showFormData: [
				{
					label: "车牌号",
					name: "licensePlate",
					type: "input",
					isClear: true,
					maxlength: 20,
				},
				{
					label: "车架号",
					name: "vin",
					type: "input",
					isClear: true,
					maxlength: 20,
				},
				{
					label: "车型",
					name: "carTypeName",
					type: "input",
					isClear: true,
					maxlength: 20,
				},
				{
					label: "签约时间",
					name: "signTime",
					type: "datePicker",
					dateType: "datetimerange",
					isClear: true,
					defaultTime: ["00:00:00", "23:59:59"],
					pickerOptions: "todayEndPickerOptions",
				},
				{
					label: "合同类型",
					name: "electronicContractType",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "electronicContractTypeOpt",
				},
				{
					label: "合同模版",
					name: "docTemplateType",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "docTemplateTypeOpt",
				},
				{
					label: "合同流转状态",
					name: "electronicContractStatus",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "electronicContractStatusOpt",
				},
				{
					label: "驻店人员",
					name: "createdBy",
					type: "input",
					isClear: true,
					maxlength: 20,
				},
				{
					label: "支付状态",
					name: "oaFlowPaymentStatus",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "oaFlowPaymentStatusOpt",
				},
				{
					label: "支付方式",
					name: "paymentType",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "payStatusOpt",
				},
				{
					label: "企微审批单号",
					name: "lastOaFlowCode",
					type: "input",
					isClear: true,
					maxlength: 20,
				},

				{
					label: "车主姓名",
					name: "previousOwnerName",
					type: "input",
					isClear: true,
					maxlength: 20,
				},
				{
					label: "车主联系方式",
					name: "previousOwnerPhone",
					type: "input",
					isClear: true,
					maxlength: 20,
				},

				{
					label: "企微审批状态",
					name: "oaFlowStatus",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "oaFlowStatusOpt",
				},
				{
					label: "是否拆分支付",
					name: "splitPay",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "splitPayOpt",
				},
				{
					label: "合同金额",
					name: "contractPrice",
					addHtml: "contractPriceHtml",
				},
				{
					label: "评估单编号",
					name: "evalOrderNo",
					type: "input",
					isClear: true,
					maxlength: 50,
				},
				{
					label: "合同来源",
					name: "source",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "electronicContractOpt",
				},
				{
					label: "付款方式",
					name: "paymentMethod",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "paymentMethodOpt",
				},
				{
					label: "签署人类型",
					name: "signerType",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "signerTypeOpt",
				},
				{
					label: "内部主体",
					name: "contractOrg",
					type: "select",
					isClear: true,
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "contractOrgOpt",
				},
			],
			baseData: {
				electronicContractTypeOpt: deepClone(electronicContractTypeOpt),
				docTemplateTypeOpt: deepClone(docTemplateTypeOpt),
				electronicContractStatusOpt: deepClone(electronicContractStatusOpt),
				payStatusOpt: deepClone(payStatusOpt),
				oaFlowStatusOpt: deepClone(oaFlowStatusOpt),
				splitPayOpt: deepClone(splitPayOpt),
				evaluationStatusOpt: deepClone(evaluationStatusOpt),
				evaluationStatusOptMap: deepClone(evaluationStatusOptMap),
				oaFlowPaymentStatusOpt: deepClone(oaFlowPaymentStatusOpt),
				electronicContractOpt: deepClone(electronicContractOpt),
				paymentMethodOpt: deepClone(paymentMethodOpt),
				signerTypeOpt: deepClone(signerTypeOpt),
				wechatTypeOpt: deepClone(wechatTypeOpt),
				contractOrgOpt: deepClone(contractOrgOpt),
			},
			fileInfo: null,
			fileVisible: false,
			fileForm: {
				fileName: "",
			},
			fileRules: {
				fileName: [
					{
						required: true,
						message: "请上传文件",
						trigger: "blur",
					},
				],
			},
			uploadFlag: false,
			track_event_code: "contract_management",
		};
	},
	mounted() {
		this.onPageShow();
		this.getOptionsList();
		this.GlOssApi = new GlOssApi({
			baseConfig,
		});
	},
	computed: {
		...mapState({
			dowloadList: state => state.d2admin.user.dowloadList,
		}),
	},
	methods: {
		getStatusItem(baseData, optKey, row, rowKey) {
			if (!baseData || !baseData[optKey] || !row)
				return null;

			return baseData[optKey].find(
				item => item.confId == row[rowKey], // 使用严格相等
			);
		},
		...mapActions("d2admin/user", ["actionSetDownloadList"]),
		// 车辆评估
		// 详情
		handleDetail(data) {
			console.log("row", data);
			this.$router.push({
				path: "/contractView",
				query: {
					id: data.id,
				},
			});
		},
		async jumpDetail(data) {
			const res = await checkContract({
				contractNo: data.contractNo,
			});
			if (res.data.code == 0 && res.data.data !== 0) {
				console.log(res);
				this.$router.push({
					path: "/contractEdit",
					query: {
						id: data.id,
					},
				});
			} else {
				this.$message.error("暂时无法编辑");
			}
		},
		getParams() {
			const params = deepClone(this.searchForm);
			// 签约时间
			if (params?.signTime?.length) {
				const [startSignTime, endSignTime] = params.signTime;
				params.startSignTime = Util.dateFormate(
					startSignTime,
					"YYYY-MM-DD HH:mm:ss",
				);
				params.endSignTime = Util.dateFormate(
					endSignTime,
					"YYYY-MM-DD HH:mm:ss",
				);
			}
			// 合同价格
			if (params?.contractPrice?.length) {
				const [minContractPrice, maxContractPrice] = params.contractPrice;
				params.minContractPrice = minContractPrice;
				params.maxContractPrice = maxContractPrice;
			}
			delete params.contractPrice;
			delete params.signTime;
			return {
				t: params,
			};
		},
		beforeSearchFn() {
			return new Promise((resolve, reject) => {
				this.searchFormSearch = this.getParams();
				resolve();
			});
		},
		filterIds() {
			const ids = [];
			if (this.$refs.table.mutiSelectArr.mutiSelectIndex) {
				this.$refs.table.mutiSelectArr.mutiSelectIndex.forEach((item) => {
					ids.push(item.id);
				});
			}

			return ids;
		},
		// 导出
		handleExport() {
			let params = this.getParams().t;
			console.log("params", params);
			params.currentPage = 1;
			params.server_provider_type = "gsc";
			params.server_provider_name = "gsc-vcp-web-facade";
			params.idsStr = this.filterIds().join(",");
			params.method = "/evalElectronicContract/exportElectronicContractAsync";
			const list = [
				...this.dowloadList,
				{
					name: "合同管理",
					exportParam: JSON.stringify(params),
					status: "waiting",
					timeid: new Date().getTime(),
					// uuid: JSON.parse(res).data,
					// ifSuccess: false
				},
			];
			this.actionSetDownloadList({ list, type: "dowloadList" });
		},
		downloadByUrl(fileUrl) {
			// 创建一个隐藏的a标签
			const link = document.createElement("a");
			link.style.display = "none";

			// 提取文件名
			let filename = "contract.pdf";
			try {
				const url = new URL(fileUrl);
				const pathname = url.pathname;
				const pathParts = pathname.split("/");
				if (pathParts.length > 0) {
					// 获取文件名部分,去除前面的UUID
					const fullName = pathParts[pathParts.length - 1];
					if (fullName.includes("contract.pdf")) {
						filename = fullName;
					}
				}
			} catch (e) {
				console.error("解析URL失败:", e);
			}

			link.href = fileUrl;
			link.download = filename; // 明确指定下载文件名
			link.target = "_blank"; // 在新窗口打开

			// 添加到DOM,触发点击,然后移除
			document.body.appendChild(link);
			link.click();
			document.body.removeChild(link);
		},
		// 合同下载
		handleDownload(row) {
			const params = {};
			params.server_provider_type = "gsc";
			params.server_provider_name = "gsc-vcp-web-facade";
			params.method = "/evalElectronicContract/exportContractImageZipAsync";
			params.contractNo = row.contractNo;
			const list = [
				...this.dowloadList,
				{
					name: "合同下载",
					exportParam: JSON.stringify(params),
					status: "waiting",
					timeid: new Date().getTime(),
					// uuid: JSON.parse(res).data,
					// ifSuccess: false
				},
			];
			this.actionSetDownloadList({ list, type: "dowloadList" });
			// exportContractImageZipAsync({
			//   contractNo: row.contractNo
			// }).then((res) => {
			//   this.downloadByUrl(res)
			//   // Util.downLoadFile(res)
			// })
		},
		handleSearch() {
			this.page = this.$options.data.call(this).page;
			this.$refs.table.refreshTable(true, true);
		},
		handleReset() {
			this.searchForm = this.$options.data.call(this).searchForm;
			this.handleSearch();
		},

		getOptionsList() {
			this.showFormData.forEach((item, index) => {
				if (item.type === "select") {
					if (
						this.baseData[item.optionsName].length
						&& this.baseData[item.optionsName][0][
							this.showFormData[index].optionLabel
						] !== "全部"
					) {
						// if (item.optionsName != "brandList") {
						const temp = {};
						temp[this.showFormData[index].optionId] = "";
						temp[this.showFormData[index].optionLabel] = "全部";
						this.baseData[item.optionsName].unshift(temp);
						// }
					}
					this.$set(
						this.showFormData[index],
						"optionList",
						this.baseData[item.optionsName],
					);
				}
			});
		},
		// 批量导入合同
		handleImportContract() {
			this.resetFileInput();
			this.fileForm = {
				fileName: "",
			};
			this.fileVisible = true;
		},
		// 上传文件,转码为base64
		importFile(e) {
			console.log(e.target.files[0], "上传文件,转码为base64");
			this.fileForm.errorFileUrl = "";
			this.fileInfo = "";
			const size = e.target.files[0].size / 1024 / 1024;
			if (size < 10) {
				this.uploadFlag = true;
				this.$set(this.fileForm, "fileName", e.target.files[0].name);
				const success = (res) => {
					this.$refs.fileRuleForm.validateField("fileName");
					console.log(res, "上传文件成功");
					this.notice.okTips("上传文件成功");
					this.fileInfo = res.aliyunAddress;
					this.uploadFlag = false;
					this.confirmBtn();
				};
				const fail = (res) => {
					this.notice.errorTips("上传文件失败");
					this.fileForm = {
						fileName: "",
					};
					this.fileInfo = "";
					console.log(res, "上传文件失败");
					this.uploadFlag = false;
				};
				this.handleOssUpload(
					e.target.files[0],
					e.target.files[0].name,
					success,
					fail,
				);
			} else {
				this.notice.errorTips("上传文件不可超过5M");
			}
			e.target.value = "";
		},
		confirmBtn() {
			this.$refs.fileRuleForm.validate((valid) => {
				if (valid) {
					this.uploadFlag = true;
					this.fileForm.succ = 0;
					this.fileForm.fail = 0;
					importContract({
						fileUrl: this.fileInfo,
					})
						.then((res) => {
							console.log(res, "上传文件成功");
							if (res.data.code == 0) {
								this.notice.okTips();
								this.uploadFlag = false;
								this.fileForm = { ...this.fileForm, ...res.data.data };
								this.$refs.table.refreshTable();
							} else {
								this.uploadFlag = false;
								this.$message.error(res.data.msg);
							}
						})
						.catch((res) => {
							console.log(res, "上传文件失败");
							this.uploadFlag = false;
						});
				} else {
					this.uploadFlag = false;
				}
			});
		},
		handleOssUpload(file, fileName, success, fail) {
			const bucketName = "jinrong-huidan-test"; // 桶名
			const fileType = fileName.substr(fileName.lastIndexOf(".") + 1);
			this.GlOssApi.multipartUpload(file, success, fail, bucketName, fileType);
		},
		removeFile() {
			this.fileForm.fileName = null;
			this.fileInfo = null;
		},
		resetFileInput() {
			const fileInput = document.getElementById("fileUpload");
			if (fileInput) {
				fileInput.value = "";
			}
		},
		exportError(errorFileUrl) {
			errorFileUrl && window.open(errorFileUrl);
		},
		exportTemplate() {
			window.open(
				"https://jinrong-huidan-test.oss-cn-shenzhen.aliyuncs.com/template/15b20472-9d99-470d-aaff-67bcd243e0dc%E3%80%90%E6%A8%A1%E6%9D%BF%E3%80%91%E5%90%88%E5%90%8C%E5%AF%BC%E5%85%A5-V1.0.1.xlsx",
			);
		},
	},
};
</script>

<style scoped lang="scss">
.contract-wrap {
	margin-top: 53px;
}
.vehicleImgUrl-preview {
	width: 138px;
	height: 54px;
	::v-deep .photo-activity {
		width: 100%;
		height: 100%;
		object-fit: contain;
		position: static !important;
	}
}
.online-status {
	display: flex;
	justify-content: center;
	align-items: center;

	.dot {
		display: inline-block;
		width: 8px;
		height: 8px;
		border-radius: 50%;
		margin-right: 8px;
	}
}

.activity-info-container {
	padding: 0 20px;
	box-sizing: border-box;
	.activity-info {
		height: 72px;
		border-radius: 8px;
		width: 100%;
		background: #f5f7fa;
		padding: 12px 20px;
		display: flex;
		align-items: center;
		box-sizing: border-box;
		margin-bottom: 20px;
		img {
			width: 48px;
			height: 48px;
			border-radius: 4px;
			margin-right: 16px;
		}
		.activity-info-top-box {
			flex: 1;
			overflow: hidden;
			color: #333333;
			font-size: 16px;
			font-weight: 400;
			.time {
				color: #999999;
				font-size: 14px;
				font-weight: 400;
			}
		}

		.period-item {
			display: flex;
			align-items: center;
			margin-bottom: 10px;
		}

		.period-input {
			width: 300px;
			display: inline-block;
			margin-right: 10px;
		}

		.delete-btn {
			vertical-align: middle;
		}

		.add-period-btn {
			margin-top: 10px;
			display: inline-block;
		}

		/* 确保元素垂直对齐 */
		.el-input,
		.el-button {
			vertical-align: middle;
		}
	}
	.import-btn1 {
		position: relative;
	}
	.import-input {
		opacity: 0;
		position: absolute;
		right: 0;
		top: 0;
		width: 98px;
		height: 36px;
		cursor: pointer;
		font-size: 0;
	}

	.import-template {
		height: 20px;
		margin-left: 10px;
	}
	.fileName {
		width: 406px;
		height: 28px;
		border-radius: 2px;
		opacity: 1;
		background: #f5f7fa;
		color: #333333;
		font-size: 14px;
		font-weight: 400;
		padding: 4px 8px;
		box-sizing: border-box;
		line-height: 0;
		display: flex;
		align-items: center;
		margin-right: 12px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.flex {
		display: flex;
		align-items: center;
	}
	.add-box {
		margin-top: 10px;
	}
	.err-box {
		border-radius: 3px;
		opacity: 1;
		background: #feeff0;
		padding: 10px;
		box-sizing: border-box;
		margin-top: 8px;
		.err-tips {
			color: #333333;
			font-size: 12px;
			font-weight: 500;
			.el-icon-warning {
				color: #ff4d4f;
				font-size: 14px;
				margin-right: 7px;
			}
		}
		.err-list {
			padding-left: 20px;
			color: #666666;
			font-size: 12px;
			font-weight: 400;
			line-height: 20px;
		}
	}
}
::v-deep .el-dialog__header {
	border-bottom: 1px solid #e5e5e5;
}
.result-box {
	display: flex;
	justify-content: space-between;
	align-items: center;
}
</style>