contract.vue 58.2 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 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563
<template>
  <div>
    <!-- 合同基本信息开始~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <el-row>
      <el-col :span="22">
        <h1 @click="contract_show =!contract_show">销售合同信息</h1>
      </el-col>
      <el-col :span="2">
        <h1 class="h-button" @click="form_submit('form')">提交</h1>
      </el-col>
    </el-row>
    <transition name="el-fade-in-linear">
      <el-form id="form" :inline="true" :model="form" class="demo-form-inline" label-width="100px" :rules="add_rules" v-show="contract_show">
        <el-row>
          <el-col :span="8">
            <el-form-item label="合同编号">
              <el-select class="width-220" v-model="form.contract_unid" filterable remote reserve-keyword placeholder="合同编号" :remote-method="contractIdRemoteMethod">
                <el-option v-for="(item,index) in contract_unid_selected_data" :key="index" :label="item.name" :value="item.country_unid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="销售员">
              <el-select class="width-220" v-model="form.salesperson_unid" filterable remote placeholder="销售人员" :remote-method="salespersonIdRemoteMethod">
                <el-option v-for="(item,index) in salesperson_unid_selected_data" :key="index" :label="item.name" :value="item.code_unid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="项目名称">
              <el-select class="width-220" v-model="form.project_unid" filterable remote placeholder="项目名称" :remote-method="projectIdRemoteMethod">
                <el-option v-for="(item,index) in project_unid_selected_data" :key="index" :label="item.name" :value="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="客户名称">
              <el-select class="width-220" v-model="form.customer_unid" filterable remote placeholder="客户名称" :remote-method="customerIdRemoteMethod">
                <el-option v-for="(item,index) in customer_unid_selected_data" :key="index" :label="item.name" :value="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="项目所在地">
              <el-select style="width:100px" v-model="form.province" placeholder="省" @change="get_cities()">
                <el-option v-for="(item,index) in provinces" :key="index" :label="item.name" :value="item.province_unid">
                </el-option>
              </el-select>
              <el-select style="width:100px" v-model="form.city" placeholder="市" @change="get_counties()">
                <el-option v-for="(item,index) in cities" :key="index" :label="item.name" :value="item.city_unid">
                </el-option>
              </el-select>
              <el-select style="width:100px" v-model="form.county" placeholder="区县">
                <el-option v-for="(item,index) in counties" :key="index" :label="item.name" :value="item.county_unid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="质保周期(月)">
              <el-input-number class="width-220" v-model="form.guarantee_period" :step="6" :min="6" :max="60" size="medium"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="签订日期">
              <el-date-picker class="width-220" v-model="form.sign_date" type="date" placeholder="日期" value-format="yyyy-MM-dd" @change="signDataChanged">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所属年份">
              <el-input class="width-220" v-model="form.year" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所属月份">
              <el-input class="width-220" v-model="form.month" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="产品线类型">
              <el-select class="width-220" v-model="form.product_line_type" placeholder="产品线类型">
                <el-option v-for="(value,index) in projectline_type_data" :key="index" :label="value" :value="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合同状态">
              <el-select class="width-220" v-model="form.contract_state" placeholder="合同状态">
                <el-option v-for="(value,index) in contract_state_data" :key="index" :label="value" :value="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合同性质">
              <el-select class="width-220" v-model="form.contract_type" placeholder="合同性质">
                <el-option v-for="(value,index) in contract_type_data" :key="index" :label="value" :value="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="合同金额" prop="contract_amount">
              <el-input class="width-220" v-model="form.contract_amount"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="抵扣金额" prop="deduct_amount">
              <el-input class="width-220" v-model="form.deduct_amount"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="备注">
              <el-input class="width-220" v-model="form.contract_amount_note"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="累计回款额">
              <el-input class="width-220" v-model="total_reback_amount" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="暂停金额" prop="stop_amount">
              <el-input class="width-220" v-model="form.stop_amount"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="备注">
              <el-input class="width-220" v-model="form.reback_note"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="合同余额">
              <el-input class="width-220" v-model="contract_remaining" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="豁免金额" prop="exemptions_amount">
              <el-input class="width-220" v-model="form.exemptions_amount"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="备注">
              <el-input class="width-220" v-model="form.contract_remain_note"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="合同是否归档">
              <el-select class="width-220" v-model="form.is_archive" placeholder="请选择">
                <el-option label="是" value=true></el-option>
                <el-option label="否" value=false></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="坏账金额" prop="bad_amount">
              <el-input class="width-220" v-model="form.bad_amount"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="备注">
              <el-input class="width-220" v-model="form.bad_amount_note"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="累计应收款">
              <el-input class="width-220" v-model="total_receive_amount" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="应收账款余额">
              <el-input class="width-220" v-model="total_leave_amount" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="逾期天数">
              <el-input class="width-220" v-model="over_days_unid" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="确认收入金额" prop="confirm_income_amount">
              <el-input class="width-220" v-model="form.confirm_income_amount"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="账款状态">
              <el-select class="width-220" v-model="form.amount_state_unid" placeholder="账款状态">
                <el-option v-for="(value,index) in amount_state_unid_data" :key="index" :label="value" :value="index">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="9">
            <el-form-item label="维保服务期">
              <el-date-picker v-model="guarantee_date" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :unlink-panels="true">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="19">
            <el-form-item label="质保期">
              <el-select class="width-220" v-model="form.mainten_start_point" placeholder="开始节点">
                <el-option v-for="(value,index) in mainten_start_point_data" :key="index" :label="value" :value="index">
                </el-option>
              </el-select>
              <el-date-picker class="width-220" v-model="this.mainten_start_date" type="date" placeholder="开始日期" value-format="yyyy-MM-dd" :readonly="true">
              </el-date-picker>
              <el-date-picker class="width-220" v-model="this.mainten_end_date" type="date" placeholder="结束日期" value-format="yyyy-MM-dd" :readonly="true">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="备注">
              <el-input v-model="form.contract_note" type="textarea" :rows="8" style="width:500px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-upload class="upload-demo" drag :action="upload_url" multiple :file-list="contract_appendix_list" :before-upload="test">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处,或点击上传</div>
            </el-upload>
          </el-col>
        </el-row>
      </el-form>
    </transition>

    <!-- 基本信息结束~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- 付款约定开始~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <el-row>
      <el-col :span="22">
        <h1 @click="payments_show = !payments_show">付款约定</h1>
      </el-col>
      <el-col :span="2">
        <h1 class="h-button" @click="form_submit('payment')">提交</h1>
      </el-col>
    </el-row>
    <transition name="el-fade-in-linear">
      <div id="payments_data_table" v-show="payments_show">
        <el-table :data="payments_data" style="width: 100%">
          <el-table-column prop="payment_progress" label="付款进度" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="payment_type" label="付款类型" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="days" label="天数" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="payment_propority" label="付款比例(%)" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="pay_date" label="本期应付款日期" min-width="200" align="center">
          </el-table-column>
          <el-table-column prop="amount" label="本期应付款金额" min-width="200" align="center">
          </el-table-column>
          <el-table-column prop="payment_requirement" label="本期付款条件" min-width="300" align="center">
          </el-table-column>
          <el-table-column label="操作" min-width="200" align="center" fixed="right">
            <template slot-scope="scope">
              <el-button @click.native.prevent="payment_data_modify(scope.$index, payments_data)" type="primary" round>
                修改
              </el-button>
              <el-button @click.native.prevent="data_delete(scope.$index, payments_data)" type="danger" round>
                移除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-button class="add_button" type="text" @click="payments_dialog_show = true">添加付款约定</el-button>
        </el-row>
      </div>
    </transition>

    <!-- 付款约定弹出框 -->

    <el-dialog id="payments_dialog" title="付款约定" :visible.sync="payments_dialog_show" width="30%">
      <el-form :model="payments_form" label-width="150px" label-position="left" :rules="add_rules" ref="payments_form">
        <el-form-item label="付款类型" prop="payment_type">
          <el-select v-model="payments_form.payment_type" placeholder="付款类型" style="width:100%">
            <el-option label="预付款" value="1">
            </el-option>
            <el-option label="到货款" value="2">
            </el-option>
            <el-option label="系统验收款" value="3">
            </el-option>
            <el-option label="质保款(发货节点计算)" value="4">
            </el-option>
            </el-option>
            <el-option label="质保款(验收节点计算)" value="5">
            </el-option>
          </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="天数" prop="days">
          <el-input v-model="payments_form.days" placeholder="请输入天数" style="width:100%"></el-input>
        </el-form-item>
        <el-form-item label="付款比例" prop="payment_propority">
          <el-input-number v-model="payments_form.payment_propority" :step="5" :min="0" :max="100" style="width:100%"></el-input-number>
        </el-form-item>
        <el-form-item label="条件" prop="payment_requirement">
          <el-input v-model="payments_form.payment_requirement" type="textarea" :rows="2" style="width:100%"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="payments_dialog_cancel()">取 消</el-button>
        <el-button type="primary" @click="payments_dialog_confirm()">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 付款约定结束~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- 合同回款信息开始~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <el-row>
      <el-col :span="22">
        <h1 @click="rebacks_show = !rebacks_show">合同回款信息(财务部)</h1>
      </el-col>
      <el-col :span="2">
        <h1 class="h-button" @click="form_submit('reback')">提交</h1>
      </el-col>
    </el-row>

    <transition name="el-fade-in-linear">
      <div id="rebacks_data_table" v-show="rebacks_show">
        <el-table :data="rebacks_data" style="width:100%">
          <el-table-column prop="reback_progress" label="回款进度" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="actual_reback_amount" label="实际回款金额" min-width="200" align="center">
          </el-table-column>
          <el-table-column prop="reback_propority" label="回款比例(%)" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="reback_date" label="回款日期" min-width="200" align="center">
          </el-table-column>
          <el-table-column prop="reback_note" label="回款备注" min-width="300" align="center">
          </el-table-column>
          <el-table-column label="操作" min-width="200" align="center" fixed="right">
            <template slot-scope="scope">
              <el-button @click.native.prevent="reback_data_modify(scope.$index, rebacks_data)" type="primary" round>
                修改
              </el-button>
              <el-button @click.native.prevent="data_delete(scope.$index, rebacks_data)" type="danger" round>
                移除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-button class="add_button" type="text" @click="rebacks_dialog_show = true">添加合同回款信息</el-button>
        </el-row>
      </div>
    </transition>
    <!-- 合同回款信息弹出框 -->

    <el-dialog id="rebacks_dialog" title="回款信息" :visible.sync="rebacks_dialog_show" width="30%">
      <el-form :model="rebacks_form" label-width="150px" label-position="left" :rules="rebacks_form_rules" ref="rebacks_form">
        <el-form-item label="实际回款金额" prop="actual_reback_amount">
          <el-input v-model="rebacks_form.actual_reback_amount" placeholder="请输入金额" style="width:100%"></el-input>
        </el-form-item>
        <el-form-item label="回款日期" prop="reback_date">
          <el-date-picker style="width:100%" v-model="rebacks_form.reback_date" type="date" value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="reback_note">
          <el-input v-model="rebacks_form.reback_note" placeholder="备注" style="width:100%" type="textarea" :rows="2"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="rebacks_dialog_cancel()">取 消</el-button>
        <el-button type="primary" @click="rebacks_dialog_confirm()">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 合同回款信息结束~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- 合同开票信息开始~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <el-row>
      <el-col :span="22">
        <h1 @click="receipts_show = !receipts_show">合同开票信息(财务部)</h1>
      </el-col>
      <el-col :span="2">
        <h1 class="h-button" @click="form_submit('receipt')">提交</h1>
      </el-col>
    </el-row>

    <transition name="el-fade-in-linear">
      <div id="receipts_data_table" v-show="receipts_show">
        <el-table :data="receipts_data" style="width: 100%">
          <el-table-column prop="receipt_progress" label="开票进度" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="receipt_amount" label="开票金额" min-width="150" align="center">
          </el-table-column>
          <el-table-column prop="oa_flow_id" label="OA流水号" min-width="150" align="center">
          </el-table-column>
          <el-table-column prop="receipt_propority" label="开票比例(%)" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="total_receipt_amount" label="累计开票金额" min-width="200" align="center">
          </el-table-column>
          <el-table-column prop="is_reback" label="是否回款" min-width="100" align="center">
          </el-table-column>
          <el-table-column prop="receipt_note" label="备注" min-width="300" align="center">
          </el-table-column>
          <el-table-column label="操作" min-width="200" align="center" fixed="right">
            <template slot-scope="scope">
              <el-button @click.native.prevent="receipt_data_modify(scope.$index, receipts_data)" type="primary" round>
                修改
              </el-button>
              <el-button @click.native.prevent="data_delete(scope.$index, receipts_data)" type="danger" round>
                移除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-button class="add_button" type="text" @click="receipts_dialog_show = true">添加开票信息</el-button>
        </el-row>
      </div>
    </transition>
    <!-- 开票信息弹出框 -->

    <el-dialog id="receipts_dialog" title="开票合同" :visible.sync="receipts_dialog_show" width="30%">
      <el-form :model="receipts_form" label-width="150px" label-position="left" :rules="receipts_form_rules" ref="receipts_form">
        <el-form-item label="开票金额" prop="receipt_amount">
          <el-input v-model="receipts_form.receipt_amount" placeholder="请输入金额" style="width:100%"></el-input>
        </el-form-item>
        <el-form-item label="OA流水号" prop="oa_flow_id">
          <el-input v-model="receipts_form.oa_flow_id" placeholder="请输入流水号" style="width:100%"></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="receipt_note">
          <el-input v-model="receipts_form.receipt_note" placeholder="备注" style="width:100%" type="textarea" :rows="2"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="receipts_dialog_cancel()">取 消</el-button>
        <el-button type="primary" @click="receipts_dialog_confirm()">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 合同开票信息结束~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- 发货信息开始~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <el-row>
      <el-col :span="22">
        <h1 @click="delivers_show = !delivers_show">发货信息(生产部)</h1>
      </el-col>
      <el-col :span="2">
        <h1 class="h-button" @click="form_submit('deliver')">提交</h1>
      </el-col>
    </el-row>

    <transition name="el-fade-in-linear">
      <div id="delivers_data_table" v-show="delivers_show">
        <el-table :data="delivers_data" style="width: 100%">
          <el-table-column prop="deliver_goods_date" label="发货日期" width="300" align="center">
          </el-table-column>
          <el-table-column prop="goods_acceptanc_date" label="到货验收日期" width="300" align="center">
          </el-table-column>
          <el-table-column label="操作" min-width="100" align="center" fixed="right">
            <template slot-scope="scope">
              <el-button @click.native.prevent="deliver_data_modify(scope.$index, delivers_data)" type="primary" round>
                修改
              </el-button>
              <el-button @click.native.prevent="data_delete(scope.$index, delivers_data)" type="danger" round>
                移除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-button class="add_button" type="text" @click="delivers_dialog_show = true">添加发货信息</el-button>
        </el-row>
      </div>
    </transition>
    <!-- 发货信息信息弹出框 -->

    <el-dialog id="delivers_dialog" title="发货信息" :visible.sync="delivers_dialog_show" width="30%">
      <el-form :model="delivers_form" label-width="150px" label-position="left" :rules="add_rules" ref="delivers_form">
        <el-form-item label="发货日期" prop="deliver_goods_date">
          <el-date-picker style="width:100%" v-model="delivers_form.deliver_goods_date" type="date" value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="到货验收日期" prop="goods_acceptanc_date">
          <el-date-picker style="width:100%" v-model="delivers_form.goods_acceptanc_date" type="date" value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          此处需要上传附件
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="delivers_dialog_cancel()">取 消</el-button>
        <el-button type="primary" @click="delivers_dialog_confirm()">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 发货信息结束~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- 工程验收信息开始~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <el-row>
      <el-col :span="22">
        <h1 @click="acceptance_show = !acceptance_show">工程验收信息(工程部)</h1>
      </el-col>
      <el-col :span="2">
        <h1 class="h-button" @click="form_submit('project')">提交</h1>
      </el-col>
    </el-row>

    <transition name="el-fade-in-linear">
      <div id="acceptance_form" v-show="acceptance_show">
        <el-form :inline="true" :model="first_acceptances_form" class="demo-form-inline" label-width="100px" :rules="acceptance_form_rules" ref="first_acceptances_form">
          <el-row>
            <el-col :span="8">
              <el-tooltip class="item" effect="dark" content="填写初验必须填写终验" placement="top">
                <el-form-item label="是否初验" prop="acceptance_type">
                  <el-select class="width-220" v-model="first_acceptances_form.acceptance_type">
                    <el-option label="是" value="1">
                    </el-option>
                    <el-option label="否" value="">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-tooltip>
            </el-col>
            <el-col :span="8">
              <el-form-item label="项目验收日期" prop="acceptance_date">
                <el-date-picker class="width-220" v-model="first_acceptances_form.acceptance_date" type="date" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="备注">
                <el-input class="width-220" v-model="first_acceptances_form.acceptance_note" placeholder="备注"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            此处需要上传附件
          </el-row>
        </el-form>
        <el-form :inline="true" :model="final_acceptances_form" class="demo-form-inline" label-width="100px" :rules="acceptance_form_rules2" ref="final_acceptances_form">
          <el-row>
            <el-col :span="8">
              <el-tooltip class="item" effect="dark" content="填写初验必须填写终验" placement="top">
                <el-form-item label="是否终验" prop="acceptance_type">
                  <el-select class="width-220" v-model="final_acceptances_form.acceptance_type">
                    <el-option label="是" value="2">
                    </el-option>
                    <el-option label="否" value="">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-tooltip>
            </el-col>
            <el-col :span="8">
              <el-form-item label="项目验收日期" prop="acceptance_date">
                <el-date-picker class="width-220" v-model="final_acceptances_form.acceptance_date" type="date" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="备注">
                <el-input class="width-220" v-model="final_acceptances_form.acceptance_note" placeholder="备注"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            此处需要上传附件
          </el-row>
        </el-form>
      </div>
    </transition>

    <!-- 工程验收信息结束~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  </div>
</template>
<script>
const twodecimalrule = {
  pattern: /((^[1-9]\d*)|^0)(\.\d{2})$/,
  message: "请输入数字并保留两位小数",
  trigger: "blur"
};
export default {
  data() {
    return {
      contract_appendix_list: [],
      operate_type: [0, 0, 0, 0, 0, 0], //整个页面的操作类型,一共6个表单,0表示新增,1表示修改
      code_base_url: disparch_data.code_base_url,
      contract_base_url: disparch_data.contract_base_url,
      contract_unid_selected_data: [], //合同编号数据数组
      salesperson_unid_selected_data: [], //销售人员数据数组
      project_unid_selected_data: [], //项目名称数据数组
      customer_unid_selected_data: [], //客户名称数据数组
      provinces: [],
      cities: [],
      counties: [],
      modify_data: false, //用来标志dialog用来修改数据
      modify_index: -1, //用来标志修改数据的索引
      projectline_type_data: ["安防", "交通", "客流", "维保"],
      contract_state_data: ["已完成", "代发货", "施工中", "项目暂停"],
      contract_type_data: ["供货", "施工", "集成", "维保"],
      amount_state_unid_data: ["正常验收款", "正常维保"],
      mainten_start_point_data: ["签订时间", "到货验收时间", "项目终验时间"],
      guarantee_date: [], //维保服务期,数组形式的日期,0开始,1结束。
      // show and display~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      payments_dialog_show: false,
      receipts_dialog_show: false,
      rebacks_dialog_show: false,
      delivers_dialog_show: false,
      payments_show: true,
      contract_show: true,
      rebacks_show: true,
      receipts_show: true,
      delivers_show: true,
      acceptance_show: true,
      // show and display~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      form: {
        // 合同编号
        contract_unid: null,
        //销售员
        salesperson_unid: null,
        // 项目名称
        project_unid: null,
        // 客户名称
        customer_unid: null,
        // 项目所在省
        province: "",
        // // 项目所在市
        city: "",
        // // 项目所在区
        county: "",
        // 质保周期
        guarantee_period: 6,
        // 签订时间
        sign_date: "",
        // 所属年份
        year: "",
        // 所属月份
        month: "",
        // 产品线类型
        product_line_type: null,
        // 合同状态
        contract_state: null,
        // 合同类型
        contract_type: null,
        // 合同金额
        contract_amount: 0.0,
        // 抵扣金额
        deduct_amount: 0.0,
        // 合同金额备注
        contract_amount_note: "",
        // 暂停金额
        stop_amount: 0.0,
        // 累计回款额备注
        reback_note: "",
        // 豁免金额
        exemptions_amount: 0.0,
        // 合同余额备注
        contract_remain_note: "",
        // 是否归档
        is_archive: "",
        // 坏账金额
        bad_amount: 0.0,
        // 坏账金额备注
        bad_amount_note: "",
        // 确定收入金额
        confirm_income_amount: "",
        // 账款状态
        amount_state_unid: "",
        // 质保期开始
        mainten_start_point: null,
        // 合同备注
        contract_note: "",
        // 合同附件
        contract_appendix: {}
      },

      // 工程验收表单
      // acceptances_form: [
      //   {
      //     acceptance_type: "",
      //     acceptance_date: null,
      //     acceptance_note: null,
      //     appendix_unids: []
      //   },
      //   {
      //     acceptance_type: "",
      //     acceptance_date: null,
      //     acceptance_note: null,
      //     appendix_unids: []
      //   }
      // ],
      first_acceptances_form: {
        acceptance_type: null,
        acceptance_date: null,
        acceptance_note: null,
        appendix_unids: []
      },

      final_acceptances_form: {
        acceptance_type: null,
        acceptance_date: null,
        acceptance_note: null,
        appendix_unids: []
      },
      // 发货信息表单和数据,提交时提交data里的数据
      delivers_data: [],
      delivers_form: {
        deliver_goods_date: "",
        goods_acceptanc_date: "",
        appendix_unids: []
      },
      // 付款约定表单和数据,提交时提交data里的数据
      payments_data: [],
      payments_form: {
        payment_type: "",
        days: "",
        payment_propority: "",
        payment_requirement: ""
      },
      // 回款信息表单和数据,提交时提交data里的数据
      rebacks_data: [],
      rebacks_form: {
        actual_reback_amount: 0,
        reback_date: "",
        reback_note: ""
      },
      // 开票信息表单和数据,提交时提交data里的数据
      receipts_data: [],
      receipts_form: {
        receipt_amount: 0,
        oa_flow_id: "",
        receipt_note: ""
      },

      // 表单验证~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      add_rules: {
        contract_amount: twodecimalrule,
        deduct_amount: twodecimalrule,
        stop_amount: twodecimalrule,
        exemptions_amount: twodecimalrule,
        bad_amount: twodecimalrule,
        confirm_income_amount: twodecimalrule,
        payment_type: {
          required: true,
          message: "类型不能为空",
          trigger: "blur"
        },
        days: {
          required: true,
          pattern: /(^[1-9](\d*)$)|(^0$)/,
          message: "请输入正确天数",
          trigger: "blur"
        },
        deliver_goods_date: {
          validator: (rule, value, callback) => {
            if (value == "") {
              callback(new Error("时间不能为空"));
            } else callback();
          },
          trigger: "blur"
        },
        goods_acceptanc_date: {
          validator: (rule, value, callback) => {
            if (value == "") {
              callback(new Error("时间不能为空"));
            } else if (
              this.delivers_form.deliver_goods_date &&
              value < this.delivers_form.deliver_goods_date
            ) {
              callback(new Error("到货验收时间不能小于发货时间"));
            } else callback();
          },
          trigger: "blur"
        }
      },
      rebacks_form_rules: {
        actual_reback_amount: {
          required: true,
          pattern: /(^[1-9](\d*)$)|(^0$)/,
          message: "请输入正确金额",
          trigger: "blur"
        },
        reback_date: {
          required: true,
          message: "不能为空",
          trigger: "blur"
        }
      },
      receipts_form_rules: {
        receipt_amount: {
          required: true,
          pattern: /(^[1-9](\d*)$)|(^0$)/,
          message: "请输入正确金额",
          trigger: "blur"
        },
        oa_flow_id: {
          required: true,
          message: "请输入流水号",
          trigger: "blur"
        }
      },
      acceptance_form_rules: {
        acceptance_date: {
          validator: (rule, value, callback) => {
            if (
              this.first_acceptances_form.acceptance_type == "1" &&
              value == null
            ) {
              callback(new Error("请填写时间"));
            } else callback();
          },
          trigger: "blur"
        }
      },
      acceptance_form_rules2: {
        acceptance_date: {
          validator: (rule, value, callback) => {
            var a = this.final_acceptances_form.acceptance_type;
            if (a == "2" && value == null) {
              callback(new Error("请填写时间"));
            } else callback();
          },
          trigger: "blur"
        },
        //callback必须返回
        acceptance_type: {
          validator: (rule, value, callback) => {
            if (
              this.first_acceptances_form.acceptance_type == "1" &&
              value != "2"
            ) {
              callback(new Error("初验必须终验"));
            } else {
              callback();
            }
          }
        }
      }
      // 表单验证~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    };
  },
  computed: {
    // 上传附件地址
    upload_url: function() {
      return (
        "/api/v1/financial/contracts/" +
        this.form.contract_unid +
        "/upload/appendixes"
      );
    },
    // 合同余额
    contract_remaining: function() {
      return (
        this.form.contract_amount -
        this.form.deduct_amount -
        this.total_reback_amount -
        this.form.stop_amount -
        this.form.exemptions_amount -
        this.form.bad_amount
      ).toFixed(2);
    },
    // 累计回款额
    total_reback_amount: function() {
      var total = 0;
      for (let i = 0; i < this.rebacks_data.length; i++) {
        const e = this.rebacks_data[i];
        total += parseFloat(e.actual_reback_amount);
      }
      return total.toFixed(2);
    },
    //累计应收款
    total_receive_amount: function() {
      var total = 0;
      var now = new Date();
      var now_date =
        now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate();
      for (let i = 0; i < this.payments_data.length; i++) {
        const e = this.payments_data[i];
        if (e.pay_date < now_date) {
          total += parseFloat(e.amount);
        }
      }
      return total.toFixed(2);
    },
    // 应收账款余额
    total_leave_amount: function() {
      return (
        this.total_receive_amount -
        this.total_reback_amount -
        this.form.deduct_amount -
        this.form.stop_amount -
        this.form.exemptions_amount -
        this.form.bad_amount
      ).toFixed(2);
    },
    // 逾期天数
    over_days_unid: function() {
      var pay_date = "";
      var now = new Date();
      var now_date =
        now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate();
      var amount = 0;
      for (let i = 0; i < this.payments_data.length; i++) {
        const element = this.payments_data[i];
        pay_date = element.pay_date;
        amount += element.amount;
      }
      if (now_date > pay_date && amount > this.total_reback_amount) {
        return this.date_diff(now_date, pay_date);
      } else {
        return 0;
      }
    },
    // 维保服务期开始时间
    start_guarantee_date: function() {
      if (this.guarantee_date[0]) {
        return this.guarantee_date[0];
      }
    },
    // 维保服务期结束时间
    end_guarantee_date: function() {
      if (this.guarantee_date[1]) {
        return this.guarantee_date[1];
      }
    },
    mainten_start_date: function() {
      if (
        this.form.mainten_start_point == 0 &&
        this.form.sign_date &&
        this.form.guarantee_period
      ) {
        return this.form.sign_date;
      } else if (this.form.mainten_start_point == 1 && this.delivers_data[0]) {
        var index = this.delivers_data.length - 1;
        return this.delivers_data[index].goods_acceptanc_date;
      } else if (
        this.form.mainten_start_point == 2 &&
        this.final_acceptances_form.acceptance_type == "2" &&
        this.final_acceptances_form.acceptance_date != ""
      ) {
        return this.final_acceptances_form.acceptance_date;
      }
    },
    mainten_end_date: function() {
      if (
        this.form.mainten_start_point == 0 &&
        this.form.sign_date &&
        this.form.guarantee_period
      ) {
        return this.date_add_month(
          this.form.sign_date,
          this.form.guarantee_period
        );
      } else if (this.form.mainten_start_point == 1 && this.delivers_data[0]) {
        var index = this.delivers_data.length - 1;
        return this.date_add_month(
          this.delivers_data[index].goods_acceptanc_date,
          this.form.guarantee_period
        );
      } else if (
        this.form.mainten_start_point == 2 &&
        this.final_acceptances_form.acceptance_type == "2" &&
        this.final_acceptances_form.acceptance_date != ""
      ) {
        return this.date_add_month(
          this.final_acceptances_form.acceptance_date,
          this.form.guarantee_period
        );
      }
    }
  },
  methods: {
    test(file) {
      this.$Axios({
        method: "post",
        url: this.upload_url,
        data: {
          business_table: "contracts",
          appendix_files: file
        }
      }).then(res => {
        console.log(res.data.appendix_unid);
      });
      return false;
    },

    // dialog_cancel~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    payments_dialog_cancel() {
      this.modify_data = false;
      this.$refs["payments_form"].resetFields();
      this.payments_dialog_show = false;
    },
    rebacks_dialog_cancel() {
      this.modify_data = false;
      this.$refs["rebacks_form"].resetFields();
      this.rebacks_dialog_show = false;
    },
    receipts_dialog_cancel() {
      this.modify_data = false;
      this.$refs["receipts_form"].resetFields();
      this.receipts_dialog_show = false;
    },
    delivers_dialog_cancel() {
      this.modify_data = false;
      this.$refs["delivers_form"].resetFields();
      this.delivers_dialog_show = false;
    },

    // dialog_cancel~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // date_methods~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    date_diff(date1, date2) {
      var date1s = date1.split("-");
      var date2s = date2.split("-");
      var days = parseInt(
        (new Date(date1s[0], date1s[1] - 1, date1s[2]).getTime() -
          new Date(date2s[0], date2s[1] - 1, date2s[2]).getTime()) /
          1000 /
          60 /
          60 /
          24
      );
      return days;
    },
    date_add_days(datestr, daynum) {
      var date_str = datestr;
      var date = new Date(date_str.replace(/-/g, "/"));
      date = new Date((date / 1000 + 86400 * daynum) * 1000);
      var result_date =
        date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
      return result_date;
    },
    date_add_month(datestr, month) {
      var dates = datestr.split("-");
      var date = new Date(dates[0], dates[1] - 1 + month, dates[2]);
      return date
        .toLocaleDateString()
        .match(/\d+/g)
        .join("-");
    },
    // date_methods~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    add_axios(m, u, arr) {
      this.$Axios({
        method: m,
        url: u
      }).then(response => {
        arr = response.data.list_data;
      });
    },
    // remoteMethod~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    contractIdRemoteMethod(query) {
      this.$Axios({
        method: "get",
        url: this.code_base_url + "countries"
        // params:{
        //   wd:this.form.contract_unid
        // }
      })
        .then(response => {
          this.contract_unid_selected_data = response.data.list_data;
        })
        .catch(err => {
          console.log(err.message);
        });
    },
    salespersonIdRemoteMethod(query) {
      this.$Axios({
        method: "get",
        url: this.code_base_url + "simple/cates/09BB973F92/codes"
        // params:{
        //   wd:this.form.contract_unid
        // }
      })
        .then(response => {
          this.salesperson_unid_selected_data = response.data.list_data;
        })
        .catch(err => {
          console.log(err.message);
        });
    },
    projectIdRemoteMethod(query) {
      this.$Axios({
        method: "get",
        url: this.code_base_url + "simple/cates/09BB973F92/codes"
        // params:{
        //   wd:this.form.contract_unid
        // }
      })
        .then(response => {
          this.project_unid_selected_data = response.data.list_data;
        })
        .catch(err => {
          console.log(err.message);
        });
    },
    customerIdRemoteMethod(query) {
      this.$Axios({
        method: "get",
        url: this.code_base_url + "simple/cates/09BB973F92/codes"
        // params:{
        //   wd:this.form.contract_unid
        // }
      })
        .then(response => {
          this.customer_unid_selected_data = response.data.list_data;
        })
        .catch(err => {
          console.log(err.message);
        });
    },

    // remoteMethod~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    signDataChanged() {
      var date = this.form.sign_date;
      this.form.year = date.slice(0, 4);
      this.form.month = date.slice(5, 7);
    },

    // dialog_confirm_start~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    payments_dialog_confirm() {
      this.$refs["payments_form"].validate(valid => {
        if (valid) {
          var progress = this.payments_data.length + 1;
          var type_value = this.payments_form.payment_type;
          var days = this.payments_form.days;
          var propority = this.payments_form.payment_propority;
          var requirement = this.payments_form.payment_requirement;
          var amount = 0;
          var date = "";
          if (this.form.contract_amount > 0) {
            amount = this.form.contract_amount * propority / 100;
          }
          if (type_value == "1" && this.form.sign_date) {
            date = this.date_add_days(this.form.sign_date, days);
          } else if (
            (type_value == "2" || type_value == "4") &&
            this.delivers_data[0]
          ) {
            var i = this.delivers_data.length - 1;
            date = this.date_add_days(
              this.delivers_data[i].goods_acceptanc_date,
              days
            );
          } else if (
            (type_value == "3" || type_value == "5") &&
            this.final_acceptances_form.acceptance_date != null
          ) {
            date = this.date_add_days(
              this.final_acceptances_form.acceptance_date,
              days
            );
          }
          var a = {
            payment_progress: progress,
            payment_type: type_value,
            days: days,
            payment_propority: propority,
            payment_requirement: requirement,
            amount: amount,
            pay_date: date
          };
          if (!this.modify_data) {
            this.payments_data.push(a);
          } else {
            this.$set(this.payments_data, this.modify_index, a);
          }

          this.modify_data = false;
          this.$refs["payments_form"].resetFields();
          this.payments_dialog_show = false;
        }
      });
    },
    receipts_dialog_confirm() {
      this.$refs["receipts_form"].validate(valid => {
        if (valid) {
          var receipt_progress = this.receipts_data.length + 1;
          var receipt_amount = parseFloat(this.receipts_form.receipt_amount);
          var oa_flow_id = this.receipts_form.oa_flow_id;
          var receipt_propority = 0;
          if (this.form.contract_amount) {
            receipt_propority = (
              receipt_amount *
              100 /
              this.form.contract_amount
            ).toFixed(2);
          }
          var total_receipt_amount = receipt_amount;
          if (receipt_progress > 1) {
            total_receipt_amount =
              parseFloat(
                this.receipts_data[receipt_progress - 2].total_receipt_amount
              ) + receipt_amount;
          }
          var is_reback = "";
          if (this.total_reback_amount >= total_receipt_amount) {
            is_reback = "是";
          } else is_reback = "否";
          var receipt_note = this.receipts_form.receipt_note;
          var a = {
            receipt_progress: receipt_progress,
            receipt_amount: receipt_amount,
            oa_flow_id: oa_flow_id,
            receipt_propority: receipt_propority,
            total_receipt_amount: total_receipt_amount,
            is_reback: is_reback,
            receipt_note: receipt_note
          };
          if (!this.modify_data) {
            this.receipts_data.push(a);
          } else {
            this.$set(this.receipts_data, this.modify_index, a);
          }

          this.modify_data = false;
          this.$refs["receipts_form"].resetFields();
          this.receipts_dialog_show = false;
        }
      });
    },
    rebacks_dialog_confirm() {
      this.$refs["rebacks_form"].validate(valid => {
        if (valid) {
          var reback_progress = this.rebacks_data.length + 1;
          var actual_reback_amount = this.rebacks_form.actual_reback_amount;
          var reback_propority = 0;
          if (this.form.contract_amount) {
            reback_propority =
              actual_reback_amount / this.form.contract_amount * 100;
          }
          var reback_date = this.rebacks_form.reback_date;
          var reback_note = this.rebacks_form.reback_note;
          var a = {
            reback_progress: reback_progress,
            actual_reback_amount: actual_reback_amount,
            reback_propority: reback_propority,
            reback_date: reback_date,
            reback_note: reback_note
          };

          if (!this.modify_data) {
            this.rebacks_data.push(a);
          } else {
            this.$set(this.rebacks_data, this.modify_index, a);
          }

          this.modify_data = false;

          this.$refs["rebacks_form"].resetFields();
          this.rebacks_dialog_show = false;
        }
      });
    },
    delivers_dialog_confirm() {
      this.$refs["delivers_form"].validate(valid => {
        if (valid) {
          var deliver_goods_date = this.delivers_form.deliver_goods_date;
          var goods_acceptanc_date = this.delivers_form.goods_acceptanc_date;
          var appendix_unids = this.delivers_form.appendix_unids;
          var a = {
            deliver_goods_date: deliver_goods_date,
            goods_acceptanc_date: goods_acceptanc_date,
            appendix_unids: appendix_unids
          };
          if (!this.modify_data) {
            this.delivers_data.push(a);
          } else {
            this.$set(this.delivers_data, this.modify_index, a);
          }
          this.modify_data = false;
          this.$refs["delivers_form"].resetFields();
          this.delivers_dialog_show = false;
        }
      });
    },
    // dialog_confirm_end~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    data_delete(index, data) {
      this.$confirm("确认删除数据?", "确认信息", {
        confirmButtonText: "确认",
        cancelButtonText: "取消"
      })
        .then(() => {
          data.splice(index, 1);
          this.$message({
            duration: 1000,
            type: "success",
            message: "删除成功"
          });
        })
        .catch(action => {
          this.$message({
            duration: 1000,
            type: "info",
            message: "没有删除数据"
          });
        });
    },

    // modifystart~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    payment_data_modify(index, data) {
      this.payments_form.payment_type = data[index].payment_type;
      this.payments_form.days = data[index].days;
      this.payments_form.payment_propority = data[index].payment_propority;
      this.payments_form.payment_requirement = data[index].payment_requirement;
      this.modify_data = true;
      this.modify_index = index;
      this.payments_dialog_show = true;
    },
    reback_data_modify(index, data) {
      this.rebacks_form.actual_reback_amount = data[index].actual_reback_amount;
      this.rebacks_form.reback_date = data[index].reback_date;
      this.rebacks_form.reback_note = data[index].reback_note;
      this.modify_data = true;
      this.modify_index = index;
      this.rebacks_dialog_show = true;
    },
    receipt_data_modify(index, data) {
      this.receipts_form.receipt_amount = data[index].receipt_amount;
      this.receipts_form.oa_flow_id = data[index].oa_flow_id;
      this.receipts_form.receipt_note = data[index].receipt_note;
      this.modify_data = true;
      this.modify_index = index;
      this.receipts_dialog_show = true;
    },
    deliver_data_modify(index, data) {
      this.delivers_form.deliver_goods_date = data[index].deliver_goods_date;
      this.delivers_form.goods_acceptanc_date =
        data[index].goods_acceptanc_date;
      this.modify_data = true;
      this.modify_index = index;
      this.delivers_dialog_show = true;
    },
    // modifyend~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // getlocation start~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    get_provinces() {
      this.$Axios({
        method: "get",
        url: this.code_base_url + "countries/0E229CD043/provinces"
      })
        .then(response => {
          this.provinces = response.data.list_data;
        })
        .catch(err => {
          console.log(err.message);
        });
    },
    get_cities() {
      this.form.city = "";
      this.form.county = "";
      if (this.form.province) {
        this.$Axios({
          method: "get",
          url:
            this.code_base_url +
            "countries/0E229CD043/provinces/" +
            this.form.province +
            "/cities"
        })
          .then(response => {
            this.cities = response.data.list_data;
          })
          .catch(err => {
            console.log(err.message);
          });
      }
    },
    get_counties() {
      this.form.county = "";
      if (this.form.province && this.form.city) {
        this.$Axios({
          method: "get",
          url:
            this.code_base_url +
            "countries/0E229CD043/provinces/" +
            this.form.province +
            "/cities/" +
            this.form.city +
            "/counties"
        })
          .then(response => {
            this.counties = response.data.list_data;
          })
          .catch(err => {
            console.log(err.message);
          });
      }
    },
    // getlocation end~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // !!!!!!~~~~~~~~~~~~~submit~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    form_submit(name) {
      if (name == "form") {
        if (this.operate_type[0] == 0) {
          this.operate_type[0] = 1;
          this.$Axios({
            method: "post",
            url: this.contract_base_url,
            data: this.form
          }).then(response => {
            if (response.data.encode == 200) {
              this.$alert("提交成功");
            }
          });
        } else if (this.operate_type[0] == 1) {
          // this.$alert("我提交 基本信息 修改的数据");
          console.log(this.form.contract_unid);
        }
      } else if (name == "payment") {
        if (this.operate_type[1] == 0) {
          this.operate_type[1] = 1;
          this.$alert("我提交 付款约定 新的数据");
        } else if (this.operate_type[1] == 1) {
          this.$alert("我提交 付款约定 修改的数据");
        }
      } else if (name == "reback") {
        if (this.operate_type[2] == 0) {
          this.operate_type[2] = 1;
          this.$alert("我提交 回款信息 新的数据");
        } else if (this.operate_type[2] == 1) {
          this.$alert("我提交 回款信息 修改的数据");
        }
      } else if (name == "receipt") {
        if (this.operate_type[3] == 0) {
          this.operate_type[3] = 1;
          this.$alert("我提交 开票信息 新的数据");
        } else if (this.operate_type[3] == 1) {
          this.$alert("我提交 开票信息 修改的数据");
        }
      } else if (name == "deliver") {
        if (this.operate_type[4] == 0) {
          this.operate_type[4] = 1;
          this.$alert("我提交 发货信息 新的数据");
        } else if (this.operate_type[4] == 1) {
          this.$alert("我提交 发货信息 修改的数据");
        }
      } else if (name == "project") {
        if (this.operate_type[5] == 0) {
          var _this = this;
          var p1 = new Promise(function(resolve, reject) {
            _this.$refs.first_acceptances_form.validate(valid => {
              if (valid) {
                resolve();
              }
            });
          });
          var p2 = new Promise(function(resolve, reject) {
            _this.$refs.final_acceptances_form.validate(valid2 => {
              if (valid2) {
                resolve();
              }
            });
          });

          Promise.all([p1, p2]).then(function() {
            _this
              .$Axios({
                method: "post",
                url: "/api/v1/financial/contracts/contract/project/acceptancs",
                data: {
                  list_data: [
                    _this.first_acceptances_form,
                    _this.final_acceptances_form
                  ]
                }
              })
              .then(response => {
                if (response.data.encode == 200) {
                  _this.$alert("提交成功");
                  _this.operate_type[5] = 1;
                }
              });
          });
        } else if (this.operate_type[5] == 1) {
          this.$refs["first_acceptances_form"].validate(valid => {
            if (valid) {
              console.log("非初次提交");
            }
          });
        }
      }
    }
  },
  created() {
    this.get_provinces();
    var id = this.$route.params.contract_unid;
    if (id != "0") {
      this.operate_type = [1, 1, 1, 1, 1, 1];
      this.form.contract_unid = id;
    }
  }
};
</script>
<style scoped>
.add_button {
  font-size: 20px;
  padding-top: 60px;
  color: gray;
}
.add_button:hover {
  color: black;
}
h1 {
  text-align: left;
  background-color: rgba(138, 200, 255, 0.5);
  padding-top: 20px;
  padding-bottom: 20px;
  padding-left: 30px;
  font-size: 26px;
  margin-bottom: 0px;
}
h1.h-button:hover {
  background-color: rgba(138, 200, 255, 0.8);
  cursor: pointer;
}

#payments_dialog {
  text-align: left;
}
.width-220 {
  width: 300px;
}
#form,
#payments_data_table,
#rebacks_data_table,
#receipts_data_table,
#delivers_data_table,
#acceptance_form {
  border-left: 5px solid rgba(138, 200, 255, 0.5);
  border-bottom: 5px solid rgba(138, 200, 255, 0.5);
  border-right: 5px solid rgba(138, 200, 255, 0.5);
  padding-top: 20px;
}
</style>