添加营销系统模块
This commit is contained in:
710
src/views/TechnologyCenter/CreatePackingList/index.vue
Normal file
710
src/views/TechnologyCenter/CreatePackingList/index.vue
Normal file
@@ -0,0 +1,710 @@
|
||||
<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>
|
||||
<el-button :disabled="disabled" type="success" size="small" icon="el-icon-circle-plus-outline" @click="addReceipt">增加</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-download">导出</el-button>
|
||||
<div class="title">总装箱单</div>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="receiptData"
|
||||
highlight-current-row
|
||||
border
|
||||
style="margin-top:20px">
|
||||
<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="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="操作" fixed="right" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
@click="handleEditReceipt(scope.row)">编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDeleteReceipt(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<el-card style="margin-top: 10px">
|
||||
<el-button :disabled="!disabled" type="primary" size="small" icon="el-icon-search" @click="addMachine">添加主机</el-button>
|
||||
<div class="title">主机</div>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="machineTableData"
|
||||
highlight-current-row
|
||||
border
|
||||
style="margin-top:20px">
|
||||
<el-table-column type="expand">
|
||||
<template slot-scope="props">
|
||||
<el-table
|
||||
:data="props.row.groupData"
|
||||
border
|
||||
style="width: 90%">
|
||||
<el-table-column
|
||||
fixed
|
||||
align="center"
|
||||
prop="类别"
|
||||
label="类别"
|
||||
/>
|
||||
<el-table-column
|
||||
label="序号"
|
||||
type="index"
|
||||
align="center"
|
||||
width="100px"/>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="代号"
|
||||
label="代号"
|
||||
/>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="部件名称"
|
||||
label="名称"
|
||||
/>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="address"
|
||||
label="规格"
|
||||
/>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="部件数量"
|
||||
label="数量"
|
||||
/>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="备注"
|
||||
label="备注"
|
||||
/>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="序号"
|
||||
type="index"
|
||||
align="center"
|
||||
width="100px"/>
|
||||
<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="操作" fixed="right" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
@click="editMachine(scope.row)">编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
@click="deleteMachine(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-card style="margin-top: 10px">
|
||||
<el-button :disabled="!disabled" type="primary" size="small" icon="el-icon-search" @click="addSpare">添加备件</el-button>
|
||||
<div class="title">随机供应的备件</div>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="spareData"
|
||||
highlight-current-row
|
||||
border
|
||||
style="margin-top:20px">
|
||||
<el-table-column
|
||||
label="序号"
|
||||
type="index"
|
||||
align="center"
|
||||
min-width="150px"/>
|
||||
<el-table-column
|
||||
label="名称"
|
||||
align="center">
|
||||
<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="操作" fixed="right" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
@click="editSpare(scope.row)">编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
@click="deleteSpare(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-card style="margin-top: 10px">
|
||||
<el-button :disabled="!disabled" type="primary" size="small" icon="el-icon-search" @click="addFile">添加文件</el-button>
|
||||
<div class="title">随机技术文件</div>
|
||||
<el-table
|
||||
v-loading="fileLoading"
|
||||
:data="fileData"
|
||||
highlight-current-row
|
||||
border
|
||||
style="margin-top:20px">
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
min-width="150px"/>
|
||||
<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="500px">
|
||||
<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="danger"
|
||||
icon="el-icon-edit"
|
||||
@click="editFile(scope.row)">编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
@click="deleteFile(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-dialog :title="receiptTitle" :visible.sync="receiptVisible" center style="min-height: 200px" width="800px">
|
||||
<el-form ref="receiptForm" :rules="rules" :model="receiptForm" label-position="left" label-width="110px" class="demo-ruleForm">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="装箱单号" prop="装箱单号">
|
||||
<el-input v-model="receiptForm.装箱单号" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="名称" prop="名称">
|
||||
<el-input v-model="receiptForm.名称" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="发货节点" prop="发货节点">
|
||||
<el-date-picker
|
||||
v-model="receiptForm.发货节点"
|
||||
value-format="yyyy-MM-dd"
|
||||
size="small"
|
||||
type="date"
|
||||
placeholder="请选择发货节点"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="收货单位" prop="收货单位">
|
||||
<el-input v-model="receiptForm.收货单位" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系人" prop="联系人">
|
||||
<el-input v-model="receiptForm.联系人" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系方式" prop="联系方式">
|
||||
<el-input v-model="receiptForm.联系方式" 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-if="receiptTitle === '新增总装箱单'" type="primary" @click="submitAddReceipt">确定</el-button>
|
||||
<el-button v-else-if="receiptTitle === '编辑总装箱单'" type="primary" @click="submitEditReceipt">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="machineVisible" :title="machineTitle" center style="min-height: 200px" width="400px">
|
||||
<el-form ref="machineForm" :rules="rules" :model="machineForm" label-position="left" label-width="110px" class="demo-ruleForm">
|
||||
<el-row>
|
||||
<el-col v-if="machineTitle==='添加主机'" :span="24">
|
||||
<el-form-item label="机床号" prop="装箱单号">
|
||||
<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>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="数量" prop="数量">
|
||||
<el-input v-model="machineForm.数量" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="名称">
|
||||
<el-input v-model="machineForm.备注" 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-if="machineTitle==='添加主机'" type="primary" @click="submitAddMachine">确定</el-button>
|
||||
<el-button v-else-if="machineTitle==='编辑主机'" type="primary" @click="submitEditMachine">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="fileVisible" :title="fileTitle" center style="min-height: 200px" width="400px">
|
||||
<el-form ref="machineForm" :rules="rules" :model="fileForm" label-position="left" label-width="110px" class="demo-ruleForm">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="名称" prop="名称">
|
||||
<el-input v-model="fileForm.名称" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="数量" prop="数量">
|
||||
<el-input v-model="fileForm.数量" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="备注">
|
||||
<el-input v-model="fileForm.备注" 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-if="fileTitle==='添加文件'" type="primary" @click="submitAddFile">确定</el-button>
|
||||
<el-button v-else-if="fileTitle==='编辑文件'" type="primary" @click="submitEditFile">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="spareVisible" :title="spareTitle" center style="min-height: 200px" width="400px">
|
||||
<el-form ref="machineForm" :rules="rules" :model="spareForm" label-position="left" label-width="110px" class="demo-ruleForm">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="名称" prop="名称">
|
||||
<el-input v-model="spareForm.名称" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="规格" prop="规格">
|
||||
<el-input v-model="spareForm.规格" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="数量" prop="数量">
|
||||
<el-input v-model="spareForm.数量" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="单位" prop="单位">
|
||||
<el-input v-model="spareForm.单位" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="备注">
|
||||
<el-input v-model="spareForm.备注" 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-if="spareTitle==='添加备件'" type="primary" @click="submitAddSpare">确定</el-button>
|
||||
<el-button v-else-if="spareTitle==='编辑备件'" type="primary" @click="submitEditSpare">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { projectSelect, getReciptData, insertReciptData, updateReciptData, deleteReciptData, getMachineData, getGroupData, machineSelect, addMachineData, updateMachineData, deleteMachineData, getFileData, addFileData, editFileData, deleteFileData, getSpareData, addSpareData, editSpareData, deleteSpareData } from '@/api/TechnologyCenter/CreatePackingList'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
project: [],
|
||||
projectValue: '',
|
||||
machine: [],
|
||||
machineValue: '',
|
||||
receiptData: [],
|
||||
loading: false,
|
||||
fileData: [],
|
||||
fileLoading: false,
|
||||
receiptTitle: '',
|
||||
receiptVisible: false,
|
||||
machineTitle: '',
|
||||
machineVisible: false,
|
||||
spareVisible: false,
|
||||
spareTitle: '',
|
||||
spareForm: {
|
||||
序号: '',
|
||||
名称: '',
|
||||
规格: '',
|
||||
单位: '',
|
||||
备注: '',
|
||||
数量: ''
|
||||
},
|
||||
spareData: [],
|
||||
receiptForm: {
|
||||
装箱单号: '',
|
||||
发货节点: '',
|
||||
名称: '',
|
||||
收货单位: '',
|
||||
联系人: '',
|
||||
联系方式: ''
|
||||
},
|
||||
machineForm: {
|
||||
序号: '',
|
||||
机床号: '',
|
||||
备注: '',
|
||||
数量: ''
|
||||
},
|
||||
rules: {
|
||||
},
|
||||
machineTableData: [],
|
||||
receiptName: '',
|
||||
receiptNum: 0, // 装箱单号,全局要使用
|
||||
fileVisible: false,
|
||||
fileTitle: '',
|
||||
fileForm: {
|
||||
序号: '',
|
||||
名称: '',
|
||||
数量: '',
|
||||
备注: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
disabled() {
|
||||
return this.receiptData.length > 0
|
||||
},
|
||||
projectName() {
|
||||
for (let i = 0; i < this.project.length; i++) {
|
||||
if (this.project[i].value === this.projectValue) {
|
||||
return this.project[i].label
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
project(val) {
|
||||
if (val.length > 0) {
|
||||
this.projectValue = val[0].value
|
||||
}
|
||||
},
|
||||
projectValue(val) {
|
||||
if (val) {
|
||||
this.getMachineSelect(val)
|
||||
}
|
||||
this.getReceipt()
|
||||
},
|
||||
receiptNum(val) {
|
||||
if (val !== 0) {
|
||||
this.getMachineData()
|
||||
this.getFileData()
|
||||
this.getSpareData()
|
||||
}
|
||||
},
|
||||
machine(val) {
|
||||
if (val.length > 0) {
|
||||
this.machineValue = val[0].value
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
fetchData() {
|
||||
this.getSelect(projectSelect, ['项目名称', '项目流水号'], 'project')
|
||||
},
|
||||
getMachineSelect(val) {
|
||||
this.getSelect(machineSelect, ['机床图号', '机床流水号'], 'machine', val)
|
||||
},
|
||||
async getReceipt() {
|
||||
this.receiptData = []
|
||||
this.machineTableData = []
|
||||
const response = await getReciptData(this.projectValue)
|
||||
const data = response.data
|
||||
if (data.length > 0) {
|
||||
this.receiptNum = data[0].装箱单编号
|
||||
this.receiptName = data[0].装箱单号
|
||||
this.receiptData = data
|
||||
} else {
|
||||
this.receiptNum = 0
|
||||
this.receiptName = ''
|
||||
}
|
||||
},
|
||||
addReceipt() {
|
||||
this.addForm('receiptForm')
|
||||
this.receiptVisible = true
|
||||
this.receiptTitle = `新增总装箱单`
|
||||
},
|
||||
submitAddReceipt() {
|
||||
this.addTable(insertReciptData, [this.receiptForm.装箱单号, this.receiptForm.发货节点, this.receiptForm.名称, this.receiptForm.收货单位, this.receiptForm.联系方式, this.receiptForm.联系人, this.projectValue], 'receiptForm', function() {
|
||||
this.receiptVisible = false
|
||||
this.getReceipt()
|
||||
})
|
||||
},
|
||||
handleEditReceipt(row) {
|
||||
this.editForm(row, 'receiptForm', function() {
|
||||
this.receiptVisible = true
|
||||
this.receiptTitle = `编辑总装箱单`
|
||||
})
|
||||
},
|
||||
submitEditReceipt() {
|
||||
this.editTable(updateReciptData, [this.receiptForm.装箱单号, this.receiptForm.发货节点, this.receiptForm.名称, this.receiptForm.收货单位, this.receiptForm.联系方式, this.receiptForm.联系人, this.receiptNum], 'receiptForm', function() {
|
||||
this.receiptVisible = false
|
||||
this.getReceipt()
|
||||
})
|
||||
},
|
||||
handleDeleteReceipt(row) {
|
||||
this.deleteRow(deleteReciptData, row.装箱单编号, function() {
|
||||
this.receiptNum = 0
|
||||
this.receiptName = ''
|
||||
this.getReceipt()
|
||||
})
|
||||
},
|
||||
cancel() {
|
||||
this.receiptVisible = false
|
||||
this.machineVisible = false
|
||||
},
|
||||
async getMachineData() {
|
||||
const response = await getMachineData(this.receiptNum)
|
||||
const data = response.data
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const resp = await getGroupData(this.projectName, data[i].代号)
|
||||
const groupData = resp.data.map(item => {
|
||||
item.类别 = '机床所属部件'
|
||||
item.代号 = data[i].代号 + '-' + item.组号.split('-')[0]
|
||||
return item
|
||||
})
|
||||
this.machineTableData.push({
|
||||
序号: data[i].序号,
|
||||
代号: data[i].代号,
|
||||
机床名称: data[i].名称,
|
||||
数量: data[i].数量,
|
||||
备注: data[i].备注,
|
||||
groupData: groupData
|
||||
})
|
||||
}
|
||||
},
|
||||
addMachine() {
|
||||
this.addForm('machineForm', function() {
|
||||
this.machineTitle = `添加主机`
|
||||
this.machineVisible = true
|
||||
})
|
||||
},
|
||||
async submitAddMachine() {
|
||||
const response = await addMachineData(this.projectName, this.machineValue, this.machineForm.备注, this.machineForm.数量, this.receiptNum)
|
||||
if (response.data[0].result === '1') {
|
||||
this.machineVisible = false
|
||||
this.getMachineData()
|
||||
}
|
||||
},
|
||||
editMachine(row) {
|
||||
this.editForm(row, 'machineForm', function() {
|
||||
this.machineTitle = `编辑主机`
|
||||
this.machineVisible = true
|
||||
})
|
||||
},
|
||||
async submitEditMachine() {
|
||||
const response = await updateMachineData(this.machineForm.序号, this.machineForm.数量, this.machineForm.备注)
|
||||
if (response.data[0].result === '1') {
|
||||
this.machineVisible = false
|
||||
this.getMachineData()
|
||||
}
|
||||
},
|
||||
deleteMachine(row) {
|
||||
this.deleteRow(deleteMachineData, row.序号, function() {
|
||||
this.getMachineData()
|
||||
})
|
||||
},
|
||||
async getFileData() {
|
||||
const response = await getFileData(this.receiptNum)
|
||||
this.fileData = response.data
|
||||
console.log(this.fileData)
|
||||
},
|
||||
addFile() {
|
||||
this.addForm('machineForm', function() {
|
||||
this.fileTitle = `添加文件`
|
||||
this.fileVisible = true
|
||||
})
|
||||
},
|
||||
async submitAddFile() {
|
||||
const response = await addFileData(this.fileForm.名称, this.fileForm.数量, this.fileForm.备注, this.receiptNum)
|
||||
if (response.data[0].result === '1') {
|
||||
this.fileVisible = false
|
||||
this.getFileData()
|
||||
}
|
||||
},
|
||||
editFile(row) {
|
||||
this.editForm(row, 'fileForm', function() {
|
||||
this.fileTitle = `编辑文件`
|
||||
this.fileVisible = true
|
||||
})
|
||||
},
|
||||
async submitEditFile() {
|
||||
const response = await editFileData(this.fileForm.名称, this.fileForm.数量, this.fileForm.备注, this.fileForm.序号)
|
||||
if (response.data[0].result === '1') {
|
||||
this.fileVisible = false
|
||||
this.getFileData()
|
||||
}
|
||||
},
|
||||
deleteFile(row) {
|
||||
this.deleteRow(deleteFileData, row.序号, function() {
|
||||
this.getFileData()
|
||||
})
|
||||
},
|
||||
async getSpareData() {
|
||||
const response = await getSpareData(this.receiptNum)
|
||||
this.spareData = response.data
|
||||
},
|
||||
addSpare() {
|
||||
this.addForm('spareForm', function() {
|
||||
this.spareTitle = `添加备件`
|
||||
this.spareVisible = true
|
||||
})
|
||||
},
|
||||
async submitAddSpare() {
|
||||
const response = await addSpareData(this.spareForm.名称, this.spareForm.规格, this.spareForm.单位, this.spareForm.数量, this.spareForm.备注, this.receiptNum)
|
||||
if (response.data[0].result === '1') {
|
||||
this.spareVisible = false
|
||||
this.getSpareData()
|
||||
}
|
||||
},
|
||||
editSpare(row) {
|
||||
this.editForm(row, 'spareForm', function() {
|
||||
this.spareTitle = `编辑备件`
|
||||
this.spareVisible = true
|
||||
})
|
||||
},
|
||||
async submitEditSpare() {
|
||||
const response = await editSpareData(this.spareForm.名称, this.spareForm.规格, this.spareForm.单位, this.spareForm.数量, this.spareForm.备注, this.fileForm.序号)
|
||||
if (response.data[0].result === '1') {
|
||||
this.spareVisible = false
|
||||
this.getSpareData()
|
||||
}
|
||||
},
|
||||
deleteSpare(row) {
|
||||
this.deleteRow(deleteSpareData, row.序号, function() {
|
||||
this.getSpareData()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
span{
|
||||
margin: 20px;
|
||||
}
|
||||
.title{
|
||||
float: right;
|
||||
font-size: 20px;
|
||||
padding: 10px;
|
||||
font-weight: bolder;
|
||||
}
|
||||
</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>
|
||||
230
src/views/TechnologyCenter/ImportParts/index.vue
Normal file
230
src/views/TechnologyCenter/ImportParts/index.vue
Normal 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>
|
||||
546
src/views/TechnologyCenter/ImportParts/specificationData.vue
Normal file
546
src/views/TechnologyCenter/ImportParts/specificationData.vue
Normal 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>
|
||||
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_零件明细表_基本件_数据导入保存_查询数据_规范表_物料流水号'
|
||||
}
|
||||
})
|
||||
}
|
||||
325
src/views/TechnologyCenter/QueryParts/index.vue
Normal file
325
src/views/TechnologyCenter/QueryParts/index.vue
Normal file
@@ -0,0 +1,325 @@
|
||||
<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="getTableData">查询</el-button>
|
||||
</el-card>
|
||||
<el-card v-if="groupName && groupName.indexOf('MX') > -1">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
highlight-current-row
|
||||
border
|
||||
style="width: 100%;max-height: 520px"
|
||||
height="520">
|
||||
<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="操作" fixed="right" align="center" width="100">
|
||||
<template slot-scope="scope">
|
||||
<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, 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 v-else>
|
||||
<el-table
|
||||
v-loading="loadingWB"
|
||||
:data="tableDataWB"
|
||||
style="width: 100%;min-height: 600px;"
|
||||
height="600"
|
||||
highlight-current-row
|
||||
border>
|
||||
<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 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 label="操作" fixed="right" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<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="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 } from '@/api/TechnologyCenter/QueryParts'
|
||||
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
|
||||
}
|
||||
},
|
||||
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[1].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.getTableData()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
fetchData() {
|
||||
this.getSelect(projectSelect, ['项目名称', '项目流水号'], 'project')
|
||||
},
|
||||
getMachineSelect(val) {
|
||||
this.getSelect(machineSelect, ['机床图号', '机床流水号'], 'machine', val)
|
||||
},
|
||||
getGroupSelect(val) {
|
||||
this.getSelect(groupSelect, ['组号', '组件流水号'], 'group', val)
|
||||
},
|
||||
getTableData() {
|
||||
if (this.groupName.indexOf('MX') > -1) {
|
||||
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.tableData = res.rows
|
||||
this.total = res.total
|
||||
})
|
||||
} else {
|
||||
const type = this.groupName.indexOf('WG') ? 1 : 2
|
||||
this.loadingWB = true
|
||||
purchasePartsData(this.groupValue, type, this.pageCurrentWB, this.pageSizeWB).then(response => {
|
||||
this.loadingWB = false
|
||||
const data = response.data
|
||||
this.totalWB = data.total
|
||||
this.tableDataWB = data.rows.map(item => {
|
||||
item.标准件类型 = item.标准件类型 === '1' ? '外购件' : '标准件'
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user