diff --git a/public/img/bg/bg1.jpg b/public/img/bg/bg1.jpg deleted file mode 100644 index c13e5c9..0000000 Binary files a/public/img/bg/bg1.jpg and /dev/null differ diff --git a/public/img/bg/bg2.jpg b/public/img/bg/bg2.jpg deleted file mode 100644 index a16b980..0000000 Binary files a/public/img/bg/bg2.jpg and /dev/null differ diff --git a/public/img/bg/bg3.jpg b/public/img/bg/bg3.jpg deleted file mode 100644 index b72458d..0000000 Binary files a/public/img/bg/bg3.jpg and /dev/null differ diff --git a/public/img/bg/bg4.jpg b/public/img/bg/bg4.jpg deleted file mode 100644 index 5b5248a..0000000 Binary files a/public/img/bg/bg4.jpg and /dev/null differ diff --git a/public/img/bg1.jpg b/public/img/bg1.jpg deleted file mode 100644 index c13e5c9..0000000 Binary files a/public/img/bg1.jpg and /dev/null differ diff --git a/public/img/bg2.jpg b/public/img/bg2.jpg deleted file mode 100644 index a16b980..0000000 Binary files a/public/img/bg2.jpg and /dev/null differ diff --git a/public/img/bg3.jpg b/public/img/bg3.jpg deleted file mode 100644 index b72458d..0000000 Binary files a/public/img/bg3.jpg and /dev/null differ diff --git a/public/img/bg4.jpg b/public/img/bg4.jpg deleted file mode 100644 index 5b5248a..0000000 Binary files a/public/img/bg4.jpg and /dev/null differ diff --git a/src/components/vehicle-attachment-table/main.vue b/src/components/vehicle-attachment-table/main.vue new file mode 100644 index 0000000..2ad00ef --- /dev/null +++ b/src/components/vehicle-attachment-table/main.vue @@ -0,0 +1,333 @@ + + + + + diff --git a/src/option/transportCapacity/transport-vehicle.js b/src/option/transportCapacity/transport-vehicle.js index 03d14fa..99f9e47 100644 --- a/src/option/transportCapacity/transport-vehicle.js +++ b/src/option/transportCapacity/transport-vehicle.js @@ -9,7 +9,7 @@ export const option = { searchMenuPosition: 'right', border: true, index: true, - selection: false, + selection: true, addBtn: false, editBtn: false, delBtn: false, diff --git a/src/option/vehicle/accident-record.js b/src/option/vehicle/accident-record.js index 96026b6..3c50f5c 100644 --- a/src/option/vehicle/accident-record.js +++ b/src/option/vehicle/accident-record.js @@ -172,6 +172,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/option/vehicle/annual-inspection-record.js b/src/option/vehicle/annual-inspection-record.js index 676ab2e..ae43a81 100644 --- a/src/option/vehicle/annual-inspection-record.js +++ b/src/option/vehicle/annual-inspection-record.js @@ -177,6 +177,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/option/vehicle/etc-record.js b/src/option/vehicle/etc-record.js index a5a6059..602cb5b 100644 --- a/src/option/vehicle/etc-record.js +++ b/src/option/vehicle/etc-record.js @@ -148,6 +148,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/option/vehicle/mileage-record.js b/src/option/vehicle/mileage-record.js index 4e310e6..fb16b18 100644 --- a/src/option/vehicle/mileage-record.js +++ b/src/option/vehicle/mileage-record.js @@ -132,6 +132,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/option/vehicle/oil-electric-record.js b/src/option/vehicle/oil-electric-record.js index 236ee44..41f3f1f 100644 --- a/src/option/vehicle/oil-electric-record.js +++ b/src/option/vehicle/oil-electric-record.js @@ -166,6 +166,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/option/vehicle/other-expense-record.js b/src/option/vehicle/other-expense-record.js index ab2111c..12f0030 100644 --- a/src/option/vehicle/other-expense-record.js +++ b/src/option/vehicle/other-expense-record.js @@ -138,6 +138,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/option/vehicle/tire-replacement-record.js b/src/option/vehicle/tire-replacement-record.js index 043a47b..e936ca2 100644 --- a/src/option/vehicle/tire-replacement-record.js +++ b/src/option/vehicle/tire-replacement-record.js @@ -134,6 +134,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/option/vehicle/transport-change-record.js b/src/option/vehicle/transport-change-record.js index 2791bd5..fde9b5d 100644 --- a/src/option/vehicle/transport-change-record.js +++ b/src/option/vehicle/transport-change-record.js @@ -89,6 +89,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/option/vehicle/violation-record.js b/src/option/vehicle/violation-record.js index 798623a..96ec8f2 100644 --- a/src/option/vehicle/violation-record.js +++ b/src/option/vehicle/violation-record.js @@ -33,7 +33,7 @@ export const processStatusDic = [ export const option = { height: 'auto', calcHeight: 32, - dialogWidth: 960, + dialogWidth: 1200, labelPosition: 'right', labelWidth: 'auto', searchLabelWidth: 88, @@ -208,6 +208,7 @@ export const option = { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/views/base/port-terminal.vue b/src/views/base/port-terminal.vue index a3ae62b..9f0191d 100644 --- a/src/views/base/port-terminal.vue +++ b/src/views/base/port-terminal.vue @@ -136,7 +136,7 @@ filterable :loading="cityLoading" :disabled="isCityDisabled" - :placeholder="isParentRegionLocked ? '自动带出' : '请先选择国家'" + placeholder="请选择" style="width: 100%" @change="handleCityChange" > @@ -155,9 +155,7 @@ filterable :loading="districtLoading" :disabled="isDistrictDisabled" - :placeholder=" - isParentRegionLocked ? '自动带出' : form.cityCode ? '请选择区县' : '选择城市后再选择区县' - " + placeholder="请选择" style="width: 100%" @change="handleDistrictChange" > @@ -443,7 +441,7 @@ export default { hide: true, span: 12, order: 88, - placeholder: '自动带出', + placeholder: '请选择', rules: [{ required: true, message: '请选择所属城市', trigger: 'change' }], }, { @@ -472,7 +470,7 @@ export default { }, dicData: [], span: 12, - placeholder: '选择城市后再选择区县', + placeholder: '请选择', rules: [{ required: true, message: '请选择区县', trigger: 'change' }], }, { diff --git a/src/views/business/components/business-crud-page.vue b/src/views/business/components/business-crud-page.vue index 4aeb52f..6f0e0dc 100644 --- a/src/views/business/components/business-crud-page.vue +++ b/src/views/business/components/business-crud-page.vue @@ -8651,15 +8651,18 @@ export default { handleTaskDriverSelect(target, item = {}) { const value = item.driverName || item.name || ''; const driverPhone = item.mobile || item.phone || item.driverPhone || ''; + const drivingVehicle = String(item.drivingVehicle || '').trim(); if (target === 'dispatch') { this.dispatchItemForm.driverId = item.id || ''; this.dispatchItemForm.driverName = value; if (driverPhone) this.dispatchItemForm.driverPhone = driverPhone; + if (drivingVehicle) this.dispatchItemForm.vehicleNo = drivingVehicle; return; } this.form.driverId = item.id || ''; this.form.driverName = value; if (driverPhone) this.form.driverPhone = driverPhone; + if (drivingVehicle) this.form.vehicleNo = drivingVehicle; }, handleTaskDriverChange(value) { const driver = this.taskDriverOptions.find(item => @@ -8670,6 +8673,9 @@ export default { if (driver) { this.form.driverPhone = driver.mobile || driver.phone || driver.driverPhone || this.form.driverPhone || ''; + if (String(driver.drivingVehicle || '').trim()) { + this.form.vehicleNo = String(driver.drivingVehicle).trim(); + } } }, getTaskCargoTypeOptionsKey(path = []) { @@ -12348,6 +12354,9 @@ export default { driver.driverPhone || this.dispatchItemForm.driverPhone || ''; + if (String(driver.drivingVehicle || '').trim()) { + this.dispatchItemForm.vehicleNo = String(driver.drivingVehicle).trim(); + } } }, getDispatchCargoRowOptions(row = {}) { diff --git a/src/views/business/components/master-order-dispatch.vue b/src/views/business/components/master-order-dispatch.vue index a27800a..db0bb65 100644 --- a/src/views/business/components/master-order-dispatch.vue +++ b/src/views/business/components/master-order-dispatch.vue @@ -543,7 +543,12 @@ export default { driverOptionKey(item) { return item.id || item.driverId || this.driverOptionLabel(item) || item.mobile; }, handleDriverChange(route, value) { const driver = this.driverOptions.find(item => this.driverOptionLabel(item) === value); - if (driver) route.driverPhone = driver.mobile || driver.driverPhone || driver.phone || ''; + if (driver) { + route.driverPhone = driver.mobile || driver.driverPhone || driver.phone || ''; + if (String(driver.drivingVehicle || '').trim()) { + route.vehicleNo = String(driver.drivingVehicle).trim(); + } + } }, async loadCarrierOptions() { this.carrierLoading = true; @@ -577,6 +582,8 @@ export default { route.driverName = this.driverOptionLabel(item); route.driverId = item.id || item.driverId || ''; route.driverPhone = item.mobile || item.driverPhone || item.phone || route.driverPhone || ''; + const drivingVehicle = String(item.drivingVehicle || '').trim(); + if (drivingVehicle) route.vehicleNo = drivingVehicle; }, setDriverInput(segmentNo, element) { if (element) this.driverInputs[segmentNo] = element; diff --git a/src/views/business/contract-manage-change.vue b/src/views/business/contract-manage-change.vue index 2b9496c..3a4267e 100644 --- a/src/views/business/contract-manage-change.vue +++ b/src/views/business/contract-manage-change.vue @@ -1,26 +1,32 @@ + + + + + + + + + + + + + + @@ -494,7 +575,9 @@ import { mapGetters } from 'vuex'; import NProgress from 'nprogress'; import { ElLoading } from 'element-plus'; +import { List } from '@element-plus/icons-vue'; import { option } from '@/option/transportCapacity/driver'; +import { option as transportVehicleOption } from '@/option/transportCapacity/transport-vehicle'; import { getList, getDetail, @@ -506,6 +589,7 @@ import { recognitionTransportCertificates, recognizeBaiduOcr, } from '@/api/transportCapacity/driver'; +import { getList as getVehicleList } from '@/api/transportCapacity/transport-vehicle'; import { getDeptTree } from '@/api/system/dept'; import { getDictionary } from '@/api/system/dictbiz'; import { getLazyTree } from '@/api/base/region'; @@ -515,6 +599,25 @@ import { getUploadHeaders } from '@/utils/upload'; import { downloadXls } from '@/utils/util'; import ImageUploadField from '@/components/image-upload-field/main.vue'; +const vehicleSelectorOption = { + ...transportVehicleOption, + height: 430, + selection: false, + addBtn: false, + editBtn: false, + delBtn: false, + viewBtn: false, + columnBtn: false, + menuWidth: 90, + menuFixed: 'right', + column: transportVehicleOption.column.map(column => ({ + ...column, + dicData: Array.isArray(column.dicData) + ? column.dicData.map(item => ({ ...item })) + : column.dicData, + })), +}; + const emptyForm = () => ({ id: '', driverName: '', @@ -526,6 +629,7 @@ const emptyForm = () => ({ addressRegionPath: [], addressRegion: '', address: '', + drivingVehicle: '', postList: ['司机'], posts: '', idCardFront: '', @@ -560,6 +664,7 @@ export default { data() { return { option, + List, form: {}, query: { expireStatus: '', @@ -581,6 +686,17 @@ export default { expired: 0, }, driverBox: false, + vehicleSelectorVisible: false, + vehicleSelectorLoading: false, + vehicleSelectorOption, + vehicleSelectorForm: {}, + vehicleSelectorData: [], + vehicleSelectorSearchForm: {}, + vehicleSelectorPage: { + pageSize: 10, + currentPage: 1, + total: 0, + }, readonly: false, driverForm: emptyForm(), drivingLicenseUploads: {}, @@ -745,6 +861,11 @@ export default { this.organizationOptions = this.formatDeptOptions(res.data.data || []); const column = this.findColumn(this.option.column, 'organizationName'); column.dicData = this.organizationOptions; + const vehicleColumn = this.findColumn( + this.vehicleSelectorOption.column, + 'organizationName' + ); + vehicleColumn.dicData = this.organizationOptions; if (this.driverBox && !this.driverForm.id && !this.driverForm.organizationName) { this.driverForm.organizationName = this.getCurrentOrganizationName(); } @@ -952,6 +1073,75 @@ export default { this.submitLoading = false; this.$refs.driverForm?.clearValidate(); }, + openVehicleSelector() { + if (this.readonly) return; + this.vehicleSelectorPage.currentPage = 1; + this.vehicleSelectorVisible = true; + }, + resetVehicleSelector() { + this.vehicleSelectorForm = {}; + this.vehicleSelectorData = []; + this.vehicleSelectorSearchForm = {}; + this.vehicleSelectorPage = { + pageSize: 10, + currentPage: 1, + total: 0, + }; + }, + normalizeVehicleSelectorQuery(params = {}) { + const query = { + ...this.vehicleSelectorSearchForm, + ...params, + }; + if (Array.isArray(query.organizationName)) { + query.organizationName = query.organizationName[query.organizationName.length - 1] || ''; + } + return query; + }, + loadVehicleSelector(page = this.vehicleSelectorPage, params = {}) { + this.vehicleSelectorLoading = true; + getVehicleList(page.currentPage, page.pageSize, this.normalizeVehicleSelectorQuery(params)) + .then(res => { + const data = res.data.data || {}; + this.vehicleSelectorData = data.records || []; + this.vehicleSelectorPage.total = data.total || 0; + }) + .finally(() => { + this.vehicleSelectorLoading = false; + }); + }, + vehicleSelectorSearchChange(params, done) { + this.vehicleSelectorSearchForm = params; + this.vehicleSelectorPage.currentPage = 1; + this.loadVehicleSelector(this.vehicleSelectorPage, params); + done(); + }, + vehicleSelectorSearchReset() { + this.vehicleSelectorSearchForm = {}; + this.vehicleSelectorPage.currentPage = 1; + this.loadVehicleSelector(); + }, + vehicleSelectorCurrentChange(currentPage) { + this.vehicleSelectorPage.currentPage = currentPage; + }, + vehicleSelectorSizeChange(pageSize) { + this.vehicleSelectorPage.pageSize = pageSize; + }, + vehicleSelectorRefreshChange() { + this.loadVehicleSelector(); + }, + selectDrivingVehicle(row) { + this.driverForm.drivingVehicle = row.plateNo || ''; + this.vehicleSelectorVisible = false; + }, + getVehicleCertificationStatus(row) { + const statusMap = { + 0: { label: '认证中', type: 'warning' }, + 1: { label: '已认证', type: 'success' }, + 2: { label: '已驳回', type: 'danger' }, + }; + return statusMap[row.certificationStatus] || { label: '-', type: 'info' }; + }, setImage(prop, url) { this.driverForm[prop] = url; this.$refs.driverForm?.validateField(prop); diff --git a/src/views/vehicle/accident-record.vue b/src/views/vehicle/accident-record.vue index 3829fa6..d1c4bd3 100644 --- a/src/views/vehicle/accident-record.vue +++ b/src/views/vehicle/accident-record.vue @@ -96,22 +96,10 @@ {{ formatAttachments(row.attachments) }} {{ formatAttachments(row.attachments) }} - + @@ -111,12 +111,16 @@ import { exportBlob } from '@/api/common'; import { downloadXls } from '@/utils/util'; import { openImportDialog } from '@/utils/import-excel'; import { getToken } from '@/utils/auth'; +import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue'; import { mapGetters } from 'vuex'; import { excelOption, option } from '@/option/vehicle/etc-record'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; export default { + components: { + VehicleAttachmentTable, + }, data() { return { form: {}, diff --git a/src/views/vehicle/maintenance-plan.vue b/src/views/vehicle/maintenance-plan.vue index b8e06ff..05edc61 100644 --- a/src/views/vehicle/maintenance-plan.vue +++ b/src/views/vehicle/maintenance-plan.vue @@ -122,22 +122,10 @@ {{ formatAttachments(row.attachments) }} @@ -169,6 +157,7 @@ import { formatUpdateUserName } from '@/utils/audit'; import { getToken } from '@/utils/auth'; import { normalizeSearchRangeParams } from '@/utils/search-range'; import AddressMapPicker from '@/components/address-map-picker/main.vue'; +import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue'; import { mapGetters } from 'vuex'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; @@ -180,6 +169,7 @@ const createTimeRangeMap = { export default { components: { AddressMapPicker, + VehicleAttachmentTable, }, data() { const validateNonNegative = (rule, value, callback) => { @@ -377,6 +367,7 @@ export default { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, diff --git a/src/views/vehicle/maintenance-record.vue b/src/views/vehicle/maintenance-record.vue index ead8988..eeefac9 100644 --- a/src/views/vehicle/maintenance-record.vue +++ b/src/views/vehicle/maintenance-record.vue @@ -106,22 +106,10 @@ {{ formatAttachments(row.attachments) }} @@ -153,6 +141,7 @@ import { formatUpdateUserName } from '@/utils/audit'; import { getToken } from '@/utils/auth'; import { normalizeSearchRangeParams } from '@/utils/search-range'; import AddressMapPicker from '@/components/address-map-picker/main.vue'; +import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue'; import { mapGetters } from 'vuex'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; @@ -164,6 +153,7 @@ const createTimeRangeMap = { export default { components: { AddressMapPicker, + VehicleAttachmentTable, }, data() { const validateNonNegative = (rule, value, callback) => { @@ -362,6 +352,7 @@ export default { { label: '附件', prop: 'attachments', + hide: true, span: 24, minWidth: 100, slot: true, @@ -542,9 +533,14 @@ export default { .catch(() => callback([])); }, formatMileage(value, unit) { - if (value === undefined || value === null || value === '') return ''; + if (this.normalizeMileageValue(value) === null) return ''; return `${Math.max(Number(value), 0)} ${unit || '公里'}`; }, + normalizeMileageValue(value) { + if (value === undefined || value === null || value === '' || Number(value) === -1) + return null; + return value; + }, formatAttachments(value) { if (!value) return ''; if (Array.isArray(value)) return `${value.length} 个`; @@ -595,6 +591,7 @@ export default { const values = { ...row }; values.vehicleType = values.vehicleType || '车辆'; values.mileageUnit = values.vehicleType === '船舶' ? '海里' : '公里'; + values.mileage = this.normalizeMileageValue(values.mileage); if (values.vehicleNo) { values.vehicleNo = values.vehicleType === '船舶' @@ -676,6 +673,7 @@ export default { detail.attachments = this.parseAttachments(detail.attachments); detail.vehicleType = detail.vehicleType || '车辆'; detail.mileageUnit = detail.vehicleType === '船舶' ? '海里' : '公里'; + detail.mileage = this.normalizeMileageValue(detail.mileage); this.form = detail; this.updateVehicleType(detail.vehicleType); }) diff --git a/src/views/vehicle/mileage-record.vue b/src/views/vehicle/mileage-record.vue index 1467676..ccb7aaa 100644 --- a/src/views/vehicle/mileage-record.vue +++ b/src/views/vehicle/mileage-record.vue @@ -149,10 +149,10 @@ {{ formatAttachments(row.attachments) }} {{ formatAttachments(row.attachments) }} @@ -143,12 +143,16 @@ import { exportBlob } from '@/api/common'; import { downloadXls } from '@/utils/util'; import { openImportDialog } from '@/utils/import-excel'; import { getToken } from '@/utils/auth'; +import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue'; import { mapGetters } from 'vuex'; import { excelOption, option } from '@/option/vehicle/oil-electric-record'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; export default { + components: { + VehicleAttachmentTable, + }, data() { return { form: {}, diff --git a/src/views/vehicle/other-expense-record.vue b/src/views/vehicle/other-expense-record.vue index cd5812e..11514f8 100644 --- a/src/views/vehicle/other-expense-record.vue +++ b/src/views/vehicle/other-expense-record.vue @@ -85,10 +85,10 @@ {{ formatAttachments(row.attachments) }} @@ -112,12 +112,16 @@ import { exportBlob } from '@/api/common'; import { downloadXls } from '@/utils/util'; import { openImportDialog } from '@/utils/import-excel'; import { getToken } from '@/utils/auth'; +import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue'; import { mapGetters } from 'vuex'; import { excelOption, option } from '@/option/vehicle/other-expense-record'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; export default { + components: { + VehicleAttachmentTable, + }, data() { return { form: {}, diff --git a/src/views/vehicle/tire-replacement-record.vue b/src/views/vehicle/tire-replacement-record.vue index e282262..8112a29 100644 --- a/src/views/vehicle/tire-replacement-record.vue +++ b/src/views/vehicle/tire-replacement-record.vue @@ -94,22 +94,10 @@ {{ formatAttachments(row.attachments) }} {{ formatAttachments(row.attachments) }} @@ -102,6 +102,7 @@ import { downloadXls } from '@/utils/util'; import { openImportDialog } from '@/utils/import-excel'; import { getToken } from '@/utils/auth'; import { normalizeSearchRangeParams } from '@/utils/search-range'; +import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue'; import { mapGetters } from 'vuex'; import { excelOption, option } from '@/option/vehicle/transport-change-record'; import NProgress from 'nprogress'; @@ -112,6 +113,9 @@ const createTimeRangeMap = { }; export default { + components: { + VehicleAttachmentTable, + }, data() { return { form: {}, diff --git a/src/views/vehicle/violation-record.vue b/src/views/vehicle/violation-record.vue index ebe07e1..c6d1cd5 100644 --- a/src/views/vehicle/violation-record.vue +++ b/src/views/vehicle/violation-record.vue @@ -128,22 +128,10 @@ {{ formatAttachments(row.attachments) }} -
- - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/vite.config.mjs b/vite.config.mjs index 09134a0..1726a3c 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -1,26 +1,27 @@ -import { - defineConfig, - loadEnv -} from 'vite'; -import { resolve } from 'path' +import { defineConfig, loadEnv } from 'vite'; +import { resolve } from 'path'; import createVitePlugins from './vite/plugins'; // https://vitejs.dev/config/ -export default ({ - mode, - command -}) => { - const env = loadEnv(mode, process.cwd()) - const { - VITE_APP_ENV, - VITE_APP_BASE - } = env +export default ({ mode, command }) => { + const env = loadEnv(mode, process.cwd()); + const { VITE_APP_ENV, VITE_APP_BASE } = env; // 判断是打生产环境包 - const isProd = VITE_APP_ENV === 'production' + const isProd = VITE_APP_ENV === 'production'; + + const assetFileNames = assetInfo => { + const fileName = assetInfo.names?.[0] || assetInfo.name || ''; + return fileName.endsWith('.mjs') ? 'assets/[name]-[hash].js' : 'assets/[name]-[hash][extname]'; + }; // 根据是否生产环境,动态设置压缩配置 const buildConfig = { target: 'esnext', minify: isProd ? 'terser' : 'esbuild', // 根据环境选择压缩工具 + rollupOptions: { + output: { + assetFileNames, + }, + }, }; // 如果是生产环境,添加Terser的配置 @@ -31,17 +32,13 @@ export default ({ drop_debugger: true, // 删除 debugger }, format: { - comments: false // 删除所有注释 - } + comments: false, // 删除所有注释 + }, + }; + buildConfig.rollupOptions.output.manualChunks = { + 'element-plus': ['element-plus'], + '@smallwei/avue': ['@smallwei/avue'], }; - buildConfig.rollupOptions = { - output: { - manualChunks: { - 'element-plus': ['element-plus'], - '@smallwei/avue': ['@smallwei/avue'] - }, - } - } } return defineConfig({ base: VITE_APP_BASE, @@ -50,26 +47,26 @@ export default ({ __VUE_I18N_LEGACY_API__: true, __INTLIFY_PROD_DEVTOOLS__: false, }, - // server: { - // port: 2888, - // proxy: { - // '/api': { - // target: 'http://localhost', - // //target: 'https://saber3.bladex.cn/api', - // changeOrigin: true, - // rewrite: path => path.replace(/^\/api/, ''), - // }, - // }, - // }, server: { - port: 2889, + port: 2888, proxy: { '/api': { - target: 'http://172.16.203.228:8000', + target: 'http://localhost', + //target: 'https://saber3.bladex.cn/api', changeOrigin: true, + rewrite: path => path.replace(/^\/api/, ''), }, }, }, + // server: { + // port: 2889, + // proxy: { + // '/api': { + // target: 'http://172.16.203.228:8000', + // changeOrigin: true, + // }, + // }, + // }, resolve: { alias: { '~': resolve(__dirname, './'),