|
|
@@ -184,6 +184,7 @@ const projTreeObj = {
|
|
|
this.bindEvent(newWorkBook);
|
|
|
this.loadContextMenu();
|
|
|
this.loadStartMenu();
|
|
|
+ this.loadBtn();
|
|
|
}
|
|
|
return newWorkBook;
|
|
|
},
|
|
|
@@ -371,6 +372,142 @@ const projTreeObj = {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ //刷新按钮有效性(升降级、上下移)
|
|
|
+ refreshBtn: function (selected) {
|
|
|
+ const upLevel = $('#upLevel');
|
|
|
+ const downLevel = $('#downLevel');
|
|
|
+ const upMove = $('#upMove');
|
|
|
+ const downMove = $('#downMove');
|
|
|
+ if (!selected) {
|
|
|
+ upLevel.addClass('disabled');
|
|
|
+ downLevel.addClass('disabled');
|
|
|
+ upMove.addClass('disabled');
|
|
|
+ downMove.addClass('disabled');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ /* 升级有效
|
|
|
+ * 当前选中文件夹,且文件夹有父项,且父项是文件夹
|
|
|
+ * 当前选中建设项目,且建设项目有父项,且父项是文件夹
|
|
|
+ */
|
|
|
+ if ([projectType.project, projectType.folder].includes(selected.data.projType)
|
|
|
+ && selected.parent && selected.parent.data && selected.parent.data.projType === projectType.folder) {
|
|
|
+ upLevel.removeClass('disabled');
|
|
|
+ } else {
|
|
|
+ upLevel.addClass('disabled');
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 降级有效
|
|
|
+ * 当前选中文件夹,且文件夹有前兄弟,且前兄弟是文件夹
|
|
|
+ * 当前选中建设项目,且建设项目有前兄弟,且前兄弟是文件夹
|
|
|
+ * */
|
|
|
+ if ([projectType.project, projectType.folder].includes(selected.data.projType)
|
|
|
+ && selected.preSibling() && selected.preSibling().data.projType === projectType.folder) {
|
|
|
+ downLevel.removeClass('disabled');
|
|
|
+ } else {
|
|
|
+ downLevel.addClass('disabled');
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 上移有效
|
|
|
+ * 当前选中行有前兄弟,不论前兄弟类型
|
|
|
+ * */
|
|
|
+ selected.preSibling() ? upMove.removeClass('disabled') : upMove.addClass('disabled');
|
|
|
+ /*
|
|
|
+ * 后移有效
|
|
|
+ * 当前选中行有后兄弟,不论后兄弟类型
|
|
|
+ * */
|
|
|
+ selected.nextSibling ? downMove.removeClass('disabled') : downMove.addClass('disabled');
|
|
|
+
|
|
|
+ },
|
|
|
+ doAfterTreeOpr: function ({selected, parent, next, projectMap}) {
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ moveProjects({"user_id": userID, rootProjectID: null, projectMap: projectMap, feeRateMap: {}, unitPriceMap: {}},function (result) {
|
|
|
+ for (let key in result) {//更新前端节点数据
|
|
|
+ let updateData = result[key].update;
|
|
|
+ let node = projTreeObj.tree.findNode(result[key].query.ID);
|
|
|
+ if (node) {
|
|
|
+ for (let ukey in updateData) {
|
|
|
+ _.set(node.data,ukey,updateData[ukey]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ projTreeObj.moveTo(selected, null, parent, next, null);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //升级后选中节点的后兄弟节点不成为其子节点,因为有层级类型限制(相当于选中节点移动到父项后成为其后兄弟)
|
|
|
+ upLevel: function () {
|
|
|
+ let selected = projTreeObj.tree.selected,
|
|
|
+ parent = selected.parent.parent,
|
|
|
+ next = selected.parent.nextSibling,
|
|
|
+ projectMap = {};
|
|
|
+ //更新父节点
|
|
|
+ projectMap[selected.pid()] = {query: {ID: selected.pid()}, update: {NextSiblingID: selected.id()}};
|
|
|
+ //更新选中节点前兄弟节点
|
|
|
+ let orgPre = selected.preSibling();
|
|
|
+ if (orgPre) {
|
|
|
+ projectMap[orgPre.id()] = {query: {ID: orgPre.id()}, update: {NextSiblingID: selected.nid()}};
|
|
|
+ }
|
|
|
+ //更新选中节点
|
|
|
+ projectMap[selected.id()] = {query: {ID: selected.id()}, update: {ParentID: selected.parent.pid(), NextSiblingID: selected.parent.nid()}};
|
|
|
+ this.doAfterTreeOpr({selected, parent, next, projectMap});
|
|
|
+ },
|
|
|
+ downLevel: function () {
|
|
|
+ let selected = projTreeObj.tree.selected,
|
|
|
+ parent = null,
|
|
|
+ next = null,
|
|
|
+ projectMap = {};
|
|
|
+ //更新前兄弟节点
|
|
|
+ let orgPre = selected.preSibling();
|
|
|
+ parent = orgPre;
|
|
|
+ projectMap[orgPre.id()] = {query: {ID: orgPre.id()}, update: {NextSiblingID: selected.nid()}};
|
|
|
+ //更新前兄弟最后子节点
|
|
|
+ if (orgPre.children.length > 0) {
|
|
|
+ let lastChild = orgPre.lastChild();
|
|
|
+ projectMap[lastChild.id()] = {query: {ID: lastChild.id()}, update: {NextSiblingID: selected.id()}};
|
|
|
+ }
|
|
|
+ //更新选中节点
|
|
|
+ projectMap[selected.id()] = {query: {ID: selected.id()}, update: {ParentID: orgPre.id(), NextSiblingID: -1}};
|
|
|
+ this.doAfterTreeOpr({selected, parent, next, projectMap});
|
|
|
+ },
|
|
|
+ upMove: function () {
|
|
|
+ let selected = projTreeObj.tree.selected,
|
|
|
+ parent = selected.parent,
|
|
|
+ next = selected.preSibling(),
|
|
|
+ projectMap = {};
|
|
|
+ //更新前前兄弟
|
|
|
+ let prepre = selected.preSibling().preSibling();
|
|
|
+ if (prepre) {
|
|
|
+ projectMap[prepre.id()] = {query: {ID: prepre.id()}, update: {NextSiblingID: selected.id()}};
|
|
|
+ }
|
|
|
+ //更新前兄弟
|
|
|
+ let pre = selected.preSibling();
|
|
|
+ projectMap[pre.id()] = {query: {ID: pre.id()}, update: {NextSiblingID: selected.nid()}};
|
|
|
+ //更新选中节点
|
|
|
+ projectMap[selected.id()] = {query: {ID: selected.id()}, update: {NextSiblingID: pre.id()}};
|
|
|
+ this.doAfterTreeOpr({selected, parent, next, projectMap});
|
|
|
+ },
|
|
|
+ downMove: function () {
|
|
|
+ let selected = projTreeObj.tree.selected,
|
|
|
+ parent = selected.parent,
|
|
|
+ next = selected.nextSibling.nextSibling,
|
|
|
+ projectMap = {};
|
|
|
+ //更新前兄弟
|
|
|
+ let pre = selected.preSibling();
|
|
|
+ if (pre) {
|
|
|
+ projectMap[pre.id()] = {query: {ID: pre.id()}, update: {NextSiblingID: selected.nid()}};
|
|
|
+ }
|
|
|
+ //更新后兄弟
|
|
|
+ projectMap[selected.nid()] = {query: {ID: selected.nid()}, update: {NextSiblingID: selected.id()}};
|
|
|
+ //更新选中节点
|
|
|
+ projectMap[selected.id()] = {query: {ID: selected.id()}, update: {NextSiblingID: selected.nextSibling.nid()}};
|
|
|
+ this.doAfterTreeOpr({selected, parent, next, projectMap});
|
|
|
+ },
|
|
|
+ loadBtn: function () {
|
|
|
+ $('#upLevel').click(this.upLevel.bind(this));
|
|
|
+ $('#downLevel').click(this.downLevel.bind(this));
|
|
|
+ $('#upMove').click(this.upMove.bind(this));
|
|
|
+ $('#downMove').click(this.downMove.bind(this));
|
|
|
+ },
|
|
|
getSelStyle: function (backColor) {
|
|
|
let style = new GC.Spread.Sheets.Style();
|
|
|
style.backColor = backColor;
|
|
|
@@ -397,6 +534,7 @@ const projTreeObj = {
|
|
|
let me = this;
|
|
|
let node = me.tree.items[newSel.row];
|
|
|
node = node ? node : null;
|
|
|
+ me.refreshBtn(node);
|
|
|
//恢复底色
|
|
|
if(oldSel){
|
|
|
me.setSelStyle(oldSel, me.setting.style.defalutBackColor,sheet);
|