|
|
<template> <div class="mod-config"> <el-row> <el-col :span="24"> <!-- <div>--><!-- <span @click="favoriteFunction()">--><!-- <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>--><!-- </span>--><!-- </div>--> <el-form :inline="true" label-position="top" > <el-form-item label="备品备件编码"> <el-input v-model="queryForm.partNo" clearable></el-input> </el-form-item> <el-form-item label="备品备件名称"> <el-input v-model="queryForm.partDescription" clearable></el-input> </el-form-item> <el-form-item label="规格型号"> <el-input v-model="queryForm.spec" clearable></el-input> </el-form-item> <el-form-item label="序列号"> <el-input v-model="queryForm.batchNo" clearable></el-input> </el-form-item> <el-form-item label="仓库"> <el-select v-model="queryForm.warehouseId"> <el-option value="" label="全部"></el-option> <el-option v-for="(item,index) in wareHouseList " :key="item.warehouseId" :value="item.warehouseId" :label="item.warehouseName"></el-option> </el-select> </el-form-item> <el-form-item label="汇总方式"> <el-select v-model="queryForm.groupType"> <el-option value="0" label="料号+序号"></el-option> <el-option value="1" label="料号"></el-option> </el-select> </el-form-item> <el-form-item label=" "> <el-button type="primary" @click="getDataList()">查询</el-button> <el-button type="primary" :disabled="this.dataListSelections.length==0" @click="printList()">打印</el-button> <download-excel :fields="fields()" :data="exportData" type="xls" :name="exportName" :header="exportHeader" :footer="exportFooter" :fetch="createExportData" :before-generate="startDownload" :before-finish="finishDownload" worksheet="导出信息" class="el-button el-button--primary el-button--medium"> {{ "导出" }} </download-excel> </el-form-item> </el-form> <el-form :inline="true" label-position="top" > <el-form-item label="录入日期"> <el-date-picker style="width: 145px" v-model="queryForm.startFirstInDate" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择日期"> </el-date-picker> - <el-date-picker style="width: 145px" v-model="queryForm.endFirstInDate" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd 23:59:59" placeholder="选择日期"> </el-date-picker> </el-form-item> <el-form-item label="在库数量范围"> <el-input style="width: 145px" v-model="queryForm.startQtyOnHand" clearable></el-input> - <el-input style="width: 145px" v-model="queryForm.endQtyOnHand" clearable></el-input> </el-form-item> <el-form-item label="货位编码"> <el-input v-model="queryForm.locationId" clearable></el-input> </el-form-item> <el-form-item label="安全库存汇总"> <el-select v-model="queryForm.safetyStock" clearable style="width: 100px"> <el-option label="安全" value="安全"></el-option> <el-option label="不安全" value="不安全"></el-option> </el-select> </el-form-item> <el-form-item label="BU"> <el-select v-model="queryForm.buNo" placeholder="请选择" style="width: 120px"> <el-option label="全部" value=""> </el-option> <el-option v-for = "i in buList" :key = "i.buNo" :label = "i.buDesc" :value = "i.buNo"> </el-option> </el-select> </el-form-item> </el-form> </el-col> </el-row> <el-table :data="dataList" border :height="height" v-loading="dataListLoading" @selection-change="handleSelectionChange" :row-style="controlRowStyle" style="width: 100%;"> <el-table-column v-if="queryForm.groupType==0" type="selection" header-align="center" align="center" width="50"> </el-table-column> <el-table-column v-for="(item,index) in columnList" :key="index" :sortable="item.columnSortable" :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip" :align="item.align" :fixed="item.fixed==''?false:item.fixed" :min-width="item.columnWidth" :label="item.columnLabel"> <template slot-scope="scope"> <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span> <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span> </template> </el-table-column> </el-table> <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[20, 100, 500, 1000]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"> </el-pagination>
</div></template>
<script>import { getInventoryStockList,partSpareTemp} from '@/api/partspare/inventorystock.js'import { getWareHouseList,} from '@/api/partspare/wareHouseEntity.js'import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'import {getAllBuList}from '@/api/factory/site.js'import {getTableDefaultListLanguage, getTableUserListLanguage} from "../../../api/table";export default { data() { return { buList: [], // 是否收藏
favorite: false, // 导出 start
exportData: [], exportName: "库存信息" + this.dayjs().format('YYYYMMDDHHmmss'), exportHeader: ["库存信息"], exportFooter: [], exportList:[], // 导出 end
queryForm: { site: this.$store.state.user.site, limit: 1, page: '', partNo: '', partDescription: '', spec: '', batchNo: '', warehouseId: '', locationId: '', startFirstInDate: '', endFirstInDate: '', startQtyOnHand: '', endQtyOnHand: '', groupType: '0', active: 'Y', safetyStock: '', buNo: '', }, dataList: [], wareHouseList: [], pageIndex: 1, pageSize: 20, totalPage: 0, height: 200, dataListLoading: false, dataListSelections: [], addOrUpdateVisible: false, // 展示列集
columnList: [], // 料号汇总
arrayPart: [ { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1BuDesc', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'buDesc', headerAlign: "center", align: "left", columnLabel: 'BU', columnHidden: false, columnImage: false, columnSortable: true, sortLv: 0, status: true, fixed: '', columnWidth: 80, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1PartNo', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'partNo', headerAlign: "center", align: "left", columnLabel: '备品备件编码', columnHidden: false, columnImage: false, columnSortable: true, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1PartDescription', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'partDescription', headerAlign: "center", align: "left", columnLabel: '备品备件名称', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1WarehouseId', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'warehouseId', headerAlign: "center", align: "left", columnLabel: '仓库编码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1LocationId', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'locationId', headerAlign: "center", align: "left", columnLabel: '货位编码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1InQty', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'inQty', headerAlign: "center", align: "right", columnLabel: '入库数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1OutQty', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'outQty', headerAlign: "center", align: "right", columnLabel: '出库数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1QtyOnHand', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'qtyOnHand', headerAlign: "center", align: "right", columnLabel: '在库数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1MaxStock', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'maxStock', headerAlign: "center", align: "right", columnLabel: '最高库存数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, {
userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1MinStock', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'minStock', headerAlign: "center", align: "right", columnLabel: '最低库存数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, },{ userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table1Spec', tableId: '200101103Table1', tableName: '库存信息汇总表', columnProp: 'spec', headerAlign: "center", align: "right", columnLabel: '规格型号', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }], // 料号_序号
arrayColumns: [ { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2BuDesc', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'buDesc', headerAlign: "center", align: "left", columnLabel: 'BU', columnHidden: false, columnImage: false, columnSortable: true, sortLv: 0, status: true, fixed: '', columnWidth: 80, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2PartNo', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'partNo', headerAlign: "center", align: "left", columnLabel: '备品备件编码', columnHidden: false, columnImage: false, columnSortable: true, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2PartDescription', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'partDescription', headerAlign: "center", align: "left", columnLabel: '备品备件名称', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2BatchNo', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'batchNo', headerAlign: "center", align: "left", columnLabel: '序列号', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2WarehouseId', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'warehouseId', headerAlign: "center", align: "left", columnLabel: '仓库编码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2LocationId', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'locationId', headerAlign: "center", align: "left", columnLabel: '货位编码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2Umid', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'umid', headerAlign: "center", align: "left", columnLabel: '单位', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 100, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2AveragePrice', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'averagePrice', headerAlign: "center", align: "right", columnLabel: '单价', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2InQty', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'inQty', headerAlign: "center", align: "right", columnLabel: '入库数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2OutQty', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'outQty', headerAlign: "center", align: "right", columnLabel: '出库数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2QtyOnHand', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'qtyOnHand', headerAlign: "center", align: "right", columnLabel: '在库数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2MaxStock', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'maxStock', headerAlign: "center", align: "right", columnLabel: '最高库存数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2MinStock', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'minStock', headerAlign: "center", align: "right", columnLabel: '最低库存数量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2TotalCost', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'totalCost', headerAlign: "center", align: "right", columnLabel: '总成本', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2Spec', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'spec', headerAlign: "center", align: "left", columnLabel: '规格型号', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2PartnerId', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'partnerId', headerAlign: "center", align: "left", columnLabel: '操作员', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }, { userId: this.$store.state.user.name, functionId: 200101103, serialNumber: '200101103Table2FirstInDate', tableId: '200101103Table2', tableName: '库存信息序号表', columnProp: 'firstInDate', headerAlign: "center", align: "left", columnLabel: '录入日期', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 140, }] } }, watch: { 'queryForm.groupType': { handler(newVal, oldVal) { if (this.queryForm.groupType==0){ this.columnList = this.arrayColumns }else { this.columnList = this.arrayPart } }, deep: true, immediate: true } }, activated() { // this.getDataList()
// this.getWareHouseList()
}, created() { // 动态列
this.getTableUserColumn(this.$route.meta.menuId+'table1',1) this.getTableUserColumn(this.$route.meta.menuId+'table2',2) this.getDataList() this.getWareHouseList() }, mounted() { this.favoriteIsOk() this. getBu () this.$nextTick(() => { this.height = window.innerHeight - 210 this.columnList = this.arrayColumns }) }, methods: { // 校验用户是否收藏
favoriteIsOk() { let userFavorite = { userId: this.$store.state.user.id, languageCode: this.$i18n.locale } userFavoriteList(userFavorite).then(({data}) => { for (let i = 0; i < data.list.length; i++) { if(this.$route.meta.menuId === data.list[i].menuId){ this.favorite = true } } }) }, // 收藏 OR 取消收藏
favoriteFunction() { let userFavorite = { userId: this.$store.state.user.id, functionId: this.$route.meta.menuId, } if (this.favorite) { // 取消收藏
this.$confirm(`确定取消收藏`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { removeUserFavorite(userFavorite).then(({data}) => { this.$message.success(data.msg) this.favorite = false }) }) } else { // 收藏
saveUserFavorite(userFavorite).then(({data}) => { this.$message.success(data.msg) this.favorite = true }) }
},
// 获取仓库列表
getWareHouseList(){ let wareHouse = { site: this.$store.state.user.site, active: 'Y', warehousetype: "备品备件仓", } getWareHouseList(wareHouse).then(({data}) =>{ if (data.code == 0 && data.data){ this.wareHouseList = data.data } }) }, handleSelectionChange(val) { this.dataListSelections = val; }, // 批量打印
printList(){ partSpareTemp(this.dataListSelections) },
// 控制单行的背景颜色
controlRowStyle({row, rowIndex}) { // 当前行在库数量
let qtyOnHand = row.qtyOnHand // 当前行最低库存数量
let minStock = row.minStock // 区分不同的样式对应不同的颜色
if (qtyOnHand <= minStock) { return { 'background-color': '#D8ECF1', cursor: 'pointer' } } },
// 获取数据列表
getDataList() { this.dataListLoading = true this.queryForm.page = this.pageIndex this.queryForm.limit = this.pageSize getInventoryStockList(this.queryForm).then(({data}) => { if (data && data.code === 0) { this.dataList = data.page.list this.totalPage = data.page.totalCount } else { this.dataList = [] this.totalPage = 0 } this.dataListLoading = false }) }, // 每页数
sizeChangeHandle(val) { this.pageSize = val this.pageIndex = 1 this.getDataList() }, // 当前页
currentChangeHandle(val) { this.pageIndex = val this.getDataList() }, //导出excel
async createExportData() { this.queryForm.limit = -1 this.queryForm.page = 1 await getInventoryStockList(this.queryForm).then(({data}) => { this.exportList= data.page.list; })
return this.exportList; }, startDownload() { // this.exportData = this.dataList
}, finishDownload() {
}, fields() { let json = "{" this.columnList.forEach((item, index) => { if (index == this.columnList.length - 1) { json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" } else { json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + "," } }) json += "}" let s = eval("(" + json + ")")
return s }, // 导出 end
getBu () { let tempData = { username: this.$store.state.user.name, } getAllBuList(tempData).then(({data}) => { if (data.code === 0) { this.buList = data.rows } }) },
// 动态列开始 获取 用户保存的 格式列
async getTableUserColumn(tableId, columnId) { let queryTableUser = { userId: this.$store.state.user.name, functionId: this.$route.meta.menuId, tableId: tableId, status: true, languageCode: this.$i18n.locale } await getTableUserListLanguage(queryTableUser).then(({data}) => { if (data.rows.length > 0) { //this.columnList1 = []
switch (columnId) { case 1: this.arrayColumns = data.rows break; case 2: this.arrayPart = data.rows break; // case 3:
// this.columnList2 = data.rows
// break;
// case 4:
// this.columnList3 = data.rows
// break;
} } else { this.getColumnList(tableId, columnId) } }) },
// 获取 tableDefault 列
async getColumnList (tableId, columnId) { let queryTable= { functionId: this.$route.meta.menuId, tableId: tableId, languageCode: this.$i18n.locale } await getTableDefaultListLanguage(queryTable).then(({data}) => { if (!data.rows.length == 0) { switch (columnId) { case 1: this.arrayColumns = data.rows break; case 2: this.arrayPart = data.rows break; // case 3:
// this.columnList2 = data.rows
// break;
// case 4:
// this.columnList3 = data.rows
// break;
} } else { // this.showDefault = true.
} }) }, }}</script>
|