Commit 6fa418e4efe2f1da3ee9dc3fe077d3dd925281d1

Authored by liujun001
1 parent d6fa5a51

优化图片上传和显示

src/api/driver/driver.js
... ... @@ -38,7 +38,7 @@ export function addDriver(data) {
38 38 // 修改驾驶员信息
39 39 export function updateDriver(data) {
40 40 return request({
41   - url: '/driver/driver',
  41 + url: '/driver/driver/edit',
42 42 method: 'put',
43 43 data: data
44 44 })
... ...
src/components/ImageUpload/index.vue
... ... @@ -64,7 +64,7 @@ const number = ref(0);
64 64 const uploadList = ref([]);
65 65 const dialogImageUrl = ref("");
66 66 const dialogVisible = ref(false);
67   -const baseUrl = import.meta.env.VITE_APP_BASE_API;
  67 +const baseUrl = "";
68 68 const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + props.uploadUrlSuffix); // 上传的图片服务器地址
69 69 const headers = ref({ Authorization: "Bearer " + getToken() });
70 70 const fileList = ref([]);
... ... @@ -73,17 +73,17 @@ const showTip = computed(
73 73 );
74 74  
75 75 watch(() => props.modelValue, val => {
  76 + console.log("value=========>"+val);
  77 +
76 78 if (val) {
77 79 // 首先将值转为数组
78 80 const list = Array.isArray(val) ? val : props.modelValue.split(",");
79 81 // 然后将数组转为对象数组
80 82 fileList.value = list.map(item => {
  83 + console.log("111111111111111111111111");
  84 +
81 85 if (typeof item === "string") {
82   - if (item.indexOf(baseUrl) === -1) {
83   - item = { name: baseUrl + item, url: baseUrl + item };
84   - } else {
85   - item = { name: item, url: item };
86   - }
  86 + item = { name: item, url: item };
87 87 }
88 88 return item;
89 89 });
... ... @@ -174,6 +174,9 @@ function handleUploadError() {
174 174  
175 175 // 预览
176 176 function handlePictureCardPreview(file) {
  177 + console.log("file.url:"+file.url);
  178 + console.log(file);
  179 +
177 180 dialogImageUrl.value = file.url;
178 181 dialogVisible.value = true;
179 182 }
... ...
src/utils/request.js
... ... @@ -17,7 +17,7 @@ const service = axios.create({
17 17 // axios中请求配置有baseURL选项,表示请求URL公共部分
18 18 baseURL: import.meta.env.VITE_APP_BASE_API,
19 19 // 超时
20   - timeout: 10000
  20 + timeout: 90000
21 21 })
22 22  
23 23 // request拦截器
... ...
src/views/driver/driver/index.vue
... ... @@ -248,6 +248,7 @@ function handleUpdate(row) {
248 248 form.value = response.data;
249 249 open.value = true;
250 250 title.value = "修改驾驶员信息";
  251 +
251 252 });
252 253 }
253 254  
... ...