<template>
  <ele-modal
    custom-class="ele-dialog-form long-dialog-form"
    :centered="true"
    :visible.sync="collectionDialogFlag"
    :title="title"
    :append-to-body="false"
    :close-on-click-modal="false"
    width="60%"
    :before-close="cancel"
  >
    <info-table ref="feeRelatedInfoTable" v-if="form.id" :form.sync="form"></info-table>
    <div slot="footer">
      <el-button type="primary" @click="handleSave(0)">保存</el-button>
      <el-button @click="cancel">返回</el-button>
    </div>

  </ele-modal>
</template>
<script>
import infoTable from "./infoTable.vue";
import {finReceivableSaveAPI, getFinReceivableInfoAPI} from "@/api/financialManage/receivableManage";

export default {
  name: "collectionDialog",
  components: {
    infoTable
  },
  props: {
    collectionDialogFlag: {
      type: Boolean,
      default: false
    },
  },
  computed: {},
  data() {
    return {
      dialogType: '',
      title: '',
      form: {
        id: '',
      },
      rules: {}
    }
  },
  created() {

  },
  methods: {
    //初始化
    async init(row = {}, type) {
      this.title = '收款'
      this.dialogType = type

      await this.getInfo(row.id)

    },
    //获取详情
    async getInfo(id) {
      this.form = await getFinReceivableInfoAPI(id)
    },
    //
    async handleSave() {
      let detailList = await this.$refs.feeRelatedInfoTable.getTableValidate()
     await finReceivableSaveAPI(detailList)
      this.$message.success('操作成功')
      this.done()
      this.cancel()
    },
    //刷新主列表数据
    done() {
      this.$emit('reload')
    },
    //关闭弹窗
    cancel() {
      this.$emit('update:collectionDialogFlag', false)
    }
  }
}
</script>
<style scoped lang="scss">

</style>
