车辆草稿内容

This commit is contained in:
XaoLi717 2024-12-24 15:38:28 +08:00
parent 56336a7b8c
commit ddb0cc1e55
3 changed files with 290 additions and 2 deletions

View File

@ -56,4 +56,12 @@ export const ClglApi = {
exportClgl: async (params) => {
return await request.download({ url: `/home/clgl/export-excel`, params })
},
// 保存为草稿
saveDraft: async (data: ClglVO) => {
return await request.post({ url: `/home/clgl/saveDraft`, data })
},
// 查询草稿
getDraft: async (params: any) => {
return await request.get({ url: `/home/clgl/draft`, params })
},
}

View File

@ -145,6 +145,7 @@
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="saveDraft" type="warning" :disabled="draftButton">存为草稿</el-button>
</template>
</el-card>
<SelectCarForm ref="selectRef" @success="changeForm"/>
@ -262,6 +263,24 @@ const changeDriverForm = (val:any) => {
form.carDriverInfo = val.contactInfo
}
const draftButton = ref(false)
const saveDraft = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as ClglVO
await ClglApi.saveDraft(data)
message.success(t('存为草稿成功!'))
// Tab
delView(unref(currentRoute))
await push({ name: 'Clgl' })
} finally {
formLoading.value = false
}
}
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
@ -281,11 +300,14 @@ const submitForm = async () => {
data.startUserSelectAssignees = startUserSelectAssignees.value
}
const curFullPath = currentRoute.value.fullPath
let curFullPath = currentRoute.value.fullPath
if( curFullPath ) {
data.curfullpath = curFullPath
}
if (curFullPath.includes("?")) {
curFullPath = curFullPath.split("?")[0];
}
const processKey = await FormProcessMappingApi.selectProcessKey( curFullPath )
if ( processKey) {
data.processDefinitionKey = processKey
@ -326,7 +348,18 @@ const getUserInfo = async () => {
onMounted(async () => {
await getUserInfo()
const curFullPath = currentRoute.value.fullPath
let curFullPath = currentRoute.value.fullPath
if (curFullPath.includes("?")) {
// 使 URLSearchParams
const params = new URLSearchParams(curFullPath.split("?")[1]);
const id = params.get("id") ;
//
curFullPath = curFullPath.split("?")[0];
if ( id != "") {
formData.value = await ClglApi.getClgl(Number( id) )
draftButton.value= true
}
}
const processKey = await FormProcessMappingApi.selectProcessKey( curFullPath )

View File

@ -0,0 +1,247 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="部门" prop="dept">
<el-input
v-model="queryParams.dept"
placeholder="请输入部门"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="用车类型" prop="carType">
<el-select
v-model="queryParams.carType"
placeholder="请选择用车类型"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.CLGL_CAR_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="用车状态" prop="carStatus">
<el-select
v-model="queryParams.carStatus"
placeholder="请选择用车状态"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.CLGL_CAR_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['home:clgl:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column width="70" label="序号" align="center" type="index" />
<el-table-column label="申请人" align="center" prop="carUserName" />
<el-table-column label="部门" align="center" prop="deptName" />
<el-table-column label="车辆类型" align="center" prop="carType">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CLGL_CAR_TYPE" :value="scope.row.carType" />
</template>
</el-table-column>
<el-table-column label="驾驶员" align="center" prop="carDriver" />
<el-table-column
label="用车开始时间"
align="center"
prop="carStart"
:formatter="dateFormatter2"
width="180px"
/>
<el-table-column
label="用车结束时间"
align="center"
prop="carEnd"
:formatter="dateFormatter2"
width="180px"
/>
<el-table-column label="目的地" align="center" prop="carAddress" />
<el-table-column label="车辆信息" align="center" prop="carInfo" />
<el-table-column label="车辆状态" align="center" prop="carStatus">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CLGL_CAR_STATUS" :value="scope.row.carStatus" />
</template>
</el-table-column>
<el-table-column label="用车原因" align="center" prop="carReason" />
<el-table-column label="备注" align="center" prop="carRemark" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
v-hasPermi="['home:clgl:update']"
link
type="primary"
@click="handleDetail(scope.row)"
>
详情
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<ClglForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import download from '@/utils/download'
import { ClglApi, ClglVO } from '@/api/home/clgl'
import ClglForm from './ClglForm.vue'
import * as LeaveApi from '@/api/bpm/leave'
import {dateFormatter2} from "@/utils/formatTime";
/** 车辆管理 列表 */
defineOptions({ name: 'Clgl' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<ClglVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
id: undefined,
title: undefined,
carUserId: undefined,
carUserName: undefined,
dept: undefined,
deptName: undefined,
carType: undefined,
carDriver: undefined,
carStart: null,
// carStart: [],
carEnd: undefined,
// carEnd: [],
carAddress: undefined,
carDriverInfo: undefined,
carMileage: undefined,
carStatus: null,
createTime: [],
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
const router = useRouter() //
/**发起操作 */
// const handleCreate =async () => {
// await router.push({name: 'ClglCreate'})
// }
/** 详情操作 */
const handleDetail =async (row: LeaveApi.LeaveVO) => {
await router.push({
name: 'ClglCreate',
//id
query: {
id: row.id
}
})
}
/** 审批进度 */
// const handleProcessDetail =async (row) => {
// await router.push({
// name: 'BpmProcessInstanceDetail',
// //id
// query: {
// id: row.processInstanceId
// }
// })
// }
// fix:
watch(
() => router.currentRoute.value,
() => {
getList()
}
)
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ClglApi.getDraft(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await ClglApi.exportClgl(queryParams)
download.excel(data, '车辆管理.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(async () => {
await getList()
})
</script>