|  |  |  | 
|---|
|  |  |  | <script setup> | 
|---|
|  |  |  | import { ref, watch, reactive } from 'vue'; | 
|---|
|  |  |  | import { useRouter } from "vue-router"; | 
|---|
|  |  |  | import { get, post, postBlob } from '@/utils/request.js' | 
|---|
|  |  |  | import { message, Modal } from 'ant-design-vue'; | 
|---|
|  |  |  | import { logout } from '@/config.js'; | 
|---|
|  |  |  | import { formatMessage } from '@/utils/localeUtils.js'; | 
|---|
|  |  |  | import useTableSearch from '@/utils/tableUtils.jsx'; | 
|---|
|  |  |  | import StockOutView from './stockOut.vue'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const router = useRouter(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const TABLE_KEY = 'table-order-out-preview'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const emit = defineEmits(['reload']) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | getColumnSearchProps, | 
|---|
|  |  |  | } = useTableSearch(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let currentOrder = ref(null); | 
|---|
|  |  |  | let searchInput = ref(null); | 
|---|
|  |  |  | let tableData = ref([]); | 
|---|
|  |  |  | const open = ref(false); | 
|---|
|  |  |  | const showWidth = ref("60%") | 
|---|
|  |  |  | const records = ref([]) | 
|---|
|  |  |  | const waveId = ref(null) | 
|---|
|  |  |  | const loading = ref(false) | 
|---|
|  |  |  | const stockOutChild = ref(null) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let columns = [ | 
|---|
|  |  |  | { | 
|---|
|  |  |  | title: formatMessage('db.man_order_detl.matnr', '商品编号'), | 
|---|
|  |  |  | dataIndex: 'matnr', | 
|---|
|  |  |  | width: 140, | 
|---|
|  |  |  | ellipsis: true, | 
|---|
|  |  |  | ...getColumnSearchProps('matnr'), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | title: formatMessage('db.man_order_detl.batch', '批号'), | 
|---|
|  |  |  | dataIndex: 'batch', | 
|---|
|  |  |  | width: 140, | 
|---|
|  |  |  | ellipsis: true, | 
|---|
|  |  |  | ...getColumnSearchProps('batch'), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | title: formatMessage('db.man_order_detl.anfme', '数量'), | 
|---|
|  |  |  | dataIndex: 'anfme', | 
|---|
|  |  |  | width: 140, | 
|---|
|  |  |  | ellipsis: true, | 
|---|
|  |  |  | ...getColumnSearchProps('anfme'), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | ]; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const state = reactive({ | 
|---|
|  |  |  | selectedRowKeys: [], | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | const onSelectChange = selectedRowKeys => { | 
|---|
|  |  |  | // console.log('selectedRowKeys changed: ', selectedRowKeys); | 
|---|
|  |  |  | state.selectedRowKeys = selectedRowKeys; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const fieldList = []; | 
|---|
|  |  |  | getColumns(); | 
|---|
|  |  |  | //加载扩展字段 | 
|---|
|  |  |  | async function getColumns() { | 
|---|
|  |  |  | let fieldResp = await post('/api/matField/list', { | 
|---|
|  |  |  | unique: 1 | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | let fieldResult = fieldResp.data; | 
|---|
|  |  |  | let tmp = columns; | 
|---|
|  |  |  | if (fieldResult.code == 200) { | 
|---|
|  |  |  | let data = fieldResult.data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | data.forEach((item) => { | 
|---|
|  |  |  | tmp.push({ | 
|---|
|  |  |  | title: formatMessage(item.language, item.describe), | 
|---|
|  |  |  | name: item.name, | 
|---|
|  |  |  | dataIndex: item.name, | 
|---|
|  |  |  | key: item.name, | 
|---|
|  |  |  | width: 140, | 
|---|
|  |  |  | editable: true, | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | fieldList.push(item.name); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | columns = tmp; | 
|---|
|  |  |  | } else if (result.code === 401) { | 
|---|
|  |  |  | message.error(result.msg); | 
|---|
|  |  |  | logout() | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | message.error(result.msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | watch(open, (newVal, oldVal) => { | 
|---|
|  |  |  | if (newVal) { | 
|---|
|  |  |  | handleOrderMergePreview() | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleOk = () => { | 
|---|
|  |  |  | if (state.selectedRowKeys.length == 0) { | 
|---|
|  |  |  | message.error(formatMessage("page.orderOut.mergeOrderOut.checkedError", "请选择至少一条数据")); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let param = [] | 
|---|
|  |  |  | state.selectedRowKeys.forEach((idx) => { | 
|---|
|  |  |  | let tmp = tableData.value[idx]; | 
|---|
|  |  |  | if (tmp != null) { | 
|---|
|  |  |  | param.push(tmp) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | stockOutChild.value.open = true; | 
|---|
|  |  |  | stockOutChild.value.records = param; | 
|---|
|  |  |  | stockOutChild.value.waveId = waveId.value; | 
|---|
|  |  |  | stockOutChild.value.showWidth = '55%' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // emit('reload', true) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleOrderMergePreview = () => { | 
|---|
|  |  |  | loading.value = true; | 
|---|
|  |  |  | tableData.value = [] | 
|---|
|  |  |  | state.selectedRowKeys = [] | 
|---|
|  |  |  |  | 
|---|
|  |  |  | post('/api/out/orderOut/merge/preview', { | 
|---|
|  |  |  | orderIds: records.value, | 
|---|
|  |  |  | }).then((resp) => { | 
|---|
|  |  |  | let result = resp.data; | 
|---|
|  |  |  | if (result.code == 200) { | 
|---|
|  |  |  | let tmp = result.data; | 
|---|
|  |  |  | let index = 0; | 
|---|
|  |  |  | tmp.forEach((item) => { | 
|---|
|  |  |  | item.index = index++; | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | tableData.value = tmp; | 
|---|
|  |  |  | loading.value = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleCloseParent = () => { | 
|---|
|  |  |  | open.value = false; | 
|---|
|  |  |  | emit('reload', true) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | defineExpose({ | 
|---|
|  |  |  | open, | 
|---|
|  |  |  | showWidth, | 
|---|
|  |  |  | records, | 
|---|
|  |  |  | waveId, | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | name: '预览合并订单' | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <template> | 
|---|
|  |  |  | <div> | 
|---|
|  |  |  | <a-modal v-model:open="open" :width="showWidth" :title="formatMessage('page.orderOutPreview.preview', '预览合并订单')" | 
|---|
|  |  |  | @ok="handleOk"> | 
|---|
|  |  |  | <a-table :data-source="tableData" | 
|---|
|  |  |  | :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }" :loading="loading" | 
|---|
|  |  |  | :defaultExpandAllRows="false" :key="TABLE_KEY" rowKey="index" | 
|---|
|  |  |  | :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="columns"> | 
|---|
|  |  |  | <template #bodyCell="{ column, text, record, index }"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </a-table> | 
|---|
|  |  |  | </a-modal> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <StockOutView ref="stockOutChild" @closeParent="handleCloseParent" /> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <style></style> | 
|---|
|  |  |  | <script setup> | 
|---|
|  |  |  | import { ref, watch, reactive } from 'vue'; | 
|---|
|  |  |  | import { useRouter } from "vue-router"; | 
|---|
|  |  |  | import { get, post, postBlob } from '@/utils/request.js' | 
|---|
|  |  |  | import { message, Modal } from 'ant-design-vue'; | 
|---|
|  |  |  | import { logout } from '@/config.js'; | 
|---|
|  |  |  | import { formatMessage } from '@/utils/localeUtils.js'; | 
|---|
|  |  |  | import useTableSearch from '@/utils/tableUtils.jsx'; | 
|---|
|  |  |  | import StockOutView from './stockOut.vue'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const router = useRouter(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const TABLE_KEY = 'table-order-out-preview'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const emit = defineEmits(['reload']) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | getColumnSearchProps, | 
|---|
|  |  |  | } = useTableSearch(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let currentOrder = ref(null); | 
|---|
|  |  |  | let searchInput = ref(null); | 
|---|
|  |  |  | let tableData = ref([]); | 
|---|
|  |  |  | const open = ref(false); | 
|---|
|  |  |  | const showWidth = ref("60%") | 
|---|
|  |  |  | const records = ref([]) | 
|---|
|  |  |  | const waveId = ref(null) | 
|---|
|  |  |  | const loading = ref(false) | 
|---|
|  |  |  | const stockOutChild = ref(null) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let columns = [ | 
|---|
|  |  |  | { | 
|---|
|  |  |  | title: formatMessage('db.man_order_detl.matnr', '商品编号'), | 
|---|
|  |  |  | dataIndex: 'matnr', | 
|---|
|  |  |  | width: 140, | 
|---|
|  |  |  | ellipsis: true, | 
|---|
|  |  |  | ...getColumnSearchProps('matnr'), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | title: formatMessage('db.man_order_detl.batch', '批号'), | 
|---|
|  |  |  | dataIndex: 'batch', | 
|---|
|  |  |  | width: 140, | 
|---|
|  |  |  | ellipsis: true, | 
|---|
|  |  |  | ...getColumnSearchProps('batch'), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | title: formatMessage('db.man_order_detl.anfme', '数量'), | 
|---|
|  |  |  | dataIndex: 'anfme', | 
|---|
|  |  |  | width: 140, | 
|---|
|  |  |  | ellipsis: true, | 
|---|
|  |  |  | ...getColumnSearchProps('anfme'), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | ]; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const state = reactive({ | 
|---|
|  |  |  | selectedRowKeys: [], | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | const onSelectChange = selectedRowKeys => { | 
|---|
|  |  |  | // console.log('selectedRowKeys changed: ', selectedRowKeys); | 
|---|
|  |  |  | state.selectedRowKeys = selectedRowKeys; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const fieldList = []; | 
|---|
|  |  |  | getColumns(); | 
|---|
|  |  |  | //加载扩展字段 | 
|---|
|  |  |  | async function getColumns() { | 
|---|
|  |  |  | let fieldResp = await post('/api/matField/list', { | 
|---|
|  |  |  | unique: 1 | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | let fieldResult = fieldResp.data; | 
|---|
|  |  |  | let tmp = columns; | 
|---|
|  |  |  | if (fieldResult.code == 200) { | 
|---|
|  |  |  | let data = fieldResult.data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | data.forEach((item) => { | 
|---|
|  |  |  | tmp.push({ | 
|---|
|  |  |  | title: formatMessage(item.language, item.describe), | 
|---|
|  |  |  | name: item.name, | 
|---|
|  |  |  | dataIndex: item.name, | 
|---|
|  |  |  | key: item.name, | 
|---|
|  |  |  | width: 140, | 
|---|
|  |  |  | editable: true, | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | fieldList.push(item.name); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | columns = tmp; | 
|---|
|  |  |  | } else if (result.code === 401) { | 
|---|
|  |  |  | message.error(result.msg); | 
|---|
|  |  |  | logout() | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | message.error(result.msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | watch(open, (newVal, oldVal) => { | 
|---|
|  |  |  | if (newVal) { | 
|---|
|  |  |  | handleOrderMergePreview() | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleOk = () => { | 
|---|
|  |  |  | if (state.selectedRowKeys.length == 0) { | 
|---|
|  |  |  | message.error(formatMessage("page.orderOut.mergeOrderOut.checkedError", "请选择至少一条数据")); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let param = [] | 
|---|
|  |  |  | state.selectedRowKeys.forEach((idx) => { | 
|---|
|  |  |  | let tmp = tableData.value[idx]; | 
|---|
|  |  |  | if (tmp != null) { | 
|---|
|  |  |  | param.push(tmp) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | stockOutChild.value.open = true; | 
|---|
|  |  |  | stockOutChild.value.records = param; | 
|---|
|  |  |  | stockOutChild.value.waveId = waveId.value; | 
|---|
|  |  |  | stockOutChild.value.showWidth = '55%' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // emit('reload', true) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleOrderMergePreview = () => { | 
|---|
|  |  |  | loading.value = true; | 
|---|
|  |  |  | tableData.value = [] | 
|---|
|  |  |  | state.selectedRowKeys = [] | 
|---|
|  |  |  |  | 
|---|
|  |  |  | post('/api/out/orderOut/merge/preview', { | 
|---|
|  |  |  | orderIds: records.value, | 
|---|
|  |  |  | }).then((resp) => { | 
|---|
|  |  |  | let result = resp.data; | 
|---|
|  |  |  | if (result.code == 200) { | 
|---|
|  |  |  | let tmp = result.data; | 
|---|
|  |  |  | let index = 0; | 
|---|
|  |  |  | tmp.forEach((item) => { | 
|---|
|  |  |  | item.index = index++; | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | tableData.value = tmp; | 
|---|
|  |  |  | loading.value = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleCloseParent = () => { | 
|---|
|  |  |  | open.value = false; | 
|---|
|  |  |  | emit('reload', true) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | defineExpose({ | 
|---|
|  |  |  | open, | 
|---|
|  |  |  | showWidth, | 
|---|
|  |  |  | records, | 
|---|
|  |  |  | waveId, | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | name: '预览合并订单' | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <template> | 
|---|
|  |  |  | <div> | 
|---|
|  |  |  | <a-modal v-model:open="open" :width="showWidth" :title="formatMessage('page.orderOutPreview.preview', '预览合并订单')" | 
|---|
|  |  |  | @ok="handleOk"> | 
|---|
|  |  |  | <a-table :data-source="tableData" | 
|---|
|  |  |  | :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }" :loading="loading" | 
|---|
|  |  |  | :defaultExpandAllRows="false" :key="TABLE_KEY" rowKey="index" | 
|---|
|  |  |  | :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="columns"> | 
|---|
|  |  |  | <template #bodyCell="{ column, text, record, index }"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </a-table> | 
|---|
|  |  |  | </a-modal> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <StockOutView ref="stockOutChild" @closeParent="handleCloseParent" /> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <style></style> | 
|---|