|
@@ -191,6 +191,95 @@ var rationLibObj = {
|
|
|
SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
|
|
|
rationLibObj.setTagForHint(rationSheet, datas);
|
|
|
};
|
|
|
+
|
|
|
+ // 去掉第一个空格及空格前面的文本,去掉后面的“(编号:”及之后的文字和字符。取剩余中间的中文及符号
|
|
|
+ function getMidlleName(name) {
|
|
|
+ const codeReg = /[\((]编码[::]/;
|
|
|
+ const withCodeReg = /\s(.+)(?=[\((]编码[::])/;
|
|
|
+ const withoutCodeReg = /\s(.+)/;
|
|
|
+ if (!name) {
|
|
|
+ return name;
|
|
|
+ }
|
|
|
+ let tempName = name;;
|
|
|
+ if (codeReg.test(name)) {
|
|
|
+ const match = withCodeReg.exec(name);
|
|
|
+ if (match && match[1]) {
|
|
|
+ tempName = match[1];
|
|
|
+ }
|
|
|
+ } else if (withoutCodeReg.test(name)) {
|
|
|
+ const match = withoutCodeReg.exec(name);
|
|
|
+ if (match && match[1]) {
|
|
|
+ tempName = match[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tempName.trim();
|
|
|
+ }
|
|
|
+ // 新的处理:
|
|
|
+ /*
|
|
|
+ 1、从定额库提取定额名称,判断其是否含有空格:
|
|
|
+ 1.1、无空格,则不处理。
|
|
|
+
|
|
|
+ 1.2、有空格,则取第一个空格前的文本,赋值为a。
|
|
|
+
|
|
|
+ 2、取定额所属节点名称,去掉第一个空格及空格前面的文本,去掉后面的“(编号:”及之后的文字和字符,剩余中间的中文及符号,赋值为b。
|
|
|
+
|
|
|
+ 3、比较a、b是否相同:
|
|
|
+
|
|
|
+ 3.1、相同,则将定额名称显示为去除第一个空格及空格之前的文本f。
|
|
|
+
|
|
|
+ 3.2、不同,则取定额所属节点的父项,去掉第一个空格及空格前面的文本,去掉后面的“(编号:”及之后的文字和字符,剩余中间的中文及符号,赋值为c。
|
|
|
+
|
|
|
+ 比较a、c+b是否相同。
|
|
|
+
|
|
|
+ 3.2.1、相同,则将定额名称显示为去除第一个空格及空格之前的文本f。
|
|
|
+
|
|
|
+ 3.2.2、不同,则比较a、c是否相同。
|
|
|
+
|
|
|
+ 3.2.2.1、相同,则将定额名称显示为去除第一个空格及空格之前的文本f。
|
|
|
+
|
|
|
+ 3.2.2.2、不同,则定额名称显示原始名称。*/
|
|
|
+ //@param {String}sectionName(章节节点) {Array}datas(定额数据)
|
|
|
+ function simplifyName(sectionItem, datas) {
|
|
|
+ if (!sectionItem) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const sectionName = sectionItem.data.name;
|
|
|
+ if (!sectionName || !datas || datas.length === 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 定额所属章节节点,章节名称中间值
|
|
|
+ const midSectionName = getMidlleName(sectionName); // (b)
|
|
|
+ //简化匹配到的定额名称
|
|
|
+ const textBeforeFirstSpaceReg = /([^\s]+)\s/;
|
|
|
+ const textAfterFirstSpaceReg = /\s(.+)/;
|
|
|
+ for (let data of datas) {
|
|
|
+ if (!data.name) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ console.log(data.name);
|
|
|
+ const firstTextMatch = textBeforeFirstSpaceReg.exec(data.name);
|
|
|
+ const textBeforeFirstSpace = firstTextMatch && firstTextMatch[1]; // (a)
|
|
|
+ if (!textBeforeFirstSpace) { // 没有空格直接跳过
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const afterTextMatch = textAfterFirstSpaceReg.exec(data.name);
|
|
|
+ const textAfterFirstSpace = afterTextMatch && afterTextMatch[1]; // (f)
|
|
|
+ // /\s(.+)/
|
|
|
+ if (textBeforeFirstSpace === midSectionName) { // (a === b)
|
|
|
+ data.name = textAfterFirstSpace;
|
|
|
+ } else {
|
|
|
+ const parentSectionName = sectionItem.parent && sectionItem.parent.data.name;
|
|
|
+ if (!parentSectionName) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const midParentSectionName = getMidlleName(parentSectionName); // (c)
|
|
|
+ const combinedSectionName = `${midParentSectionName}${midSectionName}`; // (c + b)
|
|
|
+ if (textBeforeFirstSpace === combinedSectionName || textBeforeFirstSpace === midParentSectionName) { // (a === c + b) || (a === c)
|
|
|
+ data.name = textAfterFirstSpace;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//定额名称的处理:
|
|
|
/*
|
|
|
* 1、从定额库提取的名称,是否含有空格:
|
|
@@ -199,8 +288,7 @@ var rationLibObj = {
|
|
|
* 1.2.1、不同,则不处理。
|
|
|
* 1.2.2、相同,则将定额名称显示为去除第一个空格及空格之前的文本。
|
|
|
*/
|
|
|
- //@param {String}sectionName(章节名称) {Array}datas(定额数据)
|
|
|
- function simplifyName(sectionName, datas){
|
|
|
+ /* function simplifyName(sectionName, datas){
|
|
|
if (!sectionName || !datas || datas.length === 0) {
|
|
|
return;
|
|
|
}
|
|
@@ -233,12 +321,11 @@ var rationLibObj = {
|
|
|
data.name = nameArr.join(' ');
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ } */
|
|
|
if (sectionID) {
|
|
|
CommonAjax.post('/complementaryRation/api/getRationGljItemsBySection', {user_Id: userID, sectionId: sectionID, type: me.curLibType}, function (datas) {
|
|
|
- let chapterSheet = me.rationChapterSpread.getActiveSheet();
|
|
|
- let sectionName = chapterSheet.getText(chapterSheet.getActiveRowIndex(), chapterSheet.getActiveColumnIndex());
|
|
|
- simplifyName(sectionName, datas);
|
|
|
+ const sectionItem = rationLibObj.tree.findNode(sectionID);
|
|
|
+ simplifyName(sectionItem, datas);
|
|
|
showDatas(datas, rationLibObj.sectionRationsSetting);
|
|
|
if(me.doAfterLoadGetRations){
|
|
|
me.doAfterLoadGetRations(datas);
|