2 Commits ca8c5111c3 ... ae97bf8924

Auteur SHA1 Bericht Datum
  闪电 ae97bf8924 mod: 1 week geleden
  闪电 03ded972f8 mod:上传图片 1 week geleden

+ 2 - 2
apps/web-ele/.env.development

@@ -1,10 +1,10 @@
1 1
 # 端口号
2
-VITE_PORT=8080
2
+VITE_PORT=8081
3 3
 
4 4
 VITE_BASE=/
5 5
 
6 6
 # 接口地址
7
-VITE_GLOB_API_URL=http://39.164.159.226:8088
7
+# VITE_GLOB_API_URL=http://39.164.159.226:8088
8 8
 # VITE_GLOB_API_URL=http://192.168.1.170:8080
9 9
 VITE_GLOB_FLOW_URL=http://192.168.31.160:8082
10 10
 # 是否开启 Nitro Mock服务,true 为开启,false 为关闭

+ 25 - 0
apps/web-ele/src/api/upload.ts

@@ -0,0 +1,25 @@
1
+import { requestClient } from '#/api/request';
2
+
3
+interface UploadFileParams {
4
+  file: File;
5
+  onError?: (error: Error) => void;
6
+  onProgress?: (progress: { percent: number }) => void;
7
+  onSuccess?: (data: any, file: File) => void;
8
+}
9
+export async function uploadFile({
10
+  file,
11
+  onError,
12
+  onProgress,
13
+  onSuccess,
14
+}: UploadFileParams) {
15
+  try {
16
+    onProgress?.({ percent: 0 });
17
+
18
+    const data = await requestClient.upload('/common/upload', { file });
19
+
20
+    onProgress?.({ percent: 100 });
21
+    onSuccess?.(data, file);
22
+  } catch (error) {
23
+    onError?.(error instanceof Error ? error : new Error(String(error)));
24
+  }
25
+}

+ 84 - 0
apps/web-ele/src/components/upload/config.ts

@@ -0,0 +1,84 @@
1
+import { useAppConfig } from '@vben/hooks';
2
+import { useAccessStore } from '@vben/stores';
3
+
4
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
5
+const accessStore = useAccessStore();
6
+/**
7
+ * 获取上传接口完整地址
8
+ * @param path 上传接口路径,默认为 '/api/core/upload'
9
+ * @returns 完整的上传接口地址
10
+ */
11
+export function getUploadAction(path = '/common/upload'): string {
12
+  return `${apiURL}${path}`;
13
+}
14
+
15
+/**
16
+ * 单张图片上传配置
17
+ * @param action 上传接口路径,默认为 '/common/upload'
18
+ * @returns 上传配置对象
19
+ */
20
+export function getSingleImageUploadConfig(action = '/common/upload') {
21
+  return {
22
+    accept: 'image/*',
23
+    name: 'file',
24
+    listType: 'picture-card' as const,
25
+    multiple: false,
26
+    maxCount: 1,
27
+    limit: 1,
28
+    action: getUploadAction(action),
29
+    headers: {
30
+      Authorization: `Bearer ${accessStore.accessToken}`,
31
+    },
32
+  };
33
+}
34
+
35
+/**
36
+ * 多张图片上传配置
37
+ * @param maxCount 最大上传数量
38
+ * @param action 上传接口路径,默认为 '/api/core/upload'
39
+ * @returns 上传配置对象
40
+ */
41
+export function getMultipleImageUploadConfig(
42
+  maxCount: number,
43
+  action = '/common/upload',
44
+) {
45
+  return {
46
+    accept: 'image/*',
47
+    listType: 'picture-card' as const,
48
+    maxCount,
49
+    name: 'file',
50
+    action: getUploadAction(action),
51
+    headers: {
52
+      Authorization: `Bearer ${accessStore.accessToken}`,
53
+    },
54
+  };
55
+}
56
+
57
+/**
58
+ * 文件上传配置
59
+ * @param accept 接受的文件类型
60
+ * @param listType 列表类型
61
+ * @param maxCount 最大上传数量
62
+ * @param action 上传接口路径,默认为 '/api/core/upload'
63
+ * @returns 上传配置对象
64
+ */
65
+export function getFileUploadConfig(
66
+  accept: string,
67
+  listType: 'picture' | 'picture-card' | 'text' = 'picture-card',
68
+  maxCount?: number,
69
+  action = '/common/upload',
70
+) {
71
+  const config: any = {
72
+    accept,
73
+    listType,
74
+    name: 'file',
75
+    action: getUploadAction(action),
76
+    headers: {
77
+      Authorization: `Bearer ${accessStore.accessToken}`,
78
+    },
79
+  };
80
+  if (maxCount !== undefined) {
81
+    config.maxCount = maxCount;
82
+  }
83
+  return config;
84
+}

+ 1 - 0
apps/web-ele/src/components/upload/index.ts

@@ -0,0 +1 @@
1
+export * from './config';

+ 79 - 23
apps/web-ele/src/views/oilstation/idphoto/idphoto-data.tsx

@@ -1,7 +1,13 @@
1 1
 import type { FormSchemaGetter } from '#/adapter/form';
2 2
 import type { VxeGridProps } from '#/adapter/vxe-table';
3 3
 
4
+import { DictEnum } from '@vben/constants';
5
+
6
+import { stationInfoList } from '#/api/system/infoEntry/stationInfo/stationInfo';
7
+import { getSingleImageUploadConfig } from '#/components/upload';
8
+// import { uploadFile } from '#/api/upload';
4 9
 import { getDictOptions } from '#/utils/dict';
10
+import { renderDict } from '#/utils/render';
5 11
 
6 12
 // 字典标识常量
7 13
 const DICT_KEYS = {
@@ -128,16 +134,16 @@ export const tableColumns: VxeGridProps['columns'] = [
128 134
     title: '有效日期',
129 135
     minWidth: 120,
130 136
   },
131
-  {
132
-    field: 'storageLocationCode',
133
-    title: '存放处',
134
-    minWidth: 100,
135
-    formatter: (params: { cellValue: string; column: any; row: any }) => {
136
-      const options = getStorageLocations();
137
-      const option = options.find((item) => item.value === params.cellValue);
138
-      return option ? option.label : params.cellValue;
139
-    },
140
-  },
137
+  // {
138
+  //   field: 'storageLocationCode',
139
+  //   title: '存放处',
140
+  //   minWidth: 100,
141
+  //   formatter: (params: { cellValue: string; column: any; row: any }) => {
142
+  //     const options = getStorageLocations();
143
+  //     const option = options.find((item) => item.value === params.cellValue);
144
+  //     return option ? option.label : params.cellValue;
145
+  //   },
146
+  // },
141 147
   {
142 148
     field: 'renewalRequirements',
143 149
     title: '更换要求',
@@ -163,12 +169,17 @@ export const tableColumns: VxeGridProps['columns'] = [
163 169
     field: 'statusCode',
164 170
     title: '状态',
165 171
     minWidth: 100,
166
-    formatter: (params: { cellValue: string; column: any; row: any }) => {
167
-      const options = getStatusOptions();
168
-      const option = options.find((item) => item.value === params.cellValue);
169
-      const color = params.cellValue === '1' ? 'success' : 'danger';
170
-      return `<el-tag type="${color}">${option ? option.label : params.cellValue}</el-tag>`;
172
+    slots: {
173
+      default: ({ row }) => {
174
+        return renderDict(row.statusCode, DictEnum.SYS_DISABLED_STATUS);
175
+      },
171 176
     },
177
+    // formatter: (params: { cellValue: string; column: any; row: any }) => {
178
+    //   const options = getStatusOptions();
179
+    //   const option = options.find((item) => item.value === params.cellValue);
180
+    //   const color = params.cellValue === '1' ? 'success' : 'danger';
181
+    //   return `<el-tag type="${color}">${option ? option.label : params.cellValue}</el-tag>`;
182
+    // },
172 183
   },
173 184
   {
174 185
     field: 'action',
@@ -189,12 +200,22 @@ export const drawerFormSchema: FormSchemaGetter = () => [
189 200
     fieldName: 'id',
190 201
   },
191 202
   {
192
-    component: 'Input',
203
+    component: 'ApiSelect',
193 204
     fieldName: 'stationName',
194 205
     label: '油站',
195 206
     componentProps: {
196 207
       placeholder: '请输入油站名称',
197 208
       maxlength: 100,
209
+      api: async () => {
210
+        const resp = await stationInfoList({});
211
+        const data = resp.rows || [];
212
+        return Array.isArray(data)
213
+          ? data.map((item: any) => ({
214
+              label: item.stationName,
215
+              value: item.id,
216
+            }))
217
+          : [];
218
+      },
198 219
     },
199 220
     rules: 'required',
200 221
   },
@@ -317,15 +338,50 @@ export const drawerFormSchema: FormSchemaGetter = () => [
317 338
     label: '下次换证日期',
318 339
   },
319 340
   {
320
-    component: 'Upload',
341
+    component: 'Input',
321 342
     fieldName: 'certificateScanPath',
322 343
     label: '证件扫描件',
323
-    // 注意:该组件的详细实现已在idphoto-drawer.vue中通过插槽自定义
324
-    // 这里仅保留基本配置,实际渲染由插槽控制
325
-    componentProps: {
326
-      // 基础配置
327
-      action: '#',
328
-      multiple: true,
344
+    dependencies: {
345
+      show: () => false,
346
+      triggerFields: [''],
347
+    },
348
+  },
349
+  {
350
+    component: 'Upload',
351
+    fieldName: 'certificateScanPathUrl',
352
+    label: '证件扫描件',
353
+    componentProps: (row: any) => {
354
+      return {
355
+        ...getSingleImageUploadConfig(),
356
+        onSuccess: (res: any) => {
357
+          if (res.code === 200) {
358
+            row.certificateScanPath = res.data.fileName;
359
+            // form.setFieldValue('certificateScanPath', res.data.fileName);
360
+            row.certificateScanPathUrl = [res.data.url].map((url) => ({ url }));
361
+            return res.data;
362
+          }
363
+          // return Promise.reject(res);
364
+        },
365
+      };
366
+    },
367
+
368
+    // 更多属性见:https://ant.design/components/upload-cn
369
+    // accept: '.png,.jpg,.jpeg',
370
+    // // 自动携带认证信息
371
+    // customRequest: uploadFile,
372
+    // disabled: false,
373
+    // maxCount: 1,
374
+    // // 单位:MB
375
+    // maxSize: 2,
376
+    // multiple: false,
377
+    // showUploadList: true,
378
+    // // 上传列表的内建样式,支持四种基本样式 text, picture, picture-card 和 picture-circle
379
+    // listType: 'picture-card',
380
+
381
+    renderComponentContent: () => {
382
+      return {
383
+        default: () => '点击上传',
384
+      };
329 385
     },
330 386
   },
331 387
   {

+ 2 - 43
apps/web-ele/src/views/oilstation/idphoto/idphoto-drawer.vue

@@ -1,14 +1,8 @@
1 1
 <script setup lang="ts">
2
-import type { UploadUserFile } from 'element-plus';
3
-
4 2
 import { onMounted, ref } from 'vue';
5 3
 
6 4
 import { useVbenDrawer, useVbenForm } from '@vben/common-ui';
7 5
 
8
-import { Plus } from '@element-plus/icons-vue';
9
-import { ElIcon, ElUpload } from 'element-plus';
10
-
11
-import { uploadApi } from '#/api/core/upload';
12 6
 import {
13 7
   addIdPhoto,
14 8
   getIdPhotoDetail,
@@ -35,40 +29,6 @@ const DICT_KEYS = {
35 29
 };
36 30
 
37 31
 const uploadUrlRef = ref<string>('');
38
-// 自定义上传方法
39
-const handleUpload = async (options: any) => {
40
-  try {
41
-    // 使用uploadApi进行文件上传
42
-    const res = await uploadApi(options.file);
43
-    // 上传成功后调用onSuccess回调
44
-    const responseData = { url: res.url };
45
-    // 多个文件上传时,url以逗号隔开
46
-    uploadUrlRef.value = uploadUrlRef.value
47
-      ? `${uploadUrlRef.value},${res.url}`
48
-      : res.url;
49
-    console.log('上传成功:', uploadUrlRef.value);
50
-    options.onSuccess(responseData);
51
-  } catch (error) {
52
-    console.error('上传失败:', error);
53
-    options.onError(error);
54
-  }
55
-};
56
-
57
-// 删除文件处理
58
-const handleRemove = (
59
-  uploadFile: UploadUserFile,
60
-  uploadFiles: UploadUserFile[],
61
-) => {
62
-  console.log('删除文件:', uploadFile);
63
-  return true; // 返回true允许删除
64
-};
65
-
66
-// 预览文件处理
67
-const handlePreview = (uploadFile: UploadUserFile) => {
68
-  console.log('预览文件:', uploadFile);
69
-  // 可以实现自定义的预览逻辑
70
-};
71
-
72 32
 // 获取字典选项函数
73 33
 const getDictOptionsByKey = (key: string) => getDictOptions(key);
74 34
 
@@ -186,7 +146,6 @@ const [Drawer, drawerApi] = useVbenDrawer({
186 146
         renewalRequirements:
187 147
           data.renewalRequirements || data.replacementRequirements,
188 148
         // url 数组转换为逗号分隔的字符串
189
-        certificateScanPath: uploadUrlRef.value || '',
190 149
         statusCode: data.statusCode || data.status,
191 150
       };
192 151
 
@@ -213,7 +172,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
213 172
   <Drawer :title="isUpdateRef ? '编辑证照' : '新增证照'">
214 173
     <Form>
215 174
       <!-- 自定义Upload组件插槽 -->
216
-      <template #certificateScanPath="scope">
175
+      <!-- <template #certificateScanPath="scope">
217 176
         <ElUpload
218 177
           v-model:file-list="scope.modelValue"
219 178
           action="#"
@@ -233,7 +192,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
233 192
             </ElIcon>
234 193
           </div>
235 194
         </ElUpload>
236
-      </template>
195
+      </template> -->
237 196
     </Form>
238 197
   </Drawer>
239 198
 </template>

+ 0 - 6
apps/web-ele/src/views/oilstation/idphoto/index.vue

@@ -164,12 +164,6 @@ async function exportHandle() {
164 164
       <template #toolbar-tools>
165 165
         <ElSpace>
166 166
           <ElButton
167
-            @click="exportHandle"
168
-            v-access:code="['oilstation:idphoto:export']"
169
-          >
170
-            导出
171
-          </ElButton>
172
-          <ElButton
173 167
             type="danger"
174 168
             :disabled="
175 169
               !(basicTableApi?.grid?.getCheckboxRecords?.()?.length > 0)

+ 2 - 1
packages/@core/base/shared/src/constants/dict-enum.ts

@@ -10,8 +10,10 @@ export enum DictEnum {
10 10
   ROAD_DIRECTION = 'road_direction', // 车道方向
11 11
   ROAD_TYPE = 'road_type', // 道路类型
12 12
   SHIFT_SCHEDULING_TYPE = 'shift_scheduling_type', // 排班方式
13
+  STATION_TYPE = 'station_type', // 场站类型
13 14
   SYS_COMMON_STATUS = 'sys_common_status',
14 15
   SYS_DEVICE_TYPE = 'sys_device_type', // 设备类型
16
+  SYS_DISABLED_STATUS = 'sys_disabled_status', // 禁用状态
15 17
   SYS_GRANT_TYPE = 'sys_grant_type', // 授权类型
16 18
   SYS_JOB_GROUP = 'sys_job_group',
17 19
   SYS_JOB_STATUS = 'sys_job_status',
@@ -27,5 +29,4 @@ export enum DictEnum {
27 29
   WF_BUSINESS_STATUS = 'wf_business_status', // 业务状态
28 30
   WF_FORM_TYPE = 'wf_form_type', // 表单类型
29 31
   WF_TASK_STATUS = 'wf_task_status', // 任务状态
30
-  STATION_TYPE = 'station_type', // 场站类型
31 32
 }