gaoluyang
2 天以前 29be8639dc16b5d82bddc6099b1fa5cdca75f77a
src/views/CNAS/resourceDemand/device/component/equipmentMaintenance.vue
@@ -25,10 +25,13 @@
        <el-row>
          <el-col :span="24">
            <el-form-item label="维护内容:" prop="maintenanceContentArr">
              <el-checkbox-group v-model="form.maintenanceContentArr" :disabled="operationType === 'view'">
              <el-checkbox-group v-if="qualificationList.length" v-model="form.maintenanceContentArr"
                                 :disabled="operationType === 'view'">
                <el-checkbox v-for="city in qualificationList" :key="city.label" :label="city.label"
                             :value="city.label"></el-checkbox>
              </el-checkbox-group>
              <el-input v-else v-model="form.maintenanceContentText" :disabled="operationType === 'view'"
                        size="small" placeholder="请输入维护内容" style="width: 100%"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
@@ -67,13 +70,12 @@
} from "@/api/cnas/resourceDemand/device";
import limsTable from "@/components/Table/lims-table.vue";
import {selectUserCondition} from "@/api/system/user";
import draftSave from '@/mixins/draftSave'
import {saveBlobOrShowError} from '@/utils/saveBlob'
export default {
  name: '',
  // import 引入的组件需要注入到对象中才能使用
  components: {limsTable},
  mixins: [draftSave],
  props: {
    clickNodeVal: {
      type: Object,
@@ -129,6 +131,7 @@
        maintenanceDate: '',
        maintenanceContentArr: [],
        maintenanceContent: '',
        maintenanceContentText: '',
        maintenanceUserId: '',
        remark: '',
      },
@@ -137,7 +140,19 @@
      qualificationList: [],
      rules: {
        maintenanceDate: [{ required: true, message: '请选择维护日期', trigger: 'change' }],
        maintenanceContentArr: [{ required: true, message: '请选择维护内容', trigger: 'change' }],
        maintenanceContentArr: [{
          validator: (rule, value, callback) => {
            if (this.qualificationList.length) {
              if (!value || value.length === 0) {
                return callback(new Error('请选择维护内容'))
              }
            } else if (!this.form.maintenanceContentText || !this.form.maintenanceContentText.trim()) {
              return callback(new Error('请输入维护内容'))
            }
            callback()
          },
          trigger: 'change'
        }],
        maintenanceUserId: [{ required: true, message: '请选择维护人', trigger: 'change' }],
      },
      responsibleOptions: [],
@@ -155,6 +170,7 @@
    },
    // 分页切换
    pagination(page) {
      this.page.current = page.page
      this.page.size = page.limit
      this.getTableList()
    },
@@ -180,10 +196,8 @@
        this.form.id = ''
        if (this.operationType === 'edit') {
          this.form = {...row}
          this.form['maintenanceContentArr'] = this.form.maintenanceContent.split(',')
        }
        if (this.operationType !== 'view') {
          this.draftRestore('equipmentMaintenance', 'form', this.operationType === 'edit' ? this.form.id : this.clickNodeVal.value, 'dialogVisible')
          this.form['maintenanceContentArr'] = this.form.maintenanceContent ? this.form.maintenanceContent.split(',') : []
          this.form['maintenanceContentText'] = this.form.maintenanceContent || ''
        }
      })
      this.getDictS()
@@ -229,13 +243,14 @@
        deviceId: this.clickNodeVal.value
      }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, '设备维护保养.doc')
        saveBlobOrShowError(res, '设备维护保养.doc', 'application/msword')
      }).catch(() => {
        this.outLoading = false
      })
    },
    handleDeleteClick(row) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
      this.$confirm('此操作将永久删除该条保养记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
@@ -259,12 +274,13 @@
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.buttonLoading = true;
          this.form.maintenanceContent = this.form.maintenanceContentArr.join(',')
          this.form.maintenanceContent = this.qualificationList.length
            ? this.form.maintenanceContentArr.join(',')
            : (this.form.maintenanceContentText || '').trim()
          this.form.deviceId = this.clickNodeVal.value
          addDeviceMaintenance(this.form).then(res => {
            this.buttonLoading = false;
            this.$message.success('新增成功')
            this.draftClear('equipmentMaintenance')
            this.closeDia()
            this.getTableList()
          }).catch(err => {
@@ -274,7 +290,6 @@
      })
    },
    closeDia () {
      this.draftStop('equipmentMaintenance')
      this.$refs['form'].resetFields();
      this.dialogVisible = false
      this.refreshTableList()