parent
							
								
									4e8847f93f
								
							
						
					
					
						commit
						d07a03293d
					
				| 
						 | 
				
			
			@ -219,7 +219,6 @@ export default {
 | 
			
		|||
          fileAddressList: fileAddressList
 | 
			
		||||
        }
 | 
			
		||||
        this.infoForm.incidentDate = new Date(data.info.incidentDate)
 | 
			
		||||
        this.infoForm.reportDate = new Date(data.info.reportDate)
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -395,8 +394,7 @@ export default {
 | 
			
		|||
        analysis: '', // 原因分析及责任认定
 | 
			
		||||
        suggestions: '', // 考核建议
 | 
			
		||||
        measures: '', // 整改措施
 | 
			
		||||
        creator: '', // 填表人
 | 
			
		||||
        reportDate: null // 报出日期
 | 
			
		||||
        creator: '' // 填表人
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -409,7 +407,6 @@ export default {
 | 
			
		|||
          return false
 | 
			
		||||
        }
 | 
			
		||||
        this.infoForm.incidentDate = formatDate(this.infoForm.incidentDate, 'YYYY-MM-DD HH:mm:ss')
 | 
			
		||||
        this.infoForm.reportDate = formatDate(this.infoForm.reportDate, 'YYYY-MM-DD HH:mm:ss')
 | 
			
		||||
        const params = {
 | 
			
		||||
          ...this.infoForm,
 | 
			
		||||
          photos: this.infoForm.fileList.map(item => item.remotePathName),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,17 +67,6 @@
 | 
			
		|||
      <el-form-item :label-width="formLabelWidth" label="填表人" prop="creator">
 | 
			
		||||
        <el-input v-model="infoForm.creator" :disabled="isDisabled" autocomplete="off"/>
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
      <el-form-item :label-width="formLabelWidth" label="报出日期" prop="reportDate">
 | 
			
		||||
        <el-date-picker
 | 
			
		||||
          v-model="infoForm.reportDate"
 | 
			
		||||
          :disabled="isDisabled"
 | 
			
		||||
          type="datetime"
 | 
			
		||||
          placeholder="请选择报出日期"
 | 
			
		||||
          style="width: 100%;"
 | 
			
		||||
          format="yyyy-MM-dd HH:mm:ss"
 | 
			
		||||
          value-format="yyyy-MM-dd HH:mm:ss"
 | 
			
		||||
        />
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
      <el-form-item :label-width="formLabelWidth" label="事故照片" prop="fileList">
 | 
			
		||||
        <el-upload
 | 
			
		||||
          ref="upload"
 | 
			
		||||
| 
						 | 
				
			
			@ -108,6 +97,7 @@
 | 
			
		|||
          :limit="limitNum"
 | 
			
		||||
          :on-remove="handleRemoveAnnex"
 | 
			
		||||
          :before-upload="beforeEventUpload"
 | 
			
		||||
          :on-preview="handleDownloadAnnex"
 | 
			
		||||
          :on-error="handleError"
 | 
			
		||||
          :on-exceed="handleExceed"
 | 
			
		||||
          name="file"
 | 
			
		||||
| 
						 | 
				
			
			@ -176,8 +166,7 @@ export default {
 | 
			
		|||
        analysis: '', // 原因分析及责任认定
 | 
			
		||||
        suggestions: '', // 考核建议
 | 
			
		||||
        measures: '', // 整改措施
 | 
			
		||||
        creator: '', // 填表人
 | 
			
		||||
        reportDate: null // 报出日期
 | 
			
		||||
        creator: '' // 填表人
 | 
			
		||||
      },
 | 
			
		||||
      formLabelWidth: '140px',
 | 
			
		||||
      /** 事故类型 */
 | 
			
		||||
| 
						 | 
				
			
			@ -186,7 +175,7 @@ export default {
 | 
			
		|||
      incidentLevels: [],
 | 
			
		||||
      tableName: '',
 | 
			
		||||
      /** 图片上传限制个数 */
 | 
			
		||||
      limitNum: 1,
 | 
			
		||||
      limitNum: 6,
 | 
			
		||||
      /** 预览弹窗 */
 | 
			
		||||
      dialogImgVisible: false,
 | 
			
		||||
      rules: {
 | 
			
		||||
| 
						 | 
				
			
			@ -202,8 +191,7 @@ export default {
 | 
			
		|||
        analysis: [{ required: true, message: '原因分析及责任认定不能为空', trigger: 'blur' }],
 | 
			
		||||
        suggestions: [{ required: true, message: '考核建议不能为空', trigger: 'blur' }],
 | 
			
		||||
        measures: [{ required: true, message: '整改措施不能为空', trigger: 'blur' }],
 | 
			
		||||
        creator: [{ required: true, message: '填表人不能为空', trigger: 'blur' }],
 | 
			
		||||
        reportDate: [{ required: true, message: '报出日期不能为空', trigger: 'blur' }]
 | 
			
		||||
        creator: [{ required: true, message: '填表人不能为空', trigger: 'blur' }]
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -223,30 +211,34 @@ export default {
 | 
			
		|||
    } else {
 | 
			
		||||
      // 若有数据项的ID, 则请求接口并回显表单
 | 
			
		||||
      requestFN('/accident/' + id, {}).then((data) => {
 | 
			
		||||
        const fileList = []
 | 
			
		||||
        if (data.info.photos != null && data.info.photos !== '') {
 | 
			
		||||
          JSON.parse(data.info.photos).map((item) => {
 | 
			
		||||
            fileList.push({
 | 
			
		||||
              name: 'photo',
 | 
			
		||||
              url: config.fileUrl + item,
 | 
			
		||||
              remotePathName: item
 | 
			
		||||
            })
 | 
			
		||||
          })
 | 
			
		||||
        }
 | 
			
		||||
        const fileAddressList = []
 | 
			
		||||
        if (data.info.attachmentAddress != null && data.info.attachmentAddress !== '') {
 | 
			
		||||
          const names = data.info.attachmentNames == null ? [] : JSON.parse(data.info.attachmentNames)
 | 
			
		||||
          const address = data.info.attachmentAddress == null ? [] : JSON.parse(data.info.attachmentAddress)
 | 
			
		||||
          for (let i = 0; i < address.length; i++) {
 | 
			
		||||
            fileAddressList.push({
 | 
			
		||||
              name: names[i] || '附件',
 | 
			
		||||
              url: config.fileUrl + address[i],
 | 
			
		||||
              remotePathName: address[i]
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        this.infoForm = {
 | 
			
		||||
          ...data.info,
 | 
			
		||||
          fileList: [
 | 
			
		||||
            {
 | 
			
		||||
              name: 'photo',
 | 
			
		||||
              url: config.fileUrl + data.info.photos,
 | 
			
		||||
              remotePathName: data.info.photos
 | 
			
		||||
            }
 | 
			
		||||
          ],
 | 
			
		||||
          fileAddressList: [
 | 
			
		||||
            {
 | 
			
		||||
              name: '附件',
 | 
			
		||||
              url: config.fileUrl + data.info.attachmentAddress,
 | 
			
		||||
              remotePathName: data.info.attachmentAddress
 | 
			
		||||
            }
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
        const fileAddress = this.infoForm.fileAddressList[0].remotePathName
 | 
			
		||||
        if (fileAddress == null || fileAddress === '') {
 | 
			
		||||
          this.infoForm.fileAddressList = []
 | 
			
		||||
          fileList: fileList,
 | 
			
		||||
          fileAddressList: fileAddressList
 | 
			
		||||
        }
 | 
			
		||||
        this.infoForm.incidentDate = new Date(data.info.incidentDate)
 | 
			
		||||
        this.infoForm.reportDate = new Date(data.info.reportDate)
 | 
			
		||||
      }).catch((e) => {
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -255,13 +247,13 @@ export default {
 | 
			
		|||
    /**
 | 
			
		||||
     * 文件列表移除文件时的钩子
 | 
			
		||||
     */
 | 
			
		||||
    handleRemovePicture(file) {
 | 
			
		||||
    handleRemovePicture(file, fileList) {
 | 
			
		||||
      if (file.remotePathName) {
 | 
			
		||||
        requestFN(`/accident/delete/photos`, {
 | 
			
		||||
          path: file.remotePathName
 | 
			
		||||
        }).then((res) => {
 | 
			
		||||
          if (res.result === 'success') {
 | 
			
		||||
            this.infoForm.fileList = []
 | 
			
		||||
            this.infoForm.fileList = fileList
 | 
			
		||||
            this.$message({
 | 
			
		||||
              message: '文件删除成功',
 | 
			
		||||
              type: 'info',
 | 
			
		||||
| 
						 | 
				
			
			@ -275,13 +267,13 @@ export default {
 | 
			
		|||
    /**
 | 
			
		||||
     * 文件列表移除文件时的钩子
 | 
			
		||||
     */
 | 
			
		||||
    handleRemoveAnnex(file) {
 | 
			
		||||
    handleRemoveAnnex(file, fileList) {
 | 
			
		||||
      if (file.remotePathName) {
 | 
			
		||||
        requestFN(`/accident/delete/photos`, {
 | 
			
		||||
          path: file.remotePathName
 | 
			
		||||
        }).then((res) => {
 | 
			
		||||
          if (res.result === 'success') {
 | 
			
		||||
            this.infoForm.fileAddressList = []
 | 
			
		||||
            this.infoForm.fileAddressList = fileList
 | 
			
		||||
            this.$message({
 | 
			
		||||
              message: '文件删除成功',
 | 
			
		||||
              type: 'info',
 | 
			
		||||
| 
						 | 
				
			
			@ -300,6 +292,17 @@ export default {
 | 
			
		|||
      this.dialogImageUrl = file.url
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 点击文件列表中已上传的文件时的钩子
 | 
			
		||||
     */
 | 
			
		||||
    handleDownloadAnnex(file) {
 | 
			
		||||
      var a = document.createElement('a')
 | 
			
		||||
      var event = new MouseEvent('click')
 | 
			
		||||
      a.download = file.name
 | 
			
		||||
      a.href = file.url
 | 
			
		||||
      a.dispatchEvent(event)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 文件上传失败时的钩子处理
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -340,14 +343,11 @@ export default {
 | 
			
		|||
        formData.append('file', file)
 | 
			
		||||
        upload('/accident/import/photos', formData).then((data) => {
 | 
			
		||||
          if (data.result === 'success') {
 | 
			
		||||
            this.infoForm = {
 | 
			
		||||
              ...this.infoForm,
 | 
			
		||||
              fileList: [{
 | 
			
		||||
                name: file.name,
 | 
			
		||||
                url: config.fileUrl + data.path,
 | 
			
		||||
                remotePathName: data.path
 | 
			
		||||
              }]
 | 
			
		||||
            }
 | 
			
		||||
            this.infoForm.fileList.push({
 | 
			
		||||
              name: file.name,
 | 
			
		||||
              url: config.fileUrl + data.path,
 | 
			
		||||
              remotePathName: data.path
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
        return false
 | 
			
		||||
| 
						 | 
				
			
			@ -369,14 +369,11 @@ export default {
 | 
			
		|||
      formData.append('file', file)
 | 
			
		||||
      upload('/accident/import/photos', formData).then((data) => {
 | 
			
		||||
        if (data.result === 'success') {
 | 
			
		||||
          this.infoForm = {
 | 
			
		||||
            ...this.infoForm,
 | 
			
		||||
            fileAddressList: [{
 | 
			
		||||
              name: file.name,
 | 
			
		||||
              url: config.fileUrl + data.path,
 | 
			
		||||
              remotePathName: data.path
 | 
			
		||||
            }]
 | 
			
		||||
          }
 | 
			
		||||
          this.infoForm.fileAddressList.push({
 | 
			
		||||
            name: file.name,
 | 
			
		||||
            url: config.fileUrl + data.path,
 | 
			
		||||
            remotePathName: data.path
 | 
			
		||||
          })
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
      return false
 | 
			
		||||
| 
						 | 
				
			
			@ -416,8 +413,7 @@ export default {
 | 
			
		|||
        analysis: '', // 原因分析及责任认定
 | 
			
		||||
        suggestions: '', // 考核建议
 | 
			
		||||
        measures: '', // 整改措施
 | 
			
		||||
        creator: '', // 填表人
 | 
			
		||||
        reportDate: null // 报出日期
 | 
			
		||||
        creator: '' // 填表人
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -430,23 +426,21 @@ export default {
 | 
			
		|||
          return false
 | 
			
		||||
        }
 | 
			
		||||
        this.infoForm.incidentDate = formatDate(this.infoForm.incidentDate, 'YYYY-MM-DD HH:mm:ss')
 | 
			
		||||
        this.infoForm.reportDate = formatDate(this.infoForm.reportDate, 'YYYY-MM-DD HH:mm:ss')
 | 
			
		||||
        const address = this.infoForm.fileAddressList[0]
 | 
			
		||||
        const params = {
 | 
			
		||||
          ...this.infoForm,
 | 
			
		||||
          photos: this.infoForm.fileList[0].remotePathName,
 | 
			
		||||
          attachmentAddress: address == null ? '' : address.remotePathName,
 | 
			
		||||
          photos: this.infoForm.fileList.map(item => item.remotePathName),
 | 
			
		||||
          attachmentAddress: this.infoForm.fileAddressList.map(item => item.remotePathName),
 | 
			
		||||
          attachmentNames: this.infoForm.fileAddressList.map(item => item.name),
 | 
			
		||||
          type: 2
 | 
			
		||||
        }
 | 
			
		||||
        delete params.fileList
 | 
			
		||||
        requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), params)
 | 
			
		||||
          .then((response) => {
 | 
			
		||||
          .then(() => {
 | 
			
		||||
            // 删除成功后的处理
 | 
			
		||||
            this.$message.success(this.tableName + '成功')
 | 
			
		||||
            this.infoForm = this.$options.data().infoForm
 | 
			
		||||
            this.$parent.activeName = 'List'
 | 
			
		||||
            // eslint-disable-next-line handle-callback-err
 | 
			
		||||
          }).catch((error) => {
 | 
			
		||||
          }).catch(() => {
 | 
			
		||||
            this.$message.error(this.tableName + '失败')
 | 
			
		||||
          })
 | 
			
		||||
      })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue