This commit is contained in:
parent
a889abcfc0
commit
ba71fc79c9
|
|
@ -21,7 +21,7 @@ const isError = ref(false)
|
|||
const taskDescribe = ref('')
|
||||
|
||||
const origin = window.location.href
|
||||
const taskId = ref('')
|
||||
const taskId = ref('26')
|
||||
|
||||
if (origin.indexOf('=') > -1) {
|
||||
taskId.value = origin.split('=')[1]
|
||||
|
|
@ -42,7 +42,7 @@ const getTaskDetailsData = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
getTaskDetailsData()
|
||||
// getTaskDetailsData()
|
||||
|
||||
// 填写意见按钮
|
||||
const onSubmitOptions = () => {
|
||||
|
|
|
|||
|
|
@ -181,39 +181,79 @@ const onSubmitOptions = () => {
|
|||
.then(async (valid) => {
|
||||
if (valid) {
|
||||
let files = []
|
||||
fileList.value.forEach((f) => {
|
||||
let d = {
|
||||
file: 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)
|
||||
if (fileList.value.length > 0) {
|
||||
fileList.value.forEach((f) => {
|
||||
let d = {
|
||||
file: f.url,
|
||||
name: 'file',
|
||||
uri: f.url,
|
||||
}
|
||||
},
|
||||
fail: (err) => {},
|
||||
})
|
||||
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)
|
||||
}
|
||||
},
|
||||
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(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue