|
@@ -45,6 +45,7 @@ const levelTreeSetting = {
|
|
|
};
|
|
|
const levelNodes =[];
|
|
|
const tenderTree = [];
|
|
|
+let parentId = 0;
|
|
|
function createTree() {
|
|
|
const zTree = $.fn.zTree.getZTreeObj('treeLevel');
|
|
|
if (zTree) {
|
|
@@ -167,11 +168,11 @@ function getCategoryHtml() {
|
|
|
}
|
|
|
const html = [];
|
|
|
for (const c of category) {
|
|
|
- if (c.type === categoryType.key.dropDown) {
|
|
|
+ // if (c.type === categoryType.key.dropDown) {
|
|
|
html.push(getSelectCategoryHtml(c));
|
|
|
- } else if (c.type === categoryType.key.radio) {
|
|
|
- html.push(getRadioCategoryHtml(c));
|
|
|
- }
|
|
|
+ // } else if (c.type === categoryType.key.radio) {
|
|
|
+ // html.push(getRadioCategoryHtml(c));
|
|
|
+ // }
|
|
|
}
|
|
|
return html.join('');
|
|
|
}
|
|
@@ -187,7 +188,7 @@ function initTenderTree () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- function getCategoryNode(category, value, parent) {
|
|
|
+ function getCategoryNode(category, value, parent, i = null) {
|
|
|
const array = parent ? parent.children : tenderTree;
|
|
|
let cate = findCategoryNode(category.id, value, array);
|
|
|
if (!cate) {
|
|
@@ -198,7 +199,8 @@ function initTenderTree () {
|
|
|
vid: value,
|
|
|
name: cateValue.value,
|
|
|
children: [],
|
|
|
- level: category.level,
|
|
|
+ level: i ? i : category.level,
|
|
|
+ sort_id: ++parentId,
|
|
|
};
|
|
|
array.push(cate);
|
|
|
}
|
|
@@ -206,11 +208,17 @@ function initTenderTree () {
|
|
|
}
|
|
|
function loadTenderCategory (tender) {
|
|
|
let tenderCategory = null;
|
|
|
- for (const lc of levelCategory) {
|
|
|
+ for (const [index, lc] of levelCategory.entries()) {
|
|
|
const tenderCate = findNode('cid', lc.id, tender.category);
|
|
|
if (tenderCate) {
|
|
|
tenderCategory = getCategoryNode(lc, tenderCate.value, tenderCategory);
|
|
|
} else {
|
|
|
+ if (index === 0 && tender.category) {
|
|
|
+ for (const [i,c] of tender.category.entries()) {
|
|
|
+ const cate = findNode('id', c.cid, category);
|
|
|
+ tenderCategory = getCategoryNode(cate, c.value, tenderCategory, i+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
return tenderCategory;
|
|
|
}
|
|
|
}
|
|
@@ -230,6 +238,7 @@ function initTenderTree () {
|
|
|
for (const t of tenders) {
|
|
|
calculateTender(t);
|
|
|
t.valid = true;
|
|
|
+ delete t.level;
|
|
|
if (t.category && levelCategory.length > 0) {
|
|
|
const parent = loadTenderCategory(t);
|
|
|
if (parent) {
|
|
@@ -259,13 +268,13 @@ function getProgressHtml(total, pre, cur) {
|
|
|
return '';
|
|
|
}
|
|
|
}
|
|
|
-function recursiveGetTenderNodeHtml (node, arr) {
|
|
|
+function recursiveGetTenderNodeHtml (node, arr, pid) {
|
|
|
const html = [];
|
|
|
- html.push('<tr>');
|
|
|
+ html.push('<tr pid="' + pid + '">');
|
|
|
// 名称
|
|
|
html.push('<td class="in-' + node.level + '">');
|
|
|
if (node.cid) {
|
|
|
- html.push('<i class="fa fa-folder-o"></i> ', node.name);
|
|
|
+ html.push('<span class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
|
|
|
} else {
|
|
|
html.push('<span class="text-muted mr-2">');
|
|
|
html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
|
|
@@ -296,7 +305,7 @@ function recursiveGetTenderNodeHtml (node, arr) {
|
|
|
html.push('</tr>');
|
|
|
if (node.children) {
|
|
|
for (const c of node.children) {
|
|
|
- html.push(recursiveGetTenderNodeHtml(c, node.children));
|
|
|
+ html.push(recursiveGetTenderNodeHtml(c, node.children, node.sort_id));
|
|
|
}
|
|
|
}
|
|
|
return html.join('');
|
|
@@ -313,7 +322,7 @@ function getTenderTreeHtml () {
|
|
|
html.push('<th>', '截止上期完成/本期完成/未完成', '</th>');
|
|
|
html.push('</tr>', '</thead>');
|
|
|
for (const t of tenderTree) {
|
|
|
- html.push(recursiveGetTenderNodeHtml(t, tenderTree));
|
|
|
+ html.push(recursiveGetTenderNodeHtml(t, tenderTree, ''));
|
|
|
}
|
|
|
html.push('</table>');
|
|
|
return html.join('');
|
|
@@ -388,13 +397,15 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
for (const c of category) {
|
|
|
- const cate = {cid: c.id};
|
|
|
- if (c.type === categoryType.key.dropDown) {
|
|
|
+ if (parseInt($('select', '[cate-id=' + c.id + ']').val()) !== 0) {
|
|
|
+ const cate = {cid: c.id};
|
|
|
+ // if (c.type === categoryType.key.dropDown) {
|
|
|
cate.value = parseInt($('select', '[cate-id=' + c.id + ']').val());
|
|
|
- } else if (c.type === categoryType.key.radio) {
|
|
|
- cate.value = parseInt($('input:checked', '[cate-id=' + c.id + ']').val());
|
|
|
+ // } else if (c.type === categoryType.key.radio) {
|
|
|
+ // cate.value = parseInt($('input:checked', '[cate-id=' + c.id + ']').val());
|
|
|
+ // }
|
|
|
+ data.category.push(cate);
|
|
|
}
|
|
|
- data.category.push(cate);
|
|
|
}
|
|
|
postData('/list/add', data, function (result) {
|
|
|
tenders.push(result);
|
|
@@ -405,4 +416,51 @@ $(document).ready(() => {
|
|
|
$('[name=name]', '#add-bd').val('');
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ // 展开和收起
|
|
|
+ $('body').on('click', '.fold-switch', function () {
|
|
|
+ if ($(this).children('i').hasClass('fa-minus-square-o')) {
|
|
|
+ $(this).children('i').removeClass('fa-minus-square-o').addClass('fa-plus-square-o');
|
|
|
+ $(this).attr('title', '展开');
|
|
|
+ const cid = $(this).attr('cid');
|
|
|
+ const node = findTenderTreeNode(parseInt(cid), tenderTree);
|
|
|
+ doTrStatus(returnItem, 'hide');
|
|
|
+ } else {
|
|
|
+ $(this).children('i').removeClass('fa-plus-square-o').addClass('fa-minus-square-o');
|
|
|
+ $(this).attr('title', '收起');
|
|
|
+ const cid = $(this).attr('cid');
|
|
|
+ const node = findTenderTreeNode(parseInt(cid), tenderTree);
|
|
|
+ doTrStatus(returnItem, 'show');
|
|
|
+ }
|
|
|
+ })
|
|
|
});
|
|
|
+
|
|
|
+function doTrStatus(node, status) {
|
|
|
+ if (status === 'show') {
|
|
|
+ $('.c-body').find('tr[pid="'+ node.sort_id +'"]').show();
|
|
|
+ $('.c-body').find('tr[pid="'+ node.sort_id +'"] .fold-switch').attr('title', '收起');
|
|
|
+ $('.c-body').find('tr[pid="'+ node.sort_id +'"] .fold-switch i').removeClass('fa-plus-square-o').removeClass('fa-minus-square-o').addClass('fa-minus-square-o');
|
|
|
+ } else {
|
|
|
+ $('.c-body').find('tr[pid="'+ node.sort_id +'"]').hide();
|
|
|
+ $('.c-body').find('tr[pid="'+ node.sort_id +'"] .fold-switch').attr('title', '展开');
|
|
|
+ $('.c-body').find('tr[pid="'+ node.sort_id +'"] .fold-switch i').removeClass('fa-minus-square-o').removeClass('fa-plus-square-o').addClass('fa-plus-square-o');
|
|
|
+
|
|
|
+ }
|
|
|
+ // 判断是否还有一层
|
|
|
+ if (node.children) {
|
|
|
+ for (const c of node.children) {
|
|
|
+ doTrStatus(c, status);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+let returnItem;
|
|
|
+const findTenderTreeNode = function(sortId, tree) {
|
|
|
+ tree.forEach((item) => {
|
|
|
+ if (item.sort_id !== undefined && item.sort_id === sortId) {
|
|
|
+ returnItem = item;
|
|
|
+ return item;
|
|
|
+ } else if (item.children && item.children.length > 0) {
|
|
|
+ findTenderTreeNode(sortId, item.children);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|