设备管理
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
5.4 KiB

9 months ago
<template>
<div class="storage-info-wrap">
<div class="left-wrap">
<EdfsWrap class="chart-box" title="设备库存概览">
<PieChart :data="chartData" />
</EdfsWrap>
<div class="filter">
<LeftFilter @search="onSearch" :customerList="customerList" />
9 months ago
</div>
</div>
<EdfsWrap title="设备库存列表" class="storage-info-table">
9 months ago
<EdfsTable
class="table"
v-loading="loading"
:data="list"
ref="tableRef"
9 months ago
:highlight-current-row="true"
:page-total="total"
:current-page="queryParams.pageNo"
:page-size="queryParams.pageSize"
row-class-name="row"
@pageCurrentChange="handleJump"
>
<template v-for="(col, idx) in tableCol" :key="idx">
<el-table-column
v-if="col.prop.endsWith('Time')"
:label="storageStatus + col.label"
:min-width="col.minWidth"
>
<template #default="scope">
{{ dayjs(scope.row[col.prop]).format('YYYY-MM-DD HH:mm:ss') }}
</template>
</el-table-column>
<el-table-column
v-else-if="col.prop === 'status'"
9 months ago
:label="col.label"
:min-width="col.minWidth"
>
<template #default="scope">
{{
statusList.find(item => item.value === scope.row[col.prop])?.label ?? ''
}}
9 months ago
</template>
</el-table-column>
<el-table-column
v-else
:prop="col.prop"
:label="col.label"
:min-width="col.minWidth"
/>
</template>
<el-table-column label="操作" width="120" align="center">
9 months ago
<template #default="scope">
<EdfsButton
link
type="success"
inner-text="添加维修信息"
v-if="scope.row.status === 3"
9 months ago
@click="addMaintain(scope.row)"
/>
<EdfsButton
link
type="success"
v-else-if="scope.row.status === 2"
inner-text="添加出库信息"
@click="addOutStorage(scope.row)"
/>
9 months ago
</template>
</el-table-column>
</EdfsTable>
</EdfsWrap>
</div>
</template>
<script setup lang="ts">
import dayjs from 'dayjs'
import EdfsWrap from '@/components/dashboard/Edfs-wrap.vue'
import EdfsTable from '@/components/dashboard/Edfs-table/index.vue'
import { statusList, tableCol } from './utils'
9 months ago
import { isResError } from '@/hooks/useMessage'
import LeftFilter from './components/data-filter.vue'
import { getStoragePage, getStorageStatics } from '@/api/module/eam/device/storage'
9 months ago
import { useRouter } from 'vue-router'
import PieChart from './components/pie-chart.vue'
import { getSimpleCustomerList, type CustomerVO } from '@/api/module/eam/customer'
9 months ago
const router = useRouter()
const loading = ref(true)
const total = ref(0)
const list = ref<any>([])
const queryParams = reactive({
pageNo: 1,
pageSize: undefined,
9 months ago
})
const tableRef = ref<any>(null)
9 months ago
const getList = async () => {
if (!queryParams.pageSize) {
queryParams.pageSize = tableRef.value.getSize()
}
9 months ago
loading.value = true
const res = await getStoragePage(Object.assign({}, queryParams, filter.value))
9 months ago
if (!isResError(res)) {
list.value = res.data.list
total.value = res.data.total
}
loading.value = false
}
const storageStatus = computed(
() => statusList.find(item => item.value === filter.value.status)?.colName ?? ''
)
const filter = ref<any>({})
function onSearch(search: any) {
9 months ago
queryParams.pageNo = 1
filter.value = search
9 months ago
getList()
}
9 months ago
function handleJump(page: number) {
queryParams.pageNo = page
getList()
}
function addMaintain(row: any) {
router.push({
path: '/device/deviceOperation',
query: { action: 'update', type: 'maintain', id: row.deviceId },
})
}
function addOutStorage(row: any) {
router.push({
path: '/device/deviceOperation',
query: { action: 'update', type: 'delivery', id: row.deviceId },
})
}
const customerList = ref<Array<Pick<CustomerVO, 'id' | 'name'>>>([])
async function loadCustomerList() {
const res = await getSimpleCustomerList()
if (isResError(res)) return
customerList.value = res.data
}
const chartData = ref([]) as Ref<any>
async function loadChartData() {
const res = await getStorageStatics()
if (!isResError(res)) {
chartData.value = res.data
}
}
9 months ago
onMounted(() => {
loadCustomerList()
loadChartData()
9 months ago
})
</script>
<style scoped lang="scss">
.storage-info-wrap {
width: 100%;
height: 100%;
display: flex;
column-gap: 12px;
box-sizing: border-box;
font-size: 16px;
.left-wrap {
width: 280px;
min-width: 100px;
height: 100%;
background: var(--warp-bg);
display: flex;
flex-direction: column;
box-sizing: border-box;
.station {
position: relative;
height: 60px;
padding-left: 20px;
border-bottom: 1px solid var(--pagination-border-color);
:deep(.el-input__inner) {
color: #666;
}
:deep(.el-input__wrapper) {
padding: 0;
}
:deep(.el-input__suffix) {
display: none;
9 months ago
}
}
.chart-box {
height: 300px;
}
.filter {
height: calc(100% - 300px);
overflow: hidden;
}
:deep(.edfs-wrap) {
box-shadow: none;
}
9 months ago
}
9 months ago
.storage-info-table {
flex: 1;
.table {
height: 100%;
}
}
}
</style>