(data, dataPath, item, isAdd = false)
| 435 | }; |
| 436 | }, |
| 437 | dataBindPath(data, dataPath, item, isAdd = false) { |
| 438 | // 根据用户选择的映射字段 自定义映射数据 |
| 439 | const tempData = item.option.data |
| 440 | if (Object.prototype.toString.call(dataPath) === '[object Array]') { |
| 441 | dataPath.some(dp => { |
| 442 | const dpApikey = dp.apiKey && dp.apiKey.split('.'); // key的数组格式 |
| 443 | const indexUpIndex = dpApikey.indexOf('cbzIndex'); // 找 |
| 444 | let firstArray = []; // 获取第一个出现cbzIndex 的前面个key 并组合成字符串供下面判断是否是数组 如果是则参照api的长度为组件赋值 |
| 445 | for (let i = 0; i < indexUpIndex; i++) { |
| 446 | firstArray.push(dpApikey[i]); |
| 447 | } |
| 448 | firstArray = firstArray.join('.'); |
| 449 | if (Object.prototype.toString.call(tempData) === '[object Array]' && Object.prototype.toString.call(tempData[0]) === '[object Object]') { |
| 450 | const apiData = this.objectUrlEval(data, firstArray, false) |
| 451 | if (Object.prototype.toString.call(apiData) === '[object Array]') { |
| 452 | apiData.some((opt, index) => { |
| 453 | if (!tempData[index]) { |
| 454 | tempData.push(JSON.parse(JSON.stringify(tempData[0]))) |
| 455 | } |
| 456 | tempData[index][dp.systemKey] = this.objectUrlEval(data, this.replaceStr(dp.apiKey, 'cbzIndex', index), false) |
| 457 | // this.$set( |
| 458 | // tempData[index], |
| 459 | // dp.systemKey, |
| 460 | // this.objectUrlEval(data, this.replaceStr(dp.apiKey, 'cbzIndex', index), false), |
| 461 | // ); |
| 462 | }); |
| 463 | tempData.length = apiData.length |
| 464 | // this.$set(item.option, 'data', tempData) // 去掉api返回数据没有的对象 |
| 465 | } else { |
| 466 | tempData.map((opt, index) => { |
| 467 | this.$set( |
| 468 | opt, |
| 469 | dp.systemKey, |
| 470 | this.objectUrlEval(data, this.replaceStr(dp.apiKey, 'cbzIndex', index), false), |
| 471 | ); |
| 472 | }); |
| 473 | } |
| 474 | } else if (Object.prototype.toString.call(data.data) === '[object Array]') { |
| 475 | // 当api的数据不是数组,但是给的是数组 |
| 476 | this.objectUrlEval( |
| 477 | item, |
| 478 | dp.systemKey, |
| 479 | true, |
| 480 | this.objectUrlEval(data, this.replaceStr(dp.apiKey, 'cbzIndex', 0), false), |
| 481 | ); |
| 482 | } else { |
| 483 | // 当需要字符串 则取第一项 |
| 484 | this.objectUrlEval( |
| 485 | item, |
| 486 | dp.systemKey, |
| 487 | true, |
| 488 | this.objectUrlEval(data, this.replaceStr(dp.apiKey, 'cbzIndex', 0), false), |
| 489 | ); |
| 490 | } |
| 491 | }); |
| 492 | } |
| 493 | }, |
| 494 | getTime(type, hhmmss) { |
nothing calls this directly
no outgoing calls
no test coverage detected