| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599 |
- <template>
- <view class="content">
- <view class="param">
- <view class="proMiao">任务名称</view>
- <input class="proINname" v-model="renwuName" placeholder="请输入任务名称"/>
- <view class="proMiao">评分标准</view>
- <textarea class="proINname proIMi" v-model="scoreStandard" 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;">支持pdf,docx,jpg,png,jpeg,doc,docm,dot,dotm,dotx,xlsx,xls,csv,xlsm,slxb,xlt,xltx格式,单个文件大小不超过2MB</span>
- <view class="proMiao">评分上限</view>
- <input class="proINname" placeholder="请输入评分上限" type="number" v-model="scoreLimit"/>
- <view class="proMiao">权重</view>
- <input class="proINname" placeholder="请输入权重" type="digit" v-model="weight"/>
- <view class="proMiao">任务负责人</view>
- <view @click="toggle()">
- <view class="proINname" v-if="peopleValue==''">请选择任务负责人</view>
- <view class="proINname" v-else>{{peopleValue}}</view>
- <!-- <input class="proINname" v-model="peopleValue" placeholder="请选择任务负责人"/> -->
- <!-- <uni-data-select class="proINname" :disabled="true"
- v-model="peopleValue" placeholder="请选择主办人"
- :localdata="rangePeople"
- ></uni-data-select> -->
- </view>
-
- <view class="proMiao">提醒时间</view>
- <uni-datetime-picker class="proINname" type="datetime" v-model="remindTime" @change="changeLog" />
- <view class="proMiao">预警时间</view>
- <uni-datetime-picker class="proINname" type="datetime" v-model="warnTime" @change="changeLog" />
- <view class="proMiao">任务周期</view>
- <uni-datetime-picker class="proINname" v-model="datetimerange" type="datetimerange" rangeSeparator="至" />
- <!-- 操作键 -->
- <view class="project">
- <view class="butt quxiao" @click="quxiao">取消</view>
- <view class="butt queren" @click="addRenwu">确认创建</view>
- </view>
- <view style="width: 100%;height: 60rpx;"></view>
-
- <!-- 任务负责人弹出框-->
- <uni-popup ref="popup" background-color="#fff">
-
- <view class="popup-content">
- <view class="popup-title">
- <view @click="quPopup">取消</view>
- <view>选择任务负责人</view>
- <view style="color: rgba(0, 97, 255, 1);" @click="selectPeo">确定</view>
- </view>
- <scroll-view scroll-y="true" class="scroll_view_style">
- <view class="popup-list">
- <radio-group @change="radioChange" v-for="(item,index) in people" :key="index">
- <view class="l-line"></view>
- <view class="l-kuang">
- <view class="l-circle"></view>
- <view style="margin-left: 20rpx;width: 320px;">
- <view style="font-size: 28rpx;">{{item.userName}}</view>
- <view style="font-size: 24rpx;">{{item.department}}</view>
- </view>
- <label class="l-label">
- <view>
- <radio :id="item.userName" :value="item.userName" :checked="index==peopleCruuent"></radio>
- </view>
- </label>
- </view>
- </radio-group>
- </view>
- </scroll-view>
- </view>
-
-
- </uni-popup>
- </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 {
- renwuName:'',//任务名称
- projectId:'',//项目id
- scoreStandard:'',//评价标准
- scoreLimit:'',//评分上限
- weight:'',//权重
- remindTime: '',//提醒时间
- warnTime:'',//预警时间
- datetimerange: [],
- people:[],
- peopleCruuent:0,
- peopleValue:'',
- // 附件
- fileList: [],
- fileList2: [],
- fileList22:'',
- listStyles: {
- "borderStyle": {
- "width": "0", // 边框宽度
- },
- "border": false, // 是否显示边框
- "dividline": false
- },
-
- page:1,
- size:10,
- totalCount:0,
- }
- },
- onLoad(option) {
- this.projectId=option.proId
- this.people=JSON.parse(decodeURIComponent(option.people))
- },
- methods: {
- // 任务负责人弹框
- toggle() {
- console.log('dd')
- // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
- this.$refs.popup.open('bottom')
- // this.getPeople()
- },
- //取消弹框
- quPopup(){
- this.$refs.popup.close()
- },
- //确定负责人
- selectPeo(){
- this.$refs.popup.close()
- this.peopleValue=this.people[this.peopleCruuent].userName
- },
- // 选择负责人
- radioChange: function(evt) {
- console.log(evt)
- for (let i = 0; i < this.people.length; i++) {
- if (this.people[i].userName === evt.detail.value) {
- this.peopleCruuent = i;
- this.peopleValue=this.people[this.peopleCruuent].userName
- break;
- }
- }
- },
- //选择负责人
- getPeople(){
- this.people=[]
- uni.showLoading({
- title: '加载中',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- });
- this.$Request.postJson('/api/sysProject/queryCoUsers',{}).then(res => {
- if (res.code==200) {
- // var lianji=[]
- // for(var i=0;i<res.data.length;i++){
- // if(res.data[i].organize==acc){
- // lianji=res.data[i].userList
- // }
- // }
- // console.log(lianji,'评分')
- // this.scorePeople =lianji.map(item =>{
- // return {
- // value: item.id,
- // label: item.userName,
- // }
- // })
-
- if (this.page == 1) {
- console.log('哈')
- this.people = res.data.rows
- } else {
- this.people = this.people.concat(res.data.rows)
- }
- console.log(this.people,'人')
- }else{
- var ii=JSON.stringify(res)
- console.log(res,res.data)
- console.log(JSON.parse(res))
- console.log(JSON.parse(ii))
- }
- uni.hideLoading();
- });
- },
- //取消
- quxiao(){
- uni.redirectTo({
- url:'/pages/project/projectChange'
- })
- },
- //新增任务
- addRenwu(){
- let that = this
- if (!that.renwuName) {
- that.$queue.showToast("请输入任务名称");
- }else if (!that.scoreStandard) {
- that.$queue.showToast("请输入评分标准");
- }else if (!that.scoreLimit) {
- that.$queue.showToast("请输入评分上限");
- }else if (!that.weight) {
- that.$queue.showToast("请输入权重");
- }else if (!that.remindTime) {
- that.$queue.showToast("请选择提醒时间");
- }else if (!that.warnTime) {
- that.$queue.showToast("请选择预警时间");
- }else if (!that.datetimerange) {
- that.$queue.showToast("请选择周期");
- }else {
- uni.showLoading({
- title: '加载中',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- });
- var data={
- "taskName": that.renwuName, // 任务名称
- "projectId": that.projectId, // 项目ID
- "scoreStandard": that.scoreStandard, // 评价标准
- "fileUrl": that.fileList22, // 附件
- "scoreLimit": that.scoreLimit, // 评分上限
- "weight": that.weight, // 权重
- "remindTime": that.remindTime, // 提醒时间
- "warnTime": that.warnTime, // 预警时间
- "header": that.people[that.peopleCruuent].id, // 负责人
- "startTime": that.datetimerange[0], // 周期-起始时间
- "endTime": that.datetimerange[1] // 周期-结束时间
- }
- that.$Request.postJson('/api/sysTask/add',data).then(res => {
- if (res.code==200) {
- uni.showToast({
- title: '添加成功',
- icon: 'none',
- duration:800
- });
- uni.hideLoading()
-
- setTimeout(function() {
- 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(",")
- },
- 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.fileList2)
- 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;
- }
- /* 上传附件 */
- .upload-img{
- /* margin: 25rpx 0 0 21rpx;
- width: 200rpx;
- height: 80rpx;
- opacity: 1;
- border-radius: 13rpx;
- background: rgba(0, 97, 255, 0.1);
-
- border: 1rpx solid rgba(0, 97, 255, 1); */
- }
- .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;
- }
- /* 操作键 */
- .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);
- }
- /* 任务负责人弹出框 */
- .popup-content{
- height: 452px;
- overflow-x: hidden;
- .scroll_view_style{
- height: 100%;
- }
- }
- .popup-title{
- display: flex;
- width: 100%;
- height: 104rpx;
- font-size: 32rpx;
- line-height: 104rpx;
- justify-content: space-around;
- color: rgba(0, 0, 0, 1);
- }
- .l-line{
- width: 100%;
- border: 1rpx solid rgba(230, 230, 230, 1);
- }
- .l-kuang{
- margin: 40rpx 0 0 20rpx;
- display: flex;
- }
- .l-circle{
- width: 80rpx;
- height: 80rpx;
- border-radius: 50%;
- background-color:rgba(204, 204, 204, 1);
- }
- .l-label1{
- width: 50rpx;
- height: 50rpx;
- opacity: 1;
- border-radius: 50%;
- background-color: rgba(0, 97, 255, 1);
- }
- .l-label{
- /* margin-left: 404rpx; */
- /* width: 50rpx;
- height: 50rpx;
- opacity: 1;
- border-radius: 50%;
- border: 1rpx solid rgba(166, 166, 166, 1); */
- }
- </style>
|