| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- <template>
- <view class="content">
- <view class="param">
- <view class="proMiao mingchen">{{data.taskName}}</view>
- <view class="proMiao title">评分标准</view>
- <view class="prolittle">{{data.scoreStandard}}</view>
- <view class="proMiao title">任务负责人</view>
- <view class="prolittle">{{data.headerName}}</view>
- <view class="proMiao title">评分上限</view>
- <view class="prolittle">{{data.scoreLimit}}</view>
- <view class="proMiao">附件</view>
- <view class="prolittle" v-for="(item,index) in fileList3">
- <view style="color: rgba(0, 97, 255, 1);" @click="navigateToTU(item.name)">{{item.name}}</view>
- </view>
- <view class="proMiao title">权重</view>
- <view class="prolittle">{{data.weight}}</view>
- <view class="proMiao title">提醒时间</view>
- <view class="prolittle">{{data.remindTime}}</view>
- <view class="proMiao title">预警时间</view>
- <view class="prolittle">{{data.warnTime}}</view>
- <view class="proMiao title">任务周期</view>
- <view class="prolittle">{{data.startTime}} - {{data.endTime}}</view>
- <view class="proMiao title">完成说明</view>
- <textarea class="proINname proIMi" v-model="finishRemark" placeholder="请输入完成说明"/>
- <view class="proMiao">上传附件</view>
- <view class="upload-img">
- <uni-file-picker limit="3" :maxMb="2"
- @select='selectUpload'
- @delete="deleteHandle"
- :auto-upload='false'
- file-extname='pdf,docx,jpg,png,jpeg,doc,docm,dot,dotm,dotx,xlsx,xls,csv,xlsm,slxb,xlt,xltx'
- file-mediatype="all"
- @success='uploadSuccess'
- @fail='uploadFail'
- :list-styles='listStyles'
- v-model='fileList'
- ></uni-file-picker>
- </view>
- <span style="margin: 20rpx 0 0 20rpx;width: 700rpx;">支持pdf,docx,jpg,png,jpeg,doc,docm,dot,dotm,dotx,xlsx,xls,csv,xlsm,slxb,xlt,xltx格式,单个文件大小不超过2MB</span>
- <!-- 操作键 -->
- <view class="project">
- <view class="butt quxiao" @click="quxiao">取消</view>
- <view class="butt queren" @click="updateJindu">确定</view>
- </view>
- <view style="width: 100%;height: 60rpx;"></view>
- </view>
- <!-- 图片压缩 -->
- <Compress ref="Compress" />
- </view>
- </template>
- <script>
- import configdata from '@/common/config.js'
- // 引入压缩组件
- import Compress from '@/components/compress/compress.vue'
- export default {
- components:{
- Compress
- },
- data() {
- return {
- data:{},
- fileList3: [],
- // 完成进度上传附件
- fileList: [],
- fileList2: [],
- fileList22:'',
- listStyles: {
- "borderStyle": {
- "width": "0", // 边框宽度
- },
- "border": false, // 是否显示边框
- "dividline": false
- },
- finishRemark:'',//完成说明
- }
- },
- onLoad(option) {
- console.log(JSON.parse(decodeURIComponent(option.data)))
- this.data=JSON.parse(decodeURIComponent(option.data))
- var image=[]
- image=this.data.fileUrl.split(',')
- this.fileList3 =image.map(item =>{
- return {
- name: item
- }
- })
- },
- methods: {
- //跳转页面
- navigateToTU(url) {
- window.location.href = url;
- },
- //取消
- quxiao(){
- uni.navigateBack({
- delta:1
- })
- },
- //更新进度
- updateJindu(){
- let that = this
- uni.showLoading({
- title: '加载中',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- });
- var data={
- "taskId": that.data.id,
- "finishRemark": that.finishRemark,
- "fileUrl":that.fileList22
- }
- that.$Request.postT('/api/sysTask/submitTask',data).then(res => {
- if (res.code==200) {
- uni.showToast({
- title: '更新成功',
- icon: 'none',
- duration:800
- });
- uni.hideLoading()
-
- setTimeout(function() {
- uni.navigateBack({
- delta:1
- })
- // uni.switchTab({
- // url:'/pages/project/index'
- // })
- }, 1000)
- } else {
- uni.hideLoading();
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration:800
- });
- }
- });
- },
- // 上传附件
- uploadSuccess(e) {
- console.log('上传成功', e)
- },
- uploadFail(e) {
- console.log('上传失败:', e)
- },
- //删除文件
- deleteHandle(index){
- console.log(index)
- this.fileList2.splice(index.index,1)
- console.log(this.fileList2)
- this.fileList22=this.fileList2.join(",")
- console.log(this.fileList22)
- // uni.showLoading({
- // title: '删除中',
- // mask: true, // 是否显示透明蒙层,防止触摸穿透
- // });
- // var data={
- // "fileName": this.fileList2[index]
- // }
- // this.$Request.postT('/api/sysFile/delete',data).then(res => {
- // if (res.code==200) {
- // uni.showToast({
- // title: '删除成功',
- // icon: 'none',
- // duration:800
- // });
- // uni.hideLoading()
- // } else {
- // uni.hideLoading();
- // uni.showToast({
- // title: res.message,
- // icon: 'none',
- // duration:800
- // });
- // }
- // });
- },
- async selectUpload(e) {
- console.log('上传:', e)
- // console.log((e.tempFiles[0].size / 1024 > 1024 * 2),'大小')
- if(e.tempFiles.length>0){
- for (let i = 0; i < e.tempFilePaths.length; i++) {
- if ((e.tempFiles[i].size / 1024 > 1024 * 2)) {
- console.log('过大',e.tempFiles[i].extname)
- if(e.tempFiles[i].extname=='jpg' || e.tempFiles[i].extname=='png'||e.tempFiles[i].extname=='jpeg'){
- this.yaimg(e.tempFilePaths[i])
- }else{
- uni.showModal({
- title: '提示',
- content: '文件大于2M,无法上传',
- showCancel: false, // 是否显示取消按钮,默认为 true // 是否显示取消按钮,默认为 true
- success: function(res) {
- if (res.confirm) {
- }
- }
- });
- }
- }else{
- this.imgUpload(e.tempFiles[i].file);
- }
- }
- }
- },
- //上传图片
- async imgUpload(result){
- uni.showLoading({
- title: '上传中',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- });
- let data = new FormData();
- data.set("file", result);
- let res = await this.$axios({
- method: "post",
- url: this.config('APIHOST1') + "/api/sysFile/upload",
- headers: {
- tokenW: sessionStorage.getItem("token"),
- "Content-Type": "multipart/form-data"
- },
- data: data,
- });
- // return res
- console.log(res, "图片上传成功");
- if (res.data.code == 200) {
- console.log(this.fileList)
- this.fileList2.push(res.data.data);
- this.fileList22=this.fileList2.join(",")
- // console.log(this.fileList2.join(","))
- uni.hideLoading();
- } else if(res.message=="登录凭证已过去,请重新登录"){
- sessionStorage.removeItem("token")
- sessionStorage.removeItem("roleId")
- uni.showModal({
- title: '提示',
- content: '用户信息失效,请重新登录!',
- showCancel: false, // 是否显示取消按钮,默认为 true // 是否显示取消按钮,默认为 true
- success: function(res) {
- if (res.confirm) {
- }
- }
- });
- uni.hideLoading();
- }else {
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration:800
- });
- uni.hideLoading();
- }
- },
- /**
- * 压缩图片
- * @description 由组件处理,只需传入临时路径
- * @param {Object} url - 临时路径
- * @return void
- */
- yaimg(url) {
- uni.showLoading({
- title: '压缩中',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- });
- // 组件参数也有文档,详见文章的最底部!
- // const config = {
- // src: url,//要压缩的临时路径
- // maxSize: 800,//压缩后的最大尺寸
- // fileType: 'png',//压缩后的文件类型,可选值 jpg、png
- // quality: 0.6,//压缩后的质量(仅jpg类型有效,原因可自行阅读官方canvas文档),可选值 0 ~ 1,值越大越清晰(图片也越大)
- // }
- // console.log(config)
- // 调用压缩方法
- this.$refs.Compress.compress({
- src: url,//要压缩的临时路径
- maxSize: 800,//压缩后的最大尺寸
- fileType: '',//压缩后的文件类型,可选值 jpg、png
- quality: 0.6,//压缩后的质量(仅jpg类型有效,原因可自行阅读官方canvas文档),可选值 0 ~ 1,值越大越清晰(图片也越大)
- }).then((res) => {
- // console.log('返回的base64编码', res)
- this.base = res
-
- // 时间戳 + 随机数, 防止文件名重复
- let timestamp = new Date().getTime();
- let sunumber = Math.floor(Math.random()*999);
- // H5需要将base64转为file对象进行上传
- // 第一个参数是base64编码, 第二个是文件名
- var file = this.base64ToFile(res, timestamp + sunumber)
-
- // 最终压缩完毕的file对象
- console.log('压缩后的图片(File对象)', file)
- this.upload(file)
- this.file = file
-
- uni.hideLoading();
- //上传到服务器
- // this.upload(file)
- }).catch((err) => {
- console.log('压缩失败',err)
- uni.hideLoading();
- })
- },
- /**
- * 压缩后上传到服务器
- * @description 这块需要您自行处理
- * @param {Object} file - 要上传的file对象
- * @return void
- */
- async upload(file){
- uni.showLoading({
- title: '上传中',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- });
- let data = new FormData();
- data.set("file", file);
- console.log(data)
- let res = await this.$axios({
- method: "post",
- url: this.config('APIHOST1') + "/api/sysFile/upload",
- headers: {
- tokenW: sessionStorage.getItem("token"),
- "Content-Type": "multipart/form-data"
- },
- data: data,
- });
- // return res
- console.log(res, "图片上传成功",res.data.code == 200);
- if (res.data.code == 200) {
- this.fileList2.push(res.data.data);
- this.fileList22=this.fileList2.join(",")
- console.log(this.fileList22)
- uni.hideLoading();
- }else {
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration:800
- });
- uni.hideLoading();
- }
- },
- /**
- * base64 → File
- * @description 转换函数
- * @param {String} base64- base64完整字符串
- * @param {String} name - 文件名
- * @return Object
- */
- base64ToFile(base64, name) {
- if (typeof base64 != 'string') { return; }
- var arr = base64.split(',')
- var type = arr[0].match(/:(.*?);/)[1]
- var fileExt = type.split('/')[1]
- var bstr = atob(arr[1])
- var n = bstr.length
- var u8arr = new Uint8Array(n)
- while (n--) {
- u8arr[n] = bstr.charCodeAt(n)
- }
- return new File([u8arr], `${name}.` + fileExt, {
- type: type
- })
- },
- config: function (name) {
- var info = null
- if (name) {
- var name2 = name.split('.') //字符分割
- if (name2.length > 1) {
- info = configdata[name2[0]][name2[1]] || null
- } else {
- info = configdata[name] || null
- }
- if (info == null) {
- let web_config = cache.get('web_config')
- if (web_config) {
- if (name2.length > 1) {
- info = web_config[name2[0]][name2[1]] || null
- } else {
- info = web_config[name] || null
- }
- }
- }
- }
- return info
- },
- }
- }
- </script>
- <style>
- .content {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .param{
- margin: 20rpx 0 0 0;
- width: 100%;
- background-color: rgba(255, 255, 255, 1);
- font-size: 28rpx;
- font-weight: 400;
- line-height: 41rpx;
- color: rgba(0, 0, 0, 1);
- }
- .proMiao{
- margin: 31rpx 0 0 20rpx;
- width: 710rpx;
- }
- .prolittle{
- margin: 5rpx 0 0 20rpx;
- width: 710rpx;
- word-wrap: break-word;
- word-break: break-all;
- white-space: pre-line;
- }
- .proINname{
- margin: 25rpx 0 0 21rpx;
- width: 709rpx;
- height: 90rpx;
- border-radius: 13rpx;
- background: rgba(245, 248, 252, 1);
- border: 1rpx solid rgba(229, 229, 229, 1);
- font-size: 28rpx;
- line-height: 90rpx;
- /* color: rgba(179, 179, 179, 1); */
- }
- .proIMi{
- height: 315rpx;
- }
- .mingchen{
- font-size: 32rpx;
- font-weight: 500;
- line-height: 46rpx;
- }
- .title{
- color: rgba(102, 102, 102, 1);
- }
- /* 操作键 */
- .project{
- display: flex;
- margin: 61rpx 0 0 0;
- justify-content: space-evenly;
- }
- .butt{
- width: 330rpx;
- height: 90rpx;
- border-radius: 117rpx;
- font-size: 32rpx;
- line-height: 90rpx;
- text-align: center;
- }
- .quxiao{
- border: 1rpx solid rgba(0, 97, 255, 1);
- color: rgba(0, 97, 255, 1);
- }
- .queren{
- background: rgba(0, 97, 255, 1);
- color: rgba(255, 255, 255, 1);
- }
- </style>
|