feat(crm/TripBusine):新增出差申请页面及交互逻辑

dev
Yangk 2 months ago
parent c59f37569f
commit c457f5e31d

@ -0,0 +1,76 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BusinessTripApplyVO, BusinessTripApplyForm, BusinessTripApplyQuery } from '@/api/oa/crm/businessTripApply/types';
/**
*
* @param query
* @returns {*}
*/
export const listBusinessTripApply = (query?: BusinessTripApplyQuery): AxiosPromise<BusinessTripApplyVO[]> => {
return request({
url: '/oa/crm/businessTripApply/list',
method: 'get',
params: query
});
};
/**
*
* @param tripId
*/
export const getBusinessTripApply = (tripId: string | number): AxiosPromise<BusinessTripApplyVO> => {
return request({
url: '/oa/crm/businessTripApply/' + tripId,
method: 'get'
});
};
/**
*
* @param data
*/
export const addBusinessTripApply = (data: BusinessTripApplyForm) => {
return request({
url: '/oa/crm/businessTripApply',
method: 'post',
data: data
});
};
/**
*
* @param data
*/
export const updateBusinessTripApply = (data: BusinessTripApplyForm) => {
return request({
url: '/oa/crm/businessTripApply',
method: 'put',
data: data
});
};
/**
*
* @param tripId
*/
export const delBusinessTripApply = (tripId: string | number | Array<string | number>) => {
return request({
url: '/oa/crm/businessTripApply/' + tripId,
method: 'delete'
});
};
/**
*
* @param query
* @returns {*}
*/
export function getCrmBusinessTripApplyList (query) {
return request({
url: '/oa/crm/businessTripApply/getCrmBusinessTripApplyList',
method: 'get',
params: query
});
};

@ -0,0 +1,362 @@
export interface BusinessTripApplyVO {
/**
* ID
*/
tripId: string;
/**
*
*/
applyCode: string;
/**
* 1 2 3/ 4
*/
tripType: string;
/**
* ID
*/
applicantId: string | number;
/**
*
*/
applicantName: string;
/**
* ID
*/
deptId: string | number;
/**
*
*/
deptName: string;
/**
*
*/
tripLocation: string;
/**
*
*/
startTime: string;
/**
*
*/
endTime: string;
/**
* ()
*/
durationDays: number;
/**
*
*/
tripReason: string;
/**
* ID
*/
projectId: string | number;
/**
* ID
*/
customerId: string | number;
/**
*
*/
exchangeObject: string;
/**
*
*/
businessDirection: string;
/**
*
*/
exchangePurpose: string;
/**
*
*/
exchangeProcess: string;
/**
* /
*/
meetingName: string;
/**
*
*/
feedback: string;
/**
* 1 2 3 4
*/
tripStatus: string;
/**
*
*/
flowStatus: string;
/**
*
*/
remark: string;
/**
* ID
*/
ossId: string | number;
}
export interface BusinessTripApplyForm extends BaseEntity {
/**
* ID
*/
tripId?: string;
/**
*
*/
applyCode?: string;
/**
* 1 2 3/ 4
*/
tripType?: string;
/**
* ID
*/
applicantId?: string | number;
/**
*
*/
applicantName?: string;
/**
* ID
*/
deptId?: string | number;
/**
*
*/
deptName?: string;
/**
*
*/
tripLocation?: string;
/**
*
*/
startTime?: string;
/**
*
*/
endTime?: string;
/**
* ()
*/
durationDays?: number;
/**
*
*/
tripReason?: string;
/**
* ID
*/
projectId?: string | number;
/**
* ID
*/
customerId?: string | number;
/**
*
*/
exchangeObject?: string;
/**
*
*/
businessDirection?: string;
/**
*
*/
exchangePurpose?: string;
/**
*
*/
exchangeProcess?: string;
/**
* /
*/
meetingName?: string;
/**
*
*/
feedback?: string;
/**
* 1 2 3 4
*/
tripStatus?: string;
/**
*
*/
flowStatus?: string;
/**
*
*/
remark?: string;
/**
* ID
*/
ossId?: string | number;
}
export interface BusinessTripApplyQuery extends PageQuery {
/**
* ID
*/
tripId?: string;
/**
*
*/
applyCode?: string;
/**
* 1 2 3/ 4
*/
tripType?: string;
/**
* ID
*/
applicantId?: string | number;
/**
*
*/
applicantName?: string;
/**
* ID
*/
deptId?: string | number;
/**
*
*/
deptName?: string;
/**
*
*/
tripLocation?: string;
/**
*
*/
startTime?: string;
/**
*
*/
endTime?: string;
/**
* ()
*/
durationDays?: number;
/**
*
*/
tripReason?: string;
/**
* ID
*/
projectId?: string | number;
/**
* ID
*/
customerId?: string | number;
/**
*
*/
exchangeObject?: string;
/**
*
*/
businessDirection?: string;
/**
*
*/
exchangePurpose?: string;
/**
*
*/
exchangeProcess?: string;
/**
* /
*/
meetingName?: string;
/**
*
*/
feedback?: string;
/**
* 1 2 3 4
*/
tripStatus?: string;
/**
*
*/
flowStatus?: string;
/**
* ID
*/
ossId?: string | number;
/**
*
*/
params?: any;
}

@ -0,0 +1,454 @@
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="100px">
<el-form-item label="申请单号" prop="applyCode">
<el-input v-model="queryParams.applyCode" placeholder="请输入申请单号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="出差类型" prop="tripType">
<el-select v-model="queryParams.tripType" placeholder="请选择出差类型" clearable>
<el-option v-for="dict in trip_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="申请人姓名" prop="applicantName">
<el-input v-model="queryParams.applicantName" placeholder="请输入申请人姓名" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="申请人部门" prop="deptName">
<el-input v-model="queryParams.deptName" placeholder="请输入申请人部门" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="出差地点" prop="tripLocation">
<el-input v-model="queryParams.tripLocation" placeholder="请输入出差地点" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="开始日期" prop="startTime">
<el-date-picker clearable v-model="queryParams.startTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择开始日期" />
</el-form-item>
<el-form-item label="结束日期" prop="endTime">
<el-date-picker clearable v-model="queryParams.endTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择结束日期" />
</el-form-item>
<el-form-item label="业务方向" prop="businessDirection">
<el-input v-model="queryParams.businessDirection" placeholder="请输入业务方向" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="申请状态" prop="tripStatus">
<el-select v-model="queryParams.tripStatus" placeholder="请选择申请状态" clearable>
<el-option v-for="dict in trip_status" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-dropdown trigger="click" @command="handleAdd">
<el-button type="primary" plain icon="Plus" v-hasPermi="['crm:businessTripApply:add']">
新增<el-icon class="el-icon--right"><arrow-down /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item v-for="dict in trip_type" :key="dict.value" :command="dict.value">
{{ dict.label }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/crm:businessTripApply:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['oa/crm:businessTripApply:remove']"
>删除</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/crm:businessTripApply:export']"></el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="businessTripApplyList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="申请ID" align="center" prop="tripId" v-if="columns[0].visible" />
<el-table-column label="申请单号" align="center" prop="applyCode" v-if="columns[2].visible" />
<el-table-column label="出差类型" align="center" prop="tripType" v-if="columns[3].visible">
<template #default="scope">
<dict-tag :options="trip_type" :value="scope.row.tripType" />
</template>
</el-table-column>
<el-table-column label="申请人ID" align="center" prop="applicantId" v-if="columns[4].visible" />
<el-table-column label="申请人" align="center" prop="applicantName" v-if="columns[5].visible" />
<el-table-column label="申请人部门ID" align="center" prop="deptId" v-if="columns[6].visible" />
<el-table-column label="申请人部门" align="center" prop="deptName" v-if="columns[7].visible" width="120" />
<el-table-column label="出差地点" align="center" prop="tripLocation" v-if="columns[8].visible" />
<el-table-column label="开始日期" align="center" prop="startTime" width="100" v-if="columns[9].visible">
<template #default="scope">
<span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="结束日期" align="center" prop="endTime" width="100" v-if="columns[10].visible">
<template #default="scope">
<span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="时长(天)" align="center" prop="durationDays" v-if="columns[11].visible" />
<el-table-column label="出差事由" align="center" prop="tripReason" v-if="columns[12].visible" />
<el-table-column label="项目ID" align="center" prop="projectId" v-if="columns[13].visible" />
<el-table-column label="客户ID" align="center" prop="customerId" v-if="columns[14].visible" />
<el-table-column label="交流对象" align="center" prop="exchangeObject" v-if="columns[15].visible" />
<el-table-column label="业务方向" align="center" prop="businessDirection" v-if="columns[16].visible" />
<el-table-column label="交流目的" align="center" prop="exchangePurpose" v-if="columns[17].visible" />
<el-table-column label="交流过程简述" align="center" prop="exchangeProcess" v-if="columns[18].visible" />
<el-table-column label="会议/展会名称" align="center" prop="meetingName" v-if="columns[19].visible" />
<el-table-column label="结果反馈" align="center" prop="feedback" v-if="columns[20].visible" />
<el-table-column label="申请状态" align="center" prop="tripStatus" v-if="columns[21].visible">
<template #default="scope">
<dict-tag :options="trip_status" :value="scope.row.tripStatus" />
</template>
</el-table-column>
<el-table-column label="流程状态" align="center" prop="flowStatus" v-if="columns[22].visible" />
<el-table-column label="备注" align="center" prop="remark" v-if="columns[23].visible" />
<el-table-column label="附件ID" align="center" prop="ossId" v-if="columns[24].visible" />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/crm:businessTripApply:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button
link
type="primary"
icon="Delete"
@click="handleDelete(scope.row)"
v-hasPermi="['oa/crm:businessTripApply:remove']"
></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改出差申请对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="businessTripApplyFormRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="申请单号" prop="applyCode">
<el-input v-model="form.applyCode" placeholder="请输入申请单号" />
</el-form-item>
<el-form-item label="出差类型" prop="tripType">
<el-select v-model="form.tripType" placeholder="请选择出差类型">
<el-option v-for="dict in trip_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="申请人ID" prop="applicantId">
<el-input v-model="form.applicantId" placeholder="请输入申请人ID" />
</el-form-item>
<el-form-item label="申请人姓名" prop="applicantName">
<el-input v-model="form.applicantName" placeholder="请输入申请人姓名" />
</el-form-item>
<el-form-item label="申请人部门ID" prop="deptId">
<el-input v-model="form.deptId" placeholder="请输入申请人部门ID" />
</el-form-item>
<el-form-item label="申请人部门名称" prop="deptName">
<el-input v-model="form.deptName" placeholder="请输入申请人部门名称" />
</el-form-item>
<el-form-item label="出差地点" prop="tripLocation">
<el-input v-model="form.tripLocation" placeholder="请输入出差地点" />
</el-form-item>
<el-form-item label="开始日期" prop="startTime">
<el-date-picker clearable v-model="form.startTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始日期">
</el-date-picker>
</el-form-item>
<el-form-item label="结束日期" prop="endTime">
<el-date-picker clearable v-model="form.endTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="时长(天)" prop="durationDays">
<el-input v-model="form.durationDays" placeholder="请输入时长(天)" />
</el-form-item>
<el-form-item label="出差事由" prop="tripReason">
<el-input v-model="form.tripReason" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="项目ID" prop="projectId">
<el-input v-model="form.projectId" placeholder="请输入项目ID" />
</el-form-item>
<el-form-item label="客户ID" prop="customerId">
<el-input v-model="form.customerId" placeholder="请输入客户ID" />
</el-form-item>
<el-form-item label="交流对象" prop="exchangeObject">
<el-input v-model="form.exchangeObject" placeholder="请输入交流对象" />
</el-form-item>
<el-form-item label="业务方向" prop="businessDirection">
<el-input v-model="form.businessDirection" placeholder="请输入业务方向" />
</el-form-item>
<el-form-item label="交流目的" prop="exchangePurpose">
<el-input v-model="form.exchangePurpose" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="交流过程简述" prop="exchangeProcess">
<el-input v-model="form.exchangeProcess" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="会议/展会名称" prop="meetingName">
<el-input v-model="form.meetingName" placeholder="请输入会议/展会名称" />
</el-form-item>
<el-form-item label="结果反馈" prop="feedback">
<el-input v-model="form.feedback" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="申请状态" prop="tripStatus">
<el-select v-model="form.tripStatus" placeholder="请选择申请状态">
<el-option v-for="dict in trip_status" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="流程状态" prop="flowStatus">
<el-input v-model="form.flowStatus" placeholder="请输入流程状态" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="BusinessTripApply" lang="ts">
import {
listBusinessTripApply,
getBusinessTripApply,
delBusinessTripApply,
addBusinessTripApply,
updateBusinessTripApply
} from '@/api/oa/crm/businessTripApply';
import { BusinessTripApplyVO, BusinessTripApplyQuery, BusinessTripApplyForm } from '@/api/oa/crm/businessTripApply/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { trip_status, trip_type } = toRefs<any>(proxy?.useDict('trip_status', 'trip_type'));
const businessTripApplyList = ref<BusinessTripApplyVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const businessTripApplyFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
//
const columns = ref<FieldOption[]>([
{ key: 0, label: `申请ID`, visible: false },
{ key: 1, label: `租户编号`, visible: false },
{ key: 2, label: `申请单号`, visible: true },
{ key: 3, label: `出差类型`, visible: true },
{ key: 4, label: `申请人ID`, visible: false },
{ key: 5, label: `申请人姓名`, visible: true },
{ key: 6, label: `申请人部门ID`, visible: false },
{ key: 7, label: `申请人部门名称`, visible: true },
{ key: 8, label: `出差地点`, visible: true },
{ key: 9, label: `开始日期`, visible: true },
{ key: 10, label: `结束日期`, visible: true },
{ key: 11, label: `时长(天)`, visible: true },
{ key: 12, label: `出差事由`, visible: true },
{ key: 13, label: `项目ID`, visible: false },
{ key: 14, label: `客户ID`, visible: true },
{ key: 15, label: `交流对象`, visible: true },
{ key: 16, label: `业务方向`, visible: true },
{ key: 17, label: `交流目的`, visible: true },
{ key: 18, label: `交流过程简述`, visible: true },
{ key: 19, label: `会议/展会名称`, visible: true },
{ key: 20, label: `结果反馈`, visible: true },
{ key: 21, label: `申请状态`, visible: true },
{ key: 22, label: `流程状态`, visible: true },
{ key: 23, label: `备注`, visible: true },
{ key: 24, label: `附件ID`, visible: true },
{ key: 25, label: `删除标志`, visible: true },
{ key: 26, label: `创建部门`, visible: true },
{ key: 27, label: `创建者`, visible: true },
{ key: 28, label: `创建时间`, visible: true },
{ key: 29, label: `更新者`, visible: true },
{ key: 30, label: `更新时间`, visible: true }
]);
const initFormData: BusinessTripApplyForm = {
applyCode: undefined,
tripType: undefined,
applicantId: undefined,
applicantName: undefined,
deptId: undefined,
deptName: undefined,
tripLocation: undefined,
startTime: undefined,
endTime: undefined,
durationDays: undefined,
tripReason: undefined,
projectId: undefined,
customerId: undefined,
exchangeObject: undefined,
businessDirection: undefined,
exchangePurpose: undefined,
exchangeProcess: undefined,
meetingName: undefined,
feedback: undefined,
tripStatus: undefined,
flowStatus: undefined,
remark: undefined,
ossId: undefined
};
const data = reactive<PageData<BusinessTripApplyForm, BusinessTripApplyQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
applyCode: undefined,
tripType: undefined,
applicantId: undefined,
applicantName: undefined,
deptId: undefined,
deptName: undefined,
tripLocation: undefined,
startTime: undefined,
endTime: undefined,
durationDays: undefined,
tripReason: undefined,
projectId: undefined,
customerId: undefined,
exchangeObject: undefined,
businessDirection: undefined,
exchangePurpose: undefined,
exchangeProcess: undefined,
meetingName: undefined,
feedback: undefined,
tripStatus: undefined,
flowStatus: undefined,
ossId: undefined,
params: {}
},
rules: {
tripType: [{ required: true, message: '出差类型不能为空', trigger: 'change' }],
applicantId: [{ required: true, message: '申请人ID不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询出差申请列表 */
const getList = async () => {
loading.value = true;
const res = await listBusinessTripApply(queryParams.value);
businessTripApplyList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
businessTripApplyFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: BusinessTripApplyVO[]) => {
ids.value = selection.map((item) => item.tripId);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加出差申请';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: BusinessTripApplyVO) => {
reset();
const _tripId = row?.tripId || ids.value[0];
const res = await getBusinessTripApply(_tripId);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改出差申请';
};
/** 提交按钮 */
const submitForm = () => {
businessTripApplyFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.tripId) {
await updateBusinessTripApply(form.value).finally(() => (buttonLoading.value = false));
} else {
await addBusinessTripApply(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: BusinessTripApplyVO) => {
const _tripIds = row?.tripId || ids.value;
await proxy?.$modal.confirm('是否确认删除出差申请编号为"' + _tripIds + '"的数据项?').finally(() => (loading.value = false));
await delBusinessTripApply(_tripIds);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'oa/crm/businessTripApply/export',
{
...queryParams.value
},
`businessTripApply_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
</script>
Loading…
Cancel
Save