<!-- 新增、编辑 -->
<template>
  <cg-dialog-edit ref="dialogEdit"
                  :newTitle="newTitle"
                  :visible="visible"
                  :title="dislogTitle"
                  :editModel="editModel"
                  :autoClose="autoClose"
                  :form="form"
                  :api="api"
                  :formRules="formRules"
                  :width="width"
                  :saveFlag="saveFlag"
                  @close="close"
                  @onSave="onSave">
    <!-- form元素（元素指向必须和表单对象指向是同一个） -->
    <dym-form :componentList="componentList"
              :formValue.sync="form"
              @checkChange="checkChange"
              @selectChanged="selectChanged"></dym-form>
      <!-- 附件 -->
      <el-form-item :spen="24"
                    :gutter="20"
                    label-width="125px"
                    v-for="(flieData, index) in accessoryExtList"
                    :key="index"
                    :label="index === 0 ? $t('feedbackMaterialIndex.relatedAccessories') : ''"
                    prop="fileName">
        <el-col :span="4">
          <el-input v-model="flieData.fileName"
                    size="medium"
                    :disabled="true"></el-input>
          <!-- :placeholder="$t('feedbackMaterialIndex.attachment')" -->
          <el-input v-model="flieData.fileId"
                    v-show="false"></el-input>
        </el-col>
        <!-- 删除 -->
        <auth-button type="danger"
                     v-if="editModel !== 'V'"
                     style="margin-left:9px"
                     class="iconCircle pssc-css"
                     icon="iconfont iconycjian"
                     v-show="accessoryExtList.length > 1 || flieData.fileName !== ''"
                     :title="$t('common.del')"
                     :size="'medium'"
                     @click="fileDeleteItem(accessoryExtList, index, accessoryExtList.length)"></auth-button>
        <!-- 重新上传 -->
        <btn-upload :uploadApi="uploadApi"
                    v-if="editModel !== 'V'"
                    style="margin: 0 0 0 9px"
                    icon="iconfont iconzhongxinshangchuan"
                    :title="$t('common.reUpload')"
                    :classType="true"
                    @uploadSuccess="uploadSuccess(index, $event)"
                    v-show="flieData.fileName !== ''"></btn-upload>
        <!-- 下载 -->
        <btn-download :size="'small'"
                      :fileID="flieData.fileId"
                      style="margin-left:9px"
                      :title="$t('common.downLoad')"
                      v-show="flieData.fileName !== ''"></btn-download>
        <!-- 上传 -->
        <btn-upload :uploadApi="uploadApi"
                    v-if="editModel !== 'V'"
                    style="margin-left:9px;margin-right:0px"
                    :classType="true"
                    :title="$t('common.upload')"
                    @uploadSuccess="uploadSuccess(index, $event)"
                    v-show="flieData.fileName === ''"></btn-upload>
        <!-- 新增 -->
        <auth-button :title="$t('feedbackMaterialIndex.add')"
                     v-if="editModel !== 'V'"
                     style="margin-left:9px"
                     class="iconCircle"
                     icon="iconfont iconzengjia"
                     :size="'medium'"
                     @click="fileAddItem(accessoryExtList, index)"
                     v-show="accessoryExtList.length === index + 1"></auth-button>
    </el-form-item>
    <!-- 导出 -->
    <btn-export slot="footer"
                btnSize="medium"
                type="CREATE"
                templateCode="zlsh001"
                icon=""
                :beforeExport="beforeExport"
                :btnName="$t('common.export')"
                :queryParas="queryParas"></btn-export>
    <!-- 分析 -->
    <auth-button slot="footer"
                 v-if="editModel!=='V' && analysisModelShow"
                 size="medium"
                 type="primary"
                 :label="$t('feedbackMaterialIndex.analyze')"
                 @click="openAnalyze"></auth-button>
    <!-- 保存 -->
    <auth-button slot="footer"
                 v-if="editModel!=='V'"
                 size="medium"
                 type="primary"
                 :label="$t('common.saveBtn')"
                 @click="saveAction"></auth-button>
    <!-- 保存并继续添加 -->
    <auth-button slot="footer"
                 v-if="editModel==='C'"
                 size="medium"
                 type="primary"
                 :label="$t('common.saveandadd2')"
                 @click="saveandadd"></auth-button>
  </cg-dialog-edit>
</template>

<script>
import feedbackMaterialApi from '@/api/assetaudit/feedbackMaterial/feedbackMaterialApi'
import reviewmaterialApi from '@/api/assetaudit/reviewMaterialApi'
import { parseTime } from '@/filters/index.js'
import { mapGetters } from 'vuex'
import { UPLOAD_API } from '@/constant'
import { dymForm, authButton, btnUpload, btnDownload, btnExport } from 'newepoch-components'
import CgDialogEdit from '@/components/element/assetaudit/CgDialogEdit'
import SelectReviewMaterialIndex from '@/components/element/assetaudit/SelectReviewMaterialIndex'
import SelectComplianceAcceptor from '@/components/element/assetaudit/SelectComplianceAcceptor'
import RepositoryList from '@/components/element/assetaudit/repositoryList'
export default {
  components: {
    btnExport,
    btnDownload,
    btnUpload,
    authButton,
    SelectComplianceAcceptor,
    SelectReviewMaterialIndex,
    CgDialogEdit,
    dymForm,
    RepositoryList
  },
  computed: {
    // userId（用户的ID）； user（用户的所有信息）
    ...mapGetters(['userId', 'user', 'userDropdownOption', 'payCodeDropdownOption'])//
  },
  props: {
    // 付款确认书选项
    payCodeOption: {
      type: Array,
      default () {
        return []
      }
    },
    item: {
      type: Object,
      default () {
        return {}
      }
    },
    tableData: {
      type: Array,
      default () {
        return []
      }
    },
    showBtn: {
      type: Boolean,
      default () {
        return false
      }
    },
    editModel: {
      type: String,
      default: 'C'
    }
  },
  data () {
    return {
      analysisModelShow: true, // 分析按钮显示（编辑部分）
      newTitle: '',
      editPayCode: true,
      czFrom: true,
      keyId: '',
      queryParas: {},
      saveFlag: false,
      onlyAdd: false,
      api: reviewmaterialApi.createReviewMaterialIndex,
      uploadApi: UPLOAD_API, // 上传文件api
      visible: false,
      autoClose: true,
      dislogTitle: '',
      showDetail: true,
      form: {
        payCodeSearchData: [],
        productName: '',
        productNameId: '',
        reviewStatus: 0,
        analysisStatus: 0,
        reviewNo: '',
        payCode: '',
        businessType: '',
        gysId: '',
        gysName: '',
        xmgsId: '',
        xmgsName: '',
        inspectionTime: '',
        reviewPromoterId: '',
        reviewPromoterName: '',
        committeePrincipalId: '',
        committeePrincipal: '',
        committeeMemberNamesArray: [],
        registrarId: '',
        registrar: '',
        status: '01',
        problemSummary: '',
        problemDesc: '',
        reviewConclusion: '',
        remark: '',
        accessoryExtDtoList: [] // 附件提交数据
      },
      width: '1200px',
      accessoryExtList: [ // 附件
        {
          fileId: '',
          fileName: ''
        }
      ],
      formRules: { // 表单正则
        reviewPromoterId: [
          { required: true, message: '请选择发起负责人', trigger: 'change' }
        ],
        committeePrincipalId: [
          { required: true, message: '请选择委员会负责人', trigger: 'change' }
        ],
        committeeMemberNamesArray: [
          { required: true, message: '请选择评审委员会人员', trigger: 'change' }
        ],
        registrarId: [
          { required: true, message: '请选择记录者', trigger: 'change' }
        ],
        status: [
          { required: true, message: '请选择状态', trigger: 'change' }
        ],
        problemSummary: [
          { required: true, message: '请输入问题概要', trigger: ['blur', 'change'] }
        ],
        problemDesc: [
          { required: true, message: '请输入问题描述', trigger: ['blur', 'change'] }
        ],
        reviewConclusion: [
          { required: false, message: '请输入评审结论', trigger: ['blur', 'change'] }
        ]
      },
      componentList: [ // 表单元素
        // 评审编号
        {
          value: 'reviewNo',
          disabled: true,
          componentName: 'el-input',
          label: this.$t('reviewMaterialIndex.reviewNo'),
          labelWidth: '125px',
          name: 'reviewNo',
          placeholder: this.$t('common.pleaseInput'),
          cols: [8, 8, 8, 8],
          prop: 'reviewNo'
        },
        // 付款确认书
        {
          maxlength: 64,
          value: 'payCode',
          disabled: false,
          clearable: true,
          componentName: 'el-input',
          label: this.$t('feedbackMaterialIndex.payCode'),
          labelWidth: '125px',
          name: 'payCode',
          placeholder: this.$t('common.pleaseInput'),
          cols: [8, 8, 8, 8],
          prop: 'payCode'
        },
        // 产品类型
        {
          value: 'businessType',
          disabled: false,
          componentName: 'SelectDictionary',
          // dictTypeCode: 'BUSINESS_TYPE', // 原代码
          dictTypeCode: 'ZD0087', // 临时使用代码（ZD0087 外部接口使用字典值）
          label: this.$t('feedbackMaterialIndex.productType'),
          placeholder: this.$t('common.pleaseSelect'),
          labelWidth: '125px',
          name: 'businessType',
          cols: [8, 8, 8, 8],
          prop: 'businessType'
        },
        // 供应商名称（使用id查）
        {
          value: 'gysName',
          disabled: true,
          componentName: 'el-input',
          label: this.$t('reviewPersonSetupIndex.gysName'),
          placeholder: '',
          labelWidth: '125px',
          name: 'gysName',
          cols: [8, 8, 8, 8],
          prop: 'gysName'
        },
        // 项目公司名称
        {
          label: this.$t('reviewPersonSetupIndex.xmgsName'),
          placeholder: '',
          value: 'xmgsName',
          disabled: true,
          componentName: 'el-input',
          name: 'xmgsName',
          cols: [8, 8, 8, 8],
          labelWidth: '125px',
          prop: 'xmgsName'
        },
        // 评审时间
        {
          label: this.$t('reviewPersonSetupIndex.inspectionTime'),
          placeholder: this.$t('common.pleaseSelect'),
          value: 'inspectionTime',
          type: 'datetime',
          disabled: false,
          componentName: 'el-date-picker',
          cols: [8, 8, 8, 8],
          labelWidth: '125px',
          prop: 'inspectionTime',
          valueFormat: 'timestamp',
          format: 'yyyy-MM-dd HH:mm:ss'
        },
        // 发起负责人(调用)
        {
          value: 'reviewPromoterId',
          disabled: false,
          label: this.$t('reviewMaterialIndex.reviewPromoterName'),
          // placeholder: this.$t('reviewMaterialIndex.pleaseSelectTsry'),
          placeholder: this.$t('common.pleaseSelect'),
          componentName: SelectComplianceAcceptor,
          labelWidth: '125px',
          name: 'reviewPromoterId',
          cols: [8, 8, 8, 8],
          prop: 'reviewPromoterId'
        },
        // 委员会负责人(调用)
        {
          value: 'committeePrincipalId',
          disabled: false,
          label: this.$t('reviewMaterialIndex.committeePrincipal'),
          // placeholder: this.$t('reviewMaterialIndex.pleaseSelectTsry'),
          placeholder: this.$t('common.pleaseSelect'),
          componentName: SelectComplianceAcceptor,
          labelWidth: '125px',
          name: 'committeePrincipalId',
          cols: [8, 8, 8, 8],
          prop: 'committeePrincipalId'
        },
        // 评审委员会人员(调用)
        {
          value: 'committeeMemberNamesArray',
          disabled: false,
          label: this.$t('reviewMaterialIndex.committeeMemberNames'),
          // placeholder: this.$t('reviewMaterialIndex.pleaseSelectTsryDx'),
          placeholder: this.$t('common.pleaseSelect'),
          componentName: SelectComplianceAcceptor,
          labelWidth: '125px',
          name: 'committeeMemberNamesArray',
          cols: [8, 8, 8, 8],
          prop: 'committeeMemberNamesArray',
          multiple: true,
          collapseTags: true
        },
        // 记录者(调用)
        {
          value: 'registrarId',
          disabled: false,
          label: this.$t('reviewMaterialIndex.registrar'),
          // placeholder: this.$t('reviewMaterialIndex.pleaseSelectTsry'),
          placeholder: this.$t('common.pleaseSelect'),
          componentName: SelectComplianceAcceptor,
          labelWidth: '125px',
          name: 'registrarId',
          cols: [8, 8, 8, 8],
          prop: 'registrarId'
        },
        // 评审状态
        {
          value: 'status',
          componentName: 'SelectDictionary',
          dictTypeCode: 'APPRAISAL_STATUS',
          label: this.$t('reviewMaterialIndex.psStatus'),
          // placeholder: this.$t('reviewMaterialIndex.stateWs'),
          placeholder: this.$t('common.pleaseSelect'),
          labelWidth: '125px',
          name: 'status',
          cols: [8, 8, 8, 8],
          prop: 'status'
        },
        // 问题概要
        {
          maxlength: 500,
          value: 'problemSummary',
          componentName: 'el-input',
          type: 'textarea',
          label: this.$t('reviewMaterialIndex.problemSummary'),
          placeholder: this.$t('common.pleaseTextarea'),
          labelWidth: '125px',
          name: 'problemSummary',
          cols: [24, 24, 24, 24],
          prop: 'problemSummary',
          // autosize: { minRows: 2, maxRows: 3 }
          rows: 3
        },
        // 问题描述
        {
          maxlength: 500,
          value: 'problemDesc',
          componentName: 'el-input',
          type: 'textarea',
          label: this.$t('reviewMaterialIndex.problemDesc'),
          placeholder: this.$t('common.pleaseTextarea'),
          labelWidth: '125px',
          name: 'problemDesc',
          cols: [24, 24, 24, 24],
          prop: 'problemDesc',
          // autosize: { minRows: 2, maxRows: 3 }
          rows: 3
        },
        // 评审结论
        {
          maxlength: 500,
          value: 'reviewConclusion',
          componentName: 'el-input',
          type: 'textarea',
          label: this.$t('reviewMaterialIndex.reviewConclusion'),
          placeholder: this.$t('common.pleaseTextarea'),
          labelWidth: '125px',
          name: 'reviewConclusion',
          cols: [24, 24, 24, 24],
          prop: 'reviewConclusion',
          // autosize: { minRows: 2, maxRows: 3 }
          rows: 3
        },
        // 备注
        {
          maxlength: 500,
          value: 'remark',
          componentName: 'el-input',
          type: 'textarea',
          label: this.$t('reviewMaterialIndex.remark'),
          placeholder: this.$t('common.pleaseTextarea'),
          labelWidth: '125px',
          name: 'remark',
          cols: [24, 24, 24, 24],
          prop: 'remark',
          // autosize: { minRows: 2, maxRows: 3 }
          rows: 3
        }
      ]
    }
  },
  mounted () {
    this.visible = true
    this.setReviewNo()
    this.infoData()
    this.defaultUser()
  },
  methods: {
    // 付款确认书为空，清空输入框
    payCodeEmpty () {
      this.isHovePayCode = false
      // this.form.businessType = '' // 产品类型不需要清空（设置会影响手动设置产品类型被清空）
      this.form.payId = ''
      this.form.gysId = ''
      this.form.gysName = ''
      this.form.xmgsId = ''
      this.form.xmgsName = ''
      this.form.productNameId = ''
      this.form.productName = ''
      if (this.editModel !== 'V') {
        this.componentList[2].disabled = false
      }
    },
    // 付款确认书
    checkChange (valueKey, value) {
      if (value) {
        if (valueKey === 'payCode') {
          let queryArray = []
          queryArray.push(value)
          feedbackMaterialApi.assetbycode.create(queryArray).then(res => {
            if (res.data.length > 0) {
              let data = res.data[0]
              this.isHovePayCode = true
              this.form.payCode = data.assetCode
              this.form.businessType = data.productType.toString()
              this.form.payId = data.assetInfoId
              this.form.gysId = data.creditorId
              this.form.gysName = data.creditor
              this.form.xmgsId = data.debtorId
              this.form.xmgsName = data.debtor
              this.form.productNameId = data.projectId
              this.form.productName = data.projectName
              this.componentList[2].disabled = true
            } else {
              this.isHovePayCode = false
              this.form.businessType = ''
              this.form.payId = ''
              this.form.gysId = ''
              this.form.gysName = ''
              this.form.xmgsId = ''
              this.form.xmgsName = ''
              this.form.productNameId = ''
              this.form.productName = ''
              this.componentList[2].disabled = false
              this.$nextTick(() => {
                this.warning(this.$t('feedbackMaterialIndex.confirmationInvalid'))
              })
            }
          })
        }
      }
    },
    // 导出前检测
    beforeExport () {
      let data
      this.$refs['dialogEdit'].$refs['editForm'].validate((valid) => {
        if (valid) {
          data = true
        } else {
          data = false
        }
      })
      if (data) {
        return true
      } else {
        return false
      }
    },
    // 分析（新增部分条件）
    openAnalyze () {
      if (!(this.form.status === '02' && (this.form.reviewPromoterId === this.userId || this.form.registrarId === this.userId))) {
        this.$message({
          type: 'warning',
          message: this.$t('reviewMaterialIndex.analysisJudgment')
        })
        return
      }
      this.isAnalysis = true
      this.saveAction()
    },
    // 分析按键是否显示
    analysisPermi (row) {
      let data = {}
      let dataHand = {}
      let dataEnd = {}
      if (row.analysisStatus === '0') {
        if (!row.materialRygxExtDtoList) {
          return false
        }
        data = row.materialRygxExtDtoList.filter(item => item.handlePersonId === this.userId)
        if (data.length > 0) {
          dataHand = data.filter(item => item.handleStatus === '1')
          if (dataHand.length > 0) {
            dataEnd = dataHand.find(item => item.personType === '03' || item.personType === '04')
          }
        }
      }
      if (dataEnd && JSON.stringify(dataEnd) !== '{}') {
        return true
      } else {
        return false
      }
    },
    // 详情
    infoData () {
      if (this.editModel === 'C') {
        this.dislogTitle = this.$t('reviewMaterialIndex.addTitle')
        this.newTitle = this.$t('reviewMaterialIndex.autoTitle')
      } else if (this.editModel === 'E') {
        this.dislogTitle = this.$t('reviewMaterialIndex.editTitle')
        this.newTitle = this.$t('reviewMaterialIndex.autoTitle')
      } else if (this.editModel === 'V') {
        this.dislogTitle = this.$t('reviewMaterialIndex.viewTitle')
      }
      if (JSON.stringify(this.item) !== '{}') {
        this.form = Object.assign({}, JSON.parse(JSON.stringify(this.item)))
        if (this.form.inspectionTime === 631173600000) { // 评审时间为空过滤时间戳为空
          this.form.inspectionTime = ''
        }
        if (this.editModel === 'E') { // 编辑模式判断分析按钮显示条件（添加属性）人员类型（03,04,05）并且handleStatue为1
          // debugger
          if (this.analysisPermi(this.form)) { // 分析按钮显示判断（编辑部分）
            this.analysisModelShow = true
          } else {
            this.analysisModelShow = false
          }
        }
        if (this.form.payCode) {
          this.checkChange('payCode', this.form.payCode)
          this.componentList[2].disabled = true
        }
        if (this.item.accessoryExtDtoList.length > 0) { // 附件
          this.accessoryExtList = this.item.accessoryExtDtoList
        }
        if (this.editModel === 'V') {
          this.componentList[1].disabled = true
          this.componentList[2].disabled = true
          this.componentList[5].disabled = true
          this.componentList[6].disabled = true
          this.componentList[7].disabled = true
          this.componentList[8].disabled = true
          this.componentList[9].disabled = true
          this.componentList[10].disabled = true
          this.componentList[11].disabled = true
          this.componentList[12].disabled = true
          this.componentList[13].disabled = true
          this.componentList[14].disabled = true
        } else if (this.editModel === 'E') {
          this.keyId = this.item.keyId
        }
      }
    },
    // 评审编号
    setReviewNo () {
      if (this.editModel === 'C') {
        let data = { dictId: '02', dictTypeCode: 'NUM_RULE' }
        reviewmaterialApi.createReviewNo.setReviewNo(data).then(res => {
          this.form.reviewNo = res.data
        })
      }
    },
    // 获取下拉Option数据
    defaultUser () {
      let id = []
      if (this.editModel !== 'C') {
        let array = this.item.committeeMemberNames.split('、')
        if (array) {
          array.forEach(ele => {
            this.userDropdownOption.forEach(res => {
              if (res.nickName === ele) {
                id.push(res.accountId)
              }
            })
          })
          this.form.committeeMemberNamesArray = id
        }
        return
      }
      let userInfo = this.userDropdownOption.find(item => item.accountId === this.userId) // 登录者存在下拉表中，默认为登录者
      if (userInfo) {
        // this.$nextTick(() => { // 加上nextTick会导致 selectChanged 下拉触发失效
        this.$set(this.form, 'reviewPromoterId', userInfo.accountId)
        this.$set(this.form, 'reviewPromoterName', userInfo.nickName) // 直接赋值name
        this.$set(this.form, 'registrarId', userInfo.accountId)
        this.$set(this.form, 'registrar', userInfo.nickName) // 直接赋值name
        // this.form.reviewPromoterId = userInfo.accountId
        // this.form.reviewPromoterName = userInfo.nickName // 直接赋值name
        // this.form.registrarId = userInfo.accountId
        // this.form.registrar = userInfo.nickName // 直接赋值name
        // })
      }
    },
    // 删除上传栏
    fileDeleteItem (accessoryExtList, index, length) {
      if (length > 1) {
        accessoryExtList.splice(index, 1)
      } else {
        accessoryExtList[0].fileName = ''
        accessoryExtList[0].fileId = ''
      }
    },
    // 附件上传成功、赋值显示文件
    uploadSuccess (index, event) {
      this.accessoryExtList[index].fileId = event.fileID
      this.accessoryExtList[index].fileName = event.fileName
    },
    // 添加上传栏
    fileAddItem (accessoryExtList, index) {
      if (accessoryExtList[index].fileId !== '') {
        accessoryExtList.push({
          fileName: '',
          fileId: ''
        })
      } else {
        this.warning('请先上传文件')
      }
    },
    // 下拉触发
    selectChanged (obj, index) {
      if (obj.reviewPromoterIdInfo) {
        this.form.reviewPromoterId = obj.reviewPromoterIdInfo.accountId
        this.form.reviewPromoterName = obj.reviewPromoterIdInfo.nickName
      } else if (obj.committeePrincipalIdInfo) {
        this.form.committeePrincipalId = obj.committeePrincipalIdInfo.accountId
        this.form.committeePrincipal = obj.committeePrincipalIdInfo.nickName
      } else if (obj.committeeMemberNamesArrayInfo) {
        let array = obj.committeeMemberNamesArrayInfo
        let data = []
        array.forEach((item, i) => {
          data.push({
            committeeMemberId: item.accountId,
            committeeMemberName: item.nickName
          })
        })
        this.form.committeeMemberNames = data
      } else if (obj.registrarIdInfo) {
        this.form.registrarId = obj.registrarIdInfo.accountId
        this.form.registrar = obj.registrarIdInfo.nickName
      } else if (obj.statusInfo) {
        if (obj.statusInfo.dictId === '02') {
          this.formRules.reviewConclusion[0].required = true
        } else {
          this.formRules.reviewConclusion[0].required = false
        }
      }
    },
    // 同步showDetail、关闭弹窗
    close () {
      this.visible = false
      this.$emit('update:showDetail', false)
    },
    // 对话框结束触发
    handleClose () {
      this.$emit('update:dialogVisible', false)
    },
    // 保存回调
    onSave (data) {
      this.$LoadingClose()
      this.$emit('update:searchFormView', false) // 检索表单重新渲染
      this.accessoryExtList = [
        {
          fileId: '',
          fileName: ''
        }
      ]
      this.$emit('handleFilter')
      if (!this.onlyAdd) {
        if (this.isAnalysis) {
          this.$emit('showAnalysisCg', data.res.keyId)
        }
        this.close() // 关闭窗口
      }
      this.$refs.dialogEdit.resetFields()
      this.setReviewNo()
      this.defaultUser()
      this.onlyAdd = false
    },
    // 判断付款确认书是否存在
    havePayCode () {
      if (this.form.payCode && !this.isHovePayCode) {
        this.warning(this.$t('feedbackMaterialIndex.confirmationInvalid'))
        return false
      } else {
        return true
      }
    },
    // 保存
    saveAction () {
      this.form.maintenanceWayType = '03' // 维护方式（手工维护）
      if (this.havePayCode()) {
        this.$refs['dialogEdit'].$refs['editForm'].validate((valid) => {
          if (valid) {
            this.$LoadingShow()
          }
        })
        this.$refs.dialogEdit.save()
      }
    },
    // 保存并继续添加
    saveandadd () {
      if (this.havePayCode()) {
        this.$refs.dialogEdit.resetForm()
        this.onlyAdd = true
        this.$refs['dialogEdit'].$refs['editForm'].validate((valid) => {
          if (valid) {
            this.$LoadingShow()
          }
        })
        this.$refs.dialogEdit.save()
      }
    }
  },
  watch: {
    // 监听付款确认书编号，为空清空数据
    'form.payCode': {
      handler (val) {
        if (!val) {
          this.payCodeEmpty()
        }
      },
      deep: true
    },
    // 监听登录
    userDropdownOption: {
      handler (val, old) {
        this.defaultUser()
      },
      deep: true
    },
    // 监听文件上传列表
    accessoryExtList: {
      handler (val, old) {
        this.form.accessoryExtDtoList = val
      },
      deep: true
    },
    // 监听表单数据
    form: {
      handler (val, old) {
        if (this.form.inspectionTime === 631123200000) {
          this.form.inspectionTime = ''
          return
        }
        let time
        if (this.form.inspectionTime) {
          time = parseTime(this.form.inspectionTime, '{y}-{m}-{d} {h}:{i}:{s}')
        } else {
          time = ''
        }
        let fileName = this.form.accessoryExtDtoList
        let fileNameArray = []
        fileName.forEach(res => {
          if (res.fileName) {
            fileNameArray.push(res.fileName)
          }
        })
        fileNameArray = fileNameArray.toString()
        this.queryParas.api = {
          inspectionTime: time,
          reviewPromoterName: this.form.reviewPromoterName,
          problemSummary: this.form.problemSummary,
          problemDesc: this.form.problemDesc,
          reviewConclusion: this.form.reviewConclusion,
          remark: this.form.remark,
          fileName: fileNameArray
        }
      },
      deep: true
    }
  }
}
</script>
