吴羡
10 小时以前 a1faa94fbf85553f22da934a1abc745d89dd8667
src/views/CNAS/resourceDemand/device/component/equipmentMaintenancePlan.vue
@@ -11,10 +11,6 @@
        </div>
        <div>
          <el-button size="small" type="primary" @click="loadPlan">刷新</el-button>
          <el-button size="small" type="primary" :disabled="planInfo.status === 1"
            @click="tellApprove">审核通知</el-button>
          <el-button size="small" type="primary"
            :disabled="planInfo.status === 1 || userId != planInfo.auditId" @click="handleApprove">审核</el-button>
          <el-button size="small" type="primary" :loading="outLoading" @click="handleDownOne">导出</el-button>
        </div>
      </div>
@@ -23,7 +19,6 @@
        <span>编制日期:{{ planInfo.datePreparationStr || '—' }}</span>
        <span v-if="planInfo.status === 1">审核状态:<el-tag type="success">通 过</el-tag></span>
        <span v-else-if="planInfo.status === 0">审核状态:<el-tag type="danger">不通过</el-tag></span>
        <span v-else>审核状态:<el-tag type="info">未审核</el-tag></span>
        <span v-if="planInfo.auditRemark">审核信息:{{ planInfo.auditRemark }}</span>
        <span v-if="isAudited && planInfo.audit">审核人:{{ planInfo.audit }}</span>
        <span v-if="isAudited && planInfo.auditDateStr">审核时间:{{ planInfo.auditDateStr }}</span>
@@ -66,10 +61,10 @@
          :formatter="formatDateCell"></el-table-column>
        <el-table-column align="center" fixed="right" label="操作" min-width="160">
          <template #default="scope">
            <el-button size="small" link type="primary" :disabled="planInfo.status === 1"
            <el-button size="small" link type="primary"
              @click="handleForm('edit', scope.row)">编辑</el-button>
            <el-button size="small" link type="primary" @click="handleForm('view', scope.row)">查看</el-button>
            <el-button size="small" link type="danger" :disabled="planInfo.status === 1"
            <el-button size="small" link type="danger"
              @click="deleteRow(scope.row)">删除</el-button>
          </template>
        </el-table-column>
@@ -132,45 +127,18 @@
          v-if="operationType !== 'view'">确 认</el-button>
      </span></template>
    </el-dialog>
    <el-dialog v-model="approvalDialog" title="审核" width="30%" @close="approvalDialog = false">
      <span>
        审核信息:
        <el-input v-model="approvalRemark" type="textarea"></el-input>
      </span>
      <template #footer><span class="dialog-footer">
        <el-button :loading="approvalLoading" @click="handleApproval(0)">不通过</el-button>
        <el-button :loading="approvalLoading" type="primary" @click="handleApproval(1)">通 过</el-button>
      </span></template>
    </el-dialog>
    <el-dialog v-model="notificationDia" title="提交审核" width="30%" @close="closeNotificationDia">
      <span style="margin-top: 10px;display: inline-block">
        请选择审核人:
        <el-select v-model="auditUserId" clearable filterable size="small" style="width: 90%;">
          <el-option v-for="item in responsibleOptions" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </span>
      <template #footer><span class="dialog-footer">
        <el-button :loading="notificationLoading" @click="closeNotificationDia">取 消</el-button>
        <el-button :loading="notificationLoading" type="primary" @click="notification">提 交</el-button>
      </span></template>
    </el-dialog>
  </div>
</template>
<script>
import {
  selectDeviceMaintenancePlanByPage,
  submitReviewMaintenancePlanStatus,
  getMaintenancePlanByYear,
  pageMaintenancePlanDetail,
  updateMaintenancePlanDetail,
  deleteMaintenancePlanDetail,
  exportDeviceMaintenancePlan,
  reviewMaintenancePlanStatus,
} from '@/api/cnas/resourceDemand/device.js'
import { selectUserCondition } from "@/api/business/inspectionTask";
import { mapGetters } from "@/utils/store-compat";
import { formatDateOnly } from './dateFormat'
import { saveBlobOrShowError } from '@/utils/saveBlob'
export default {
@@ -207,13 +175,6 @@
      },
      submitFormLoading: false,
      outLoading: false,
      responsibleOptions: [],
      notificationDia: false,
      notificationLoading: false,
      auditUserId: '',
      approvalDialog: false,
      approvalLoading: false,
      approvalRemark: '',
    }
  },
  mounted() {
@@ -374,59 +335,6 @@
        });
      });
    },
    // 打开提交审核弹框
    tellApprove() {
      this.getUserList()
      this.notificationDia = true
    },
    // 关闭提交审核弹框
    closeNotificationDia() {
      this.notificationDia = false
      this.auditUserId = ''
    },
    // 提交审核通知
    notification() {
      if (!this.auditUserId) {
        this.$message.warning('请选择审核人')
        return
      }
      this.notificationLoading = true
      submitReviewMaintenancePlanStatus({
        auditId: this.auditUserId,
        maintenancePlanId: this.planInfo.maintenancePlanId,
      }).then(res => {
        this.notificationLoading = false
        if (res.code == 200) {
          this.closeNotificationDia()
          this.loadPlan()
        }
      }).catch(() => {
        this.notificationLoading = false
      })
    },
    // 打开审核弹框
    handleApprove() {
      this.approvalRemark = ''
      this.approvalDialog = true
    },
    // 提交审核结果
    handleApproval(status) {
      this.approvalLoading = true
      reviewMaintenancePlanStatus({
        maintenancePlanId: this.planInfo.maintenancePlanId,
        status: status,
        auditRemark: this.approvalRemark,
      }).then(res => {
        if (res.code == 200) {
          this.$message.success('审核成功!');
          this.approvalDialog = false
          this.loadPlan()
        }
        this.approvalLoading = false
      }).catch(() => {
        this.approvalLoading = false
      })
    },
    // 导出
    handleDownOne() {
      this.outLoading = true
@@ -436,21 +344,9 @@
      }).catch(() => {
        this.outLoading = false
      })
    },
    // 获取负责人信息接口
    getUserList() {
      selectUserCondition().then(res => {
        if (res.code == 200) {
          this.responsibleOptions = (res.data || []).map(item => ({
            label: item.name,
            value: item.id,
          }))
        }
      });
    }
  },
  computed: {
    ...mapGetters(["userId"]),
    // 是否已完成审核(通过/不通过)
    isAudited() {
      return this.planInfo.status === 0 || this.planInfo.status === 1;