添加营销系统模块

This commit is contained in:
hedekun
2018-11-08 08:39:42 +08:00
commit f7eb22e5bb
181 changed files with 35426 additions and 0 deletions

View 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>

View File

@@ -0,0 +1,230 @@
<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" placeholder="项目名称">
<el-option
v-for="item in project"
: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 icon="el-icon-upload2" type="primary" size="small" @click="basicPartsToSQL">导入到数据库</el-button>
</div>
</div>
</el-card>
<specification-data ref="specificationData" :groups-names="groupsNames" :machine-names="machineNames" :project-name="projectName" @machineChange="machineChange"/>
</div>
</template>
<script>
/* eslint-disable */
import UploadExcelComponent from './UploadExcel/index.vue'
import specificationData from './specificationData'
import { initProject, isExit, importBasics, importPurcharse, searchMachine, searchGroupNum } from '../../../api/TechnologyCenter/ImportParts'
export default {
name: 'UploadExcel',
components: { UploadExcelComponent, specificationData },
data() {
return {
project: [],
projectValue: '',
worksheet: [],
itemFile: [],
loading: false,
groupsNames: [],
machineNames: [],
err: 0
}
},
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: {
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.组号
})
})
})
}
},
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.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[j].Column1 !== 0) {
// this.$notify.error(`${this.worksheet[j].F2.v}机床不存在,请确认文件是否正确`)
// } else {
this.worksheet[j].G1 ? establishment = this.worksheet[j].G1.v : establishment = ''
this.worksheet[j].I1 ? proofread = this.worksheet[j].I1.v : proofread = ''
this.worksheet[j].L1 ? review = this.worksheet[j].L1.v : review = ''
this.worksheet[j].P1 ? date = this.worksheet[j].P1.v : date = ''
this.worksheet[j].Q1 ? pageNum = parseInt(this.worksheet[j].Q1.v.replace(/[^0-9]/ig, '')) : pageNum = ''
this.worksheet[j].C2 ? machineName = this.worksheet[j].C2.v : machineName = ''
this.worksheet[j].F2 ? machineNum = this.worksheet[j].F2.v : machineNum = ''
this.worksheet[j].J2 ? componentName = this.worksheet[j].J2.v : componentName = ''
this.worksheet[j].P2 ? componentNum = this.worksheet[j].P2.v : componentNum = ''
this.worksheet[j].Q2 ? totalNum = parseInt(this.worksheet[j].Q2.v.replace(/[^0-9]/ig, '')) : totalNum = ''
this.worksheet[j].R2 ? contractNum = this.worksheet[j].R2.v : contractNum = ''
this.worksheet[j].M2 ? groupNum = this.worksheet[j].M2.v : groupNum = ''
const len = parseInt(this.worksheet[j]['!ref'].split(':')[1].substring(1)) - 3
for (let i = 0; i < len; i++) {
const attr = i + 4
drawingNum = this.worksheet[j][`B${attr}`] ? this.worksheet[j][`B${attr}`].v : ''
name = this.worksheet[j][`D${attr}`] ? this.worksheet[j][`D${attr}`].v : ''
type = this.worksheet[j][`F${attr}`] ? this.worksheet[j][`F${attr}`].v : ''
material = this.worksheet[j][`J${attr}`] ? this.worksheet[j][`J${attr}`].v : ''
spareNum = this.worksheet[j][`L${attr}`] ? this.worksheet[j][`L${attr}`].v : ''
useNum = this.worksheet[j][`M${attr}`] ? this.worksheet[j][`M${attr}`].v : ''
manufacturer = this.worksheet[j][`O${attr}`] ? this.worksheet[j][`O${attr}`].v : ''
remarks = this.worksheet[j][`Q${attr}`] ? this.worksheet[j][`Q${attr}`].v : ''
classificationCode = this.worksheet[j][`R${attr}`] ? this.worksheet[j][`R${attr}`].v : ''
if (!drawingNum && !name && !type && !material && !spareNum && !useNum && !manufacturer && !remarks && !classificationCode) { // 当图号、名称、规格、材料、备件数量、装机数量、制造商、备注、分类码都为空时,循环终止,防止向数据库中插入多余且无用的数据
break
} else {
if (machineNum && groupNum) {
await this.insertToSQL(establishment, proofread, review, date, machineName, machineNum, componentName, componentNum, groupNum, contractNum, pageNum, totalNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
} else {
this.loading = false
this.$notify.error(`请确认导入文件是否正确`)
return
}
}
// }
}
this.itemFile.splice(j, 1)
this.worksheet.splice(j, 1)
}
this.loading = false
this.err === 0 ? this.$message.success(`导入完成`) : this.$message.error(`导入失败零件个数为${this.err},请检查文件是否正确`)
this.projectChange(this.projectName) // 调用查询机床方法通过watch属性检测变化会自动得到下面表格的值。
} catch (e) {
this.err++
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, groupNum, contractNum, totalNum, pageNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
const res = response.data
if (res[0].result === '0') {
this.$notify.error(`${drawingNum}导入失败`)
}
} else {
const response = await importPurcharse(establishment, proofread, review, date, this.projectName, machineNum, machineName, componentName, componentNum, groupNum, contractNum, totalNum, pageNum, drawingNum, name, type, material, spareNum, useNum, manufacturer, remarks, classificationCode)
const res = response.data
if (res[0].result === '0') {
this.$notify.error(`${drawingNum}导入失败`)
}
}
} catch (e) {
this.err++
this.$message.error(`导入数据错误`)
console.log(`导入数据错误${e}`)
}
}
}
}
</script>
<style lang="scss" scoped>
.wrapper{
width: 100%;
margin: 0 auto;
}
</style>

View File

@@ -0,0 +1,546 @@
<template>
<div>
<el-card>
<div style="width: 700px;margin: 0 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>分组名称</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 :disabled="disabled" type="primary" icon="el-icon-d-caret" size="small" style="margin-left: 10px" @click="transferData">传递</el-button>
</div>
</el-card>
<el-card>
<el-table
v-loading="listLoading"
:data="tableData"
:row-class-name="tableRowClassName"
border>
<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="名称" min-width="100">
<template slot-scope="scope">
{{ scope.row.名称 }}
</template>
</el-table-column>
<el-table-column align="center" label="材料" 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 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" 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-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>
</div>
</template>
<script>
import { unSpecificationQuery, unSpecificationQueryWB, specificationQueryWB, specificationQuery, deleteBasicParts, deleteBWParts, getMaterial, getMaterialWB, searchMaterialWB, updateRow, updateRowWB, transferMX, transferWG } from '../../../api/TechnologyCenter/ImportParts'
export default {
name: 'SpecificationData',
props: {
groupsNames: {
type: Array,
default: () => []
},
machineNames: {
type: Array,
default: () => []
},
projectName: {
type: String,
default: ''
}
},
data() {
return {
componentNum: '',
groupValue: '',
machineValue: '',
tableData: [],
tableDataAll: [],
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,
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.total = 0
this.machineValue = val.length > 0 ? val[0].value : ''
this.getGroups()
},
groupsNames(val) {
this.groupValue = val.length > 0 ? val[0].value : ''
},
groupValue(val) {
val ? this.fetchData() : this.tableData = []
}
},
mounted() {
this.getSelect(getMaterial, ['材料', '材料流水号'], 'materials')
},
methods: {
async fetchData() {
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
if (this.groupValue.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)
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}`)
}
},
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 {
if (this.groupValue) {
this.listLoading = true
if (this.groupValue.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 transferMX(data.图号或者型号, data.名称, total, data.备注, data.标记, data.设计者编号, data.组件流水号, data.材料流水号, data.数据类型, data.是否传递, data.序号, data.id)
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.groupValue.indexOf('WG') > -1) {
dataType = 1
} else {
dataType = 2
}
const resp = await transferWG(data.组件流水号, data.物料流水号, total, data.备注, data.标记, data.设计者编号, data.是否传递, dataType, data.序号, data.id)
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 = []
} 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: oldlace;
}
</style>
<style scoped>
span{
margin: 10px;
}
</style>

View 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_零件明细表_基本件_数据导入保存_查询数据_规范表_物料流水号'
}
})
}