|
@@ -7,418 +7,109 @@
|
|
|
* @date 2018/10/11
|
|
|
* @version
|
|
|
*/
|
|
|
-const EmptyTenderHtml = [
|
|
|
- '<div class="jumbotron">',
|
|
|
- '<h3 class="display-6">还没有标段数据</h3>',
|
|
|
- '</div>'
|
|
|
-];
|
|
|
-// levelTree - setting
|
|
|
-const levelTreeSetting = {
|
|
|
- view: {
|
|
|
- selectedMulti: false
|
|
|
- },
|
|
|
- data: {
|
|
|
- simpleData: {
|
|
|
- idKey: 'lid',
|
|
|
- pIdKey: 'lpId',
|
|
|
- rootPId: 0,
|
|
|
- enable: true,
|
|
|
- }
|
|
|
- },
|
|
|
- edit: {
|
|
|
- enable: true,
|
|
|
- showRemoveBtn: false,
|
|
|
- showRenameBtn: false,
|
|
|
- drag: {
|
|
|
- autoExpandTrigger: true,
|
|
|
- isCopy: false,
|
|
|
- isMove: true,
|
|
|
- prev: false,
|
|
|
- next: false,
|
|
|
- inner: true,
|
|
|
- }
|
|
|
- },
|
|
|
- callback: {
|
|
|
- beforeDrop: beforeDropNode,
|
|
|
- onDrop: onDropNode,
|
|
|
- }
|
|
|
-};
|
|
|
-const levelNodes =[];
|
|
|
-const tenderTree = [];
|
|
|
-let parentId = 0;
|
|
|
-function createTree() {
|
|
|
- const zTree = $.fn.zTree.getZTreeObj('treeLevel');
|
|
|
- if (zTree) {
|
|
|
- zTree.destroy();
|
|
|
- }
|
|
|
- $.fn.zTree.init($("#treeLevel"), levelTreeSetting, levelNodes);
|
|
|
-}
|
|
|
-function beforeDropNode(treeId, treeNodes, targetNode, moveType, isCopy) {
|
|
|
- if (targetNode !== null && targetNode.lid !== 1) {
|
|
|
- const parent = targetNode.getParentNode();
|
|
|
- if (parent && parent.lid === 1) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- for (var i=0,l=treeNodes.length; i<l; i++) {
|
|
|
- if (treeNodes[i].drag === false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!targetNode && treeNodes[i].dropRoot === false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if(treeNodes[i].isParent === true && targetNode.lid !== 1){
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-function onDropNode(event, treeId, treeNodes, targetNode, moveType) {
|
|
|
- const zTree = $.fn.zTree.getZTreeObj(treeId);
|
|
|
- function resetFixNode(id) {
|
|
|
- const node = zTree.getNodeByParam('lid', id);
|
|
|
- node.isParent = true;
|
|
|
- zTree.updateNode(node, false);
|
|
|
- zTree.expandNode(node, true);
|
|
|
- }
|
|
|
- function moveChildren(children, node) {
|
|
|
- if (!children || children.length === 0) { return }
|
|
|
- for (const c of children) {
|
|
|
- moveChildren(c.children, node);
|
|
|
- zTree.moveNode(node, c, 'inner');
|
|
|
- }
|
|
|
- }
|
|
|
- resetFixNode(1);
|
|
|
- resetFixNode(2);
|
|
|
- if (targetNode !== null && targetNode.lid === 1 && treeNodes[0].children && treeNodes[0].children.length !== 0) {
|
|
|
- moveChildren(treeNodes[0].children, zTree.getNodeByParam('lid', 1));
|
|
|
- } else if (targetNode !== null && targetNode.lid !== 1) {
|
|
|
- if (targetNode.children.length >= 2) {
|
|
|
- for (const c of targetNode.children) {
|
|
|
- if (c.lid !== treeNodes[0].lid) {
|
|
|
- zTree.moveNode(treeNodes[0], c, 'inner');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-// 查询方法
|
|
|
-function findNode (key, value, arr) {
|
|
|
- for (const a of arr) {
|
|
|
- if (a[key] && a[key] === value) {
|
|
|
- return a;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-function getPId(level) {
|
|
|
- if (level !== 1) {
|
|
|
- const p = findNode('level', level - 1, levelNodes);
|
|
|
- if (p) {
|
|
|
- return p.lid
|
|
|
- } else {
|
|
|
- return 1;
|
|
|
- }
|
|
|
- } else {
|
|
|
- return 2;
|
|
|
- }
|
|
|
-}
|
|
|
-// 分类数据排序
|
|
|
-function sortCategory() {
|
|
|
- category.sort(function (a, b) {
|
|
|
- return a.level ? (b.level ? a.level - b.level : -1) : a.id - b.id;
|
|
|
- });
|
|
|
-}
|
|
|
-// 初始化分类树结构数据
|
|
|
-function initCategoryLevelNode() {
|
|
|
- levelNodes.splice(0, levelNodes.length);
|
|
|
- levelNodes.push(
|
|
|
- { lid:1, lpId:0, name:"可用类别", open:true, isParent: true, drag: false},
|
|
|
- { lid:2, lpId:0, name:"已用类别", open:true, isParent: true, drag: false}
|
|
|
- );
|
|
|
- for (const c of category) {
|
|
|
- const cate = JSON.parse(JSON.stringify(c));
|
|
|
- cate.lid = levelNodes.length + 1;
|
|
|
- cate.open = true;
|
|
|
- cate.dropRoot = false;
|
|
|
- if (!cate.level) {
|
|
|
- cate.lpId = 1;
|
|
|
- levelNodes.push(cate);
|
|
|
- } else {
|
|
|
- cate.lpId = getPId(cate.level);
|
|
|
- levelNodes.push(cate);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-// 新建标段 -- 分类属性选择
|
|
|
-function getCategoryHtml() {
|
|
|
- function getSelectCategoryHtml (cate) {
|
|
|
+const tenderListSpec = (function(){
|
|
|
+ function getTenderNodeHtml(node, arr, pid) {
|
|
|
const html = [];
|
|
|
- html.push('<div class="form-group" cate-id="' + cate.id + '">');
|
|
|
- html.push('<lable>', cate.name, '</lable>');
|
|
|
- html.push('<select class="form-control form-control-sm">');
|
|
|
- for (const v of cate.value) {
|
|
|
- html.push('<option value="' + v.id + '">', v.value, '</option>');
|
|
|
- }
|
|
|
- html.push('<option value="0">不选</option>');
|
|
|
- html.push('</select>');
|
|
|
- html.push('</div>');
|
|
|
- return html.join('');
|
|
|
- }
|
|
|
- function getRadioCategoryHtml (cate) {
|
|
|
- const html = [];
|
|
|
- html.push('<div class="form-group" cate-id="' + cate.id + '">');
|
|
|
- html.push('<lable>', cate.name, '</lable>');
|
|
|
- html.push('<div>');
|
|
|
- for (const iV in cate.value) {
|
|
|
- const v = cate.value[iV];
|
|
|
- html.push('<div class="form-check-inline">');
|
|
|
- html.push('<input class="form-check-input" type="radio"', 'name="' + cate.name + '" ', 'value="' , v.id, (iV == 0 ? '" checked="' : ''), '">');
|
|
|
- html.push('<label class="form-check-label">', v.value, '</label>');
|
|
|
- html.push('</div>');
|
|
|
- }
|
|
|
- html.push('</div>');
|
|
|
- html.push('</div>');
|
|
|
- return html.join('');
|
|
|
- }
|
|
|
- const html = [];
|
|
|
- for (const c of category) {
|
|
|
- // if (c.type === categoryType.key.dropDown) {
|
|
|
- html.push(getSelectCategoryHtml(c));
|
|
|
- // } else if (c.type === categoryType.key.radio) {
|
|
|
- // html.push(getRadioCategoryHtml(c));
|
|
|
- // }
|
|
|
- }
|
|
|
- return html.join('');
|
|
|
-}
|
|
|
-// 初始化TenderTree数据
|
|
|
-function calculateParent(node) {
|
|
|
- if (node.children && node.cid) {
|
|
|
- node.total_price = 0;
|
|
|
- node.gather_tp = 0;
|
|
|
- node.end_contract_tp = 0;
|
|
|
- node.end_qc_tp = 0;
|
|
|
- node.end_gather_tp = 0;
|
|
|
- node.pre_gather_tp = 0;
|
|
|
- node.yf_tp = 0;
|
|
|
- node.end_yf_tp = 0;
|
|
|
- node.advance_tp = 0;
|
|
|
- node.contract_price = 0;
|
|
|
- for (const c of node.children) {
|
|
|
- calculateParent(c);
|
|
|
- node.total_price = ZhCalc.add(node.total_price, c.total_price);
|
|
|
- node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
|
|
|
- node.end_contract_tp = ZhCalc.add(node.end_contract_tp, c.end_contract_tp);
|
|
|
- node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
|
|
|
- node.end_gather_tp = ZhCalc.add(node.end_gather_tp, c.end_gather_tp);
|
|
|
- node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
|
|
|
- node.yf_tp = ZhCalc.add(node.yf_tp, c.yf_tp);
|
|
|
- node.end_yf_tp = ZhCalc.add(node.end_yf_tp, c.end_yf_tp);
|
|
|
- node.advance_tp = ZhCalc.add(node.advance_tp, c.advance_tp);
|
|
|
- node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-function initTenderTree () {
|
|
|
- const levelCategory = category.filter(function (c) {
|
|
|
- return c.level && c.level > 0;
|
|
|
- });
|
|
|
- function findCategoryNode(cid, value, array) {
|
|
|
- for (const a of array) {
|
|
|
- if (a.cid === cid && a.vid === value) {
|
|
|
- return a;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- function getCategoryNode(category, value, parent, i = null) {
|
|
|
- const array = parent ? parent.children : tenderTree;
|
|
|
- let cate = findCategoryNode(category.id, value, array);
|
|
|
- if (!cate) {
|
|
|
- const cateValue = findNode('id', value, category.value);
|
|
|
- if (!cateValue) return null;
|
|
|
- cate = {
|
|
|
- cid: category.id,
|
|
|
- vid: value,
|
|
|
- name: cateValue.value,
|
|
|
- children: [],
|
|
|
- level: i ? i : category.level,
|
|
|
- sort_id: ++parentId,
|
|
|
- sort: cateValue.sort,
|
|
|
- };
|
|
|
- array.push(cate);
|
|
|
- }
|
|
|
- return cate;
|
|
|
- }
|
|
|
- function loadTenderCategory (tender) {
|
|
|
- let tenderCategory = null;
|
|
|
- for (const [index, lc] of levelCategory.entries()) {
|
|
|
- const tenderCate = findNode('cid', lc.id, tender.category);
|
|
|
- if (tenderCate) {
|
|
|
- tenderCategory = getCategoryNode(lc, tenderCate.value, tenderCategory);
|
|
|
+ html.push('<tr pid="' + pid + '">');
|
|
|
+ // 名称
|
|
|
+ html.push('<td style="min-width: 300px;" class="in-' + node.level + '">');
|
|
|
+ if (node.cid) {
|
|
|
+ html.push('<span onselectstart="return false" style="{-moz-user-select:none}" 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 ? '└' : '├');
|
|
|
+ html.push('</span>');
|
|
|
+ //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
|
|
|
+ html.push('<a href="javascript: void(0)" style="min-width: 300px;word-break:break-all;" id="' + node.id + '">', node.name, '</a>');
|
|
|
+ }
|
|
|
+ html.push('</td>');
|
|
|
+ // 计量模式
|
|
|
+ html.push('<td style="width: 75px" class="text-center">');
|
|
|
+ if (node.measure_type) {
|
|
|
+ html.push(node.measure_type === measureType.tz.value ? '0号台账' : '工程量清单');
|
|
|
+ }
|
|
|
+ html.push('</td>');
|
|
|
+ // 计量进度
|
|
|
+ html.push('<td style="width: 105px">');
|
|
|
+ if (!node.cid && node.cur_flow) {
|
|
|
+ if (node.progress) {
|
|
|
+ html.push(node.progress.title + ' (' + '<span class="' + node.progress.status_class +'">' + node.progress.status + '</span>' + ')');
|
|
|
} else {
|
|
|
- if (index === 0 && tender.category) {
|
|
|
- for (const [i,c] of tender.category.entries()) {
|
|
|
- const cate = findNode('id', c.cid, category);
|
|
|
- if (cate) {
|
|
|
- tenderCategory = getCategoryNode(cate, c.value, tenderCategory, i+1);
|
|
|
- } else {
|
|
|
- console.log(tender.name, c.cid, c.value);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return tenderCategory;
|
|
|
+ html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>' + ')');
|
|
|
}
|
|
|
}
|
|
|
- return tenderCategory;
|
|
|
- }
|
|
|
- function calculateTender(tender) {
|
|
|
- if (tender.stage_tp) {
|
|
|
- tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
|
|
|
- tender.end_contract_tp = ZhCalc.sum([tender.stage_tp.pre_contract_tp, tender.stage_tp.contract_tp, tender.stage_tp.contract_pc_tp]);
|
|
|
- tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]);
|
|
|
- tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
|
|
|
- tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
|
|
|
- tender.yf_tp = ZhCalc.add(tender.stage_tp.yf_tp);
|
|
|
- tender.end_yf_tp = ZhCalc.add(tender.stage_tp.pre_yf_tp, tender.yf_tp);
|
|
|
- } else if (tender.lastStage) {
|
|
|
- tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
|
|
|
- tender.end_contract_tp = ZhCalc.sum([tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp, tender.lastStage.contract_pc_tp]);
|
|
|
- tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
|
|
|
- tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
|
|
|
- tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
|
|
|
- tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
|
|
|
- tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
|
|
|
- }
|
|
|
- }
|
|
|
- tenderTree.splice(0, tenderTree.length);
|
|
|
- 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) {
|
|
|
- t.level = parent.level + 1;
|
|
|
- parent.children.push(t);
|
|
|
+ html.push('</td>');
|
|
|
+ // 当前流程
|
|
|
+ html.push('<td style="width: 230px">');
|
|
|
+ if (!node.cid && node.cur_flow) {
|
|
|
+ if (node.stage_status !== undefined) {
|
|
|
+ const curUser = node.cur_flow.name + (node.cur_flow.role ? '-'+node.cur_flow.role : '');
|
|
|
+ html.push((node.stage_status === auditConst.stage.status.uncheck || node.ledger_status === auditConst.ledger.status.uncheck)
|
|
|
+ ? curUser
|
|
|
+ : `<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="${node.stage_count ? 'stage' : 'ledger'}" data-tender="${node.id}" data-order="${node.stage_count ? node.stage_count + '' : ''}">${curUser}</a>`
|
|
|
+ );
|
|
|
+ html.push(`<span class="${node.progress.status_class} ml-1">${node.progress.status}</span>`);
|
|
|
} else {
|
|
|
- tenderTree.push(t);
|
|
|
+ html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? '' :
|
|
|
+ '<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="'+ (node.lastStage ? 'stage' : 'ledger') +'"' +
|
|
|
+ ' data-tender="'+ node.id +'" data-order="'+ (node.lastStage ? node.lastStage.order : '') +'">');
|
|
|
+ html.push(node.cur_flow.name+ (node.cur_flow.role ? '-'+node.cur_flow.role : ''));
|
|
|
+ html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? ' ':
|
|
|
+ '</a> ');
|
|
|
+ html.push('<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>');
|
|
|
}
|
|
|
- } else {
|
|
|
- tenderTree.push(t);
|
|
|
- }
|
|
|
- }
|
|
|
- sortTenderTree();
|
|
|
- for (const t of tenderTree) {
|
|
|
- calculateParent(t);
|
|
|
- }
|
|
|
-}
|
|
|
-function recursiveGetTenderNodeHtml (node, arr, pid) {
|
|
|
- const html = [];
|
|
|
- html.push('<tr pid="' + pid + '">');
|
|
|
- // 名称
|
|
|
- html.push('<td style="min-width: 300px;" class="in-' + node.level + '">');
|
|
|
- if (node.cid) {
|
|
|
- html.push('<span onselectstart="return false" style="{-moz-user-select:none}" 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 ? '└' : '├');
|
|
|
- html.push('</span>');
|
|
|
- //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
|
|
|
- html.push('<a href="javascript: void(0)" style="min-width: 300px;word-break:break-all;" id="' + node.id + '">', node.name, '</a>');
|
|
|
- }
|
|
|
- html.push('</td>');
|
|
|
- // 计量模式
|
|
|
- html.push('<td style="width: 75px" class="text-center">');
|
|
|
- if (node.measure_type) {
|
|
|
- html.push(node.measure_type === measureType.tz.value ? '0号台账' : '工程量清单');
|
|
|
- }
|
|
|
- html.push('</td>');
|
|
|
- // 计量进度
|
|
|
- html.push('<td style="width: 105px">');
|
|
|
- if (!node.cid && node.cur_flow) {
|
|
|
- if (node.progress) {
|
|
|
- html.push(node.progress.title + ' (' + '<span class="' + node.progress.status_class +'">' + node.progress.status + '</span>' + ')');
|
|
|
- } else {
|
|
|
- html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>' + ')');
|
|
|
- }
|
|
|
- }
|
|
|
- html.push('</td>');
|
|
|
- // 当前流程
|
|
|
- html.push('<td style="width: 230px">');
|
|
|
- if (!node.cid && node.cur_flow) {
|
|
|
- if (node.stage_status !== undefined) {
|
|
|
- const curUser = node.cur_flow.name + (node.cur_flow.role ? '-'+node.cur_flow.role : '');
|
|
|
- html.push((node.stage_status === auditConst.stage.status.uncheck || node.ledger_status === auditConst.ledger.status.uncheck)
|
|
|
- ? curUser
|
|
|
- : `<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="${node.stage_count ? 'stage' : 'ledger'}" data-tender="${node.id}" data-order="${node.stage_count ? node.stage_count + '' : ''}">${curUser}</a>`
|
|
|
- );
|
|
|
- html.push(`<span class="${node.progress.status_class} ml-1">${node.progress.status}</span>`);
|
|
|
- } else {
|
|
|
- html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? '' :
|
|
|
- '<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="'+ (node.lastStage ? 'stage' : 'ledger') +'"' +
|
|
|
- ' data-tender="'+ node.id +'" data-order="'+ (node.lastStage ? node.lastStage.order : '') +'">');
|
|
|
- html.push(node.cur_flow.name+ (node.cur_flow.role ? '-'+node.cur_flow.role : ''));
|
|
|
- html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? ' ':
|
|
|
- '</a> ');
|
|
|
- html.push('<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>');
|
|
|
- }
|
|
|
- }
|
|
|
- html.push('</td>');
|
|
|
- // 上一流程审批时间
|
|
|
- // html.push('<td style="width: 7%">');
|
|
|
- // if (!node.cid && node.pre_flow) {
|
|
|
- // html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
|
|
|
- // }
|
|
|
- // html.push('</td>');
|
|
|
- // 签约合同价
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.contract_price || '');
|
|
|
- html.push('</td>');
|
|
|
- // 0号台账合同
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.total_price || '');
|
|
|
- html.push('</td>');
|
|
|
- // 本期完成
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.gather_tp || '');
|
|
|
- html.push('</td>');
|
|
|
- // 截止本期合同
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.end_contract_tp || '');
|
|
|
- html.push('</td>');
|
|
|
- // 截止本期变更
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.end_qc_tp || '');
|
|
|
- html.push('</td>');
|
|
|
- // 截止本期完成
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.end_gather_tp || '');
|
|
|
- html.push('</td>');
|
|
|
- // 截止上期完成
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.pre_gather_tp || '');
|
|
|
- html.push('</td>');
|
|
|
- // 预付款
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.advance_tp || '');
|
|
|
- html.push('</td>');
|
|
|
- // 本期应付
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.yf_tp || '');
|
|
|
- html.push('</td>');
|
|
|
- // 截止本期应付
|
|
|
- html.push('<td style="width: 100px" class="text-right">');
|
|
|
- html.push(node.end_yf_tp || '');
|
|
|
- html.push('</td>');
|
|
|
- html.push('</tr>');
|
|
|
- if (node.children) {
|
|
|
- for (const c of node.children) {
|
|
|
- html.push(recursiveGetTenderNodeHtml(c, node.children, node.sort_id));
|
|
|
}
|
|
|
+ html.push('</td>');
|
|
|
+ // 上一流程审批时间
|
|
|
+ // html.push('<td style="width: 7%">');
|
|
|
+ // if (!node.cid && node.pre_flow) {
|
|
|
+ // html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
|
|
|
+ // }
|
|
|
+ // html.push('</td>');
|
|
|
+ // 签约合同价
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.contract_price || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 0号台账合同
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.total_price || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 本期完成
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.gather_tp || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 截止本期合同
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.end_contract_tp || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 截止本期变更
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.end_qc_tp || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 截止本期完成
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.end_gather_tp || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 截止上期完成
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.pre_gather_tp || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 预付款
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.advance_tp || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 本期应付
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.yf_tp || '');
|
|
|
+ html.push('</td>');
|
|
|
+ // 截止本期应付
|
|
|
+ html.push('<td style="width: 100px" class="text-right">');
|
|
|
+ html.push(node.end_yf_tp || '');
|
|
|
+ html.push('</td>');
|
|
|
+ html.push('</tr>');
|
|
|
+ return html.join('');
|
|
|
}
|
|
|
- return html.join('');
|
|
|
-}
|
|
|
-// 根据TenderTree数据获取Html代码
|
|
|
-function getTenderTreeHtml () {
|
|
|
- if (tenderTree.length > 0) {
|
|
|
+ function getTenderTreeHeaderHtml() {
|
|
|
const html = [];
|
|
|
html.push('<table class="table table-hover table-bordered">');
|
|
|
html.push('<thead style="position: fixed;left:56px;top: 34px;">', '<tr>');
|
|
@@ -438,110 +129,55 @@ function getTenderTreeHtml () {
|
|
|
html.push('<th class="text-center" style="width: 100px">', '本期应付', '</th>');
|
|
|
html.push('<th class="text-center" style="width: 100px">', '截止本期应付', '</th>');
|
|
|
html.push('</tr>', '</thead>');
|
|
|
- parentId = 0;
|
|
|
- for (const t of tenderTree) {
|
|
|
- html.push(recursiveGetTenderNodeHtml(t, tenderTree, ''));
|
|
|
- }
|
|
|
- html.push('</table>');
|
|
|
return html.join('');
|
|
|
- } else {
|
|
|
- return EmptyTenderHtml.join('');
|
|
|
}
|
|
|
-}
|
|
|
-function bindTenderUrl() {
|
|
|
- $('.c-body').on('click', 'a', function () {
|
|
|
- const tenderId = parseInt($(this).attr('id'));
|
|
|
- const tender = _.find(tenders, function (t) {
|
|
|
- return t.id === tenderId;
|
|
|
- });
|
|
|
- if (!tender) return;
|
|
|
- if (!tender.measure_type && tender.user_id !== userID) return;
|
|
|
- if (tender.measure_type) {
|
|
|
- // window.location.href = '/tender/' + tenderId;
|
|
|
- window.open('/tender/' + tenderId, '_blank');
|
|
|
- } else {
|
|
|
- for (const a of $('a', '#jlms')) {
|
|
|
- a.href = '/tender/' + tenderId + '/type?type=' + $(a).attr('mst');
|
|
|
- }
|
|
|
- $('#jlms').modal('show');
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-$(document).ready(() => {
|
|
|
- autoFlashHeight();
|
|
|
- sortCategory();
|
|
|
- // 初始化分类数据
|
|
|
- initCategoryLevelNode();
|
|
|
- $('.modal-body', '#add-bd').append(getCategoryHtml());
|
|
|
- // 初始化标段树结构
|
|
|
- initTenderTree();
|
|
|
- $('.c-body').html(getTenderTreeHtml());
|
|
|
- bindTenderUrl();
|
|
|
- localHideList();
|
|
|
- tenderTreeShowLevel.initShowLevel();
|
|
|
- // 分类
|
|
|
- $('#cate-set').on('show.bs.modal', function () {
|
|
|
- createTree();
|
|
|
- });
|
|
|
- $('#set-cate-ok').click(function () {
|
|
|
- const data = [];
|
|
|
- const zTree = $.fn.zTree.getZTreeObj('treeLevel');
|
|
|
- for (const c of category) {
|
|
|
- const node = zTree.getNodeByParam('id', c.id);
|
|
|
- const parent = node.getParentNode();
|
|
|
- if (parent.lid === 1) {
|
|
|
- data.push({id: c.id, level: 0});
|
|
|
- } else {
|
|
|
- data.push({id: c.id, level: node.getPath().length - 1});
|
|
|
- }
|
|
|
- }
|
|
|
- postData('/setting/category/level', data, function (rst) {
|
|
|
- for (const d of data) {
|
|
|
- const c = findNode('id', d.id, category);
|
|
|
- c.level = d.level;
|
|
|
- }
|
|
|
- sortCategory();
|
|
|
- initCategoryLevelNode();
|
|
|
- initTenderTree();
|
|
|
- $('.c-body').html(getTenderTreeHtml());
|
|
|
- localHideList();
|
|
|
- $('#cate-set').modal('hide');
|
|
|
- tenderTreeShowLevel.refreshMenuVisible();
|
|
|
- });
|
|
|
- });
|
|
|
- // 新增标段
|
|
|
- $('#add-bd-ok').click(function () {
|
|
|
- const data = {
|
|
|
- name: cleanSymbols($('[name=name]', '#add-bd').val()),
|
|
|
- valuation: $('[name=valuation]:checked').val(),
|
|
|
- category: [],
|
|
|
- };
|
|
|
- if (!data.name || data.name === '') {
|
|
|
- // TODO 提示用户
|
|
|
- return;
|
|
|
+ function calculateTender(tender) {
|
|
|
+ if (tender.stage_tp) {
|
|
|
+ tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
|
|
|
+ tender.end_contract_tp = ZhCalc.sum([tender.stage_tp.pre_contract_tp, tender.stage_tp.contract_tp, tender.stage_tp.contract_pc_tp]);
|
|
|
+ tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]);
|
|
|
+ tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
|
|
|
+ tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
|
|
|
+ tender.yf_tp = ZhCalc.add(tender.stage_tp.yf_tp);
|
|
|
+ tender.end_yf_tp = ZhCalc.add(tender.stage_tp.pre_yf_tp, tender.yf_tp);
|
|
|
+ } else if (tender.lastStage) {
|
|
|
+ tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
|
|
|
+ tender.end_contract_tp = ZhCalc.sum([tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp, tender.lastStage.contract_pc_tp]);
|
|
|
+ tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
|
|
|
+ tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
|
|
|
+ tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
|
|
|
+ tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
|
|
|
+ tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
|
|
|
}
|
|
|
- for (const c of category) {
|
|
|
- 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());
|
|
|
- // }
|
|
|
- data.category.push(cate);
|
|
|
+ }
|
|
|
+ function calculateParent(node) {
|
|
|
+ if (node.children && node.cid) {
|
|
|
+ node.total_price = 0;
|
|
|
+ node.gather_tp = 0;
|
|
|
+ node.end_contract_tp = 0;
|
|
|
+ node.end_qc_tp = 0;
|
|
|
+ node.end_gather_tp = 0;
|
|
|
+ node.pre_gather_tp = 0;
|
|
|
+ node.yf_tp = 0;
|
|
|
+ node.end_yf_tp = 0;
|
|
|
+ node.advance_tp = 0;
|
|
|
+ node.contract_price = 0;
|
|
|
+ for (const c of node.children) {
|
|
|
+ calculateParent(c);
|
|
|
+ node.total_price = ZhCalc.add(node.total_price, c.total_price);
|
|
|
+ node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
|
|
|
+ node.end_contract_tp = ZhCalc.add(node.end_contract_tp, c.end_contract_tp);
|
|
|
+ node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
|
|
|
+ node.end_gather_tp = ZhCalc.add(node.end_gather_tp, c.end_gather_tp);
|
|
|
+ node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
|
|
|
+ node.yf_tp = ZhCalc.add(node.yf_tp, c.yf_tp);
|
|
|
+ node.end_yf_tp = ZhCalc.add(node.end_yf_tp, c.end_yf_tp);
|
|
|
+ node.advance_tp = ZhCalc.add(node.advance_tp, c.advance_tp);
|
|
|
+ node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
|
|
|
}
|
|
|
}
|
|
|
- $('#hide-all').show();
|
|
|
- postData('/list/add', data, function (result) {
|
|
|
- tenders.push(result);
|
|
|
- initTenderTree();
|
|
|
- $('.c-body').html(getTenderTreeHtml());
|
|
|
- bindTenderUrl();
|
|
|
- localHideList();
|
|
|
- $('#add-bd').modal('hide');
|
|
|
- $('[name=name]', '#add-bd').val('');
|
|
|
- $('#hide-all').hide();
|
|
|
- });
|
|
|
- });
|
|
|
-});
|
|
|
+ }
|
|
|
+ return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent }
|
|
|
+})();
|
|
|
+
|
|
|
+
|