This commit is contained in:
BianLzhaoMin 2025-04-01 09:53:37 +08:00
parent a889abcfc0
commit ba71fc79c9
2 changed files with 74 additions and 34 deletions

View File

@ -21,7 +21,7 @@ const isError = ref(false)
const taskDescribe = ref('') const taskDescribe = ref('')
const origin = window.location.href const origin = window.location.href
const taskId = ref('') const taskId = ref('26')
if (origin.indexOf('=') > -1) { if (origin.indexOf('=') > -1) {
taskId.value = origin.split('=')[1] taskId.value = origin.split('=')[1]
@ -42,7 +42,7 @@ const getTaskDetailsData = async () => {
} }
} }
getTaskDetailsData() // getTaskDetailsData()
// //
const onSubmitOptions = () => { const onSubmitOptions = () => {

View File

@ -181,39 +181,79 @@ const onSubmitOptions = () => {
.then(async (valid) => { .then(async (valid) => {
if (valid) { if (valid) {
let files = [] let files = []
fileList.value.forEach((f) => { if (fileList.value.length > 0) {
let d = { fileList.value.forEach((f) => {
file: f.url, let d = {
name: 'file', file: f.url,
uri: f.url, name: 'file',
} uri: f.url,
files.push(d)
})
uni.uploadFile({
url: '/manager/option/appUploadFile',
files: files,
name: 'file',
formData: {
param: JSON.stringify(opinionModel.value),
},
success: (res) => {
res = JSON.parse(res.data)
if (res.data === '添加成功') {
uni.$u.toast('提交成功')
opinionModel.value = {
userName: '',
userPhone: '',
unit: '',
userOpinion: '',
}
fileList.value = []
isSuccess.value = true
} else {
uni.$u.toast('添加失败' + res.data)
} }
}, files.push(d)
fail: (err) => {}, })
})
uni.uploadFile({
url: '/manager/option/appUploadFile',
files: files,
name: 'file',
formData: {
param: JSON.stringify(opinionModel.value),
},
success: (res) => {
res = JSON.parse(res.data)
if (res.data === '添加成功') {
uni.$u.toast('提交成功')
opinionModel.value = {
userName: '',
userPhone: '',
unit: '',
userOpinion: '',
}
fileList.value = []
isSuccess.value = true
} else {
uni.$u.toast('添加失败' + res.data)
}
},
fail: (err) => {},
})
} else {
const boundary = '----WebKitFormBoundary' + Math.random().toString(16).substr(2)
const data =
`--${boundary}\r\n` +
`Content-Disposition: form-data; name="param"\r\n\r\n` +
`${JSON.stringify(opinionModel.value)}\r\n` +
`--${boundary}--`
uni.request({
url: '/manager/option/appUploadFile',
method: 'POST',
header: {
'Content-Type': `multipart/form-data; boundary=${boundary}`,
},
data: data,
success: (res) => {
res = JSON.parse(res.data)
if (res.data === '添加成功') {
uni.$u.toast('提交成功')
opinionModel.value = {
userName: '',
userPhone: '',
unit: '',
userOpinion: '',
}
fileList.value = []
isSuccess.value = true
} else {
uni.$u.toast('添加失败' + res.data)
}
},
fail: (err) => {
//
},
})
console.log(result, 'result')
}
} }
}) })
.catch(() => { .catch(() => {