fengshang_yangzhou/dev_wms_client/src/layout/clcKanban.vue

308 lines
9.4 KiB
Vue
Raw Normal View History

2025-09-25 13:11:33 +08:00
<template>
<el-config-provider :locale="zhCn">
<el-container class="content">
<div class="work-area">
<fieldset class="search-area">
<el-form ref="kanbanQueryFormRef" :model="kanbanQuery" :label-position="labelPosition"
label-width="158px" style="max-width: 100%" status-icon>
<div style="display: flex;justify-content: space-between;">
<el-row>
<el-form-item label="料号">
<el-input v-model="kanbanQuery.goodsId" placeholder="料号" @keyup.enter="search()"
clearable/>
</el-form-item>
<el-form-item label="看板Id">
<el-input v-model="kanbanQuery.kanbanId" placeholder="看板Id"
@keyup.enter="search()" clearable/>
</el-form-item>
<el-form-item label="看板状态">
<el-select-v2 style="width: 196px" v-model="kanbanQuery.kanbanStatus" placeholder="看板状态"
:options="addAllOptionOfOptions(kanbanStatusOptions)"
@change="search()"></el-select-v2>
</el-form-item>
</el-row>
<div style="align-content: center;">
<el-row>
<el-button type="primary"
style="height: 30px; width: 80px; margin: auto 5px 5px auto; color: black;"
@click="search()">查询
</el-button>
<el-button type="warning"
style="height: 30px; width: 80px; margin: auto 5px 5px auto; color: black;"
@click="clearQuery()">清空
</el-button>
</el-row>
<el-row>
<el-button
style="height: 30px; width: 80px; margin: auto 5px 5px auto; background-color: #32CD32; color: #000;"
@click="exportExcel()">导出看板
</el-button>
</el-row>
</div>
</div>
</el-form>
</fieldset>
<div class="table-area">
<el-table :data="kanbanList" stripe border v-loading="tableLoading" class="table-class"
:max-height="maxHeight" highlight-current-row @row-click="getCurrentRow"
:header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }"
@sort-change="handleSortChange">
<el-table-column width="65px" fixed="left">
<template v-slot="scope">
<el-radio :label="scope.row.recordId" v-model="recordId">&nbsp;</el-radio>
</template>
</el-table-column>
<el-table-column prop="recordId" label="id" fixed="left" min-width="120px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="goodsId" label="料号" show-overflow-tooltip sortable="custom"
min-width="120px"/>
<el-table-column prop="kanbanId" label="看板id" min-width="120px" sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="kanbanStatus" label="看板状态" sortable="custom"
:formatter="kanbanStatusFormat" min-width="120px" show-overflow-tooltip/>
</el-table>
<br/>
<el-pagination v-model:current-page="baseTableQuery.currentPage"
v-model:page-size="baseTableQuery.pageSize" :page-sizes="[10, 25, 50]" :small="false"
:disabled="false" :background="false" :default-page-size="10" @size-change="search"
@current-change="search" layout="total, sizes, prev, pager, next, jumper"
:total="baseTableQuery.total"/>
</div>
</div>
</el-container>
</el-config-provider>
</template>
<script setup>
import store from '@/store'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import {queryKanbanByPage} from '@/api/kateWork.js'
import {ref, reactive, onMounted, nextTick, onBeforeUnmount} from 'vue'
import {ElMessage} from 'element-plus'
import {genTableRequest, addAllOptionOfOptions} from '@/utils/generator.js'
import {labelPosition} from '@/constant/form'
import {kanbanStatusOptions} from '@/constant/options'
import {dateFormatter} from '@/utils/formatter.js'
import {exportKanbanExcel} from '@/api/excel.js'
/**
* 常量定义
*/
const STAND_ID = store.getters.getStandId
const USER_NAME = store.getters.getUserName
/**
* 变量定义
*/
let maxHeight = ref(window.innerHeight * 0.55)
let tableLoading = ref(false)
let kanbanList = ref([])
let baseTableQuery = reactive({
currentPage: 1,
pageSize: 10,
total: 0,
sortBy: new Map([['goodsId', true]]),
standId: STAND_ID,
userName: USER_NAME
})
let kanbanQuery = reactive({
goodsId: '',
kanbanId: '',
kanbanStatus: -99
})
let kanbanQueryFormRef = ref()
let recordId = ''
/**
* 系统方法
*/
onMounted(() => {
nextTick(() => {
window.addEventListener('resize', resizeHeight)
search()
})
})
onBeforeUnmount(() => {
nextTick(() => {
window.removeEventListener('resize', resizeHeight)
})
})
const resizeHeight = () => {
maxHeight.value = window.innerHeight * 0.55
}
/**
* 自定义方法
*/
// 查询
const search = () => {
tableLoading.value = true
let request = genTableRequest(baseTableQuery)
// 设定查询参数
request.goodsId = kanbanQuery.goodsId
request.kanbanId = kanbanQuery.kanbanId
request.kanbanStatus = kanbanQuery.kanbanStatus === -99 ? null : kanbanQuery.kanbanStatus
queryKanbanByPage(request).then((res) => {
const response = res.data
if (response.code === 0) {
const data = response.data
if (data != null) {
kanbanList.value = data.lists
baseTableQuery.total = data.total
} else {
kanbanList.value = []
baseTableQuery.total = 0
}
} else {
ElMessage.error(response.message)
}
}).catch(err => {
console.log(err)
ElMessage.error('查询看板信息异常。')
}).finally(() => {
tableLoading.value = false
})
}
// 清空查询
const clearQuery = () => {
kanbanQuery.goodsId = ''
kanbanQuery.kanbanId = ''
kanbanQuery.kanbanStatus = -99
}
// 处理排序
const handleSortChange = (data) => {
if (baseTableQuery.sortBy.has(data.prop)) {
baseTableQuery.sortBy.delete(data.prop)
}
baseTableQuery.sortBy.set(data.prop, data.order.toLowerCase() === 'ascending')
search()
}
const getCurrentRow = (row) => {
recordId = row.recordId
}
// 看板状态格式化
const kanbanStatusFormat = (row, column, cellValue, index) => {
switch (cellValue) {
case 0:
return '空'
case 1:
return '满'
default:
return '异常'
}
}
// 导出看板
const exportExcel = () => {
const params = {
goodsId: kanbanQuery.goodsId,
kanbanId: kanbanQuery.kanbanId,
kanbanStatus: kanbanQuery.kanbanStatus == -99 ? null : kanbanQuery.kanbanStatus,
standId: STAND_ID,
userName: USER_NAME
}
exportKanbanExcel(params).then(res => {
const link = document.createElement('a');//创建a标签
try {
// let blob = new Blob([res.data],{type: 'application/vnd.ms-excel'}); //如果后台返回的不是blob对象类型先定义成blob对象格式该type导出为xls格式
let blob = res.data //如果后台返回的直接是blob对象类型直接获取数据
// let _fileName = res.headers['content-disposition'].split(';')[1].split('=')[1]; //拆解获取文件名,如果后端有给返回文件名的话
let _fileName = '看板需求' + dateFormatter(new Date) + '.xlsx'
link.style.display = 'none'//隐藏
// 兼容不同浏览器的URL对象
const url = window.URL || window.webkitURL || window.moxURL
link.href = url.createObjectURL(blob)
link.setAttribute('download', _fileName.substring(_fileName.lastIndexOf('_') + 1))
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
url.revokeObjectURL(link.href)//移除url对象
} catch (e) {
console.log(e)
ElMessage.error('下载文件失败')
}
}).catch(err => {
console.log(err)
ElMessage.error('导出失败')
})
}
</script>
<style scoped>
.content {
display: flex;
width: 100%;
}
.work-area {
width: 100%;
/* padding: 5px; */
}
.search-area {
margin: auto;
min-height: fit-content;
max-height: 40%;
margin-bottom: 10px;
min-width: inherit;
border: solid 1px;
border-radius: 10px;
box-shadow: 0px 15px 10px -15px #000;
overflow: auto;
padding: 10px;
}
.table-area {
margin: auto;
min-height: fit-content;
max-height: 60%;
margin-bottom: 10px;
min-width: inherit;
border: solid 1px;
border-radius: 10px;
box-shadow: 0px 15px 10px -15px #000;
overflow: auto;
padding: 10px;
}
.el-form-item {
margin: 5px 5px 5px 5px;
}
.el-form-item .el-input {
width: 196px;
}
.table-class {
margin: 5px 5px 5px 5px;
width: inherit;
}
.el-pagination {
padding-left: 5px;
}
.my-autocomplete li {
width: 196px;
line-height: normal;
padding: 7px;
}
.my-autocomplete li .name {
text-overflow: ellipsis;
overflow: hidden;
}
.my-autocomplete li .addr {
font-size: 12px;
color: #b4b4b4;
}
.my-autocomplete li .highlighted .addr {
color: #ddd;
}
.my-autocomplete li .goods_id {
color: brown;
}
.my-autocomplete li .goods_name {
color: cornflowerblue;
}
</style>