|
|
@@ -39,17 +39,6 @@ function isDef(v) {
|
|
|
return typeof v !== 'undefined' && v !== null;
|
|
|
}
|
|
|
|
|
|
-let keyupTime = 0,
|
|
|
- delayTime = 500;
|
|
|
-function delayKeyup(callback) {
|
|
|
- let nowTime = Date.now();
|
|
|
- keyupTime = nowTime;
|
|
|
- setTimeout(function () {
|
|
|
- if (nowTime - keyupTime == 0) {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }, delayTime);
|
|
|
-}
|
|
|
//操作状态
|
|
|
const STATE = {
|
|
|
addingTender: false,
|
|
|
@@ -321,15 +310,10 @@ const projTreeObj = {
|
|
|
return !selectedItem;
|
|
|
},
|
|
|
callback: function (key, opt) {
|
|
|
- let selected = projTreeObj.tree.selected;
|
|
|
- $('#sharePhone').val('');
|
|
|
- $('#share-info').hide();
|
|
|
- $('#shareFindDiv').hide();
|
|
|
- setShareToModal(selected);
|
|
|
- $('#share').modal('show');
|
|
|
- setTimeout(function () {
|
|
|
- $('#sharePhone').focus();
|
|
|
- }, 200);
|
|
|
+ const selected = projTreeObj.tree.selected;
|
|
|
+ if (selected && selected.data.ID) {
|
|
|
+ SHARE_TO.initModal(selected.data.ID);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
manageFiles: {
|
|
|
@@ -634,7 +618,6 @@ const projTreeObj = {
|
|
|
return;
|
|
|
}
|
|
|
me.tree.selected = node;
|
|
|
- shareSeleted = node;
|
|
|
me.preSelection = newSel;
|
|
|
},
|
|
|
onSelectionChanging: function (sender, args) {
|
|
|
@@ -1634,88 +1617,9 @@ const projTreeObj = {
|
|
|
|
|
|
};
|
|
|
|
|
|
-// 显示最近分享信息
|
|
|
-function showRecentShareInfo() {
|
|
|
- function getBookListHtml(users) {
|
|
|
- return users.reduce((acc, user) => {
|
|
|
- const mobile = user.mobile || '';
|
|
|
- const realName = user.real_name || '';
|
|
|
- const company = user.company || '';
|
|
|
- // 手机最后一位
|
|
|
- const lastMobileNumer = mobile.substring(mobile.length - 1);
|
|
|
- // 显示名称为真实名称后两位
|
|
|
- const nickName = realName.substring(realName.length - 2);
|
|
|
- return acc +
|
|
|
- `<li>
|
|
|
- <span class="avatar bg-${lastMobileNumer}">${nickName}</span>
|
|
|
- <div class="book-body">
|
|
|
- <h5 class="mt-0" title="${company}">${realName}</h5>
|
|
|
- <span class="mobile-info">${mobile}</span>
|
|
|
- </div>
|
|
|
- </li>`;
|
|
|
- }, '');
|
|
|
-
|
|
|
- }
|
|
|
- $.bootstrapLoading.start();
|
|
|
- CommonAjax.post('/pm/api/getRecentShareInfo', {user_id: userID, count: 5}, (data) => {
|
|
|
- const recentHtml = getBookListHtml(data.recentUsers);
|
|
|
- // 联系人按拼英首字母降序排序
|
|
|
- data.contacts.sort((a, b) => {
|
|
|
- const realNameA = a.real_name || '';
|
|
|
- const realNameB = b.real_name || '';
|
|
|
- return realNameA.localeCompare(realNameB, 'zh-Hans-CN', {sensitivity: 'accent'})
|
|
|
- });
|
|
|
- const contactsHtml = getBookListHtml(data.contacts);
|
|
|
- $('#recentList').html(recentHtml);
|
|
|
- $('#contactsList').html(contactsHtml);
|
|
|
- $('#myTabContent ul li').click(function () {
|
|
|
- const mobile = $(this).find('.mobile-info')[0].textContent;
|
|
|
- $('#sharePhone').val(mobile);
|
|
|
- shareTender();
|
|
|
- const $subMenu = $('#shareSubMenu');
|
|
|
- const subMenu = $subMenu[0];
|
|
|
- $(subMenu.parentElement).removeClass('show');
|
|
|
- $subMenu.removeClass('show');
|
|
|
- });
|
|
|
- $.bootstrapLoading.end();
|
|
|
- }, () => {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
$(document).ready(function() {
|
|
|
- // 最近分享、联系人列表相关
|
|
|
- $('body').click(function (e) {
|
|
|
- const body = $(this)[0];
|
|
|
- const $subMenu = $('#shareSubMenu');
|
|
|
- const subMenu = $subMenu[0];
|
|
|
- const menuBook = $('#dropdownMenuBook')[0]
|
|
|
- if (!$subMenu.is(':visible')) {
|
|
|
- return;
|
|
|
- }
|
|
|
- let target = e.target;
|
|
|
- while (target !== body) {
|
|
|
- if ([subMenu, menuBook].includes(target)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- target = target.parentElement;
|
|
|
- }
|
|
|
- $(subMenu.parentElement).removeClass('show');
|
|
|
- $subMenu.removeClass('show');
|
|
|
- });
|
|
|
- // 最近分享、联系人列表相关
|
|
|
- $('#dropdownMenuBook').click(function () {
|
|
|
- const $subMenu = $('#shareSubMenu');
|
|
|
- const visible = $subMenu.is(':visible');
|
|
|
- if (visible) {
|
|
|
- $(this).parent().removeClass('show');
|
|
|
- $subMenu.removeClass('show');
|
|
|
- } else {
|
|
|
- $(this).parent().addClass('show');
|
|
|
- $subMenu.addClass('show');
|
|
|
- showRecentShareInfo();
|
|
|
- }
|
|
|
- });
|
|
|
+ // 分享给的一些事件监听
|
|
|
+ SHARE_TO.handleEventListener();
|
|
|
|
|
|
// 单位工程超限提示后,弹出客服列表
|
|
|
$('#hintBox_form').on('hide.bs.modal', function () {
|
|
|
@@ -3764,127 +3668,6 @@ function refreshTenderFile(tenders, type, newName){
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-//添加分享 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 = $('#shareFindDiv');
|
|
|
- const addUser = $('#addShareUser');
|
|
|
- const copyInput = $('#allowCopy');
|
|
|
- const coopInput = $('#allowCooperate');
|
|
|
- const shareConfirm = $('#share-confirm');
|
|
|
- shareConfirm.addClass('disabled');
|
|
|
- //可分享才可添加用户
|
|
|
- addUser.addClass('disabled');
|
|
|
- if (hintInfo.is(':visible')) {
|
|
|
- hintInfo.hide();
|
|
|
- }
|
|
|
- if(!phone || phone.trim() === ''){
|
|
|
- setDangerInfo(hintInfo, '请输入手机号码。', true);
|
|
|
- if(userInfo.is(':visible')){
|
|
|
- userInfo.hide();
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- //根据手机号获取用户
|
|
|
- CommonAjax.post('/user/getUserByMobile', {mobile: phone}, function (userData) {
|
|
|
- if(!userData){
|
|
|
- setDangerInfo(hintInfo, '账号不存在。', true);
|
|
|
- if(userInfo.is(':visible')){
|
|
|
- userInfo.hide();
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- else{
|
|
|
- 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 : '');
|
|
|
- $('#user_mobile').text(userData.mobile ? userData.mobile : '');
|
|
|
- $('#user_email').text(userData.email ? userData.email : '');
|
|
|
- //默认可拷贝
|
|
|
- copyInput.prop('checked', true);
|
|
|
- //默认不可协作
|
|
|
- coopInput.prop('checked', false);
|
|
|
- userInfo.show();
|
|
|
- //判断项目是否已经分享
|
|
|
- CommonAjax.post('/pm/api/getProjectShareInfo', {user_id: userID, projectID: shareSeleted.data.ID}, function (shareInfo) {
|
|
|
- for(let shareData of shareInfo){
|
|
|
- if(shareData.userID === userData._id){
|
|
|
- setDangerInfo(hintInfo, '已与该用户分享。', true);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- addUser.removeClass('disabled');
|
|
|
- shareConfirm.removeClass('disabled');
|
|
|
- canShare = true;
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-$('#sharePhone').on('keyup',function () {
|
|
|
- delayKeyup(function () {
|
|
|
- shareTender();
|
|
|
- });
|
|
|
-});
|
|
|
-
|
|
|
-//确认分享
|
|
|
-$('#share-confirm').click(function(){
|
|
|
- const hintInfo = $('#share-info');
|
|
|
- $.bootstrapLoading.start();
|
|
|
- const perHeight = 30;
|
|
|
- let allowCopy = $('#allowCopy').prop('checked'),
|
|
|
- allowCoop = $('#allowCooperate').prop('checked');
|
|
|
- userName = $('#user_name').text() || '',
|
|
|
- userCompany = $('#user_company').text() || '',
|
|
|
- userMobile = $('#user_mobile').text() || '',
|
|
|
- userEmail = $('#user_email').text() || '';
|
|
|
- let shareData = [{userID: shareUserID, allowCopy: allowCopy, allowCooperate: allowCoop}];
|
|
|
- //分享
|
|
|
- CommonAjax.post('/pm/api/share', {user_id: userID, type: shareType.create, projectID: shareSeleted.data.ID, shareData: shareData}, function (rstData) {
|
|
|
- //更新已分享table
|
|
|
- let $tr = $(`<tr>
|
|
|
- <td style="width: 112px">${userName}</td>
|
|
|
- <td style="width: 165px">${userCompany}</td>
|
|
|
- <td style="width: 136px">${userMobile}</td>
|
|
|
- <td style="width: 136px">${userEmail}</td>
|
|
|
- <td style="width: 90px;"><input value="allowCopy" ${allowCopy ? 'checked' : ''} type="checkbox"></td>
|
|
|
- <td style="width: 90px;"><input value="allowCooperate" ${allowCoop ? 'checked' : ''} type="checkbox"></td>
|
|
|
- <td style="width: 90px;"><input value="cancelShare" type="checkbox"></td>
|
|
|
- </tr>`);
|
|
|
- let tbodyTotalHeight = $('#shareToInfo').height() + perHeight > 200 ? 200 : $('#shareToInfo').height() + perHeight;
|
|
|
- $('#shareToInfo').height(tbodyTotalHeight);
|
|
|
- $('#shareToInfo').append($tr);
|
|
|
- //更新缓存
|
|
|
- shareSeleted.data.shareInfo = shareSeleted.data.shareInfo.concat(shareData);
|
|
|
- let sheet = projTreeObj.workBook.getSheet(0);
|
|
|
- projTreeObj.renderSheetFuc(sheet, function () {
|
|
|
- sheet.invalidateLayout();
|
|
|
- sheet.repaint();
|
|
|
- });
|
|
|
- bindCancelShareCheck(shareSeleted);
|
|
|
- $.bootstrapLoading.end();
|
|
|
- $('#shareFindDiv').hide();
|
|
|
- $('#share-confirm').addClass('disabled');
|
|
|
- }, function () {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- $('#share-confirm').removeClass('disabled');
|
|
|
- });
|
|
|
-});
|
|
|
|
|
|
//批量替换文件,切换建设项目
|
|
|
$('#otherProject').change(function(){
|
|
|
@@ -3905,17 +3688,6 @@ $('#otherProject').change(function(){
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
-//分享给...界面确认
|
|
|
-$('#shareToConfirm').click(function () {
|
|
|
- let selected = projTreeObj.tree.selected;
|
|
|
- if (!selected) {
|
|
|
- return;
|
|
|
- }
|
|
|
- updateShareInfo(selected);
|
|
|
-});
|
|
|
-
|
|
|
-
|
|
|
$("#confirm-import").click(function() {
|
|
|
//$.bootstrapLoading.start();
|
|
|
if (STATE.importing) {
|
|
|
@@ -4053,132 +3825,6 @@ $('#import').on('show.bs.modal', function(){
|
|
|
$('.custom-file-label').text(`请选择建设项目文件`);
|
|
|
});
|
|
|
|
|
|
-//设置分享给界面数据
|
|
|
-//@param {Object}selected @return {void}
|
|
|
-function setShareToModal(selected){
|
|
|
- const perHeight = 30; //每条分享给数据的高度
|
|
|
- $('#shareToInfo').empty();
|
|
|
- if(!selected){
|
|
|
- return;
|
|
|
- }
|
|
|
- let userIDs = [];
|
|
|
- for(let user of selected.data.shareInfo){
|
|
|
- userIDs.push(user.userID);
|
|
|
- }
|
|
|
- CommonAjax.post('/user/getUsers', {userIDs: userIDs}, function (rstData) {
|
|
|
- for(let userInfo of rstData){
|
|
|
- for(let user of selected.data.shareInfo){
|
|
|
- if(user.userID === userInfo._id){
|
|
|
- user.exist = true;
|
|
|
- user.name = userInfo.real_name;
|
|
|
- user.company = userInfo.company;
|
|
|
- user.mobile = userInfo.mobile;
|
|
|
- user.email = userInfo.email;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- let infoArr = [];
|
|
|
- //居中style="width: 90px;text-align: center"
|
|
|
- let theadHtml = `<tr>
|
|
|
- <th style="width: 112px;">姓名</th>
|
|
|
- <th style="width: 165px;">公司</th>
|
|
|
- <th style="width: 136px;">手机</th>
|
|
|
- <th style="width: 136px;">邮箱</th>
|
|
|
- <th style="width: 90px;">允许拷贝</th>
|
|
|
- <th style="width: 90px;">允许编辑</th>
|
|
|
- <th style="width: 90px;">取消分享</th>
|
|
|
- </tr>`;
|
|
|
- infoArr.push(theadHtml);
|
|
|
- for(let user of selected.data.shareInfo){
|
|
|
- if (!user.exist) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- let infoHtml = `<tr>
|
|
|
- <td style="width: 112px;">${user.name}</td>
|
|
|
- <td style="width: 165px;">${user.company}</td>
|
|
|
- <td style="width: 136px;">${user.mobile}</td>
|
|
|
- <td style="width: 160px;">${user.email}</td>
|
|
|
- <td style="width: 90px;"><input value="allowCopy" ${user.allowCopy ? 'checked' : ''} type="checkbox"></td>
|
|
|
- <td style="width: 90px;"><input value="allowCooperate" ${user.allowCooperate ? 'checked' : ''} type="checkbox"></td>
|
|
|
- <td style="width: 90px;"><input value="cancelShare" type="checkbox"></td>
|
|
|
- </tr>`;
|
|
|
- infoArr.push(infoHtml);
|
|
|
- }
|
|
|
- let tbodyTotalHeight = infoArr.length * perHeight + 5 > 200 ? 200 : infoArr.length * perHeight + 5;
|
|
|
- $('#shareToInfo').height(tbodyTotalHeight);
|
|
|
- let infoHtml = infoArr.join('');
|
|
|
- $('#shareToInfo').html(infoHtml);
|
|
|
- bindCancelShareCheck(selected);
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-//取消分享的勾选操作
|
|
|
-//@param {Object}selected(选中项目节点) @return {void}
|
|
|
-function bindCancelShareCheck(selected) {
|
|
|
- $('#shareToInfo input[value="cancelShare"]').unbind('click');
|
|
|
- $('#shareToInfo input[value="cancelShare"]').click(function () {
|
|
|
- let index = $(this).parent().parent().index() - 1,
|
|
|
- $coo = $(this).parent().prev().children(),
|
|
|
- $copy = $(this).parent().prev().prev().children();
|
|
|
- let isCancel = $(this).prop('checked');
|
|
|
- if (isCancel) {//取消分享,取消拷贝、协作勾选
|
|
|
- $coo.prop('checked', false);
|
|
|
- $copy.prop('checked', false);
|
|
|
- } else {//取消取消分享,恢复原本的拷贝、协作勾选状态
|
|
|
- let shareData = selected.data.shareInfo[index];
|
|
|
- if (shareData) {
|
|
|
- $coo.prop('checked', shareData.allowCooperate);
|
|
|
- $copy.prop('checked', shareData.allowCopy);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-//更新项目分享信息
|
|
|
-//@param {Object}selected
|
|
|
-function updateShareInfo(selected){
|
|
|
- if(!selected){
|
|
|
- return;
|
|
|
- }
|
|
|
- let usersTr = $('#shareToInfo').find('tr');
|
|
|
- if (usersTr && usersTr.length > 0) {
|
|
|
- usersTr = usersTr.slice(1);
|
|
|
- }
|
|
|
- let newShareInfo = [],
|
|
|
- orgShareInfo = [];
|
|
|
- const postData = [];
|
|
|
- //数据不同才提交
|
|
|
- for (let shareData of selected.data.shareInfo) {
|
|
|
- orgShareInfo.push({userID: shareData.userID, allowCopy: shareData.allowCopy, allowCooperate: shareData.allowCooperate})
|
|
|
- }
|
|
|
- for(let i = 0; i < usersTr.length; i++){
|
|
|
- let userTr = usersTr[i];
|
|
|
- let allowCopy = $(userTr).find('input:eq(0)').prop('checked');
|
|
|
- let allowCoop = $(userTr).find('input:eq(1)').prop('checked');
|
|
|
- let cancelShare = $(userTr).find('input:eq(2)').prop('checked');
|
|
|
- selected.data.shareInfo[i].allowCopy = allowCopy;
|
|
|
- selected.data.shareInfo[i].allowCooperate = allowCoop;
|
|
|
- let shareItem;
|
|
|
- if(cancelShare){
|
|
|
- shareItem = {userID: selected.data.shareInfo[i].userID, isCancel: true};
|
|
|
- } else {
|
|
|
- shareItem = {userID: selected.data.shareInfo[i].userID, allowCopy: allowCopy, allowCooperate: allowCoop};
|
|
|
- newShareInfo.push(shareItem);
|
|
|
- }
|
|
|
- postData.push(shareItem);
|
|
|
- }
|
|
|
- if (_.isEqual(newShareInfo, orgShareInfo)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- CommonAjax.post('/pm/api/share', {user_id: userID, type: 'update', projectID: selected.data.ID, shareData: postData}, function (shareData) {
|
|
|
- selected.data.shareInfo = shareData;
|
|
|
- let sheet = projTreeObj.workBook.getSheet(0);
|
|
|
- projTreeObj.renderSheetFuc(sheet, function () {
|
|
|
- sheet.invalidateLayout();
|
|
|
- sheet.repaint();
|
|
|
- });
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
//刷新建设项目汇总金额信息
|
|
|
function refreshProjSummary(project, summaryInfo) {
|
|
|
let refreshNodes = [];
|