Commit 2e4c4efe by 施晓雨

更新逻辑错误代码

parent 92f8d5ac
......@@ -83,16 +83,12 @@ function table () {
if (!_isVerified) return null;//如果还没通过验证不返回数据
let rowIndex = 1;
while (true) {
let cellResult = {}
let result = {}; // 为每个 cell 创建一个新的结果对象
this.cells.forEach(cell => {
let result = {}; // 为每个 cell 创建一个新的结果对象
cell.getData(result, rowIndex); // 调用 getData 方法
if (Object.keys(result).length > 0) {
rtns.push(result); // 如果 result 对象非空,则添加到 rtn 数组
cellResult = result
}
});
if (Object.keys(cellResult).length === 0) break;//不断的根据rowIndex取值,直到取不到值就退出,需要注意如果第0行是表头,也不一定可以取到值
if (Object.keys(result).length === 0) break;//不断的根据rowIndex取值,直到取不到值就退出,需要注意如果第0行是表头,也不一定可以取到值
rtns.push(result);
rowIndex++;
}
return rtns;
......@@ -146,14 +142,10 @@ function cell (xpath, name = "", type = "", title = "") {
*/
this.isExist = function () {
let existCount = 0;
// let _tableXpathArrays = [..._tableXpathArray]; //深拷贝,值修改不影响原数组
// let _relativeXpathArrays = [..._relativeXpathArray];//深拷贝,值修改不影响原数组
let _tableXpathArrays = _tableXpathArray.join('/')
let _relativeXpathArrays = _relativeXpathArray.join('/')
for (let i = 1; i < 3; i++) {
// 验证是否能找到元素
let _xpath = _tableXpathArrays + '[' + i + ']' + '/' + _relativeXpathArrays;
let result = document.evaluate(_xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
let cellXpath = _tableXpathArray.join('/') + '[' + i + ']' + '/' + _relativeXpathArray.join('/');
let result = document.evaluate(cellXpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!!result.singleNodeValue) {
existCount++;
}
......@@ -171,12 +163,10 @@ function cell (xpath, name = "", type = "", title = "") {
* @param {int} index 索引号
*/
this.getData = function (result, index) {
let realXpath = this.tableXpath + "[" + index + "]" + '/' + this.relativeXpath;
let results = document.evaluate(realXpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
let cellXpath = this.tableXpath + "[" + index + "]" + '/' + this.relativeXpath;
let results = document.evaluate(cellXpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!!results.singleNodeValue) {
result[this.name] = '动态绑定属性值'
result['xpath'] = results.singleNodeValue.innerText
return result
result[this.name] = results.singleNodeValue.innerText;
}
};
return this;//返回当前对象
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment