<!--审核意见信息列表-->
<template>
  <div>
    <dialog-edit :visible.sync="dialogVisible" :title="$t('expressFileReceiveList.auditMindList')"
                 width="800px" :api="api" :form="form" :editModel="editModel">
      <data-table :api="api" :operateBtnLayout="operateBtnLayout" :columns="columns" :loadCount="loadCount"
                  :menuFlag="false" :sourceData.sync="sourceData" :queryParas="queryParas" loadPage="getAuditMindList" loadList="getAuditDetail"
                  :headTitle="$t('expressFileReceiveList.auditMind')" :showPage="showPage">
      </data-table>
    </dialog-edit>
  </div>
</template>

<script>
import { DialogEdit, DataTable } from 'newepoch-components'
import BaseEditPage from '@/pages/baseEditPage'
import expressApi from '@/api/expressApi'
import * as format from '@/filters/index'
export default {
  extends: new BaseEditPage(''),
  components: {
    DialogEdit,
    DataTable
  },
  data () {
    return {
      loadCount: 0,
      queryParas: {
        pageIndex: 1,
        pageSize: 10
      },
      operateBtnLayout: '',
      sourceData: [],
      columns: [
        {
          prop: 'fileName',
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.fileName,
          align: 'left',
          width: '200px'
        },
        {
          prop: 'auditOpinions',
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.auditMind,
          align: 'center',
          width: '200px'
        },
        {
          prop: 'auditTime',
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.auditTime,
          align: 'center',
          width: '150px',
          format: (row) => { return format.formatDateMinute(row.auditTime) }
        },
        {
          prop: 'auditorName',
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.auditor,
          align: 'center',
          width: '150px'
        }
      ]
    }
  },
  mounted () {
  },
  computed: {
    api: function () {
      if (this.editModel !== 'E') {
        return expressApi.assetsfileReceiveApi
      } else {
        return undefined
      }
    },
    showPage: function () {
      return this.editModel !== 'E'
    }
  },
  methods: {
  },
  watch: {
    dialogVisible (newVal) {
      if (newVal) {
        if (this.editModel !== 'E') {
          this.$set(this.queryParas, 'assetInfoId', this.form.assetInfoId)
          this.$set(this.queryParas, 'fileCode', this.form.fileCode)
          if (!this.form.fileCode) {
            this.error('文件编号不能为空')
          } else {
            this.$nextTick(() => {
              this.loadCount = this.loadCount + 1
            })
          }
        } else {
          this.$set(this.queryParas, 'enterpriseId', this.form.debtorId)
          this.$set(this.queryParas, 'fileCode', this.form.fileCode)
          if (!this.form.fileCode) {
            this.error('文件编号不能为空')
          } else {
            expressApi.assetsfileReceiveApi.getAuditDetail(this.queryParas).then(res => {
              if (res && res.data) {
                res.data.forEach(it => {
                  if (it.auditItemCommonFileInfoDtos) {
                    it.auditItemCommonFileInfoDtos.forEach(it1 => {
                      this.sourceData.push({
                        fileName: it1.fileName,
                        auditOpinions: it1.auditOpinions,
                        auditTime: it1.auditTime,
                        auditorName: it1.auditorName
                      })
                    })
                  }
                })
              }
            })
          }
        }
      } else {
        this.sourceData = []
      }
    }
  }
}
</script>
