|
@@ -2548,6 +2548,46 @@ const billsGuidance = (function () {
|
|
|
|
|
|
/* 生成特征分类: 测试使用 */
|
|
|
function getItemCharacterData(nodes, prefix) {
|
|
|
+ const processNodes = nodes.filter(node => isProcessNode(node));
|
|
|
+ const classGroups = []; // 同层必填选项的数组(二维数组)
|
|
|
+ processNodes.forEach(processNode => {
|
|
|
+ const classItems = [];
|
|
|
+ const optionNodes = processNode.children.filter(node => isOptionNode(node));
|
|
|
+ optionNodes.forEach(optionNode => {
|
|
|
+ // const name = prefix ? `${prefix}@${optionNode.data.name}` : optionNode.data.name;
|
|
|
+ if (optionNode.parent && optionNode.parent.data.required && (!optionNode.children
|
|
|
+ || !optionNode.children.length
|
|
|
+ || (optionNode.children[0].data && optionNode.children[0].data.rationID)
|
|
|
+ || !optionNode.children.some(node => isProcessNode(node)))) {
|
|
|
+ classItems.push(optionNode.data.name);
|
|
|
+ } else {
|
|
|
+ classItems.push(...getItemCharacterData(optionNode.children, optionNode.parent && optionNode.parent.data.required ? optionNode.data.name : ''));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (classItems.length) {
|
|
|
+ classGroups.push(classItems);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 拼接上一文本
|
|
|
+ if (classGroups[0] && classGroups[0].length) {
|
|
|
+ classGroups[0] = classGroups[0].map(name => prefix ? `${prefix}@${name}` : name);
|
|
|
+ }
|
|
|
+ // 二维数组内容排列组合
|
|
|
+ while (classGroups.length > 1) {
|
|
|
+ const prevClassItems = classGroups[0];
|
|
|
+ const nextClassItems = classGroups[1];
|
|
|
+ const mergedClassItems = [];
|
|
|
+ for (let i = 0; i < prevClassItems.length; i++) {
|
|
|
+ for (let j = 0; j < nextClassItems.length; j++) {
|
|
|
+ mergedClassItems.push(`${prevClassItems[i]}@${nextClassItems[j]}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ classGroups.splice(0, 2, mergedClassItems);
|
|
|
+ }
|
|
|
+ return classGroups[0] ? [...new Set(classGroups[0])] : [];
|
|
|
+ }
|
|
|
+ /* function getItemCharacterData(nodes, prefix) {
|
|
|
+ debugger;
|
|
|
const processNodes = nodes.filter(node => isProcessNode(node) && node.data.required);
|
|
|
const classGroups = []; // 同层必填选项的数组(二维数组)
|
|
|
processNodes.forEach(processNode => {
|
|
@@ -2583,13 +2623,13 @@ const billsGuidance = (function () {
|
|
|
classGroups.splice(0, 2, mergedClassItems);
|
|
|
}
|
|
|
return classGroups[0] || [];
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
$('#generate-class').click(() => {
|
|
|
- /* if (bills.tree.selected && bills.tree.selected.guidance.tree) {
|
|
|
+ if (bills.tree.selected && bills.tree.selected.guidance.tree) {
|
|
|
const classData = getItemCharacterData(bills.tree.selected.guidance.tree.roots);
|
|
|
console.log(classData);
|
|
|
- } */
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
|