|
|
@ -48,9 +48,10 @@ |
|
|
|
</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" 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"> |
|
|
|
<!-- :action="uploadUrl" --> |
|
|
|
<el-icon> |
|
|
|
<Plus /> |
|
|
|
</el-icon> |
|
|
@ -85,9 +86,10 @@ |
|
|
|
</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" list-type="picture-card" :auto-upload="false" |
|
|
|
:on-change="handleImageChange" :on-success="handleUploadSuccess" :on-error="handleUploadError" |
|
|
|
:before-upload="beforeUpload" :show-file-list="false"> |
|
|
|
<!-- :action="uploadUrl" --> |
|
|
|
<el-icon> |
|
|
|
<Plus /> |
|
|
|
</el-icon> |
|
|
@ -120,7 +122,7 @@ import { useRouter } from 'vue-router'; |
|
|
|
import { usegiftFixedListStone } from '@/stone/giftFixedListStone'; |
|
|
|
import { getPrizeList, addPrize, deletePrize, updatePrize } from '@/api/manage/gift'; |
|
|
|
import { getGradeNameList } from '@/api/manage/level'; |
|
|
|
|
|
|
|
const validator = /^[a-zA-Z0-9\u4e00-\u9fa5]+$/ // 中英文和数字 |
|
|
|
const router = useRouter(); |
|
|
|
const gradeNames = ref([]) |
|
|
|
const tableData = ref([]) |
|
|
@ -143,11 +145,7 @@ const editForm = ref({ |
|
|
|
gradeId: '', |
|
|
|
imageUrl: null |
|
|
|
}) |
|
|
|
// const uploadUrl = 'https://api.homilychart.com/hljw/api/aws/upload'; //生产 |
|
|
|
const uploadUrl = 'http://39.101.133.168:8828/hljw/api/aws/upload'; //测试 |
|
|
|
// const uploadUrl = '/hljw/api/aws/upload' |
|
|
|
// const uploadUrl = 'https://39.101.133.168:8828/hljw/api/aws/upload' |
|
|
|
// const uploadUrl = '/api/upload/upload' |
|
|
|
const uploadUrl = import.meta.env.VITE_UPLOAD_URL |
|
|
|
const formRef = ref(null) |
|
|
|
const uploadRef = ref(null) |
|
|
|
|
|
|
@ -216,6 +214,14 @@ const submitAdd = async () => { |
|
|
|
ElMessage.error('请上传图片'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if(addForm.value.prizeName.length > 15){ |
|
|
|
ElMessage.error('奖品名称最多输入15个字符'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!validator.test(addForm.value.prizeName)) { |
|
|
|
ElMessage.error('礼品名称只能输入中英文和数字') |
|
|
|
return |
|
|
|
} |
|
|
|
try { |
|
|
|
const data = { |
|
|
|
prizeName: addForm.value.prizeName, |
|
|
@ -243,7 +249,7 @@ const submitAdd = async () => { |
|
|
|
} |
|
|
|
// 删除 |
|
|
|
const deleteGift = (row) => { |
|
|
|
ElMessageBox.confirm('确定要删除该等级吗?', '提示', { |
|
|
|
ElMessageBox.confirm('确定要删除该礼品吗?', '提示', { |
|
|
|
confirmButtonText: '确定', |
|
|
|
cancelButtonText: '取消', |
|
|
|
type: 'warning' |
|
|
@ -274,6 +280,14 @@ const submitEdit = async () => { |
|
|
|
ElMessage.error('请上传图片'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if(editForm.value.prizeName.length > 15){ |
|
|
|
ElMessage.error('奖品名称最多输入15个字符'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!validator.test(editForm.value.prizeName)) { |
|
|
|
ElMessage.error('礼品名称只能输入中英文和数字') |
|
|
|
return |
|
|
|
} |
|
|
|
try { |
|
|
|
const data = { |
|
|
|
id: editForm.value.id, |
|
|
@ -308,7 +322,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' }); |
|
|
|
} |
|
|
|