<template>
  <div>
    <avue-form :option="option"
               @submit="submit"
               v-model="form"
               ref="form">
    </avue-form>
  </div>
</template>

<script>
  import {returnsApprove} from "@/api/bank/returns";;

  export default {
    name: "returns-approve-batch",
    data(){
      return {
        loading: false,
        form: {},
        option: {
          mockBtn: false,
          submitText: '確認',
          printBtn: false,
          emptyBtn: false,
          column: [
            /*{
              label: "接辦行經辦",
              prop: "handlingBank",
              rules: [{
                required: true,
                message: "請輸入接辦行經辦",
                trigger: "blur"
              }]
            },
            {
              label: "接辦行覆核",
              prop: "handlingBankReview",
              rules: [{
                required: false,
                message: "請輸入接辦行覆核",
                trigger: "blur"
              }]
            },*/
            {
              label: "跟進情況",
              prop: "handlingStatus",
              type: "select",
              dataType: "string",
              dicUrl: `/api/blade-system/dict/dictionary?code=processing_status`,
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              dicFormatter: (res) => {
                res.data.forEach(item => {item.disabled = item.isSealed == 1;})
                return res.data;
              },
              change: ({value}) => {
                this.findObject(this.option.column, 'bankRemark').rules[0].required = value == '2'
              },
              rules: [{
                required: true,
                message: "請輸入跟進情況",
                trigger: "blur"
              }]
            },
            {
              label: "支行備註",
              prop: "bankRemark",
              rules: [{
                required: false,
                message: "請輸入支行備註",
                trigger: "blur"
              }]
            },
          ]
        }
      }
    },
    props: {
      data: {
        type: Object
      },

    },
    mounted() {
    },
    methods: {
      submit(row, done){
        let _this = this;
        for (let i = 0; i < this.data.length; i++) {
          let row = this.data[i];
          returnsApprove(Object.assign(row, this.form)).then(() => {});
        }
        this.$confirm("批量確認成功！",{
          type: "success",
          showCancelButton: false,
          showClose: false,
        }).then(() => {
          _this.$emit("close")
          done();
        })

      },
    }
  }
</script>

<style scoped>

</style>
