家里的样式
This commit is contained in:
1066
src/views/TechnologyCenter/CreatePackingList/index.vue
Normal file
1066
src/views/TechnologyCenter/CreatePackingList/index.vue
Normal file
File diff suppressed because one or more lines are too long
297
src/views/TechnologyCenter/ImportChangeParts/index.vue
Normal file
297
src/views/TechnologyCenter/ImportChangeParts/index.vue
Normal file
@@ -0,0 +1,297 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-card v-loading="loading">
|
||||
<div style="width: 620px;margin: 0 auto">
|
||||
<div style="overflow: hidden">
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span>项目:</span>
|
||||
<el-select v-model="projectValue" filterable size="small" style="margin-top: 3px" placeholder="项目名称">
|
||||
<el-option
|
||||
v-for="item in project"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<span style="margin-left: 10px">类型:</span>
|
||||
<el-select v-model="groupName" filterable size="small" placeholder="类型">
|
||||
<el-option
|
||||
v-for="item in Group"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
</div>
|
||||
<upload-excel-component @on-selected-file="selected"/>
|
||||
</div>
|
||||
<div>
|
||||
<el-tooltip content="删除全部" placement="top">
|
||||
<span v-show="worksheet.length > 1" style="cursor: pointer;float: right;margin: 5px" @click="removeAll"><i class="el-icon-close"/></span>
|
||||
</el-tooltip>
|
||||
<el-upload :on-remove="handleRemove" :file-list="itemFile" action=""/>
|
||||
</div>
|
||||
<div v-if="worksheet.length !== 0" style="float: right;margin: 20px 0">
|
||||
<el-button :disabled="disabled" icon="el-icon-upload2" type="primary" size="small" @click="basicPartsToSQL">导入到数据库</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<specification-data1 ref="specificationData" :groups-names="groupsNames" :machine-names="machineNames" :project-name="projectName" :group-name="groupName" @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>-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UploadExcelComponent from '../ImportParts/UploadExcel/index.vue'
|
||||
import specificationData1 from './specificationData1'
|
||||
import { sleep } from '../../../utils/tool'
|
||||
import { initProject, isExit, importBasics, importPurcharse, searchMachine, searchGroupNum1 } from '../../../api/TechnologyCenter/ImportParts'
|
||||
|
||||
export default {
|
||||
name: 'UploadExcel',
|
||||
components: { UploadExcelComponent, specificationData1 },
|
||||
data() {
|
||||
return {
|
||||
project: [],
|
||||
projectValue: '',
|
||||
groupName: '',
|
||||
Group: [{
|
||||
value: 'MX',
|
||||
name: 'MX'
|
||||
}, {
|
||||
value: 'WG',
|
||||
name: 'WG'
|
||||
}, {
|
||||
value: 'BZ',
|
||||
name: 'BZ'
|
||||
}],
|
||||
group: '',
|
||||
worksheet: [],
|
||||
itemFile: [],
|
||||
loading: false,
|
||||
groupsNames: [],
|
||||
machineNames: [],
|
||||
err: 0,
|
||||
disabled: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
projectName() {
|
||||
for (let i = 0; i < this.project.length; i++) {
|
||||
if (this.project[i].value === this.projectValue) {
|
||||
return this.project[i].label
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
projectValue(val) {
|
||||
if (val) {
|
||||
this.groupsNames = []
|
||||
this.machineNames = []
|
||||
this.projectChange(this.projectName)
|
||||
}
|
||||
},
|
||||
project(val) {
|
||||
if (val.length > 0) {
|
||||
this.projectValue = val[0].value
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
async test() {
|
||||
await sleep(10000)
|
||||
console.log(1)
|
||||
},
|
||||
fetchData() {
|
||||
this.getSelect(initProject, ['项目名称', '项目流水号'], 'project')
|
||||
},
|
||||
// 根据项目获取机床
|
||||
projectChange(val) {
|
||||
this.machineNames = []
|
||||
if (val) {
|
||||
this.getSelect(searchMachine, ['机床'], 'machineNames', val)
|
||||
}
|
||||
},
|
||||
// 根据机床获取分组
|
||||
machineChange(val) {
|
||||
this.groupsNames = []
|
||||
if (val) {
|
||||
searchGroupNum1(this.projectName, val).then(response => {
|
||||
const res = response.data
|
||||
res.forEach(item => {
|
||||
this.groupsNames.push({
|
||||
value: item.组号
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
async 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 = []
|
||||
},
|
||||
async basicPartsToSQL() {
|
||||
try {
|
||||
this.loading = true
|
||||
this.dispatch = true
|
||||
this.err = 0
|
||||
for (let j = this.worksheet.length - 1; j >= 0; j--) {
|
||||
let establishment,
|
||||
proofread,
|
||||
review,
|
||||
date,
|
||||
machineName,
|
||||
machineNum,
|
||||
componentName,
|
||||
componentNum,
|
||||
groupNum,
|
||||
contractNum,
|
||||
pageNum,
|
||||
totalNum,
|
||||
drawingNum,
|
||||
name,
|
||||
type,
|
||||
material,
|
||||
spareNum,
|
||||
useNum,
|
||||
manufacturer,
|
||||
remarks,
|
||||
classificationCode
|
||||
console.log(this.worksheet[j].M2.v.substring(0, 1))
|
||||
this.group = this.worksheet[j].M2.v.substring(0, this.worksheet[j].M2.v.indexOf('-')) + '组'
|
||||
console.log(this.worksheet[j].J2.v.substring(0, 2), 11111111111)
|
||||
if (this.worksheet[j].M2.v.substring(0, 1) === '9' && this.worksheet[j].J2.v.substring(0, 2) === '整改') {
|
||||
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 = ''
|
||||
for (let i = 0; i < 999; 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 {
|
||||
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 {
|
||||
this.loading = false
|
||||
this.disabled = false
|
||||
this.$notify.error(`请确认导入文件是否正确`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.itemFile.splice(j, 1)
|
||||
this.worksheet.splice(j, 1)
|
||||
this.err === 0 ? this.$message.success(`导入完成`) : this.$message.error(`导入失败零件个数为${this.err},请检查文件是否正确`)
|
||||
} else {
|
||||
this.$message.error('只能导入整改组')
|
||||
}
|
||||
}
|
||||
this.loading = false
|
||||
this.projectChange(this.projectName) // 调用查询机床方法,通过watch属性检测变化会自动得到下面表格的值。
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.err++
|
||||
this.loading = false
|
||||
this.$notify.error(`导入数据错误,请检查导入文件是否正确`)
|
||||
console.log(`导入数据错误${e}`)
|
||||
}
|
||||
},
|
||||
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) {
|
||||
const response = await importBasics(establishment, proofread, review, date, this.projectName, machineNum, machineName, componentName, componentNum, this.group, contractNum, totalNum, pageNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
|
||||
const res = response.data
|
||||
console.log(res)
|
||||
if (res.hasOwnProperty('output') === false) {
|
||||
if (res[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
} else {
|
||||
if (res.result[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
if (res.output[0].导入类型 === '2') {
|
||||
this.$notify.warning(`存在重复数据`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const response = await importPurcharse(establishment, proofread, review, date, this.projectName, machineNum, machineName, componentName, componentNum, this.group, contractNum, totalNum, pageNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
|
||||
const res = response.data
|
||||
if (res.hasOwnProperty('output') === false) {
|
||||
if (res[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
} else {
|
||||
if (res.result[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
if (res.output[0].导入类型 === '2') {
|
||||
this.$notify.warning(`存在重复数据`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.err++
|
||||
this.$message.error(`导入数据错误`)
|
||||
console.log(`导入数据错误${e}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.wrapper{
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,770 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card>
|
||||
<div style="width: 900px;margin: 3px auto">
|
||||
<span>机床名称:</span>
|
||||
<el-select v-model="machineValue" filterable clearable size="small" placeholder="机床名称" @change="getGroups">
|
||||
<el-option
|
||||
v-for="item in machineNames"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<span style="margin-left: 10px">分组名称:</span>
|
||||
<el-select v-model="groupValue" filterable clearable size="small" placeholder="分组名称">
|
||||
<el-option
|
||||
v-for="item in groupsNames"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<el-button :loading="listLoading" :disabled="disabled" type="primary" plain icon="el-icon-d-caret" size="small" style="margin-left: 10px" @click="transferData">传递</el-button>
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="small" style="margin-left: 10px" @click="allDelete">一键删除</el-button>
|
||||
<el-row style="margin-top: 10px">
|
||||
<span>机床名称:</span>
|
||||
<el-input v-model="machineName" readonly size="small" placeholder="机床名称" style="width: 200px;"/>
|
||||
<span>机床数量:</span>
|
||||
<el-input v-model="machineNum" readonly size="small" placeholder="机床数量" style="width: 200px;"/>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="tableData"
|
||||
:row-class-name="tableRowClassName"
|
||||
size="mini"
|
||||
height="300"
|
||||
highlight-current-row
|
||||
border
|
||||
stripe
|
||||
@row-click="searchMaterial1">
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
width="50"/>
|
||||
<el-table-column align="center" label="物料状态" min-width="90">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.物料流水号===null" type="warning" size="small">不存在</el-tag>
|
||||
<el-tag v-if="scope.row.物料流水号!==null" type="primary" size="small">存在</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="图号" min-width="120">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.图号或者型号 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="名称" min-width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.名称 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="材料" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.材料或者规格 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="规格" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.规格 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="备件数量" width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.备件数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="装机数量" width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.装机数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="部件数量" width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.部件数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="制造商" min-width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.制造商 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="备注" width="80">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.备注 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="分类码" width="60">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.分类码 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="整改类型" width="300">
|
||||
<template slot-scope="scope">
|
||||
<el-radio-group v-model="scope.row.整改类型" @change="submitChangeType(scope.row)" >
|
||||
<el-radio :label="1" class="radio">新增</el-radio>
|
||||
<el-radio :label="2" class="radio">替换</el-radio>
|
||||
<el-radio :label="3" class="radio">补充加工</el-radio>
|
||||
</el-radio-group>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="旧图号" >
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.前图号或者型号 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="block" style="margin-top: 10px;">
|
||||
<el-pagination
|
||||
:current-page="pageCurrent"
|
||||
:page-sizes="[10, 20, 40, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"/>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<el-table
|
||||
:data="tableData10"
|
||||
:cell-class-name="cell"
|
||||
style="width: 100%"
|
||||
size="mini"
|
||||
highlight-current-row
|
||||
height="150"
|
||||
border
|
||||
stripe>
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
width="50"/>
|
||||
<el-table-column align="center" label="物料名称">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料名称 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料规格">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料规格 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料型号">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料型号 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="供货商">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.供货商 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" center style="min-height: 300px" width="800px">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="110px" class="demo-ruleForm">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="图号" prop="图号或者型号">
|
||||
<el-input
|
||||
v-model="form.图号或者型号"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="名称" prop="名称">
|
||||
<el-input
|
||||
v-model="form.名称"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item v-if="type === 1" label="材料" prop="材料">
|
||||
<el-select v-model="form.材料流水号" filterable clearable size="small" placeholder="机床名称">
|
||||
<el-option
|
||||
v-for="item in materials"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="type === 2" label="材料" prop="材料">
|
||||
<el-input v-model="form.物料名称" clearable size="small" style="width: 200px;" placeholder="物料流水号" @dblclick.native="materialShow"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="规格" prop="规格">
|
||||
<el-input
|
||||
v-model="form.规格"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="备件数量" prop="数量">
|
||||
<el-input
|
||||
v-model.number="form.备件数量"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="装机数量" prop="数量">
|
||||
<el-input
|
||||
v-model.number="form.装机数量"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="部件数量" prop="数量">
|
||||
<el-input
|
||||
v-model.number="form.部件数量"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="制造商" prop="供货商">
|
||||
<el-input
|
||||
v-model.number="form.制造商"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="分类码" prop="分类码">
|
||||
<el-input
|
||||
v-model.number="form.分类码"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="备注" prop="备注">
|
||||
<el-input
|
||||
v-model.number="form.备注"
|
||||
type="textarea"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancel()">取消</el-button>
|
||||
<el-button v-show="title==='编辑零件信息'" type="primary" @click="submitEdit()">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="dialogMaterial" title="物料选择">
|
||||
<el-input v-model="inputMaterial" placeholder="材质" size="small" style="width:200px"/>
|
||||
<el-button type="success" size="small" icon="el-icon-search" style="margin: 0 0 10px 10px" @click="searchMaterial()">查询</el-button>
|
||||
<el-table
|
||||
:data="MaterialData"
|
||||
size="mini"
|
||||
highlight-current-row
|
||||
border
|
||||
@row-click="selectMaterial">
|
||||
<el-table-column align="center" label="物料代码">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料代码 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料名称">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料名称 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料规格">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料规格 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料型号">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料型号 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="block" style="margin-top: 10px;">
|
||||
<el-pagination
|
||||
:current-page="pageCurrentMaterial"
|
||||
:page-sizes="[10, 20]"
|
||||
:page-size="pageSizeMaterial"
|
||||
:total="totalMaterial"
|
||||
small
|
||||
layout="sizes, prev, pager, next"
|
||||
@size-change="handleSizeChangeMaterial"
|
||||
@current-change="handleCurrentChangeMaterial"/>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="dialogMaterial=false">提交</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="dialogParts" :title="title1" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" center width="400px">
|
||||
<span>零件图号:</span>
|
||||
<el-input v-model="PartsValueNum" size="small" placeholder="零件图号" style="width: 200px"/>
|
||||
<!--<el-select v-model="PartsValueNum" filterable size="small" placeholder="零件图号">-->
|
||||
<!--<el-option-->
|
||||
<!--v-for="item in PartsValue"-->
|
||||
<!--:key="item.value"-->
|
||||
<!--:label="item.label"-->
|
||||
<!--:value="item.value"/>-->
|
||||
<!--</el-select>-->
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submit">提交</el-button>
|
||||
<el-button type="primary" @click="submitCancel">取消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { sleep } from '../../../utils/tool'
|
||||
import { unSpecificationQuery1, specificationQuery1, unSpecificationQueryWB1, specificationQueryWB1, deleteBasicParts, deleteBWParts, getMaterial, getMaterialWB, searchMaterialWB, updateRow, updateRowWB, transferMX1, update, searchOldParts, getMachineNames, transferWG1, allDelete, update1, searchMaterial1 } from '../../../api/TechnologyCenter/ImportParts'
|
||||
export default {
|
||||
name: 'SpecificationData',
|
||||
props: {
|
||||
groupsNames: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
machineNames: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
projectName: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
groupName: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
componentNum: '',
|
||||
groupValue: '',
|
||||
machineValue: '',
|
||||
machineName: '',
|
||||
machineNum: '',
|
||||
tableData: [],
|
||||
tableDataAll: [],
|
||||
tableData10: [],
|
||||
listLoading: false,
|
||||
unSpecification: [],
|
||||
pageCurrent: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
title: '',
|
||||
materials: [],
|
||||
dialogFormVisible: false,
|
||||
dialogParts: false,
|
||||
title1: '',
|
||||
oldPartsValue: '',
|
||||
Number: '',
|
||||
Type: '',
|
||||
PartsValue: [],
|
||||
PartsValueNum: '',
|
||||
type: 0, // 零件类型 暂定1为基本件,2为外购件和标准件
|
||||
form: {
|
||||
id: '',
|
||||
物料物流号: null, // 当基本件时使用材料流水号,外购件和标准件时,使用物料流水号
|
||||
物料名称: '',
|
||||
材料流水号: null,
|
||||
图号或者型号: '',
|
||||
名称: '',
|
||||
材料或者规格: '',
|
||||
规格: '',
|
||||
备件数量: '',
|
||||
装机数量: '',
|
||||
部件数量: '',
|
||||
制造商: '',
|
||||
备注: '',
|
||||
分类码: ''
|
||||
},
|
||||
err: 0,
|
||||
dialogFormVisibleWB: false,
|
||||
dialogMaterial: false,
|
||||
MaterialData: [],
|
||||
inputMaterial: '',
|
||||
rules: {
|
||||
},
|
||||
rulesWB: {
|
||||
},
|
||||
pageCurrentMaterial: 1,
|
||||
pageSizeMaterial: 10,
|
||||
totalMaterial: 0,
|
||||
loadingMaterial: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
disabled() {
|
||||
if (this.tableDataAll.length === 0) {
|
||||
return true
|
||||
}
|
||||
if (this.unSpecification.data) {
|
||||
return this.unSpecification.data.length > 0
|
||||
}
|
||||
return true
|
||||
},
|
||||
materialName() {
|
||||
for (let i = 0; i < this.materials.length; i++) {
|
||||
if (this.materials[i].value === this.form.材料流水号) {
|
||||
return this.materials[i].label
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
machineNames(val) {
|
||||
this.machineName = ''
|
||||
this.machineNum = ''
|
||||
this.total = 0
|
||||
this.machineValue = val.length > 0 ? val[0].value : ''
|
||||
this.getGroups()
|
||||
},
|
||||
machineValue() {
|
||||
this.getMachineNames()
|
||||
},
|
||||
groupsNames(val) {
|
||||
this.groupValue = val.length > 0 ? val[0].value : ''
|
||||
},
|
||||
groupValue(val) {
|
||||
val ? this.fetchData() : this.tableData = []
|
||||
},
|
||||
groupName(val) {
|
||||
val ? this.fetchData() : this.tableData = []
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getSelect(getMaterial, ['材料', '材料流水号'], 'materials')
|
||||
},
|
||||
methods: {
|
||||
cell({ row, column, rowIndex, columnIndex }) {
|
||||
if (row.对比类型 === 1 && columnIndex === 2) {
|
||||
return 'rgb196'
|
||||
}
|
||||
if (row.对比类型 === 3 && columnIndex === 1) {
|
||||
return 'rgb196'
|
||||
}
|
||||
if (row.对比类型 === 4 && columnIndex === 3) {
|
||||
return 'rgb196'
|
||||
}
|
||||
},
|
||||
async fetchData() {
|
||||
this.pageCurrent = 1
|
||||
this.tableData10 = []
|
||||
try {
|
||||
this.listLoading = true
|
||||
this.total = 0
|
||||
this.tableDataAll = []
|
||||
const projectCheck = this.projectName ? 1 : 0
|
||||
const machineCheck = this.machineValue ? 1 : 0
|
||||
const groupCheck = this.groupValue ? 1 : 0
|
||||
console.log(this.groupName)
|
||||
if (this.groupName.indexOf('MX') > -1) { // 当分组为基本件时,查询基本件规范和不规范数据,否则查询外购件或标准件规范和不规范数据
|
||||
// 分别查出规范和不规范数据,将规范数据放前面在一个总数组中
|
||||
this.type = 1
|
||||
this.unSpecification = await unSpecificationQuery1(projectCheck, this.projectName, machineCheck, this.machineValue, groupCheck, this.groupValue)
|
||||
this.unSpecification.data.forEach(item => {
|
||||
this.tableDataAll.push(item)
|
||||
})
|
||||
const specification = await specificationQuery1(projectCheck, this.projectName, machineCheck, this.machineValue, groupCheck, this.groupValue)
|
||||
specification.data.forEach(item => {
|
||||
this.tableDataAll.push(item)
|
||||
})
|
||||
} else {
|
||||
this.type = 2
|
||||
this.unSpecification = await unSpecificationQueryWB1(projectCheck, this.projectName, machineCheck, this.machineValue, groupCheck, this.groupValue)
|
||||
console.log(this.unSpecification)
|
||||
this.unSpecification.data.forEach(item => {
|
||||
this.tableDataAll.push(item)
|
||||
})
|
||||
const specification = await specificationQueryWB1(projectCheck, this.projectName, machineCheck, this.machineValue, groupCheck, this.groupValue)
|
||||
specification.data.forEach(item => {
|
||||
this.tableDataAll.push(item)
|
||||
})
|
||||
}
|
||||
this.total = this.tableDataAll.length
|
||||
this.pagination(this.pageCurrent, this.pageSize) // 前端分页,数据很多生成DOM节点也多,分页效果很明显。
|
||||
this.listLoading = false
|
||||
} catch (e) {
|
||||
console.log(`查询零件发生错误:${e}`)
|
||||
}
|
||||
},
|
||||
submitChangeType(row) {
|
||||
this.Number = row.id
|
||||
this.Type = row.整改类型
|
||||
if (row.整改类型 === 1) {
|
||||
if (this.groupName.indexOf('MX') > -1) {
|
||||
update(this.projectName, this.machineValue, row.id, row.整改类型).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.fetchData()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
update1(row.id, row.整改类型).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.fetchData()
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (row.整改类型 === 2) {
|
||||
this.title1 = '替换'
|
||||
this.oldPartsValue = row.图号或者型号.split('-')[0] + '-' + row.图号或者型号.split('-')[1].substring(2, 7)
|
||||
searchOldParts(this.projectName, this.machineValue, this.oldPartsValue).then(response => {
|
||||
this.PartsValueNum = response.data[0].图号或者型号
|
||||
})
|
||||
} else {
|
||||
this.title1 = '补充加工'
|
||||
this.oldPartsValue = row.图号或者型号.split('-')[0] + '-' + row.图号或者型号.split('-')[1].substring(2, 7)
|
||||
searchOldParts(this.projectName, this.machineValue, this.oldPartsValue).then(response => {
|
||||
this.PartsValueNum = response.data[0].图号或者型号
|
||||
})
|
||||
}
|
||||
this.dialogParts = true
|
||||
}
|
||||
},
|
||||
searchMaterial1(row) {
|
||||
console.log(row)
|
||||
searchMaterial1(row.图号或者型号, row.名称, row.规格).then(response => {
|
||||
this.tableData10 = response.data
|
||||
console.log(response.data)
|
||||
})
|
||||
},
|
||||
allDelete() {
|
||||
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
if (this.projectName !== '' && this.machineValue !== '' && this.groupValue !== '') {
|
||||
allDelete(this.projectName, this.machineValue, this.groupValue).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.tableData = []
|
||||
this.tableData10 = []
|
||||
this.$message.success('删除成功')
|
||||
} else {
|
||||
this.$message.error('删除失败')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.warning('请选择好项目机床分组')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
})
|
||||
})
|
||||
},
|
||||
getMachineNames() {
|
||||
console.log(this.machineValue, 2222)
|
||||
getMachineNames(this.machineValue).then(response => {
|
||||
console.log(response.data, 3333)
|
||||
if (response.data.length !== 0) {
|
||||
this.machineName = response.data[0].机床名称
|
||||
this.machineNum = response.data[0].机床数量
|
||||
}
|
||||
})
|
||||
},
|
||||
submit() {
|
||||
this.dialogParts = false
|
||||
update(this.projectName, this.machineValue, this.Number, this.Type, this.PartsValueNum).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.fetchData()
|
||||
this.$message.success('关联成功')
|
||||
} else {
|
||||
this.$message.error('关联失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
submitCancel() {
|
||||
this.dialogParts = false
|
||||
update(this.projectName, this.machineValue, this.Number, 0).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.fetchData()
|
||||
this.$message.success('取消成功')
|
||||
} else {
|
||||
this.$message.error('取消失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
getGroups() {
|
||||
this.$emit('machineChange', this.machineValue)
|
||||
},
|
||||
pagination(pageCurrent, pageSize) {
|
||||
this.tableData = this.tableDataAll.slice((pageCurrent - 1) * pageSize, pageCurrent * pageSize)
|
||||
},
|
||||
tableRowClassName({ row }) {
|
||||
if (this.unSpecification.data.indexOf(row) > -1) {
|
||||
return 'warning-row'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
handleEdit(row) {
|
||||
this.editForm(row, 'form', [this.title = '编辑零件信息', this.dialogFormVisible = true])
|
||||
if (this.type === 2) {
|
||||
this.form.物料名称 = row.材料或者规格
|
||||
this.form.物料物流号 = row.物料流水号
|
||||
}
|
||||
},
|
||||
submitEdit() {
|
||||
if (this.type === 1) {
|
||||
this.editTable(updateRow, [this.form.图号或者型号, this.form.名称, this.form.规格, this.materialName, this.form.备件数量, this.form.装机数量, this.form.制造商, this.form.备注, this.form.分类码, this.form.id, this.form.材料流水号, this.form.部件数量], 'form', function() {
|
||||
this.dialogFormVisible = false
|
||||
this.fetchData()
|
||||
})
|
||||
} else if (this.type === 2) {
|
||||
this.editTable(updateRowWB, [this.form.图号或者型号, this.form.名称, this.form.规格, this.form.物料名称, this.form.备件数量, this.form.装机数量, this.form.制造商, this.form.备注, this.form.分类码, this.form.id, this.form.物料流水号, this.form.部件数量], 'form', function() {
|
||||
this.dialogFormVisible = false
|
||||
this.fetchData()
|
||||
})
|
||||
} else {
|
||||
console.log(`编辑类型发生错误`)
|
||||
}
|
||||
},
|
||||
cancel() {
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
handleDelete(row) {
|
||||
if (this.type === 1) {
|
||||
this.deleteRow(deleteBasicParts, row.id, function() {
|
||||
this.fetchData()
|
||||
})
|
||||
} else {
|
||||
this.deleteRow(deleteBWParts, row.id, function() {
|
||||
this.fetchData()
|
||||
})
|
||||
}
|
||||
},
|
||||
materialShow() {
|
||||
this.inputMaterial = ''
|
||||
this.getMaterialWB()
|
||||
this.dialogMaterial = true
|
||||
},
|
||||
getMaterialWB() {
|
||||
this.getTable(getMaterialWB, [this.pageCurrentMaterial, this.pageSizeMaterial], ['MaterialData', 'totalMaterial', 'loadingMaterial'])
|
||||
},
|
||||
searchMaterial() {
|
||||
this.getTable(searchMaterialWB, [this.inputMaterial, this.pageCurrentMaterial, this.pageSizeMaterial], ['MaterialData', 'totalMaterial', 'loadingMaterial'])
|
||||
},
|
||||
selectMaterial(row) {
|
||||
this.dialogMaterial = false
|
||||
this.form.物料流水号 = row.物料流水号
|
||||
this.form.物料名称 = row.物料名称
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.pageCurrent = 1
|
||||
this.pageSize = val
|
||||
this.pagination(this.pageCurrent, this.pageSize)
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.pageCurrent = val
|
||||
this.pagination(this.pageCurrent, this.pageSize)
|
||||
},
|
||||
handleSizeChangeMaterial(val) {
|
||||
this.pageCurrentMaterial = 1
|
||||
this.pageSizeMaterial = val
|
||||
this.getMaterialWB()
|
||||
},
|
||||
handleCurrentChangeMaterial(val) {
|
||||
this.pageCurrentMaterial = val
|
||||
this.getMaterialWB()
|
||||
},
|
||||
async transferData() {
|
||||
try {
|
||||
this.err = 0
|
||||
if (this.groupValue) {
|
||||
this.listLoading = true
|
||||
if (this.groupName.indexOf('MX') > -1) {
|
||||
for (let i = 0; i < this.tableDataAll.length; i++) {
|
||||
const data = this.tableDataAll[i]
|
||||
const total = parseInt(data.备件数量) + parseInt(data.装机数量) * parseInt(data.部件数量)
|
||||
const resp = await transferMX1(data.图号或者型号, data.名称, total, data.备注, data.标记, data.设计者编号, data.组件流水号, data.材料流水号, data.规格, 1, data.是否传递, data.序号, data.分类码, data.整改类型, data.id, data.前id, data.前图号或者型号)
|
||||
await sleep(10)
|
||||
if (resp.data[0].result === '0') {
|
||||
this.err++
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < this.tableDataAll.length; i++) {
|
||||
let dataType
|
||||
const data = this.tableDataAll[i]
|
||||
const total = parseInt(data.备件数量) + parseInt(data.装机数量) * parseInt(data.部件数量)
|
||||
if (this.groupName.indexOf('WG') > -1) {
|
||||
dataType = 2
|
||||
} else {
|
||||
dataType = 1
|
||||
}
|
||||
console.log(data)
|
||||
const resp = await transferWG1(data.组件流水号, data.物料流水号, total, data.备注, data.标记, data.设计者编号, data.是否传递, dataType, data.序号, data.id, data.备件数量, data.分类码, data.整改类型)
|
||||
await sleep(10)
|
||||
if (resp.data[0].result === '0') {
|
||||
this.err++
|
||||
this.$notify.error(`传递零件失败`)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.err === 0) { // 传递成功后,清除该分组。当所有组都传递完成后,该项目下的机床和分组消失
|
||||
const index = this.groupsNames.indexOf(this.groupValue)
|
||||
this.groupsNames.splice(index, 1)
|
||||
if (this.groupsNames.length === 0) {
|
||||
const groupIndex = this.machineNames.indexOf(this.machineValue)
|
||||
this.machineNames.splice(groupIndex, 1)
|
||||
}
|
||||
this.$message.success(`传递成功`)
|
||||
this.tableDataAll = []
|
||||
this.tableData = []
|
||||
this.tableData10 = []
|
||||
} else {
|
||||
this.$message.error(`${this.err}个零件传递失败`)
|
||||
}
|
||||
this.listLoading = false
|
||||
} else {
|
||||
this.$message.warning(`请选择分组传递`)
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error(`传递发生错误`)
|
||||
console.log(`${e}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.el-table .warning-row {
|
||||
background: red;
|
||||
}
|
||||
.rgb196{
|
||||
background: palevioletred !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
span{
|
||||
margin: 3px;
|
||||
}
|
||||
radio {
|
||||
margin-left: 3px;
|
||||
}
|
||||
</style>
|
||||
103
src/views/TechnologyCenter/ImportParts/UploadExcel/index.vue
Normal file
103
src/views/TechnologyCenter/ImportParts/UploadExcel/index.vue
Normal file
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<div style="display: inline-block;width: 100%;height: 100%;margin: 10px 20px 40px 10px">
|
||||
<input id="excel-upload-input" ref="excel-upload-input" type="file" multiple="multiple" accept=".xlsx, .xls" class="c-hide" @change="handkeFileChange">
|
||||
<div id="drop" @drop="handleDrop" @dragover="handleDragover" @dragenter="handleDragover">
|
||||
将Excel文件拖到这或
|
||||
<el-button style="margin-left:16px;" size="small" icon="el-icon-search" type="success" @click="handleUpload">浏览</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import XLSX from 'xlsx'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
excelData: {
|
||||
itemFile: [],
|
||||
worksheet: []
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
generateDate({ itemFile, worksheet }) {
|
||||
this.excelData.itemFile.push(itemFile)
|
||||
this.excelData.worksheet.push(worksheet)
|
||||
},
|
||||
handleDrop(e) {
|
||||
this.excelData.itemFile = []
|
||||
this.excelData.worksheet = [] // 每次拖拽都清空一次
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
const files = e.dataTransfer.files
|
||||
for (let i = 0; i < files.length; i++) { // 支持多个文件
|
||||
const itemFile = files[i]
|
||||
this.readerData(itemFile)
|
||||
}
|
||||
this.$emit('on-selected-file', this.excelData)
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
},
|
||||
handleDragover(e) {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
},
|
||||
handleUpload() {
|
||||
this.excelData.itemFile = []
|
||||
this.excelData.worksheet = [] // 每次点击“浏览”都清空一次
|
||||
document.getElementById('excel-upload-input').click()
|
||||
},
|
||||
handkeFileChange(e) {
|
||||
const files = e.target.files
|
||||
for (let i = 0; i < files.length; i++) { // 支持多个文件
|
||||
const itemFile = files[i]
|
||||
if (!itemFile) return
|
||||
this.readerData(itemFile)
|
||||
}
|
||||
this.$emit('on-selected-file', this.excelData)
|
||||
this.$refs['excel-upload-input'].value = null // fix can't select the same excel
|
||||
},
|
||||
readerData(itemFile) {
|
||||
const reader = new FileReader()
|
||||
reader.onload = e => {
|
||||
const data = e.target.result
|
||||
const fixedData = this.fixdata(data)
|
||||
const workbook = XLSX.read(btoa(fixedData), { type: 'base64' })
|
||||
const firstSheetName = workbook.SheetNames[0] // cjnsheetname
|
||||
const worksheet = workbook.Sheets[firstSheetName] // 默认firstsheet
|
||||
this.generateDate({ itemFile, worksheet })
|
||||
}
|
||||
reader.readAsArrayBuffer(itemFile)
|
||||
},
|
||||
fixdata(data) {
|
||||
let o = ''
|
||||
let l = 0
|
||||
const w = 10240
|
||||
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)))
|
||||
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)))
|
||||
return o
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
#excel-upload-input{
|
||||
display: none;
|
||||
z-index: -9999;
|
||||
}
|
||||
#drop{
|
||||
border: 2px dashed #bbb;
|
||||
width: 600px;
|
||||
line-height: 160px;
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
color: #bbb;
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
507
src/views/TechnologyCenter/ImportParts/index.vue
Normal file
507
src/views/TechnologyCenter/ImportParts/index.vue
Normal file
@@ -0,0 +1,507 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-card v-loading="loading">
|
||||
<div style="width: 650px;margin: 0 auto">
|
||||
<div style="overflow: hidden">
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span>项目:</span>
|
||||
<el-select v-model="projectValue" filterable size="small" placeholder="项目名称" style="margin-top: 3px">
|
||||
<el-option
|
||||
v-for="item in project"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<span style="margin-left: 10px">类型:</span>
|
||||
<el-select v-model="groupName" filterable size="small" placeholder="类型">
|
||||
<el-option
|
||||
v-for="item in Group"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<el-button type="primary" size="small" icon="el-icon-upload2" style="margin-left: 10px" @click="opendialogVisibleMachine()">上传总图</el-button>
|
||||
</div>
|
||||
<upload-excel-component @on-selected-file="selected"/>
|
||||
</div>
|
||||
<div>
|
||||
<el-tooltip content="删除全部" placement="top">
|
||||
<span v-show="worksheet.length > 1" style="cursor: pointer;float: right;margin: 5px" @click="removeAll"><i class="el-icon-close"/></span>
|
||||
</el-tooltip>
|
||||
<el-upload :on-remove="handleRemove" :file-list="itemFile" action=""/>
|
||||
</div>
|
||||
<div v-if="worksheet.length !== 0" style="float: right;margin: 3px 0">
|
||||
<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" :group-name="groupName" @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-dialog
|
||||
:visible.sync="dialogVisibleMachine"
|
||||
width="30%">
|
||||
<el-card>
|
||||
<el-select v-model="machineDrawValue" clearable filterable size="small" placeholder="机床名称" @change="changeMachine">
|
||||
<el-option
|
||||
v-for="item in machineDraw"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<div style="float: right;">
|
||||
<el-upload
|
||||
:disabled="disabledMachine"
|
||||
:action="action"
|
||||
:on-success="uploadSuccess"
|
||||
:on-error="uploadFailure"
|
||||
:show-file-list="showFileList"
|
||||
:file-list="fileList"
|
||||
class="upload-demo"
|
||||
multiple>
|
||||
<el-button :disabled="disabledMachine" size="small" type="primary">点击上传</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<div v-for="(file, key) in hadFile" :key="key">
|
||||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div class="action">
|
||||
<a class="delete" @click="deleteFileData(file.id)">删除</a>
|
||||
</div>
|
||||
<div v-if="file.suffix==='pdf'" class="icon"><svg-icon icon-class="pdf" /></div>
|
||||
<div v-else-if="file.suffix==='docx'||file.suffix === 'doc'" class="icon"><svg-icon icon-class="doc" /></div>
|
||||
<div v-else-if="file.suffix==='xlsx' || file.suffix === 'xls'" class="icon"><svg-icon icon-class="excel" /></div>
|
||||
<div v-else-if="file.suffix==='pptx' || file.suffix === 'ppt'" class="icon"><svg-icon icon-class="ppt" /></div>
|
||||
<div v-else-if="file.suffix==='jpg' || file.suffix === 'jpeg'|| file.suffix === 'png'" class="icon"><svg-icon icon-class="pic" /></div>
|
||||
<div v-else class="icon"><svg-icon icon-class="file" /></div>
|
||||
<a :href="file.url"><div class="info">{{ file.name }}</div></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UploadExcelComponent from './UploadExcel/index.vue'
|
||||
import specificationData from './specificationData'
|
||||
import { sleep } from '../../../utils/tool'
|
||||
import { initProject, isExit, isExit1, importBasics, importPurcharse, searchMachine, searchGroupNum, machineSelect, getFileData, deleteFileData } from '../../../api/TechnologyCenter/ImportParts'
|
||||
import { uploadFileMachine, downloadFileMachine } from '@/utils/request'
|
||||
export default {
|
||||
name: 'UploadExcel',
|
||||
components: { UploadExcelComponent, specificationData },
|
||||
data() {
|
||||
return {
|
||||
fileList: [],
|
||||
hadFile: [],
|
||||
showFileList: true,
|
||||
projectId: '',
|
||||
action: '',
|
||||
disabledMachine: true,
|
||||
machineDrawValue: '',
|
||||
machineDraw: [],
|
||||
dialogVisibleMachine: false,
|
||||
project: [],
|
||||
projectValue: '',
|
||||
worksheet: [],
|
||||
itemFile: [],
|
||||
loading: false,
|
||||
groupsNames: [],
|
||||
groupName: '',
|
||||
Group: [{
|
||||
value: 'MX',
|
||||
name: 'MX'
|
||||
}, {
|
||||
value: 'WG',
|
||||
name: 'WG'
|
||||
}, {
|
||||
value: 'BZ',
|
||||
name: 'BZ'
|
||||
}],
|
||||
group: '',
|
||||
ceshi: '',
|
||||
machineNames: [],
|
||||
err: 0,
|
||||
disabled: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
projectName() {
|
||||
for (let i = 0; i < this.project.length; i++) {
|
||||
if (this.project[i].value === this.projectValue) {
|
||||
return this.project[i].label
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
projectValue(val) {
|
||||
if (val) {
|
||||
this.groupsNames = []
|
||||
this.machineNames = []
|
||||
this.projectChange(this.projectName)
|
||||
}
|
||||
},
|
||||
project(val) {
|
||||
if (val.length > 0) {
|
||||
this.projectValue = val[0].value
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
opendialogVisibleMachine() {
|
||||
this.machineDraw = []
|
||||
this.machineDrawValue = ''
|
||||
this.dialogVisibleMachine = true
|
||||
this.machineDrawValue === '' ? this.disabledMachine = true : this.disabledMachine = false
|
||||
this.getSelect(machineSelect, ['机床图号', '机床流水号'], 'machineDraw', this.projectValue)
|
||||
},
|
||||
changeMachine() {
|
||||
this.machineDrawValue === '' ? this.disabledMachine = true : this.disabledMachine = false
|
||||
this.action = `${uploadFileMachine}?&MachineNum=${this.machineDrawValue}`
|
||||
this.getFileData(this.machineDrawValue)
|
||||
console.log(this.action)
|
||||
},
|
||||
uploadSuccess(res, file, fileList) {
|
||||
if (res[0].result === '1') {
|
||||
const index = fileList.indexOf(file)
|
||||
fileList.splice(index, 1)
|
||||
} else {
|
||||
this.$message.error(`${file.name}文件上传失败,请检查上传文件是否正确!`)
|
||||
}
|
||||
if (fileList.length === 0) {
|
||||
this.$message.success('文件上传成功')
|
||||
this.getFileData(this.machineDrawValue)
|
||||
}
|
||||
},
|
||||
uploadFailure(a, file, fileList) {
|
||||
fileList.map(file => {
|
||||
this.$message.error(`${file.name}文件上传失败,请检查上传文件是否正确!`)
|
||||
})
|
||||
},
|
||||
// 在什么情况下需要查询上传的附件,调用this.getFileData()即可根据
|
||||
getFileData(machineDrawValue) {
|
||||
this.hadFile = []
|
||||
getFileData(machineDrawValue).then(res => {
|
||||
if (res.data.length > 0) {
|
||||
res.data.map(item => {
|
||||
this.hadFile.push({
|
||||
url: `${downloadFileMachine}?id=${item.文件标识}.${item.文件后缀}&name=${item.文件名称}.${item.文件后缀}`,
|
||||
name: `${item.文件名称}.${item.文件后缀}`,
|
||||
suffix: item.文件后缀,
|
||||
id: item.文件标识
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
deleteFileData(id) {
|
||||
this.deleteRow(deleteFileData, id, function() { this.getFileData(this.machineDrawValue) })
|
||||
},
|
||||
async test() {
|
||||
await sleep(10000)
|
||||
console.log(1)
|
||||
},
|
||||
fetchData() {
|
||||
this.getSelect(initProject, ['项目名称', '项目流水号'], 'project')
|
||||
},
|
||||
// 根据项目获取机床
|
||||
projectChange(val) {
|
||||
this.machineNames = []
|
||||
if (val) {
|
||||
this.getSelect(searchMachine, ['机床'], 'machineNames', val)
|
||||
}
|
||||
},
|
||||
// 根据机床获取分组
|
||||
machineChange(val) {
|
||||
this.groupsNames = []
|
||||
if (val) {
|
||||
searchGroupNum(this.projectName, val).then(response => {
|
||||
const res = response.data
|
||||
res.forEach(item => {
|
||||
this.groupsNames.push({
|
||||
value: item.组号
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
async selected(data) { // 选择需要导入的文件
|
||||
this.worksheet = data.worksheet // 获取每个多选文件的表格坐标及值
|
||||
console.log(this.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 = []
|
||||
},
|
||||
async basicPartsToSQL() {
|
||||
try {
|
||||
this.loading = true
|
||||
this.dispatch = true
|
||||
this.err = 0
|
||||
for (let j = this.worksheet.length - 1; j >= 0; j--) {
|
||||
let establishment,
|
||||
proofread,
|
||||
review,
|
||||
date,
|
||||
machineName,
|
||||
machineNum,
|
||||
componentName,
|
||||
componentNum,
|
||||
groupNum,
|
||||
contractNum,
|
||||
pageNum,
|
||||
totalNum,
|
||||
drawingNum,
|
||||
name,
|
||||
type,
|
||||
material,
|
||||
spareNum,
|
||||
useNum,
|
||||
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
|
||||
this.disabled = false
|
||||
return
|
||||
} else {
|
||||
if (this.worksheet[j].M2.v === '00-MX') {
|
||||
this.group = this.worksheet[j].M2.v
|
||||
if (this.worksheet[j].M2.v.substring(0, 1) !== '9') {
|
||||
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 = ''
|
||||
for (let i = 0; i < 999; 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 {
|
||||
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 {
|
||||
this.loading = false
|
||||
this.disabled = false
|
||||
this.$notify.error(`请确认导入文件是否正确`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.$notify.error('禁止导入整改组')
|
||||
break
|
||||
}
|
||||
} else {
|
||||
this.group = this.worksheet[j].M2.v.substring(0, this.worksheet[j].M2.v.indexOf('-')) + '组'
|
||||
const response = await isExit1(this.projectValue, this.worksheet[j].F2.v, this.group)
|
||||
const res = response.data
|
||||
console.log(res, 1111)
|
||||
if (res[0].Column1 === 0) {
|
||||
this.$notify.error(`${this.group}组件不存在,请确认文件是否正确`)
|
||||
this.loading = false
|
||||
this.disabled = false
|
||||
return
|
||||
} else {
|
||||
console.log(this.worksheet[j], 111111111)
|
||||
if (this.worksheet[j].M2.v.substring(0, 1) !== '9') {
|
||||
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 = ''
|
||||
for (let i = 0; i < 999; 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 {
|
||||
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 {
|
||||
this.loading = false
|
||||
this.disabled = false
|
||||
this.$notify.error(`请确认导入文件是否正确`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.$notify.error('禁止导入整改组')
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.itemFile.splice(j, 1)
|
||||
this.worksheet.splice(j, 1)
|
||||
this.err === 0 ? this.$message.success(`导入完成`) : this.$message.error(`导入失败零件个数为${this.err},请检查文件是否正确`)
|
||||
}
|
||||
this.loading = false
|
||||
this.projectChange(this.projectName) // 调用查询机床方法,通过watch属性检测变化会自动得到下面表格的值。
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.err++
|
||||
this.loading = false
|
||||
this.$notify.error(`导入数据错误,请检查导入文件是否正确`)
|
||||
console.log(`导入数据错误${e}`)
|
||||
}
|
||||
},
|
||||
async insertToSQL(establishment, proofread, review, date, machineName, machineNum, componentName, componentNum, groupNum, contractNum, pageNum, totalNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode) {
|
||||
try {
|
||||
console.log(useNum, 232)
|
||||
if (groupNum.indexOf('MX') > -1) {
|
||||
const response = await importBasics(establishment, proofread, review, date, this.projectName, machineNum, machineName, componentName, componentNum, this.group, contractNum, totalNum, pageNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
|
||||
const res = response.data
|
||||
console.log(res, 11111111)
|
||||
if (res.hasOwnProperty('output') === false) {
|
||||
if (res[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
} else {
|
||||
if (res.result[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
if (res.output[0].导入类型 === '2') {
|
||||
this.$notify.warning(`存在重复数据`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(drawingNum, 1111111111)
|
||||
const response = await importPurcharse(establishment, proofread, review, date, this.projectName, machineNum, machineName, componentName, componentNum, this.group, contractNum, totalNum, pageNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
|
||||
const res = response.data
|
||||
console.log(res, 222222)
|
||||
if (res.hasOwnProperty('output') === false) {
|
||||
if (res[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
} else {
|
||||
if (res.result[0].result === '0') {
|
||||
this.$notify.error(`${drawingNum}导入失败`)
|
||||
}
|
||||
if (res.output[0].导入类型 === '2') {
|
||||
this.$notify.warning(`存在重复数据`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('哈哈哈哈')
|
||||
this.err++
|
||||
this.$message.error(`导入数据错误`)
|
||||
console.log(`导入数据错误${e}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
/*.wrapper{*/
|
||||
/*width: 100%;*/
|
||||
/*margin: 0 auto;*/
|
||||
/*}*/
|
||||
.wrapper{
|
||||
width: 225px;
|
||||
height: 50px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #b8c7d9;
|
||||
float: left;
|
||||
margin: 10px;
|
||||
}
|
||||
.content{
|
||||
position: relative;
|
||||
padding: 8px 8px 0 8px;
|
||||
}
|
||||
.action{
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 8px;
|
||||
}
|
||||
.delete{
|
||||
padding: 0 5px;
|
||||
border-radius: 3px;
|
||||
color: #0f84b0;
|
||||
font-size: 12px;
|
||||
}
|
||||
.delete:hover{
|
||||
background: -webkit-linear-gradient(top,#0ba9e3,#0099d3);
|
||||
color: #fff;
|
||||
}
|
||||
a{
|
||||
text-decoration: none;
|
||||
}
|
||||
.icon{
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: inline-block;
|
||||
margin-right: 7px;
|
||||
margin-top: 2px;
|
||||
font-size: 26px;
|
||||
}
|
||||
.info{
|
||||
position: absolute;
|
||||
left: 44px;
|
||||
line-height: 30px;
|
||||
display: inline-block;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
641
src/views/TechnologyCenter/ImportParts/specificationData.vue
Normal file
641
src/views/TechnologyCenter/ImportParts/specificationData.vue
Normal file
@@ -0,0 +1,641 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card>
|
||||
<div style="width: 900px;margin: 0 auto">
|
||||
<span>机床名称:</span>
|
||||
<el-select v-model="machineValue" filterable clearable size="small" placeholder="机床名称" style="margin-top: 3px" @change="getGroups">
|
||||
<el-option
|
||||
v-for="item in machineNames"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<span>分组名称:</span>
|
||||
<el-select v-model="groupValue" filterable clearable size="small" placeholder="分组名称">
|
||||
<el-option
|
||||
v-for="item in groupsNames"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<el-button :loading="listLoading" :disabled="disabled" type="primary" plain icon="el-icon-d-caret" size="small" style="margin-left: 10px" @click="transferData">传递</el-button>
|
||||
<el-button type="danger" icon="el-icon-delete" plain size="small" @click="allDelete">一键删除</el-button>
|
||||
<el-row style="margin-top: 5px;margin-bottom: 3px">
|
||||
<span>机床名称:</span>
|
||||
<el-input v-model="machineName" readonly size="small" placeholder="机床名称" style="width: 200px;"/>
|
||||
<span>机床数量:</span>
|
||||
<el-input v-model="machineNum" readonly size="small" placeholder="机床数量" style="width: 200px;"/>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="tableData"
|
||||
:row-class-name="tableRowClassName"
|
||||
size="mini"
|
||||
border
|
||||
stripe
|
||||
height="280px"
|
||||
highlight-current-row
|
||||
@row-click="searchMaterial1">
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
width="50"/>
|
||||
<el-table-column align="center" label="物料状态" min-width="50">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.物料流水号===null" type="warning" size="small" style="margin: 0px">不存在</el-tag>
|
||||
<el-tag v-if="scope.row.物料流水号!==null" type="primary" size="small" style="margin: 0px">存在</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="图号" min-width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.图号或者型号 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="名称" min-width="200" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.名称 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="材料" width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.材料或者规格 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="规格" width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.规格 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="备件数量" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.备件数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="装机数量" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.装机数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="部件数量" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.部件数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="制造商" min-width="200">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.制造商 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="备注" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.备注 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="分类码" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.分类码 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!--<el-table-column label="操作" fixed="right" align="center" width="200">-->
|
||||
<!--<template slot-scope="scope">-->
|
||||
<!--<el-button-->
|
||||
<!--size="mini"-->
|
||||
<!--type="primary"-->
|
||||
<!--icon="el-icon-edit"-->
|
||||
<!--@click="handleEdit(scope.row)">编辑</el-button>-->
|
||||
<!--<el-button-->
|
||||
<!--size="mini"-->
|
||||
<!--type="danger"-->
|
||||
<!--icon="el-icon-delete"-->
|
||||
<!--@click="handleDelete(scope.row)">删除</el-button>-->
|
||||
<!--</template>-->
|
||||
<!--</el-table-column>-->
|
||||
</el-table>
|
||||
<div class="block">
|
||||
<el-pagination
|
||||
:current-page="pageCurrent"
|
||||
:page-sizes="[10, 20, 40, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"/>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<el-table
|
||||
:data="tableData10"
|
||||
:cell-class-name="cell"
|
||||
style="width: 100%"
|
||||
size="mini"
|
||||
height="200px"
|
||||
highlight-current-row
|
||||
border
|
||||
stripe>
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
width="50"/>
|
||||
<el-table-column align="center" label="物料名称">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料名称 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料规格">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料规格 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料型号">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料型号 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="供货商">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.供货商 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" center style="min-height: 300px" width="800px">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="110px" class="demo-ruleForm">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="图号" prop="图号或者型号">
|
||||
<el-input
|
||||
v-model="form.图号或者型号"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="名称" prop="名称">
|
||||
<el-input
|
||||
v-model="form.名称"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item v-if="type === 1" label="材料" prop="材料">
|
||||
<el-select v-model="form.材料流水号" filterable clearable size="small" placeholder="机床名称">
|
||||
<el-option
|
||||
v-for="item in materials"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="type === 2" label="规格" prop="规格">
|
||||
<el-input
|
||||
v-model="form.规格"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="备件数量" prop="数量">
|
||||
<el-input
|
||||
v-model.number="form.备件数量"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="装机数量" prop="数量">
|
||||
<el-input
|
||||
v-model.number="form.装机数量"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="部件数量" prop="数量">
|
||||
<el-input
|
||||
v-model.number="form.部件数量"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="制造商" prop="供货商">
|
||||
<el-input
|
||||
v-model.number="form.制造商"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="分类码" prop="分类码">
|
||||
<el-input
|
||||
v-model.number="form.分类码"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="备注" prop="备注">
|
||||
<el-input
|
||||
v-model.number="form.备注"
|
||||
type="textarea"
|
||||
size="small"
|
||||
style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancel()">取消</el-button>
|
||||
<el-button v-show="title==='编辑零件信息'" type="primary" @click="submitEdit()">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { sleep } from '../../../utils/tool'
|
||||
import { unSpecificationQuery, unSpecificationQueryWB, specificationQueryWB, specificationQuery, deleteBasicParts, deleteBWParts, getMaterial, getMaterialWB, searchMaterialWB, updateRow, updateRowWB, transferMX, transferWG, allDelete, searchMaterial1, getMachineNames } from '../../../api/TechnologyCenter/ImportParts'
|
||||
export default {
|
||||
name: 'SpecificationData',
|
||||
props: {
|
||||
groupsNames: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
machineNames: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
projectName: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
groupName: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
componentNum: '',
|
||||
groupValue: '',
|
||||
machineValue: '',
|
||||
machineName: '',
|
||||
machineNum: '',
|
||||
tableData: [],
|
||||
tableDataAll: [],
|
||||
tableData10: [],
|
||||
listLoading: false,
|
||||
unSpecification: [],
|
||||
pageCurrent: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
title: '',
|
||||
materials: [],
|
||||
dialogFormVisible: false,
|
||||
type: 0, // 零件类型 暂定1为基本件,2为外购件和标准件
|
||||
form: {
|
||||
id: '',
|
||||
物料物流号: null, // 当基本件时使用材料流水号,外购件和标准件时,使用物料流水号
|
||||
物料名称: '',
|
||||
材料流水号: null,
|
||||
图号或者型号: '',
|
||||
名称: '',
|
||||
材料或者规格: '',
|
||||
规格: '',
|
||||
备件数量: '',
|
||||
装机数量: '',
|
||||
部件数量: '',
|
||||
制造商: '',
|
||||
备注: '',
|
||||
分类码: ''
|
||||
},
|
||||
err: 0,
|
||||
dialogFormVisibleWB: false,
|
||||
MaterialData: [],
|
||||
inputMaterial: '',
|
||||
rules: {
|
||||
},
|
||||
rulesWB: {
|
||||
},
|
||||
pageCurrentMaterial: 1,
|
||||
pageSizeMaterial: 10,
|
||||
totalMaterial: 0,
|
||||
loadingMaterial: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
disabled() {
|
||||
if (this.tableDataAll.length === 0) {
|
||||
return true
|
||||
}
|
||||
if (this.unSpecification.data) {
|
||||
return this.unSpecification.data.length > 0
|
||||
}
|
||||
return true
|
||||
},
|
||||
materialName() {
|
||||
for (let i = 0; i < this.materials.length; i++) {
|
||||
if (this.materials[i].value === this.form.材料流水号) {
|
||||
return this.materials[i].label
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
machineNames(val) {
|
||||
this.machineName = ''
|
||||
this.machineNum = ''
|
||||
this.total = 0
|
||||
this.machineValue = val.length > 0 ? val[0].value : ''
|
||||
this.getGroups()
|
||||
},
|
||||
machineValue() {
|
||||
this.getMachineNames()
|
||||
},
|
||||
groupsNames(val) {
|
||||
this.groupValue = val.length > 0 ? val[0].value : ''
|
||||
},
|
||||
groupValue(val) {
|
||||
val ? this.fetchData() : this.tableData = []
|
||||
},
|
||||
groupName(val) {
|
||||
val ? this.fetchData() : this.tableData = []
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getSelect(getMaterial, ['材料', '材料流水号'], 'materials')
|
||||
},
|
||||
methods: {
|
||||
cell({ row, column, rowIndex, columnIndex }) {
|
||||
if (row.对比类型 === 1 && columnIndex === 2) {
|
||||
return 'rgb196'
|
||||
}
|
||||
if (row.对比类型 === 3 && columnIndex === 1) {
|
||||
return 'rgb196'
|
||||
}
|
||||
if (row.对比类型 === 4 && columnIndex === 3) {
|
||||
return 'rgb196'
|
||||
}
|
||||
},
|
||||
async fetchData() {
|
||||
this.pageCurrent = 1
|
||||
this.tableData10 = []
|
||||
try {
|
||||
this.listLoading = true
|
||||
this.total = 0
|
||||
this.tableDataAll = []
|
||||
const projectCheck = this.projectName ? 1 : 0
|
||||
const machineCheck = this.machineValue ? 1 : 0
|
||||
const groupCheck = this.groupValue ? 1 : 0
|
||||
console.log(this.groupName, 123)
|
||||
if (this.groupName.indexOf('MX') > -1) { // 当分组为基本件时,查询基本件规范和不规范数据,否则查询外购件或标准件规范和不规范数据
|
||||
// 分别查出规范和不规范数据,将规范数据放前面在一个总数组中
|
||||
this.type = 1
|
||||
this.unSpecification = await unSpecificationQuery(projectCheck, this.projectName, machineCheck, this.machineValue, groupCheck, this.groupValue)
|
||||
this.unSpecification.data.forEach(item => {
|
||||
this.tableDataAll.push(item)
|
||||
})
|
||||
const specification = await specificationQuery(projectCheck, this.projectName, machineCheck, this.machineValue, groupCheck, this.groupValue)
|
||||
specification.data.forEach(item => {
|
||||
this.tableDataAll.push(item)
|
||||
})
|
||||
} else {
|
||||
this.type = 2
|
||||
this.unSpecification = await unSpecificationQueryWB(projectCheck, this.projectName, machineCheck, this.machineValue, groupCheck, this.groupValue)
|
||||
console.log(this.unSpecification)
|
||||
this.unSpecification.data.forEach(item => {
|
||||
this.tableDataAll.push(item)
|
||||
})
|
||||
const specification = await specificationQueryWB(projectCheck, this.projectName, machineCheck, this.machineValue, groupCheck, this.groupValue)
|
||||
specification.data.forEach(item => {
|
||||
this.tableDataAll.push(item)
|
||||
})
|
||||
}
|
||||
this.total = this.tableDataAll.length
|
||||
this.pagination(this.pageCurrent, this.pageSize) // 前端分页,数据很多生成DOM节点也多,分页效果很明显。
|
||||
this.listLoading = false
|
||||
} catch (e) {
|
||||
console.log(`查询零件发生错误:${e}`)
|
||||
}
|
||||
},
|
||||
allDelete() {
|
||||
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
if (this.projectName !== '' && this.machineValue !== '' && this.groupValue !== '') {
|
||||
allDelete(this.projectName, this.machineValue, this.groupValue).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.tableData = []
|
||||
this.total = 0
|
||||
this.tableData10 = []
|
||||
this.$message.success('删除成功')
|
||||
} else {
|
||||
this.$message.error('删除失败')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.warning('请选择好项目机床分组')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
})
|
||||
})
|
||||
},
|
||||
getMachineNames() {
|
||||
console.log(this.machineValue, 2222)
|
||||
getMachineNames(this.machineValue).then(response => {
|
||||
console.log(response.data, 3333)
|
||||
this.machineName = response.data[0].机床名称
|
||||
this.machineNum = response.data[0].机床数量
|
||||
})
|
||||
},
|
||||
getGroups() {
|
||||
this.$emit('machineChange', this.machineValue)
|
||||
},
|
||||
pagination(pageCurrent, pageSize) {
|
||||
this.tableData = this.tableDataAll.slice((pageCurrent - 1) * pageSize, pageCurrent * pageSize)
|
||||
},
|
||||
tableRowClassName({ row }) {
|
||||
if (this.unSpecification.data.indexOf(row) > -1) {
|
||||
return 'warning-row'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
handleEdit(row) {
|
||||
this.editForm(row, 'form', [this.title = '编辑零件信息', this.dialogFormVisible = true])
|
||||
if (this.type === 2) {
|
||||
this.form.物料名称 = row.材料或者规格
|
||||
this.form.物料流水号 = row.物料流水号
|
||||
}
|
||||
},
|
||||
submitEdit() {
|
||||
if (this.type === 1) {
|
||||
this.editTable(updateRow, [this.form.图号或者型号, this.form.名称, this.form.规格, this.materialName, this.form.备件数量, this.form.装机数量, this.form.制造商, this.form.备注, this.form.分类码, this.form.id, this.form.材料流水号, this.form.部件数量], 'form', function() {
|
||||
this.dialogFormVisible = false
|
||||
this.fetchData()
|
||||
})
|
||||
} else if (this.type === 2) {
|
||||
this.editTable(updateRowWB, [this.form.图号或者型号, this.form.名称, this.form.规格, this.form.物料名称, this.form.备件数量, this.form.装机数量, this.form.制造商, this.form.备注, this.form.分类码, this.form.id, this.form.物料流水号, this.form.部件数量], 'form', function() {
|
||||
this.dialogFormVisible = false
|
||||
this.fetchData()
|
||||
})
|
||||
} else {
|
||||
console.log(`编辑类型发生错误`)
|
||||
}
|
||||
},
|
||||
cancel() {
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
handleDelete(row) {
|
||||
if (this.type === 1) {
|
||||
this.deleteRow(deleteBasicParts, row.id, function() {
|
||||
this.fetchData()
|
||||
})
|
||||
} else {
|
||||
this.deleteRow(deleteBWParts, row.id, function() {
|
||||
this.fetchData()
|
||||
})
|
||||
}
|
||||
},
|
||||
searchMaterial1(row) {
|
||||
console.log(row)
|
||||
searchMaterial1(row.图号或者型号, row.名称, row.规格).then(response => {
|
||||
this.tableData10 = response.data
|
||||
console.log(response.data)
|
||||
})
|
||||
},
|
||||
getMaterialWB() {
|
||||
this.getTable(getMaterialWB, [this.pageCurrentMaterial, this.pageSizeMaterial], ['MaterialData', 'totalMaterial', 'loadingMaterial'])
|
||||
},
|
||||
searchMaterial() {
|
||||
this.getTable(searchMaterialWB, [this.inputMaterial, this.pageCurrentMaterial, this.pageSizeMaterial], ['MaterialData', 'totalMaterial', 'loadingMaterial'])
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.pageCurrent = 1
|
||||
this.pageSize = val
|
||||
this.pagination(this.pageCurrent, this.pageSize)
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.pageCurrent = val
|
||||
this.pagination(this.pageCurrent, this.pageSize)
|
||||
},
|
||||
handleSizeChangeMaterial(val) {
|
||||
this.pageCurrentMaterial = 1
|
||||
this.pageSizeMaterial = val
|
||||
this.getMaterialWB()
|
||||
},
|
||||
handleCurrentChangeMaterial(val) {
|
||||
this.pageCurrentMaterial = val
|
||||
this.getMaterialWB()
|
||||
},
|
||||
async transferData() {
|
||||
try {
|
||||
this.err = 0
|
||||
if (this.groupValue) {
|
||||
this.listLoading = true
|
||||
console.log(this.groupName, 123)
|
||||
if (this.groupName.indexOf('MX') > -1) {
|
||||
for (let i = 0; i < this.tableDataAll.length; i++) {
|
||||
const data = this.tableDataAll[i]
|
||||
console.log(data)
|
||||
if (this.groupValue.indexOf('00') > -1) {
|
||||
const index = data.图号或者型号.lastIndexOf('-')
|
||||
data.图号或者型号 = data.图号或者型号.substring(index + 1)
|
||||
if (data.图号或者型号.indexOf('组') > -1) {
|
||||
const total = parseInt(data.备件数量) + parseFloat(data.装机数量) * parseInt(data.部件数量)
|
||||
const resp = await transferMX(data.图号或者型号, data.名称, total, data.备注, data.标记, data.设计者编号, data.组件流水号, data.材料流水号, data.规格, 1, data.是否传递, data.序号, data.id, data.备件数量, data.部件数量)
|
||||
await sleep(10)
|
||||
if (resp.data[0].result === '0') {
|
||||
this.err++
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(222222222)
|
||||
const total = parseInt(data.备件数量) + parseFloat(data.装机数量) * parseInt(data.部件数量)
|
||||
const resp = await transferMX(data.图号或者型号, data.名称, total, data.备注, data.标记, data.设计者编号, data.组件流水号, data.材料流水号, data.规格, 1, data.是否传递, data.序号, data.id, data.备件数量)
|
||||
await sleep(10)
|
||||
if (resp.data[0].result === '0') {
|
||||
this.err++
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < this.tableDataAll.length; i++) {
|
||||
let dataType
|
||||
const data = this.tableDataAll[i]
|
||||
const total = parseInt(data.备件数量) + parseFloat(data.装机数量) * parseInt(data.部件数量)
|
||||
if (this.groupName.indexOf('WG') > -1) {
|
||||
dataType = 2
|
||||
} else {
|
||||
dataType = 1
|
||||
}
|
||||
const resp = await transferWG(data.组件流水号, data.物料流水号, total, data.备注, data.标记, data.设计者编号, data.是否传递, dataType, data.序号, data.id, data.备件数量)
|
||||
await sleep(10)
|
||||
if (resp.data[0].result === '0') {
|
||||
this.err++
|
||||
this.$notify.error(`传递零件失败`)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.err === 0) { // 传递成功后,清除该分组。当所有组都传递完成后,该项目下的机床和分组消失
|
||||
console.log(this.groupsNames.indexOf(this.groupValue), 22222)
|
||||
// const index = this.groupsNames.indexOf(this.groupValue)
|
||||
// this.groupsNames.splice(index, 1)
|
||||
if (this.groupsNames.length === 0) {
|
||||
const groupIndex = this.machineNames.indexOf(this.machineValue)
|
||||
this.machineNames.splice(groupIndex, 1)
|
||||
}
|
||||
this.$message.success(`传递成功`)
|
||||
this.tableDataAll = []
|
||||
this.tableData = []
|
||||
this.tableData10 = []
|
||||
} else {
|
||||
this.$message.error(`${this.err}个零件传递失败`)
|
||||
}
|
||||
this.listLoading = false
|
||||
} else {
|
||||
this.$message.warning(`请选择分组传递`)
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error(`传递发生错误`)
|
||||
console.log(`${e}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.el-table .warning-row {
|
||||
background: yellowgreen;
|
||||
}
|
||||
.rgb196{
|
||||
background: palevioletred !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
span{
|
||||
margin: 10px;
|
||||
}
|
||||
</style>
|
||||
166
src/views/TechnologyCenter/ImportParts/uploadFile.js
Normal file
166
src/views/TechnologyCenter/ImportParts/uploadFile.js
Normal file
@@ -0,0 +1,166 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 初始化 项目名称
|
||||
export function initProject() {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '1',
|
||||
name: 'PDM_项目名称_查询数据_按时间排序'
|
||||
}
|
||||
})
|
||||
}
|
||||
// 导入Excel
|
||||
export function upload(project, machine, group, designer) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '2',
|
||||
name: '组件明细表_基本件_导入数据',
|
||||
param: '项目=' + project + '&机床=' + machine + '&组号=' + group + '&设计者=' + designer
|
||||
}
|
||||
})
|
||||
}
|
||||
// 导入Excel1
|
||||
export function upload1(designer, time, project, machine, group, num1, num2, name, size, num3, supplier, remark, mark) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '2',
|
||||
name: '组件明细表_基本件_导入数据1',
|
||||
param: '设计者=' + designer + '&保存时间=' + time + '&项目=' + project + '&机床=' + machine + '&组号=' + group + '&序号=' + num1 + '&图号或者型号=' + num2 + '=string&名称=' + name + '&材料或者规格=' + size + '&数量=' + num3 + '&供货商=' + supplier + '&备注=' + remark + '&标记=' + mark
|
||||
}
|
||||
})
|
||||
}
|
||||
// 查询零件(查重)
|
||||
export function searchPart(project, machine, group) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '1',
|
||||
name: '导入数据_查询',
|
||||
param: '项目=' + project + '&机床=' + machine + '&组号=' + group
|
||||
}
|
||||
})
|
||||
}
|
||||
// 导入Excel外购件
|
||||
export function outBuyUpload(project, machine, group, designer) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '2',
|
||||
name: '组件明细表_外购件_导入数据',
|
||||
param: '项目=' + project + '&机床=' + machine + '&组号=' + group + '&设计者=' + designer
|
||||
}
|
||||
})
|
||||
}
|
||||
// 导入Excel1外购件
|
||||
export function outBuyUpload1(designer, time, project, machine, group, num1, num2, name, size, num3, supplier, remark, mark) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '2',
|
||||
name: '组件明细表_外购件_导入数据1',
|
||||
param: '设计者=' + designer + '&保存时间=' + time + '&项目=' + project + '&机床=' + machine + '&组号=' + group + '&序号=' + num1 + '&图号或者型号=' + num2 + '&名称=' + name + '&材料或者规格=' + size + '&数量=' + num3 + '&供货商=' + supplier + '&备注=' + remark + '&标记=' + mark
|
||||
}
|
||||
})
|
||||
}
|
||||
// 查询零件(查重)外购件
|
||||
export function outBuySearchPart(project, machine, group) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '1',
|
||||
name: '导入数据_外购件_查询',
|
||||
param: '项目=' + project + '&机床=' + machine + '&组号=' + group
|
||||
}
|
||||
})
|
||||
}
|
||||
// 查询零件 基本件
|
||||
export function searchBasePartDetail(project, machine, group) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '1',
|
||||
name: 'PDM_零件明细表_基本件_数据导入保存_查询数据_综合_全部',
|
||||
param: '项目=' + project + '&机床=' + machine + '&组号=' + group
|
||||
}
|
||||
})
|
||||
}
|
||||
// 查询零件 基本件
|
||||
export function searchOutPartDetail(project, machine, group) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '1',
|
||||
name: 'PDM_零件明细表_外购件和标准件_数据导入保存_综合_全部',
|
||||
param: '项目=' + project + '&机床=' + machine + '&组号=' + group
|
||||
}
|
||||
})
|
||||
}
|
||||
// 删除 基本件
|
||||
export function deleteTable1(id) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '2',
|
||||
name: 'PDM_零件明细表_基本件_数据导入保存_删除数据',
|
||||
param: 'id=' + id
|
||||
}
|
||||
})
|
||||
}
|
||||
// 删除 外购件
|
||||
export function deleteTable2(id) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '2',
|
||||
name: 'PDM_零件明细表_外购件和标准件_数据导入保存_删除数据',
|
||||
param: 'id=' + id
|
||||
}
|
||||
})
|
||||
}
|
||||
// 初始化规范 备注
|
||||
export function initStandard1() {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '1',
|
||||
name: 'PDM_零件明细表_基本件_数据导入保存_查询数据_规范表_备注'
|
||||
}
|
||||
})
|
||||
}
|
||||
// 初始化规范 材料或者规格
|
||||
export function initStandard2() {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '1',
|
||||
name: 'PDM_零件明细表_基本件_数据导入保存_查询数据_规范表_材料或者规格'
|
||||
}
|
||||
})
|
||||
}
|
||||
// 初始化规范 物料流水号
|
||||
export function initStandard3() {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '1',
|
||||
name: 'PDM_零件明细表_基本件_数据导入保存_查询数据_规范表_物料流水号'
|
||||
}
|
||||
})
|
||||
}
|
||||
412
src/views/TechnologyCenter/PartDrawingMaintenance/index.vue
Normal file
412
src/views/TechnologyCenter/PartDrawingMaintenance/index.vue
Normal file
@@ -0,0 +1,412 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card>
|
||||
<span>项目名称</span>
|
||||
<el-select v-model="projectValue" placeholder="请选择项目名称" filterable size="small">
|
||||
<el-option
|
||||
v-for="item in project"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<span>机床图号</span>
|
||||
<el-select v-model="machineValue" placeholder="请选择机床图号" filterable size="small">
|
||||
<el-option
|
||||
v-for="item in machine"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
<span>组号</span>
|
||||
<el-select v-model="groupValue" placeholder="请选择组号" filterable size="small">
|
||||
<el-option
|
||||
v-for="item in group"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
|
||||
<el-button icon="el-icon-search" type="success" size="small" @click="pageCurrentWB = 1;pageSizeWB = 10;pageCurrent = 1;pageSize = 10;getTableData()">查询</el-button>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
highlight-current-row
|
||||
border
|
||||
size="mini"
|
||||
style="width: 100%;max-height: 520px"
|
||||
height="520">
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
width="50"/>
|
||||
<el-table-column
|
||||
label="机床图号"
|
||||
align="center"
|
||||
min-width="100px">
|
||||
<template slot-scope="scope">{{ scope.row.机床图号 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="零件图号"
|
||||
align="center"
|
||||
min-width="100px">
|
||||
<template slot-scope="scope">{{ scope.row.零件图号 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="零件名称"
|
||||
align="center"
|
||||
min-width="100px">
|
||||
<template slot-scope="scope">{{ scope.row.零件名称 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="组号"
|
||||
align="center"
|
||||
min-width="100px">
|
||||
<template slot-scope="scope">{{ scope.row.组号 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="材料"
|
||||
align="center">
|
||||
<template slot-scope="scope">{{ scope.row.材料 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="备注"
|
||||
align="center">
|
||||
<template slot-scope="scope">{{ scope.row.零件备注 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="零件类型"
|
||||
align="center">
|
||||
<template slot-scope="scope">{{ scope.row.零件类型名称 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
min-width="50px"
|
||||
label="零件图纸"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
|
||||
<el-button circle icon="el-icon-search" size="small" @click="getNum(scope.row)"/>
|
||||
<!--<el-button slot="reference" type="success" icon="el-icon-search" circle size="mini"></el-button>-->
|
||||
<!--<el-button type="success" icon="el-icon-search" circle size="mini"></el-button>-->
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
min-width="80px"
|
||||
label="操作"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
<!--<FileUpload ref="FileUpload" :num="scope.row.基本件流水号" table-name="机加工MES_零件图PDF表" @listenMsg ="listenMsgFromChid"/>-->
|
||||
<el-upload
|
||||
:disabled="disabled"
|
||||
:action="action"
|
||||
:on-success="uploadSuccess"
|
||||
:on-error="uploadFailure"
|
||||
:show-file-list="showFileList"
|
||||
:file-list="fileList"
|
||||
class="upload-demo"
|
||||
multiple>
|
||||
<el-button :disabled="disabled" size="mini" type="primary" round @click="getAction(scope.row)">点击上传</el-button>
|
||||
</el-upload>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="block" style="margin-top: 10px;">
|
||||
<el-pagination
|
||||
:current-page="pageCurrent"
|
||||
:page-sizes="[10, 20, 30, 40]"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChanges"
|
||||
@current-change="handleCurrentChanges"/>
|
||||
</div>
|
||||
|
||||
</el-card>
|
||||
<el-dialog
|
||||
:show-close="close"
|
||||
:visible.sync="dialogVisible"
|
||||
width="15%">
|
||||
<div v-for="(file, key) in hadFile" :key="key">
|
||||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div class="action">
|
||||
<a v-show="isDeleteShow" class="delete" @click="deleteFileData(file.id)">删除</a>
|
||||
</div>
|
||||
<div v-if="file.suffix==='pdf'" class="icon"><svg-icon icon-class="pdf" /></div>
|
||||
<div v-else-if="file.suffix==='docx'||file.suffix === 'doc'" class="icon"><svg-icon icon-class="doc" /></div>
|
||||
<div v-else-if="file.suffix==='xlsx' || file.suffix === 'xls'" class="icon"><svg-icon icon-class="excel" /></div>
|
||||
<div v-else-if="file.suffix==='pptx' || file.suffix === 'ppt'" class="icon"><svg-icon icon-class="ppt" /></div>
|
||||
<div v-else-if="file.suffix==='jpg' || file.suffix === 'jpeg'|| file.suffix === 'png'" class="icon"><svg-icon icon-class="pic" /></div>
|
||||
<div v-else class="icon"><svg-icon icon-class="file" /></div>
|
||||
<a id="appUrl" :href="file.url" target="view_window"><div class="info">{{ file.name }}</div></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request'
|
||||
import { projectSelect, machineSelect, groupSelect, basicPartsData } from '@/api/TechnologyCenter/PartDrawingMaintenance'
|
||||
import { MESUploadFile, MESDownloadFile } from '@/utils/request'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
close: false,
|
||||
dialogVisible: false,
|
||||
partID: '',
|
||||
projectValue: '',
|
||||
project: [],
|
||||
machineValue: '',
|
||||
machine: [],
|
||||
groupValue: '',
|
||||
group: [],
|
||||
pageCurrent: 1,
|
||||
pageSize: 10,
|
||||
total: null,
|
||||
loading: false,
|
||||
tableData: [],
|
||||
fileList: [],
|
||||
showFileList: true,
|
||||
action: '',
|
||||
disabled: false,
|
||||
tableName: '机加工MES_零件图PDF表',
|
||||
num: '',
|
||||
hadFile: [],
|
||||
isDeleteShow: false,
|
||||
deleteShow: '1',
|
||||
operationType: '0'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
groupName() {
|
||||
for (let i = 0; i < this.group.length; i++) {
|
||||
if (this.group[i].value === this.groupValue) {
|
||||
return this.group[i].label
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
project(val) {
|
||||
if (val.length > 0) {
|
||||
this.projectValue = val[0].value
|
||||
}
|
||||
},
|
||||
projectValue(val) {
|
||||
this.machineValue = ''
|
||||
this.machine = []
|
||||
this.groupValue = ''
|
||||
this.group = []
|
||||
if (val) {
|
||||
this.getMachineSelect(val)
|
||||
}
|
||||
},
|
||||
machine(val) {
|
||||
if (val.length > 0) {
|
||||
this.machineValue = val[0].value
|
||||
}
|
||||
},
|
||||
machineValue(val) {
|
||||
this.groupValue = ''
|
||||
this.group = []
|
||||
if (val) {
|
||||
this.getGroupSelect(val)
|
||||
}
|
||||
},
|
||||
group(val) {
|
||||
if (val.length > 0) {
|
||||
this.groupValue = val[0].value
|
||||
}
|
||||
},
|
||||
groupValue(val) {
|
||||
if (val) {
|
||||
this.pageCurrent = 1
|
||||
this.pageSize = 10
|
||||
this.getTableData()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
getAction(row) {
|
||||
this.num = row.基本件流水号
|
||||
this.action = `${MESUploadFile}?&num=${this.num}&tableName=${this.tableName}`
|
||||
},
|
||||
getNum(row) {
|
||||
this.dialogVisible = true
|
||||
this.num = row.基本件流水号
|
||||
this.getFileList(this.num)
|
||||
},
|
||||
uploadSuccess(res, file, fileList) {
|
||||
if (res[0].result === '1') {
|
||||
const index = fileList.indexOf(file)
|
||||
fileList.splice(index, 1)
|
||||
} else {
|
||||
this.$message.error(`${file.name}文件上传失败,请检查上传文件是否正确!`)
|
||||
}
|
||||
if (fileList.length === 0) {
|
||||
this.$message.success('文件上传成功')
|
||||
// this.$refs.FileDown.getFileList(this.num)
|
||||
}
|
||||
},
|
||||
uploadFailure(a, file, fileList) {
|
||||
fileList.map(file => {
|
||||
this.$message.error(`${file.name}文件上传失败,请检查上传文件是否正确!`)
|
||||
})
|
||||
},
|
||||
fetchData() {
|
||||
this.getSelect(projectSelect, ['项目名称', '项目流水号'], 'project')
|
||||
},
|
||||
getMachineSelect(val) {
|
||||
this.getSelect(machineSelect, ['机床图号', '机床流水号'], 'machine', val)
|
||||
},
|
||||
getGroupSelect(val) {
|
||||
this.getSelect(groupSelect, ['组号', '组件流水号'], 'group', val)
|
||||
},
|
||||
getTableData() {
|
||||
const project_check = this.projectValue ? 1 : 0
|
||||
const machine_check = this.machineValue ? 1 : 0
|
||||
const group_check = this.groupValue ? 1 : 0
|
||||
this.loading = true
|
||||
basicPartsData(project_check, this.projectValue, machine_check, this.machineValue, group_check, this.groupValue, this.pageSize, this.pageCurrent).then(response => {
|
||||
this.loading = false
|
||||
this.tableData = response.data.rows
|
||||
this.total = response.data.total
|
||||
})
|
||||
},
|
||||
handleSizeChanges(val) {
|
||||
this.pageCurrent = 1
|
||||
this.pageSize = val
|
||||
this.getTableData()
|
||||
},
|
||||
handleCurrentChanges(val) {
|
||||
this.pageCurrent = val
|
||||
this.getTableData()
|
||||
},
|
||||
async getFileList(value) {
|
||||
this.hadFile = []
|
||||
this.deleteShow === '1' ? this.isDeleteShow = true : this.isDeleteShow = false
|
||||
if (value) {
|
||||
await request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '3',
|
||||
name: `select * from ${this.tableName} where 是否启用 = 1 and num = ${value}`
|
||||
}
|
||||
}).then(data => {
|
||||
this.suffix = data.data
|
||||
if (data.data.length > 0) {
|
||||
if (this.operationType === '1') {
|
||||
data.data.map(item => {
|
||||
this.hadFile.push({
|
||||
url: `${MESDownloadFile}?id=${item.uid}.${item.suffix}&name=${item.name}.${item.suffix}`,
|
||||
name: `${item.name}.${item.suffix}`,
|
||||
suffix: item.suffix,
|
||||
id: item.uid
|
||||
})
|
||||
})
|
||||
} else if (this.operationType === '0') {
|
||||
const server = `${MESDownloadFile}`.split('/')
|
||||
data.data.map(item => {
|
||||
this.hadFile.push({
|
||||
url: `http://${server[2]}/webpage/part/${item.uid}.${item.suffix}`,
|
||||
name: `${item.name}.${item.suffix}`,
|
||||
suffix: item.suffix,
|
||||
id: item.uid
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
async deleteFileData(id) {
|
||||
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '3',
|
||||
name: `delete from ${this.tableName} where uid = N'${id}'`
|
||||
}
|
||||
}).then(response => {
|
||||
if (response.data.length === 0) {
|
||||
this.$message.success('删除成功')
|
||||
this.getFileList(this.num)
|
||||
} else {
|
||||
this.$message.error('删除失败')
|
||||
this.getFileList(this.num)
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.wrapper{
|
||||
width: 90%;
|
||||
height: 50px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #b8c7d9;
|
||||
/*float: left;*/
|
||||
margin: 10px;
|
||||
}
|
||||
.content{
|
||||
position: relative;
|
||||
padding: 8px 8px 0 8px;
|
||||
}
|
||||
.action{
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 8px;
|
||||
}
|
||||
.delete{
|
||||
padding: 0 5px;
|
||||
border-radius: 3px;
|
||||
color: #0f84b0;
|
||||
font-size: 12px;
|
||||
}
|
||||
.delete:hover{
|
||||
background: -webkit-linear-gradient(top,#0ba9e3,#0099d3);
|
||||
color: #fff;
|
||||
}
|
||||
a{
|
||||
text-decoration: none;
|
||||
}
|
||||
.icon{
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: inline-block;
|
||||
margin-right: 7px;
|
||||
margin-top: 2px;
|
||||
font-size: 26px;
|
||||
}
|
||||
.info{
|
||||
width:100px;
|
||||
height: 50px;
|
||||
position: absolute;
|
||||
left: 44px;
|
||||
line-height: 30px;
|
||||
display: inline-block;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
494
src/views/TechnologyCenter/QueryParts/index.vue
Normal file
494
src/views/TechnologyCenter/QueryParts/index.vue
Normal file
@@ -0,0 +1,494 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<span>项目名称</span>
|
||||
<el-select v-model="projectValue" placeholder="请选择项目名称" filterable size="small">
|
||||
<el-option
|
||||
v-for="item in project"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
|
||||
<span>机床图号</span>
|
||||
<el-select v-model="machineValue" placeholder="请选择机床图号" filterable size="small">
|
||||
<el-option
|
||||
v-for="item in machine"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
|
||||
<span>组号</span>
|
||||
<el-select v-model="groupValue" placeholder="请选择组号" filterable size="small">
|
||||
<el-option
|
||||
v-for="item in group"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
|
||||
<el-button icon="el-icon-search" type="success" size="small" @click="pageCurrentWB = 1;pageSizeWB = 10;pageCurrent = 1;pageSize = 10;getTableData()">查询</el-button>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<div v-for="(file, key) in hadFile" :key="key">
|
||||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<div class="action"/>
|
||||
<div v-if="file.suffix==='pdf'" class="icon"><svg-icon icon-class="pdf" /></div>
|
||||
<div v-else-if="file.suffix==='docx'||file.suffix === 'doc'" class="icon"><svg-icon icon-class="doc" /></div>
|
||||
<div v-else-if="file.suffix==='xlsx' || file.suffix === 'xls'" class="icon"><svg-icon icon-class="excel" /></div>
|
||||
<div v-else-if="file.suffix==='pptx' || file.suffix === 'ppt'" class="icon"><svg-icon icon-class="ppt" /></div>
|
||||
<div v-else-if="file.suffix==='jpg' || file.suffix === 'jpeg'|| file.suffix === 'png'" class="icon"><svg-icon icon-class="pic" /></div>
|
||||
<div v-else class="icon"><svg-icon icon-class="file" /></div>
|
||||
<a :href="file.url" target="view_window"><div class="info">{{ file.name }}</div></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
highlight-current-row
|
||||
border
|
||||
size="mini"
|
||||
style="width: 100%;max-height: 520px"
|
||||
height="520">
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
width="50"/>
|
||||
<el-table-column
|
||||
label="机床图号"
|
||||
align="center"
|
||||
min-width="150px">
|
||||
<template slot-scope="scope">{{ scope.row.机床图号 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="零件图号"
|
||||
align="center"
|
||||
min-width="200px">
|
||||
<template slot-scope="scope">{{ scope.row.零件图号 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="零件名称"
|
||||
align="center"
|
||||
min-width="100px">
|
||||
<template slot-scope="scope">{{ scope.row.零件名称 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="组号"
|
||||
align="center"
|
||||
min-width="100px">
|
||||
<template slot-scope="scope">{{ scope.row.组号 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="零件数量"
|
||||
align="center">
|
||||
<template slot-scope="scope">{{ scope.row.零件数量 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="部件数量" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.部件数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="机床数量" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.机床数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="材料"
|
||||
align="center">
|
||||
<template slot-scope="scope">{{ scope.row.材料 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="规格"
|
||||
align="center">
|
||||
<template slot-scope="scope">{{ scope.row.规格 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="备注"
|
||||
align="center">
|
||||
<template slot-scope="scope">{{ scope.row.零件备注 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="零件类型"
|
||||
align="center">
|
||||
<template slot-scope="scope">{{ scope.row.零件类型名称 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="分类码" width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.分类码 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="旧零件图号" width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.前零件图号 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="整改类型" width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.整改类型 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" align="center" width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
:disabled="Number(id)!==0"
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="block" style="margin-top: 10px;">
|
||||
<el-pagination
|
||||
:current-page="pageCurrent"
|
||||
:page-sizes="[10, 20, 30, 40]"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChanges"
|
||||
@current-change="handleCurrentChanges"/>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<el-table
|
||||
v-loading="loadingWB"
|
||||
:data="tableDataWB"
|
||||
style="width: 100%;min-height: 600px;"
|
||||
size="mini"
|
||||
height="600"
|
||||
highlight-current-row
|
||||
border>
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
width="50"/>
|
||||
<el-table-column align="center" label="物料名称">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料名称 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料规格">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料规格 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="物料型号">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.物料型号 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="零件数量">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.零件数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="部件数量" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.部件数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="机床数量" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.机床数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="零件类型">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.零件类型 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="供货商">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.供货商 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="备注" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.备注 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="标记" width="100">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.标记 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="分类码" width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.分类码 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="整改类型" width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.整改类型 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
:disabled="Number(id)!==0"
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="block" style="margin-top: 10px">
|
||||
<el-pagination
|
||||
:current-page="pageCurrentWB"
|
||||
:page-sizes="[10, 20, 30, 40]"
|
||||
:page-size="pageSizeWB"
|
||||
:total="totalWB"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChangeWB"
|
||||
@current-change="handleCurrentChangeWB"/>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { projectSelect, machineSelect, groupSelect, basicPartsData, deleteBasicParts, purchasePartsData, deletePurchaseData, getFileData } from '@/api/TechnologyCenter/QueryParts'
|
||||
import { mapGetters } from 'vuex'
|
||||
import { ServerIP } from '@/utils/request'
|
||||
export default {
|
||||
name: 'Index',
|
||||
data() {
|
||||
return {
|
||||
projectValue: '',
|
||||
project: [],
|
||||
machineValue: '',
|
||||
machine: [],
|
||||
groupValue: '',
|
||||
group: [],
|
||||
loading: false,
|
||||
loadingWB: false,
|
||||
total: 0,
|
||||
tableData: [],
|
||||
tableDataWB: [],
|
||||
pageCurrent: 1,
|
||||
pageSize: 10,
|
||||
pageCurrentWB: 1,
|
||||
pageSizeWB: 10,
|
||||
totalWB: 0,
|
||||
hadFile: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'name',
|
||||
'id'// 人员编号
|
||||
]),
|
||||
groupName() {
|
||||
for (let i = 0; i < this.group.length; i++) {
|
||||
if (this.group[i].value === this.groupValue) {
|
||||
return this.group[i].label
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
project(val) {
|
||||
console.log(val)
|
||||
if (val.length > 0) {
|
||||
this.projectValue = val[0].value
|
||||
}
|
||||
},
|
||||
projectValue(val) {
|
||||
this.machineValue = ''
|
||||
this.machine = []
|
||||
this.groupValue = ''
|
||||
this.group = []
|
||||
if (val) {
|
||||
this.getMachineSelect(val)
|
||||
}
|
||||
},
|
||||
machine(val) {
|
||||
if (val.length > 0) {
|
||||
this.machineValue = val[0].value
|
||||
}
|
||||
},
|
||||
machineValue(val) {
|
||||
this.groupValue = ''
|
||||
this.group = []
|
||||
if (val) {
|
||||
this.getGroupSelect(val)
|
||||
}
|
||||
},
|
||||
group(val) {
|
||||
if (val.length > 0) {
|
||||
this.groupValue = val[0].value
|
||||
}
|
||||
},
|
||||
groupValue(val) {
|
||||
if (val) {
|
||||
this.pageCurrentWB = 1
|
||||
this.pageSizeWB = 10
|
||||
this.pageCurrent = 1
|
||||
this.pageSize = 10
|
||||
this.getTableData()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
// 在什么情况下需要查询上传的附件,调用this.getFileData()即可根据
|
||||
getFileData(machineValue) {
|
||||
this.hadFile = []
|
||||
getFileData(machineValue).then(res => {
|
||||
if (res.data.length > 0) {
|
||||
res.data.map(item => {
|
||||
this.hadFile.push({
|
||||
url: `${ServerIP}${item.文件标识}.${item.文件后缀}`,
|
||||
name: `${item.文件名称}.${item.文件后缀}`,
|
||||
suffix: item.文件后缀,
|
||||
id: item.文件标识
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
fetchData() {
|
||||
this.getSelect(projectSelect, ['项目名称', '项目流水号'], 'project')
|
||||
},
|
||||
getMachineSelect(val) {
|
||||
this.getSelect(machineSelect, ['机床图号', '机床流水号'], 'machine', val)
|
||||
},
|
||||
getGroupSelect(val) {
|
||||
this.getSelect(groupSelect, ['组号', '组件流水号'], 'group', val)
|
||||
},
|
||||
getTableData() {
|
||||
this.getFileData(this.machineValue)
|
||||
console.log(this.hadFile, 88899)
|
||||
const project_check = this.projectValue ? 1 : 0
|
||||
const machine_check = this.machineValue ? 1 : 0
|
||||
const group_check = this.groupValue ? 1 : 0
|
||||
this.loading = true
|
||||
basicPartsData(project_check, this.projectValue, machine_check, this.machineValue, group_check, this.groupValue, this.pageSize, this.pageCurrent).then(response => {
|
||||
this.loading = false
|
||||
const res = response.data
|
||||
this.total = res.total
|
||||
console.log(this.tableData)
|
||||
this.tableData = res.rows.map(item => {
|
||||
if (item.整改类型 === '1') {
|
||||
item.整改类型 = '新增'
|
||||
} else if (item.整改类型 === '2') {
|
||||
item.整改类型 = '替换'
|
||||
} else if (item.整改类型 === '3') {
|
||||
item.整改类型 = '补充加工'
|
||||
}
|
||||
return item
|
||||
})
|
||||
})
|
||||
this.loadingWB = true
|
||||
purchasePartsData(this.groupValue, this.pageCurrentWB, this.pageSizeWB).then(response => {
|
||||
this.loadingWB = false
|
||||
const data = response.data
|
||||
this.totalWB = data.total
|
||||
this.tableDataWB = data.rows.map(item => {
|
||||
console.log(item)
|
||||
if (item.整改类型 === '1') {
|
||||
item.整改类型 = '新增'
|
||||
} else if (item.整改类型 === '2') {
|
||||
item.整改类型 = '替换'
|
||||
} else if (item.整改类型 === '3') {
|
||||
item.整改类型 = '补充加工'
|
||||
}
|
||||
item.零件类型 = item.零件类型 === '2' ? '外购件' : '标准件'
|
||||
return item
|
||||
})
|
||||
})
|
||||
},
|
||||
handleDelete(row) {
|
||||
if (row.基本件流水号) {
|
||||
this.deleteRow(deleteBasicParts, row.基本件流水号, function() {
|
||||
this.getTableData()
|
||||
})
|
||||
} else {
|
||||
this.deleteRow(deletePurchaseData, row.标准件和外购件流水号, function() {
|
||||
this.getTableData()
|
||||
})
|
||||
}
|
||||
},
|
||||
handleSizeChanges(val) {
|
||||
this.pageCurrent = 1
|
||||
this.pageSize = val
|
||||
this.getTableData()
|
||||
},
|
||||
handleCurrentChanges(val) {
|
||||
this.pageCurrent = val
|
||||
this.getTableData()
|
||||
},
|
||||
handleSizeChangeWB(val) {
|
||||
this.pageCurrentWB = 1
|
||||
this.pageSizeWB = val
|
||||
this.getTableData()
|
||||
},
|
||||
handleCurrentChangeWB(val) {
|
||||
this.pageCurrentWB = val
|
||||
this.getTableData()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
span{
|
||||
margin: 20px;
|
||||
}
|
||||
.wrapper{
|
||||
width: 225px;
|
||||
height: 50px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #b8c7d9;
|
||||
float: left;
|
||||
margin: 10px;
|
||||
}
|
||||
.content{
|
||||
position: relative;
|
||||
padding: 8px 8px 0 8px;
|
||||
}
|
||||
.action{
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 8px;
|
||||
}
|
||||
.delete{
|
||||
padding: 0 5px;
|
||||
border-radius: 3px;
|
||||
color: #0f84b0;
|
||||
font-size: 12px;
|
||||
}
|
||||
.delete:hover{
|
||||
background: -webkit-linear-gradient(top,#0ba9e3,#0099d3);
|
||||
color: #fff;
|
||||
}
|
||||
a{
|
||||
text-decoration: none;
|
||||
}
|
||||
.icon{
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: inline-block;
|
||||
margin-right: 7px;
|
||||
margin-top: 2px;
|
||||
font-size: 26px;
|
||||
}
|
||||
.info{
|
||||
position: absolute;
|
||||
left: 44px;
|
||||
line-height: 30px;
|
||||
display: inline-block;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user