装箱单修改
This commit is contained in:
@@ -22,25 +22,24 @@
|
||||
<el-upload :on-remove="handleRemove" :file-list="itemFile" action=""/>
|
||||
</div>
|
||||
<div v-if="worksheet.length !== 0" style="float: right;margin: 20px 0">
|
||||
<el-button icon="el-icon-upload2" type="primary" size="small" @click="basicPartsToSQL">导入到数据库</el-button>
|
||||
<el-button :disabled="disabled" icon="el-icon-upload2" type="primary" size="small" @click="basicPartsToSQL">导入到数据库</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<specification-data ref="specificationData" :groups-names="groupsNames" :machine-names="machineNames" :project-name="projectName" @machineChange="machineChange"/>
|
||||
<el-upload
|
||||
class="upload-demo"
|
||||
drag
|
||||
action="http://localhost:8410/submit/uploadImg.ashx?InvoiceNum=1"
|
||||
multiple>
|
||||
<i class="el-icon-upload"/>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
|
||||
</el-upload>
|
||||
<!--<el-upload-->
|
||||
<!--class="upload-demo"-->
|
||||
<!--drag-->
|
||||
<!--action="http://localhost:8410/submit/uploadImg.ashx?InvoiceNum=1"-->
|
||||
<!--multiple>-->
|
||||
<!--<i class="el-icon-upload"/>-->
|
||||
<!--<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>-->
|
||||
<!--<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>-->
|
||||
<!--</el-upload>-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/* eslint-disable */
|
||||
import UploadExcelComponent from './UploadExcel/index.vue'
|
||||
import specificationData from './specificationData'
|
||||
import { sleep } from '../../../utils/tool'
|
||||
@@ -58,7 +57,8 @@ export default {
|
||||
loading: false,
|
||||
groupsNames: [],
|
||||
machineNames: [],
|
||||
err: 0
|
||||
err: 0,
|
||||
disabled: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -88,6 +88,10 @@ export default {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
async test() {
|
||||
await sleep(10000)
|
||||
console.log(1)
|
||||
},
|
||||
fetchData() {
|
||||
this.getSelect(initProject, ['项目名称', '项目流水号'], 'project')
|
||||
},
|
||||
@@ -112,7 +116,7 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
selected(data) { // 选择需要导入的文件
|
||||
async selected(data) { // 选择需要导入的文件
|
||||
this.worksheet = data.worksheet // 获取每个多选文件的表格坐标及值
|
||||
this.itemFile = data.itemFile
|
||||
},
|
||||
@@ -131,6 +135,7 @@ export default {
|
||||
async basicPartsToSQL() {
|
||||
try {
|
||||
this.loading = true
|
||||
this.dispatch = true
|
||||
this.err = 0
|
||||
for (let j = this.worksheet.length - 1; j >= 0; j--) {
|
||||
let establishment,
|
||||
@@ -154,48 +159,51 @@ export default {
|
||||
manufacturer,
|
||||
remarks,
|
||||
classificationCode
|
||||
const response = await isExit(this.projectValue, this.worksheet[j].F2.v)
|
||||
const res = response.data
|
||||
if (res[0].Column1 === 0) {
|
||||
this.$notify.error(`${this.worksheet[j].F2.v}机床不存在,请确认文件是否正确`)
|
||||
this.loading = false
|
||||
return
|
||||
const response = await isExit(this.projectValue, this.worksheet[j].F2.v)
|
||||
const res = response.data
|
||||
if (res[0].Column1 === 0) {
|
||||
this.$notify.error(`${this.worksheet[j].F2.v}机床不存在,请确认文件是否正确`)
|
||||
this.loading = false
|
||||
this.disabled = false
|
||||
return
|
||||
} else {
|
||||
this.worksheet[j].G1 ? establishment = this.worksheet[j].G1.v : establishment = ''
|
||||
this.worksheet[j].I1 ? proofread = this.worksheet[j].I1.v : proofread = ''
|
||||
this.worksheet[j].L1 ? review = this.worksheet[j].L1.v : review = ''
|
||||
this.worksheet[j].P1 ? date = this.worksheet[j].P1.v : date = ''
|
||||
this.worksheet[j].Q1 ? pageNum = parseInt(this.worksheet[j].Q1.v.replace(/[^0-9]/ig, '')) : pageNum = ''
|
||||
this.worksheet[j].C2 ? machineName = this.worksheet[j].C2.v : machineName = ''
|
||||
this.worksheet[j].F2 ? machineNum = this.worksheet[j].F2.v : machineNum = ''
|
||||
this.worksheet[j].J2 ? componentName = this.worksheet[j].J2.v : componentName = ''
|
||||
this.worksheet[j].P2 ? componentNum = this.worksheet[j].P2.v : componentNum = ''
|
||||
this.worksheet[j].Q2 ? totalNum = parseInt(this.worksheet[j].Q2.v.replace(/[^0-9]/ig, '')) : totalNum = ''
|
||||
this.worksheet[j].R2 ? contractNum = this.worksheet[j].R2.v : contractNum = ''
|
||||
this.worksheet[j].M2 ? groupNum = this.worksheet[j].M2.v : groupNum = ''
|
||||
const len = parseInt(this.worksheet[j]['!ref'].split(':')[1].substring(1)) - 3
|
||||
for (let i = 0; i < len; i++) {
|
||||
const attr = i + 4
|
||||
drawingNum = this.worksheet[j][`B${attr}`] ? this.worksheet[j][`B${attr}`].v : ''
|
||||
name = this.worksheet[j][`D${attr}`] ? this.worksheet[j][`D${attr}`].v : ''
|
||||
type = this.worksheet[j][`F${attr}`] ? this.worksheet[j][`F${attr}`].v : ''
|
||||
material = this.worksheet[j][`J${attr}`] ? this.worksheet[j][`J${attr}`].v : ''
|
||||
spareNum = this.worksheet[j][`L${attr}`] ? this.worksheet[j][`L${attr}`].v : ''
|
||||
useNum = this.worksheet[j][`M${attr}`] ? this.worksheet[j][`M${attr}`].v : ''
|
||||
manufacturer = this.worksheet[j][`O${attr}`] ? this.worksheet[j][`O${attr}`].v : ''
|
||||
remarks = this.worksheet[j][`Q${attr}`] ? this.worksheet[j][`Q${attr}`].v : ''
|
||||
classificationCode = this.worksheet[j][`R${attr}`] ? this.worksheet[j][`R${attr}`].v : ''
|
||||
if (!drawingNum && !name && !type && !material && !spareNum && !useNum && !manufacturer && !remarks && !classificationCode) { // 当图号、名称、规格、材料、备件数量、装机数量、制造商、备注、分类码都为空时,循环终止,防止向数据库中插入多余且无用的数据
|
||||
break
|
||||
} else {
|
||||
this.worksheet[j].G1 ? establishment = this.worksheet[j].G1.v : establishment = ''
|
||||
this.worksheet[j].I1 ? proofread = this.worksheet[j].I1.v : proofread = ''
|
||||
this.worksheet[j].L1 ? review = this.worksheet[j].L1.v : review = ''
|
||||
this.worksheet[j].P1 ? date = this.worksheet[j].P1.v : date = ''
|
||||
this.worksheet[j].Q1 ? pageNum = parseInt(this.worksheet[j].Q1.v.replace(/[^0-9]/ig, '')) : pageNum = ''
|
||||
this.worksheet[j].C2 ? machineName = this.worksheet[j].C2.v : machineName = ''
|
||||
this.worksheet[j].F2 ? machineNum = this.worksheet[j].F2.v : machineNum = ''
|
||||
this.worksheet[j].J2 ? componentName = this.worksheet[j].J2.v : componentName = ''
|
||||
this.worksheet[j].P2 ? componentNum = this.worksheet[j].P2.v : componentNum = ''
|
||||
this.worksheet[j].Q2 ? totalNum = parseInt(this.worksheet[j].Q2.v.replace(/[^0-9]/ig, '')) : totalNum = ''
|
||||
this.worksheet[j].R2 ? contractNum = this.worksheet[j].R2.v : contractNum = ''
|
||||
this.worksheet[j].M2 ? groupNum = this.worksheet[j].M2.v : groupNum = ''
|
||||
const len = parseInt(this.worksheet[j]['!ref'].split(':')[1].substring(1)) - 3
|
||||
for (let i = 0; i < len; i++) {
|
||||
const attr = i + 4
|
||||
drawingNum = this.worksheet[j][`B${attr}`] ? this.worksheet[j][`B${attr}`].v : ''
|
||||
name = this.worksheet[j][`D${attr}`] ? this.worksheet[j][`D${attr}`].v : ''
|
||||
type = this.worksheet[j][`F${attr}`] ? this.worksheet[j][`F${attr}`].v : ''
|
||||
material = this.worksheet[j][`J${attr}`] ? this.worksheet[j][`J${attr}`].v : ''
|
||||
spareNum = this.worksheet[j][`L${attr}`] ? this.worksheet[j][`L${attr}`].v : ''
|
||||
useNum = this.worksheet[j][`M${attr}`] ? this.worksheet[j][`M${attr}`].v : ''
|
||||
manufacturer = this.worksheet[j][`O${attr}`] ? this.worksheet[j][`O${attr}`].v : ''
|
||||
remarks = this.worksheet[j][`Q${attr}`] ? this.worksheet[j][`Q${attr}`].v : ''
|
||||
classificationCode = this.worksheet[j][`R${attr}`] ? this.worksheet[j][`R${attr}`].v : ''
|
||||
if (!drawingNum && !name && !type && !material && !spareNum && !useNum && !manufacturer && !remarks && !classificationCode) { // 当图号、名称、规格、材料、备件数量、装机数量、制造商、备注、分类码都为空时,循环终止,防止向数据库中插入多余且无用的数据
|
||||
break
|
||||
if (machineNum && groupNum) {
|
||||
await sleep(50)
|
||||
await this.insertToSQL(establishment, proofread, review, date, machineName, machineNum, componentName, componentNum, groupNum, contractNum, pageNum, totalNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
|
||||
} else {
|
||||
if (machineNum && groupNum) {
|
||||
await this.insertToSQL(establishment, proofread, review, date, machineName, machineNum, componentName, componentNum, groupNum, contractNum, pageNum, totalNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
|
||||
} else {
|
||||
this.loading = false
|
||||
this.$notify.error(`请确认导入文件是否正确`)
|
||||
return
|
||||
}
|
||||
this.loading = false
|
||||
this.disabled = false
|
||||
this.$notify.error(`请确认导入文件是否正确`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.itemFile.splice(j, 1)
|
||||
@@ -213,14 +221,12 @@ export default {
|
||||
async insertToSQL(establishment, proofread, review, date, machineName, machineNum, componentName, componentNum, groupNum, contractNum, pageNum, totalNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode) {
|
||||
try {
|
||||
if (groupNum.indexOf('MX') > -1) {
|
||||
await sleep(10)
|
||||
const response = await importBasics(establishment, proofread, review, date, this.projectName, machineNum, machineName, componentName, componentNum, groupNum, contractNum, totalNum, pageNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
|
||||
const res = response.data
|
||||
if (res[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
} else {
|
||||
await sleep(10)
|
||||
const response = await importPurcharse(establishment, proofread, review, date, this.projectName, machineNum, machineName, componentName, componentNum, groupNum, contractNum, totalNum, pageNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
|
||||
const res = response.data
|
||||
if (res[0].result === '0') {
|
||||
|
||||
Reference in New Issue
Block a user