|
|
@ -48,7 +48,7 @@ |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="礼品图片" :rules="{ required: true, message: '请上传图片', trigger: 'change' }"> |
|
|
|
<el-upload ref="uploadRef" :action="uploadUrl" list-type="picture-card" :auto-upload="false" |
|
|
|
<el-upload ref="uploadRef" :action="uploadUrl" list-type="picture-card" :auto-upload="false" :http-request="customUpload" |
|
|
|
:on-change="handleImageChange" :on-success="handleUploadSuccess" :on-error="handleUploadError" |
|
|
|
:before-upload="beforeUpload" :show-file-list="false"> |
|
|
|
<el-icon> |
|
|
@ -143,7 +143,7 @@ const editForm = ref({ |
|
|
|
gradeId: '', |
|
|
|
imageUrl: null |
|
|
|
}) |
|
|
|
const uploadUrl = '/hljw/api/aws/upload'; |
|
|
|
const uploadUrl = ref('/upload') |
|
|
|
const formRef = ref(null) |
|
|
|
const uploadRef = ref(null) |
|
|
|
|
|
|
@ -239,7 +239,7 @@ const submitAdd = async () => { |
|
|
|
} |
|
|
|
// 删除 |
|
|
|
const deleteGift = (row) => { |
|
|
|
ElMessageBox.confirm('确定要删除该等级吗?', '提示', { |
|
|
|
ElMessageBox.confirm('确定要删除该礼品吗?', '提示', { |
|
|
|
confirmButtonText: '确定', |
|
|
|
cancelButtonText: '取消', |
|
|
|
type: 'warning' |
|
|
@ -304,7 +304,30 @@ const goToimportFixedList = (row) => { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
const customUpload = async (options) => { |
|
|
|
try { |
|
|
|
const formData = new FormData(); |
|
|
|
formData.append('file', options.file); |
|
|
|
|
|
|
|
const response = await axios.post(import.meta.env.VITE_UPLOAD_URL, formData, { |
|
|
|
headers: { |
|
|
|
'Content-Type': 'multipart/form-data', |
|
|
|
'Authorization': `Bearer ${localStorage.getItem('token')}` |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if (response.data.code === 200 && response.data.data) { |
|
|
|
// 传递原始文件对象和响应数据 |
|
|
|
handleUploadSuccess(response.data, options.file); |
|
|
|
ElMessage.success('上传成功'); |
|
|
|
} else { |
|
|
|
ElMessage.error(response.data.msg || '上传失败'); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('上传错误:', error); |
|
|
|
ElMessage.error(`上传失败: ${error.response?.data?.message || error.message}`); |
|
|
|
} |
|
|
|
}; |
|
|
|
const goToimportUsers = () => { |
|
|
|
router.push({ name: 'importUsers' }); |
|
|
|
} |
|
|
|