|
|
@@ -3,14 +3,19 @@
|
|
|
<el-form :model="form" label-width="90px" style="max-width:880px">
|
|
|
<el-form-item label="工单号"><el-input v-model="form.no" /></el-form-item>
|
|
|
<el-form-item label="产品">
|
|
|
- <el-select v-model="form.product_id" filterable placeholder="选择产品" style="width:100%" @change="onProduct">
|
|
|
+ <el-select
|
|
|
+ v-model="form.product_id"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="可不选,选择后带出名称和工序"
|
|
|
+ style="width:100%"
|
|
|
+ @change="onProduct"
|
|
|
+ >
|
|
|
<el-option v-for="item in products" :key="item.id" :label="item.name + ' / ' + item.code" :value="item.id" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="总数量"><el-input v-model="form.qty" /></el-form-item>
|
|
|
- <el-form-item label="每版数量">
|
|
|
- <el-input v-model="form.sheet_qty" placeholder="一版 = 一张流程单" />
|
|
|
- <p v-if="sheetHint" class="qty-hint">{{ sheetHint }}</p>
|
|
|
+ <el-form-item label="名称">
|
|
|
+ <el-input v-model="form.product_name" placeholder="选择产品后自动带出,不选产品则手动填写" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="批次"><el-input v-model="form.batch_no" /></el-form-item>
|
|
|
<el-form-item label="客户"><el-input v-model="form.customer" /></el-form-item>
|
|
|
@@ -30,13 +35,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { computed, onMounted, reactive, ref } from 'vue'
|
|
|
+import { onMounted, reactive, ref } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import ProcessEditor from '@/components/ProcessEditor.vue'
|
|
|
import { productInfo, productList, workorderDel, workorderInfo, workorderSave } from '@/api/ps'
|
|
|
import { openPrint } from '@/utils/print'
|
|
|
-import { sheetCountText } from '@/utils/sheet'
|
|
|
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
@@ -47,8 +51,7 @@ const form = reactive({
|
|
|
id: 0,
|
|
|
no: '',
|
|
|
product_id: '',
|
|
|
- qty: '',
|
|
|
- sheet_qty: '',
|
|
|
+ product_name: '',
|
|
|
batch_no: '',
|
|
|
customer: '',
|
|
|
plan_date: '',
|
|
|
@@ -56,7 +59,6 @@ const form = reactive({
|
|
|
status: 'draft',
|
|
|
processes: [],
|
|
|
})
|
|
|
-const sheetHint = computed(() => sheetCountText(form.qty, form.sheet_qty))
|
|
|
|
|
|
onMounted(async () => {
|
|
|
const list = await productList({ limit: 200 })
|
|
|
@@ -68,6 +70,8 @@ onMounted(async () => {
|
|
|
try {
|
|
|
const row = await workorderInfo(route.params.id)
|
|
|
Object.assign(form, row)
|
|
|
+ form.product_id = row.product_id || ''
|
|
|
+ form.product_name = row.product_name || (row.product && row.product.name) || ''
|
|
|
form.processes = row.processes || []
|
|
|
} finally {
|
|
|
loading.value = false
|
|
|
@@ -79,12 +83,7 @@ async function onProduct(id) {
|
|
|
return
|
|
|
}
|
|
|
const row = await productInfo(id)
|
|
|
- if (row.qty) {
|
|
|
- form.qty = row.qty
|
|
|
- }
|
|
|
- if (row.sheet_qty) {
|
|
|
- form.sheet_qty = row.sheet_qty
|
|
|
- }
|
|
|
+ form.product_name = row.name || ''
|
|
|
if (form.processes && form.processes.length) {
|
|
|
return
|
|
|
}
|
|
|
@@ -107,17 +106,22 @@ async function onDel() {
|
|
|
}
|
|
|
|
|
|
async function onSave() {
|
|
|
- if (!form.no) {
|
|
|
+ if (!String(form.no || '').trim()) {
|
|
|
ElMessage.warning('请填写工单号')
|
|
|
return
|
|
|
}
|
|
|
- if (!(Number(form.qty) > 0) || !(Number(form.sheet_qty) > 0)) {
|
|
|
- ElMessage.warning('请填写总数量和每版数量')
|
|
|
+ if (!form.product_id && !String(form.product_name || '').trim()) {
|
|
|
+ ElMessage.warning('请选择产品或填写名称')
|
|
|
return
|
|
|
}
|
|
|
saving.value = true
|
|
|
try {
|
|
|
- await workorderSave(form)
|
|
|
+ const { qty, sheet_qty, product, ...rest } = form
|
|
|
+ await workorderSave({
|
|
|
+ ...rest,
|
|
|
+ product_id: Number(form.product_id) || 0,
|
|
|
+ product_name: String(form.product_name || '').trim(),
|
|
|
+ })
|
|
|
ElMessage.success('已保存')
|
|
|
router.push('/workorders')
|
|
|
} finally {
|
|
|
@@ -125,7 +129,3 @@ async function onSave() {
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
-
|
|
|
-<style scoped>
|
|
|
-.qty-hint { margin: 6px 0 0; color: #7a8794; font-size: 12px; }
|
|
|
-</style>
|