This commit is contained in:
2021-12-10 17:07:29 +08:00
parent 9f3c13f893
commit f445045cc4
29 changed files with 539 additions and 868 deletions

View File

@@ -1,20 +1,32 @@
<template>
<el-dialog
:title="!dataForm.id ? '新增' : '修改'"
:title="!row ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<el-form-item label="标识卡" prop="paramKey">
<el-input v-model="dataForm.paramKey" placeholder="标识卡"></el-input>
<el-form :model="dataForm" v-loading="formLoading" :rules="dataRule" ref="dataForm" label-width="80px">
<el-form-item label="标识卡" prop="idenCardNum">
<el-input v-model="dataForm.idenCardNum" @change="setIdenCardNum" ref="idenCardNum" placeholder="标识卡"></el-input>
</el-form-item>
<el-form-item label="产品名称" prop="paramValue">
<el-input v-model="dataForm.paramValue" placeholder="产品名称"></el-input>
<el-form-item label="客户名称" prop="customerName">
<el-input v-model="dataForm.customerName" disabled placeholder="客户名称"></el-input>
</el-form-item>
<el-form-item label="数量" prop="number">
<el-input v-model="dataForm.remark" placeholder="数量"></el-input>
<el-form-item label="材料牌号" prop="materialDes">
<el-input v-model="dataForm.materialDes" disabled placeholder="材料牌号"></el-input>
</el-form-item>
<el-form-item label="重量" prop="remark">
<el-input v-model="dataForm.remark" placeholder="重量"></el-input>
<el-form-item label="订单号" prop="orderNo">
<el-input v-model="dataForm.orderNo" disabled placeholder="订单号"></el-input>
</el-form-item>
<el-form-item label="产品名称" prop="productName">
<el-input v-model="dataForm.productName" disabled placeholder="产品名称"></el-input>
</el-form-item>
<el-form-item label="数量" prop="quantity">
<el-input v-model="dataForm.quantity" placeholder="数量"></el-input>
</el-form-item>
<el-form-item label="单位" prop="unit">
<el-input v-model="dataForm.unit" disabled placeholder="单位"></el-input>
</el-form-item>
<el-form-item label="重量" prop="weight">
<el-input v-model="dataForm.weight" placeholder="重量"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
@@ -30,68 +42,93 @@
return {
visible: false,
dataForm: {
id: 0,
paramKey: '',
paramValue: '',
remark: ''
idenCardNum: null,
customerName: null,
materialDes: null,
orderNo: null,
productName: null,
quantity: null,
unit: null,
weight: null
},
dataRule: {
paramKey: [
{ required: true, message: '参数名不能为空', trigger: 'blur' }
idenCardNum: [
{ required: true, message: '标识卡号不能为空', trigger: 'blur' }
],
paramValue: [
{ required: true, message: '参数值不能为空', trigger: 'blur' }
quantity: [
{ required: true, message: '数量不能为空', trigger: 'blur' }
],
weight: [
{ required: true, message: '重量不能为空', trigger: 'blur' }
]
}
},
formLoading: false,
row: null,
editIndex: null
}
},
methods: {
init (id) {
this.dataForm.id = id || 0
init (row, idx) {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/sys/config/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.paramKey = data.config.paramKey
this.dataForm.paramValue = data.config.paramValue
this.dataForm.remark = data.config.remark
}
})
if (row) {
this.row = row
this.dataForm = row
this.editIndex = idx
}
this.$refs['idenCardNum'].focus()
})
},
setIdenCardNum () {
this.formLoading = true
if (this.dataForm.idenCardNum) {
this.$http({
url: this.$http.adornUrl(`/orderInfo/getTaskInfoByIdenCardNum`),
method: 'get',
params: this.$http.adornParams({
'idenCardNum': this.dataForm.idenCardNum
})
}).then(({data}) => {
console.log(data)
if (data && data.code === 0) {
this.dataForm = data.data
this.dataForm.targetQuantity = data.data.quantity
this.dataForm.targetWeight = data.data.weight
this.dataForm.weight = null
this.dataForm.quantity = null
} else {
this.$message.warning(data.msg)
}
this.formLoading = false
})
} else {
this.$message.warning('请输入标识卡号')
}
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/sys/config/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'paramKey': this.dataForm.paramKey,
'paramValue': this.dataForm.paramValue,
'remark': this.dataForm.remark
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
if (this.editIndex) {
const taskList = JSON.parse(sessionStorage.getItem('taskList'))
taskList.splice(this.editIndex, 1, this.dataForm)
sessionStorage.setItem('taskList', JSON.stringify(taskList))
} else if (sessionStorage.getItem('taskList')) {
const taskList = JSON.parse(sessionStorage.getItem('taskList'))
taskList.push(this.dataForm)
sessionStorage.setItem('taskList', JSON.stringify(taskList))
} else {
const arr = [this.dataForm]
sessionStorage.setItem('taskList', JSON.stringify(arr))
}
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
}