<template>
|
<PageWrapper
|
class="high-form"
|
:title="t('盘点管理')"
|
:content="t('这是盘点管理页面。')"
|
@back="goBack"
|
>
|
<a-card :title="t('盘点信息')" :bordered="false">
|
<BasicForm @register="register">
|
<template #add="{ field }">
|
<a-button
|
v-if="field"
|
class="mt-1 ml-1"
|
size="small"
|
@click="handleSelectItem"
|
preIcon="search|svg"
|
/>
|
<ItemModal @register="registerItemAdd" @success="handleSuccess" />
|
</template>
|
</BasicForm>
|
<div class="ml-10">
|
<a-button type="primary" @click="handleStartCount"> {{ t('盘点启动') }} </a-button>
|
|
<a-button type="primary" @click="handleStopCount"> {{ t('盘点暂停') }} </a-button>
|
|
<a-button type="primary" @click="handleEndCount"> {{ t('盘点结束') }} </a-button>
|
|
<a-button type="primary" @click="handleRevokeCount"> {{ t('盘点作废') }} </a-button>
|
</div>
|
</a-card>
|
<a-card :title="t('盘点明细')" :bordered="false" class="!mt-5">
|
<div>
|
<!-- :columns="dtlColumns"
|
:dataSource="data" -->
|
<PageWrapper dense contentFullHeight contentClass="flex">
|
<WareHouseTree
|
class="w-1/4 xl:w-1/5"
|
:disabledTree="disabledTree"
|
@select="handleSelect"
|
@gettree="handleCheck"
|
/>
|
<BasicTable
|
class="w-3/4 xl:w-4/5"
|
:columns="dtlColumns"
|
:dataSource="count_data"
|
ref="tableRef"
|
:canResize="canResize"
|
:loading="Tableloading"
|
:striped="striped"
|
:bordered="border"
|
:pagination="pagination"
|
showTableSetting
|
>
|
<template #toolbar>
|
<a-button type="primary" @click="handleCreate"> {{ t('预览') }} </a-button>
|
<a-button type="primary" @click="handleMdtl"> {{ t('物品明细') }} </a-button>
|
<!-- <a-button type="primary" @click="handleLdtl"> {{ t('储位明细') }} </a-button> -->
|
<a-button type="primary" @click="handleSum"> {{ t('结果汇总') }} </a-button>
|
<CountLdtlModal @register="registerCountLdtl" @success="handleSuccess" />
|
<CountMdtlModal @register="registerCountMdtl" @success="handleSuccess" />
|
<CountSumModal @register="registerCountSum" @success="handleSuccess" />
|
</template>
|
<template #action="{ record }">
|
<TableAction
|
:actions="[
|
{
|
icon: 'clarity:note-edit-line',
|
onClick: handleEdit.bind(null, record),
|
},
|
{
|
icon: 'ant-design:delete-outlined',
|
color: 'error',
|
popConfirm: {
|
title: '是否确认删除?',
|
placement: 'left',
|
confirm: handleDelete.bind(null, record),
|
},
|
},
|
]"
|
/>
|
</template>
|
</BasicTable>
|
</PageWrapper>
|
</div>
|
</a-card>
|
|
<template #rightFooter>
|
<a-button class="mr-4" type="info" @click="cancel"> {{ t('取消') }} </a-button>
|
<a-button type="primary" @click="submitAll"> {{ t('提交') }} </a-button>
|
</template>
|
<!-- <CheckruleDrawer @register="registerDrawer" @success="handleSuccess" /> -->
|
<Loading :loading="loading" :tip="tip" />
|
</PageWrapper>
|
</template>
|
<script lang="ts">
|
import { BasicForm, useForm } from '/@/components/Form';
|
import { defineComponent, onMounted, reactive, ref, unref, toRefs } from 'vue';
|
import { useRoute, useRouter } from 'vue-router';
|
import { PageWrapper } from '/@/components/Page';
|
import { Card } from 'ant-design-vue';
|
import { useGo } from '/@/hooks/web/usePage';
|
import { useDrawer } from '/@/components/Drawer';
|
import { BasicTable, TableAction, TableActionType } from '/@/components/Table';
|
import { dtlColumns, newFormSchema } from './inventory.data';
|
import { useTabs } from '/@/hooks/web/useTabs';
|
|
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
import { getWHList } from '/@/api/tigerapi/wms/house';
|
import WareHouseTree from './WareHouseTree.vue';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
import ItemModal from '/@/views/components/ItemModal.vue';
|
import CountLdtlModal from './CountLdtlModal.vue';
|
import CountMdtlModal from './CountMdtlModal.vue';
|
import CountSumModal from './CountSumModal.vue';
|
import { useModal } from '/@/components/Modal';
|
import {
|
SaveInventory,
|
GenerateCount,
|
SummaryCount,
|
getInventorytByPage,
|
CreateBillCode,
|
} from '/@/api/tigerapi/wms/inventory';
|
import { iV_ITEM_COUNT } from '/@/api/tigerapi/model/warehoueseModel';
|
import { formatToDateTime } from '/@/utils/dateUtil';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
import { Loading } from '/@/components/Loading';
|
|
export default defineComponent({
|
name: 'CountDetail',
|
components: {
|
BasicForm,
|
BasicTable,
|
PageWrapper,
|
//CheckruleDrawer,
|
[Card.name]: Card,
|
TableAction,
|
WareHouseTree,
|
ItemModal,
|
CountLdtlModal,
|
CountMdtlModal,
|
CountSumModal,
|
Loading,
|
},
|
setup(props) {
|
const compState = reactive({
|
absolute: false,
|
loading: false,
|
tip: '加载中...',
|
});
|
const count = useRoute();
|
const { t } = useI18n('WMS.Count');
|
const go = useGo();
|
const { createMessage } = useMessage();
|
|
const tableRef = ref<Nullable<TableActionType>>(null);
|
const CountObj = ref(JSON.parse(decodeURI(count.params?.id as string)));
|
const { setTitle } = useTabs();
|
const canResize = ref(false);
|
const Tableloading = ref(false);
|
const striped = ref(true);
|
const border = ref(true);
|
const pagination = ref<any>(false);
|
var disabledTree = ref(0);
|
const tabStore = useMultipleTabStore();
|
const router = useRouter();
|
const [registerItemAdd, { openModal: openItemModal }] = useModal();
|
const [registerCountLdtl, { openModal: openCountLdtlModal }] = useModal();
|
const [registerCountMdtl, { openModal: openCountMdtlModal }] = useModal();
|
const [registerCountSum, { openModal: openCountSumModal }] = useModal();
|
|
const { currentRoute } = router;
|
function getCurrentTab() {
|
const route = unref(currentRoute);
|
return tabStore.getTabList.find((item) => item.fullPath === route.fullPath)!;
|
}
|
const currentTab = getCurrentTab();
|
var _title = CountObj.value.ITEM_CODE == '0' ? t('新增盘点') : t('编辑盘点'); // + RuleObj.value.RULE_CODE;
|
setTitle(_title);
|
const [registerDrawer, { openDrawer }] = useDrawer();
|
const [register, { resetFields, setFieldsValue, validateFields, getFieldsValue, validate }] =
|
useForm({
|
labelWidth: 120,
|
baseColProps: {
|
span: 24,
|
},
|
schemas: newFormSchema,
|
showActionButtonGroup: false,
|
});
|
const [
|
registerTest,
|
{
|
//getFieldsValue: getFieldsValueTest,
|
//validate: validateTestForm,
|
},
|
] = useForm({
|
labelWidth: 120,
|
baseColProps: {
|
span: 24,
|
},
|
//schemas: testSchemas,
|
showActionButtonGroup: false,
|
});
|
// const params: CheckRuleDtlParams = {
|
// RULE_ID: RuleObj.value.RULE_CODE == '0' ? '' : (RuleObj.value.ID as string),
|
// };
|
//const data = ref([] as iBAS_CODE_DTL[]);
|
var checkeds = ref();
|
var treeCode = ref([]);
|
var count_one = ref([]);
|
onMounted(async () => {
|
const billCode = await CreateBillCode();
|
|
treeCode.value = [];
|
resetFields();
|
pagination.value = { pageSize: 12 };
|
//data.value = (await getRuleDtl(params)).Items;
|
|
//根据单据查回数据
|
count_one.value = await getInventorytByPage(CountObj.value.ID);
|
if (billCode != null) {
|
setFieldsValue({
|
COUNT_NO: billCode,
|
});
|
}
|
|
if (count_one.value != undefined) {
|
setFieldsValue(count_one.value[0]);
|
if (
|
count_one.value[0]?.WH_IDS != undefined ||
|
count_one.value[0]?.REGION_IDS != undefined ||
|
count_one.value[0]?.SHELF_IDS != undefined
|
) {
|
var wh = count_one.value[0].WH_IDS.split(',');
|
var region = count_one.value[0].REGION_IDS.split(',');
|
var shelf = count_one.value[0].SHELF_IDS.split(',');
|
|
var sum = wh.concat(region);
|
sum = sum.concat(shelf);
|
treeCode.value.push(sum as never);
|
checkeds.value.setCheckedKeys(treeCode.value[0]);
|
// var check = checkeds.getCheckedKeys()
|
// if (check != '') {
|
// handleCreate();
|
// }
|
var data = await validateFields();
|
count_data.value = await SummaryCount(data);
|
if (count_one.value[0].STATUS != 0) {
|
disabledTree.value = count_one.value[0].STATUS;
|
}
|
Tableloading.value = false;
|
}
|
}
|
});
|
function getTableAction() {
|
const tableAction = unref(tableRef);
|
if (!tableAction) {
|
throw new Error('tableAction is null');
|
}
|
return tableAction;
|
}
|
|
var keys = ref([]);
|
var count_data = ref([] as iV_ITEM_COUNT[]);
|
//提交
|
async function submitAll() {
|
var data = await validateFields();
|
if (disabledTree.value === 0) {
|
try {
|
compState.absolute = true;
|
compState.loading = true;
|
//var data = await validateFields();
|
keys.value = [];
|
checkeds.value.getCheckedKeys().forEach((element) => {
|
keys.value.push(checkeds.value.getNodeById(element) as never);
|
});
|
var wh = [];
|
var region = [];
|
var shelf = [];
|
keys.value.forEach((key) => {
|
if (key != null) {
|
if (key.houseType == 'Warehouse') {
|
wh.push(key.id as never);
|
}
|
if (key.houseType == 'Region') {
|
region.push(key.id as never);
|
}
|
if (key.houseType == 'Shelf') {
|
shelf.push(key.id as never);
|
}
|
}
|
});
|
data.WH_IDS = wh.join(',');
|
data.REGION_IDS = region.join(',');
|
data.SHELF_IDS = shelf.join(',');
|
var Apiaction = await SaveInventory(data, false);
|
if (Apiaction.IsSuccessed) {
|
createMessage.info(data.COUNT_NO + ':' + t('盘点单保存成功'));
|
}
|
if (keys.value[0] != '') {
|
var apiaction = await GenerateCount(data);
|
if (apiaction.IsSuccessed) {
|
createMessage.info(data.COUNT_NO + ':' + t('盘点单明细保存成功'));
|
}
|
compState.loading = false;
|
}
|
} catch (error) {
|
compState.loading = false;
|
}
|
} else {
|
createMessage.error(data.COUNT_NO + ':' + t('该盘点已经开始盘点,无法提交修改'));
|
}
|
}
|
async function cancel() {
|
try {
|
tabStore.closeTab(currentTab, router);
|
} catch (error) {}
|
}
|
//生成
|
async function handleCreate() {
|
if (disabledTree.value === 0) {
|
Tableloading.value = true;
|
keys.value = [];
|
var data = await validateFields();
|
|
//data.MIRROR_DATE=now.getFullYear()+'-'+(now.getMonth()+1)+'-'+now.getDate()+' '+now.getHours()+':'+now.getMinutes()+':'+now.getSeconds()
|
checkeds.value.getCheckedKeys().forEach((element) => {
|
keys.value.push(checkeds.value.getSelectedNode(element) as never);
|
});
|
var wh = [];
|
var region = [];
|
var shelf = [];
|
var location = [];
|
keys.value.forEach((key) => {
|
if (key?.houseType == 'Warehouse') {
|
wh.push(key.id as never);
|
}
|
if (key?.houseType == 'Region') {
|
region.push(key.id as never);
|
}
|
if (key?.houseType == 'Shelf') {
|
shelf.push(key.id as never);
|
}
|
if (key?.houseType == 'Location') {
|
location.push(key.id as never);
|
}
|
});
|
data.WH_IDS = wh.join(',');
|
data.REGION_IDS = region.join(',');
|
data.SHELF_IDS = shelf.join(',');
|
data.LOCATION_IDS = location.join(',');
|
count_data.value = await SummaryCount(data);
|
setFieldsValue({
|
MIRROR_DATE: formatToDateTime(new Date()),
|
});
|
if (count_data.value.length > 0) {
|
createMessage.info(data.COUNT_NO + ':' + t('已生成'));
|
Tableloading.value = false;
|
} else {
|
createMessage.info(data.COUNT_NO + ':' + t('没有数据生成'));
|
}
|
}
|
}
|
|
async function handleCheck(data) {
|
checkeds.value = data;
|
}
|
|
function handleEdit(record: Recordable) {
|
openDrawer(true, {
|
record,
|
isUpdate: true,
|
});
|
}
|
|
function handleDelete(record: Recordable) {
|
// var _data = data.value.map((item) => {
|
// return item;
|
// });
|
}
|
//获取物料列表
|
function handleSuccess(d, u) {
|
setFieldsValue({
|
ITEM_CODE_LIST: d.values.values,
|
});
|
}
|
//获取树结构
|
var WareHouse = ref(false);
|
var Region = ref(false);
|
var Shelf = ref(false);
|
async function handleSelect(WareHouseCode) {
|
// WareHouse.value=false;
|
// Region.value=false;
|
// Shelf.value=false;
|
await handleTree(WareHouseCode);
|
WareHouse.value = WareHouseCode.slice(0, 1) == 'W' ? true : false;
|
Region.value = WareHouseCode.slice(0, 1) == 'R' ? true : false;
|
Shelf.value = WareHouseCode.slice(0, 1) == 'S' ? true : false;
|
|
console.log(WareHouseCode, 15);
|
//reload();
|
}
|
//点击打开物料列表框
|
function handleSelectItem() {
|
openItemModal(true, {
|
data: 'content',
|
info: 'Info',
|
});
|
}
|
var Wdata = ref();
|
var Rdata = ref();
|
var Sdata = ref();
|
async function handleTree(record: string) {
|
var Code = record;
|
var data = await getWHList(Code);
|
if (record.slice(0, 1) == 'W') {
|
Wdata.value = data;
|
WareHouse.value = false;
|
}
|
if (record.slice(0, 1) == 'R') {
|
Rdata.value = data;
|
Region.value = false;
|
}
|
if (record.slice(0, 1) == 'S') {
|
Sdata.value = data;
|
Shelf.value = false;
|
}
|
}
|
function goBack() {
|
// 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页
|
go('/inventory');
|
}
|
//按类型盘点:物品
|
async function handleMdtl() {
|
var data = await validateFields();
|
openCountMdtlModal(true, {
|
data: data,
|
info: 'Info',
|
});
|
}
|
//储位
|
async function handleLdtl() {
|
var data = await validateFields();
|
openCountLdtlModal(true, {
|
data: data,
|
info: 'Info',
|
});
|
}
|
//汇总
|
async function handleSum() {
|
var data = await validateFields();
|
openCountSumModal(true, {
|
data: data,
|
info: 'Info',
|
});
|
}
|
//启动盘点
|
async function handleStartCount() {
|
undefined;
|
if (disabledTree.value === 0 || disabledTree.value === 2) {
|
var data = await validateFields();
|
data.STATUS = 1;
|
data.BEGIN_DATE = formatToDateTime(new Date());
|
var apiAction = await SaveInventory(data, true);
|
if (apiAction.IsSuccessed) {
|
createMessage.info(data.COUNT_NO + ':' + t('启动成功'));
|
disabledTree.value = 1;
|
}
|
} else {
|
createMessage.error(t('启动失败,单据不是新建状态'));
|
}
|
}
|
//暂停
|
async function handleStopCount() {
|
if (disabledTree.value === 1) {
|
var data = await validateFields();
|
data.STATUS = 2;
|
var apiAction = await SaveInventory(data, true);
|
if (apiAction.IsSuccessed) {
|
createMessage.info(data.COUNT_NO + ':' + t('已暂停'));
|
disabledTree.value = 2;
|
}
|
} else {
|
createMessage.error(t('暂停失败,单据没启动'));
|
}
|
}
|
//结束
|
async function handleEndCount() {
|
if (disabledTree.value === 1) {
|
var data = await validateFields();
|
data.STATUS = 3;
|
data.END_DATE = formatToDateTime(new Date());
|
var apiAction = await SaveInventory(data, true);
|
if (apiAction.IsSuccessed) {
|
createMessage.info(data.COUNT_NO + ':' + t('结束成功'));
|
disabledTree.value = 3;
|
}
|
} else {
|
createMessage.error(t('结束失败,单据没启动'));
|
}
|
}
|
//作废
|
async function handleRevokeCount() {
|
var data = await validateFields();
|
data.STATUS = 4;
|
var apiAction = await SaveInventory(data, true);
|
if (apiAction.IsSuccessed) {
|
createMessage.info(data.COUNT_NO + ':' + t('作废成功'));
|
disabledTree.value = 4;
|
}
|
}
|
return {
|
t,
|
dtlColumns,
|
register,
|
registerTest,
|
resetFields,
|
setFieldsValue,
|
getFieldsValue,
|
validate,
|
CountObj,
|
handleCheck,
|
//data,
|
treeCode,
|
count_data,
|
canResize,
|
Tableloading,
|
striped,
|
border,
|
pagination,
|
disabledTree,
|
registerDrawer,
|
submitAll,
|
cancel,
|
tableRef,
|
goBack,
|
handleCreate,
|
handleEdit,
|
handleDelete,
|
handleSuccess,
|
handleSelect,
|
handleSelectItem,
|
registerItemAdd,
|
registerCountLdtl,
|
registerCountMdtl,
|
registerCountSum,
|
handleSum,
|
handleLdtl,
|
handleMdtl,
|
handleRevokeCount,
|
handleEndCount,
|
handleStartCount,
|
handleStopCount,
|
...toRefs(compState),
|
};
|
},
|
});
|
</script>
|
<style lang="less" scoped>
|
.high-form {
|
padding-bottom: 48px;
|
}
|
</style>
|