填写日志bug

This commit is contained in:
shijingjing
2022-10-27 10:04:10 +08:00
parent 7f1ab4e039
commit d1e2853b6e
3 changed files with 412 additions and 380 deletions

View File

@@ -169,10 +169,8 @@ export default {
}&partyOrgId=${this.user.partyOrgId}&size=${10000}` }&partyOrgId=${this.user.partyOrgId}&size=${10000}`
) )
.then((res) => { .then((res) => {
if (res.code == 0) { if (res?.data) {
if (res.data.records == null) { if (res.data?.records) {
this.list = [];
} else {
this.list = res.data.records; this.list = res.data.records;
} }
} }

View File

@@ -5,7 +5,13 @@
<view class="main"> <view class="main">
<div class="textarea"> <div class="textarea">
<div class="color-333"><span class="color-red">*</span>活动总结</div> <div class="color-333"><span class="color-red">*</span>活动总结</div>
<textarea type="textarea" placeholder="填写本次活动参与心得体会200字以内" v-model="baseInfo.content" adjust-position="false" maxlength="200"></textarea> <textarea
type="textarea"
placeholder="填写本次活动参与心得体会200字以内"
v-model="baseInfo.content"
adjust-position="false"
maxlength="200"
></textarea>
</div> </div>
<view class="uni-uploader"> <view class="uni-uploader">
<view class="title-box title-box-margin"> <view class="title-box title-box-margin">
@@ -15,11 +21,26 @@
<view class="uni-uploader__files"> <view class="uni-uploader__files">
<block v-for="(image, index) in imageList" :key="index"> <block v-for="(image, index) in imageList" :key="index">
<view class="uni-uploader__file"> <view class="uni-uploader__file">
<image class="uni-uploader__img" :src="image.accessUrl" :data-index="index" @tap="previewImage"></image> <image
<AiUniIcon type="clear" class="icon" color="#8f8f94" size="20" @click="deleteImage(index)"></AiUniIcon> class="uni-uploader__img"
:src="image.accessUrl"
:data-index="index"
@tap="previewImage"
></image>
<AiUniIcon
type="clear"
class="icon"
color="#8f8f94"
size="20"
@click="deleteImage(index)"
></AiUniIcon>
</view> </view>
</block> </block>
<view class="pre-view" @tap="chooseImageType" v-if="imageList.length < 9"> <view
class="pre-view"
@tap="chooseImageType"
v-if="imageList.length < 9"
>
<text class="pre-label">+</text> <text class="pre-label">+</text>
<text class="add-image">添加照片</text> <text class="add-image">添加照片</text>
</view> </view>
@@ -33,57 +54,62 @@
</template> </template>
<script> <script>
import axios from "@/utils/axios.js" import settings from "@/utils/config"
import {mapState} from 'vuex'
export default { export default {
name: "fillLog", name: "fillLog",
data() { data() {
return { return {
reportId:'', reportId: "",
baseInfo: { baseInfo: {
content:'', content: "",
fileIds: [], fileIds: [],
reportId:'', reportId: "",
id:'' id: "",
}, },
imageList: [], imageList: [],
sourceTypeIndex: 2, sourceTypeIndex: 2,
sourceType:[ // 图片来源类型 sourceType: [
['camera'], // 图片来源类型
['album'], ["camera"],
["album"],
], ],
} };
}, },
onLoad(options) { onLoad(options) {
uni.setNavigationBarColor({ uni.setNavigationBarColor({
frontColor: "#ffffff", frontColor: "#ffffff",
backgroundColor: "#e60012", backgroundColor: "#e60012",
}) });
this.baseInfo.reportId = options.reportId; this.baseInfo.reportId = options.reportId;
this.baseInfo.id = options.signupId; this.baseInfo.id = options.signupId;
options.signupContent ? this.logReport() : null; options.signupContent ? this.logReport() : null;
}, },
computed: {
...mapState(['user']),
},
methods: { methods: {
// 选择照片类型 // 选择照片类型
chooseImageType() { chooseImageType() {
let that = this let that = this;
uni.showActionSheet({ uni.showActionSheet({
itemList:['拍照','从相册选择'], itemList: ["拍照", "从相册选择"],
success: function (res) { success: function (res) {
that.sourceTypeIndex = res.tapIndex that.sourceTypeIndex = res.tapIndex;
that.chooseImage() that.chooseImage();
} },
}) });
}, },
showModel(title) { showModel(title) {
uni.showModal({ uni.showModal({
title: '温馨提示', title: "温馨提示",
content: title, content: title,
showCancel: false, showCancel: false,
confirmColor: "#135AB8", confirmColor: "#135AB8",
}) });
}, },
chooseImage: async function () { chooseImage: async function () {
let that = this let that = this;
if (that.imageList.length === 9) { if (that.imageList.length === 9) {
let isContinue = await that.isFullImg(); let isContinue = await that.isFullImg();
if (!isContinue) { if (!isContinue) {
@@ -97,15 +123,15 @@
count: 9, count: 9,
success: (res) => { success: (res) => {
// 图片的本地文件路径列表 // 图片的本地文件路径列表
that.tempFilePaths = res.tempFilePaths that.tempFilePaths = res.tempFilePaths;
// console.log(res.tempFilePaths) // console.log(res.tempFilePaths)
for (let i = 0; i < that.tempFilePaths.length; i++) { for (let i = 0; i < that.tempFilePaths.length; i++) {
let str = '' let str = "";
let token = uni.getStorageSync("token") let token = uni.getStorageSync("token");
// console.log('token',token) // console.log('token',token)
let params = { let params = {
token: token, token: token,
} };
// url String 是 开发者服务器 url // url String 是 开发者服务器 url
// files Aarry 否 需要上传的文件列表。使用 files 时filePath 和 name 不生效。 5+App // files Aarry 否 需要上传的文件列表。使用 files 时filePath 和 name 不生效。 5+App
// filePath String 是 要上传文件资源的路径。 // filePath String 是 要上传文件资源的路径。
@@ -116,47 +142,50 @@
// fail Function 否 接口调用失败的回调函数 // fail Function 否 接口调用失败的回调函数
// complete Function 否 接口调用结束的回调函数(调用成功、失败都会执行) // complete Function 否 接口调用结束的回调函数(调用成功、失败都会执行)
uni.uploadFile({ uni.uploadFile({
url: axios.baseURL + '/admin/file/add', url: settings.baseUrl + "/admin/file/add",
filePath: that.tempFilePaths[i], filePath: that.tempFilePaths[i],
name: 'file', name: "file",
// formData:params, // formData:params,
header: { header: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
'access_token': token, access_token: token,
"Authorization": token Authorization: token,
}, },
success(res) { success(res) {
str = JSON.stringify(JSON.parse(res.data).data[0]).replace(/\"/g, "") str = JSON.stringify(JSON.parse(res.data).data[0]).replace(
/\"/g,
""
);
var temp = { var temp = {
fileId: str.split(";")[1], fileId: str.split(";")[1],
accessUrl: str.split(";")[0], accessUrl: str.split(";")[0],
} };
that.imageList = that.imageList.concat(temp) that.imageList = that.imageList.concat(temp);
if (that.imageList.length > 9) { if (that.imageList.length > 9) {
that.imageList = that.imageList.slice(0, 9) that.imageList = that.imageList.slice(0, 9);
uni.showToast({ uni.showToast({
title: '图片最多只能上传9张', title: "图片最多只能上传9张",
icon: "none" icon: "none",
}) });
} }
that.imgUrl = JSON.stringify(that.imageList) that.imgUrl = JSON.stringify(that.imageList);
}, },
fail(res) { fail(res) {
console.log('error',res) console.log("error", res);
},
});
} }
}) },
} });
}
})
}, },
// 预览图片(大图预览) // 预览图片(大图预览)
previewImage: function (e) { previewImage: function (e) {
let that = this let that = this;
var current = e.target.dataset.index var current = e.target.dataset.index;
var tempList = [] var tempList = [];
for (var i in that.imageList) { for (var i in that.imageList) {
tempList.push(that.imageList[i].accessUrl) tempList.push(that.imageList[i].accessUrl);
} }
uni.previewImage({ uni.previewImage({
@@ -164,15 +193,15 @@
current: tempList[current], current: tempList[current],
urls: tempList, urls: tempList,
longPressActions: { longPressActions: {
itemList: ['发送给朋友', '保存图片', '收藏'], itemList: ["发送给朋友", "保存图片", "收藏"],
success: function (data) { success: function (data) {
// console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片'); // console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
}, },
fail: function (err) { fail: function (err) {
// console.log(err.errMsg); console.log(err.errMsg);
} },
} },
}) });
}, },
// 删除照片 // 删除照片
deleteImage(index) { deleteImage(index) {
@@ -181,59 +210,63 @@
report() { report() {
let arr = []; let arr = [];
if (!this.baseInfo.content) { if (!this.baseInfo.content) {
this.showModel('请填写活动总结') this.showModel("请填写活动总结");
return false return false;
}; }
this.imageList.map((e) => { this.imageList.map((e) => {
arr.push(e.fileId); arr.push(e.fileId);
}) });
this.baseInfo.fileIds = arr; this.baseInfo.fileIds = arr;
this.$instance.post(`/app/apppartyreport/log-add`,this.baseInfo,null).then(res => { this.$instance
.post(`/app/apppartyreport/log-add`, this.baseInfo)
.then((res) => {
if (res.code == 0) { if (res.code == 0) {
uni.showToast({ uni.showToast({
title: '提交', title: "提交",
icon: 'success', icon: "success",
duration: 2000 duration: 2000,
}) });
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1,
}); });
} }
}).catch(err=>{ })
.catch((err) => {
uni.showToast({ uni.showToast({
title: err, title: err,
icon: "none", icon: "none",
duration:1000 duration: 1000,
}) });
}) });
}, },
logReport() { logReport() {
const userInfo = uni.getStorageSync("userInfo") ; this.$instance
this.$instance.post(`/app/apppartyreport/log-report?partyId=${userInfo.partyId}&reportId=${this.baseInfo.reportId}`) .post(
`/app/apppartyreport/log-report?partyId=${this.user.partyId}&reportId=${this.baseInfo.reportId}`
)
.then((res) => { .then((res) => {
if (res.code == 0 && res.data) { if (res.code == 0 && res.data) {
this.baseInfo.content = res.data.content; this.baseInfo.content = res.data.content;
this.baseInfo.fileIds = res.data.fileIds; this.baseInfo.fileIds = res.data.fileIds;
res.data.files.map((e) => { res.data.files.map((e) => {
this.imageList.push({ accessUrl: e.accessUrl, fileId: e.id }); this.imageList.push({ accessUrl: e.accessUrl, fileId: e.id });
}) });
}
})
}
}
} }
});
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.page { .page {
width: 100%; width: 100%;
height: 100%; height: 100%;
header { header {
width: 100%; width: 100%;
height: 112rpx; height: 112rpx;
background-color: #E60012; background-color: #e60012;
} }
.form { .form {
width: 100%; width: 100%;
@@ -275,7 +308,7 @@
align-items: center; align-items: center;
color: #999999; color: #999999;
font-size: 32rpx; font-size: 32rpx;
background-color: #FFFFFF; background-color: #ffffff;
} }
.picker > .AiArea { .picker > .AiArea {
background-color: #fff !important; background-color: #fff !important;
@@ -302,7 +335,6 @@
background-color: #fff; background-color: #fff;
line-height: 48rpx; line-height: 48rpx;
padding: 0; padding: 0;
} }
button::after { button::after {
@@ -330,7 +362,7 @@
justify-content: space-between; justify-content: space-between;
} }
.uni-uploader-info { .uni-uploader-info {
color: #B2B2B2; color: #b2b2b2;
} }
.uni-uploader-body { .uni-uploader-body {
margin-top: 16rpx; margin-top: 16rpx;
@@ -354,10 +386,10 @@
} }
.pre-label { .pre-label {
font-size: 80rpx; font-size: 80rpx;
color: #DDDDDD; color: #dddddd;
} }
.add-image { .add-image {
color: #DDDDDD; color: #dddddd;
font-size: 24rpx; font-size: 24rpx;
} }
.pre-view { .pre-view {
@@ -368,14 +400,13 @@
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
border-radius: 8rpx; border-radius: 8rpx;
border: 2rpx solid #DDDDDD; border: 2rpx solid #dddddd;
} }
.icon { .icon {
position: absolute; position: absolute;
top: -15rpx; top: -15rpx;
right: -10rpx; right: -10rpx;
} }
} }
.report { .report {
position: fixed; position: fixed;
@@ -387,8 +418,6 @@
text-align: center; text-align: center;
background: rgba(230, 0, 18, 1); background: rgba(230, 0, 18, 1);
color: #fff; color: #fff;
} }
} }
</style> </style>

View File

@@ -186,6 +186,11 @@ export default {
url: `./partyDetail?id=${e.id}&listType=${this.navId}` url: `./partyDetail?id=${e.id}&listType=${this.navId}`
}) })
}, },
goToLog(e) {
uni.navigateTo({
url: `./fillLog?signupId=${e.signupId}&reportId=${e.id}&signupContent=${e.signupContent}`
})
}
} }
} }