<template>
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      v-dialogDrag
      width="800px"
      @close="close"
      @keyup.enter.native="doSubmit"
      :visible.sync="visible">
      <el-form size="middle"
               :model="inputForm"
               ref="inputForm"
               :class="method==='view'?'readonly':''"
               :disabled="method==='view'"
               v-loading="loading"
               label-width="150px">
        <el-row  :gutter="15">
          <el-col :span="12">
            <el-form-item label="客户名称" prop="customerName"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.customerName" placeholder="请填写客户名称"     ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目名称" prop="projectName"
                          :rules="[
                  {required: true, message:'项目名称不能为空', trigger:'blur'}
                 ]">
              <el-input v-model="inputForm.projectName" placeholder="请填写项目名称"     ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="评估目的" prop="evaluationObjective"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.evaluationObjective" placeholder="请填写评估目的"     ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目类型" prop="projectType"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.projectType" placeholder="请填写项目类型"     ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="评估基准日" prop="evaluationBaseDateUi"
                          :rules="[

                 ]">
              <!--              {required: true, message:'评估基准日不能为空', trigger:'blur'}-->
              <!--              <el-input v-model="inputForm.evaluationBaseDate" placeholder="请填写评估基准日"     ></el-input>-->
              <el-date-picker
                style="width:100%;"
                v-model="inputForm.evaluationBaseDateUi"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="评估报告日" prop="evaluationReportDateUi"
                          :rules="[

                 ]">
              <!--              {required: true, message:'评估报告日不能为空', trigger:'blur'}-->
              <!--              <el-input v-model="inputForm.evaluationReportDate" placeholder="请填写评估报告日"     ></el-input>-->
              <el-date-picker
                style="width:100%;"
                v-model="inputForm.evaluationReportDateUi"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="协议号" prop="protocolNum"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.protocolNum" placeholder="请填写协议号"     ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="文号" prop="documentNum"
                          :rules="[
                  {required: true, message:'文号不能为空', trigger:'blur'}
                 ]">
              <el-input v-model="inputForm.documentNum" placeholder="请填写文号"     ></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item prop="projectHead" :rules=" [{required: true, message: '项目负责人不能为空', trigger: 'blur'}]" label="项目负责人">
              <SelectUserTree
                ref="companyTree"
                :props="{
                    value: 'id',             // ID字段名
                    label: 'name',         // 显示名称
                    children: 'children'    // 子级字段名
                  }"
                :url="`/sys/user/treeUserDataAllOffice?type=2`"
                :value="inputForm.projectHead"
                :clearable="true"
                :accordion="true"
                :disabled="method==='view'"
                @getValue="(value) => {inputForm.projectHead=value}"/>
            </el-form-item>
          </el-col>


          <el-col :span="12">
            <el-form-item label="废旧物资评估(万元)" prop="waystEvaluation"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.waystEvaluation" placeholder="请填写废旧物资评估" @keyup.native="inputForm.waystEvaluation = twoDecimalPlaces(inputForm.waystEvaluation)"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="固定资产评估(万元)" prop="fixedAssetsEvaluation"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.fixedAssetsEvaluation" placeholder="请填写固定资产评估" @keyup.native="inputForm.fixedAssetsEvaluation = twoDecimalPlaces(inputForm.fixedAssetsEvaluation)"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="净资产评估" prop="netAssetsEvaluation"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.netAssetsEvaluation" placeholder="请填写净资产评估" @keyup.native="inputForm.netAssetsEvaluation = twoDecimalPlaces(inputForm.netAssetsEvaluation)"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="租金评估(万/年)" prop="rentEvaluation"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.rentEvaluation" placeholder="请填写租金评估" @keyup.native="inputForm.rentEvaluation = twoDecimalPlaces(inputForm.rentEvaluation)"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司法鉴定" prop="forensics"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.forensics" placeholder="请填写司法鉴定"     ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告收费(元)" prop="reportCharges"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.reportCharges" placeholder="请填写报告收费" @keyup.native="inputForm.reportCharges = twoDecimalPlaces(inputForm.reportCharges)"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item prop="currentDisposePerson" :rules=" [{trigger: 'blur'}]" label="当前处理人">
              <SelectUserTree
                ref="companyTree"
                :props="{
                    value: 'id',             // ID字段名
                    label: 'name',         // 显示名称
                    children: 'children'    // 子级字段名
                  }"
                :url="`/sys/user/treeUserDataAllOffice?type=2`"
                :value="inputForm.currentDisposePerson"
                :clearable="true"
                :accordion="true"
                :disabled="method==='view'"
                @getValue="(value) => {inputForm.currentDisposePerson=value}"/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="是否开票" prop="isInvoice"
                          :rules="[
                 ]">
              <el-radio-group v-model="inputForm.isInvoice">
                <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开票日期" prop="invoiceDateUi"
                          :rules="[
                 ]">
              <!--              {required: true, message:'开票日期不能为空', trigger:'blur'}-->
              <!--              <el-input v-model="inputForm.invoiceDate" placeholder="请填写开票日期"     ></el-input>-->
              <el-date-picker
                style="width:100%;"
                v-model="inputForm.invoiceDateUi"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预估/实际收费(万元）" prop="actualCharges"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.actualCharges" placeholder="请填写预估/实际收费" @keyup.native="inputForm.actualCharges = twoDecimalPlaces(inputForm.actualCharges)"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同是否存档" prop="isContractArchive"
                          :rules="[
                 ]">
              <!--              <el-input v-model="inputForm.isContractArchive" placeholder="请填写合同是否存档"     ></el-input>-->
              <el-radio-group v-model="inputForm.isContractArchive">
                <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="底稿是否完好" prop="isPapersIntact"
                          :rules="[
                 ]">
              <!--              <el-input v-model="inputForm.isPapersIntact" placeholder="请填写底稿是否完好"     ></el-input>-->
              <el-radio-group v-model="inputForm.isPapersIntact">
                <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="底稿是否归档" prop="isPapersArchive"
                          :rules="[
                 ]">
              <!--              <el-input v-model="inputForm.isPapersArchive" placeholder="请填写底稿是否归档"     ></el-input>-->
              <el-radio-group v-model="inputForm.isPapersArchive">
                <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报销外勤天数" prop="opsAmount"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.opsAmount" placeholder="请填写报销外勤天数" @keyup.native="inputForm.opsAmount = positiveInteger(inputForm.opsAmount)"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="外勤是否已经报销" prop="isOpsReimbursement"
                          :rules="[
                 ]">
              <!--              <el-input v-model="inputForm.isOpsReimbursement" placeholder="请填写外勤是否已经报销"     ></el-input>-->
              <el-radio-group v-model="inputForm.isOpsReimbursement">
                <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否已经报销提成" prop="isCommissionReimbursement"
                          :rules="[
                 ]">
              <!--              <el-input v-model="inputForm.isCommissionReimbursement" placeholder="请填写是否已经报销提成"     ></el-input>-->
              <el-radio-group v-model="inputForm.isCommissionReimbursement">
                <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="已报销金额" prop="reimbursementAmount"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.reimbursementAmount" placeholder="请填写已报销金额" @keyup.native="inputForm.reimbursementAmount = twoDecimalPlaces(inputForm.reimbursementAmount)"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="未报销金额" prop="unreimbursedAmount"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.unreimbursedAmount" placeholder="请填写未报销金额" @keyup.native="inputForm.unreimbursedAmount = twoDecimalPlaces(inputForm.unreimbursedAmount)"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报销单号" prop="reimbursementNum"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.reimbursementNum" placeholder="请填写报销单号"     ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报销日期" prop="reimbursementDateUi"
                          :rules="[
                 ]">
              <!--              <el-input v-model="inputForm.reimbursementDate" placeholder="请填写报销日期"     ></el-input>-->
              <el-date-picker
                style="width:100%;"
                v-model="inputForm.reimbursementDateUi"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="签字评估师1" prop="evaluationPersonOne"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.evaluationPersonOne" placeholder="请填写签字评估师1"     ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="签字评估师2" prop="evaluationPersonTwo"
                          :rules="[
                 ]">
              <el-input v-model="inputForm.evaluationPersonTwo" placeholder="请填写签字评估师2"     ></el-input>
            </el-form-item>
          </el-col>

          <!--<el-col :span="12">
            <el-form-item label="项目状态" prop="status"
                          :rules="[
                 ]">
&lt;!&ndash;              <el-input v-model="inputForm.status" placeholder="请填写项目状态"     ></el-input>&ndash;&gt;
              <el-select v-model="inputForm.status" placeholder="请选择" style="width:100%;">
                <el-option
                  v-for="item in $dictUtils.getDictList('project_status')"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>-->

        </el-row>
        <el-divider content-position="left"><i class="el-icon-document"></i> 附件信息</el-divider>
        <el-upload ref="upload" style="display: inline-block; margin-left: 5em; :show-header='status'" action=""
                   :limit="999" :http-request="httpRequest"
                   multiple
                   :on-exceed="(files, fileList) =>{
                      $message.warning(`当前限制选择 999 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
                     }"
                   :on-remove="handleRemove"
                   :show-file-list="false"
                   :on-change="changes"
                   :on-progress="uploadVideoProcess"
                   :file-list="filesArra2">
          <el-button type="info" size="mini" v-if="inputForm.permissionFlag&&showVi" >点击上传</el-button>
        </el-upload>
        <div style="height: calc(100% - 80px);margin-top: 10px">
          <!-- 进度条 -->
          <el-progress style="margin-left: 5em" v-if="progressFlag" :percentage="loadProgress"></el-progress>
          <vxe-table
            style="margin-left: 5em"
            border="inner"
            auto-resize
            resizable
            :loading="loading"
            size="small"
            ref="projectTable"
            show-header-overflow
            show-overflow
            highlight-hover-row
            :menu-config="{}"
            :print-config="{}"
            @sort-change="sortChangeHandle"
            :sort-config="{remote:true}"
            :data="dataListNew"
            :checkbox-config="{}">
            <vxe-column type="seq" width="40"></vxe-column>
            <vxe-column title="文件名称" field="name">
              <template slot-scope="scope">
                <!--                <div v-if="ifName(scope.row) === true">-->
                <!--                  <el-image-->
                <!--                    style="width: 100px; height: 100px"-->
                <!--                    :src="src"-->
                <!--                    :preview-src-list="srcList" lazy>-->
                <!--                  </el-image>-->
                <!--                </div>-->
                <!--                <div v-else>-->
                <!--                  <el-link  type="primary" :underline="false" @click="showFile(scope.row)">{{scope.row.name}}</el-link>-->
                <!--                </div>-->
                <el-link  type="primary" :underline="false" @click="showFile(scope.row)">{{scope.row.name}}</el-link>
              </template>
            </vxe-column>
            <vxe-column title="创建人" field="createBy"></vxe-column>
            <vxe-column title="创建时间" field="createDate"></vxe-column>
            <!--            <vxe-column title="文件描述" field="description"></vxe-column>-->
            <vxe-column title="操作" width="200px" fixed="right" align="center">
              <template  slot-scope="scope">
                <el-button type="text"  icon="el-icon-edit" size="small" @click="toHref(scope.row)">下载</el-button>
                <el-button type="text"  icon="el-icon-delete" size="small" v-if="inputForm.permissionFlag&&showVi" @click="deleteMsgById(scope.row, scope.$rowIndex)">删除</el-button>
              </template>
            </vxe-column>
          </vxe-table>
        </div>

      </el-form>
      <el-image-viewer
        v-if="showViewer"
        :on-close="closeViewer"
        :url-list="[url]"
        zIndex="9999"/>
      <span slot="footer" class="dialog-footer">
      <el-button  @click="close()" icon="el-icon-circle-close">关闭</el-button>
      <el-button  type="primary" v-if="method != 'view'"  @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
    </span>
    </el-dialog>
  </div>
</template>

<script>
  import ProjectService from '@/api/sys/ProjectService'
  import SelectUserTree from '@/views/modules/utils/treeUserSelect'
  import OSSSerive, {
    httpRequest,
    handleRemove,
    fileName
  } from '@/api/sys/OSSService'
  import moment from 'moment'
  import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
  export default {
    data () {
      return {
        dataList: [],
        dataListNew: [],
        title: '',
        method: '',
        visible: false,
        loading: false,
        inputForm: {
          permissionFlag: '', // 判断是否为当前登录人参数
          customerName: '',
          projectName: '',
          evaluationObjective: '',
          projectType: '',
          evaluationBaseDate: '',
          evaluationBaseDateUi: '',
          evaluationReportDate: '',
          evaluationReportDateUi: '',
          protocolNum: '',
          documentNum: '',
          projectHead: '',
          waystEvaluation: '',
          fixedAssetsEvaluation: '',
          netAssetsEvaluation: '',
          rentEvaluation: '',
          forensics: '',
          reportCharges: '',
          currentDisposePerson: '',
          isInvoice: '',
          invoiceDate: '',
          invoiceDateUi: '',
          actualCharges: '',
          isContractArchive: '',
          isPapersIntact: '',
          isPapersArchive: '',
          opsAmount: '',
          isOpsReimbursement: '',
          reimbursementAmount: '',
          unreimbursedAmount: '',
          reimbursementNum: '',
          reimbursementDate: '',
          reimbursementDateUi: '',
          evaluationPersonOne: '',
          evaluationPersonTwo: '',
          status: '',
          assessReportMessage: '',
          assessBaseMessage: '',
          invoiceMessage: '',
          isCommissionReimbursement: '',
          itemType: '',
          workAttachments: []
        },
        filesArra2: [],
        fileList: [],
        isFlag: true,
        showViewer: false, // 显示查看器
        url: '',
        rowurl: '',
        src: '',
        showVi: true,
        loadProgress: 0, // 动态显示进度条
        progressFlag: false // 关闭进度条
      }
    },
    components: {
      ElImageViewer,
      SelectUserTree
    },
    projectService: null,
    ossService: null,
    created () {
      this.ossService = new OSSSerive()
      this.projectService = new ProjectService()
    },
    methods: {

      uploadVideoProcess (event, file, fileList) {
        this.progressFlag = true // 显示进度条
        this.loadProgress = parseInt(event.percent) // 动态获取文件上传进度
        if (this.loadProgress >= 100) {
          this.loadProgress = 100
          setTimeout(() => { this.progressFlag = false }, 1000) // 一秒后关闭进度条
        }
      },
      async toHref (row) {
        const link = document.createElement('a')
        if (row.id === null || row.id === undefined || row.id === '') {
          await this.ossService.getTemporaryUrl(row.raw.url).then((data) => {
            const url = data.data // 完整的url则直接使用
            // 这里是将url转成blob地址，
            fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
              link.href = URL.createObjectURL(blob)
              link.download = row.name || '' // 下载文件的名字
              // a.download = url.split('/')[url.split('/').length -1] //  // 下载文件的名字
              document.body.appendChild(link)
              link.click()
              // 在资源下载完成后 清除 占用的缓存资源
              window.URL.revokeObjectURL(link.href)
              document.body.removeChild(link)
            })
          })
        } else {
          const url = row.temporaryUrl // 完整的url则直接使用
          // 这里是将url转成blob地址，
          fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
            link.href = URL.createObjectURL(blob)
            link.download = row.name || '' // 下载文件的名字
            // a.download = url.split('/')[url.split('/').length -1] //  // 下载文件的名字
            document.body.appendChild(link)
            link.click()
            // 在资源下载完成后 清除 占用的缓存资源
            window.URL.revokeObjectURL(link.href)
            document.body.removeChild(link)
          })
        }
      },
      onPreview (url) {
        this.url = url
        this.showViewer = true
      },
      // 关闭查看器
      closeViewer () {
        this.url = ''
        this.showViewer = false
      },
      init (method, id) {
        this.dataList = []
        this.dataListNew = []
        this.ossService.findFileList(id).then(({data}) => {
          data.forEach((item) => {
            item.name = item.attachmentName
            // item.createBy = item.createBy
            // item.createDate = item.createDate
            // item.description = item.description
            this.dataList.push(item)
            this.dataListNew.push(item)
          })
        })
        this.method = method
        this.inputForm = {
          customerName: '',
          projectName: '',
          evaluationObjective: '',
          projectType: '',
          evaluationBaseDate: '',
          evaluationBaseDateUi: '',
          evaluationReportDate: '',
          evaluationReportDateUi: '',
          protocolNum: '',
          documentNum: '',
          projectHead: '',
          waystEvaluation: '',
          fixedAssetsEvaluation: '',
          netAssetsEvaluation: '',
          rentEvaluation: '',
          forensics: '',
          reportCharges: '',
          currentDisposePerson: '',
          isInvoice: '',
          invoiceDate: '',
          invoiceDateUi: '',
          actualCharges: '',
          isContractArchive: '',
          isPapersIntact: '',
          isPapersArchive: '',
          opsAmount: '',
          isOpsReimbursement: '',
          reimbursementAmount: '',
          unreimbursedAmount: '',
          reimbursementNum: '',
          reimbursementDate: '',
          reimbursementDateUi: '',
          evaluationPersonOne: '',
          evaluationPersonTwo: '',
          status: '',
          assessReportMessage: '',
          assessBaseMessage: '',
          invoiceMessage: '',
          isCommissionReimbursement: '',
          itemType: ''
        }
        this.inputForm.id = id
        if (method === 'add') {
          this.inputForm.permissionFlag = true
          this.title = `新建项目`
        } else if (method === 'edit') {
          this.title = '修改项目信息'
        } else if (method === 'view') {
          this.showVi = false
          this.title = '查看项目详情'
        }
        this.visible = true
        this.loading = false
        this.$nextTick(() => {
          this.$refs.upload.clearFiles()
          this.$refs.inputForm.resetFields()
          if (method === 'edit' || method === 'view') { // 修改或者查看
            this.loading = true
            this.projectService.queryById(this.inputForm.id).then(({data}) => {
              this.inputForm = this.recover(this.inputForm, data)
              this.inputForm.evaluationBaseDateUi = data.evaluationBaseDate
              this.inputForm.evaluationReportDateUi = data.evaluationReportDate
              this.inputForm.invoiceDateUi = data.invoiceDate
              this.inputForm.reimbursementDateUi = data.reimbursementDate
              this.inputForm.permissionFlag = data.permissionFlag
              this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
              this.loading = false
            })
          }
        })
      },
      // 表单提交
      doSubmit () {
        if (this.progressFlag === true) {
          this.$message.warning('文件正在上传中,请稍等')
        }
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.inputForm.itemType = '2'
            this.inputForm.workAttachments = []
            this.dataListNew.forEach((item) => {
              if (item.id === null || item.id === undefined || item.id === '') {
                item.url = item.raw.url
              }
              item.attachmentFlag = 'projectRecords'
              item.fileSize = item.size
              item.attachmentName = item.name
              this.inputForm.workAttachments.push(item)
            })
            if (this.inputForm.evaluationReportDateUi === null || this.inputForm.evaluationReportDateUi === undefined || this.inputForm.evaluationReportDateUi === '') {
              this.inputForm.status = '1'
            } else {
              this.inputForm.status = '5'
            }
            this.projectService.save(this.inputForm).then(({data}) => {
              this.close()
              this.$message.success(data)
              this.$emit('refreshDataList')
              this.loading = false
            }).catch(() => {
              this.loading = false
            })
          }
        })
      },
      close () {
        this.$refs.inputForm.resetFields()
        this.visible = false
        this.showVi = true
      },
      async httpRequest (file) {
        await httpRequest(file, fileName(file), 'projectRecords')
      },
      handleRemove () {
        this.fileList = handleRemove()
      },
      changes (file, fileList) {
        this.dataListNew = []
        this.dataList.forEach((item) => {
          this.dataListNew.push(item)
        })
        fileList.forEach((item) => {
          item.createDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
          item.createBy = this.$store.state.user.name
          this.dataListNew.push(item)
        })
        const isLt2M = file.size / 1024 / 1024 < 300
        if (isLt2M === false) {
          this.$message.error('文件大小不能超过 ' + 300 + 'M !')
          this.fileList = []
          this.filesArra2 = []
        } else {
          // if (exnameFix(file, '1') === false) {
          //   this.fileList = []
          //   this.filesArra2 = []
          // }
        }
      },
      async showFile (row) {
        let suffix = row.name.substring(row.name.lastIndexOf('.') + 1)
        if (suffix === 'jpg' || suffix === 'png' || suffix === 'gif' || suffix === 'bmp' || suffix === 'jpeg') {
          if (row.url !== null && row.url !== undefined && row.url !== '') {
            this.onPreview(row.url)
            return
          } else {
            await this.ossService.getTemporaryUrl(row.raw.url).then((data) => {
              this.onPreview(data.data)
            })
            return
          }
        }
        if (row.url !== null && row.url !== undefined && row.url !== '') {
          if (suffix === 'pdf') {
            window.open('https://view.xdocin.com/xdoc?_xdoc=' + row.url, '_blank')
          } else if (suffix === 'rar' || suffix === 'zip' || suffix === 'jar' || suffix === '7z') {
            window.open('http://ow365.cn/?i=25008&furl=' + row.url, '_blank')
          } else {
            window.open('https://view.officeapps.live.com/op/view.aspx?src=' + row.url, '_blank')
          }
        } else if (row.raw.url !== null && row.raw.url !== undefined && row.raw.url !== '') {
          await this.ossService.getTemporaryUrl(row.raw.url).then((data) => {
            this.rowurl = data.data
          })
          if (suffix === 'pdf') {
            window.open('https://view.xdocin.com/xdoc?_xdoc=' + this.rowurl, '_blank')
          } else if (suffix === 'rar' || suffix === 'zip' || suffix === 'jar' || suffix === '7z') {
            window.open('http://ow365.cn/?i=25008&furl=' + this.rowurl, '_blank')
          } else {
            window.open('https://view.officeapps.live.com/op/view.aspx?src=' + this.rowurl, '_blank')
          }
        }
      },
      // 排序
      sortChangeHandle (column) {
        this.orders = []
        if (column.order != null) {
          this.orders.push({column: this.$utils.toLine(column.prop), asc: column.order === 'ascending'})
        }
        this.refreshList()
      },
      deleteMsgById (row, index) {
        this.dataListNew.splice(index, 1)
        if (row.id !== null && row.id !== '' && row.id !== undefined) {
          this.ossService.deleteMsgById(row.id)
        }
      },
      twoDecimalPlaces (num) {
        let str = num.toString()
        var len1 = str.substr(0, 1)
        var len2 = str.substr(1, 1)
        // eslint-disable-next-line eqeqeq
        if (str.length > 1 && len1 == 0 && len2 != '.') {
          str = str.substr(1, 1)
        }
        // eslint-disable-next-line eqeqeq
        if (len1 == '.') {
          str = ''
        }
        // eslint-disable-next-line eqeqeq
        if (str.indexOf('.') != -1) {
          var str_ = str.substr(str.indexOf('.') + 1)
          // eslint-disable-next-line eqeqeq
          if (str_.indexOf('.') != -1) {
            str = str.substr(0, str.indexOf('.') + str_.indexOf('.') + 1)
          }
          if (str_.length > 4) {
            this.$message.warning(`金额小数点后只能输入四位，请正确输入！`)
            return (str = '')
          }
        }
        // eslint-disable-next-line no-useless-escape
        str = str.replace(/[^\d^\.]+/g, '') // 保留数字和小数点
        return str
      },
      positiveInteger (num) {
        let str = num.toString()
        var len1 = str.substr(0, 1)
        var len2 = str.substr(1, 1)
        // eslint-disable-next-line eqeqeq
        if (str.length > 1 && len1 == 0 && len2 != '.') {
          str = str.substr(1, 1)
        }
        // eslint-disable-next-line eqeqeq
        if (len1 == '.') {
          str = ''
        }
        // eslint-disable-next-line no-useless-escape
        str = str.replace(/[^\d^]+/g, '') // 保留数字
        return str
      }
    }
  }
</script>
<style scoped>
  .avatar{
    height: 100px;
  }
  .el-divider__text {
    font-weight: bold;
    font-size: 16px;
  }
</style>
