新增入库模块
parent
f717e63946
commit
03eda3fa78
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import {SmartEnum} from '/@/types/smart-enum';
|
||||
|
||||
//单据类型
|
||||
export const ASN_ORDER_TYPE_ENUM: SmartEnum<string> = {
|
||||
PURCHASE: {
|
||||
value: 'PURCHASE',
|
||||
|
|
@ -19,6 +20,35 @@ export const ASN_ORDER_TYPE_ENUM: SmartEnum<string> = {
|
|||
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 {
|
||||
ASN_ORDER_TYPE_ENUM,
|
||||
ASN_ORDER_STATUS_ENUM
|
||||
};
|
||||
|
|
|
|||
|
|
@ -62,6 +62,11 @@ async function queryData() {
|
|||
disabledFlag: props.disabledFlag
|
||||
});
|
||||
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']);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
-->
|
||||
<template>
|
||||
<div class="detail-header">
|
||||
<a-page-header :title="'添加入库单'" :avatar="{ src: logo }">
|
||||
<a-page-header :title="form.asnId ? '编辑入库单' : '添加入库单'" :avatar="{ src: '' }">
|
||||
<template #extra>
|
||||
<a-button @click="onSubmit" type="primary">
|
||||
<template #icon>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
</template>
|
||||
保存
|
||||
</a-button>
|
||||
<a-button @click="onSubmit" type="primary" danger>
|
||||
<a-button @click="onBack" type="primary" danger>
|
||||
<template #icon>
|
||||
<ArrowLeftOutlined/>
|
||||
</template>
|
||||
|
|
@ -21,11 +21,11 @@
|
|||
</template>
|
||||
<div>
|
||||
<a-form ref="formRef" :model="form" :rules="rules">
|
||||
|
||||
<a-row :gutter="24">
|
||||
<a-col :span="8">
|
||||
<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-col>
|
||||
<a-col :span="8">
|
||||
|
|
@ -44,7 +44,8 @@
|
|||
<a-row :gutter="24">
|
||||
<a-col :span="8">
|
||||
<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-col>
|
||||
<a-col :span="4">
|
||||
|
|
@ -60,7 +61,7 @@
|
|||
|
||||
<a-col :span="8">
|
||||
<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-col>
|
||||
|
||||
|
|
@ -75,7 +76,6 @@
|
|||
</a-row>
|
||||
|
||||
|
||||
|
||||
</a-form>
|
||||
</div>
|
||||
</a-page-header>
|
||||
|
|
@ -100,26 +100,27 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import _ from 'lodash';
|
||||
import {computed, onMounted, reactive, ref} from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { enterpriseApi } from '/@/api/business/oa/enterprise-api';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import {onMounted, reactive, ref} from 'vue';
|
||||
import {useRoute, useRouter} from 'vue-router';
|
||||
import DataTracer from '/@/components/support/data-tracer/index.vue';
|
||||
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 SmartEnumSelect from "/@/components/framework/smart-enum-select/index.vue";
|
||||
import AddressSelect from "/@/views/business/base/address/address-select.vue";
|
||||
import dayjs from 'dayjs';
|
||||
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 formDefault = {
|
||||
asnId: undefined,//入库单id
|
||||
customerId: undefined, //客户
|
||||
customerNumber: undefined, //客户订单号
|
||||
orderType: undefined,//单据类型
|
||||
orderDate: dayjs(),//订单日期
|
||||
orderDate: dayjs().format('YYYY-MM-DD'),//订单日期
|
||||
addressId: undefined,//收货单位
|
||||
person: undefined,//联系人
|
||||
telephone: undefined,//电话
|
||||
|
|
@ -138,7 +139,14 @@ const rules = {
|
|||
|
||||
};
|
||||
|
||||
//选择
|
||||
//选择客户
|
||||
function changeCustomerSelect(selectValue: any) {
|
||||
if (selectValue) {
|
||||
form.customerId = selectValue.customerId;
|
||||
}
|
||||
}
|
||||
|
||||
//选择收货单位
|
||||
function changeAddressSelect(selectValue: any) {
|
||||
if (selectValue) {
|
||||
form.addressId = selectValue.addressId;
|
||||
|
|
@ -148,49 +156,70 @@ function changeAddressSelect(selectValue: any) {
|
|||
}
|
||||
}
|
||||
|
||||
//数据展示
|
||||
const route = useRoute();
|
||||
let enterpriseId = ref();
|
||||
onMounted(() => {
|
||||
if (route.query.enterpriseId) {
|
||||
enterpriseId.value = Number(route.query.enterpriseId);
|
||||
getDetail();
|
||||
//获取路由传过来的参数
|
||||
const id = route.query.id;
|
||||
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() {
|
||||
try {
|
||||
await formRef.value.validateFields();
|
||||
await save();
|
||||
} catch (err) {
|
||||
message.error('参数验证错误,请仔细填写表单数据!');
|
||||
}
|
||||
}
|
||||
|
||||
// 详情
|
||||
let detail = ref({});
|
||||
|
||||
async function getDetail() {
|
||||
//保存/编辑
|
||||
async function save() {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
let result = await enterpriseApi.detail(enterpriseId.value);
|
||||
detail.value = result.data;
|
||||
} catch (error) {
|
||||
smartSentry.captureError(error);
|
||||
if (form.asnId) {
|
||||
let res = await asnApi.update(form);
|
||||
form.asnId = res.data.asnId;
|
||||
} else {
|
||||
let res = await asnApi.add(form);
|
||||
form.asnId = res.data.asnId;
|
||||
}
|
||||
message.success('操作成功');
|
||||
} catch (err) {
|
||||
smartSentry.captureError(err);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
|
||||
//返回
|
||||
let router = useRouter();
|
||||
|
||||
const logo = computed(() => {
|
||||
if (!detail.value) {
|
||||
return '';
|
||||
}
|
||||
if (!_.isEmpty(detail.value.enterpriseLogo)) {
|
||||
return detail.value.enterpriseLogo[0].fileUrl;
|
||||
}
|
||||
return '';
|
||||
function onBack() {
|
||||
router.push({
|
||||
path: '/receive/asn/asn-list',
|
||||
query: {refresh: '1'}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
|||
|
|
@ -67,6 +67,16 @@
|
|||
>
|
||||
<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'">
|
||||
<div class="smart-table-operate">
|
||||
|
|
@ -107,7 +117,7 @@
|
|||
</a-card>
|
||||
</template>
|
||||
<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 {SmartLoading} from '/@/components/framework/smart-loading';
|
||||
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 {asnApi} from '/@/api/business/receive/asn/asn-api';
|
||||
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',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '客户',
|
||||
dataIndex: 'customerName',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '入库单号',
|
||||
dataIndex: 'asnNumber',
|
||||
|
|
@ -146,8 +161,8 @@ const columns = ref([
|
|||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '收货地址',
|
||||
dataIndex: 'addressId',
|
||||
title: '收货单位',
|
||||
dataIndex: 'name',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
|
|
@ -174,7 +189,7 @@ const columns = ref([
|
|||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
fixed: 'right',
|
||||
width: 90,
|
||||
width: 140,
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
@ -222,15 +237,18 @@ async function queryData() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
onMounted(queryData);
|
||||
|
||||
// ---------------------------- 添加/修改 ----------------------------
|
||||
let router = useRouter();
|
||||
function showForm() {
|
||||
|
||||
function showForm(data: any) {
|
||||
const id = Date.now().toString(); // 生成一个唯一标识符
|
||||
//将数据存储到sessionStorage中
|
||||
sessionStorage.setItem(id, JSON.stringify(data));
|
||||
router.push({
|
||||
path: '/receive/asn/asn-form',
|
||||
query: { enterpriseId: 1 }
|
||||
query: {
|
||||
id: id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -304,4 +322,38 @@ async function requestBatchDelete() {
|
|||
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>
|
||||
|
|
|
|||
|
|
@ -48,18 +48,18 @@ Caffeine :
|
|||
|
||||
//------------------------ 删除 ---------------------
|
||||
|
||||
async function remove(key) {
|
||||
async function remove(key: string) {
|
||||
try {
|
||||
await cacheApi.remove(key);
|
||||
message.success('删除成功');
|
||||
ajaxQuery();
|
||||
await ajaxQuery();
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------ 获取所有key ---------------------
|
||||
async function getAllKeys(cacheName) {
|
||||
async function getAllKeys(cacheName:String) {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
let res = await cacheApi.getKeys(cacheName);
|
||||
|
|
|
|||
Loading…
Reference in New Issue