| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="search_form"> |
| | | <el-form :model="searchForm" :inline="true"> |
| | | <el-form-item label="车çå·ï¼"> |
| | | <el-input v-model="searchForm.carNo" placeholder="请è¾å
¥è½¦çå·" clearable prefix-icon="Search" |
| | | @change="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="é¢è²ï¼"> |
| | | <el-input v-model="searchForm.color" placeholder="请è¾å
¥é¢è²" clearable prefix-icon="Search" |
| | | @change="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="åçï¼"> |
| | | <el-input v-model="searchForm.brand" placeholder="请è¾å
¥åç" clearable prefix-icon="Search" |
| | | @change="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="使ç¨ç¶æï¼"> |
| | | <el-select v-model="searchForm.usageStatus" placeholder="è¯·éæ©" clearable @change="handleQuery" style="width: 200px"> |
| | | <el-option label="空é²" value="空é²" /> |
| | | <el-option label="使ç¨ä¸" value="使ç¨ä¸" /> |
| | | <el-option label="ç»´ä¿®ä¸" value="ç»´ä¿®ä¸" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="handleQuery">æç´¢</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <div class="table_list"> |
| | | <div class="actions"> |
| | | <div></div> |
| | | <div> |
| | | <el-button type="primary" @click="openForm('add')"> |
| | | æ°å¢è½¦è¾ |
| | | </el-button> |
| | | <!-- <el-button @click="handleOut">导åº</el-button>--> |
| | | <el-button type="danger" plain @click="handleDelete">å é¤</el-button> |
| | | </div> |
| | | </div> |
| | | <PIMTable |
| | | :table-data="tableData" |
| | | :column="tableColumns" |
| | | :is-selection="true" |
| | | :border="true" |
| | | :row-key="'id'" |
| | | :expand-row-keys="expandRowKeys" |
| | | :table-loading="tableLoading" |
| | | :table-style="{ width: '100%', height: 'calc(100vh - 21.5em)' }" |
| | | :page="{ |
| | | current: page.current, |
| | | size: page.size, |
| | | total: total, |
| | | layout: 'total, sizes, prev, pager, next, jumper' |
| | | }" |
| | | @selection-change="handleSelectionChange" |
| | | @pagination="paginationChange" |
| | | @expand-change="handleExpandChange" |
| | | > |
| | | <template #expand="{ row }"> |
| | | <div class="expand-wrapper"> |
| | | <el-skeleton v-if="expandChildLoading[row.id]" animated :rows="3" /> |
| | | <template v-else> |
| | | <el-empty v-if="!(expandChildData[row.id] && expandChildData[row.id].length)" description="ææ ä½¿ç¨è®°å½" /> |
| | | <el-table |
| | | v-else |
| | | :data="expandChildData[row.id]" |
| | | size="small" |
| | | border |
| | | style="width: 100%" |
| | | :header-cell-style="{ background: '#F7F8FA' }" |
| | | > |
| | | <el-table-column prop="userName" label="使ç¨äºº" width="140" /> |
| | | <el-table-column prop="desc" label="ç®çå°" width="180" /> |
| | | <el-table-column prop="useTime" label="ä½¿ç¨æ¶é´" width="180" /> |
| | | <el-table-column prop="carReturnDate" label="è¿è½¦æ¶é´" width="180" /> |
| | | <el-table-column prop="odometerBefore" label="使ç¨åéç¨(km)" width="140" /> |
| | | <el-table-column prop="odometerAfter" label="è¿è½¦æ¶éç¨(km)" width="140" /> |
| | | <el-table-column prop="thisTripMileage" label="æ¬æ¬¡è¡é©¶éç¨(km)" width="160" /> |
| | | </el-table> |
| | | </template> |
| | | </div> |
| | | </template> |
| | | <template #operation="{ row }"> |
| | | <el-button link type="primary" size="small" @click="openForm('edit', row)">ç¼è¾</el-button> |
| | | <el-button link type="primary" size="small" v-if="row.usageStatus === '空é²'" @click="openUseForm(row)">ç¨è½¦</el-button> |
| | | <el-button link type="primary" size="small" v-if="row.usageStatus === '使ç¨ä¸'" @click="openReturnForm(row)">è¿è½¦</el-button> |
| | | <el-button link type="primary" size="small" @click="openUsageRecordsDialog(row)">使ç¨è®°å½</el-button> |
| | | </template> |
| | | </PIMTable> |
| | | </div> |
| | | |
| | | <!-- æ°å¢/ç¼è¾è½¦è¾å¼¹çª --> |
| | | <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? 'æ°å¢è½¦è¾' : 'ç¼è¾è½¦è¾'" width="50%" |
| | | @close="closeDia"> |
| | | <el-form :model="form" label-width="120px" label-position="top" :rules="rules" ref="formRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="车çå·ï¼" prop="carNo"> |
| | | <el-input v-model="form.carNo" placeholder="请è¾å
¥è½¦çå·" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="é¢è²ï¼" prop="color"> |
| | | <el-input v-model="form.color" placeholder="请è¾å
¥é¢è²" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="åçï¼" prop="brand"> |
| | | <el-input v-model="form.brand" placeholder="请è¾å
¥åç" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="使ç¨ç¶æï¼" prop="usageStatus"> |
| | | <el-select v-model="form.usageStatus" placeholder="è¯·éæ©" clearable style="width: 100%"> |
| | | <el-option label="空é²" value="空é²" /> |
| | | <el-option label="使ç¨ä¸" value="使ç¨ä¸" /> |
| | | <el-option label="ç»´ä¿®ä¸" value="ç»´ä¿®ä¸" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="表æ¾éç¨(km)ï¼"> |
| | | <el-input-number v-model="form.odometerMileage" :min="0" :precision="2" style="width: 100%" |
| | | placeholder="请è¾å
¥è¡¨æ¾éç¨" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="夿³¨ï¼"> |
| | | <el-input v-model="form.remark" placeholder="请è¾å
¥å¤æ³¨" clearable type="textarea" :rows="3" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确认</el-button> |
| | | <el-button @click="closeDia">åæ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- 使ç¨è½¦è¾å¼¹çª --> |
| | | <el-dialog v-model="useFormVisible" title="使ç¨è½¦è¾" width="50%" @close="closeUseDia"> |
| | | <el-form :model="useForm" label-width="140px" label-position="top" :rules="useRules" ref="useFormRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="车çå·ï¼"> |
| | | <el-input :value="currentUseRow ? currentUseRow.carNo : ''" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="ç®çå°ï¼" prop="destination"> |
| | | <el-input v-model="useForm.destination" placeholder="请è¾å
¥ç®çå°" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="åç¨æ¶é´ï¼" prop="carRentalDate"> |
| | | <el-date-picker |
| | | style="width: 100%" |
| | | v-model="useForm.carRentalDate" |
| | | type="date" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | placeholder="è¯·éæ©åç¨æ¶é´" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="使ç¨äººï¼" prop="userName"> |
| | | <el-select v-model="useForm.userName" placeholder="è¯·éæ©ä½¿ç¨äºº" clearable filterable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="表æ¾éç¨(km)ï¼" prop="odometerMileage"> |
| | | <el-input-number v-model="useForm.odometerMileage" :min="0" :precision="2" style="width: 100%" |
| | | placeholder="请è¾å
¥è¡¨æ¾éç¨" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="æ¬æ¬¡é¢è®¡è¡é©¶éç¨(km)ï¼" prop="thisTripMileage"> |
| | | <el-input-number v-model="useForm.thisTripMileage" :min="0" :precision="2" style="width: 100%" |
| | | placeholder="请è¾å
¥æ¬æ¬¡é¢è®¡è¡é©¶éç¨" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="夿³¨ï¼"> |
| | | <el-input v-model="useForm.remark" placeholder="请è¾å
¥å¤æ³¨" clearable type="textarea" :rows="3" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitUseForm">确认</el-button> |
| | | <el-button @click="closeUseDia">åæ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- è¿è½¦å¼¹çª --> |
| | | <el-dialog v-model="returnFormVisible" title="è¿è½¦" width="50%" @close="closeReturnDia"> |
| | | <el-form :model="returnForm" label-width="140px" label-position="top" :rules="returnRules" ref="returnFormRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="车çå·ï¼"> |
| | | <el-input :value="currentReturnRow ? currentReturnRow.carNo : ''" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="è¿è½¦æ¶é´ï¼" prop="carReturnDate"> |
| | | <el-date-picker style="width: 100%" v-model="returnForm.carReturnDate" value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" type="date" placeholder="è¯·éæ©è¿è½¦æ¶é´" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="表æ¾éç¨(km)ï¼" prop="odometerMileage"> |
| | | <el-input-number v-model="returnForm.odometerMileage" :min="0" :precision="2" style="width: 100%" |
| | | placeholder="请è¾å
¥è¡¨æ¾éç¨" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="夿³¨ï¼"> |
| | | <el-input v-model="returnForm.remark" placeholder="请è¾å
¥å¤æ³¨" clearable type="textarea" :rows="3" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitReturnForm">确认</el-button> |
| | | <el-button @click="closeReturnDia">åæ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- 使ç¨è®°å½å¼¹çª --> |
| | | <el-dialog v-model="usageRecordsVisible" title="使ç¨è®°å½" width="70%" @close="closeUsageRecords"> |
| | | <PIMTable |
| | | :table-data="usageRecordsData" |
| | | :column="usageRecordsColumns" |
| | | :border="true" |
| | | :table-loading="usageRecordsLoading" |
| | | :table-style="{ height: 'calc(100vh - 24em)', width: '100%' }" |
| | | :page="{ |
| | | current: usageRecordsPage.current, |
| | | size: usageRecordsPage.size, |
| | | total: usageRecordsTotal, |
| | | layout: 'total, sizes, prev, pager, next, jumper' |
| | | }" |
| | | @pagination="usageRecordsPaginationChange" |
| | | /> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue"; |
| | | import PIMTable from "@/components/PIMTable/PIMTable.vue"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import { userListNoPage } from "@/api/system/user.js"; |
| | | import { |
| | | listVehicle, |
| | | addVehicle, |
| | | updateVehicle, |
| | | delVehicle, |
| | | getVehicleById, |
| | | useVehicle, |
| | | returnVehicle, |
| | | getVehicleUsageRecords, |
| | | } from "@/api/collaborativeApproval/vehicleManagement.js"; |
| | | import useFormData from "@/hooks/useFormData.js"; |
| | | import dayjs from "dayjs"; |
| | | |
| | | const userStore = useUserStore(); |
| | | const { proxy } = getCurrentInstance(); |
| | | const tableData = ref([]); |
| | | const selectedRows = ref([]); |
| | | const userList = ref([]); |
| | | const tableLoading = ref(false); |
| | | const expandRowKeys = ref([]); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 100, |
| | | }); |
| | | const total = ref(0); |
| | | |
| | | // 使ç¨è®°å½å¼¹çª |
| | | const usageRecordsVisible = ref(false); |
| | | const usageRecordsData = ref([]); |
| | | const usageRecordsLoading = ref(false); |
| | | const usageRecordsPage = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | }); |
| | | const usageRecordsTotal = ref(0); |
| | | const usageRecordsColumns = ref([ |
| | | { label: "使ç¨äºº", prop: "userName", width: "120" }, |
| | | { label: "ç®çå°", prop: "destination", width: "150" }, |
| | | { label: "åç¨æ¶é´", prop: "carRentalDate", }, |
| | | { label: "è¿è½¦æ¶é´", prop: "carReturnDate",}, |
| | | { label: "使ç¨åéç¨(km)", prop: "odometerMileage", }, |
| | | { label: "æ¬æ¬¡è¡é©¶éç¨(km)", prop: "thisTripMileage",}, |
| | | ]); |
| | | |
| | | // æç´¢è¡¨å |
| | | const data = reactive({ |
| | | searchForm: { |
| | | carNo: "", |
| | | color: "", |
| | | brand: "", |
| | | usageStatus: "", |
| | | }, |
| | | form: { |
| | | carNo: "", |
| | | color: "", |
| | | brand: "", |
| | | usageStatus: "空é²", |
| | | odometerMileage: 0, |
| | | remark: "", |
| | | }, |
| | | rules: { |
| | | carNo: [{ required: true, message: "请è¾å
¥è½¦çå·", trigger: "blur" }], |
| | | color: [{ required: true, message: "请è¾å
¥é¢è²", trigger: "blur" }], |
| | | brand: [{ required: true, message: "请è¾å
¥åç", trigger: "blur" }], |
| | | usageStatus: [{ required: true, message: "è¯·éæ©ä½¿ç¨ç¶æ", trigger: "change" }], |
| | | }, |
| | | }); |
| | | const { form, rules } = toRefs(data); |
| | | const { form: searchForm } = useFormData(data.searchForm); |
| | | |
| | | // 使ç¨è½¦è¾è¡¨å |
| | | const useFormVisible = ref(false); |
| | | const currentUseRow = ref(null); |
| | | const useVehicleFormData = reactive({ |
| | | useForm: { |
| | | carInfoId: "", |
| | | destination: "", |
| | | carRentalDate: dayjs().format("YYYY-MM-DD"), |
| | | odometerMileage: 0, |
| | | thisTripMileage: 0, |
| | | userName: "", |
| | | remark: "", |
| | | }, |
| | | useRules: { |
| | | destination: [{ required: true, message: "请è¾å
¥ç®çå°", trigger: "blur" }], |
| | | carRentalDate: [{ required: true, message: "è¯·éæ©åç¨æ¶é´", trigger: "change" }], |
| | | odometerMileage: [{ required: true, message: "请è¾å
¥è¡¨æ¾éç¨", trigger: "blur" }], |
| | | thisTripMileage: [{ required: true, message: "请è¾å
¥æ¬æ¬¡è¡é©¶éç¨", trigger: "blur" }], |
| | | userName: [{ required: true, message: "è¯·éæ©ä½¿ç¨äºº", trigger: "change" }], |
| | | }, |
| | | }); |
| | | const { useForm, useRules } = toRefs(useVehicleFormData); |
| | | |
| | | // è¿è½¦è¡¨å |
| | | const returnFormVisible = ref(false); |
| | | const currentReturnRow = ref(null); |
| | | const returnFormData = reactive({ |
| | | returnForm: { |
| | | carInfoId: "", |
| | | carReturnDate: "", |
| | | odometerMileage: 0, |
| | | remark: "", |
| | | }, |
| | | returnRules: { |
| | | carReturnDate: [{ required: true, message: "è¯·éæ©è¿è½¦æ¶é´", trigger: "change" }], |
| | | odometerMileage: [{ required: true, message: "请è¾å
¥è¡¨æ¾éç¨", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | const { returnForm, returnRules } = toRefs(returnFormData); |
| | | |
| | | const expandChildData = reactive({}); |
| | | const expandChildLoading = reactive({}); |
| | | |
| | | // ç¨æ·ä¿¡æ¯è¡¨åå¼¹æ¡æ°æ® |
| | | const operationType = ref(""); |
| | | const dialogFormVisible = ref(false); |
| | | const currentId = ref(""); |
| | | |
| | | // è¡¨æ ¼åé
ç½® |
| | | const tableColumns = ref([ |
| | | { label: "车çå·", prop: "carNo", width: "120" }, |
| | | { label: "é¢è²", prop: "color", width: "100" }, |
| | | { label: "åç", prop: "brand", width: "120" }, |
| | | { |
| | | label: "使ç¨ç¶æ", |
| | | prop: "usageStatus", |
| | | dataType: "tag", |
| | | formatType: (val) => { |
| | | if (val === "空é²") return "success"; |
| | | if (val === "使ç¨ä¸") return "warning"; |
| | | if (val === "ç»´ä¿®ä¸") return "danger"; |
| | | return "info"; |
| | | }, |
| | | }, |
| | | { label: "å½å使ç¨äºº", prop: "currentUserName", }, |
| | | { label: "表æ¾éç¨(km)", prop: "odometerMileage",}, |
| | | { label: "å建æ¶é´", prop: "createTime", width: "180" }, |
| | | { |
| | | label: "æä½", |
| | | dataType: "slot", |
| | | slot: "operation", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: "180", |
| | | }, |
| | | ]); |
| | | |
| | | // æ¥è¯¢å表 |
| | | const handleQuery = () => { |
| | | page.current = 1; |
| | | expandRowKeys.value = []; |
| | | getList(); |
| | | }; |
| | | |
| | | const paginationChange = (obj) => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getList(); |
| | | }; |
| | | |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | listVehicle(page, searchForm) |
| | | .then((res) => { |
| | | tableLoading.value = false; |
| | | tableData.value = res.data.records; |
| | | total.value = res.data.total || 0; |
| | | }) |
| | | .catch(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | // è¡¨æ ¼éæ©æ°æ® |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | // å±å¼åè¡¨æ°æ® |
| | | const handleExpandChange = (row, expandedRows) => { |
| | | expandRowKeys.value = expandedRows.map((item) => item.id); |
| | | if (expandRowKeys.value.includes(row.id)) { |
| | | loadChildRecords(row.id); |
| | | } |
| | | }; |
| | | |
| | | const loadChildRecords = (carInfoId) => { |
| | | if (expandChildLoading[carInfoId]) return; |
| | | expandChildLoading[carInfoId] = true; |
| | | getVehicleUsageRecords({ current: 1, size: 20 }, { carInfoId }) |
| | | .then((res) => { |
| | | expandChildData[carInfoId] = res.records || res.data || []; |
| | | }) |
| | | .finally(() => { |
| | | expandChildLoading[carInfoId] = false; |
| | | }); |
| | | }; |
| | | |
| | | // æå¼å¼¹æ¡ |
| | | const openForm = async (type, row) => { |
| | | operationType.value = type; |
| | | form.value = { |
| | | carNo: "", |
| | | color: "", |
| | | brand: "", |
| | | usageStatus: "空é²", |
| | | odometerMileage: 0, |
| | | remark: "", |
| | | }; |
| | | |
| | | const userLists = await userListNoPage(); |
| | | userList.value = userLists.data || []; |
| | | |
| | | if (type !== "add") { |
| | | currentId.value = row.id; |
| | | // ç´æ¥ä½¿ç¨è¡¨æ ¼è¡æ°æ®ï¼ä¸åè°ç¨API |
| | | form.value = { ...row }; |
| | | } |
| | | dialogFormVisible.value = true; |
| | | }; |
| | | |
| | | // æäº¤è¡¨å |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (operationType.value === "add") { |
| | | addVehicle(form.value).then(() => { |
| | | proxy.$modal.msgSuccess("æ°å¢æå"); |
| | | closeDia(); |
| | | getList(); |
| | | }); |
| | | } else { |
| | | form.value.id = currentId.value; |
| | | updateVehicle(form.value).then(() => { |
| | | proxy.$modal.msgSuccess("ä¿®æ¹æå"); |
| | | closeDia(); |
| | | getList(); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | // å
³éå¼¹æ¡ |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | | dialogFormVisible.value = false; |
| | | currentId.value = ""; |
| | | }; |
| | | |
| | | // æå¼ä½¿ç¨è½¦è¾å¼¹æ¡ |
| | | const openUseForm = async (row) => { |
| | | currentUseRow.value = row; |
| | | useForm.value = { |
| | | carInfoId: row.id, |
| | | destination: "", |
| | | carRentalDate: dayjs().format("YYYY-MM-DD"), |
| | | odometerMileage: row.odometerMileage || 0, |
| | | thisTripMileage: 0, |
| | | userName: "", |
| | | remark: "", |
| | | }; |
| | | |
| | | const userLists = await userListNoPage(); |
| | | userList.value = userLists.data || []; |
| | | |
| | | useFormVisible.value = true; |
| | | }; |
| | | |
| | | // æäº¤ä½¿ç¨è½¦è¾è¡¨å |
| | | const submitUseForm = () => { |
| | | proxy.$refs["useFormRef"].validate((valid) => { |
| | | if (valid) { |
| | | useVehicle(useForm.value).then(() => { |
| | | proxy.$modal.msgSuccess("使ç¨è½¦è¾æå"); |
| | | closeUseDia(); |
| | | getList(); |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | // å
³é使ç¨è½¦è¾å¼¹æ¡ |
| | | const closeUseDia = () => { |
| | | try { |
| | | proxy.resetForm("useFormRef"); |
| | | } catch (error) { |
| | | console.error("Error resetting form:", error); |
| | | } |
| | | useFormVisible.value = false; |
| | | currentUseRow.value = null; |
| | | }; |
| | | |
| | | // æå¼ä½¿ç¨è®°å½å¼¹çª |
| | | const openUsageRecordsDialog = async (row) => { |
| | | usageRecordsVisible.value = true; |
| | | usageRecordsPage.current = 1; |
| | | loadUsageRecords(row.id); |
| | | }; |
| | | |
| | | // å 载使ç¨è®°å½ |
| | | const loadUsageRecords = (carInfoId) => { |
| | | usageRecordsLoading.value = true; |
| | | getVehicleUsageRecords(usageRecordsPage, { carInfoId: carInfoId }) |
| | | .then((res) => { |
| | | usageRecordsData.value = res.data.records; |
| | | usageRecordsTotal.value = res.data.total || 0; |
| | | }) |
| | | .finally(() => { |
| | | usageRecordsLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | // 使ç¨è®°å½å页 |
| | | const usageRecordsPaginationChange = (obj) => { |
| | | usageRecordsPage.current = obj.page; |
| | | usageRecordsPage.size = obj.limit; |
| | | loadUsageRecords(currentUseRow.value.id); |
| | | }; |
| | | |
| | | // å
³é使ç¨è®°å½å¼¹çª |
| | | const closeUsageRecords = () => { |
| | | usageRecordsVisible.value = false; |
| | | }; |
| | | |
| | | // æå¼è¿è½¦å¼¹æ¡ |
| | | const openReturnForm = async (row) => { |
| | | currentReturnRow.value = row; |
| | | returnForm.value = { |
| | | carInfoId: row.id, |
| | | carReturnDate: dayjs().format("YYYY-MM-DD"), |
| | | odometerMileage: row.odometerMileage || 0, |
| | | remark: "", |
| | | }; |
| | | |
| | | const userLists = await userListNoPage(); |
| | | userList.value = userLists.data || []; |
| | | |
| | | returnFormVisible.value = true; |
| | | }; |
| | | |
| | | // æäº¤è¿è½¦è¡¨å |
| | | const submitReturnForm = () => { |
| | | proxy.$refs["returnFormRef"].validate((valid) => { |
| | | if (valid) { |
| | | // èªå¨è®¾ç½®ä½¿ç¨ç¶æä¸ºç©ºé²å¹¶æ·»å 车è¾è®°å½ID |
| | | const formData = { |
| | | ...returnForm.value, |
| | | usageStatus: "空é²", |
| | | id: currentReturnRow.value.carInfoRecordId |
| | | }; |
| | | returnVehicle(formData).then(() => { |
| | | proxy.$modal.msgSuccess("è¿è½¦æå"); |
| | | closeReturnDia(); |
| | | getList(); |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | // å
³éè¿è½¦å¼¹æ¡ |
| | | const closeReturnDia = () => { |
| | | proxy.resetForm("returnFormRef"); |
| | | returnFormVisible.value = false; |
| | | currentReturnRow.value = null; |
| | | }; |
| | | |
| | | // å¯¼åº |
| | | const handleOut = () => { |
| | | ElMessageBox.confirm("éä¸çå
容å°è¢«å¯¼åºï¼æ¯å¦ç¡®è®¤å¯¼åºï¼", "导åº", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | proxy.download("/vehicleManagement/export", {}, "车è¾ç®¡ç.xlsx"); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已忶"); |
| | | }); |
| | | }; |
| | | |
| | | // å é¤ |
| | | const handleDelete = () => { |
| | | let ids = []; |
| | | if (selectedRows.value.length > 0) { |
| | | ids = selectedRows.value.map((item) => item.id); |
| | | } else { |
| | | proxy.$modal.msgWarning("è¯·éæ©æ°æ®"); |
| | | return; |
| | | } |
| | | ElMessageBox.confirm("éä¸çå
容å°è¢«å é¤ï¼æ¯å¦ç¡®è®¤å é¤ï¼", "å é¤", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | delVehicle(ids).then(() => { |
| | | proxy.$modal.msgSuccess("å 餿å"); |
| | | getList(); |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已忶"); |
| | | }); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .ml-10 { |
| | | margin-left: 10px; |
| | | } |
| | | |
| | | .table_list { |
| | | margin-top: unset; |
| | | } |
| | | |
| | | .actions { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | margin-bottom: 10px; |
| | | } |
| | | </style> |