123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- /**
- * Created by Mai on 2017/5/16.
- */
- /*var stdBillsLibController = {
- };*/
- CommonAjax.post('/stdBillsEditor/getStdBillsLib', {userId: userID}, function (datas) {
- var i, select = $('#stdBillsLibSelect');
- select.empty();
- datas.forEach(function (data) {
- var option = $('<option>').val(data.billsLibId).text(data.billsLibName);
- select.append(option);
- });
- if (select.children.length !== 0) {
- LoadStdBills(select.val());
- }
- });
- var LoadStdBills = (function () {
- var stdBillsSpread = SheetDataHelper.createNewSpread($('#stdBillsSpread')[0]);
- var stdBillsJobSpread = null, stdBillsFeatureSpread = null;
- var stdBillsTreeSetting = {
- "treeCol": 0,
- "emptyRows":0,
- "headRows":1,
- "headRowHeight":[
- 35
- ],
- "cols":[
- {
- "width":100,
- "readOnly":null,
- "head":{
- "titleNames":[
- "项目编码"
- ],
- "spanCols":[
- 1
- ],
- "spanRows":[
- 1
- ],
- "vAlign":[
- 1
- ],
- "hAlign":[
- 1
- ],
- "font":[
- "12px Arial"
- ]
- },
- "data":{
- "field":"code",
- "vAlign":0,
- "hAlign":3,
- "font":"12px Arial"
- }
- },
- {
- "width":120,
- "readOnly":null,
- "head":{
- "titleNames":[
- "项目名称"
- ],
- "spanCols":[
- 1
- ],
- "spanRows":[
- 1
- ],
- "vAlign":[
- 1
- ],
- "hAlign":[
- 1
- ],
- "font":[
- "12px Arial"
- ]
- },
- "data":{
- "field":"name",
- "vAlign":0,
- "hAlign":3,
- "font":"12px Arial"
- }
- },
- {
- "width":40,
- "readOnly":null,
- "head":{
- "titleNames":[
- "计量单位"
- ],
- "spanCols":[
- 1
- ],
- "spanRows":[
- 1
- ],
- "vAlign":[
- 1
- ],
- "hAlign":[
- 1
- ],
- "font":[
- "12px Arial"
- ],
- "wordWrap": true
- },
- "data":{
- "field":"unti",
- "vAlign":0,
- "hAlign":3,
- "font":"12px Arial"
- }
- },
- {
- "width":100,
- "readOnly":null,
- "head":{
- "titleNames":[
- "工程量计算规则"
- ],
- "spanCols":[
- 1
- ],
- "spanRows":[
- 1
- ],
- "vAlign":[
- 1
- ],
- "hAlign":[
- 1
- ],
- "font":[
- "12px Arial"
- ]
- },
- "data":{
- "field":"ruleText",
- "vAlign":0,
- "hAlign":3,
- "font":"12px Arial"
- }
- }
- ]
- };
- var stdBillsData, stdBillsJobData, stdBillsFeatureData;
- var stdBillsTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
- var stdBillsTreeController = TREE_SHEET_CONTROLLER.createNew(stdBillsTree, stdBillsSpread.getActiveSheet(), stdBillsTreeSetting);
- var findData = function (value, field, Array) {
- var i = 0;
- for (i = 0; i < Array.length - 1; i++) {
- if (value === Array[i][field]) {
- return Array[i];
- }
- }
- return null;
- };
- var getBillsJobs = function (node) {
- var jobs = [], i, jobData = null;
- if (node && node.data.jobs) {
- for (i = 0; i < node.data.jobs.length - 1; i++) {
- jobData = findData(node.data.jobs[i], 'id', stdBillsJobData);
- if (jobData) {
- jobs.push(jobData);
- }
- }
- }
- return jobs;
- };
- var getBillsFeatures = function (node) {
- var features = [], i, featureData = null;
- if (node && node.data.items) {
- for (i = 0; i < node.data.items.length - 1; i++) {
- featureData = findData(node.data.items[i], 'id', stdBillsFeatureData);
- if (featureData) {
- features.push(featureData);
- }
- }
- }
- return features;
- };
- var showJobs = function (jobs) {
- var jobsSetting = {
- "emptyRows":0,
- "headRows":1,
- "headRowHeight":[
- 20
- ],
- "cols":[
- {
- "width":200,
- "readOnly":null,
- "head":{
- "titleNames":[
- "工程内容"
- ],
- "spanCols":[
- 1
- ],
- "spanRows":[
- 1
- ],
- "vAlign":[
- 1
- ],
- "hAlign":[
- 1
- ],
- "font":[
- "12px Arial"
- ]
- },
- "data":{
- "field":"content",
- "vAlign":0,
- "hAlign":3,
- "font":"12px Arial"
- }
- }
- ]
- };
- SheetDataHelper.loadSheetHeader(jobsSetting, stdBillsJobSpread.getActiveSheet());
- SheetDataHelper.loadSheetData(jobsSetting, stdBillsJobSpread.getActiveSheet(), jobs);
- };
- var showFeatures = function (features) {
- var featuresSetting = {
- "emptyRows":0,
- "headRows":1,
- "headRowHeight":[
- 20
- ],
- "cols":[
- {
- "width":200,
- "readOnly":null,
- "head":{
- "titleNames":[
- "项目特征"
- ],
- "spanCols":[
- 1
- ],
- "spanRows":[
- 1
- ],
- "vAlign":[
- 1
- ],
- "hAlign":[
- 1
- ],
- "font":[
- "12px Arial"
- ]
- },
- "data":{
- "field":"content",
- "vAlign":0,
- "hAlign":3,
- "font":"12px Arial"
- }
- }
- ]
- };
- SheetDataHelper.loadSheetHeader(featuresSetting, stdBillsFeatureSpread.getActiveSheet());
- SheetDataHelper.loadSheetData(featuresSetting, stdBillsFeatureSpread.getActiveSheet(), features);
- }
- var showJobsAndFeatures = function (node) {
- $('#stdBillsJobTab').show();
- $('#stdBillsRemarkTab').hide();
- if (!stdBillsJobSpread) {
- stdBillsJobSpread = SheetDataHelper.createNewSpread($('#stdBillsJobs')[0]);
- }
- showJobs(getBillsJobs(node));
- if (!stdBillsFeatureSpread) {
- stdBillsFeatureSpread = SheetDataHelper.createNewSpread($('#stdBillsFeatures')[0]);
- }
- showFeatures(getBillsFeatures(node));
- };
- var showBillsRemark = function (node) {
- $('#stdBillsJobTab').hide();
- $('#stdBillsRemarkTab').show();
- $('#stdBillsRemark').text(node && node.data.recharge ? node.data.recharge : '');
- };
- var LoadData = function (stdBillsLibID) {
- CommonAjax.post('/stdBillsEditor/getBills', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
- stdBills = datas;
- stdBillsTree.loadDatas(stdBills);
- stdBillsTreeController.showTreeData();
- showBillsRemark(stdBillsTree.firstNode());
- stdBillsTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
- if (node.children.length === 0) {
- showJobsAndFeatures(node);
- } else {
- showBillsRemark(node);
- }
- });
- });
- CommonAjax.post('/stdBillsEditor/getJobContent', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
- stdBillsJobData = datas;
- }, function () {
- stdBillsJobData = [];
- });
- CommonAjax.post('/stdBillsEditor/getItemCharacter', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
- stdBillsFeatureData = datas;
- }, function () {
- stdBillsFeatureData = [];
- });
- };
- stdBillsSpread.options.tabStripVisible = false;
- stdBillsSpread.options.scrollbarMaxAlign = true;
- stdBillsSpread.options.cutCopyIndicatorVisible = false;
- stdBillsSpread.options.allowCopyPasteExcelStyle = false;
- return LoadData;
- })();
- $('#stdBillsLibSelect').change(function () {
- var select = $(this);
- if (this.children.length !== 0) {
- LoadStdBills(select.val());
- }
- });
|