|
|
<template>
|
|
|
<el-form
|
|
|
ref="formRef"
|
|
|
:model="formData"
|
|
|
:rules="formRules"
|
|
|
v-loading="formLoading"
|
|
|
label-width="0px"
|
|
|
:inline-message="true"
|
|
|
>
|
|
|
<el-table :data="formData" class="-mt-10px">
|
|
|
<el-table-column label="序号" type="index" width="100" />
|
|
|
<el-table-column label="产品" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.productId`" :rules="formRules.productId" class="mb-0px!">
|
|
|
<el-select
|
|
|
v-model="row.productId"
|
|
|
clearable
|
|
|
filterable
|
|
|
placeholder="请选择"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in productList"
|
|
|
:key="item.id"
|
|
|
:label="item.name"
|
|
|
:value="item.id"
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="单位" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.unitId`" :rules="formRules.unitId" class="mb-0px!">
|
|
|
<el-select v-model="row.unitId" clearable filterable placeholder="请选择单位" class="w-1/1">
|
|
|
<el-option
|
|
|
v-for="unit in unitList"
|
|
|
:key="unit.id"
|
|
|
:label="unit.name"
|
|
|
:value="unit.id"
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="数量" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.number`" :rules="formRules.number" class="mb-0px!">
|
|
|
<el-input v-model="row.number" placeholder="请输入数量" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="打包要求(每包/个)" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.packageSize`" :rules="formRules.packageSize" class="mb-0px!">
|
|
|
<el-input v-model="row.packageSize" placeholder="请输入打包要求(每包/个)" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="项目名称" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.projectName`" :rules="formRules.projectName" class="mb-0px!">
|
|
|
<el-input v-model="row.projectName" placeholder="请输入项目名称" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="技术要求" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.techRequirements`" :rules="formRules.techRequirements" class="mb-0px!">
|
|
|
<el-input v-model="row.techRequirements" placeholder="请输入技术要求" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="备注" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.remark`" :rules="formRules.remark" class="mb-0px!">
|
|
|
<el-input v-model="row.remark" placeholder="请输入备注" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="打包数量" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.packageNumber`" :rules="formRules.packageNumber" class="mb-0px!">
|
|
|
<el-input v-model="row.packageNumber" placeholder="请输入打包数量" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="工厂完成" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.finishDate`" :rules="formRules.finishDate" class="mb-0px!">
|
|
|
<el-date-picker
|
|
|
v-model="row.finishDate"
|
|
|
type="date"
|
|
|
value-format="x"
|
|
|
placeholder="选择工厂完成"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="装柜时间" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.boxingDate`" :rules="formRules.boxingDate" class="mb-0px!">
|
|
|
<el-date-picker
|
|
|
v-model="row.boxingDate"
|
|
|
type="date"
|
|
|
value-format="x"
|
|
|
placeholder="选择装柜时间"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="到达时间" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.arriveDate`" :rules="formRules.arriveDate" class="mb-0px!">
|
|
|
<el-date-picker
|
|
|
v-model="row.arriveDate"
|
|
|
type="date"
|
|
|
value-format="x"
|
|
|
placeholder="选择到达时间"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="条码" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.barCode`" :rules="formRules.barCode" class="mb-0px!">
|
|
|
<el-input v-model="row.barCode" placeholder="请输入条码" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="附件" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item :prop="`${$index}.attachment`" :rules="formRules.attachment" class="mb-0px!">
|
|
|
<UploadFile v-model="row.attachment" :is-show-tip = "false" :limit = "1"/>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column align="center" fixed="right" label="操作" width="60">
|
|
|
<template #default="{ $index }">
|
|
|
<el-button @click="handleDelete($index)" link>—</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-form>
|
|
|
<el-row justify="center" class="mt-3">
|
|
|
<el-button @click="handleAdd" round>+ 添加任务单明细</el-button>
|
|
|
<el-button @click="openOrderItemsList" round>+ 从销售单添加</el-button>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<SaleOrderItemsList ref="orderItemsRef" />
|
|
|
</el-row>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
import { TaskApi } from '@/api/mes/task'
|
|
|
import { ProductUnitApi, ProductUnitVO } from '@/api/erp/product/unit'
|
|
|
import {ProductApi, ProductVO} from "@/api/erp/product/product";
|
|
|
import SaleOrderItemsList from './SaleOrderItemsList.vue'
|
|
|
|
|
|
const unitList = ref<ProductUnitVO[]>([]) // 产品单位列表
|
|
|
const productList = ref<ProductVO[]>([]) // 产品列表
|
|
|
|
|
|
const props = defineProps<{
|
|
|
taskId: undefined // task ID(主表的关联字段)
|
|
|
}>()
|
|
|
const formLoading = ref(false) // 表单的加载中
|
|
|
const formData = ref([])
|
|
|
const formRules = reactive({
|
|
|
productId: [{ required: true, message: '产品ID不能为空', trigger: 'blur' }],
|
|
|
unitId: [{ required: true, message: '单位ID不能为空', trigger: 'blur' }],
|
|
|
taskId: [{ required: true, message: 'task ID不能为空', trigger: 'blur' }],
|
|
|
number: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
|
|
|
packageSize: [{ required: true, message: '打包要求(每包/个)不能为空', trigger: 'blur' }],
|
|
|
isEnable: [{ required: true, message: '是否启用不能为空', trigger: 'blur' }],
|
|
|
})
|
|
|
const formRef = ref() // 表单 Ref
|
|
|
|
|
|
/** 添加/修改操作 */
|
|
|
const orderItemsRef = ref()
|
|
|
const openOrderItemsList = () => {
|
|
|
console.log("---openOrderItemsList--------")
|
|
|
orderItemsRef.value.open()
|
|
|
}
|
|
|
|
|
|
/** 初始化 */
|
|
|
onMounted(async () => {
|
|
|
// 产品单位
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
productList.value = await ProductApi.getProductSimpleList()
|
|
|
// 默认添加一个
|
|
|
if (formData.value.length === 0) {
|
|
|
handleAdd()
|
|
|
}
|
|
|
})
|
|
|
|
|
|
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
|
|
watch(
|
|
|
() => props.taskId,
|
|
|
async (val) => {
|
|
|
// 1. 重置表单
|
|
|
formData.value = []
|
|
|
// 2. val 非空,则加载数据
|
|
|
if (!val) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
formLoading.value = true
|
|
|
formData.value = await TaskApi.getTaskDetailListByTaskId(val)
|
|
|
} finally {
|
|
|
formLoading.value = false
|
|
|
}
|
|
|
},
|
|
|
{ immediate: true }
|
|
|
)
|
|
|
|
|
|
/** 新增按钮操作 */
|
|
|
const handleAdd = () => {
|
|
|
const row = {
|
|
|
id: undefined,
|
|
|
productId: undefined,
|
|
|
unitId: undefined,
|
|
|
taskId: undefined,
|
|
|
number: undefined,
|
|
|
packageSize: undefined,
|
|
|
projectName: undefined,
|
|
|
techRequirements: undefined,
|
|
|
remark: undefined,
|
|
|
isEnable: undefined,
|
|
|
packageNumber: undefined,
|
|
|
finishDate: undefined,
|
|
|
boxingDate: undefined,
|
|
|
arriveDate: undefined,
|
|
|
barCode: undefined,
|
|
|
attachment: undefined,
|
|
|
}
|
|
|
row.taskId = props.taskId
|
|
|
formData.value.push(row)
|
|
|
}
|
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
const handleDelete = (index) => {
|
|
|
formData.value.splice(index, 1)
|
|
|
}
|
|
|
|
|
|
/** 表单校验 */
|
|
|
const validate = () => {
|
|
|
return formRef.value.validate()
|
|
|
}
|
|
|
|
|
|
/** 表单值 */
|
|
|
const getData = () => {
|
|
|
return formData.value
|
|
|
}
|
|
|
|
|
|
defineExpose({ validate, getData })
|
|
|
</script>
|