|
|
@@ -1,29 +1,105 @@ |
|
|
|
<!-- |
|
|
|
* @Author: zhp |
|
|
|
* @Date: 2024-08-01 16:27:30 |
|
|
|
* @LastEditTime: 2024-08-01 16:29:31 |
|
|
|
* @LastEditTime: 2024-08-02 15:27:58 |
|
|
|
* @LastEditors: zhp |
|
|
|
* @Description: |
|
|
|
--> |
|
|
|
<template> |
|
|
|
<el-form ref="orderAddForm" :rules="rules" label-width="130px" :model="form" label-position='top'> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-col :span='6'> |
|
|
|
<el-form-item label="订单名称" prop="name"> |
|
|
|
<el-input v-model="form.name"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
<el-form ref="orderAddForm" :rules="rules" :model="form" :inline="true" class="demo-form-inline"> |
|
|
|
<!-- <el-row :gutter="20"> --> |
|
|
|
<!-- <el-col :span='6'> --> |
|
|
|
<el-form-item label="拆分数量" prop="attr3"> |
|
|
|
<el-input v-model.number="form.attr3" oninput="value=value.replace(/[^\d]/g,'')"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-button type="primary" @click="handleSplit">确定</el-button> |
|
|
|
</el-form-item> |
|
|
|
<!-- </el-col> --> |
|
|
|
<!-- </el-row> --> |
|
|
|
<base-table @emitFun="inputChange" :table-props="tableProps" :table-data="list" :max-height="tableH"> |
|
|
|
<!-- <method-btn v-if="tableBtn.length" slot="handleBtn" :width="240" label="操作" :method-list="tableBtn" |
|
|
|
@clickBtn="handleClick" /> --> |
|
|
|
</base-table> |
|
|
|
</el-form> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import { getOrderCode, getOrderById, getProcessFlowList, orderUpdate, orderCreate } from '@/api/base/orderManage' |
|
|
|
import { getOrderCode, getOrderById, getProcessFlowList, orderUpdate, orderCreate, orderSplit } from '@/api/base/orderManage' |
|
|
|
import { getProductAll } from '@/api/base/product' |
|
|
|
import { getCustomerList } from '@/api/base/customer' |
|
|
|
import { parseTime } from '@/utils/ruoyi' |
|
|
|
// import { publicFormatter } from '@/utils/dict' |
|
|
|
import inputArea from './inputArea.vue' |
|
|
|
const tableProps = [ |
|
|
|
{ |
|
|
|
prop: 'name', |
|
|
|
label: '订单名称', |
|
|
|
minWidth: 120, |
|
|
|
showOverflowtooltip: true, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
{ |
|
|
|
prop: 'code', |
|
|
|
label: '订单编码', |
|
|
|
minWidth: 180, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
{ |
|
|
|
prop: 'productName', |
|
|
|
label: '产品', |
|
|
|
showOverflowtooltip: true, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
// { |
|
|
|
// prop: 'priority', |
|
|
|
// label: '优先级', |
|
|
|
// filter: publicFormatter('order_priority') |
|
|
|
// }, |
|
|
|
{ |
|
|
|
prop: 'planQuantity', |
|
|
|
label: '计划加工量', |
|
|
|
width: 100, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
{ |
|
|
|
prop: 'deliveTime', |
|
|
|
label: '交货日期', |
|
|
|
filter: parseTime, |
|
|
|
minWidth: 160, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
{ |
|
|
|
prop: 'customerId', |
|
|
|
label: '客户', |
|
|
|
showOverflowtooltip: true, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
{ |
|
|
|
prop: 'price', |
|
|
|
label: '单价', |
|
|
|
width: 100, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
{ |
|
|
|
prop: 'packSpec', |
|
|
|
label: '包装规格', |
|
|
|
width: 100, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
{ |
|
|
|
prop: 'remark', |
|
|
|
label: '备注', |
|
|
|
width: 100, |
|
|
|
subcomponent: inputArea |
|
|
|
}, |
|
|
|
] |
|
|
|
export default { |
|
|
|
name: 'OrderAdd', |
|
|
|
data() { |
|
|
|
return { |
|
|
|
tableProps, |
|
|
|
list: [], |
|
|
|
tableH: this.tableHeight(260), |
|
|
|
form: { |
|
|
|
id: '', |
|
|
|
name: '', |
|
|
@@ -32,6 +108,7 @@ export default { |
|
|
|
planProductId: '', |
|
|
|
price: '', |
|
|
|
customerId: '', |
|
|
|
attr3:undefined, |
|
|
|
priority: '', |
|
|
|
packSpec: '', |
|
|
|
workers: '', |
|
|
@@ -42,10 +119,7 @@ export default { |
|
|
|
planStartTime: '', |
|
|
|
}, |
|
|
|
rules: { |
|
|
|
name: [{ required: true, message: "订单名称不能为空", trigger: "blur" }], |
|
|
|
code: [{ required: true, message: "订单号不能为空", trigger: "blur" }], |
|
|
|
planQuantity: [{ required: true, message: "计划加工数量不能为空", trigger: "blur" }], |
|
|
|
planProductId: [{ required: true, message: "产品名称不能为空", trigger: "change" }] |
|
|
|
attr3: [{ required: true, message: "拆分数量不能为空", trigger: "blur" }], |
|
|
|
}, |
|
|
|
productList: [], |
|
|
|
customerList: [], |
|
|
@@ -53,12 +127,26 @@ export default { |
|
|
|
isEdit: false //是否是编辑 |
|
|
|
} |
|
|
|
}, |
|
|
|
created () { |
|
|
|
window.addEventListener('resize', () => { |
|
|
|
this.tableH = this.tableHeight(260) |
|
|
|
}) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
init(id) { |
|
|
|
this.getList() |
|
|
|
if (id) { |
|
|
|
handleSplit() { |
|
|
|
let obj = { |
|
|
|
attr3: this.form.attr3, |
|
|
|
id:this.form.id |
|
|
|
} |
|
|
|
orderSplit(obj).then((res) => { |
|
|
|
this.list = res.data |
|
|
|
}) |
|
|
|
}, |
|
|
|
init(obj) { |
|
|
|
// this.getList() |
|
|
|
if (obj) { |
|
|
|
this.isEdit = true |
|
|
|
this.form.id = id |
|
|
|
this.form.id = obj.id |
|
|
|
getOrderById({id: this.form.id}).then(res => { |
|
|
|
if (res.code === 0) { |
|
|
|
this.form.name = res.data.name |
|
|
@@ -87,73 +175,80 @@ export default { |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
getList() { |
|
|
|
// 产品 |
|
|
|
getProductAll().then(res => { |
|
|
|
this.productList = res.data || [] |
|
|
|
}) |
|
|
|
// 客户 |
|
|
|
getCustomerList().then(res => { |
|
|
|
this.customerList = res.data || [] |
|
|
|
}) |
|
|
|
// 工艺 |
|
|
|
getProcessFlowList().then(res => { |
|
|
|
this.processFlowList = res.data || [] |
|
|
|
}) |
|
|
|
}, |
|
|
|
timeChange() { |
|
|
|
if (this.form.planStartTime && this.form.planFinishTime) { |
|
|
|
if (this.form.planStartTime > this.form.planFinishTime) { |
|
|
|
this.$modal.msgError('计划开始时间不能大于结束时间') |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
// 工艺变更 |
|
|
|
materialMethodChange(val) { |
|
|
|
if (val === 2 && !this.form.processFlowId) { |
|
|
|
this.form.materialMethod = 1 |
|
|
|
this.$modal.msgError("请先选择关联工艺"); |
|
|
|
} |
|
|
|
}, |
|
|
|
// 工艺变更 |
|
|
|
processFlowIdChange(val) { |
|
|
|
console.log(val) |
|
|
|
if (!val) { |
|
|
|
this.form.materialMethod = 1 |
|
|
|
} |
|
|
|
}, |
|
|
|
// getList() { |
|
|
|
// // 产品 |
|
|
|
// getProductAll().then(res => { |
|
|
|
// this.productList = res.data || [] |
|
|
|
// }) |
|
|
|
// // 客户 |
|
|
|
// getCustomerList().then(res => { |
|
|
|
// this.customerList = res.data || [] |
|
|
|
// }) |
|
|
|
// // 工艺 |
|
|
|
// getProcessFlowList().then(res => { |
|
|
|
// this.processFlowList = res.data || [] |
|
|
|
// }) |
|
|
|
// }, |
|
|
|
// timeChange() { |
|
|
|
// if (this.form.planStartTime && this.form.planFinishTime) { |
|
|
|
// if (this.form.planStartTime > this.form.planFinishTime) { |
|
|
|
// this.$modal.msgError('计划开始时间不能大于结束时间') |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// // 工艺变更 |
|
|
|
// materialMethodChange(val) { |
|
|
|
// if (val === 2 && !this.form.processFlowId) { |
|
|
|
// this.form.materialMethod = 1 |
|
|
|
// this.$modal.msgError("请先选择关联工艺"); |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// // 工艺变更 |
|
|
|
// processFlowIdChange(val) { |
|
|
|
// console.log(val) |
|
|
|
// if (!val) { |
|
|
|
// this.form.materialMethod = 1 |
|
|
|
// } |
|
|
|
// }, |
|
|
|
submitForm() { |
|
|
|
this.$refs['orderAddForm'].validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
if (this.form.planStartTime && this.form.planFinishTime) { |
|
|
|
if (this.form.planStartTime > this.form.planFinishTime) { |
|
|
|
this.$modal.msgError('计划开始时间不能大于结束时间') |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log(this.form) |
|
|
|
if (this.isEdit) { |
|
|
|
//编辑 |
|
|
|
orderUpdate({ ...this.form }).then((res) => { |
|
|
|
if (res.code === 0) { |
|
|
|
this.$modal.msgSuccess("操作成功"); |
|
|
|
this.$emit('successSubmit') |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.form.status = 1 |
|
|
|
this.form.triggerOrigin = 1 |
|
|
|
orderCreate({ ...this.form }).then((res) => { |
|
|
|
if (res.code === 0) { |
|
|
|
this.$modal.msgSuccess("操作成功"); |
|
|
|
this.$emit('successSubmit') |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
Promise.all(this.list.forEach((ele) => { |
|
|
|
orderCreate(ele) |
|
|
|
})).then((res) => { |
|
|
|
this.$modal.msgSuccess("操作成功"); |
|
|
|
this.$emit('successSubmit') |
|
|
|
}) |
|
|
|
|
|
|
|
// this.$refs['orderAddForm'].validate((valid) => { |
|
|
|
// if (valid) { |
|
|
|
// if (this.form.planStartTime && this.form.planFinishTime) { |
|
|
|
// if (this.form.planStartTime > this.form.planFinishTime) { |
|
|
|
// this.$modal.msgError('计划开始时间不能大于结束时间') |
|
|
|
// return false |
|
|
|
// } |
|
|
|
// } |
|
|
|
// // console.log(this.form) |
|
|
|
// if (this.isEdit) { |
|
|
|
// //编辑 |
|
|
|
// orderUpdate({ ...this.form }).then((res) => { |
|
|
|
// if (res.code === 0) { |
|
|
|
// this.$modal.msgSuccess("操作成功"); |
|
|
|
// this.$emit('successSubmit') |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } else { |
|
|
|
// this.form.status = 1 |
|
|
|
// this.form.triggerOrigin = 1 |
|
|
|
// orderCreate({ ...this.form }).then((res) => { |
|
|
|
// if (res.code === 0) { |
|
|
|
// this.$modal.msgSuccess("操作成功"); |
|
|
|
// this.$emit('successSubmit') |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// return false |
|
|
|
// } |
|
|
|
// }) |
|
|
|
}, |
|
|
|
formClear() { |
|
|
|
this.$refs.orderAddForm.resetFields() |
|
|
|