New file |
| | |
| | | <script setup> |
| | | import { getCurrentInstance, ref, watch, reactive } from 'vue'; |
| | | import { useRouter } from "vue-router"; |
| | | import { get, post, postForm } 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'; |
| | | const context = getCurrentInstance()?.appContext.config.globalProperties; |
| | | |
| | | const router = useRouter(); |
| | | |
| | | const emit = defineEmits(['handleOk']) |
| | | |
| | | const TABLE_KEY = 'table-mat'; |
| | | let currentPage = 1; |
| | | let pageSize = 10; |
| | | let tableData = ref([]); |
| | | let selectedData = ref([]); |
| | | const open = ref(false); |
| | | const reload = ref(false); |
| | | const searchInput = ref("") |
| | | |
| | | const showWidth = ref("60%") |
| | | |
| | | const { |
| | | getColumnSearchProps, |
| | | } = useTableSearch(); |
| | | |
| | | const state = reactive({ |
| | | selectedRowKeys: [], |
| | | loading: false, |
| | | columns: [], |
| | | }); |
| | | const onSelectChange = (selectedRowKeys, selectedRows) => { |
| | | // console.log('selectedRowKeys changed: ', selectedRowKeys); |
| | | state.selectedRowKeys = selectedRowKeys; |
| | | selectedData.value = selectedRows; |
| | | }; |
| | | |
| | | getColumns(); |
| | | getPage(); |
| | | |
| | | state.columns = [ |
| | | { |
| | | title: formatMessage('db.man_mat.tag_id', '所属归类'), |
| | | dataIndex: 'tagId$', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('tagId$'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.matnr', '商品编号'), |
| | | dataIndex: 'matnr', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('matnr'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.maktx', '商品名称'), |
| | | dataIndex: 'maktx', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('maktx'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.name', '别名'), |
| | | dataIndex: 'name', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('name'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.specs', '规格'), |
| | | dataIndex: 'specs', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('specs'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.model', '型号'), |
| | | dataIndex: 'model', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('model'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.color', '颜色'), |
| | | dataIndex: 'color', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('color'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.brand', '品牌'), |
| | | dataIndex: 'brand', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('brand'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.unit', '单位'), |
| | | dataIndex: 'unit', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('unit'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.price', '单价'), |
| | | dataIndex: 'price', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('price'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.sku', 'sku'), |
| | | dataIndex: 'sku', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('sku'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.units', '单位量'), |
| | | dataIndex: 'units', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('units'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.barcode', '条码'), |
| | | dataIndex: 'barcode', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('barcode'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.origin', '产地'), |
| | | dataIndex: 'origin', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('origin'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.manu', '厂家'), |
| | | dataIndex: 'manu', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('manu'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.manu_date', '生产日期'), |
| | | dataIndex: 'manuDate', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('manuDate'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.item_num', '品项数'), |
| | | dataIndex: 'itemNum', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('itemNum'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.weight', '重量'), |
| | | dataIndex: 'weight', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('weight'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.length', '长度'), |
| | | dataIndex: 'length', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('length'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.volume', '体积'), |
| | | dataIndex: 'volume', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('volume'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.three_code', '三方编码'), |
| | | dataIndex: 'threeCode', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('threeCode'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.supp', '供应商'), |
| | | dataIndex: 'supp', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('supp'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.supp_code', '供应商编码'), |
| | | dataIndex: 'suppCode', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('suppCode'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.dead_time', '保质期'), |
| | | dataIndex: 'deadTime', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('deadTime'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.safeStockLimit', '安全库存上限'), |
| | | dataIndex: 'safeStockLimit', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('safeStockLimit'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.safeStockMinimum', '安全库存下限'), |
| | | dataIndex: 'safeStockMinimum', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('safeStockMinimum'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.validity', '有效期'), |
| | | dataIndex: 'validity', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('validity'), |
| | | }, |
| | | |
| | | { |
| | | title: formatMessage('db.man_mat.uuid', '编号'), |
| | | dataIndex: 'uuid', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('uuid'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.flag', '标识'), |
| | | dataIndex: 'flag', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('flag'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.sort', '排序'), |
| | | dataIndex: 'sort', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('sort'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.status', '状态'), |
| | | dataIndex: 'status$', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('status$'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_mat.memo', '备注'), |
| | | dataIndex: 'memo', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('memo'), |
| | | }, |
| | | |
| | | ]; |
| | | |
| | | //加载扩展字段 |
| | | async function getColumns() { |
| | | let fieldResp = await post('/api/matField/list', { |
| | | fieldType: 0 |
| | | }) |
| | | let fieldResult = fieldResp.data; |
| | | let tmp = state.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, |
| | | }) |
| | | }) |
| | | |
| | | state.columns = tmp; |
| | | } else if (result.code === 401) { |
| | | message.error(result.msg); |
| | | logout() |
| | | } else { |
| | | message.error(result.msg); |
| | | } |
| | | } |
| | | |
| | | function getPage() { |
| | | state.loading = true; |
| | | |
| | | post('/api/mat/page', { |
| | | current: currentPage, |
| | | pageSize: pageSize, |
| | | condition: searchInput.value |
| | | }).then((resp) => { |
| | | let result = resp.data; |
| | | if (result.code == 200) { |
| | | let data = result.data; |
| | | tableData.value = data; |
| | | |
| | | state.loading = false; |
| | | } else if (result.code === 401) { |
| | | message.error(result.msg); |
| | | logout() |
| | | } else { |
| | | message.error(result.msg); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const handleOk = () => { |
| | | open.value = false; |
| | | emit('handleOk', selectedData.value) |
| | | |
| | | state.selectedRowKeys = [] |
| | | selectedData.value = [] |
| | | } |
| | | |
| | | const handleCancel = () => { |
| | | open.value = false; |
| | | } |
| | | |
| | | const onSearch = () => { |
| | | getPage() |
| | | } |
| | | |
| | | const onPageChange = (page, size) => { |
| | | currentPage = page; |
| | | pageSize = size; |
| | | getPage(); |
| | | } |
| | | |
| | | const showTotalPage = (total, range) => { |
| | | return formatMessage('page.total.head', '总计') + total + formatMessage('page.total.footer', '条') |
| | | } |
| | | |
| | | const reloadPage = () => { |
| | | currentPage = 1; |
| | | searchInput.value = ""; |
| | | getPage() |
| | | } |
| | | |
| | | watch(reload, (newVal, oldVal) => { |
| | | if (reload.value) { |
| | | reloadPage() |
| | | } |
| | | }) |
| | | |
| | | defineExpose({ |
| | | tableData, |
| | | open, |
| | | showWidth, |
| | | reload |
| | | }) |
| | | |
| | | </script> |
| | | |
| | | <script> |
| | | export default { |
| | | name: 'matQueryComponent' |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | | <div> |
| | | <a-modal v-model:open="open" :width="showWidth" @ok="handleOk" @cancel="handleCancel"> |
| | | <div class="table-header"> |
| | | <a-input-search v-model:value="searchInput" :placeholder="formatMessage('page.input', '请输入')" |
| | | style="width: 200px;" @search="onSearch" /> |
| | | </div> |
| | | <a-table :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }" |
| | | :pagination="{ total: tableData.total, showTotal: showTotalPage, onChange: onPageChange }" |
| | | :data-source="tableData.records" :defaultExpandAllRows="false" :key="TABLE_KEY" rowKey="id" |
| | | :scroll="{ y: 768 }" :columns="state.columns" :loading="state.loading"> |
| | | </a-table> |
| | | </a-modal> |
| | | </div> |
| | | </template> |
| | | |
| | | <style></style> |
| | |
| | | }) |
| | | }) |
| | | |
| | | tmp.push({ |
| | | title: formatMessage('common.operation', '操作'), |
| | | name: 'oper', |
| | | dataIndex: 'oper', |
| | | key: 'oper', |
| | | width: 140, |
| | | }) |
| | | // tmp.push({ |
| | | // title: formatMessage('common.operation', '操作'), |
| | | // name: 'oper', |
| | | // dataIndex: 'oper', |
| | | // key: 'oper', |
| | | // width: 140, |
| | | // }) |
| | | |
| | | state.columns = tmp; |
| | | } else if (result.code === 401) { |
New file |
| | |
| | | <script setup> |
| | | import { ref, reactive } from 'vue'; |
| | | import { useRouter } from "vue-router"; |
| | | import { get, post, postForm } 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 MatQueryView from '@/components/mat/matQuery/index.vue' |
| | | |
| | | const router = useRouter(); |
| | | |
| | | const TABLE_KEY = 'table-locDetl'; |
| | | const matQueryChild = ref(null) |
| | | const searchInput = ref(null) |
| | | |
| | | let tableData = ref([]); |
| | | getColumns(); |
| | | |
| | | const { |
| | | getColumnSearchProps, |
| | | handleResizeColumn, |
| | | } = useTableSearch(); |
| | | |
| | | const state = reactive({ |
| | | selectedRowKeys: [], |
| | | loading: false, |
| | | columns: [], |
| | | }); |
| | | const onSelectChange = selectedRowKeys => { |
| | | // console.log('selectedRowKeys changed: ', selectedRowKeys); |
| | | state.selectedRowKeys = selectedRowKeys; |
| | | }; |
| | | |
| | | state.columns = [ |
| | | { |
| | | title: formatMessage('db.man_loc_detl.qty', '实际数量'), |
| | | dataIndex: 'qty', |
| | | width: 140, |
| | | ellipsis: true, |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.anfme', '库存数量'), |
| | | dataIndex: 'anfme', |
| | | width: 140, |
| | | ellipsis: true, |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.matnr', '商品编号'), |
| | | dataIndex: 'matnr', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('matnr'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.batch', '批号'), |
| | | dataIndex: 'batch', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('batch'), |
| | | }, |
| | | ]; |
| | | |
| | | let columnsOther = [ |
| | | { |
| | | title: formatMessage('db.man_loc_detl.loc_id', '库位'), |
| | | dataIndex: 'locId$', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('locId$'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.loc_no', '库位号'), |
| | | dataIndex: 'locNo', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('locNo'), |
| | | }, |
| | | // { |
| | | // title: formatMessage('db.man_loc_detl.mat_id', '商品'), |
| | | // dataIndex: 'matId$', |
| | | // width: 140, |
| | | // ellipsis: true, |
| | | // ...getColumnSearchProps('matId$'), |
| | | // }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.order_no', '订单号'), |
| | | dataIndex: 'orderNo', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('orderNo'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.anfme', '数量'), |
| | | dataIndex: 'anfme', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('anfme'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.freeze', '是否冻结'), |
| | | dataIndex: 'freeze$', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('freeze$'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.status', '状态'), |
| | | dataIndex: 'status$', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('status$'), |
| | | }, |
| | | // { |
| | | // title: formatMessage('db.man_loc_detl.create_time', '添加时间'), |
| | | // dataIndex: 'createTime$', |
| | | // width: 140, |
| | | // ellipsis: true, |
| | | // ...getColumnSearchProps('createTime$'), |
| | | // }, |
| | | // { |
| | | // title: formatMessage('db.man_loc_detl.create_by', '添加人员'), |
| | | // dataIndex: 'createBy$', |
| | | // width: 140, |
| | | // ellipsis: true, |
| | | // ...getColumnSearchProps('createBy$'), |
| | | // }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.update_time', '修改时间'), |
| | | dataIndex: 'updateTime$', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('updateTime$'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.update_by', '修改人员'), |
| | | dataIndex: 'updateBy$', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('updateBy$'), |
| | | }, |
| | | { |
| | | title: formatMessage('db.man_loc_detl.memo', '备注'), |
| | | dataIndex: 'memo', |
| | | width: 140, |
| | | ellipsis: true, |
| | | ...getColumnSearchProps('memo'), |
| | | }, |
| | | ] |
| | | |
| | | let fieldList = []; |
| | | //加载扩展字段 |
| | | async function getColumns() { |
| | | let fieldResp = await post('/api/matField/list', { |
| | | unique: 1 |
| | | }) |
| | | let fieldResult = fieldResp.data; |
| | | let tmp = state.columns; |
| | | if (fieldResult.code == 200) { |
| | | let data = fieldResult.data; |
| | | data.forEach((item) => { |
| | | let filed = { |
| | | title: formatMessage(item.language, item.describe), |
| | | name: item.name, |
| | | dataIndex: item.name, |
| | | key: item.name, |
| | | width: 140, |
| | | editable: true, |
| | | } |
| | | tmp.push(filed) |
| | | fieldList.push(filed) |
| | | }) |
| | | |
| | | tmp = tmp.concat(columnsOther) |
| | | |
| | | tmp.push({ |
| | | title: formatMessage('common.operation', '操作'), |
| | | name: 'oper', |
| | | dataIndex: 'oper', |
| | | key: 'oper', |
| | | width: 140, |
| | | fixed: 'right', |
| | | }) |
| | | |
| | | state.columns = tmp; |
| | | } else if (result.code === 401) { |
| | | message.error(result.msg); |
| | | logout() |
| | | } else { |
| | | message.error(result.msg); |
| | | } |
| | | } |
| | | |
| | | const openSelect = () => { |
| | | if (loc.value == null) { |
| | | message.error(formatMessage('page.stockAdjust.locDetlListNull', '请检索库位')); |
| | | return; |
| | | } |
| | | |
| | | if (loc.value.locSts$ != 'F') { |
| | | message.error(formatMessage('page.stockAdjust.locDetlListNull', '当前库位状态不可调整')); |
| | | return; |
| | | } |
| | | |
| | | matQueryChild.value.open = true; |
| | | } |
| | | |
| | | const handleMatQueryOk = (result) => { |
| | | let tmp = []; |
| | | |
| | | if (tableData.value != undefined) { |
| | | tmp = [...tableData.value] |
| | | } |
| | | |
| | | for (let i = 0; i < result.length; i++) { |
| | | let item = result[i] |
| | | item.anfme = 0; |
| | | item.qty = 0; |
| | | item.matId = item.id; |
| | | item.id = null; |
| | | |
| | | fieldList.forEach((filed) => { |
| | | item[filed.key] = '' |
| | | }) |
| | | |
| | | tmp.push(item) |
| | | } |
| | | |
| | | tableData.value = tmp; |
| | | } |
| | | |
| | | const handleDel = (record) => { |
| | | let data = tableData.value; |
| | | let tmp = [] |
| | | |
| | | for (let i = 0; i < data.length; i++) { |
| | | let item = data[i] |
| | | if (item.id == record.id) { |
| | | continue |
| | | } |
| | | tmp.push(item) |
| | | } |
| | | tableData.value = tmp |
| | | } |
| | | |
| | | const loc = ref(null) |
| | | const onSearch = () => { |
| | | if (searchInput.value == '' || searchInput.value == null) { |
| | | message.error(formatMessage('page.stockAdjust.input.loc', '请先输入库位号')); |
| | | return; |
| | | } |
| | | |
| | | postForm('/api/loc/search/locNo', { |
| | | locNo: searchInput.value, |
| | | }).then(resp => { |
| | | let result = resp.data; |
| | | if (result.code == 200) { |
| | | loc.value = result.data.loc; |
| | | |
| | | let detls = []; |
| | | result.data.locDetls.forEach((item) => { |
| | | item.qty = item.anfme; |
| | | detls.push(item) |
| | | }) |
| | | tableData.value = detls; |
| | | } else { |
| | | message.error(result.msg); |
| | | loc.value = null; |
| | | tableData.value = null; |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const submitAdj = () => { |
| | | Modal.confirm({ |
| | | title: formatMessage('page.stockAdjust.adjust', '调整库存'), |
| | | content: formatMessage('page.stockAdjust.confirm', '确定调整库存吗?'), |
| | | maskClosable: true, |
| | | onOk: async () => { |
| | | confirmAdj() |
| | | }, |
| | | }); |
| | | |
| | | } |
| | | |
| | | const confirmAdj = () => { |
| | | if (loc.value == null) { |
| | | message.error(formatMessage('page.stockAdjust.locDetlListNull', '请检索库位')); |
| | | return; |
| | | } |
| | | |
| | | if (loc.value.locSts$ != 'F') { |
| | | message.error(formatMessage('page.stockAdjust.locDetlListNull', '当前库位状态不可调整')); |
| | | return; |
| | | } |
| | | |
| | | let tmpData = tableData.value; |
| | | if (tmpData.length == 0) { |
| | | message.error(formatMessage('page.stockAdjust.locDetlListNull', '库存信息不能为空')); |
| | | return; |
| | | } |
| | | |
| | | post('/api/loc/adjust', { |
| | | locNo: loc.value.locNo, |
| | | detls: tmpData |
| | | }).then(resp => { |
| | | let result = resp.data; |
| | | if (result.code == 200) { |
| | | message.success(formatMessage('page.stockAdjust.success', '库存调整成功')); |
| | | |
| | | loc.value = null; |
| | | tableData.value = null; |
| | | searchInput.value = null; |
| | | } else { |
| | | message.error(result.msg); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <script> |
| | | export default { |
| | | name: '库存调整' |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | | <div> |
| | | <div style="margin-bottom: 20px;display: flex;align-items: center;"> |
| | | <a-input-search v-model:value="searchInput" :placeholder="formatMessage('page.input', '请输入')" |
| | | style="width: 200px;" @search="onSearch" /> |
| | | <div v-if="loc" style="margin-left: 20px;font-size: 18px;"> |
| | | 当前检索库位: {{ loc.locNo }} ,库位状态: {{ loc.locSts$ }}.{{ loc.locStsId$ }} |
| | | </div> |
| | | </div> |
| | | <div class="table-header"> |
| | | <div> |
| | | <a-button @click="openSelect">新增库存</a-button> |
| | | <a-button style="margin-left: 5px;" type="primary" @click="submitAdj">调整库存</a-button> |
| | | </div> |
| | | </div> |
| | | <a-table :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }" |
| | | :data-source="tableData" :defaultExpandAllRows="false" :key="TABLE_KEY" rowKey="id" |
| | | :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="state.columns" |
| | | @resizeColumn="handleResizeColumn"> |
| | | <template #bodyCell="{ column, text, record }"> |
| | | <template v-if="column.dataIndex === 'oper'"> |
| | | <div style="display: flex;justify-content: space-evenly;"> |
| | | <a-button type="link" danger @click="handleDel(record)">{{ formatMessage('page.delete', '删除') |
| | | }}</a-button> |
| | | </div> |
| | | </template> |
| | | |
| | | <template v-if="column.dataIndex === 'qty'"> |
| | | <div> |
| | | <a-input-number v-model:value="record[column.dataIndex]" :min="1" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <template v-if="column.dataIndex === 'batch'"> |
| | | <div> |
| | | <a-input v-model:value="record[column.dataIndex]" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <template v-if="column.editable"> |
| | | <div> |
| | | <a-input v-model:value="record[column.dataIndex]" /> |
| | | </div> |
| | | </template> |
| | | </template> |
| | | </a-table> |
| | | |
| | | <MatQueryView ref="matQueryChild" @handle-ok="handleMatQueryOk" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <style></style> |
| | |
| | | |
| | | state.columns = [ |
| | | { |
| | | title: formatMessage('db.man_loc_detl.anfme', '出库数量'), |
| | | title: formatMessage('db.man_loc_detl.workQty', '出库数量'), |
| | | dataIndex: 'workQty', |
| | | width: 140, |
| | | ellipsis: true, |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wms.asrs.entity.LocDetl; |
| | | import com.zy.asrs.wms.asrs.service.LocDetlService; |
| | | import com.zy.asrs.wms.common.annotation.OperationLog; |
| | | import com.zy.asrs.wms.common.domain.BaseParam; |
| | | import com.zy.asrs.wms.common.domain.KeyValVo; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | |
| | | |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | @PreAuthorize("hasAuthority('asrs:loc:list')") |
| | | @PostMapping("/loc/page") |
| | |
| | | return R.ok().add(locService.getById(id)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('asrs:loc:list')") |
| | | @PostMapping("/loc/search/locNo") |
| | | public R get(@RequestParam("locNo") String locNo) { |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, locNo)); |
| | | if(loc == null) { |
| | | return R.error("库位不存在"); |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, loc.getId())); |
| | | locDetls = locDetlService.parseLocDetl(locDetls); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("loc", loc); |
| | | map.put("locDetls", locDetls); |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('asrs:loc:save')") |
| | | @OperationLog("添加库位") |
| | | @PostMapping("/loc/save") |
| | |
| | | package com.zy.asrs.wms.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.Loc; |
| | | import com.zy.asrs.wms.asrs.entity.LocDetl; |
| | | import com.zy.asrs.wms.asrs.entity.LocDetlField; |
| | | import com.zy.asrs.wms.asrs.entity.MatField; |
| | | import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam; |
| | | import com.zy.asrs.wms.asrs.service.WorkService; |
| | | import com.zy.asrs.wms.asrs.entity.param.LocAdjustParam; |
| | | import com.zy.asrs.wms.asrs.service.*; |
| | | import com.zy.asrs.wms.common.annotation.OperationLog; |
| | | import com.zy.asrs.wms.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | |
| | | |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private MatFieldService matFieldService; |
| | | @Autowired |
| | | private LocDetlFieldService locDetlFieldService; |
| | | |
| | | @OperationLog("生成入库任务") |
| | | @PostMapping("/rpc/generatePakIn") |
| | |
| | | } |
| | | } |
| | | |
| | | @OperationLog("库存调整") |
| | | @PostMapping("/loc/adjust") |
| | | @Transactional |
| | | public R locAdjust(@RequestBody LocAdjustParam param) { |
| | | if (param == null) { |
| | | return R.error("参数不能为空"); |
| | | } |
| | | |
| | | if (Cools.isEmpty(param.getLocNo())) { |
| | | return R.error("库位号不能为空"); |
| | | } |
| | | |
| | | if (param.getDetls() == null) { |
| | | return R.error("库存明细不能为空"); |
| | | } |
| | | |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, param.getLocNo())); |
| | | if (loc == null) { |
| | | return R.error("库位不存在"); |
| | | } |
| | | |
| | | //删除源库存 |
| | | locDetlService.removeLocDetl(loc.getId()); |
| | | |
| | | List<MatField> matFields = matFieldService.list(new LambdaQueryWrapper<MatField>().eq(MatField::getUnique, 1)); |
| | | for (Map<String, Object> map : param.getDetls()) { |
| | | LocDetl locDetl = JSON.parseObject(JSON.toJSONString(map), LocDetl.class); |
| | | HashMap<String, Object> uniqueFields = new HashMap<>(); |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | for (MatField field : matFields) { |
| | | if (entry.getKey().equals(field.getName())) { |
| | | uniqueFields.put(entry.getKey(), entry.getValue()); |
| | | } |
| | | } |
| | | } |
| | | locDetl.setAnfme(Double.parseDouble(map.get("qty").toString())); |
| | | locDetl.syncFieldMap(uniqueFields); |
| | | |
| | | if (locDetl.getAnfme() <= 0D) { |
| | | throw new CoolException("数量不能小于0"); |
| | | } |
| | | |
| | | locDetl.setId(null); |
| | | locDetl.setLocId(loc.getId()); |
| | | locDetl.setLocNo(loc.getLocNo()); |
| | | boolean save = locDetlService.save(locDetl); |
| | | if (!save) { |
| | | throw new CoolException("库存调整失败"); |
| | | } |
| | | |
| | | //插入库存明细字段 |
| | | for (MatField matField : matFields) { |
| | | LocDetlField locDetlField = new LocDetlField(); |
| | | locDetlField.setDetlId(locDetl.getId()); |
| | | locDetlField.setFieldId(matField.getId()); |
| | | locDetlField.setName(matField.getName()); |
| | | locDetlField.setValue(Optional.ofNullable(uniqueFields.get(matField.getName()).toString()).orElse("")); |
| | | locDetlFieldService.save(locDetlField); |
| | | } |
| | | |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | * 是否删除 1: 是 0: 否 |
| | | */ |
| | | @ApiModelProperty(value= "是否删除 1: 是 0: 否 ") |
| | | @TableLogic |
| | | private Integer deleted; |
| | | |
| | | /** |
New file |
| | |
| | | package com.zy.asrs.wms.asrs.entity.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Data |
| | | public class LocAdjustParam { |
| | | |
| | | private String locNo; |
| | | |
| | | private List<Map<String, Object>> detls; |
| | | |
| | | } |
| | |
| | | |
| | | void locDetlFreeze(LocDetlFreezeParam param); |
| | | |
| | | void removeLocDetl(Long locId); |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void removeLocDetl(Long locId) { |
| | | List<LocDetl> locDetls = this.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, locId)); |
| | | for (LocDetl locDetl : locDetls) { |
| | | boolean remove = locDetlFieldService.remove(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId())); |
| | | if (!remove) { |
| | | throw new CoolException("扩展字段删除失败"); |
| | | } |
| | | |
| | | boolean result = this.removeById(locDetl.getId()); |
| | | if (!result) { |
| | | throw new CoolException("明细删除失败"); |
| | | } |
| | | } |
| | | } |
| | | } |