<template>
|
<el-dialog
|
width="40%"
|
title="投料"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
>
|
<div class="app-container">
|
<div class="avue-crud">
|
<el-table
|
ref="table"
|
v-loading="listLoading"
|
:key="tableKey"
|
:data="dataList"
|
border
|
style="width: 100%;"
|
@cell-dblclick="dblhandleCurrentChange"
|
show-summary
|
:span-method="objectSpanMethod"
|
:summary-method="getSummaries"
|
>
|
<el-table-column
|
prop="partNo"
|
header-align="center"
|
align="center"
|
label="零件编号"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partName"
|
header-align="center"
|
align="center"
|
label="零件"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partBatchNo"
|
header-align="center"
|
align="center"
|
label="零件批号"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="specs"
|
header-align="center"
|
align="center"
|
label="规格型号"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="suppliedQuantity"
|
header-align="center"
|
align="center"
|
label="投入数量"
|
>
|
<template scope="scope">
|
<el-input
|
size="small"
|
v-model="scope.row.suppliedQuantity"
|
placeholder="请输入数量"
|
@blur="inputblur"
|
v-focus
|
clearable
|
></el-input>
|
<!--<span v-if="!scope.row.suppliedQuantityFlag">{{scope.row.suppliedQuantity}}</span>-->
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="unit"
|
header-align="center"
|
align="center"
|
label="单位"
|
>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button type="primary" :disabled="isSubmit" v-thinclick="`pullFeed`"
|
>投 料</el-button
|
>
|
</div>
|
<el-dialog
|
width="40%"
|
title="投料密码框"
|
top="15vh"
|
:visible.sync="onnerVisible"
|
append-to-body
|
:close-on-click-modal="false"
|
class="part-dialog"
|
>
|
<div style="margin-bottom:10px;">
|
<span style="color:red;"> {{ messages }},请确认! </span>
|
</div>
|
<div style="display:flex;">
|
<div style="width:50px;line-height:32px;"><span>密码:</span></div>
|
<div>
|
<el-input
|
v-model="password"
|
placeholder="请输入密码"
|
show-password
|
></el-input>
|
</div>
|
</div>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="onnerVisible = false">取 消</el-button>
|
<el-button type="primary" @click="confirmData">确定</el-button>
|
</div>
|
</el-dialog>
|
</el-dialog>
|
</template>
|
<script>
|
import { addFeed, checkSubmitPassword } from '@/api/product/personboard'
|
import { getCheckRawPart } from '@/api/product/checkRawPart'
|
export default {
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
dataList: {
|
type: Array
|
},
|
workstationId: {
|
type: Number
|
},
|
operationTaskId: {
|
type: Number
|
}
|
},
|
data() {
|
return {
|
messages: '',
|
innerVisible: false,
|
listLoading: false,
|
tableKey: 0,
|
isSubmit: false,
|
onnerVisible: false,
|
password: null
|
}
|
},
|
directives: {
|
focus: {
|
inserted: function(el, option) {
|
var defClass = 'el-input'
|
var defTag = 'input'
|
var value = option.value || true
|
if (typeof value === 'boolean')
|
value = { cls: defClass, tag: defTag, foc: value }
|
else
|
value = {
|
cls: value.cls || defClass,
|
tag: value.tag || defTag,
|
foc: value.foc || false
|
}
|
// if (el.classList.contains(value.cls) && value.foc)
|
el.getElementsByTagName(value.tag)[0].focus()
|
}
|
}
|
},
|
methods: {
|
confirmData() {
|
if (this.password != null) {
|
checkSubmitPassword({ password: this.password }).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
if (resData.data) {
|
this.onnerVisible = false
|
// 密码校验成功 直接投料
|
this.saveFeed()
|
} else {
|
this.$message.error('密码错误')
|
}
|
}
|
})
|
} else {
|
this.$message.error('请输入密码')
|
}
|
},
|
dblhandleCurrentChange(row, column, cell, event) {
|
switch (column.label) {
|
case '投入数量':
|
this.$set(row, 'suppliedQuantityFlag', true)
|
break
|
}
|
},
|
inputblur(row, event, column, cell) {
|
var _this = this
|
const tableD = _this.dataList
|
tableD.forEach(function(item) {
|
_this.$set(item, 'suppliedQuantityFlag', false)
|
})
|
},
|
pullFeed() {
|
var partNoList = []
|
var partNoLists
|
console.log('this.dataList', this.dataList)
|
for (var i = 0; i < this.dataList.length; i++) {
|
partNoLists = this.dataList[i].partNo
|
partNoList.push(partNoLists)
|
}
|
getCheckRawPart(partNoList).then((response) => {
|
console.log(response)
|
if (response.data.code === 0) {
|
// 需要密码确认情况
|
if (response.data.data.success === false) {
|
this.messages = response.data.data.message
|
this.onnerVisible = true
|
} else {
|
// 不需要密码 直接投料
|
this.saveFeed()
|
}
|
}
|
})
|
},
|
saveFeed() {
|
this.isSubmit = true
|
// 调用投料接口,然后刷新线边仓、投料列表
|
var feeds = []
|
var feed
|
for (var i = 0; i < this.dataList.length; i++) {
|
if (!this.dataList[i].suppliedQuantity) {
|
this.isSubmit = false
|
this.$message.error('第' + (i + 1) + '投入数量不能为空')
|
return
|
}
|
if (!this.checkDecimal(this.dataList[i].suppliedQuantity)) {
|
this.isSubmit = false
|
this.$message.error(
|
'第' + (i + 1) + '数据格式有误,数据大于0且最多保留6位小数'
|
)
|
return
|
}
|
feed = {
|
workstationId: this.workstationId,
|
stockId: this.dataList[i].id,
|
joinStockOrderId: null,
|
suppliedQuantity: this.dataList[i].suppliedQuantity,
|
partId: this.dataList[i].partId,
|
partBatchNo: this.dataList[i].partBatchNo,
|
systemNo: this.dataList[i].systemNo,
|
partName: this.dataList[i].partName,
|
unit: this.dataList[i].unit ? this.dataList[i].unit : ''
|
}
|
feeds.push(feed)
|
}
|
const feedIn = {
|
feeds: feeds,
|
feedingFrom: 'stocker',
|
operationTaskId: this.operationTaskId
|
}
|
if (feeds.length > 0) {
|
addFeed(feedIn)
|
.then((response) => {
|
var data = response.data
|
if (data.code === 0) {
|
this.$message.success('投料成功')
|
} else {
|
this.$message.error('投料失败')
|
}
|
// 刷新线边仓、投料列表
|
this.$emit('refreshFeedList')
|
this.isSubmit = false
|
this.innerVisible = false
|
})
|
.catch(() => {
|
this.isSubmit = false
|
})
|
} else {
|
this.isSubmit = false
|
}
|
},
|
// 大于0且最多保留6位小数
|
checkDecimal(value) {
|
const reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,6})?$/
|
return reg.test(value)
|
},
|
objectSpanMethod() {
|
setTimeout(() => {
|
if (this.$refs.table.$el) {
|
const current = this.$refs.table.$el
|
.querySelector('.el-table__footer-wrapper')
|
.querySelector('.el-table__footer')
|
const cell = current.rows[0].cells
|
// cell[1].style.display = 'none'
|
cell[0].colSpan = '4'
|
}
|
}, 50)
|
},
|
getSummaries(param) {
|
const { columns, data } = param
|
const sums = ['', '', '']
|
columns.forEach((column, index) => {
|
if (column.property === 'partNo') {
|
const values = data.map((item) => item[column.property])
|
sums[0] = values.join(';')
|
} else if (column.property === 'suppliedQuantity') {
|
const values = data.map((item) => Number(item[column.property]))
|
if (!values.every((value) => isNaN(value))) {
|
sums[1] = values.reduce((prev, curr) => {
|
const value = Number(curr)
|
if (!isNaN(value)) {
|
return Number((prev + curr).toFixed(6))
|
} else {
|
return prev
|
}
|
}, 0)
|
} else {
|
sums[1] = ''
|
}
|
}
|
})
|
return sums
|
}
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
this.password = null
|
if (this.currshowlist) {
|
this.$nextTick(() => {})
|
}
|
}
|
},
|
mounted() {}
|
}
|
</script>
|