<template>
  <div class="edit-content">
    <div class="multiple-form" style="margin: 20px 0px;">
      <div>
        <div class="required">客户名称：</div>
        <div>
          <el-input placeholder="请输入客户名称" v-model="customerName" disabled></el-input>
        </div>
      </div>
    </div>
    <div class="info-title">基础资料清单</div>
    <div class="table-box">
      <el-table v-loading="loading" :data="tableData">
        <el-table-column type="index" label="序号"  width="50"></el-table-column>
        <el-table-column prop="profileName" label="资料名称">
          <template slot-scope="scope">
            <span>{{ scope.row.profileName }}</span>
            <span v-if="scope.$index < tableData.length - 3" style="color: #F56C6C"> *</span>
          </template>
        </el-table-column>
        <el-table-column prop="remark" label="说明"></el-table-column>
        <el-table-column prop="address" label="附件"  width="300">
          <template slot-scope="scope">
            <div :style="{'padding-top': disabled ?  '10px' : '10px', 'padding-bottom': disabled ?  '0px' : '10px'}">
              <cy-upload :disabled="disabled" :upload-params="uploadParams" size="mini" :ref="'fileList'+scope.$index" :file-data="scope.row.fileStorageList"></cy-upload>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
module.exports = {
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    deatailsInfo: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      customerName: '',
      loading: false,
      tableData: [],
      uploadParams: {
        mouldName: 'FinancialCustomer',
      }
    }
  },
  watch: {
    deatailsInfo: {
      handler(newV) {
        if(newV.id) {
          const data = JSON.parse(JSON.stringify(newV))
          const { customerName, financialBasicFileVos} = data
          this.customerName = customerName
          this.tableData = financialBasicFileVos
        }
      },
      immediate: true,
      deep: true
    }
  },
  // created() {
  //   this.uploadParams.id = this.$route.query.id
  // },
  methods: {
    getParams() {
      const { id, taskId } = this.$route.query
      const basicFiles = []
      this.tableData.forEach((item, index) => {
        const fileList =  this.$refs['fileList' + index].getFileLists
        basicFiles.push({
          id: item.id,
          financialBasicFileDicInfoId: item.financialBasicFileDicInfoId,
          fileStorageIdList: fileList.map(item => item.id )
        })
      })
      const params = {
        financialCustomerInfoId: id,
        taskId,
        basicFiles
      }
      return params
    }
  },
}
</script>

<style scoped>

</style>
