Infsea.vue 41.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
·<template>
  <div class="eibs-tab">
    <c-col :span="12" style="padding-right: 20px">
      <c-col :span="24">
        <el-form-item label="参数类型" prop="rec.pratyp">
          <c-select v-model="model.rec.pratyp" dbCode="PRATYP" @change="changePratyp" style="width: 100%" placeholder="请选择参数类型"> </c-select>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <el-form-item label="优惠类型" prop="rec.rattyp">
          <c-select v-model="model.rec.rattyp" dbCode="YOHTYP" disabled style="width: 100%" placeholder="请选择优惠类型"> </c-select>
        </el-form-item>
      </c-col>
    </c-col>

    <c-col :span="12" style="padding-left: 20px" v-if="model.rec.pratyp=='2'">
      <c-col :span="24">
        <c-col :span="12">
          <el-form-item label="Party No." prop="rec.ecifno">
            <c-input v-model="model.rec.ecifno" @keyup.enter.native="showPtapDialog()" @blur="handleExtkeyBlur()" @clear="clear()" @input="extkeyInput()" style="width: 100%" placeholder="请输入Party No."> </c-input>
          </el-form-item>
        </c-col>
        <c-col :span="12">
          <el-form-item label-width="5px" prop="rec.cusnam">
            <c-input v-model="model.rec.cusnam" disabled style="width: 100%" placeholder="请输入"> </c-input>
          </el-form-item>
        </c-col>
      </c-col>
      <c-col :span="24">
        <el-form-item label="是否电子购汇签约" prop="pty.sigflg">
          <c-select v-model="model.pty.sigflg" dbCode="SIGFLG" disabled style="width: 100%" placeholder="请选择是否电子购汇签约"> </c-select>
        </el-form-item>
      </c-col>
    </c-col>

    <c-col :span="24">
      <span style="float: left">
        <el-button type="primary" size="small" @click="sefratAdd">新增</el-button>
      </span>
      <span style="float: right">
        <el-button size="small" @click="handleReset">重置</el-button>
        <el-button type="primary" icon="el-icon-search" size="small" :loading="searchLoading" @click="onSearch">查询
        </el-button>
      </span>
    </c-col>

    <c-col :span="24">
      <c-table :list="sefratData" :border="true">
        <el-table-column label="币种" prop="sefhepcur" sortable width="auto">
          <template slot-scope="scope">
            <span> {{getCodelabel(scope.row.sefhepcur,'curtxt') }}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="优惠类型" prop="sefheptyp" sortable width="auto">
          <template slot-scope="scope">
            <span> {{getCodelabel(scope.row.sefheptyp,'heptyp') }}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="优惠比例/点数" prop="sefheprat" sortable width="auto">
        </el-table-column>
        <el-table-column label="有效期起始日" prop="sefhepdatfrm" sortable width="auto">
        </el-table-column>
        <el-table-column label="有效期截止日" prop="sefhepdatend" sortable width="auto">
        </el-table-column>
        <el-table-column label="提前申请时限" prop="sefhepappday" sortable width="auto">
        </el-table-column>
        <el-table-column label="单笔限额" prop="sefheplmtamt" sortable width="auto">
        </el-table-column>
        <el-table-column label="开始时间(HH:MM:SS)" prop="sefheptimfrm" sortable width="auto">
        </el-table-column>
        <el-table-column label="结束时间(HH:MM:SS)" prop="sefheptimend" sortable width="auto">
        </el-table-column>
        <el-table-column label="操作" width="200px">
          <template slot-scope="scope">
            <el-button @click="sefratInfo(scope.$index, scope.row)" type="" size="mini">详情</el-button>
            <c-button style="margin-left: 5px" size="small" type="primary" @click="sefratEdit(scope.$index, scope.row)">修改</c-button>
            <c-button size="small" style="margin-left: 5px" @click="sefratDelete(scope.$index, scope.row)">删除</c-button>
          </template>
        </el-table-column>
      </c-table>
    </c-col>

    <el-dialog :title="
        '购汇信息:' +
        (operate === 'details' ? '详情' : operate === 'edit' ? '修改' : '新增')
      " :visible.sync="sefratDialog" top="10vh" width="80%" :destroy-on-close="true" :before-close="handleClose">
      <el-form ref="sefratForm" :model="model" :rules="rules" label-width="170px" label-position="right" :disabled="operate === 'details'">
        <c-col :span="12" style="padding-right: 20px;">
          <c-col :span="24">
            <el-form-item label="参数类型" prop="rec.pratyp">
              <c-select v-model="model.rec.pratyp" :disabled="operate === 'edit'" @change="changePratyp" dbCode="PRATYP" style="width: 100%" placeholder="请选择参数类型"> </c-select>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <el-form-item label="优惠类型" prop="rec.rattyp">
              <c-select v-model="model.rec.rattyp" dbCode="YOHTYP" disabled style="width: 100%" placeholder="请选择优惠类型"> </c-select>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <c-col :span="20">
              <el-form-item label="自助售汇提前申请时限" prop="rec.sefhepappday">
                <c-input v-model="model.rec.sefhepappday" maxlength="2" :disabled="model.rec.pratyp !='0'" style="width: 100%" placeholder="请输入请输入自助售汇提前申请时限"> </c-input>
              </el-form-item>
            </c-col>
            <c-col :span="4" v-if="model.rec.pratyp=='2'">
              <el-form-item label-width="0px" prop="rec.allowlistflg">
                <c-checkbox v-model="model.rec.allowlistflg" @change="changeAllowlistflg" :disabled="model.sigflg!='0'" style="width: 100%" true-label="X" false-label="" >白名单标识</c-checkbox>
              </el-form-item>
            </c-col>
          </c-col>
          <c-col :span="24">
            <el-form-item label="售汇交易开始时间(HH:MM:SS)" prop="rec.sefheptimfrm">
              <c-input v-model="model.rec.sefheptimfrm" maxlength="8" :disabled="model.rec.pratyp !='0' " style="width: 100%" placeholder="请输入售汇交易开始时间(HH:MM:SS)"> </c-input>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <el-form-item label="售汇交易截止时间(HH:MM:SS)" prop="rec.sefheptimend">
              <c-input v-model="model.rec.sefheptimend" maxlength="8" :disabled="model.rec.pratyp !='0' " style="width: 100%" placeholder="请输入售汇交易截止时间(HH:MM:SS)"> </c-input>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <el-form-item label="售汇单笔申请限额" prop="rec.sefheplmtamt">
              <c-input-currency v-model="model.rec.sefheplmtamt" :disabled="model.rec.pratyp !='0' " style="width: 100%" placeholder="请输入售汇单笔申请限额"> </c-input-currency>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <el-form-item label="自助售汇优惠币种" prop="rec.sefhepcur">
              <c-select v-model="model.rec.sefhepcur" :disabled="model.rec.pratyp !='0' || operate === 'edit'" dbCode="CURTXT" :isShowKeyAndLabel="true" :filterKey="['AUD','CAD','CHF','DKK','EUR','GBP','JPY','HKD','MOP','NOK','NZD','SEK','SGD','USD']" style="width: 100%" placeholder="请选择自助售汇优惠币种"> </c-select>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <el-form-item label="自助售汇优惠类型" prop="rec.sefheptyp">
              <c-select v-model="model.rec.sefheptyp" @change="changeSefheptyp" :disabled="model.rec.pratyp !='0' " dbCode="HEPTYP" style="width: 100%" placeholder="请选择自助售汇优惠类型"> </c-select>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <el-form-item label="自助售汇优惠比例/点数" prop="rec.sefheprat">
              <c-input-currency v-model="model.rec.sefheprat" :disabled="model.rec.sefheptyp=='' || operate === 'edit'" style="width: 100%" placeholder="请输入自助售汇优惠比例/点数"> </c-input-currency>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <el-form-item label="自助售汇优惠有效期起始日" prop="rec.sefhepdatfrm">
              <c-date-picker v-model="model.rec.sefhepdatfrm" :disabled="model.rec.sefheptyp=='' || operate === 'edit'" style="width: 100%" placeholder="请输入自助售汇优惠有效期起始日"> </c-date-picker>
            </el-form-item>
          </c-col>
          <c-col :span="24">
            <el-form-item label="自助售汇优惠有效期截止日" prop="rec.sefhepdatend">
              <c-date-picker v-model="model.rec.sefhepdatend" :disabled="model.rec.sefheptyp=='' || operate === 'edit'" style="width: 100%" placeholder="请输入自助售汇优惠有效期截止日"> </c-date-picker>
            </el-form-item>
          </c-col>
        </c-col>

        <c-col :span="12" style="padding-right: 20px;">
          <c-col :span="24" v-if="model.rec.pratyp=='2'">
            <c-col :span="12">
              <el-form-item label="Party No." prop="rec.ecifno">
                <c-input v-model="model.rec.ecifno" @keyup.enter.native="showPtapDialog()" @blur="handleExtkeyBlur()" @clear="clear()" @input="extkeyInput()" style="width: 100%" placeholder="请输入Party No."> </c-input>
              </el-form-item>
            </c-col>
            <c-col :span="12">
              <el-form-item label-width="5px" prop="rec.cusnam">
                <c-input v-model="model.rec.cusnam" disabled style="width: 100%" placeholder="请输入"> </c-input>
              </el-form-item>
            </c-col>
          </c-col>
          <c-col :span="24">
            <c-col :span="12">
              <el-form-item label="币种" prop="rec.sefhepcur">
                <c-select v-model="model.rec.sefhepcur" :disabled="operate === 'edit'" @change="changeSefhepcur" dbCode="CURTXT" :isShowKeyAndLabel="true" :filterKey="['AUD','CAD','CHF','DKK','EUR','GBP','JPY','HKD','MOP','NOK','NZD','SEK','SGD','USD']" style="width: 100%" placeholder="请选择币种"> </c-select>
              </el-form-item>
            </c-col>
            <c-col :span="12" v-if="model.rec.pratyp=='2'">
              <el-form-item label="是否电子购汇签约" prop="sigflg">
                <c-select v-model="model.sigflg" dbCode="SIGFLG" style="width: 100%" placeholder="请选择是否电子购汇签约"> </c-select>
              </el-form-item>
            </c-col>
          </c-col>
          <c-col :span="24" v-if="model.rec.pratyp=='0' && model.rec.sefhepcur=='USD'">
            <c-col :span="12">
              <el-form-item label="全局参数提前申请时限最小值" prop="rec.minappday">
                <c-input v-model="model.rec.minappday" maxlength="2" style="width: 100%" placeholder="请输入最小值"> </c-input>
              </el-form-item>
            </c-col>
            <c-col :span="12">
              <el-form-item label="最大值" prop="rec.maxappday">
                <c-input v-model="model.rec.maxappday" maxlength="2" style="width: 100%" placeholder="请输入最大值"> </c-input>
              </el-form-item>
            </c-col>
          </c-col>
          <c-col :span="24" v-if="model.rec.pratyp=='0' && model.rec.sefhepcur=='USD'">
            <el-form-item label="全局参数交易开始时间" prop="rec.mintim">
              <c-input v-model="model.rec.mintim" maxlength="8" style="width: 100%" placeholder="请输入全局参数交易开始时间"> </c-input>
            </el-form-item>
          </c-col>
          <c-col :span="24" v-if="model.rec.pratyp=='0' && model.rec.sefhepcur=='USD'">
            <el-form-item label="全局参数交易截止时间" prop="rec.maxtim">
              <c-input v-model="model.rec.maxtim" maxlength="8" style="width: 100%" placeholder="请输入全局参数交易截止时间"> </c-input>
            </el-form-item>
          </c-col>
          <c-col :span="24" v-if="model.rec.allowlistflg=='X' || model.rec.pratyp=='0'">
            <el-form-item label="单笔申请限额最大值" prop="rec.maxlmtamt">
              <c-input-currency v-model="model.rec.maxlmtamt" :disabled="model.rec.allowlistflg=='X'" style="width: 100%" placeholder="请输入单笔申请限额最大值"> </c-input-currency>
            </el-form-item>
          </c-col>
        </c-col>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <button class="el-button el-button--default el-button--small" style="margin-left: 0" size="small" :disabled="false" @click.prevent="cancel">
          <span>取 消</span>
        </button>
        <c-button type="primary" @click="cancel" v-if="operate === 'details'">确 定</c-button>
        <c-button type="primary" @click="editSefrat" v-if="operate === 'edit'">保 存</c-button>
        <c-button type="primary" @click="saveSefrat" v-if="operate === 'add'">保 存</c-button>
      </span>
    </el-dialog>

    <!-- 客户信息弹窗 -->
		<el-dialog title="客户信息详情" v-dialogDrag width="64%" :visible.sync="dialogTableVisible" destroy-on-close :close-on-click-modal="false" :close-on-press-escape="false" :show-close="true" v-if="dialogTableVisible" :modal-append-to-body="false" :append-to-body="true">
			<div v-if="!tableLoading && tableList.length === 0">暂无数据</div>
			<div v-else style="width: 100%;height: 100%;">
				<el-table id='tableRef' height="calc(100% - 32px)" style="width: 100%;" v-loading="tableLoading" :data="tableList" @row-dblclick="dbClickRow" :before-close="beforeClose">
					<el-table-column label="Party Number" prop="extkey" width="auto">
					</el-table-column>
					<el-table-column label="Name 1" prop="nam" width="auto">
					</el-table-column>
          <el-table-column label="Chinese Name" prop="nam1" width="auto">
					</el-table-column>
					<el-table-column label="Type" prop="ptytyp" width="auto">
					</el-table-column>
				</el-table>
				<el-pagination class="eContainer-pagination" layout="prev, pager, next, jumper, ->, sizes, total" :page-sizes="pageSizes" :page-size="pageSize" :current-page="currentPage" :total="total" @size-change="sizeChange" @current-change="currentChange"></el-pagination>
			</div>
		</el-dialog>

  </div>
</template>

<script>
import Sefrat, { Pattern } from "./Sefrat.js";
import codes from "~/config/CodeTable";
import commonFunctions from "~/mixin/commonFunctions.js";
import commonDepend from "~/mixin/commonDepend.js";
import Api from "~/service/Api";

export default {
  inject: ["root"],
  mixins: [commonFunctions, commonDepend],
  props: ["model"],
  data() {
    return {
      sefratData: [],
      searchLoading: false,
      sefratDialog: false,
      sefrat: new Sefrat().data,
      operate: "",
      operateIdx: 0,
      dialogTableVisible: false, // 控制弹框的展示和隐藏
      tableLoading: false,
      dbCodes: {
        heptyp: [],
        curtxt: [],
      },
      total: 0,
      currentPage: 1, // 页数
      pageSizes: [5, 10, 20, 30, 40, 50, 100],
      pageSize: 10, // 条数
      tableList: [],
      markExtkey: "",
      rules: {
        "rec.pratyp": [{
            required: true,message: "必输项"
          },
        ],
        "rec.ecifno": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.pratyp == "2") {
                if (!value) {
                  callback(new Error("必输项"));
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.sefhepcur": [{
            required: true,message: "必输项"
          },
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.pratyp == "2") {
                if (this.model.currat.inr == "" || this.model.currat.inr == null) {
                  callback(new Error("当前币种总行未维护参数,请联系管理员"));
                }
              }
              if(this.operate === 'add'){
                if (this.model.issefhepcurexit == "Y") {
                  if(this.model.rec.ecifno){
                    callback(new Error("该客户对应的币种" + value + "已新增过优惠参数"));
                  } else {
                    callback(new Error("该币种" + value + "已维护过优惠参数,请去维护交易进行修改"));
                  }
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.sefhepappday": [
          {
            required: true,
            message: "必输项"
          },
          {
            validator: (rule, value, callback) => {
              if (Number(value)) {
                if (
                  this.model.rec.pratyp == "0" &&
                  this.model.rec.sefhepcur == "USD"
                ) {
                  if (
                    Number(value) > Number(this.model.rec.maxappday) ||
                    Number(value) < Number(this.model.rec.minappday)
                  ) {
                    callback(
                      new Error(
                        "提前申请时限范围为" +
                          this.model.rec.minappday +
                          "-" +
                          this.model.rec.maxappday +
                          "天"
                      )
                    );
                  }
                } else {
                  if (
                    Number(value) < Number(this.model.globalrat.minappday) ||
                    Number(value) > Number(this.model.globalrat.maxappday)
                  ) {
                    callback(
                      new Error(
                        "提前申请时限范围为" +
                          this.model.globalrat.minappday +
                          "-" +
                          this.model.globalrat.maxappday +
                          "天"
                      )
                    );
                  }
                }
              } else {
                callback(new Error("必输项"));
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.sefheptimfrm": [
          {
            required: true,
            message: "必输项"
          },
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.sefheptimfrm) {
                let frmtim = this.model.rec.sefheptimfrm;
                let endtim = this.model.rec.sefheptimend;
                let HH = frmtim.slice(0,2);
                let MM = frmtim.slice(3,5);
                let SS = frmtim.slice(6,8);
                let mintim = "";
                let maxtim = "";
                if (
                  this.model.rec.pratyp == "0" &&
                  this.model.rec.sefhepcur == "USD"
                ) {
                  mintim = this.model.rec.mintim;
                  maxtim = this.model.rec.maxtim;
                } else {
                  if (
                    this.model.rec.pratyp == "2" &&
                    this.model.rec.allowlistflg == ""
                  ) {
                    mintim = this.model.currat.sefheptimfrm;
                    maxtim = this.model.currat.sefheptimend;
                  } else {
                    mintim = this.model.globalrat.mintim;
                    maxtim = this.model.globalrat.maxtim;
                  }
                }
                let minHH = mintim.slice(0,2);
                let minMM = mintim.slice(3,5);
                let minSS = mintim.slice(6,8);
                let maxHH = maxtim.slice(0,2);
                let maxMM = maxtim.slice(3,5);
                let maxSS = maxtim.slice(6,8);
                let endHH = endtim.slice(0,2);
                let endMM = endtim.slice(3,5);
                let endSS = endtim.slice(6,8);
                //输入格式校验
                if (HH > 23 || MM > 59 || SS > 59 || HH.includes(':') || MM.includes(':') || SS.includes(':') || HH.length != 2 || MM.length != 2 || SS.length != 2) {
                  callback(new Error("输入格式应为HH:MM:SS,输入不合法"));
                } else {
                  //最大时间限制校验
                  let timerr = 0;
                  if (HH > maxHH) {
                    callback(new Error("起止时间为:" + mintim + "-" + maxtim));
                    timerr = 1;
                  } else {
                    if (HH == maxHH && MM > maxMM) {
                      callback(
                        new Error("起止时间为:" + mintim + "-" + maxtim)
                      );
                      timerr = 1;
                    } else {
                      if (HH == maxHH && MM == maxMM && SS > maxSS) {
                        callback(
                          new Error("起止时间为:" + mintim + "-" + maxtim)
                        );
                        timerr = 1;
                      }
                    }
                  }
                  //最小时间限制校验
                  if (HH < minHH) {
                    callback(new Error("起止时间为:" + mintim + "-" + maxtim));
                    timerr = 1;
                  } else {
                    if (HH == minHH && MM < minMM) {
                      callback(
                        new Error("起止时间为:" + mintim + "-" + maxtim)
                      );
                      timerr = 1;
                    } else {
                      if (HH == minHH && MM == minMM && SS < minSS) {
                        callback(
                          new Error("起止时间为:" + mintim + "-" + maxtim)
                        );
                        timerr = 1;
                      }
                    }
                  }
                  //大于截止时间校验
                  if (this.model.rec.sefheptimend) {
                    if (timerr == 0) {
                      if (HH > endHH) {
                        callback(new Error("开始时间不能大于结束时间"));
                      } else {
                        if (HH == endHH && MM > endMM) {
                          callback(new Error("开始时间不能大于结束时间"));
                        } else {
                          if (HH == endHH && MM == endMM && SS > endSS) {
                            callback(new Error("开始时间不能大于结束时间"));
                          }
                        }
                      }
                    }
                  }
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.sefheptimend": [
          {
            required: true,
            message: "必输项"
          },
          {
            validator: (rule, value, callback) => {
              if (value) {
                let endtim = value;
                let HH = endtim.slice(0,2);
                let MM = endtim.slice(3,5);
                let SS = endtim.slice(6,8);
                let mintim = "";
                let maxtim = "";
                if (
                  this.model.rec.pratyp == "0" &&
                  this.model.rec.sefhepcur == "USD"
                ) {
                  mintim = this.model.rec.mintim;
                  maxtim = this.model.rec.maxtim;
                } else {
                  if (
                    this.model.rec.pratyp == "2" &&
                    this.model.rec.allowlistflg == ""
                  ) {
                    mintim = this.model.currat.sefheptimfrm;
                    maxtim = this.model.currat.sefheptimend;
                  } else {
                    mintim = this.model.globalrat.mintim;
                    maxtim = this.model.globalrat.maxtim;
                  }
                }
                let minHH = mintim.slice(0,2);
                let minMM = mintim.slice(3,5);
                let minSS = mintim.slice(6,8);
                let maxHH = maxtim.slice(0,2);
                let maxMM = maxtim.slice(3,5);
                let maxSS = maxtim.slice(6,8);
                //输入格式校验
                if (HH > 23 || MM > 59 || SS > 59 || HH.includes(':') || MM.includes(':') || SS.includes(':') || HH.length != 2 || MM.length != 2 || SS.length != 2) {
                  callback(new Error("输入格式应为HH:MM:SS,输入不合法"));
                } else {
                  //最大时间限制校验
                  if (HH > maxHH) {
                    callback(new Error("起止时间为:" + mintim + "-" + maxtim));
                  } else {
                    if (HH == maxHH && MM > maxMM) {
                      callback(
                        new Error("起止时间为:" + mintim + "-" + maxtim)
                      );
                    } else {
                      if (HH == maxHH && MM == maxMM && SS > maxSS) {
                        callback(
                          new Error("起止时间为:" + mintim + "-" + maxtim)
                        );
                      }
                    }
                  }
                  //最小时间限制校验
                  if (HH < minHH) {
                    callback(new Error("起止时间为:" + mintim + "-" + maxtim));
                  } else {
                    if (HH == minHH && MM < minMM) {
                      callback(
                        new Error("起止时间为:" + mintim + "-" + maxtim)
                      );
                    } else {
                      if (HH == minHH && MM == minMM && SS < minSS) {
                        callback(
                          new Error("起止时间为:" + mintim + "-" + maxtim)
                        );
                      }
                    }
                  }
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.sefheplmtamt": [
          {
            required: true,
            message: "必输项"
          },
          {
            validator: (rule, value, callback) => {
              if (Number(value)) {
                let cur = this.model.rec.sefhepcur;
                if (this.model.rec.pratyp == "0") {
                  if (Number(value) > Number(this.model.rec.maxlmtamt)) {
                    callback(
                      new Error(
                        "单笔限额必须小于等于总行设置最大值(" +
                          cur +
                          ")" +
                          this.model.rec.maxlmtamt
                      )
                    );
                  }
                } else {
                  if (this.model.rec.allowlistflg == "X") {
                    if (Number(value) > Number(this.model.currat.maxlmtamt)) {
                      callback(
                        new Error(
                          "白名单客户单笔限额必须小于等于总行设置最大值(" +
                            cur +
                            ")" +
                            this.model.currat.maxlmtamt
                        )
                      );
                    }
                  } else {
                    if (Number(value) > Number(this.model.currat.maxlmtamt)) {
                      callback(
                        new Error(
                          "非白名单,应小于等于总行设置的单笔限额(" +
                            cur +
                            ")" +
                            this.model.currat.maxlmtamt
                        )
                      );
                    }
                  }
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.sefhepdatend": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.sefheptyp) {
                if (!value) {
                  callback(new Error("必输项"));
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.sefhepdatend": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.sefheptyp) {
                if (!value) {
                  callback(new Error("必输项"));
                } else {
                  if (value < this.model.rec.sefhepdatfrm) {
                    callback(new Error("有效期截至日不能早于起始日"));
                  } else {
                    if (new Date(value) < new Date()) {
                      callback(new Error("有效期截止日不能早于当日"));
                    }
                  }
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.sefheprat": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.sefheptyp) {
                if (!Number(value)) {
                  callback(new Error("必输项"));
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.minappday": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.pratyp == '0' && this.model.rec.sefhepcur == 'USD') {
                if (!Number(value)) {
                  callback(new Error("必输项"));
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.maxappday": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.pratyp == '0' && this.model.rec.sefhepcur == 'USD') {
                if (!Number(value)) {
                  callback(new Error("必输项"));
                } else if(Number(value) > 22){
                  callback(new Error("最大时限不能超过22天"));
                }
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.mintim": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.pratyp == '0' && this.model.rec.sefhepcur == 'USD') {
                if (!value) {
                  callback(new Error("必输项"));
                } 
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.maxtim": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.pratyp == '0' && this.model.rec.sefhepcur == 'USD') {
                if (!value) {
                  callback(new Error("必输项"));
                } 
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
        "rec.maxlmtamt": [
          {
            validator: (rule, value, callback) => {
              if (this.model.rec.pratyp == '0') {
                if (!Number(value)) {
                  callback(new Error("必输项"));
                } 
              }
              callback();
            },
            trigger: ["blur"]
          }
        ],
      },
    };
  },
  computed: {},
  created() {},
  watch: {},
  mounted() {
    this.getdbCode("heptyp", "CN", "heptyp");
    this.getdbCode("curtxt", "CN", "curtxt");
  },
  methods: {
    getCodelabel(value, codenam) {
      const codeobj = this.dbCodes[codenam].find(obj => obj.value === value);
      return codeobj ? codeobj.label : value;
    },

    async getdbCode(codeType, uil, codeNam) {
      let params = {
        codeType: codeType,
        uil: uil ? uil : "EN"
      };
      let rtnmsg = await Api.post("/manager/dic/listDicInfo", params);
      if (rtnmsg.respCode === SUCCESS) {
        let curList = rtnmsg.data.map(item => ({
          value: item.codeValue,
          label: item.codeName
        }));
        this.dbCodes[codeNam] = curList;
      }
    },

    changePratyp() {
      this.sefratData = [];
      if(this.model.rec.pratyp == '0'){
        this.model.rec.ecifno = "";
        this.model.rec.cusnam = "";
        this.model.pty.sigflg = "";
        this.model.sigflg = "";
        this.model.rec.ptyinr = "";
      }
      if(this.model.rec.pratyp == '2'){
        this.model.rec.sefhepcur = "";
        this.model.rec.sefhepappday = '0';
        this.model.rec.sefheptimfrm = "";
        this.model.rec.sefhepdatend = "";
        this.model.rec.sefheptimend = "";
        this.model.rec.sefheptyp = "";
        this.model.rec.sefheprat = "";
        this.model.rec.sefhepdatfrm = "";
        this.model.rec.sefhepdatend = "";
      }
    },
    //重置
    handleReset() {
      this.model.rec.pratyp = "";
      this.model.rec.ecifno = "";
      this.model.rec.cusnam = "";
      this.model.pty.sigflg = "";
    },

    async onSearch() {
      if(!this.model.rec.pratyp){
        this.$notify.error({ title: '错误', message: '请先选择参数类型' });
        return;
      } else if(this.model.rec.pratyp == '2'){
        if(!this.model.rec.ecifno){
          this.$notify.error({ title: '错误', message: 'Party No.必输' });
          return;
        }
      }
      this.searchLoading = true;
      let rtnmsg = await Api.post("/manager/exr/querySefratlst", this.model);
      if (rtnmsg.respCode == "AAAAAA") {
        this.sefratData = rtnmsg.data.sefratlst;
        this.model.rec.ptyinr = rtnmsg.data.rec.ptyinr;
        this.model.globalrat = rtnmsg.data.globalrat;
        this.searchLoading = false;
      } else {
        this.$notify.error("未查询到购汇汇率信息");
      }
      this.searchLoading = false;
    },

    sefratAdd() {
      this.model.rec.sefhepcur = "";
      this.model.rec.allowlistflg = "";
      this.model.rec.sefheptimfrm = "";
      this.model.rec.sefheptimend = "";
      this.model.rec.sefheplmtamt = "";
      this.model.rec.sefheptyp = "";
      this.model.rec.sefheprat = "";
      this.model.rec.sefhepdatfrm = "";
      this.model.rec.sefhepdatend = "";
      this.model.rec.mintim = "";
      this.model.rec.maxtim = "";
      this.model.rec.maxlmtamt = "";
      this.operate = "add";
      this.sefratDialog = true;
    },

    //新增保存
    async saveSefrat() {
      this.$refs.sefratForm.validate(async validated => {
        if (validated) {
          if(this.model.rec.pratyp == '2'){
            this.model.pty.inr = this.model.rec.ptyinr;
            this.model.rec.maxlmtamt = "";
            this.model.pty.sigflg = this.model.sigflg;
          }
          let rtnmsg = await Api.post("/manager/exr/saveSefrat", this.model);
          if (rtnmsg.respCode == "AAAAAA") {
            this.$notify.success("新建成功");
            this.handleClose();
            this.onSearch();
          } else {
            this.$notify.error("新建失败");
            this.handleClose();
          }
        }
      });
    },

    //详情
    async sefratInfo(index, row) {
      this.model.rec = { ...row };
      this.model.sigflg = this.model.pty.sigflg;
      await this.getCurrat(this.model.rec.sefhepcur);
      this.model.rec.maxlmtamt = this.model.currat.maxlmtamt;
      this.operate = "details";
      this.operateIdx = index;
      this.sefratDialog = true;
    },

    //修改
    async sefratEdit(index, row) {
      this.model.issefhepcurexit = "N";
      this.model.rec = { ...row };
      this.model.sigflg = this.model.pty.sigflg;
      await this.getCurrat(this.model.rec.sefhepcur);
      this.model.rec.maxlmtamt = this.model.currat.maxlmtamt;
      this.operate = "edit";
      this.operateIdx = index;
      this.sefratDialog = true;
    },

    //修改保存
    async editSefrat() {
      this.$refs.sefratForm.validate(async validated => {
        if (validated) {
          if(this.model.rec.pratyp == '2'){
            this.model.pty.inr = this.model.rec.ptyinr;
            this.model.rec.maxlmtamt = "";
            this.model.pty.sigflg = this.model.sigflg;
          }
          let rtnmsg = await Api.post("/manager/exr/editSefrat", this.model);
          if (rtnmsg.respCode == "AAAAAA") {
            this.$notify.success("修改成功");
            this.handleClose();
            this.onSearch();
          } else {
            this.$notify.error("新建失败");
            this.handleClose();
          }
        }
      });
    },

    //删除
    async sefratDelete(index, row) {
      this.$confirm("是否确认删除?", "提示", {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: "warning"
      }).then(async (res) => {
        this.model.rec = { ...row };
        let rtnmsg = await Api.post("/manager/exr/sefratDelete", this.model);
        if (rtnmsg.respCode == SUCCESS) {
          this.$notify.success("删除成功!");
          this.onSearch();
        } else {
          this.$notify.error("删除失败!");
        }
      }).catch((action) => {
        this.$message({
          type: "info",
          message: "已取消删除"
        });
      });
    },

    //切换币种
    async changeSefhepcur() {
      this.model.issefhepcurexit = "N";
      let rtnmsg = await Api.post("/manager/exr/changeSefhepcur", this.model);
      if (rtnmsg.respCode === SUCCESS) {
        if(this.model.rec.pratyp == '0'){
          this.model.issefhepcurexit = rtnmsg.data.issefhepcurexit;
          this.model.globalrat = rtnmsg.data.globalrat;
        } else if(this.model.rec.pratyp == '2'){
          this.model.rec.sefheptimfrm = rtnmsg.data.rec.sefheptimfrm
          this.model.rec.sefheptimend = rtnmsg.data.rec.sefheptimend
          this.model.rec.sefhepappday = rtnmsg.data.rec.sefhepappday
          this.model.rec.sefheplmtamt = rtnmsg.data.rec.sefheplmtamt
          this.model.rec.maxlmtamt = rtnmsg.data.currat.maxlmtamt;
          this.model.currat = rtnmsg.data.currat;
          this.model.ptyrat = rtnmsg.data.ptyrat;
          this.model.globalrat = rtnmsg.data.globalrat;
          this.model.issefhepcurexit = rtnmsg.data.issefhepcurexit;
        }
      }
    },

    changeAllowlistflg() {
      this.changeSefhepcur();
    },

    //查询总行全局参数
    async getCurrat(data) {
      let params = {
        rec: {
          sefhepcur: data
        }
      };
      let rtnmsg = await Api.post("/manager/exr/getCurrat", params);
      if (rtnmsg.respCode === SUCCESS) {
        this.model.currat = rtnmsg.data.currat;
      }
    },

    //切换优惠类型
    changeSefheptyp() {
      if (this.model.rec.sefheptyp === "") {
        this.model.rec.sefheprat = "";
        this.model.rec.sefhepdatfrm = "";
        this.model.rec.sefhepdatend = "";
      }
    },

    cancel() {
      this.handleClose();
    },
    handleClose(done) {
      this.sefratDialog = false;
      if (done && typeof done === "function") {
        done();
      }
    },

    // extkey输入框失焦
    handleExtkeyBlur(e) {
      let extkey = this.model.rec.ecifno;
      if (extkey && extkey !== this.markExtkey) {
        this.showPtapDialog();
      }
    },

    // 弹框
    async showPtapDialog() {
      if (this.tableLoading || this.dialogTableVisible) {
        return;
      }
      const value = this.model.rec.ecifno;
      // 分层取值
      await this.getTableData(value);
      if (this.total == 1) {
        this.dbClickRow(this.tableList[0]);
      } else {
        // 设置弹框标题
        this.dialogTableVisible = true;
        this.$nextTick(() => {
          this.root.$refs["modelForm"].validateField([`rec.ecifno`]);
        });
      }
    },

    // 获取弹框内的table数据
    async getTableData(value) {
      return new Promise(async resolve => {
        this.tableLoading = true;
        this.tableList = [];
        // 获取table的表格数据
        let params = {
          extkey: value || "",
          bchbranch: JSON.parse(window.sessionStorage.accbch).branch,
          pageNum: this.currentPage,
          pageSize: this.pageSize
        };
        const loading = this.loading();
        const res = await Api.post("/manager/exr/querySefratInfoByExtkey", params);
        loading.close();
        if (res.respCode == SUCCESS) {
          if (res.data && res.data.list) {
            this.total = res.data.total;
            this.tableList = res.data.list;
            resolve(this.tableList);
          }
        }
        this.tableLoading = false; //接口掉完变成false
      });
    },

    async dbClickRow(row, column, event) {
      this.markExtkey = row.extkey;
      this.model.rec.ecifno = row.extkey;
      this.model.rec.cusnam = row.nam;
      this.model.rec.ptyinr = row.inr;
      this.model.pty.sigflg = row.sigflg;
      this.model.sigflg = row.sigflg;
      this.$nextTick(() => {
        this.root.$refs["modelForm"].validateField([`rec.ecifno`]);
      });
      this.dialogTableVisible = false;
      this.changeSefhepcur();
    },

    //extkey清空时
    extkeyInput() {
      if (!this.model.rec.ecifno) {
        this.model.rec.cusnam = "";
        this.markExtkey = "";
        this.clear();
      }
    },

    // 清除
    clear() {
      this.$emit("clear");
      this.$nextTick(() => {
        this.root.$refs["modelForm"].validateField([`rec.ecifno`]);
      });
    },

    beforeClose(done) {
      this.dialogTableVisible = false;
      this.currentPage = 1;
      done();
    },

    sizeChange(num) {
      this.pageSize = num;
      const value = this.model.rec.ecifno;
      this.getTableData(value);
    },

    currentChange(num) {
      this.currentPage = num;
      const value = this.model.rec.ecifno;
      this.getTableData(value);
    },
  }
};
</script>

<style scoped>
</style>