RepayTemplateModal.vue 37.3 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
<template>
  <a-modal
    :title="title"
    :width="1000"
    :centered="true"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSave"
    @cancel="handleCancel"
    cancelText="关闭"
    style="top:20px;"
    :maskClosable="false"  
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="还款模版编号:" :labelCol="labelCol1" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入还款模版编号"
            v-decorator="[ 'repaymentTemplateNo', validatorRules.repaymentTemplateNo]"
          />
        </a-form-item>

        <a-form-item label="还款模版名称:" :labelCol="labelCol1" :wrapperCol="wrapperCol" hasFeedback>
          <a-input
            placeholder="请输入还款模版名称"
            v-decorator="[ 'repaymentTemplateName', validatorRules.repaymentTemplateName]"
          />
        </a-form-item>

        <a-form-item label="是否系统代扣:" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-radio-group @change="handleChange" v-decorator="[ 'autoRepayment', validatorRules.autoRepayment]">
            <a-radio :value="1">是</a-radio>
            <a-radio :value="2">否</a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item
        v-if="show==1"
          label="正常线上代扣方式"
          style="margin-bottom:0"
          :labelCol="labelCol1"
          :wrapperCol="wrapperCol"
          hasFeedback
        ></a-form-item>
        <a-form-item v-if="show==1">
          <a-row :gutter="24" style="width:100%">
            <a-col :span="11" :offset="1">
              <a-card title="还款平台方账户设置"  :headStyle="headStyle"  :bodyStyle="bodyStyle">
                <div v-for="(item,index) in model.repaymentTransactionTypeRequest.normalLine.platform">
                   <a-select  style="width:32%" :defaultValue="item.repaymentType" :value="item.repaymentName"  @change="value => handleChangeType(value,{index:index,type:'normalLine',key:'platform'})"  placeholder="请选择">
                 <a-select-option :value="1">线下还款</a-select-option>
                  <a-select-option :value="2">支付宝代扣</a-select-option>                  
                  <a-select-option :value="3">银行卡还款</a-select-option>
                </a-select>
                <a-input-number :min="1" style="width:15%" :value="item.sort" @change="value =>sortFun(value,{index:index,type:'normalLine',key:'platform'})" placeholder="排序" />
                <a-select v-if="item.repaymentType==1" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'normalLine',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>
                <a-select v-if="item.repaymentType==2" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'normalLine',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account1" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select> 
                <a-select v-if="item.repaymentType==3" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'normalLine',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account2" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>            
                  <a-button @click="addAccount({index:index,type:'normalLine',key:'platform'})" type="primary" icon="plus" style="margin-left: 1%;" size="small" />
                  <a-button @click="delAccount({index:index,type:'normalLine',key:'platform'})" v-if="model.repaymentTransactionTypeRequest.normalLine.platform.length!=1" type="primary" icon="minus" style="margin-left: 1%;" size="small" />
                </div>
              
              </a-card>
            </a-col>
            <a-col :span="11">
              <a-card title="还款平台方费用账户设置"  :headStyle="headStyle"  :bodyStyle="bodyStyle">
                <div v-for="(item,index) in model.repaymentTransactionTypeRequest.normalLine.platformCost">
                   <a-select  style="width:32%" :defaultValue="item.repaymentType" :value="item.repaymentName"  @change="value => handleChangeType(value,{index:index,type:'normalLine',key:'platformCost'})"  placeholder="请选择">
                 <a-select-option :value="1">线下还款</a-select-option>
                  <a-select-option :value="2">支付宝代扣</a-select-option>                  
                  <a-select-option :value="3">银行卡还款</a-select-option>
                </a-select>
                <a-input-number :min="1" style="width:15%" :value="item.sort" @change="value =>sortFun(value,{index:index,type:'normalLine',key:'platformCost'})" placeholder="排序" />
                <a-select v-if="item.repaymentType==1" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'normalLine',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>
                <a-select v-if="item.repaymentType==2" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'normalLine',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account1" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select> 
                <a-select v-if="item.repaymentType==3" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'normalLine',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account2" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>            
                  <a-button @click="addAccount({index:index,type:'normalLine',key:'platformCost'})" type="primary" icon="plus" style="margin-left: 1%;" size="small" />
                  <a-button @click="delAccount({index:index,type:'normalLine',key:'platformCost'})" v-if="model.repaymentTransactionTypeRequest.normalLine.platformCost.length!=1" type="primary" icon="minus" style="margin-left: 1%;" size="small" />
                </div>
              
              </a-card>
            </a-col>
          </a-row>
        </a-form-item>
        <a-form-item  v-if="show==1"
          label="回购线上代扣方式"
          style="margin-bottom:0"
          :labelCol="labelCol1"
          :wrapperCol="wrapperCol"
          hasFeedback
        ></a-form-item>
        <a-form-item  v-if="show==1">
         <a-row :gutter="24" style="width:100%">
            <a-col :span="11" :offset="1">
              <a-card title="还款平台方账户设置"  :headStyle="headStyle"  :bodyStyle="bodyStyle">
                <div v-for="(item,index) in model.repaymentTransactionTypeRequest.buyBackLine.platform">
                   <a-select  style="width:32%" :defaultValue="item.repaymentType" :value="item.repaymentName"  @change="value => handleChangeType(value,{index:index,type:'buyBackLine',key:'platform'})"  placeholder="请选择">
                 <a-select-option :value="1">线下还款</a-select-option>
                  <a-select-option :value="2">支付宝代扣</a-select-option>                  
                  <a-select-option :value="3">银行卡还款</a-select-option>
                </a-select>
                <a-input-number :min="1" style="width:15%" :value="item.sort" @change="value =>sortFun(value,{index:index,type:'buyBackLine',key:'platform'})" placeholder="排序" />
                <a-select v-if="item.repaymentType==1" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackLine',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>
                <a-select v-if="item.repaymentType==2" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackLine',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account1" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select> 
                <a-select v-if="item.repaymentType==3" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackLine',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account2" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>            
                  <a-button @click="addAccount({index:index,type:'buyBackLine',key:'platform'})" type="primary" icon="plus" style="margin-left: 1%;" size="small" />
                  <a-button @click="delAccount({index:index,type:'buyBackLine',key:'platform'})" v-if="model.repaymentTransactionTypeRequest.buyBackLine.platform.length!=1" type="primary" icon="minus" style="margin-left: 1%;" size="small" />
                </div>
              
              </a-card>
            </a-col>
            <a-col :span="11">
              <a-card title="还款平台方费用账户设置"  :headStyle="headStyle"  :bodyStyle="bodyStyle">
                <div v-for="(item,index) in model.repaymentTransactionTypeRequest.buyBackLine.platformCost">
                   <a-select  style="width:32%" :defaultValue="item.repaymentType" :value="item.repaymentName"  @change="value => handleChangeType(value,{index:index,type:'buyBackLine',key:'platformCost'})"  placeholder="请选择">
                 <a-select-option :value="1">线下还款</a-select-option>
                  <a-select-option :value="2">支付宝代扣</a-select-option>                  
                  <a-select-option :value="3">银行卡还款</a-select-option>
                </a-select>
                <a-input-number :min="1" style="width:15%" :value="item.sort" @change="value =>sortFun(value,{index:index,type:'buyBackLine',key:'platformCost'})" placeholder="排序" />
                <a-select v-if="item.repaymentType==1" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackLine',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>
                <a-select v-if="item.repaymentType==2" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackLine',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account1" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select> 
                <a-select v-if="item.repaymentType==3" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackLine',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account2" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>            
                  <a-button @click="addAccount({index:index,type:'buyBackLine',key:'platformCost'})" type="primary" icon="plus" style="margin-left: 1%;" size="small" />
                  <a-button @click="delAccount({index:index,type:'buyBackLine',key:'platformCost'})" v-if="model.repaymentTransactionTypeRequest.buyBackLine.platformCost.length!=1" type="primary" icon="minus" style="margin-left: 1%;" size="small" />
                </div>
              
              </a-card>
            </a-col>
          </a-row>
        </a-form-item>
        <a-form-item
          label="客户主动还款"
          style="margin-bottom:0"
          :labelCol="labelCol1"
          :wrapperCol="wrapperCol"
          hasFeedback
        ></a-form-item>
        <a-form-item>
         <a-row :gutter="24" style="width:100%">
            <a-col :span="11" :offset="1">
              <a-card title="还款平台方账户设置"  :headStyle="headStyle"  :bodyStyle="bodyStyle">
                <div v-for="(item,index) in model.repaymentTransactionTypeRequest.customer.platform">
                   <a-select  style="width:32%" :defaultValue="item.repaymentType" :value="item.repaymentName"  @change="value => handleChangeType(value,{index:index,type:'customer',key:'platform'})"  placeholder="请选择">
                 <a-select-option :value="1">线下还款</a-select-option>
                  <a-select-option :value="2">支付宝代扣</a-select-option>                  
                  <a-select-option :value="3">银行卡还款</a-select-option>
                </a-select>
                <a-input-number :min="1" style="width:15%" :value="item.sort" @change="value =>sortFun(value,{index:index,type:'customer',key:'platform'})" placeholder="排序" />
                <a-select v-if="item.repaymentType==1" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'customer',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>
                <a-select v-if="item.repaymentType==2" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'customer',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account1" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select> 
                <a-select v-if="item.repaymentType==3" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'customer',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account2" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>            
                  <a-button @click="addAccount({index:index,type:'customer',key:'platform'})" type="primary" icon="plus" style="margin-left: 1%;" size="small" />
                  <a-button @click="delAccount({index:index,type:'customer',key:'platform'})" v-if="model.repaymentTransactionTypeRequest.customer.platform.length!=1" type="primary" icon="minus" style="margin-left: 1%;" size="small" />
                </div>
              
              </a-card>
            </a-col>
            <a-col :span="11">
              <a-card title="还款平台方费用账户设置"  :headStyle="headStyle"  :bodyStyle="bodyStyle">
                <div v-for="(item,index) in model.repaymentTransactionTypeRequest.customer.platformCost">
                   <a-select  style="width:32%" :defaultValue="item.repaymentType" :value="item.repaymentName"  @change="value => handleChangeType(value,{index:index,type:'customer',key:'platformCost'})"  placeholder="请选择">
                 <a-select-option :value="1">线下还款</a-select-option>
                  <a-select-option :value="2">支付宝代扣</a-select-option>                  
                  <a-select-option :value="3">银行卡还款</a-select-option>
                </a-select>
                <a-input-number :min="1" style="width:15%" :value="item.sort" @change="value =>sortFun(value,{index:index,type:'customer',key:'platformCost'})" placeholder="排序" />
                <a-select v-if="item.repaymentType==1" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'customer',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>
                <a-select v-if="item.repaymentType==2" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'customer',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account1" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select> 
                <a-select v-if="item.repaymentType==3" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'customer',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account2" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>            
                  <a-button @click="addAccount({index:index,type:'customer',key:'platformCost'})" type="primary" icon="plus" style="margin-left: 1%;" size="small" />
                  <a-button @click="delAccount({index:index,type:'customer',key:'platformCost'})" v-if="model.repaymentTransactionTypeRequest.customer.platformCost.length!=1" type="primary" icon="minus" style="margin-left: 1%;" size="small" />
                </div>
              
              </a-card>
            </a-col>
          </a-row>
        </a-form-item>
        <a-form-item
          label="回购客户主动还款方式"
          style="margin-bottom:0"
          :labelCol="labelCol1"
          :wrapperCol="wrapperCol"
          hasFeedback
        ></a-form-item>
        <a-form-item>
          <a-row :gutter="24" style="width:100%">
            <a-col :span="11" :offset="1">
              <a-card title="还款平台方账户设置"  :headStyle="headStyle"  :bodyStyle="bodyStyle">
                <div v-for="(item,index) in model.repaymentTransactionTypeRequest.buyBackCustomer.platform">
                   <a-select  style="width:32%" :defaultValue="item.repaymentType" :value="item.repaymentName"  @change="value => handleChangeType(value,{index:index,type:'buyBackCustomer',key:'platform'})"  placeholder="请选择">
                 <a-select-option :value="1">线下还款</a-select-option>
                  <a-select-option :value="2">支付宝代扣</a-select-option>                  
                  <a-select-option :value="3">银行卡还款</a-select-option>
                </a-select>
                <a-input-number :min="1" style="width:15%" :value="item.sort" @change="value =>sortFun(value,{index:index,type:'buyBackCustomer',key:'platform'})" placeholder="排序" />
                <a-select v-if="item.repaymentType==1" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackCustomer',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>
                <a-select v-if="item.repaymentType==2" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackCustomer',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account1" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select> 
                <a-select v-if="item.repaymentType==3" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackCustomer',key:'platform'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account2" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>            
                  <a-button @click="addAccount({index:index,type:'buyBackCustomer',key:'platform'})" type="primary" icon="plus" style="margin-left: 1%;" size="small" />
                  <a-button @click="delAccount({index:index,type:'buyBackCustomer',key:'platform'})" v-if="model.repaymentTransactionTypeRequest.buyBackCustomer.platform.length!=1" type="primary" icon="minus" style="margin-left: 1%;" size="small" />
                </div>
              
              </a-card>
            </a-col>
            <a-col :span="11">
              <a-card title="还款平台方费用账户设置"  :headStyle="headStyle"  :bodyStyle="bodyStyle">
                <div v-for="(item,index) in model.repaymentTransactionTypeRequest.buyBackCustomer.platformCost">
                   <a-select  style="width:32%" :defaultValue="item.repaymentType" :value="item.repaymentName"  @change="value => handleChangeType(value,{index:index,type:'buyBackCustomer',key:'platformCost'})"  placeholder="请选择">
                 <a-select-option :value="1">线下还款</a-select-option>
                  <a-select-option :value="2">支付宝代扣</a-select-option>                  
                  <a-select-option :value="3">银行卡还款</a-select-option>
                </a-select>
                <a-input-number :min="1" style="width:15%" :value="item.sort" @change="value =>sortFun(value,{index:index,type:'buyBackCustomer',key:'platformCost'})" placeholder="排序" />
                <a-select v-if="item.repaymentType==1" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackCustomer',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>
                <a-select v-if="item.repaymentType==2" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackCustomer',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account1" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select> 
                <a-select v-if="item.repaymentType==3" style="width:32%" :labelInValue="true" :defaultValue="item.repaymentAccountNo" :value="{key:item.repaymentAccountNo,label:item.repaymentAccountName}"  @change="value => handleChangeBank(value,{index:index,type:'buyBackCustomer',key:'platformCost'})"  placeholder="请选择">
                  <a-select-option v-for="item in Account2" :key="item.repaymentAccountName"  :value="item.repaymentAccountNo">{{item.repaymentAccountName}}</a-select-option>
                </a-select>            
                  <a-button @click="addAccount({index:index,type:'buyBackCustomer',key:'platformCost'})" type="primary" icon="plus" style="margin-left: 1%;" size="small" />
                  <a-button @click="delAccount({index:index,type:'buyBackCustomer',key:'platformCost'})" v-if="model.repaymentTransactionTypeRequest.buyBackCustomer.platformCost.length!=1" type="primary" icon="minus" style="margin-left: 1%;" size="small" />
                </div>
              
              </a-card>
            </a-col>
          </a-row>
        </a-form-item>
        <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-textarea rows="4" placeholder="备注" v-decorator="['remark']" />
        </a-form-item>
        <div v-show="false">
          <div v-for="item,index in arr1" v-if="index==1">{{item}}</div>
        </div>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import { changPassword } from '@/api/api'
import { repaymentAccountByType, insertRepaymentTemplate,updateRepaymentTemplate } from '@/api/configApi'
export default {
  name: 'PasswordModal',
  data() {
    return {
      visible: false,
      confirmLoading: false,
      confirmDirty: false,
      type:'add',
      show:false,
      title: '',
      arr:[{type:'',sort:'',bank:''}],//添加账户
      arr1:[],
      validatorRules: {
        repaymentTemplateNo: {
          rules: [
            {
              required: true,
              message: '请输还款模版编号'
            }
          ]
        },
        repaymentTemplateName: {
          rules: [
            {
              required: true,
              message: '请输入还款模版名称'
            }
          ]
        },
        autoRepayment: {
          rules: [
            {
              required: true,
              message: '请选择是否系统代扣'
            }
          ]
        }
      },

      model: {
        repaymentTransactionTypeRequest:{
          normalLine:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          buyBackLine:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          customer:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          buyBackCustomer:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},
        }
      },
      Account:[],
      Account1:[],
      Account2:[],
      headStyle: {
        fontSize: '12px',
        color: 'blue'
      },
      bodyStyle: { padding: 0 },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      labelCol1: {
        xs: { span: 12 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      form: this.$form.createForm(this),
    }
  },
  created() {
    console.log('created')
  },
watch: {
    Account: {
      handler(newName, oldName) {
        // console.log(newName);
        this.Account = newName
      },
      deep: true,
      immediate: true
    },
    Account1: {
      handler(newName, oldName) {
        // console.log(newName);
        this.Account1 = newName
      },
      deep: true,
      immediate: true
    },
    Account2: {
      handler(newName, oldName) {
        // console.log(newName);
        this.Account2 = newName
      },
      deep: true,
      immediate: true
    },
    // "model.repaymentTransactionTypeRequest.normalLine.platformCost": {
    //   handler(newName, oldName) {
    //     console.log(newName);
    //     this.model.repaymentTransactionTypeRequest.normalLine.platformCost = newName
    //   },
    //   deep: true,
    //   immediate: true
    // }
  },
  methods: {
    addAccount(param){
      this.arr1.push(2)
      this.model.repaymentTransactionTypeRequest[param.type][param.key].push({repaymentType:1,sort:'',repaymentAccountName:'',repaymentAccountName:''})
      // console.log(this.model.repaymentTransactionTypeRequest[param.type])
      if(this.model.repaymentTransactionTypeRequest[param.type][param.key].length>2)return '';
      this.getAccountInfo(1)
    },
    delAccount(param){
      this.arr1.splice(param.index, 1)
      this.model.repaymentTransactionTypeRequest[param.type][param.key].splice(param.index, 1);
      console.log(this.model.repaymentTransactionTypeRequest)
    },
    // 是否选择系统代扣
    handleChange(value) {
      this.show = value.target.value;
      // console.log(this.show)
    },
    // 排序 
    sortFun(value,param){
      // this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index].sort=value
       this.arr1.push(2)
      this.$set(this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index],'sort',value)
      console.log(this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index])
    },
    //银行变动
    handleChangeBank(value,param){
      //value = {key: "2333", label: "333"} repaymentAccountNo 还款账户编号 key=repaymentAccountName 还款账户名称
      // model.repaymentTransactionTypeRequest.normalLine.platform
      this.arr1.push(2)
     this.$set(this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index],'repaymentAccountNo',value.key)
      this.$set(this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index],'repaymentAccountName',value.label)
      console.log(this.model.repaymentTransactionTypeRequest[param.type][param.key])
    },
    // 还款类型变动
    handleChangeType(value,param){
      //value = repaymentType 还款类型:1线下还款、2支付宝代扣、3银行卡代扣
      let types = ["线下还款","支付宝代扣","银行卡代扣"]
       this.arr1.push(2)
      // this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index].repaymentType=value
      this.$set(this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index],'repaymentType',value)
      this.$set(this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index],'repaymentName',types[value-1])
      // 重置账户信息
      //  this.delAccount(param)
      // this.addAccount(param)
      this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index].repaymentAccountNo=''
      this.model.repaymentTransactionTypeRequest[param.type][param.key][param.index].repaymentAccountName=''
      console.log(this.model.repaymentTransactionTypeRequest[param.type][param.key])
      // return '';
      this.getAccountInfo(value)
    },
    // 获取账户信息
    getAccountInfo(value){
      let _p = {
        repaymentType:value||1,
      }
      if(this.Account.length!=0&&this.Account1.length!=0&&this.Account2.length!=0){
        return '';
      }
      repaymentAccountByType(_p).then(res => {
              if (res.status.statusCode == 0) {
                // this.Account = res.result;
                switch (value){
                  case 1: this.Account = res.result;break;
                  case 2: this.Account1 = res.result;break;
                  case 3: this.Account2 = res.result;break;
                }
                // this.$message.success(res.status.statusReason)
                // this.$emit('ok')
              } else {
                this.$message.warning(res.status.statusReason)
              }
            })
            .finally(() => {
              // this.confirmLoading = false
              // this.close()
            })
    },
    edit(recodes) {
      this.form.resetFields()
      this.type = "edit"
      this.visible = true
      this.model = recodes
      this.model.repaymentTransactionTypeRequest={
          normalLine:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          buyBackLine:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          customer:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          buyBackCustomer:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},
        }
      this.show = recodes.autoRepayment
      this.$nextTick(() => {
        this.form.setFieldsValue(recodes)
      })
    },

    add(recodes) {
      this.form.resetFields()
      this.type = 'add'
      this.show = false
      this.visible = true
      this.model.repaymentTransactionTypeRequest={
          normalLine:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          buyBackLine:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          customer:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},

          buyBackCustomer:{platform:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}],
          platformCost:[{repaymentType:'',sort:'',repaymentAccountName:'',repaymentAccountName:''}]},
        }
      this.$nextTick(() => {
        this.form.setFieldsValue()
      })
    },

    onChange() {},

    close() {
      this.$emit('close')
      this.visible = false
      this.disableSubmit = false
      this.selectedRole = []
    },
    handleSave() {
      // 触发表单验证
      this.form.validateFields((err, values) => {
        console.log(err, values)
        // if (!err) {
          this.confirmLoading = true
          let formData = Object.assign(this.model, values)
          if(this.type=='add'){
            insertRepaymentTemplate(formData)
            .then(res => {
              if (res.status.statusCode == 0) {
                this.$message.success(res.status.statusReason)
                this.$emit('ok')
              } else {
                this.$message.warning(res.status.statusReason)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
          }else{
            updateRepaymentTemplate(formData)
            .then(res => {
              if (res.status.statusCode == 0) {
                this.$message.success(res.status.statusReason)
                this.$emit('ok')
              } else {
                this.$message.warning(res.status.statusReason)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
          }
          
        // }
      })
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>