<template>
    <dialog-edit :visible.sync="dialogVisible"
                 :title="$t('traceMgr.confirmedDocumentScanReviewFeedback')"
                 :editModel="'V'"
                 :form="form"
                 :api="api"
                 :footerBtnShow="isFootView"
                 :appendToBody="true">
    <el-row>
        <payment-info :keyId="keyId" :title="$t('traceMgr.orderInfo')"></payment-info>
    </el-row>
    <el-row class="textRight threeBtn">
        <el-button size="medium" type="primary" class="iconfont "  @click="loadDown()"> {{$t('traceMgr.downloadingData')}}</el-button>
        <el-button size="medium" type="primary" class="iconfont "  @click="save()"> {{$t('common.save')}}</el-button>
    </el-row>
    <!--律所审核 第2次反馈-->
    <el-row>
        <el-tabs>
            <el-tab-pane :label="$t('traceMgr.fileListTableName')"></el-tab-pane>
        </el-tabs>
    </el-row>
    <data-table
            :border="true"
            :stripe="true"
            :api="api"
            :loadCount.sync="loadCount"
            :columns="columns"
            :loadList="loadList"
            @getTableData="transData"
            :operateBtnLayout="''"
            :sourceData="sourceData"
            :showSelection="true"
            :showPage="false">
        <template slot="operate" slot-scope="scope">
            <btn-upload  :uploadApi="uploadApi" :rowData="scope.data.row" @click="passRowFileId(scope.data.row)" @uploadSuccess="uploadSuccess"
                        :classType="true"></btn-upload>
            <btn-download :fileID="scope.data.row.fileId" :title="$t('traceMgr.downloadArchive')"></btn-download>
        </template>
        <template slot="headButton">

        </template>>
        <template slot="commissionerRemarks" slot-scope="scope">
            <el-input type="textarea"
                      :rows="1"
                      :placeholder="$t('common.MultilineInput')" size="mini" v-model="scope.data.row.factoringCommissionerFeedback"></el-input>
        </template>

    </data-table>
        <!--话术-->
        <el-row>supplemenFile
            <el-row class="head_msg padding-content title" v-for="(employee,index) in employees" :key="index">
              <el-col :span="3" v-if="employee.employeeName">
                <!--联系人-->
                <span>{{$t('common.contact')}}:&nbsp;</span>
                <span>{{employee.employeeName}}</span>
              </el-col>
              <el-col :span="3" v-if="employee.telephone">
                <!--联系人电话-->
                <span>{{$t('common.phoneNum')}}:&nbsp;</span>
                <span>{{employee.telephone}}</span>
              </el-col>
            </el-row>
            <!--话术组件-->
            <el-row class="body_msg">
                <el-col :span="1" class="text-center">
                    <span>{{$t('common.discourse')}}</span>
                </el-col>
                <el-col :span="10">
                    <speech-craft-input :autosize="autosize" v-model="discourse" ></speech-craft-input>
                </el-col>
            </el-row>
        </el-row>
        <el-row class="text-center">
            <auth-button type="primary" size="medium" :label="$t('common.complete')" ></auth-button>
        </el-row>
        </dialog-edit>
</template>
<script>
import { DataTable, btnDownload, btnUpload, paymentInfo, speechCraftInput, authButton } from 'newepoch-components'
import tracemgrApi from '@/api/tracemgrApi'
import BasePage from '@/pages/basePage'
import { UPLOAD_API } from '@/constant.js'
import fileApi from '@/api/fileApi'
import { downFile } from '@/utils/devUtils'
import * as format from '@/filters/index'
import mixin from '@/pages/mixin'
export default {
  extends: new BasePage('fileList'),
  mixins: [mixin],
  name: 'fileList',
  components: {
    DataTable,
    fileApi,
    downFile,
    format,
    speechCraftInput,
    paymentInfo,
    tracemgrApi,
    authButton,
    UPLOAD_API,
    btnDownload,
    btnUpload
  },
  props: {
    assetCode: {
      type: String
    }
  },
  data () {
    return {
      employees: [],
      uploadApi: UPLOAD_API,
      loadList: 'getList',
      loadCount: 0,
      isFootView: false,
      form: {},
      autosize: {
        minRows: 8,
        maxRows: 10
      },
      discourse: '',
      sourceData: [],
      columns: [
        // 任务类型
        {
          prop: 'taskType',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.taskType,
          width: 140
        },
        // 补寄类型
        {
          prop: 'name',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.supplementaryType,
          width: 140
        },
        // 文件名称
        {
          prop: 'fileName',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.fileName,
          width: 190
        },
        // 审核意见
        {
          prop: 'auditOpinion',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.auditOpinion,
          width: 190
        },
        // 补寄份数
        {
          prop: 'quantityOfSupplement',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.quantityOfSupplement,
          width: 90
        },
        // 截至时间
        {
          prop: 'deadline',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].common.deadline,
          width: 90
        },
        // 操作
        {
          prop: 'operate',
          align: 'center',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].common.operate,
          width: 140,
          slot: true
        },
        // 区域专员反馈
        {
          prop: 'commissionerRemarks',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.CommissionerRemarks,
          width: 190,
          slot: true
        },
        // 审核人员
        {
          prop: 'auditors',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.auditor,
          width: 140
        },
        // 处理状态
        {
          prop: 'address',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.processingStatus,
          width: 140
        }
      ]
    }
  },
  computed: {
    api () {
      return tracemgrApi['supplemenFileInPool']
    }
  },
  mounted: function () {
    this.handleFilter()
  },
  watch: {
    visible: {
      handler: function (newValue) {
        if (newValue) {
          this.$nextTick(() => {
            // 获取联系人信息
            tracemgrApi['onlineAuditTaskDialog'].getEmployeeInfos({ 'assetCode': this.assetCode }).then(res => {
              this.employees = res.data
            })
          })
        }
      }
    }
  },
  methods: {
    passRowFileId (row) {
      alert(row)
    },
    transData (data) {
      this.$emit('submitData', data)
    },
    uploadSuccess (returnData, rowData) {
      this.success(this.$i18n.messages[this.$i18n.locale].traceMgr.file + returnData.fileName + this.$i18n.messages[this.$i18n.locale].common.uploadSuccess)
      // console.log(rowData)
      rowData.fileId = returnData.fileID
    },
    loadDown: function () {
      // alert('下载')
    },
    save: function () {
      // alert('保存')
    }
  }
}
</script>
