家里的样式

This commit is contained in:
zhangdingyu
2019-09-18 09:34:02 +08:00
commit 02d1678fff
681 changed files with 133918 additions and 0 deletions

View File

@@ -0,0 +1,315 @@
<template>
<div class="app-container">
<el-card>
<span style="margin: 5px">零件图号</span>
<el-input v-model="Partpaint" clearable size="small" style="width:200px" />
<el-button size="small" type="success" icon="el-icon-search" style="margin: 0 0 0 10px" @click="getCraftNumber()">查询</el-button>
<el-button size="small" type="danger" icon="el-icon-remove-outline" style="margin: 0 0 0 10px" @click="Empty()">清空</el-button>
<el-button type="primary" size="small" class="el-icon-success" style="margin: 0 0 0 10px" @click="Innumber">入库</el-button>
</el-card>
<el-card>
<el-table v-loading="listLoading" :data="tableDataNum" border size="mini" style="width: 100%" height="650px">
<el-table-column
label="序号"
align="center"
type="index"
width="50"/>
<el-table-column label="项目名称" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.项目名称 }}
</template>
</el-table-column>
<el-table-column label="机床图号" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.机床图号 }}
</template>
</el-table-column>
<el-table-column label="零件图号" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.零件图号 }}
</template>
</el-table-column>
<el-table-column label="计划数量" align="center" min-width="100">
<template slot-scope="scope" align="center">
{{ tableDataNum[scope.$index].plannumber }}
</template>
</el-table-column>
<el-table-column label="入库数量" align="center" min-width="100">
<template slot-scope="scope">
<el-input v-model="tableDataNum[scope.$index].innumber" clearable size="mini"/>
</template>
</el-table-column>
<el-table-column label="仓库" align="center" min-width="100">
<template slot-scope="scope">
<el-select v-model="inventoryNumber" filterable clearable size="mini" placeholder="仓库名称" @change="Getlocate">
<el-option
v-for="item in inventoryName"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="货位" align="center" min-width="120">
<template slot-scope="scope">
<el-select v-model="locateNumber" filterable clearable size="mini" placeholder="货位名称">
<el-option
v-for="item in locateName"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="备注" align="center">
<template slot-scope="scope" align="center">
<el-input v-model="tableData[scope.$index].note" clearable size="mini"/>
</template>
</el-table-column>
<el-table-column label="操作" min-width="100" align="center">
<template slot-scope="scope">
<el-button
:disabled="scope.row.是否禁用"
size="mini"
type="danger"
class="el-icon-delete"
@click="handleDelete(scope.$index, scope.row)">移除</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</div>
</template>
<script>
import { searchTable, insertOne, getinventory, getlocate, searchPartNumber, CraftNumber } from '@/api/Inventory/Inboundscanning'
import { mapGetters } from 'vuex'
import { wsuri, name } from '@/utils/request'
export default {
data() {
return {
ace: 0,
a: '',
tableData: [],
partNumber: [],
listLoading: false,
craftplannumber: '',
radio2: 3,
PeopleNumber: '',
inventoryName: [], // 仓库名称下拉框
inventoryNumber: '',
locateName: [], // 货位名称下拉框
locateNumber: '',
Partpaint: '',
tableDataNum: []
}
},
computed: {
...mapGetters([
'id',
'token'
])
},
created() {
this.initWebpack()
this.getpeopleid()
this.Getinvent()
},
methods: {
// 移除
handleDelete(index, row) {
this.tableDataNum.splice(index, 1)
this.tableData.splice(index, 1)
},
// 获取人员编号
getpeopleid() {
this.PeopleNumber = this.id
},
// 初始化websocket
initWebpack() {
this.websock = new WebSocket(wsuri)// 这里面的this都指向vue
this.websock.onopen = this.websocketopen
this.websock.onmessage = this.websocketonmessage
this.websock.onclose = this.websocketclose
this.websock.onerror = this.websocketerror
},
// 打开
websocketopen() {
console.log('WebSocket连接成功')
this.websock.send('{<' + name + '>}')
},
// 数据接收
websocketonmessage(msg) {
this.partNumber = msg.data.split('|')[3]
this.partNumber = this.partNumber.slice(1)
this.getPaint(this.partNumber)
},
// 关闭
websocketclose() {
console.log('WebSocket关闭')
},
// 失败
websocketerror() {
console.log('WebSocket连接失败')
},
// 根据图号查流水号并查表1
getCraftNumber() {
this.partNumber = []
CraftNumber(this.Partpaint).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.partNumber.push(
response.data[i].工艺计划流水号
)
}
}).then(() => {
this.getscantable()
})
},
// 扫描并获取图号并查表1
getPaint() {
searchPartNumber(this.partNumber).then(response => {
this.Partpaint = response.data[0].零件图号
return this.Partpaint
}).then(() => {
this.getCraftNumber()
})
// this.getscantable()
},
// 根据流水号查询
getscantable() {
// this.tableData = []
if (this.partNumber.length === 0) {
this.$notify({
title: '警告',
message: '请输入正确的零件图号',
type: 'warning'
})
} else {
this.listLoading = true
searchTable(this.partNumber).then(response => {
if (response.data.length === 0) {
this.listLoading = false
this.$notify({
title: '警告',
message: '该零件未加工完成',
type: 'warning'
})
} else {
for (let i = 0; i < response.data.length; i++) {
if (response.data[i].考核状态 === 8) {
this.listLoading = false
this.$notify({
title: '警告',
message: 'P' + response.data[i].工艺计划流水号 + '已入库',
type: 'warning'
})
} else if (response.data[i].考核状态 === 9) {
this.listLoading = false
this.$notify({
title: '警告',
message: 'P' + response.data[i].工艺计划流水号 + '已出库',
type: 'warning'
})
} else if (response.data[i].考核状态 === 7) {
this.listLoading = false
this.tableData.push({
plannumber: response.data[i].剩余数量,
innumber: response.data[i].入库数量,
capture: '',
note: '',
工艺计划流水号: response.data[i].工艺计划流水号,
项目名称: response.data[i].项目名称,
机床图号: response.data[i].机床图号,
零件图号: response.data[i].零件图号
})
const hash = {} // 一个新数组data为你需要去重的数组newData用于接收去重后的数组, curVal.去重条件
this.tableDataNum = this.tableData.reduce((preVal, curVal) => {
hash[curVal.工艺计划流水号] ? '' : hash[curVal.工艺计划流水号] = true && preVal.push({
工艺计划流水号: curVal.工艺计划流水号,
项目名称: curVal.项目名称,
机床图号: curVal.机床图号,
零件图号: curVal.零件图号,
plannumber: curVal.plannumber,
innumber: curVal.innumber,
capture: '',
note: ''
})
return preVal
}, [])
}
}
}
}).then(() => {
this.listLoading = false
})
}
},
// 修改入库
Innumber() {
this.$confirm('此操作将不可逆转,且如果入库数量大于计划数量,则全部入库,是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.locateNumber === '') {
this.$message.error('请选择货位')
} else {
for (let i = 0; i < this.tableDataNum.length; i++) {
if (Number(this.tableDataNum[i].innumber) === 0) {
this.$message.error('请输入正确数量')
} else {
if (this.tableDataNum[i].innumber > this.tableDataNum[i].plannumber) {
this.tableDataNum[i].innumber = this.tableDataNum[i].plannumber
}
insertOne(this.tableDataNum[i].工艺计划流水号, this.tableDataNum[i].innumber, this.PeopleNumber, this.tableDataNum[i].capture, this.inventoryNumber, this.locateNumber, this.tableDataNum[i].note).then(response => {
if (response.data[0].result === '1') {
this.$message({
type: 'success',
message: '零件入库成功!'
})
this.Empty()
} else {
this.$message({
type: 'error',
message: '零件入库失败!'
})
}
})
}
}
}
}).catch(() => {
this.$message({
type: 'info',
message: '已取消入库'
})
})
},
// 清空
Empty() {
this.tableData = []
this.tableDataNum = []
this.Partpaint = ''
},
// 仓库查询
Getinvent() {
this.getSelect(getinventory, ['仓库名称', '仓库流水号'], 'inventoryName')
},
// 根据仓库获取货位
Getlocate() {
this.locateName = []
this.locateNumber = ''
if (this.inventoryNumber) {
this.getSelect(getlocate, ['货位名称', '货位流水号'], 'locateName', this.inventoryNumber)
}
}
}
}
</script>
<style scoped>
.el-card {
margin-bottom: 15px;
}
</style>