新增入库模块

main
HUOJIN\92525 2025-03-27 15:43:02 +08:00
parent f717e63946
commit 03eda3fa78
5 changed files with 180 additions and 64 deletions

View File

@ -5,6 +5,7 @@
import {SmartEnum} from '/@/types/smart-enum'; import {SmartEnum} from '/@/types/smart-enum';
//单据类型
export const ASN_ORDER_TYPE_ENUM: SmartEnum<string> = { export const ASN_ORDER_TYPE_ENUM: SmartEnum<string> = {
PURCHASE: { PURCHASE: {
value: 'PURCHASE', value: 'PURCHASE',
@ -19,6 +20,35 @@ export const ASN_ORDER_TYPE_ENUM: SmartEnum<string> = {
desc: '其他入库', desc: '其他入库',
}, },
}; };
//单据状态
export const ASN_ORDER_STATUS_ENUM: SmartEnum<string> = {
CREATED: {
value: 'CREATED',
desc: '已创建',
},
APPROVING: {
value: 'APPROVING',
desc: '已提交',
},
APPROVED: {
value: 'APPROVED',
desc: '已审核',
},
IN_PROGRESS: {
value: 'IN_PROGRESS',
desc: '入库中',
},
COMPLETED: {
value: 'COMPLETED',
desc: '已完成',
},
CANCELLED: {
value: 'CANCELLED',
desc: '已取消',
},
};
export default { export default {
ASN_ORDER_TYPE_ENUM, ASN_ORDER_TYPE_ENUM,
ASN_ORDER_STATUS_ENUM
}; };

View File

@ -62,6 +62,11 @@ async function queryData() {
disabledFlag: props.disabledFlag disabledFlag: props.disabledFlag
}); });
customers.value = res.data; customers.value = res.data;
//
/* if (customers.value.length > 0 &&!props.value) {
selectValue.value = customers.value[0].customerId;
handleChange(selectValue.value);
}*/
} }
const emit = defineEmits(['update:value', 'change']); const emit = defineEmits(['update:value', 'change']);

View File

@ -4,7 +4,7 @@
--> -->
<template> <template>
<div class="detail-header"> <div class="detail-header">
<a-page-header :title="'添加入库单'" :avatar="{ src: logo }"> <a-page-header :title="form.asnId ? '编辑入库单' : '添加入库单'" :avatar="{ src: '' }">
<template #extra> <template #extra>
<a-button @click="onSubmit" type="primary"> <a-button @click="onSubmit" type="primary">
<template #icon> <template #icon>
@ -12,20 +12,20 @@
</template> </template>
保存 保存
</a-button> </a-button>
<a-button @click="onSubmit" type="primary" danger> <a-button @click="onBack" type="primary" danger>
<template #icon> <template #icon>
<ArrowLeftOutlined /> <ArrowLeftOutlined/>
</template> </template>
返回 返回
</a-button> </a-button>
</template> </template>
<div> <div>
<a-form ref="formRef" :model="form" :rules="rules"> <a-form ref="formRef" :model="form" :rules="rules">
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="8"> <a-col :span="8">
<a-form-item label="客户" name="customerId"> <a-form-item label="客户" name="customerId">
<CustomerSelect style="width: 100%" v-model:value="form.customerId" :disabled-flag="true" @change="changeCustomerSelect"/> <CustomerSelect style="width: 100%" v-model:value="form.customerId" :disabled-flag="true"
@change="changeCustomerSelect"/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="8"> <a-col :span="8">
@ -44,7 +44,8 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="8"> <a-col :span="8">
<a-form-item label="单位" name="addressId"> <a-form-item label="单位" name="addressId">
<AddressSelect style="width: 100%" v-model:value="form.addressId" :disabled-flag="true" @change="changeAddressSelect"/> <AddressSelect style="width: 100%" v-model:value="form.addressId" :disabled-flag="true"
@change="changeAddressSelect"/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="4"> <a-col :span="4">
@ -60,22 +61,21 @@
<a-col :span="8"> <a-col :span="8">
<a-form-item label="订单日期" name="orderDate"> <a-form-item label="订单日期" name="orderDate">
<a-date-picker style="width: 100%" format="YYYY-MM-DD" v-model:value="form.orderDate" /> <a-date-picker style="width: 100%" value-format="YYYY-MM-DD" v-model:value="form.orderDate"/>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row > <a-row>
<a-col :span="24"> <a-col :span="24">
<a-form-item label="地址" name="address"> <a-form-item label="地址" name="address">
<a-textarea v-model:value="form.address" style="width: 100%; height: 100px; outline: none;" auto-size /> <a-textarea v-model:value="form.address" style="width: 100%; height: 100px; outline: none;" auto-size/>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
</div> </div>
</a-page-header> </a-page-header>
@ -83,16 +83,16 @@
<a-card class="smart-margin-top10" size="small"> <a-card class="smart-margin-top10" size="small">
<a-tabs> <a-tabs>
<a-tab-pane key="employee" tab="员工信息"> <a-tab-pane key="employee" tab="员工信息">
<EmployeeList :enterpriseId="enterpriseId" /> <EmployeeList :enterpriseId="enterpriseId"/>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="bank" tab="银行信息"> <a-tab-pane key="bank" tab="银行信息">
<BankList :enterpriseId="enterpriseId" /> <BankList :enterpriseId="enterpriseId"/>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="invoice" tab="发票信息"> <a-tab-pane key="invoice" tab="发票信息">
<InvoiceList :enterpriseId="enterpriseId" /> <InvoiceList :enterpriseId="enterpriseId"/>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="dataTracer" tab="变更记录"> <a-tab-pane key="dataTracer" tab="变更记录">
<DataTracer :dataId="enterpriseId" :type="DATA_TRACER_TYPE_ENUM.OA_ENTERPRISE.value" /> <DataTracer :dataId="enterpriseId" :type="DATA_TRACER_TYPE_ENUM.OA_ENTERPRISE.value"/>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</a-card> </a-card>
@ -100,26 +100,27 @@
<script setup lang="ts"> <script setup lang="ts">
import _ from 'lodash'; import _ from 'lodash';
import {computed, onMounted, reactive, ref} from 'vue'; import {onMounted, reactive, ref} from 'vue';
import { useRoute } from 'vue-router'; import {useRoute, useRouter} from 'vue-router';
import { enterpriseApi } from '/@/api/business/oa/enterprise-api';
import { SmartLoading } from '/@/components/framework/smart-loading';
import DataTracer from '/@/components/support/data-tracer/index.vue'; import DataTracer from '/@/components/support/data-tracer/index.vue';
import { DATA_TRACER_TYPE_ENUM } from '/@/constants/support/data-tracer-const'; import {DATA_TRACER_TYPE_ENUM} from '/@/constants/support/data-tracer-const';
import { smartSentry } from '/@/lib/smart-sentry';
import CustomerSelect from "/@/views/business/base/customer/customer-select.vue"; import CustomerSelect from "/@/views/business/base/customer/customer-select.vue";
import SmartEnumSelect from "/@/components/framework/smart-enum-select/index.vue"; import SmartEnumSelect from "/@/components/framework/smart-enum-select/index.vue";
import AddressSelect from "/@/views/business/base/address/address-select.vue"; import AddressSelect from "/@/views/business/base/address/address-select.vue";
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import {message} from "ant-design-vue"; import {message} from "ant-design-vue";
import {SmartLoading} from "/@/components/framework/smart-loading";
import {asnApi} from "/@/api/business/receive/asn/asn-api";
import {smartSentry} from "/@/lib/smart-sentry";
// //
const formRef = ref(); const formRef = ref();
const formDefault = { const formDefault = {
asnId: undefined,//id
customerId: undefined, // customerId: undefined, //
customerNumber: undefined, // customerNumber: undefined, //
orderType: undefined,// orderType: undefined,//
orderDate: dayjs(),// orderDate: dayjs().format('YYYY-MM-DD'),//
addressId: undefined,// addressId: undefined,//
person: undefined,// person: undefined,//
telephone: undefined,// telephone: undefined,//
@ -130,15 +131,22 @@ let form = reactive({...formDefault});
// //
const rules = { const rules = {
customerId: [{ required: true, message: '客户 必填' }], customerId: [{required: true, message: '客户 必填'}],
customerNumber: [{ required: true, message: '客户订单号 必填' }], customerNumber: [{required: true, message: '客户订单号 必填'}],
orderType: [{ required: true, message: '单据类型 必填' }], orderType: [{required: true, message: '单据类型 必填'}],
orderDate: [{ required: true, message: '订单日期 必填' }], orderDate: [{required: true, message: '订单日期 必填'}],
addressId: [{ required: true, message: '收货单位 必填' }], addressId: [{required: true, message: '收货单位 必填'}],
}; };
// //
function changeCustomerSelect(selectValue: any) {
if (selectValue) {
form.customerId = selectValue.customerId;
}
}
//
function changeAddressSelect(selectValue: any) { function changeAddressSelect(selectValue: any) {
if (selectValue) { if (selectValue) {
form.addressId = selectValue.addressId; form.addressId = selectValue.addressId;
@ -148,49 +156,70 @@ function changeAddressSelect(selectValue: any) {
} }
} }
//
const route = useRoute(); const route = useRoute();
let enterpriseId = ref();
onMounted(() => { onMounted(() => {
if (route.query.enterpriseId) { //
enterpriseId.value = Number(route.query.enterpriseId); const id = route.query.id;
getDetail(); if (typeof id === 'string') {
// sessionStorage
const res = JSON.parse(sessionStorage.getItem(id) as string);
//
if (res.asnId) {
form.asnId = res.asnId;
form.customerId = res.customerId;
form.customerNumber = res.customerNumber;
form.orderType = res.orderType;
form.orderDate = res.orderDate;
form.addressId = res.addressId;
form.person = res.person;
form.telephone = res.telephone;
form.address = res.address;
} }
sessionStorage.removeItem(id); //
}
}); });
//
// //
async function onSubmit() { async function onSubmit() {
try { try {
await formRef.value.validateFields(); await formRef.value.validateFields();
await save();
} catch (err) { } catch (err) {
message.error('参数验证错误,请仔细填写表单数据!'); message.error('参数验证错误,请仔细填写表单数据!');
} }
} }
// ///
let detail = ref({}); async function save() {
SmartLoading.show();
async function getDetail() {
try { try {
let result = await enterpriseApi.detail(enterpriseId.value); if (form.asnId) {
detail.value = result.data; let res = await asnApi.update(form);
} catch (error) { form.asnId = res.data.asnId;
smartSentry.captureError(error); } else {
let res = await asnApi.add(form);
form.asnId = res.data.asnId;
}
message.success('操作成功');
} catch (err) {
smartSentry.captureError(err);
} finally { } finally {
SmartLoading.hide(); SmartLoading.hide();
} }
} }
//
let router = useRouter();
const logo = computed(() => { function onBack() {
if (!detail.value) { router.push({
return ''; path: '/receive/asn/asn-list',
} query: {refresh: '1'}
if (!_.isEmpty(detail.value.enterpriseLogo)) { });
return detail.value.enterpriseLogo[0].fileUrl; }
}
return '';
});
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@ -67,6 +67,16 @@
> >
<template #bodyCell="{ text, record, column }"> <template #bodyCell="{ text, record, column }">
<template v-if="column.dataIndex === 'orderType'">
{{ $smartEnumPlugin.getDescByValue('ASN_ORDER_TYPE_ENUM', text) }}
</template>
<template v-if="column.dataIndex === 'status'">
<a-tag :color="getStatusColor(text)">
{{ $smartEnumPlugin.getDescByValue('ASN_ORDER_STATUS_ENUM', text) }}
</a-tag>
</template>
<template v-if="column.dataIndex === 'action'"> <template v-if="column.dataIndex === 'action'">
<div class="smart-table-operate"> <div class="smart-table-operate">
@ -107,7 +117,7 @@
</a-card> </a-card>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {reactive, ref, onMounted} from 'vue'; import {reactive, ref, onMounted, watch} from 'vue';
import {message, Modal} from 'ant-design-vue'; import {message, Modal} from 'ant-design-vue';
import {SmartLoading} from '/@/components/framework/smart-loading'; import {SmartLoading} from '/@/components/framework/smart-loading';
import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const'; import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const';
@ -115,7 +125,7 @@ import {smartSentry} from '/@/lib/smart-sentry';
import TableOperator from '/@/components/support/table-operator/index.vue'; import TableOperator from '/@/components/support/table-operator/index.vue';
import {asnApi} from '/@/api/business/receive/asn/asn-api'; import {asnApi} from '/@/api/business/receive/asn/asn-api';
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const"; import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
import {useRouter} from "vue-router"; import {useRoute, useRouter} from "vue-router";
// ---------------------------- ---------------------------- // ---------------------------- ----------------------------
@ -125,6 +135,11 @@ const columns = ref([
dataIndex: 'asnId', dataIndex: 'asnId',
ellipsis: true, ellipsis: true,
}, },
{
title: '客户',
dataIndex: 'customerName',
ellipsis: true,
},
{ {
title: '入库单号', title: '入库单号',
dataIndex: 'asnNumber', dataIndex: 'asnNumber',
@ -146,8 +161,8 @@ const columns = ref([
ellipsis: true, ellipsis: true,
}, },
{ {
title: '收货地址', title: '收货单位',
dataIndex: 'addressId', dataIndex: 'name',
ellipsis: true, ellipsis: true,
}, },
{ {
@ -174,7 +189,7 @@ const columns = ref([
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
fixed: 'right', fixed: 'right',
width: 90, width: 140,
}, },
]); ]);
@ -222,21 +237,24 @@ async function queryData() {
} }
} }
onMounted(queryData);
// ---------------------------- / ---------------------------- // ---------------------------- / ----------------------------
let router = useRouter(); let router = useRouter();
function showForm() {
function showForm(data: any) {
const id = Date.now().toString(); //
//sessionStorage
sessionStorage.setItem(id, JSON.stringify(data));
router.push({ router.push({
path: '/receive/asn/asn-form', path: '/receive/asn/asn-form',
query: { enterpriseId: 1 } query: {
id: id
}
}); });
} }
// ---------------------------- ---------------------------- // ---------------------------- ----------------------------
// //
function onDelete(data:object) { function onDelete(data: object) {
Modal.confirm({ Modal.confirm({
title: '提示', title: '提示',
content: '确定要删除选吗?', content: '确定要删除选吗?',
@ -252,7 +270,7 @@ function onDelete(data:object) {
} }
// //
async function requestDelete(data:any) { async function requestDelete(data: any) {
SmartLoading.show(); SmartLoading.show();
try { try {
@ -304,4 +322,38 @@ async function requestBatchDelete() {
SmartLoading.hide(); SmartLoading.hide();
} }
} }
//orange green purple success processing error default warning
function getStatusColor(status: string) {
//
switch (status) {
case 'CREATED':
return 'orange';
case 'APPROVING':
return 'cyan';
case 'APPROVED':
return 'purple';
case 'IN_PROGRESS':
return 'blue';
case 'COMPLETED':
return 'green';
case 'CANCELLED':
return 'red';
default:
return 'orange';
}
}
//asn-form
const route = useRoute();
watch(
() => route.query,
(newValue) => {
if (newValue.refresh === '1') {
queryData();
}
}
);
onMounted(queryData);
</script> </script>

View File

@ -48,18 +48,18 @@ Caffeine
//------------------------ --------------------- //------------------------ ---------------------
async function remove(key) { async function remove(key: string) {
try { try {
await cacheApi.remove(key); await cacheApi.remove(key);
message.success('删除成功'); message.success('删除成功');
ajaxQuery(); await ajaxQuery();
} catch (e) { } catch (e) {
smartSentry.captureError(e); smartSentry.captureError(e);
} }
} }
//------------------------ key --------------------- //------------------------ key ---------------------
async function getAllKeys(cacheName) { async function getAllKeys(cacheName:String) {
SmartLoading.show(); SmartLoading.show();
try { try {
let res = await cacheApi.getKeys(cacheName); let res = await cacheApi.getKeys(cacheName);