OfficeApp/subpkg/otherTask/otherTask.vue

221 lines
5.8 KiB
Vue
Raw Normal View History

2023-08-28 18:24:47 +08:00
<template>
2023-08-29 16:02:08 +08:00
<view style="padding-top: 28rpx;padding-bottom: 160rpx;">
2023-08-28 18:24:47 +08:00
<view class="card">
2023-09-14 14:27:42 +08:00
<view class="title">任务名称: {{task_info.title}}</view>
2023-08-28 18:24:47 +08:00
<u-line style="margin: 14rpx 0;"></u-line>
2023-09-14 14:27:42 +08:00
<!-- <view class="text">阶段类型: 单次</view> -->
<view class="text" style="color: #FF7C32;">任务金额: {{task_info.money}}</view>
2023-08-28 18:24:47 +08:00
</view>
<view class="card">
<view class="title">任务描述</view>
<u-line style="margin: 14rpx 0;"></u-line>
2023-09-14 14:27:42 +08:00
<view class="text">{{task_info.content}}</view>
2023-08-28 18:24:47 +08:00
</view>
<view class="card">
2023-08-28 19:36:09 +08:00
<view class="title">详情描述</view>
2023-08-28 18:24:47 +08:00
<u-line style="margin: 14rpx 0;"></u-line>
2023-09-14 14:27:42 +08:00
<u--textarea v-model="other.note" placeholder="请输入内容" placeholderStyle="font-size: 22rpx;"
style="font-size: 28rpx;background-color: #eee;min-height: 100px;" autoHeight maxlength="-1"></u--textarea>
2023-08-29 16:02:08 +08:00
<view class="title" style="margin: 16rpx 0;">添加附件</view>
<view class="file">
2023-09-14 14:27:42 +08:00
<view class="file_item" v-for="(item, index) in fileList" :key="'file'+index">
2023-08-29 16:02:08 +08:00
<image class="image" :src="item" @click="priview(index)"></image>
<image class="del" src="/static/icons/delete.png" @click.stop="deleteFile(index)"></image>
</view>
2023-09-14 14:27:42 +08:00
<view class="file_btn" @click="chooseFile">
<image src="/static/icons/plus.png"></image>
</view>
2023-08-29 16:02:08 +08:00
<view class="file_empty" v-for="k in placeholderLength" :key="'empty'+k"></view>
</view>
2023-08-28 18:24:47 +08:00
</view>
2023-09-14 14:27:42 +08:00
<mybtn v-if="!other.is_commit" text="确认提交" @click="$u.throttle(submit, 1500)"></mybtn>
<mybtn v-else-if="task_info.status==3" text="已完成" :my_btn_disabled="true"></mybtn>
<mybtn v-else-if="task_info.status==5" text="已关闭" :my_btn_disabled="true"></mybtn>
<mybtn v-else text="已提交" :my_btn_disabled="true"></mybtn>
2023-08-28 18:24:47 +08:00
</view>
</template>
<script>
2023-08-29 16:02:08 +08:00
import {
2023-09-14 14:27:42 +08:00
upLoadImage
2023-08-29 16:02:08 +08:00
} from "@/api/file.js"
2023-09-14 11:02:19 +08:00
import {
2023-09-14 14:27:42 +08:00
taskOtherTaskDetail,
taskOtherTaskUpload
2023-09-14 11:02:19 +08:00
} from "@/api/task.js"
2023-09-14 14:27:42 +08:00
import { Toast } from "../../libs/uniApi";
2023-08-28 18:24:47 +08:00
export default {
data() {
return {
task_id: -1,
2023-09-14 14:27:42 +08:00
task_info: {
},
other: {
annex: [], // 附件列表
is_commit: 0, // 是否提交
note: "", // 详情描述
},
fileList: []
2023-08-28 18:24:47 +08:00
};
},
onLoad(options) {
this.task_id = options.task_id;
2023-09-14 11:02:19 +08:00
this.initDetail();
2023-08-28 18:24:47 +08:00
},
2023-09-14 14:27:42 +08:00
computed: {
2023-08-29 16:02:08 +08:00
// 占位长度
2023-09-14 14:27:42 +08:00
placeholderLength() {
return (this.fileList.length + 1) % 3 == 0 ? 0 : 3 - (this.fileList.length + 1) % 3;
2023-08-29 16:02:08 +08:00
}
},
2023-09-14 14:27:42 +08:00
methods: {
initDetail() {
taskOtherTaskDetail({ id: this.task_id }).then((res) => {
this.task_info = res.data;
this.other = res.data?.extend?.other;
2023-09-14 11:02:19 +08:00
})
},
2023-09-14 14:27:42 +08:00
async submit(){
console.log('提交');
if(this.other.note.trim()=='')return Toast('详情描述不能为空');
await taskOtherTaskUpload({
id: this.task_id,
extend: {
other: {
note: this.other.note,
annex: this.other.annex
}
}
});
this.other.is_commit = 1;
Toast('提交成功')
},
chooseFile() {
2023-08-29 16:02:08 +08:00
uni.chooseImage({
sizeType: ['compressed'],
success: async (res) => {
for (let item of res.tempFiles) {
let res = await upLoadImage({
filePath: item.path,
name: 'file'
});
2023-09-14 14:27:42 +08:00
this.fileList.push(res.data.uri);
2023-08-29 16:02:08 +08:00
}
2023-09-14 14:27:42 +08:00
// this.fileList = [...this.fileList, res.tempFiles]
2023-08-29 16:02:08 +08:00
}
})
},
2023-09-14 14:27:42 +08:00
priview(index) {
2023-08-29 16:02:08 +08:00
uni.previewImage({
2023-09-14 14:27:42 +08:00
urls: this.fileList,
2023-08-29 16:02:08 +08:00
current: index,
longPressActions: {
itemList: ['删除'],
itemColor: '#ff0000',
success(e) {
2023-09-14 14:27:42 +08:00
if (e.tapIndex == 0) this.deleteFile(e.index);
2023-08-29 16:02:08 +08:00
}
},
})
},
2023-09-14 14:27:42 +08:00
deleteFile(index) {
this.fileList.splice(index, 1);
2023-08-29 16:02:08 +08:00
},
2023-09-14 14:27:42 +08:00
navTo(url) {
if (url) {
2023-08-28 18:24:47 +08:00
uni.showLoading({
title: '加载中',
mask: true
});
uni.navigateTo({
2023-09-14 14:27:42 +08:00
url: url,
2023-08-28 18:24:47 +08:00
success() {
uni.hideLoading()
}
})
2023-09-14 14:27:42 +08:00
} else Toast('暂未开放')
2023-08-28 18:24:47 +08:00
},
}
}
</script>
<style lang="scss">
.card {
margin: 0 auto;
margin-bottom: 28rpx;
width: 694rpx;
background: #FFFFFF;
border-radius: 14rpx;
padding: 28rpx;
.title {
font-size: 32rpx;
font-weight: bold;
color: #333333;
}
.text {
line-height: 50rpx;
}
2023-09-14 14:27:42 +08:00
.file {
2023-08-29 16:02:08 +08:00
display: flex;
justify-content: left;
flex-wrap: wrap;
2023-09-14 14:27:42 +08:00
&_item {
2023-08-29 16:02:08 +08:00
flex-shrink: 0;
width: 200rpx;
height: 200rpx;
margin: 0 auto;
margin-bottom: 16rpx;
border: 2px solid #ccc;
border-radius: 10rpx;
overflow: hidden;
position: relative;
2023-09-14 14:27:42 +08:00
.image {
2023-08-29 16:02:08 +08:00
width: 100%;
height: 100%;
}
2023-09-14 14:27:42 +08:00
.del {
2023-08-29 16:02:08 +08:00
position: absolute;
height: 40rpx;
width: 40rpx;
top: 10rpx;
right: 10rpx;
}
}
2023-09-14 14:27:42 +08:00
&_btn {
2023-08-29 16:02:08 +08:00
flex-shrink: 0;
width: 200rpx;
height: 200rpx;
margin: 0 auto;
margin-bottom: 16rpx;
border: 2px solid #ccc;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
border-radius: 10rpx;
2023-09-14 14:27:42 +08:00
image {
2023-08-29 16:02:08 +08:00
width: 100rpx;
height: 100rpx;
}
}
2023-09-14 14:27:42 +08:00
&_empty {
2023-08-29 16:02:08 +08:00
flex-shrink: 0;
width: 200rpx;
height: 200rpx;
margin: 0 auto;
margin-bottom: 16rpx;
border: 2px solid transparent;
}
}
2023-08-28 18:24:47 +08:00
}
</style>