master
吴普建 10 months ago
parent ff58217550
commit a7d245c9ab

@ -28,3 +28,8 @@ export const editSaleOrder = (data: any) => {
export const getSaleOrderAll = () => {
return request.get('/md/mes/md/mdSaleOrder/selectAll');
};
export const approveSaleOrder = (data: any) => {
return request.post('/md/mes/md/mdSaleOrder/approve', data);
}

@ -19,7 +19,7 @@ declare namespace Auth {
/** 用户头像 */
avatar: '';
nickName?: string;
roles: [];
roles: string[];
// 用户权限
permissions: [];
sex: string;

@ -855,78 +855,6 @@ const columns: Ref<DataTableColumns<Procure.rawProcureList.columns>> = ref([
</NPopconfirm>
</NSpace>
)
// const Btn: JSX.Element[] = [];
// console.log(row.status)
// if (row.status === 'APPROVE') {
// Btn.push(
// useBtn(
// () => {
// // row.status = 'DISTRIBUTE';
// sendPurchase({ ...row, status: 'DISTRIBUTE' }).then(res => {
// console.log(res);
// if (res.code === 200) {
// message.success('');
// init();
// }
// });
// },
// 'send',
// 'tiny'
// )
// );
// }else if(row.status === 'PREAUDIT') {
// Btn.push(
// useEditBtn(
// () => {
// editFlag.value = false;
// auditFlag.value = true;
// getPurchaseTop(row.purchaseId as string).then(res => {
// dialogForm.value = deepClone(res.data);
// if (res.data.lineList.length > 0) {
// panels.value = [];
// res.data.lineList.forEach((item, index) => {
// panels.value.push({
// name: `${index + 1}`,
// form: { ...item, deliveryDate: new Date(item.deliveryDate), numMeasureName: item.unitOfMeasure }
// });
// });
// }
// showDialog.value = true;
// });
// },
// 'tiny',
// ''
// )
// )
// }
// Btn.push(
// ...[
// useInfoBtn(
// () => {
// detail.value = true;
// detailLoading.value = true;
// getPurchaseDetail(row.purchaseId as string).then(res => {
// detailLoading.value = false;
//
// detailData.value = res.rows;
// });
// },
// 'tiny',
// ''
// ),
// useDelBtn(() => {
// delPurchase(row.purchaseId as string).then(res => {
// if (res.code === 200) {
// message.success('');
// init();
// }
// });
// }, 'tiny')
// ]
// );
// return Btn;
}
}
]);

@ -2,7 +2,7 @@
<div>
<my-card title="搜索条件" search>
<n-form inline>
<n-form-item label="辅料类型">
<n-form-item label="订单类型">
<n-select
v-model:value="searchForm.orderType"
class="w-180px"
@ -12,7 +12,7 @@
/>
</n-form-item>
<n-form-item label="订单编号">
<n-input v-model:value="searchForm.orderCode" placeholder="请输入辅料型号"></n-input>
<n-input v-model:value="searchForm.orderCode" placeholder="请输入订单编号"></n-input>
</n-form-item>
<n-form-item>
<component
@ -30,12 +30,28 @@
</n-form-item>
</n-form>
</my-card>
<!-- <my-card title="销售订单列表">-->
<!-- <template #right>-->
<!-- <div>-->
<!-- <CxColumns v-model:columns="columns" />-->
<!-- </div>-->
<!-- </template>-->
<!-- <n-data-table-->
<!-- :loading="loading"-->
<!-- :columns="columns"-->
<!-- :data="data"-->
<!-- :scroll-x="dataTableConfig.scrollWidth(columns)"-->
<!-- :max-height="dataTableConfig.maxHeight"-->
<!-- ></n-data-table>-->
<!-- <my-pagination v-model:search-form="searchForm" @init="init()"></my-pagination>-->
<!-- </my-card>-->
<my-card title="销售订单列表">
<template #right>
<div style="display: flex; align-items: center">
<div>
<n-button color="#8a2be2" size="small" class="mr" :disabled="checked.length === 0" @click="oneClickDelivery">
<ArrowRedo class="mr-1px text-15px w-13px" />
一键下发
<ArrowRedo class="mr-1px text-15px w-13px" />一键下发
</n-button>
<component
:is="
@ -49,25 +65,27 @@
<CxColumns v-model:columns="columns" />
</div>
</template>
<n-data-table
<n-data-table
v-model:checked-row-keys="checkedRowKeys"
:data="data"
:loading="loading"
:row-key="rowKey"
:columns="columns"
:max-height="dataTableConfig.maxHeight"
:scroll-x="dataTableConfig.scrollWidth(columns)"
@update-checked-row-keys="handleCheck"
></n-data-table>
<my-pagination v-model:search-form="searchForm" @init="init"></my-pagination>
</my-card>
<my-dialog
></n-data-table>
<my-pagination v-model:search-form="searchForm" @init="init"></my-pagination>
</my-card>
<my-dialog
:title="flag ? '新增销售订单' : '编辑销售订单'"
:show="dialogFlag"
width="750px"
@cancel="handleCancel"
@submit="handleSubmit"
>
<template #content>
>
<template #content>
<div>
<n-form
ref="addFormRef"
@ -125,16 +143,16 @@
</n-grid>
</n-form>
</div>
</template>
</my-dialog>
<my-dialog
</template>
</my-dialog>
<my-dialog
title="下发工单"
:show="workorderFlag"
height="200px"
@cancel="workorderHandleCancel"
@submit="workorderHandleSubmit"
>
<template #content>
>
<template #content>
<div>
<n-form
ref="addWorkorderFormRef"
@ -155,17 +173,86 @@
</n-form-item>
</n-form>
</div>
</template>
</my-dialog>
</template>
</my-dialog>
<!-- 审批模态框 -->
<!-- 审批模态框 -->
<n-modal
v-model:show="approveModalVisible"
preset="dialog"
title="审批订单"
class="w-700px h-680px"
style="width: 750px; height: 680px;"
:mask-closable="false"
@positive-click="handleApproveSubmit"
@negative-click="handleApproveCancel"
>
<div class="grid grid-cols-2 gap-4">
<div class="col-span-2 p-4 bg-gray-50 rounded-lg">
<h3 class="text-lg font-semibold mb-3">订单详情</h3>
<div class="grid grid-cols-2 gap-4">
<div>
<p class="text-sm text-gray-500">订单类型</p>
<p>{{ currentOrder?.orderType === '0' ? '客户订单' : '备库订单' }}</p>
</div>
<div>
<p class="text-sm text-gray-500">客户名称</p>
<p>{{ currentOrder?.customerName || '-' }}</p>
</div>
<div>
<p class="text-sm text-gray-500">订单编号</p>
<p>{{ currentOrder?.orderCode || '-' }}</p>
</div>
<div>
<p class="text-sm text-gray-500">产品规格</p>
<p>{{ currentOrder?.specification || '-' }}</p>
</div>
<div>
<p class="text-sm text-gray-500">产品型号</p>
<p>{{ currentOrder?.model || '-' }}</p>
</div>
<div>
<p class="text-sm text-gray-500">数量</p>
<p>{{ currentOrder?.weight || '-' }}</p>
</div>
<div>
<p class="text-sm text-gray-500">单位</p>
<p>{{ currentOrder?.measureName || '-' }}</p>
</div>
<div>
<p class="text-sm text-gray-500">交付日期</p>
<p>{{ currentOrder?.payTime || '-' }}</p>
</div>
</div>
</div>
<div class="col-span-6 mt-8" style="width: 600px; overflow: auto;" v-if="viewType == 'APPROVE'">
<n-form ref="approveFormRef" :model="approveForm" :rules="approveRules">
<n-form-item label="审批意见" path="remark" style="width: 100%;">
<n-input type="textarea" placeholder="请输入审批意见" v-model:value="approveForm.remark" />
</n-form-item>
</n-form>
</div>
</div>
<div style="width: 100%;text-align: center;padding: 10px;" v-if="viewType == 'APPROVE'">
<n-button @click="handleAudit(currentOrder, 'REJECT')" type="error" style="margin-right: 10px;">
驳回
</n-button>
<n-button @click="handleAudit(currentOrder, 'APPROVE')" type="success">
通过
</n-button>
</div>
</n-modal>
</div>
</template>
<script setup lang="tsx">
import type { Ref } from 'vue';
import { ref, h, onMounted } from 'vue';
import type { FormInst, DataTableColumns } from 'naive-ui';
import { useMessage, NTag } from 'naive-ui';
import { ref, computed, onMounted } from 'vue';
import {FormInst, DataTableColumns, useDialog, NButton} from 'naive-ui';
import { useMessage, NTag, NModal } from 'naive-ui';
import { ArrowRedo } from '@vicons/ionicons5';
import { getSaleOrderList, deleteSaleOrder, editSaleOrder, addSaleOrder } from '@/service/api/sale/order';
import { getSaleOrderList, deleteSaleOrder, editSaleOrder, addSaleOrder, approveSaleOrder } from '@/service/api/sale/order';
import { addProductWorkOrder } from '@/service/api/plan/productOrder/index';
import { getUserList } from '@/service/api/sale/userManage';
import { getAllUnit } from '@/service/api/md/unit/index';
@ -174,6 +261,9 @@ import { getTechnologyListLine } from '@/service/api/technology/technologyLine';
import { dataTableConfig } from '@/config/dataTableConfig';
import { useAddBtn, useEditBtn, useDelBtn, useSearchBtn } from '~/src/hooks/common/useBtn';
import { useLoading } from '~/src/hooks/index';
import { useAuthStore } from '@/store';
const dialog = useDialog();
const authStore = useAuthStore();
const { loading, startLoading, endLoading } = useLoading();
const message = useMessage();
@ -197,6 +287,7 @@ const typeOption = [
const routingOption = ref<any[]>([]);
const flag = ref<boolean>(true);
const data = ref<DataType[]>([]);
const currentOrder = ref<DataType | null>(null);
const searchForm = ref<searchType>({
orderType: null,
orderCode: '',
@ -307,6 +398,7 @@ const addWorkorderForm = ref<addWorkorderFormType>({
routingId: null
});
const addFormRef = ref<FormInst | null>(null);
const viewType = ref('');
const checkedRowKeys = ref<Array<string | number>>([]);
const addWorkorderFormRef = ref<FormInst | null>(null);
function handleSearch() {
@ -323,6 +415,13 @@ function handleReset() {
};
init();
}
//
function formatDate(timestamp: number) {
if (!timestamp) return '';
const date = new Date(timestamp);
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
}
type DataType = {
id: number;
orderType: string | null;
@ -334,36 +433,50 @@ type DataType = {
measureId: number | null;
measureName: string;
payTime: number;
status: string;
status: string; // 0:, 1:, 2:, 3:
productId: number;
createBy?: string; //
checkedBy?: string; //
checkedTime?: number; //
remark?: string; //
};
function changeType(str: any) {
if (str === '0') {
return 'default';
} else if (str === '1') {
return 'warning';
} else if (str === '2' || str === '3') {
return 'info';
} else if (str === '4') {
} else if (str === '2') {
return 'success';
} else if (str === '5') {
} else if (str === '3') {
return 'error';
}
return 'error';
}
function getStatus(status: string) {
if (status === '0') return '未下发';
if (status === '1') return '已下发';
if (status === '2') return '已排产';
if (status === '3') return '生产中';
if (status === '4') return '已完成';
if (status === '5') return '已作废';
return '';
}
const unitOptions = ref<{ value: string; label: string }[]>([]);
const productOptions = ref<{ value: string; label: string }[]>([]);
const customerOptions = ref<{ value: string; label: string }[]>([]);
const rowKey = (row: any) => row.id;
//
const approveModalVisible = ref(false);
const approveForm = ref<{
id: number | string | null; // IDID()
status: string;
remark: string;
}>({
id: null,
status: '',
remark: ''
});
const approveRules = {
remark: [{ required: true, message: '请输入审批意见' }]
};
//
const hasApprovePermission = computed(() =>
authStore.userInfo.roles.includes('XSSP') || authStore.userInfo.userName === 'admin'
);
const columns: Ref<DataTableColumns<DataType>> = ref([
{
type: 'selection',
@ -374,13 +487,14 @@ const columns: Ref<DataTableColumns<DataType>> = ref([
{
title: '序号',
key: 'index',
width: 80,
width: 50,
align: 'center',
render: (_row, index) => (searchForm.value.pageNum - 1) * searchForm.value.pageSize + index + 1
},
{
title: '订单类型',
key: 'orderType',
width: 150,
render: (row: any) => (
<n-tag type={row.orderType === '0' ? 'success' : 'warning'}>
{row.orderType === '0' ? '客户订单' : '备库订单'}
@ -390,28 +504,26 @@ const columns: Ref<DataTableColumns<DataType>> = ref([
{
title: '客户名称',
align: 'center',
key: 'customerName'
key: 'customerName',
width: 150,
},
{
title: '订单编号',
align: 'center',
key: 'orderCode',
width: 200
},
{
title: '产品规格',
align: 'center',
key: 'specification'
width: 150,
},
{
title: '产品型号',
title: '规格型号',
align: 'center',
key: 'model'
key: 'specification',
width: 150,
},
{
title: '数量',
align: 'center',
key: 'weight'
key: 'weight',
width: 80,
},
{
title: '单位',
@ -435,30 +547,105 @@ const columns: Ref<DataTableColumns<DataType>> = ref([
title: '状态',
align: 'center',
key: 'status',
width: 80,
render: (row: DataType) => {
return h(
NTag,
const statusMap = {
'wtj': { label: '未提交', type: 'info' },
'dsp': { label: '待审批', type: 'warning' },
'0': { label: '已通过', type: 'success' },
'1': { label: '已下发', type: 'success' },
'2': { label: '已排产', type: 'success' },
'3': { label: '生产中', type: 'warning' },
'4': { label: '已完成', type: 'success' },
'6': { label: '已驳回', type: 'error' }
};
const { label, type } = statusMap[row.status || '0'];
return <NTag type={type}>{label}</NTag>;
}
},
{
type: changeType(row.status)
title: '申请人',
align: 'center',
key: 'createBy',
width: 150,
render: (row: DataType) => {
return row.createBy == 'admin' ? '跟单': row.createBy;
}
},
() => getStatus(row.status as string)
);
{
title: '审批人',
align: 'center',
width: 150,
key: 'checkedBy',
render: (row: DataType) => {
return row.checkedBy || '-';
}
},
{
title: '审批时间',
align: 'center',
key: 'checkedTime',
width: 150,
render: (row: DataType) => {
return row.checkedTime ? new Date(row.checkedTime).toLocaleDateString() : '-';
}
},
{
title: '操作',
align: 'center',
key: 'actions',
width: 250,
width: 220,
render: row => {
return [
<n-button color="#8a2be2" size="small" class="mr" v-show={row.status === '0'} onClick={() => handleInfo(row)}>
<ArrowRedo class="mr-1px text-15px w-13px" />
下发工单
</n-button>,
const actions:any[] = [];
actions.push(
<n-button size="small" type="info" onClick={() => handleApprove(row, 'see')}>
明细
</n-button>
);
//
if (row.status === 'wtj') {
actions.push(
<n-button size="small" type="primary" onClick={() => handleSubmitApprove(row)}>
提交审批
</n-button>
);
}
// //
// if (row.status === '1' && !hasApprovePermission.value) {
// actions.push(
// <n-button size="small" type="warning" onClick={() => handleCancelApprove(row)}>
//
// </n-button>
// );
// }
//
if (row.status === 'dsp' && hasApprovePermission.value) {
actions.push(
<n-button size="small" type="success" onClick={() => handleApprove(row, 'APPROVE')}>审批
</n-button>
);
}
//
if (row.status === '0') {
actions.push(
<n-button color="#8a2be2" size="small" class="mr" onClick={() => handleInfo(row)}>
<ArrowRedo class="mr-1px text-15px w-13px" />下发工单
</n-button>
);
}
if(row.status === 'wtj' || row.status === '6'){
actions.push(
useEditBtn(() => {
handleEdit(row);
}, 'small'),
}, 'small')
)
}
//
actions.push(
useDelBtn(() => {
deleteSaleOrder(row).then(res => {
if (res.code === 200) {
@ -467,7 +654,9 @@ const columns: Ref<DataTableColumns<DataType>> = ref([
}
});
}, 'small')
];
);
return actions;
}
}
]);
@ -494,13 +683,13 @@ const handleCheck = (rowKeys: (string | number)[]) => {
});
}
});
// addWorkorderFormList
}
checked.value = rowKeys;
};
//
const workorderFlag = ref<boolean>(false);
const approveFormRef = ref<any | null>(null);
function oneClickDelivery() {
workorderFlag.value = true;
isOneClickDelivery.value = true;
@ -546,6 +735,10 @@ const workorderHandleCancel = () => {
addWorkorderForm.value.orderId = null;
};
function handleInfo(row) {
if (row.status !== '0') {
message.warning('请先完成订单审批');
return;
}
addWorkorderFormList.value = [];
addWorkorderForm.value = {
orderId: row.id,
@ -569,7 +762,7 @@ async function handleSubmit() {
await addFormRef.value?.validate(errors => {
if (!errors) {
if (flag.value) {
addSaleOrder(addForm.value).then((res: any) => {
addSaleOrder({...addForm.value, status: 'wtj'}).then((res: any) => {
if (res.code === 200) {
message.success('添加成功');
handleCancel();
@ -577,7 +770,7 @@ async function handleSubmit() {
}
});
} else {
editSaleOrder(addForm.value).then((res: any) => {
editSaleOrder({...addForm.value, status: 'wtj'}).then((res: any) => {
if (res.code === 200) {
message.success('修改成功');
handleCancel();
@ -618,6 +811,77 @@ function handleEdit(row) {
};
}
//
function handleApprove(row: any, status: string) {
if(status === 'see'){
viewType.value = 'view';
}else{
viewType.value = 'APPROVE';
}
currentOrder.value = row;
approveModalVisible.value = true;
}
async function handleAudit(row:any,status: 'APPROVE' | 'REJECT') {
approveForm.value = {
id: row.id,
status: status === 'APPROVE' ? '0' : '6',
remark: approveForm.value.remark
};
handleApproveSubmit()
}
async function handleApproveSubmit() {
await approveFormRef.value?.validate(errors => {
if (!errors) {
const api = approveSaleOrder;
api({
id: approveForm.value.id,
status: approveForm.value.status,
remark: approveForm.value.remark
}).then(res => {
if (res.code === 200) {
message.success(`审批${approveForm.value.status === '0' ? '通过' : '驳回'}成功`);
approveModalVisible.value = false;
init();
} else {
message.error(res.msg || '审批失败');
}
});
}
});
}
function handleApproveCancel() {
approveModalVisible.value = false;
}
//
function handleSubmitApprove(row: DataType) {
editSaleOrder({ ...row, status: 'dsp' }).then(res => {
if (res.code === 200) {
message.success('提交审批成功');
init();
} else {
message.error(res.msg || '提交失败');
}
});
}
//
function handleCancelApprove(row: DataType) {
editSaleOrder({ ...row, status: '0' }).then(res => {
if (res.code === 200) {
message.success('撤销审批成功');
init();
} else {
message.error(res.msg || '撤销失败');
}
});
}
function init() {
startLoading();
data.value = [];
@ -677,8 +941,12 @@ onMounted(() => {
</script>
<style scoped>
:deep(.n-data-table-td--last-col) {
display: flex;
justify-content: flex-end;
:deep(.n-space){
margin-right: 5px;
}
:deep(.n-dialog.n-modal){
width: 860px !important;
}
</style>

Loading…
Cancel
Save