分享操作

This commit is contained in:
daihh
2022-11-15 11:12:19 +08:00
parent 83eb91e2e4
commit 9314357c97

View File

@@ -67,21 +67,7 @@
</view>
</view>
</u-popup>
<u-popup :show="shareInfo.show" @close="closeShare" @open="addShare" mode="right">
<view style="padding: 10px 20px;line-height: 60upx;">
<view style="padding: 10upx;">请输入要分享给人的姓名</view>
<view style="padding: 10upx;">
<u--input placeholder="请输入人员姓名" border="surround" v-model="shareInfo.name"></u--input>
</view>
<view style="padding-top:20upx;">
<u-button @click="findUsers()" type="primary" text="查询"></u-button>
</view>
<view style="padding-top: 50upx;">
<!--查询内容列表-->
<view style="line-height: 60upx;" v-for="(su,suidx) in shareInfo.users" :key="suidx" @click="confirmShare(su)">{{suidx+1}}, {{su.name}} {{su.code}}</view>
</view>
</view>
</u-popup>
<interact-share ref="comShare" :data="data":type="type"></interact-share>
</view>
</template>
<script>
@@ -457,124 +443,8 @@ export default {
},
addShare(){
//分享
this.shareInfo.show=true;
},
findUsers(){
this.shareInfo.users=[];
//模拟数据
//模拟数据
if(!this.shareInfo.name){
uni.showToast({
title: '请输入查询条件',
icon: 'none'
});
// return this.$refs.interactToast.show({message:'请输入工号或姓名',type:'warning'});
}
var name=this.shareInfo.name;
var regPos = /^\d+(\.\d+)?$/; //非负浮点数
if(regPos.test(name)){
apiUser.getByLoginName(name).then(rs=>{
if(rs.status==200){
//因为根据工号查询只会是一个人所有会有null情况而json会返回空字符串
if(rs.result!=''){
this.shareInfo.users=[rs.result];
}else{
uni.showToast({
title: '查无此用户',
icon: 'none'
});
// this.$refs.interactToast.show({message:"查无此用户",type:'warning'});
}
}else{
uni.showToast({
title: rs.message,
icon: 'none'
});
// this.$refs.interactToast.show({message:rs.message,type:'warning'});
}
})
}else{
apiUser.findByName(name).then(rs=>{
if(rs.status==200){
if(rs.result.length==0){
return uni.showToast({
title: rs.message,
icon: 'none'
});
// return this.$refs.interactToast.show({message:rs.message,type:'error'});
}
this.shareInfo.users=rs.result;
}else{
uni.showToast({
title: rs.message,
icon: 'none'
});
// this.$refs.interactToast.show({message:rs.message,type:'error'});
}
})
}
// apiUser.findByName(name).then(rs=>{
// if(rs.status==200){
// this.shareInfo.users=rs.result;
// }else{
// this.$refs.interactToast.show({message:'查询用户失败',type:'error'});
// console.log(rs.message);
// console.log(rs.error)
// }
// })
},
closeShare(){
this.shareInfo.show=false;
},
confirmShare(u){
let conType;
if(this.type == 1) {
conType = this.data.type;
}
let postData={
objType:this.type,
objId:this.data.id,
content:'',
isRead:false,
toAid:u.aid,
toAname:u.name,
conType:conType,
}
if(this.userInfo.aid==postData.toAid){
uni.showToast({
title: '不能分享给自己',
icon: 'none'
});
// return this.$message.warning("不能分享给自己")
}
apiShares.save(postData).then(rs=>{
if(rs.status==200){
if(rs.result){
this.shareInfo.show=false;
this.$refs.interactToast.show({message:'分享成功',type:'success'});
this.$emit("share-success", rs.result);
if(this.type!=3){
if(this.type==1){
this.messageSave(this.data.id,this.data.name,this.userInfo.name,u.name,u.aid,'分享给我的');
}else{
this.messageSave(this.data.id,this.data.title,this.userInfo.name,u.name,u.aid,'分享给我的');
}
}
}else{
uni.showToast({
title: '分享失败,您不能将同一资源多次分享给同一个人',
icon: 'none'
});
// this.$refs.interactToast.show({message:'分享失败,您不能将同一资源多次分享给同一个人',type:'warning'});
}
}else{
// this.$message({message:'分享失败',type:'success'});
this.$refs.interactToast.show({message:'分享处理失败',type:'error'});
console.log(rs.message);
}
});
},
this.$refs.comShare.openShare();
}
}
};