|  |  | 
 |  |  | import { logout } from '@/config.js'; | 
 |  |  | import { formatMessage } from '@/utils/localeUtils.js'; | 
 |  |  | import useTableSearch from '@/utils/tableUtils.jsx'; | 
 |  |  | import { debounce } from 'lodash-es'; | 
 |  |  | const context = getCurrentInstance()?.appContext.config.globalProperties; | 
 |  |  |  | 
 |  |  | const router = useRouter(); | 
 |  |  | 
 |  |  | const TABLE_KEY = 'table-locDetl'; | 
 |  |  |  | 
 |  |  | let tableData = ref([]); | 
 |  |  | let editTableData = ref([]); | 
 |  |  | let deleteDetlId = ref([]); | 
 |  |  | let orderId = ref(null); | 
 |  |  | getColumns(); | 
 |  |  |  | 
 |  |  | const { | 
 |  |  | 
 |  |  |         ellipsis: true, | 
 |  |  |     }, | 
 |  |  |     { | 
 |  |  |         title: formatMessage('db.man_loc_detl.matnr', '物料号'), | 
 |  |  |         title: formatMessage('db.man_loc_detl.matnr', '商品编号'), | 
 |  |  |         dataIndex: 'matnr', | 
 |  |  |         width: 140, | 
 |  |  |         ellipsis: true, | 
 |  |  |     }, | 
 |  |  |     { | 
 |  |  |         title: formatMessage('db.man_loc_detl.maktx', '物料名'), | 
 |  |  |         title: formatMessage('db.man_loc_detl.maktx', '商品名称'), | 
 |  |  |         dataIndex: 'maktx', | 
 |  |  |         width: 140, | 
 |  |  |         ellipsis: true, | 
 |  |  | 
 |  |  |     { | 
 |  |  |         title: formatMessage('db.man_loc_detl.anfme', '数量'), | 
 |  |  |         dataIndex: 'anfme', | 
 |  |  |         width: 140, | 
 |  |  |         ellipsis: true, | 
 |  |  |         editable: true, | 
 |  |  |     }, | 
 |  |  |     { | 
 |  |  |         title: formatMessage('db.man_loc_detl.qty', '已完成数量'), | 
 |  |  |         dataIndex: 'qty', | 
 |  |  |         width: 140, | 
 |  |  |         ellipsis: true, | 
 |  |  |         editable: true, | 
 |  |  |     }, | 
 |  |  |     { | 
 |  |  |         title: formatMessage('db.man_loc_detl.workQty', '作业中数量'), | 
 |  |  |         dataIndex: 'workQty', | 
 |  |  |         width: 140, | 
 |  |  |         ellipsis: true, | 
 |  |  |         editable: true, | 
 |  |  | 
 |  |  | const openAddDetl = ref(false); | 
 |  |  | const matChecked = ref([]); | 
 |  |  | const matQueryList = ref(null); | 
 |  |  | const matFetching = ref(false); | 
 |  |  | const matSelectList = ref([]); | 
 |  |  | const addDetl = () => { | 
 |  |  |     openAddDetl.value = true; | 
 |  |  | 
 |  |  |             maktx: item.data.maktx, | 
 |  |  |             batch: '', | 
 |  |  |             anfme: 0, | 
 |  |  |             qty: 0, | 
 |  |  |             workQty: 0, | 
 |  |  |             memo: '' | 
 |  |  |         }; | 
 |  |  |         fieldList.forEach((field) => { | 
 |  |  | 
 |  |  |     matChecked.value = []; | 
 |  |  | } | 
 |  |  |  | 
 |  |  | const handleSearch = val => { | 
 |  |  | const handleSearch = debounce(val => { | 
 |  |  |     matQuery(val); | 
 |  |  | } | 
 |  |  | }, 600) | 
 |  |  |  | 
 |  |  | const handleSelect = (value, option) => { | 
 |  |  |     let flag = true; | 
 |  |  | 
 |  |  |  | 
 |  |  | matQuery(null); | 
 |  |  | function matQuery(condition) { | 
 |  |  |     matFetching.value = true; | 
 |  |  |     post('/api/mat/page', { | 
 |  |  |         current: 1, | 
 |  |  |         pageSize: 100, | 
 |  |  |         pageSize: 10, | 
 |  |  |         condition: condition | 
 |  |  |     }).then((resp) => { | 
 |  |  |         let result = resp.data; | 
 |  |  | 
 |  |  |         result.data.records.forEach((item) => { | 
 |  |  |             tmp.push({ | 
 |  |  |                 value: item.matnr, | 
 |  |  |                 label: item.matnr, | 
 |  |  |                 label: item.matnr + '_' + item.maktx, | 
 |  |  |                 data: item | 
 |  |  |             }) | 
 |  |  |         }) | 
 |  |  |         matQueryList.value = tmp; | 
 |  |  |         matFetching.value = false; | 
 |  |  |     }) | 
 |  |  | } | 
 |  |  |  | 
 |  |  | 
 |  |  |     tableData.value = tmp; | 
 |  |  | } | 
 |  |  |  | 
 |  |  | watch(editTableData, (newVal, oldVal) => { | 
 |  |  |     let index = 1; | 
 |  |  |     let tmp = []; | 
 |  |  |     if (newVal.length > 0) { | 
 |  |  |         newVal.forEach((item) => { | 
 |  |  | watch(orderId, (newVal, oldVal) => { | 
 |  |  |     if (newVal == undefined || newVal == null) { | 
 |  |  |         tableData.value = []; | 
 |  |  |         return; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     get("/api/orderDetl/orderId/" + newVal, {}).then((resp) => { | 
 |  |  |         let result = resp.data; | 
 |  |  |         let index = 1; | 
 |  |  |         let tmp = []; | 
 |  |  |         result.data.forEach((item) => { | 
 |  |  |             let data = { | 
 |  |  |                 _id: index++, | 
 |  |  |                 detlId: item.id, | 
 |  |  | 
 |  |  |                 maktx: item.mat$.maktx, | 
 |  |  |                 batch: item.batch, | 
 |  |  |                 anfme: item.anfme, | 
 |  |  |                 qty: item.qty, | 
 |  |  |                 workQty: item.workQty, | 
 |  |  |                 memo: item.memo | 
 |  |  |             }; | 
 |  |  |             fieldList.forEach((field) => { | 
 |  |  | 
 |  |  |             }) | 
 |  |  |             tmp.push(data) | 
 |  |  |         }) | 
 |  |  |     } | 
 |  |  |     tableData.value = tmp; | 
 |  |  |         tableData.value = tmp; | 
 |  |  |     }) | 
 |  |  |  | 
 |  |  | }) | 
 |  |  |  | 
 |  |  | defineExpose({ | 
 |  |  |     tableData, | 
 |  |  |     editTableData, | 
 |  |  |     orderId, | 
 |  |  |     deleteDetlId, | 
 |  |  | }) | 
 |  |  |  | 
 |  |  | 
 |  |  |             @ok="handleAddDetlOk" @cancel="handleAddDetlCancel"> | 
 |  |  |             <a-select v-model:value="matChecked" :options="matQueryList" mode="multiple" | 
 |  |  |                 :placeholder="formatMessage('component.orderDetl.edit.selectMat', '请选择物料')" @search="handleSearch" | 
 |  |  |                 @select="handleSelect" @deselect="handleDeselect"></a-select> | 
 |  |  |                 :filter-option="false" :not-found-content="matFetching ? undefined : null" @select="handleSelect" | 
 |  |  |                 @deselect="handleDeselect"></a-select> | 
 |  |  |         </a-modal> | 
 |  |  |     </div> | 
 |  |  | </template> |