gaoluyang
2026-04-29 3b577bb9493c389c5a3f0dca4538ddbf41fb1387
src/views/equipmentManagement/upkeep/index.vue
@@ -64,16 +64,14 @@
            <template #operation="{ row }">
              <el-button
                type="primary"
                text
                icon="editPen"
                link
                @click="editScheduledTask(row)"
              >
                编辑
              </el-button>
              <el-button
                type="danger"
                text
                icon="delete"
                link
                @click="delScheduledTaskByIds(row.id)"
              >
                删除
@@ -144,7 +142,7 @@
              <el-button
                type="danger"
                icon="Delete"
                :disabled="multipleList.length <= 0"
                :disabled="multipleList.length <= 0 || hasFinishedStatus"
                @click="delRepairByIds(multipleList.map((item) => item.id))"
              >
                批量删除
@@ -173,28 +171,44 @@
          <el-tag v-if="row.status === 0" type="warning">待保养</el-tag>
        </template>
        <template #operation="{ row }">
          <el-button
          <!-- 这个功能跟新增保养功能一模一样,有啥意义? -->
          <!-- <el-button
              type="primary"
              text
              @click="addMaintain(row)"
          >
            新增保养
          </el-button>
          </el-button> -->
          <el-button
            type="primary"
            text
            icon="editPen"
            link
            :disabled="row.status === 1"
            @click="editPlan(row.id)"
          >
            编辑
          </el-button>
          <el-button
            type="success"
            link
            :disabled="row.status === 1"
            @click="addMaintain(row)"
          >
            保养
          </el-button>
          <el-button
            type="danger"
            text
            icon="delete"
            link
            :disabled="row.status === 1"
            @click="delRepairByIds(row.id)"
          >
            删除
          </el-button>
          <el-button
            type="primary"
            link
            @click="openFileDialog(row)"
          >
            附件
          </el-button>
        </template>
      </PIMTable>
@@ -204,16 +218,17 @@
    <PlanModal ref="planModalRef" @ok="getTableData" />
        <MaintenanceModal ref="maintainModalRef" @ok="getTableData" />
        <FormDia ref="formDiaRef" @closeDia="getScheduledTableData" />
    <FileList v-if="fileDialogVisible"  v-model:visible="fileDialogVisible" :record-type="'device_maintenance'" :record-id="currentMaintenanceTaskId"  />
  </div>
</template>
<script setup>
import { ref, onMounted, reactive, getCurrentInstance, nextTick } from 'vue'
import {ref, onMounted, reactive, getCurrentInstance, nextTick, computed, defineAsyncComponent} from 'vue'
import { Search } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import PlanModal from './Modal/PlanModal.vue'
import MaintenanceModal from './Modal/MaintenanceModal.vue'
import FormDia from './Modal/formDia.vue'
import PlanModal from './Form/PlanModal.vue'
import MaintenanceModal from './Form/MaintenanceModal.vue'
import FormDia from './Form/formDia.vue'
import {
  getUpkeepPage,
  delUpkeep,
@@ -223,6 +238,7 @@
import dayjs from 'dayjs'
const { proxy } = getCurrentInstance()
const FileList = defineAsyncComponent(() => import("@/components/Dialog/FileList.vue"));
// Tab相关
const activeTab = ref('scheduled')
@@ -233,6 +249,10 @@
const maintainModalRef = ref()
// 定时任务弹窗控制器
const formDiaRef = ref()
// 附件弹窗
const fileListDialogRef = ref(null)
const fileDialogVisible = ref(false)
const currentMaintenanceTaskId = ref(null)
// 任务记录tab(原设备保养页面)相关变量
const filters = reactive({
@@ -339,6 +359,11 @@
      align: "center",
      prop: "createUserName",
   },
  {
    label: "项目",
    align: "center",
    prop: "machineryCategory",
  },
   // {
   //   label: "录入日期",
   //   align: "center",
@@ -378,7 +403,7 @@
      dataType: "slot",
      slot: "operation",
      align: "center",
      width: "300px",
      width: "350px",
   },
])
@@ -493,6 +518,11 @@
  multipleList.value = selection
}
// 检查选中的记录中是否有完结状态的
const hasFinishedStatus = computed(() => {
  return multipleList.value.some(item => item.status === 1)
})
const changePage = (page) => {
  pagination.value.currentPage = page.page
  pagination.value.pageSize = page.limit
@@ -512,6 +542,13 @@
}
const delRepairByIds = async (ids) => {
  // 检查是否有完结状态的记录
  const hasFinished = multipleList.value.some(item => item.status === 1)
  if (hasFinished) {
    ElMessage.warning('不能删除状态为完结的记录')
    return
  }
  try {
    await ElMessageBox.confirm('确认删除保养数据, 此操作不可逆?', '警告', {
      confirmButtonText: '确定',
@@ -552,6 +589,12 @@
  getTableData()
}
// 打开附件弹窗
const openFileDialog = async (row) => {
  currentMaintenanceTaskId.value = row.id
  fileDialogVisible.value = true
}
onMounted(() => {
  // 根据默认激活的 Tab 调用对应的查询接口
  if (activeTab.value === 'scheduled') {