| <script setup>  | 
| import { ref, nextTick, watch } from 'vue';  | 
| import { get, post, postBlob, postForm } from '@/utils/request.js'  | 
| import { formatMessage } from '@/utils/localeUtils.js';  | 
| import { message } from 'ant-design-vue';  | 
|   | 
| const formTable = ref(null);  | 
| const submitButton = ref(null);  | 
| const isSave = ref(true);  | 
| const open = ref(false);  | 
| const initFormData = {}  | 
| let formData = ref(initFormData);  | 
|   | 
| let minAnfme = ref(0);  | 
| let maxAnfme = ref(999);  | 
|   | 
| const emit = defineEmits(['tableReload'])  | 
|   | 
| const handleOk = (e) => {  | 
|     nextTick(() => {  | 
|         setTimeout(() => {  | 
|             submitButton.value.$el.click();  | 
|         }, 100);  | 
|     });  | 
| };  | 
|   | 
| const onFinish = values => {  | 
|     // console.log('Success:', values);  | 
|     open.value = false;  | 
|     post(isSave.value ? '/api/waitPakin/save' : '/api/waitPakin/update', formData.value).then((resp) => {  | 
|         let result = resp.data;  | 
|         if (result.code === 200) {  | 
|             message.success(isSave.value ? formatMessage('page.add.success', '新增成功') : formatMessage('page.update.success', '更新成功'));  | 
|             emit('tableReload', 'reload')  | 
|         } else {  | 
|             message.error(result.msg);  | 
|         }  | 
|         nextTick(() => {  | 
|             formTable.value.resetFields()  | 
|         })  | 
|     })  | 
| };  | 
| const onFinishFailed = errorInfo => {  | 
|     console.log('Failed:', errorInfo);  | 
| };  | 
|   | 
| const orderQueryList = ref(null);  | 
| orderQuery(null);  | 
| function orderQuery(condition) {  | 
|     postForm('/api/order/query', {  | 
|         condition: condition  | 
|     }).then(resp => {  | 
|         let result = resp.data;  | 
|         orderQueryList.value = result.data;  | 
|     })  | 
| }  | 
| const orderDetlQueryList = ref(null);  | 
| async function orderDetlQuery(orderId) {  | 
|     let resp = await get('/api/orderDetl/orderId/' + orderId, {});  | 
|     let result = resp.data;  | 
|     return result;  | 
| }  | 
|   | 
| const userQueryList = ref(null);  | 
| userQuery();  | 
| function userQuery() {  | 
|     postForm('/api/user/query', {}).then(resp => {  | 
|         let result = resp.data;  | 
|         userQueryList.value = result.data;  | 
|     })  | 
| }  | 
|   | 
| const zpalletBarcodeQueryList = ref([]);  | 
| zpalletBarcodeQuery("");  | 
| function zpalletBarcodeQuery(condition) {  | 
|     postForm('/api/zpalletBarcode/query', {  | 
|         condition: condition  | 
|     }).then(resp => {  | 
|         let result = resp.data;  | 
|         let tmp = []  | 
|         result.data.forEach((item) => {  | 
|             tmp.push({  | 
|                 value: item.label  | 
|             })  | 
|         })  | 
|         zpalletBarcodeQueryList.value = tmp;  | 
|     })  | 
| }  | 
| const zpalletBarcodeSearch = (e) => {  | 
|     zpalletBarcodeQuery(e)  | 
| }  | 
|   | 
| const handleSearchChange = (e) => {  | 
|     orderQuery(e);  | 
| }  | 
|   | 
| const handleSelectChange = async (id) => {  | 
|     orderQueryList.value.forEach((item) => {  | 
|         if (item.value == id) {  | 
|             formData.value.orderNo = item.label;  | 
|         }  | 
|     })  | 
|   | 
|     let result = await orderDetlQuery(id);  | 
|     let tmp = []  | 
|     result.data.forEach((item) => {  | 
|         let count = item.anfme - item.qty - item.workQty - item.waitQty;  | 
|         tmp.push({  | 
|             value: item.id,  | 
|             label: item.mat$.matnr + '-' + count,  | 
|             anfme: count  | 
|         })  | 
|     })  | 
|     orderDetlQueryList.value = tmp;  | 
| }  | 
|   | 
| const handleDetlSelectChange = (id) => {  | 
|     orderDetlQueryList.value.forEach((item) => {  | 
|         if (item.value == id) {  | 
|             maxAnfme.value = item.anfme;  | 
|         }  | 
|     })  | 
| }  | 
|   | 
| watch(formData, (newVal, oldVal) => {  | 
|     if (formData.value.orderId != null) {  | 
|         handleSelectChange(formData.value.orderId);  | 
|     }  | 
| })  | 
|   | 
| defineExpose({  | 
|     open,  | 
|     formData,  | 
|     initFormData,  | 
|     isSave,  | 
| })  | 
|   | 
| </script>  | 
|   | 
| <script>  | 
| export default {  | 
|     name: '组托通知档-edit'  | 
| }  | 
| </script>  | 
|   | 
| <template>  | 
|     <div>  | 
|         <a-modal v-model:open="open"  | 
|             :title="isSave ? formatMessage('page.add', '添加') : formatMessage('page.edit', '编辑')" @ok="handleOk"  | 
|             style="width: 600px;">  | 
|             <a-form :model="formData" ref="formTable" name="formTable" :label-col="{ span: 8 }"  | 
|                 :wrapper-col="{ span: 16 }" style="display: flex;justify-content: space-between;flex-wrap: wrap;"  | 
|                 autocomplete="off" @finish="onFinish" @finishFailed="onFinishFailed">  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.order_id', '订单')" name="orderId"  | 
|                     style="width: 250px;">  | 
|                     <a-select v-model:value="formData.orderId" :placeholder="formatMessage('common.select', '请选择')"  | 
|                         style="width: 100%" show-search :options="orderQueryList" optionFilterProp="label"  | 
|                         optionLabelProp="label" @change="handleSelectChange" @search="handleSearchChange">  | 
|                     </a-select>  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.order_no', '订单编号')" name="orderNo"  | 
|                     style="width: 250px;">  | 
|                     <a-input v-model:value="formData.orderNo" />  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.anfme', '组托数量')" name="anfme"  | 
|                     style="width: 250px;">  | 
|                     <a-input-number v-model:value="formData.anfme" :min="minAnfme" :max="maxAnfme"  | 
|                         style="width: 100%;" />  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.barcode', '托盘码')" name="barcode"  | 
|                     style="width: 250px;">  | 
|                     <a-auto-complete v-model:value="formData.barcode" :options="zpalletBarcodeQueryList"  | 
|                         @search="zpalletBarcodeSearch" />  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.detl_id', '订单明细')" name="detlId"  | 
|                     style="width: 250px;">  | 
|                     <a-select v-model:value="formData.detlId" :placeholder="formatMessage('common.select', '请选择')"  | 
|                         style="width: 100%" show-search :options="orderDetlQueryList" optionFilterProp="label"  | 
|                         optionLabelProp="label" @change="handleDetlSelectChange">  | 
|                     </a-select>  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.io_status', '组托状态')" name="status"  | 
|                     style="width: 250px;">  | 
|                     <a-select v-model:value="formData.ioStatus" :options="[  | 
|                         { label: '待入库', value: 0 },  | 
|                         { label: '入库中', value: 1 },  | 
|                     ]">  | 
|                     </a-select>  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.status', '状态')" name="status"  | 
|                     style="width: 250px;">  | 
|                     <a-select v-model:value="formData.status" :options="[  | 
|                         { label: '正常', value: 1 },  | 
|                         { label: '禁用', value: 0 },  | 
|                     ]">  | 
|                     </a-select>  | 
|                 </a-form-item>  | 
|                 <!-- <a-form-item :label="formatMessage('db.man_wait_pakin.create_time', '添加时间')" name="createTime"  | 
|                     style="width: 250px;">  | 
|                     <a-date-picker v-model:value="formData.createTime" show-time format="YYYY-MM-DD HH:mm:ss"  | 
|                         value-format="YYYY-MM-DD HH:mm:ss" />  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.create_by', '添加人员')" name="createBy"  | 
|                     style="width: 250px;">  | 
|                     <a-select v-model:value="formData.createBy" :placeholder="formatMessage('common.select', '请选择')"  | 
|                         style="width: 100%" show-search :options="userQueryList" optionFilterProp="label"  | 
|                         optionLabelProp="label">  | 
|                     </a-select>  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.update_time', '修改时间')" name="updateTime"  | 
|                     style="width: 250px;">  | 
|                     <a-date-picker v-model:value="formData.updateTime" show-time format="YYYY-MM-DD HH:mm:ss"  | 
|                         value-format="YYYY-MM-DD HH:mm:ss" />  | 
|                 </a-form-item>  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.update_by', '修改人员')" name="updateBy"  | 
|                     style="width: 250px;">  | 
|                     <a-select v-model:value="formData.updateBy" :placeholder="formatMessage('common.select', '请选择')"  | 
|                         style="width: 100%" show-search :options="userQueryList" optionFilterProp="label"  | 
|                         optionLabelProp="label">  | 
|                     </a-select>  | 
|                 </a-form-item> -->  | 
|                 <a-form-item :label="formatMessage('db.man_wait_pakin.memo', '备注')" name="memo" style="width: 250px;">  | 
|                     <a-input v-model:value="formData.memo" />  | 
|                 </a-form-item>  | 
|   | 
|                 <a-form-item>  | 
|                     <a-button type="primary" html-type="submit" ref="submitButton"  | 
|                         style="visibility: hidden;">Submit</a-button>  | 
|                 </a-form-item>  | 
|             </a-form>  | 
|         </a-modal>  | 
|     </div>  | 
| </template>  | 
|   | 
| <style></style>  |