|
@@ -742,26 +742,71 @@ let pageCCOprObj = {
|
|
|
CommonAjax.post(url, postData, function (rstData) {
|
|
|
//更新节点数据
|
|
|
if(updateCol){
|
|
|
- if (!oprObj.hasOwnProperty("getID")) {
|
|
|
- // 已当前选中行更新数据
|
|
|
- let selectedNode = projectObj.mainController.tree.selected;
|
|
|
- selectedNode.data[updateObj.field] = updateObj.updateArr;
|
|
|
- selectedNode.data[txtObj.field] = txtObj.text;
|
|
|
- me.showData(oprObj.workBook.getSheet(0), oprObj.setting, oprObj.currentCache);//刷新特征及内容Spread
|
|
|
+ // 已当前选中行更新数据
|
|
|
+ let selectedNode = projectObj.mainController.tree.selected;
|
|
|
+ selectedNode.data[updateObj.field] = updateObj.updateArr;
|
|
|
+ selectedNode.data[txtObj.field] = txtObj.text;
|
|
|
+ me.showData(oprObj.workBook.getSheet(0), oprObj.setting, oprObj.currentCache);//刷新特征及内容Spread
|
|
|
|
|
|
- let activeCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];
|
|
|
- projectObj.mainSpread.getActiveSheet().setValue(activeCell.row, updateCol, txtObj.text + ''); //刷新输出显示
|
|
|
- projectObj.mainSpread.getActiveSheet().autoFitRow(activeCell.row);
|
|
|
- } else {
|
|
|
- // 以节点更新数据
|
|
|
- const row = oprObj.getID() - 1;
|
|
|
- projectObj.mainSpread.getActiveSheet().setValue(row, updateCol, txtObj.text + ''); //刷新输出显示
|
|
|
- projectObj.mainSpread.getActiveSheet().autoFitRow(row);
|
|
|
- }
|
|
|
+ let activeCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];
|
|
|
+ projectObj.mainSpread.getActiveSheet().setValue(activeCell.row, updateCol, txtObj.text + ''); //刷新输出显示
|
|
|
+ projectObj.mainSpread.getActiveSheet().autoFitRow(activeCell.row);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
|
+ * 更新bill数据
|
|
|
+ *
|
|
|
+ * @param {Object} findSet - 更新条件
|
|
|
+ * @param {Object} updateData - 更新数据
|
|
|
+ * @param {Function} callback - 回调函数
|
|
|
+ * @return {void}
|
|
|
+ */
|
|
|
+ updateBill: function(findSet, updateData, callback) {
|
|
|
+ if (!updateData instanceof Array || updateData.length <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let url = '/bills/updateBill';
|
|
|
+ let postData = { findSet, updateData };
|
|
|
+ CommonAjax.post(url, postData, function (response) {
|
|
|
+ callback(response);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 刷新节点数据
|
|
|
+ *
|
|
|
+ * @param {Object} node - 节点数据
|
|
|
+ * @param {Object} refreshData - 刷新的数据
|
|
|
+ * @param {Object} defaultData - 默认数据
|
|
|
+ * @return {void}
|
|
|
+ */
|
|
|
+ refreshView: function(node, refreshData, defaultData) {
|
|
|
+ // 更新清单行特征列或内容列
|
|
|
+ let updateCol = [
|
|
|
+ { name: 'character', col: 4 },
|
|
|
+ { name: 'content', col: 5 },
|
|
|
+ { name: 'name', col: 2 }
|
|
|
+ ];
|
|
|
+ if (updateCol === '') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const row = node.getID() - 1;
|
|
|
+ // 刷新输出显示
|
|
|
+ for (const tmp of updateCol) {
|
|
|
+ // 没有默认的数据则跳过刷新
|
|
|
+ if (defaultData[tmp.name] === undefined) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 不存在更新的数据则全部用默认数据替代
|
|
|
+ if (refreshData[tmp.name] === undefined) {
|
|
|
+ projectObj.mainSpread.getActiveSheet().setValue(row, tmp.col, defaultData[tmp.name] + '');
|
|
|
+ } else {
|
|
|
+ projectObj.mainSpread.getActiveSheet().setValue(row, tmp.col, refreshData[tmp.name] + '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ projectObj.mainSpread.getActiveSheet().autoFitRow(row);
|
|
|
+ },
|
|
|
+ /**
|
|
|
* 根据配置设置清单项目特征
|
|
|
*
|
|
|
* @param {Object} node - 选中的node节点
|
|
@@ -770,91 +815,46 @@ let pageCCOprObj = {
|
|
|
*/
|
|
|
setCharacterBySetting: function(node, setting) {
|
|
|
let contentArray = [];
|
|
|
- // 特征部分
|
|
|
- const itemCharacter = node.data.itemCharacter;
|
|
|
- // 内容数据
|
|
|
- const itemJob = node.data.jobContent;
|
|
|
+ let self = this;
|
|
|
|
|
|
- if (itemCharacter === undefined || itemCharacter.length <= 0 || itemJob === undefined || itemJob.length <= 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
// 保存的条件数据
|
|
|
const findSet = { ID: node.data.ID, projectID: node.data.projectID };
|
|
|
- const baseData = { findSet, itemJob, itemCharacter };
|
|
|
- let characterArray = [];
|
|
|
- for (const tmp of itemCharacter) {
|
|
|
- if (tmp.eigenvalue === undefined || tmp.eigenvalue.length <= 0 || !tmp.isChecked) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 获取选中的特征值
|
|
|
- let selectedEigen = '';
|
|
|
- for (const eigen of tmp.eigenvalue) {
|
|
|
- if (eigen.isSelected) {
|
|
|
- selectedEigen = eigen.value;
|
|
|
- }
|
|
|
- }
|
|
|
- // 匹配设置的序号格式
|
|
|
- const serialNo = this.formatSerialNumber(setting.serialType, tmp.serialNo);
|
|
|
- let characterString = '';
|
|
|
- // 特征生成方式
|
|
|
- switch (setting.characterFormat) {
|
|
|
- case '1':
|
|
|
- // 特征值
|
|
|
- characterString = serialNo + selectedEigen;
|
|
|
- break;
|
|
|
- case '2':
|
|
|
- // 特征:特征值
|
|
|
- characterString = serialNo + tmp.character + ': ' + selectedEigen;
|
|
|
- break;
|
|
|
- }
|
|
|
- characterArray.push(characterString);
|
|
|
- }
|
|
|
+ // 获取默认数据
|
|
|
+ const defaultData = this.getDataBySetting(node, {
|
|
|
+ serialType: "1",
|
|
|
+ characterFormat: "2",
|
|
|
+ });
|
|
|
+ // console.log(defaultData);return false;
|
|
|
+ defaultData.character = defaultData.character.join("\r\n");
|
|
|
+ defaultData.content = defaultData.content.join("\r\n");
|
|
|
|
|
|
- // 内容部分
|
|
|
- let jobArray = [];
|
|
|
- for (const tmp of itemJob) {
|
|
|
- if (!tmp.isChecked) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 匹配设置的序号格式
|
|
|
- const serialNo = this.formatSerialNumber(setting.serialType, tmp.serialNo);
|
|
|
- jobArray.push(serialNo + tmp.content)
|
|
|
- }
|
|
|
+ // 获取当前设置数据
|
|
|
+ const currentData = this.getDataBySetting(node, setting);
|
|
|
|
|
|
// 组合数据
|
|
|
let content = '';
|
|
|
- const jobContent = jobArray.join("\r\n");
|
|
|
- const characterContent = characterArray.join("\r\n");
|
|
|
- let nodeNameList = node.data.name.split("\n");
|
|
|
- const nameContent = nodeNameList[0] !== undefined ? nodeNameList[0] : '';
|
|
|
- // 存入对象,生成数据时用
|
|
|
- let defaultContentInfo = {
|
|
|
- jobContent,
|
|
|
- characterContent,
|
|
|
- nameContent
|
|
|
- };
|
|
|
switch (setting.addContent) {
|
|
|
case "1":
|
|
|
// 项目特征+工作内容
|
|
|
contentArray.push('[项目特征]');
|
|
|
- contentArray.push.apply(contentArray, characterArray);
|
|
|
+ contentArray.push.apply(contentArray, currentData.character);
|
|
|
contentArray.push('[工作内容]');
|
|
|
- contentArray.push.apply(contentArray, jobArray);
|
|
|
+ contentArray.push.apply(contentArray, currentData.content);
|
|
|
break;
|
|
|
case "2":
|
|
|
// 工作内容+项目特征
|
|
|
contentArray.push('[工作内容]');
|
|
|
- contentArray.push.apply(contentArray, jobArray);
|
|
|
+ contentArray.push.apply(contentArray, currentData.content);
|
|
|
contentArray.push('[项目特征]');
|
|
|
- contentArray.push.apply(contentArray, characterArray);
|
|
|
+ contentArray.push.apply(contentArray, currentData.character);
|
|
|
break;
|
|
|
case "3":
|
|
|
// 项目特征
|
|
|
- contentArray.push.apply(contentArray, characterArray);
|
|
|
+ contentArray.push.apply(contentArray, currentData.character);
|
|
|
break;
|
|
|
case "4":
|
|
|
// 工作内容
|
|
|
- contentArray.push.apply(contentArray, jobArray);
|
|
|
+ contentArray.push.apply(contentArray, currentData.content);
|
|
|
break;
|
|
|
case "5":
|
|
|
// 定额子目
|
|
@@ -880,53 +880,57 @@ let pageCCOprObj = {
|
|
|
content = '(' + contentArray.join(',') + ')';
|
|
|
break;
|
|
|
}
|
|
|
- // 还原数据
|
|
|
- this.restoreData(node, setting.position, baseData, defaultContentInfo);
|
|
|
// 添加到对应位置
|
|
|
- let saveObj = {};
|
|
|
+ let saveObj = [];
|
|
|
+ let refreshData = {};
|
|
|
+ saveObj.push({ field: 'addRule', value: setting });
|
|
|
switch (setting.position) {
|
|
|
case "1":
|
|
|
// 添加到项目特征列
|
|
|
- saveObj = {field: 'itemCharacterText', text: content};
|
|
|
- // 更新到数据库
|
|
|
- pageCCOprObj.updateCharacterContent(findSet, {field: 'itemCharacter', updateArr: itemCharacter},
|
|
|
- saveObj, node);
|
|
|
+ saveObj.push({field: 'itemCharacterText', value: content});
|
|
|
+ // 还原名称及内容
|
|
|
+ saveObj.push({field: 'name', value: defaultData.name});
|
|
|
+ saveObj.push({field: 'jobContentText', value: defaultData.content});
|
|
|
+ // 刷新数据
|
|
|
+ refreshData = {'character': content};
|
|
|
break;
|
|
|
case "2":
|
|
|
// 添加到清单名称列
|
|
|
- const column = this.mainActiveCell.col !== undefined ? this.mainActiveCell.col : -1;
|
|
|
- let colSetting = projectObj.mainController.setting.cols[column];
|
|
|
- if (colSetting !== undefined) {
|
|
|
- content = node.data.name + "\r\n" + content;
|
|
|
- projectObj.project.Bills.updateField(node.source, 'name', content, true);
|
|
|
- projectObj.mainController.refreshTreeNode([node], false);
|
|
|
- }
|
|
|
+ content = defaultData.name + "\r\n" + content;
|
|
|
+ saveObj.push({field: 'name', value: content});
|
|
|
+ // 还原特征及内容
|
|
|
+ saveObj.push({field: 'itemCharacterText', value: defaultData.character});
|
|
|
+ saveObj.push({field: 'jobContentText', value: defaultData.content});
|
|
|
+ // 刷新数据
|
|
|
+ refreshData = {'name': content};
|
|
|
break;
|
|
|
case "3":
|
|
|
// 添加到工作内容列
|
|
|
- saveObj = {field: 'jobContentText', text: content};
|
|
|
- // 更新到数据库
|
|
|
- pageCCOprObj.updateCharacterContent(findSet, {field: 'jobContent', updateArr: itemJob},
|
|
|
- saveObj, node);
|
|
|
+ saveObj.push({field: 'jobContentText', value: content});
|
|
|
+ // 还原名称以及特征
|
|
|
+ saveObj.push({field: 'itemCharacterText', value: defaultData.character});
|
|
|
+ saveObj.push({field: 'name', value: defaultData.name});
|
|
|
+ // 刷新数据
|
|
|
+ refreshData = {'content': content};
|
|
|
break;
|
|
|
case "4":
|
|
|
// 分别添加到对应列
|
|
|
- if (Object.keys(defaultContentInfo).length <= 0) {
|
|
|
+ if (Object.keys(defaultData).length <= 0) {
|
|
|
return;
|
|
|
}
|
|
|
- // 名称
|
|
|
- projectObj.project.Bills.updateField(node.source, 'name', defaultContentInfo.nameContent, true);
|
|
|
- projectObj.mainController.refreshTreeNode([node], false);
|
|
|
// 特征
|
|
|
- saveObj = {field: 'itemCharacterText', text: defaultContentInfo.characterContent};
|
|
|
- pageCCOprObj.updateCharacterContent(findSet, {field: 'itemCharacter', updateArr: itemCharacter},
|
|
|
- saveObj, node);
|
|
|
+ saveObj.push({field: 'itemCharacterText', value: defaultData.character});
|
|
|
// 内容
|
|
|
- saveObj = {field: 'jobContentText', text: defaultContentInfo.jobContent};
|
|
|
- pageCCOprObj.updateCharacterContent(findSet, {field: 'jobContent', updateArr: itemJob},
|
|
|
- saveObj, node);
|
|
|
+ saveObj.push({field: 'jobContentText', value: defaultData.content});
|
|
|
+ // 名称
|
|
|
+ saveObj.push({field: 'name', value: defaultData.name});
|
|
|
+ refreshData = {};
|
|
|
break;
|
|
|
}
|
|
|
+ // 更新到数据库
|
|
|
+ pageCCOprObj.updateBill(findSet, saveObj, function(response) {
|
|
|
+ self.refreshView(node, refreshData, defaultData);
|
|
|
+ });
|
|
|
|
|
|
},
|
|
|
/**
|
|
@@ -952,6 +956,9 @@ let pageCCOprObj = {
|
|
|
// 英文字母(大写)
|
|
|
serialNo = letter[serialNo - 1] !== undefined ? letter[serialNo - 1].toUpperCase() + '. ' : '';
|
|
|
break;
|
|
|
+ default:
|
|
|
+ serialNo = '';
|
|
|
+ break;
|
|
|
}
|
|
|
return serialNo;
|
|
|
},
|
|
@@ -974,13 +981,86 @@ let pageCCOprObj = {
|
|
|
continue;
|
|
|
}
|
|
|
const serialNo = this.formatSerialNumber(setting.serialType, count.toString());
|
|
|
- result.push(serialNo + tmp.data.code + ':' + tmp.data.name);
|
|
|
+ setting.childDisplayFormat === "1" ? result.push(tmp.data.code + ':' + tmp.data.name) : result.push(serialNo + tmp.data.name);
|
|
|
count++;
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 获取默认数据
|
|
|
+ *
|
|
|
+ * @param {Object} node - 节点数据
|
|
|
+ * @param {Object} setting - 设置
|
|
|
+ * @return {Object}
|
|
|
+ */
|
|
|
+ getDataBySetting: function(node, setting) {
|
|
|
+ let result = {};
|
|
|
+ try {
|
|
|
+ if (node.data === undefined) {
|
|
|
+ throw '数据错误';
|
|
|
+ }
|
|
|
+ const itemCharacter = node.data.itemCharacter;
|
|
|
+ const itemJob = node.data.jobContent;
|
|
|
+ if (itemCharacter === undefined || itemCharacter.length <= 0 || itemJob === undefined || itemJob.length <= 0) {
|
|
|
+ throw '内部数据错误';
|
|
|
+ }
|
|
|
+ // 默认名称
|
|
|
+ let nodeNameList = node.data.name.split("\r\n");
|
|
|
+ const nameContent = nodeNameList[0] !== undefined ? nodeNameList[0] : '';
|
|
|
+ result['name'] = nameContent;
|
|
|
|
|
|
+ // 特征
|
|
|
+ let characterArray = [];
|
|
|
+ let count = 1;
|
|
|
+ for (const tmp of itemCharacter) {
|
|
|
+ if (tmp.eigenvalue === undefined || tmp.eigenvalue.length <= 0 || !tmp.isChecked) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 获取选中的特征值
|
|
|
+ let selectedEigen = '';
|
|
|
+ for (const eigen of tmp.eigenvalue) {
|
|
|
+ if (eigen.isSelected) {
|
|
|
+ selectedEigen = eigen.value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 匹配设置的序号格式
|
|
|
+ const serialNo = this.formatSerialNumber(setting.serialType, count.toString());
|
|
|
+ let characterString = '';
|
|
|
+ // 特征生成方式
|
|
|
+ switch (setting.characterFormat) {
|
|
|
+ case '1':
|
|
|
+ // 特征值
|
|
|
+ characterString = serialNo + selectedEigen;
|
|
|
+ break;
|
|
|
+ case '2':
|
|
|
+ // 特征:特征值
|
|
|
+ characterString = serialNo + tmp.character + ': ' + selectedEigen;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ characterArray.push(characterString);
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ result['character'] = characterArray;
|
|
|
+
|
|
|
+ // 内容部分
|
|
|
+ let jobArray = [];
|
|
|
+ count = 1;
|
|
|
+ for (const tmp of itemJob) {
|
|
|
+ if (!tmp.isChecked) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 匹配设置的序号格式
|
|
|
+ const serialNo = this.formatSerialNumber(setting.serialType, count.toString());
|
|
|
+ jobArray.push(serialNo + tmp.content);
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ result['content'] = jobArray;
|
|
|
+ } catch (error) {
|
|
|
+ result = {};
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ },
|
|
|
/**
|
|
|
* 还原数据
|
|
|
*
|
|
@@ -1005,16 +1085,16 @@ let pageCCOprObj = {
|
|
|
projectObj.mainController.refreshTreeNode([node], false);
|
|
|
// 还原工作内容
|
|
|
pageCCOprObj.updateCharacterContent(baseData.findSet, {field: 'jobContent', updateArr: baseData.itemJob},
|
|
|
- {field: 'jobContentText', text: defaultContentInfo.jobContent}, node);
|
|
|
+ {field: 'jobContentText', text: contentOprObj.lastTextCache}, node);
|
|
|
break;
|
|
|
case "2":
|
|
|
// 添加到清单名称
|
|
|
// 还原特征
|
|
|
pageCCOprObj.updateCharacterContent(baseData.findSet, {field: 'itemCharacter', updateArr: baseData.itemCharacter},
|
|
|
- {field: 'itemCharacterText', text: defaultContentInfo.characterContent}, node);
|
|
|
+ {field: 'itemCharacterText', text: characterOprObj.lastTextCache}, node);
|
|
|
// 还原工作内容
|
|
|
pageCCOprObj.updateCharacterContent(baseData.findSet, {field: 'jobContent', updateArr: baseData.itemJob},
|
|
|
- {field: 'jobContentText', text: defaultContentInfo.jobContent}, node);
|
|
|
+ {field: 'jobContentText', text: contentOprObj.lastTextCache}, node);
|
|
|
break;
|
|
|
case "3":
|
|
|
// 添加到工作内容列
|
|
@@ -1023,7 +1103,7 @@ let pageCCOprObj = {
|
|
|
projectObj.mainController.refreshTreeNode([node], false);
|
|
|
// 还原特征
|
|
|
pageCCOprObj.updateCharacterContent(baseData.findSet, {field: 'itemCharacter', updateArr: baseData.itemCharacter},
|
|
|
- {field: 'jobContentText', text: defaultContentInfo.characterContent}, node);
|
|
|
+ {field: 'itemCharacterText', text: characterOprObj.lastTextCache}, node);
|
|
|
break;
|
|
|
}
|
|
|
},
|