Commit 465531bd by 高源

优化

parent ddfd24b9
...@@ -64,7 +64,7 @@ function table () { ...@@ -64,7 +64,7 @@ function table () {
this.getData = function () { this.getData = function () {
let rtns = [];//定义返回值 let rtns = [];//定义返回值
if (!_isVerified) return null;//如果还没通过验证不返回数据 if (!_isVerified) return null;//如果还没通过验证不返回数据
let rowIndex = 0; let rowIndex = 1;
while (true) { while (true) {
let result = {} let result = {}
this.cells.forEach(cell => cell.getData(result, rowIndex)); this.cells.forEach(cell => cell.getData(result, rowIndex));
...@@ -123,13 +123,13 @@ function cell (xpath, name = "", type = "", title = "") { ...@@ -123,13 +123,13 @@ function cell (xpath, name = "", type = "", title = "") {
*/ */
this.isExist = function () { this.isExist = function () {
let existCount = 0; let existCount = 0;
let _tableXpathArrays = [..._tableXpathArray]; //深拷贝,值修改不影响原数组 // let _tableXpathArrays = [..._tableXpathArray]; //深拷贝,值修改不影响原数组
let _relativeXpathArrays = [..._relativeXpathArray];//深拷贝,值修改不影响原数组 // let _relativeXpathArrays = [..._relativeXpathArray];//深拷贝,值修改不影响原数组
_tableXpathArrays = _tableXpathArray.join('/') let _tableXpathArrays = _tableXpathArray.join('/')
_relativeXpathArrays = _relativeXpathArray.join('/') let _relativeXpathArrays = _relativeXpathArray.join('/')
for (let i = 0; i < 3; i++) { for (let i = 1; i < 3; i++) {
// 验证是否能找到元素 // 验证是否能找到元素
let _xpath = _tableXpathArrays + '[' + (i + 1) + ']' + '/' + _relativeXpathArrays; let _xpath = _tableXpathArrays + '[' + i + ']' + '/' + _relativeXpathArrays;
let result = document.evaluate(_xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); let result = document.evaluate(_xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!!result.singleNodeValue) { if (!!result.singleNodeValue) {
existCount++; existCount++;
...@@ -148,7 +148,7 @@ function cell (xpath, name = "", type = "", title = "") { ...@@ -148,7 +148,7 @@ function cell (xpath, name = "", type = "", title = "") {
* @param {int} index 索引号 * @param {int} index 索引号
*/ */
this.getData = function (result, index) { this.getData = function (result, index) {
let realXpath = this.tableXpath + "[" + (index + 1) + "]" + '/' + this.relativeXpath; let realXpath = this.tableXpath + "[" + index + "]" + '/' + this.relativeXpath;
let results = document.evaluate(realXpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); let results = document.evaluate(realXpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!!results.singleNodeValue) { if (!!results.singleNodeValue) {
// 后续处理type类型事件 // 后续处理type类型事件
......
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