mt-qj-wms-ui/src/views/common/order-process-add.vue
2021-12-10 17:07:29 +08:00

140 lines
4.9 KiB
Vue

<template>
<el-dialog
:title="!row ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<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="customerName">
<el-input v-model="dataForm.customerName" disabled placeholder="客户名称"></el-input>
</el-form-item>
<el-form-item label="材料牌号" prop="materialDes">
<el-input v-model="dataForm.materialDes" disabled placeholder="材料牌号"></el-input>
</el-form-item>
<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">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
idenCardNum: null,
customerName: null,
materialDes: null,
orderNo: null,
productName: null,
quantity: null,
unit: null,
weight: null
},
dataRule: {
idenCardNum: [
{ 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 (row, idx) {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
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) {
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')
}
})
}
})
}
}
}
</script>