吉安感知网项目-前端
shuishen
8 days ago 6e88705bd5b443a259b24c17c8a299765d059d96
applications/drone-command/src/views/basicManage/deviceStock/index.vue
@@ -1,9 +1,9 @@
<template>
   <basic-container>
      <div class="chart">
         <DeviceChart1 />
         <DeviceChart2 />
         <DeviceChart3 />
         <DeviceChart1 :key="updateKey" />
         <DeviceChart2 :key="updateKey" />
         <DeviceChart3 :key="updateKey" />
      </div>
      <el-form ref="queryParamsRef" :model="searchParams" class="command-page-history-search">
@@ -62,36 +62,48 @@
      <div class="command-table-container" v-loading="loading" element-loading-background="rgba(5, 5, 15, 0.6)">
         <div class="command-table-content command-table-content-bg">
            <el-table class="command-table" :data="list" @selection-change="handleSelectionChange">
               <el-table-column type="selection" width="46" />
               <el-table-column type="index" show-overflow-tooltip width="64" label="序号" />
               <el-table-column prop="deviceName" show-overflow-tooltip width="130" label="设备名称" />
               <el-table-column prop="deviceType" show-overflow-tooltip width="130" label="设备类型">
               <el-table-column prop="deviceName" show-overflow-tooltip label="设备名称" />
               <el-table-column prop="deviceType" show-overflow-tooltip width="100" label="设备类型">
                  <template v-slot="{ row }">
                     {{ getDictLabel(row.deviceType, dictObj.deviceType) }}
                  </template>
               </el-table-column>
               <el-table-column prop="deviceModel" show-overflow-tooltip width="98" label="型号" />
               <el-table-column prop="deviceSpecification" show-overflow-tooltip width="112" label="规格" />
               <el-table-column prop="manufacturer" show-overflow-tooltip width="130" label="生产厂商" />
               <el-table-column prop="deviceModel" show-overflow-tooltip width="110" label="型号" />
               <el-table-column prop="deviceSpecification" show-overflow-tooltip width="142" label="规格" />
               <el-table-column prop="manufacturer" show-overflow-tooltip width="140" label="生产厂商" />
               <el-table-column prop="createTime" show-overflow-tooltip width="96" label="入库时间">
                  <template v-slot="{ row }">
                     {{ dayjs(row.createTime).format('YYYY-MM-DD') }}
                  </template>
               </el-table-column>
               <el-table-column prop="source" show-overflow-tooltip width="112" label="来源" />
               <el-table-column prop="purpose" show-overflow-tooltip width="206" label="用途" />
               <el-table-column prop="belongDeptName" show-overflow-tooltip width="124" label="所属部门" />
               <el-table-column prop="charger" show-overflow-tooltip width="100" label="负责人" />
               <el-table-column prop="yxzt" show-overflow-tooltip width="116" label="运行状态">
               <el-table-column prop="source" show-overflow-tooltip width="120" label="来源" />
               <el-table-column prop="purpose" show-overflow-tooltip width="130" label="用途" />
               <el-table-column prop="belongDeptName" show-overflow-tooltip width="130" label="所属部门" />
               <el-table-column prop="charger" show-overflow-tooltip width="130" label="负责人" />
               <el-table-column prop="yxzt" show-overflow-tooltip width="96" label="运行状态">
                  <template v-slot="{ row }">
                     {{ getDictLabel(row.status, dictObj.deviceStatus) }}
                  </template>
               </el-table-column>
               <el-table-column label="操作" class-name="operation-btns">
               <el-table-column prop="yxzt" show-overflow-tooltip width="96" label="出库状态">
                  <template v-slot="{ row }">
                     {{ getDictLabel(row.trackStatus, trackStatusOptions) }}
                  </template>
               </el-table-column>
               <el-table-column prop="maintenanceStatus" show-overflow-tooltip width="96" label="报废预警">
                  <template v-slot="{ row }">
                     <span :style="{ color: row.maintenanceStatus === 0 ? 'inherit' : 'red' }">
                        {{ row.maintenanceStatus === 0 ? '正常' : '临近报废' }}
                     </span>
                  </template>
               </el-table-column>
               <el-table-column label="操作" class-name="operation-btns" width="196" fixed="right">
                  <template v-slot="{ row }">
                     <el-link @click="handleView(row)">查看</el-link>
                     <el-link @click="handleEdit(row)">编辑</el-link>
                     <el-link @click="outbound(row)">出库</el-link>
                     <el-link v-if="row.trackStatus === 0" @click="outbound(row)">出库</el-link>
                     <el-link v-else @click="returnDevice(row)">归还</el-link>
                     <el-link @click="scrap(row)" v-if="row.status !== 3">报废</el-link>
                     <!--               <el-link @click="handleDelete(row)" type="danger">删除</el-link>-->
                  </template>
@@ -111,9 +123,9 @@
         </div>
      </div>
      <FormDiaLog ref="dialogRef" @success="getList" />
      <DeviceTrackDiaLog ref="outboundDialogRef" @success="getList" />
      <DeviceScrapDiaLog ref="scrapDialogRef" @success="getList" />
      <FormDiaLog ref="dialogRef" @success="successFun" />
      <DeviceTrackDiaLog ref="outboundDialogRef" @success="successFun" />
      <DeviceScrapDiaLog ref="scrapDialogRef" @success="successFun" />
   </basic-container>
</template>
@@ -122,6 +134,7 @@
import { onMounted, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { exportFwDeviceApi, fwDevicePageApi, fwDeviceRemoveApi } from '@/views/basicManage/deviceStock/fwDevice'
import { fwDeviceUpdateTrackStatusApi } from '@/views/basicManage/deviceStock/fwDeviceTrackApi'
import FormDiaLog from './FormDiaLog.vue'
import { getDictionaryByCode } from '@/api/system/dictbiz'
import { getDeptTree } from '@/api/system/dept'
@@ -162,6 +175,18 @@
const exportLoading = ref(false)
provide('dictObj', dictObj)
provide('deptTree', deptTree)
// 出库状态
const trackStatusOptions = ref([
   { dictKey: 0, dictValue: '未出库' },
   { dictKey: 1, dictValue: '已出库' },
])
const updateKey = ref(0)
function successFun() {
   updateKey.value = updateKey.value + 1
   getList()
}
// 获取列表
async function getList() {
@@ -205,6 +230,22 @@
   outboundDialogRef.value?.open({ mode: 'edit', row: { ...row } })
}
// 归还
async function returnDevice(row) {
   await ElMessageBox.confirm(`确认归还吗?`, '提示', {
      type: 'warning',
      customClass: 'command-page-view-message-box',
      confirmButtonClass: 'command-message-box-confirm',
      cancelButtonClass: 'command-message-box-cancel',
   })
   const payload = {
      deviceId: row.id,
   }
   await fwDeviceUpdateTrackStatusApi(payload)
   ElMessage.success('归还成功')
   getList()
}
function scrap(row) {
   scrapDialogRef.value?.open({ mode: 'edit', row: { ...row } })
}
@@ -212,7 +253,12 @@
// 删除
async function handleDelete(row) {
   const tips = row ? '该条' : '选中的项'
   await ElMessageBox.confirm(`确认删除${tips}吗?`, '提示', { type: 'warning' })
   await ElMessageBox.confirm(`确认删除${tips}吗?`, '提示', {
      type: 'warning',
      customClass: 'command-page-view-message-box',
      confirmButtonClass: 'command-message-box-confirm',
      cancelButtonClass: 'command-message-box-cancel',
   })
   const ids = row ? row.id : selectedIds.value.join(',')
   await fwDeviceRemoveApi({ ids })
   ElMessage.success('删除成功')
@@ -302,4 +348,7 @@
      }
   }
}
.danger-text {
   color: red; /* 或者直接用 red */
}
</style>