|
@@ -259,13 +259,15 @@ const projTreeObj = {
|
|
|
icon: 'fa-share',
|
|
|
disabled: function () {
|
|
|
let selectedItem = projTreeObj.tree.selected;
|
|
|
- return true;
|
|
|
- // return !(selectedItem && selectedItem.data.projType === projectType.tender);
|
|
|
+ return !(selectedItem && selectedItem.data.projType === projectType.tender);
|
|
|
},
|
|
|
callback: function (key, opt) {
|
|
|
+ $('#sharePhone').val('');
|
|
|
$('#share-info').hide();
|
|
|
$('#share').find('.card').hide();
|
|
|
$('#share').modal('show');
|
|
|
+ $('#allowCopy').prop('checked', false);
|
|
|
+ $('#allowCopyHint').hide();
|
|
|
}
|
|
|
},
|
|
|
}
|
|
@@ -315,6 +317,7 @@ const projTreeObj = {
|
|
|
return;//如果是复制到表,不用做后面的操作
|
|
|
}
|
|
|
me.tree.selected = node;
|
|
|
+ shareSeleted = node;
|
|
|
me.preSelection = newSel;
|
|
|
$(".tools-btn > a").not(".disabled").addClass("disabled");
|
|
|
$("#add-engineering-btn").addClass("disabled");
|
|
@@ -2817,55 +2820,103 @@ function refreshTenderFile(tenders, type, newName){
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
-//添加分享
|
|
|
-$('#sharePhone').change(function () {
|
|
|
- let phone = $(this).val();
|
|
|
- let hintInfo = $('#share-info');
|
|
|
+//添加分享 pm share共用
|
|
|
+const shareType = {create: 'create', cancel: 'cancel'};
|
|
|
+let shareSeleted = null;
|
|
|
+let shareUserID = null;
|
|
|
+let canShare = false;
|
|
|
+$('#sharePhone').bind('keypress', function (e) {
|
|
|
+ if(e.keyCode === 13){
|
|
|
+ $(this).blur();
|
|
|
+ }
|
|
|
+});
|
|
|
+function shareTender(){
|
|
|
+ canShare = false;
|
|
|
+ let phone = $('#sharePhone').val();
|
|
|
+ const hintInfo = $('#share-info');
|
|
|
+ const userInfo = $('#share').find('.card');
|
|
|
if(!phone || phone.trim() === ''){
|
|
|
- replaceClass(hintInfo, 'text-info', 'text-danger');
|
|
|
setDangerInfo(hintInfo, '请输入手机号码。', true);
|
|
|
+ if(userInfo.is(':visible')){
|
|
|
+ userInfo.hide();
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
//根据手机号获取用户
|
|
|
- CommonAjax.post('/user/getUserByMobile', {mobile: phone}, function (rstData) {
|
|
|
- if(!rstData){
|
|
|
- replaceClass(hintInfo, 'text-info', 'text-danger');
|
|
|
+ CommonAjax.post('/user/getUserByMobile', {mobile: phone}, function (userData) {
|
|
|
+ if(!userData){
|
|
|
setDangerInfo(hintInfo, '账号不存在。', true);
|
|
|
+ if(userInfo.is(':visible')){
|
|
|
+ userInfo.hide();
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
else{
|
|
|
- console.log(rstData);
|
|
|
- $('#user_name').text(rstData.real_name ? rstData.real_name : '');
|
|
|
- $('#user_company').text(rstData.company ? rstData.company : '');
|
|
|
- $('#user_mobile').text(rstData.mobile ? rstData.mobile : '');
|
|
|
- $('#user_email').text(rstData.email ? rstData.email : '');
|
|
|
- $('#share').find('.card').show();
|
|
|
+ if(userData._id === userID){
|
|
|
+ setDangerInfo(hintInfo, '不可分享给自己。', true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ shareUserID = userData._id;
|
|
|
+ setDangerInfo(hintInfo, '', false);
|
|
|
+ $('#user_name').text(userData.real_name ? userData.real_name : '');
|
|
|
+ $('#user_company').text(userData.company ? userData.company : '');
|
|
|
+ let mobileHtml = `<i class="fa fa-tablet"> ${userData.mobile ? userData.mobile : ''}</i>`;
|
|
|
+ $('#user_mobile').html(mobileHtml);
|
|
|
+ let emailHtml = `<i class="fa fa-envelope-o"> ${userData.email ? userData.email : ''}</i>`;
|
|
|
+ $('#user_email').html(emailHtml);
|
|
|
+ userInfo.show();
|
|
|
//判断项目是否已经分享
|
|
|
- //CommonAjax.post('/pm/api/getProjectShareInfo');
|
|
|
+ CommonAjax.post('/pm/api/getProjectShareInfo', {user_id: userID, projectID: shareSeleted.data.ID}, function (rstData) {
|
|
|
+ for(let shareData of rstData.shareInfo){
|
|
|
+ if(shareData.userID === userData._id){
|
|
|
+ setDangerInfo(hintInfo, '已与该用户分享。', true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ canShare = true;
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
+}
|
|
|
+$('#sharePhone').on('keyup',function () {
|
|
|
+ shareTender();
|
|
|
});
|
|
|
-
|
|
|
-function shareTender(){
|
|
|
+//确认分享
|
|
|
+$('#share-confirm').click(function(){
|
|
|
let phone = $('#sharePhone').val();
|
|
|
- let hintInfo = $('#share-info');
|
|
|
+ const hintInfo = $('#share-info');
|
|
|
+ const userInfo = $('#share').find('.card');
|
|
|
if(!phone || phone.trim() === ''){
|
|
|
- replaceClass(hintInfo, 'text-info', 'text-danger');
|
|
|
setDangerInfo(hintInfo, '请输入手机号码。', true);
|
|
|
+ if(userInfo.is(':visible')){
|
|
|
+ userInfo.hide();
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
- //根据手机号获取用户
|
|
|
- CommonAjax.post('/user/getUserByMobile', {mobile: phone}, function (rstData) {
|
|
|
- if(!rstData){
|
|
|
- replaceClass(hintInfo, 'text-info', 'text-danger');
|
|
|
- setDangerInfo(hintInfo, '账号不存在。', true);
|
|
|
- }
|
|
|
- else{
|
|
|
- $('#user_name').text(rstData.real_name ? rstData.real_name : '');
|
|
|
- $('#user_company').text(rstData.company ? rstData.company : '');
|
|
|
- $('#user_mobile').text(rstData.mobile ? rstData.mobile : '');
|
|
|
- $('#user_email').text(rstData.email ? rstData.email : '');
|
|
|
- $('#share').find('.card').show();
|
|
|
- }
|
|
|
+ if(!canShare){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $('#share-confirm').addClass('disabled');
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ let allowCopy = $('#allowCopy').prop('checked');
|
|
|
+ //分享
|
|
|
+ CommonAjax.post('/pm/api/share', {user_id: userID, type: shareType.create, projectID: shareSeleted.data.ID, userID: shareUserID, allowCopy: allowCopy}, function (rstData) {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ $('#share-confirm').removeClass('disabled');
|
|
|
+ $('#share').modal('hide');
|
|
|
+ }, function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ $('#share-confirm').removeClass('disabled');
|
|
|
+ $('#share').modal('hide');
|
|
|
});
|
|
|
-}
|
|
|
+});
|
|
|
+//允许拷贝
|
|
|
+$('#allowCopy').change(function () {
|
|
|
+ let checked = $(this).prop('checked');
|
|
|
+ if(checked){
|
|
|
+ $('#allowCopyHint').show();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ $('#allowCopyHint').hide();
|
|
|
+ }
|
|
|
+});
|