同步项目变更

This commit is contained in:
Developer
2026-06-27 09:02:07 +08:00
parent 99c7077865
commit 137e276340
16 changed files with 8028 additions and 22 deletions

View File

@@ -7,6 +7,7 @@
<el-input v-model="specificationsModel" style="width: 150px " size="small" clearable placeholder="图号或型号"/>
<el-input v-model="LocationName" style="width: 100px " size="small" clearable placeholder="库位"/>
<el-button style="margin-left: 7px;width: 80px" type="primary" plain size="small" @click="pageCurrent=1;searchTable()">查询</el-button>
<el-button type="primary" plain icon="el-icon-upload2" size="small" style="margin-left: 7px" @click="handleExcel()">导入查询</el-button>
<el-button v-if="Number(token) === 2" type="success" plain icon="el-icon-download" size="small" style="margin-left: 7px" @click="exportExcel()">导出</el-button>
<el-button type="distribution" size="small" @click="addMaterial()">增加物料存货</el-button>
<el-button type="primary" icon="el-icon-printer" style="margin-left: 20px" plain size="small" @click="Pronters()">批量打印</el-button>
@@ -162,6 +163,22 @@
<el-button type="primary" size="small" @click="submitMaterialChange">确定</el-button>
</div>
</el-dialog>
<el-dialog
v-el-drag-dialog
:visible.sync="dialogFormVisibleExcel"
title="导入查询"
center
width="720px">
<upload-excel-component @on-selected-file="selected"/>
<div style="margin: 10px 0 0 45px">
<span v-show="worksheet.length > 1" style="cursor: pointer;width: 50px;" @click="removeAll"><i class="el-icon-close"/></span>
<el-upload :on-remove="handleRemove" :file-list="itemFile" style="width: 260px" action=""/>
</div>
<div slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogFormVisibleExcel=false">取消</el-button>
<el-button type="primary" size="small" icon="el-icon-search" @click="importExcelSearch">查询</el-button>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible" title="增加产品" center width="390px">
<el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="100px" class="demo-ruleForm" style="margin: auto">
<el-row>
@@ -200,11 +217,14 @@
import { ExecDatabase } from '@/main'
import { wsuri } from '@/utils/request'
import { mapGetters } from 'vuex'
import UploadExcelComponent from '@/views/TechnologyCenter/ImportBOM/UploadExcel/index.vue'
export default {
components: { UploadExcelComponent },
data() {
return {
dialogFormVisible: false,
dialogFormVisible1: false,
dialogFormVisibleExcel: false,
title: '',
materialName: '',
materialSpec: '',
@@ -223,6 +243,8 @@ export default {
productName: [],
editorialStaff: [],
multipleSelection: [],
itemFile: [],
worksheet: [],
rules: {
入库数: [{ required: true, message: '请输入入库数' }],
产品名称: [{ required: true, message: '请选择产品名称' }]
@@ -362,6 +384,157 @@ export default {
}
})
},
handleExcel() {
this.dialogFormVisibleExcel = true
},
selected(data) {
this.worksheet = data.worksheet
this.itemFile = data.itemFile
},
handleRemove(file) {
for (let i = 0; i < this.itemFile.length; i++) {
if (this.itemFile[i].name === file.name) {
this.worksheet.splice(i, 1)
this.itemFile.splice(i, 1)
}
}
},
removeAll() {
this.worksheet = []
this.itemFile = []
},
getExcelCellValue(sheet, col, row) {
var cell = sheet[col + row]
if (!cell || cell.v === undefined || cell.v === null) {
return ''
}
return String(cell.v).trim()
},
getImportColumns(sheet) {
var cols = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
]
var result = {
headerRow: 1,
nameCol: 'B',
drawingCol: 'A'
}
for (let row = 1; row <= 10; row++) {
let nameCol = ''
let drawingCol = ''
for (let i = 0; i < cols.length; i++) {
var title = this.getExcelCellValue(sheet, cols[i], row).replace(/\s/g, '')
if (title === '物料名称' || title === '名称' || title === '零件名称') {
nameCol = cols[i]
}
if (title === '图号' || title === '图号型号' || title === '图号或型号' || title === '图号/型号' || title === '规格型号') {
drawingCol = cols[i]
}
}
if (nameCol || drawingCol) {
result.headerRow = row
result.nameCol = nameCol || result.nameCol
result.drawingCol = drawingCol || result.drawingCol
return result
}
}
return result
},
getImportDetail() {
var detail = []
for (let j = 0; j < this.worksheet.length; j++) {
var sheet = this.worksheet[j]
var columns = this.getImportColumns(sheet)
var emptyCount = 0
for (let row = columns.headerRow + 1; row <= 2000; row++) {
var materialName = this.getExcelCellValue(sheet, columns.nameCol, row)
var specificationsModel = this.getExcelCellValue(sheet, columns.drawingCol, row)
if (!materialName && !specificationsModel) {
emptyCount++
if (emptyCount >= 20) {
break
}
continue
}
emptyCount = 0
detail.push({
物料名称: materialName,
图号或型号: specificationsModel
})
}
}
return detail
},
getImportConditionList(detail) {
var conditionMap = {}
var conditionList = []
for (let i = 0; i < detail.length; i++) {
var materialName = String(detail[i].物料名称 || '').trim()
var drawing = String(detail[i].图号或型号 || '').trim()
var condition = materialName + '^' + drawing
if ((materialName || drawing) && !conditionMap[condition]) {
conditionMap[condition] = true
conditionList.push(condition)
}
}
return conditionList.join(',')
},
setTableData(rows) {
this.tableData = []
for (let i = 0; i < rows.length; i++) {
this.tableData.push({
物料编码: rows[i].物料编码,
物料名称: rows[i].物料名称,
图号或型号: rows[i].图号或型号,
物料与货位流水号: rows[i].物料与货位流水号,
类型: rows[i].类型,
单位: rows[i].单位,
库存: rows[i].库存,
货位流水号: rows[i].货位流水号,
货位名称: rows[i].货位名称,
批次编号: rows[i].批次编号,
编辑人: rows[i].编辑人,
编辑时间: rows[i].编辑时间,
库存_before: rows[i].库存,
货位流水号_before: rows[i].货位流水号,
货位名称_before: rows[i].货位名称,
打印条码数: 1,
edit: false
})
}
},
importExcelSearch() {
var detail = this.getImportDetail()
if (detail.length === 0) {
this.$message.warning('请导入包含物料名称或图号的表格')
return
}
let LocationName_check
this.LocationName ? LocationName_check = 1 : LocationName_check = 0
var param = []
param[0] = ['物料名称_check', 0]
param[1] = ['物料名称', '']
param[2] = ['图号或型号_check', 1]
param[3] = ['图号或型号', this.getImportConditionList(detail)]
param[4] = ['库位_check', LocationName_check]
param[5] = ['库位', this.LocationName]
param[6] = ['排序名称', this.orderName]
param[7] = ['排序方式', this.order]
this.pageCurrent = 1
var Data = this.CreateData('11', '仓储管理_库存盘点_查询', param, this.pageSize, this.pageCurrent)
this.loading = true
this.ExecDatabase(Data).then(response => {
var rows = response.data.rows || response.data || []
this.setTableData(rows)
this.total = response.data.total || rows.length
this.dialogFormVisibleExcel = false
this.loading = false
this.$message.success('导入查询完成')
}).catch(() => {
this.loading = false
})
},
exportExcel() {
if (this.tableData.length === 0) {
this.$message.warning('暂无数据')
@@ -403,28 +576,7 @@ export default {
ExecDatabase(Data).then(response => {
// console.log(response.data)
if (response.data.rows.length !== 0) {
for (let i = 0; i < response.data.rows.length; i++) {
this.tableData.push({
// 表示将从数据库中查询到的数据,分别对应填充到表格中
物料编码: response.data.rows[i].物料编码,
物料名称: response.data.rows[i].物料名称,
图号或型号: response.data.rows[i].图号或型号,
物料与货位流水号: response.data.rows[i].物料与货位流水号,
类型: response.data.rows[i].类型,
单位: response.data.rows[i].单位,
库存: response.data.rows[i].库存,
货位流水号: response.data.rows[i].货位流水号,
货位名称: response.data.rows[i].货位名称,
批次编号: response.data.rows[i].批次编号,
编辑人: response.data.rows[i].编辑人,
编辑时间: response.data.rows[i].编辑时间,
库存_before: response.data.rows[i].库存,
货位流水号_before: response.data.rows[i].货位流水号,
货位名称_before: response.data.rows[i].货位名称,
打印条码数: 1,
edit: false
})
}
this.setTableData(response.data.rows)
}
this.total = response.data.total
this.loading = false