<template>
|
<basic-container>
|
<div class="chart">
|
<DeviceChart1 :key="updateKey"/>
|
<DeviceChart2 :key="updateKey"/>
|
<DeviceChart3 :key="updateKey"/>
|
</div>
|
|
<el-form ref="queryParamsRef" :model="searchParams" class="command-page-history-search">
|
<el-form-item label="设备名称" prop="deviceName">
|
<el-input
|
class="command-input"
|
v-model="searchParams.deviceName"
|
placeholder="请输入"
|
clearable
|
@clear="handleSearch"
|
/>
|
</el-form-item>
|
|
<el-form-item label="设备类型" prop="deviceType">
|
<el-select
|
class="command-select"
|
popper-class="command-select-popper"
|
v-model="searchParams.deviceType"
|
placeholder="请选择"
|
clearable
|
@change="handleSearch"
|
>
|
<el-option
|
v-for="item in dictObj.deviceType"
|
:key="item.dictKey"
|
:label="item.dictValue"
|
:value="item.dictKey"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="所属部门" prop="belongDept">
|
<el-tree-select
|
class="command-select"
|
popper-class="command-tree-select-popper"
|
v-model="searchParams.belongDept"
|
:data="deptTree"
|
:props="treeProps"
|
node-key="id"
|
check-strictly
|
clearable
|
@change="handleSearch"
|
/>
|
</el-form-item>
|
<el-form-item class="history-search-actions">
|
<el-button :icon="RefreshRight" @click="resetForm"></el-button>
|
<el-button class="search-btn" :icon="Search" @click="handleSearch"></el-button>
|
</el-form-item>
|
</el-form>
|
|
<div class="command-table-toolbar">
|
<el-button :icon="Plus" color="#284FE3" type="primary" @click="handleAdd">设备建档</el-button>
|
<!-- <el-button type="danger" :disabled="!selectedIds.length" @click="handleDelete()">删除</el-button>-->
|
</div>
|
|
<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="index" show-overflow-tooltip width="64" 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="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="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 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 }">
|
{{ row.maintenanceStatus === 0 ? '否' : '是' }}
|
</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 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>
|
</el-table-column>
|
</el-table>
|
</div>
|
|
<div class="command-table-pagination">
|
<el-pagination
|
popper-class="command-select-popper"
|
v-model:current-page="searchParams.current"
|
v-model:page-size="searchParams.size"
|
layout="total, prev, pager, next, sizes"
|
:total="total"
|
@change="getList"
|
/>
|
</div>
|
</div>
|
|
<FormDiaLog ref="dialogRef" @success="successFun" />
|
<DeviceTrackDiaLog ref="outboundDialogRef" @success="successFun" />
|
<DeviceScrapDiaLog ref="scrapDialogRef" @success="successFun" />
|
</basic-container>
|
</template>
|
|
<script setup>
|
import { Search, RefreshRight, Plus, Download } from '@element-plus/icons-vue'
|
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'
|
import { blobDownload, dateRangeFormat, getDictLabel, formatDateToSlash } from '@ztzf/utils'
|
import DeviceTrackDiaLog from '@/views/basicManage/deviceStock/DeviceTrackDiaLog.vue'
|
import DeviceScrapDiaLog from '@/views/basicManage/deviceStock/DeviceScrapDiaLog.vue'
|
import DeviceChart1 from '@/views/basicManage/deviceStock/DeviceChart1.vue'
|
import DeviceChart2 from '@/views/basicManage/deviceStock/DeviceChart2.vue'
|
import DeviceChart3 from '@/views/basicManage/deviceStock/DeviceChart3.vue'
|
import dayjs from 'dayjs'
|
|
const initSearchParams = () => ({
|
deviceName: '', // 设备名称
|
deviceType: '', // 设备类型
|
belongDept: '', // 所属部门
|
current: 1, // 当前页
|
size: 10, // 每页大小
|
})
|
const searchParams = ref(initSearchParams()) // 查询参数
|
const loading = ref(true) // 列表加载中
|
const list = ref([]) // 列表数据
|
const total = ref(0) // 总数
|
const selectedIds = ref([]) // 勾选的设备ID列表
|
const queryParamsRef = ref(null) // 查询表单实例
|
const dialogRef = ref(null) // 弹框实例
|
const outboundDialogRef = ref(null) // 弹框实例
|
const scrapDialogRef = ref(null) // 弹框实例
|
const dictObj = ref({
|
deviceType: [], //设备类型
|
deviceAtt: [], //设备属性
|
})
|
const dateRange = ref([])
|
const deptTree = ref([])
|
const treeProps = {
|
label: 'name',
|
children: 'children',
|
}
|
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() {
|
const range = dateRangeFormat(dateRange.value)
|
loading.value = true
|
try {
|
const params = { ...searchParams.value, startTime: range[0], endTime: range[1] }
|
const res = await fwDevicePageApi(params)
|
list.value = res?.data?.data?.records ?? []
|
total.value = res?.data?.data?.total ?? 0
|
} finally {
|
loading.value = false
|
}
|
}
|
|
// 查询
|
function handleSearch() {
|
searchParams.value.current = 1
|
getList()
|
}
|
|
// 重置查询
|
function resetForm() {
|
dateRange.value = []
|
queryParamsRef.value?.resetFields()
|
searchParams.value.current = 1
|
getList()
|
}
|
|
// 查看
|
function handleView(row) {
|
dialogRef.value?.open({ mode: 'view', row: { ...row } })
|
}
|
|
// 编辑
|
function handleEdit(row) {
|
dialogRef.value?.open({ mode: 'edit', row: { ...row } })
|
}
|
|
function outbound(row) {
|
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 } })
|
}
|
|
// 删除
|
async function handleDelete(row) {
|
const tips = row ? '该条' : '选中的项'
|
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('删除成功')
|
selectedIds.value = []
|
getList()
|
}
|
|
// 勾选值设置
|
function handleSelectionChange(rows) {
|
selectedIds.value = rows.map(item => item.id)
|
}
|
|
function exportFile() {
|
exportLoading.value = true
|
exportFwDeviceApi()
|
.then(res => {
|
blobDownload(res)
|
})
|
.finally(() => {
|
exportLoading.value = false
|
})
|
}
|
|
// 获取字典
|
function getDictList() {
|
getDictionaryByCode('deviceType,deviceAtt,deviceStatus').then(res => {
|
dictObj.value = res.data.data
|
})
|
}
|
|
// 获取部门树
|
function getDeptTreeFun() {
|
getDeptTree().then(res => {
|
deptTree.value = res.data.data
|
})
|
}
|
|
// 新增
|
function handleAdd() {
|
dialogRef.value?.open({ mode: 'add' })
|
}
|
|
onMounted(() => {
|
getList()
|
getDictList()
|
getDeptTreeFun()
|
})
|
</script>
|
<style scoped lang="scss">
|
.chart {
|
margin-bottom: 30px;
|
width: 100%;
|
height: 234px;
|
display: flex;
|
:deep() {
|
* {
|
box-sizing: border-box;
|
}
|
.deviceChart {
|
margin-left: 20px;
|
height: 100%;
|
background: rgba(26, 26, 42, 0.3);
|
border-radius: 10px 10px 10px 10px;
|
position: relative;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-between;
|
align-items: center;
|
padding: 10px;
|
|
&:first-child {
|
margin-left: 0;
|
}
|
|
.titleBg {
|
font-weight: 400;
|
font-size: 18px;
|
color: #ffffff;
|
font-family: PangMen, serif;
|
padding-left: 22px;
|
}
|
.chartBox {
|
width: 100%;
|
height: 0;
|
flex-grow: 1;
|
}
|
}
|
}
|
}
|
</style>
|