@zscreate/form-component 1.1.40 → 1.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form-component.css +93 -59
- package/dist/form-component.umd-report.html +2 -2
- package/dist/form-component.umd.js +1182 -36
- package/package.json +3 -2
|
@@ -62875,7 +62875,7 @@ module.exports = /******/function (modules) {
|
|
|
62875
62875
|
/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6903);
|
|
62876
62876
|
/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
62877
62877
|
/* harmony import */ var _util_mathUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(38);
|
|
62878
|
-
/* harmony import */ var
|
|
62878
|
+
/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6955);
|
|
62879
62879
|
/* harmony import */ var _layoutItem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7102);
|
|
62880
62880
|
/* harmony import */ var _components_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1033);
|
|
62881
62881
|
/* harmony import */ var pubsub_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9616);
|
|
@@ -62883,6 +62883,7 @@ module.exports = /******/function (modules) {
|
|
|
62883
62883
|
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7203);
|
|
62884
62884
|
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_5__);
|
|
62885
62885
|
/* harmony import */ var _components_MessageBox_confirmBox_vue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5927);
|
|
62886
|
+
/* harmony import */ var _form_modules_common_tableItem_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2780);
|
|
62886
62887
|
|
|
62887
62888
|
//
|
|
62888
62889
|
//
|
|
@@ -63245,6 +63246,18 @@ module.exports = /******/function (modules) {
|
|
|
63245
63246
|
//
|
|
63246
63247
|
//
|
|
63247
63248
|
//
|
|
63249
|
+
//
|
|
63250
|
+
//
|
|
63251
|
+
//
|
|
63252
|
+
//
|
|
63253
|
+
//
|
|
63254
|
+
//
|
|
63255
|
+
//
|
|
63256
|
+
//
|
|
63257
|
+
//
|
|
63258
|
+
//
|
|
63259
|
+
//
|
|
63260
|
+
|
|
63248
63261
|
|
|
63249
63262
|
|
|
63250
63263
|
|
|
@@ -63255,6 +63268,11 @@ module.exports = /******/function (modules) {
|
|
|
63255
63268
|
|
|
63256
63269
|
/* harmony default export */ __webpack_exports__.Z = ({
|
|
63257
63270
|
name: "formLayout",
|
|
63271
|
+
computed: {
|
|
63272
|
+
tableItem() {
|
|
63273
|
+
return _form_modules_common_tableItem_vue__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z;
|
|
63274
|
+
}
|
|
63275
|
+
},
|
|
63258
63276
|
data() {
|
|
63259
63277
|
return {
|
|
63260
63278
|
defauList: ["loginUserName", "currentDate"],
|
|
@@ -63262,9 +63280,9 @@ module.exports = /******/function (modules) {
|
|
|
63262
63280
|
//表单分页list 如果不需要分页 数组length为0
|
|
63263
63281
|
formNameHeight: 40,
|
|
63264
63282
|
//标题高度
|
|
63265
|
-
A4Width: (0,
|
|
63283
|
+
A4Width: (0,_util_util__WEBPACK_IMPORTED_MODULE_8__/* .mmToPx */ .Zt)(210),
|
|
63266
63284
|
//A4纸 px宽度
|
|
63267
|
-
A4Height: (0,
|
|
63285
|
+
A4Height: (0,_util_util__WEBPACK_IMPORTED_MODULE_8__/* .mmToPx */ .Zt)(297),
|
|
63268
63286
|
//A4纸 px高度
|
|
63269
63287
|
contentStyle: {
|
|
63270
63288
|
width: "200px",
|
|
@@ -63422,7 +63440,10 @@ module.exports = /******/function (modules) {
|
|
|
63422
63440
|
},
|
|
63423
63441
|
//添加子表单里面的row
|
|
63424
63442
|
addToTableData(data, model, addModel = undefined, clickByUser = false) {
|
|
63425
|
-
let dataTemp =
|
|
63443
|
+
let dataTemp = data;
|
|
63444
|
+
if (!data._clone) {
|
|
63445
|
+
dataTemp = JSON.parse(JSON.stringify(data));
|
|
63446
|
+
}
|
|
63426
63447
|
this.tableIndex[model] === undefined ? this.$set(this.tableIndex, model, 0) : null;
|
|
63427
63448
|
dataTemp.index = this.tableIndex[model];
|
|
63428
63449
|
this.tableIndex[model]++;
|
|
@@ -63586,18 +63607,26 @@ module.exports = /******/function (modules) {
|
|
|
63586
63607
|
},
|
|
63587
63608
|
tableInitByModel(model) {
|
|
63588
63609
|
if (this.models[model] && this.models[model] instanceof Array && this.models[model].length > 0) {
|
|
63610
|
+
if (this.tableData[model] === undefined) {
|
|
63611
|
+
this.$set(this.tableData, model, []);
|
|
63612
|
+
}
|
|
63589
63613
|
// console.log('--',this.tableModel[model], model)
|
|
63590
63614
|
setTimeout(async () => {
|
|
63591
63615
|
this.$emit("tableLoading", true);
|
|
63592
63616
|
this.formLoading = true;
|
|
63593
63617
|
this.tableLoading = true;
|
|
63618
|
+
let dataTemp = JSON.parse(JSON.stringify(this.tableModel[model]));
|
|
63619
|
+
dataTemp._clone = true;
|
|
63594
63620
|
for (let i = 0; i < this.models[model].length; i++) {
|
|
63595
63621
|
this.originIndex++;
|
|
63596
|
-
|
|
63597
|
-
|
|
63622
|
+
if (i < 20) {
|
|
63623
|
+
await this.timeout(0);
|
|
63624
|
+
}
|
|
63625
|
+
this.addToTableData(dataTemp, model);
|
|
63598
63626
|
}
|
|
63599
63627
|
this.tableLoading = false;
|
|
63600
63628
|
this.formLoading = false;
|
|
63629
|
+
console.log("tableLoading false");
|
|
63601
63630
|
this.$emit("tableLoading", false);
|
|
63602
63631
|
}, 0);
|
|
63603
63632
|
}
|
|
@@ -63618,7 +63647,7 @@ module.exports = /******/function (modules) {
|
|
|
63618
63647
|
// values里面存在当前字段的值
|
|
63619
63648
|
if (this.value && Object.keys(this.value).indexOf(widget.model) >= 0) {
|
|
63620
63649
|
if (![undefined, null].includes(this.value[widget.model])) {
|
|
63621
|
-
this.models[widget.model] = (0,
|
|
63650
|
+
this.models[widget.model] = (0,_util_util__WEBPACK_IMPORTED_MODULE_8__/* .cloneObj */ .Cl)(this.value[widget.model]);
|
|
63622
63651
|
} else {
|
|
63623
63652
|
// 如果value数据是null 或者 undefined 则需要特殊处理(用于处理数据不完整)
|
|
63624
63653
|
this.models[widget.model] = ["imgupload", "deptSelector", "userSelector", "userSelectorByRole", "relateSub"].includes(widget.type) ? [] : "";
|
|
@@ -63638,7 +63667,7 @@ module.exports = /******/function (modules) {
|
|
|
63638
63667
|
|
|
63639
63668
|
// 是否为无效值
|
|
63640
63669
|
let is_invalidation = [undefined, null].includes(widget.options.defaultValue);
|
|
63641
|
-
this.models[widget.model] = this.models[widget.model] ? this.models[widget.model] : is_invalidation ? "" : (0,
|
|
63670
|
+
this.models[widget.model] = this.models[widget.model] ? this.models[widget.model] : is_invalidation ? "" : (0,_util_util__WEBPACK_IMPORTED_MODULE_8__/* .cloneObj */ .Cl)(widget.options.defaultValue);
|
|
63642
63671
|
}
|
|
63643
63672
|
});
|
|
63644
63673
|
}
|
|
@@ -63657,13 +63686,13 @@ module.exports = /******/function (modules) {
|
|
|
63657
63686
|
}
|
|
63658
63687
|
return true;
|
|
63659
63688
|
case "checkbox":
|
|
63660
|
-
this.models[widget.model] = typeof widget.options.defaultValue === "string" ? [] : (0,
|
|
63689
|
+
this.models[widget.model] = typeof widget.options.defaultValue === "string" ? [] : (0,_util_util__WEBPACK_IMPORTED_MODULE_8__/* .cloneObj */ .Cl)(widget.options.defaultValue);
|
|
63661
63690
|
return true;
|
|
63662
63691
|
case "select":
|
|
63663
63692
|
this.models[widget.model] = widget.options.multiple ? [] : "";
|
|
63664
63693
|
return true;
|
|
63665
63694
|
case "table":
|
|
63666
|
-
this.models[widget.model] = (0,
|
|
63695
|
+
this.models[widget.model] = (0,_util_util__WEBPACK_IMPORTED_MODULE_8__/* .cloneObj */ .Cl)(widget.options.defaultValue);
|
|
63667
63696
|
this.generateTableData(widget);
|
|
63668
63697
|
return true;
|
|
63669
63698
|
default:
|
|
@@ -106592,6 +106621,171 @@ var component = (0,componentNormalizer/* default */.Z)(
|
|
|
106592
106621
|
|
|
106593
106622
|
/***/ }),
|
|
106594
106623
|
|
|
106624
|
+
/***/ 2780:
|
|
106625
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
106626
|
+
|
|
106627
|
+
"use strict";
|
|
106628
|
+
|
|
106629
|
+
// EXPORTS
|
|
106630
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
106631
|
+
Z: function() { return /* binding */ tableItem; }
|
|
106632
|
+
});
|
|
106633
|
+
|
|
106634
|
+
;// CONCATENATED MODULE: ./node_modules/_vue-loader@15.10.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.10.1@vue-loader/lib/index.js??vue-loader-options!./src/form/modules/common/tableItem.vue?vue&type=template&id=b1812dae&scoped=true&
|
|
106635
|
+
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"sub-table-col sub-table-col-no-border"},[_vm._l((_vm.source.columns),function(tableItem,talbeIndex){return _c('span',{directives:[{name:"show",rawName:"v-show",value:(tableItem.type !== 'hidden'),expression:"tableItem.type !== 'hidden'"}],key:_vm.index + '_' + talbeIndex,staticClass:"sub-table-item"},[(['input', 'textarea'].includes(tableItem.type) && !_vm.editArr[talbeIndex] && !tableItem.tableColCanEdit )?_c('div',{style:(("color: #000; border-right: 1px solid #333; border-bottom: 1px solid #333; line-height: normal; padding: 0 15px; line-break: anywhere; overflow: hidden; display: flex; align-items: center; height: " + (_vm.widget.options.rowsHeight ? _vm.widget.options.rowsHeight + 'px' : 'initial'))),on:{"dblclick":function($event){return _vm.tableColumnsDBClick(talbeIndex, tableItem, _vm.source.model + '_' + _vm.index + '_' + tableItem.model)}}},[_c('span',[_vm._v(_vm._s(_vm.models[_vm.source.model][_vm.index][tableItem.model]))])]):_c('layout-item',{directives:[{name:"show",rawName:"v-show",value:(tableItem.options.canView),expression:"tableItem.options.canView"}],key:_vm.source.model,attrs:{"tableKey":_vm.source.model,"rules":_vm.rules,"tableIndex":_vm.index,"widget":tableItem,"models":_vm.models,"showLabel":false},on:{"update:rules":function($event){_vm.rules=$event}}})],1)}),(!_vm.widget.options.disabled && !_vm.widget.options.hiddenOperateBtn)?_c('span',{staticClass:"last-one",style:({ borderColor: _vm.data.config.borderColor })},[_c('a-button',{attrs:{"size":"small","type":"primary"},on:{"click":function($event){return _vm.handleDeleteRow(_vm.index, _vm.widget.model)}}},[_vm._v("删除行")])],1):_vm._e()],2)}
|
|
106636
|
+
var staticRenderFns = []
|
|
106637
|
+
|
|
106638
|
+
|
|
106639
|
+
;// CONCATENATED MODULE: ./node_modules/_thread-loader@3.0.4@thread-loader/dist/cjs.js!./node_modules/_babel-loader@8.3.0@babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/_vue-loader@15.10.1@vue-loader/lib/index.js??vue-loader-options!./src/form/modules/common/tableItem.vue?vue&type=script&lang=js&
|
|
106640
|
+
//
|
|
106641
|
+
//
|
|
106642
|
+
//
|
|
106643
|
+
//
|
|
106644
|
+
//
|
|
106645
|
+
//
|
|
106646
|
+
//
|
|
106647
|
+
//
|
|
106648
|
+
//
|
|
106649
|
+
//
|
|
106650
|
+
//
|
|
106651
|
+
//
|
|
106652
|
+
//
|
|
106653
|
+
//
|
|
106654
|
+
//
|
|
106655
|
+
//
|
|
106656
|
+
//
|
|
106657
|
+
//
|
|
106658
|
+
//
|
|
106659
|
+
//
|
|
106660
|
+
//
|
|
106661
|
+
//
|
|
106662
|
+
//
|
|
106663
|
+
//
|
|
106664
|
+
//
|
|
106665
|
+
//
|
|
106666
|
+
//
|
|
106667
|
+
//
|
|
106668
|
+
//
|
|
106669
|
+
//
|
|
106670
|
+
//
|
|
106671
|
+
//
|
|
106672
|
+
//
|
|
106673
|
+
//
|
|
106674
|
+
//
|
|
106675
|
+
//
|
|
106676
|
+
//
|
|
106677
|
+
//
|
|
106678
|
+
//
|
|
106679
|
+
//
|
|
106680
|
+
//
|
|
106681
|
+
//
|
|
106682
|
+
//
|
|
106683
|
+
|
|
106684
|
+
/* harmony default export */ var tableItemvue_type_script_lang_js_ = ({
|
|
106685
|
+
props: {
|
|
106686
|
+
widget: {
|
|
106687
|
+
type: Object,
|
|
106688
|
+
default: () => {
|
|
106689
|
+
return {};
|
|
106690
|
+
}
|
|
106691
|
+
},
|
|
106692
|
+
source: {
|
|
106693
|
+
type: Object,
|
|
106694
|
+
default: () => {
|
|
106695
|
+
return {};
|
|
106696
|
+
}
|
|
106697
|
+
},
|
|
106698
|
+
index: {
|
|
106699
|
+
type: Number
|
|
106700
|
+
},
|
|
106701
|
+
rules: {
|
|
106702
|
+
type: Object,
|
|
106703
|
+
default: () => {
|
|
106704
|
+
return {};
|
|
106705
|
+
}
|
|
106706
|
+
},
|
|
106707
|
+
models: {
|
|
106708
|
+
type: Object,
|
|
106709
|
+
default: () => {
|
|
106710
|
+
return {};
|
|
106711
|
+
}
|
|
106712
|
+
},
|
|
106713
|
+
data: {
|
|
106714
|
+
type: Object,
|
|
106715
|
+
default: () => {
|
|
106716
|
+
return {};
|
|
106717
|
+
}
|
|
106718
|
+
},
|
|
106719
|
+
handleDeleteRow: {
|
|
106720
|
+
type: Function,
|
|
106721
|
+
default: () => {
|
|
106722
|
+
return () => {};
|
|
106723
|
+
}
|
|
106724
|
+
}
|
|
106725
|
+
},
|
|
106726
|
+
inject: {
|
|
106727
|
+
isCorrectAudit: {
|
|
106728
|
+
from: "isCorrectAudit",
|
|
106729
|
+
// 来源
|
|
106730
|
+
default: () => () => false // 默认值
|
|
106731
|
+
},
|
|
106732
|
+
|
|
106733
|
+
isCorrect: {
|
|
106734
|
+
// 健名
|
|
106735
|
+
from: "isCorrect",
|
|
106736
|
+
// 来源
|
|
106737
|
+
default: false // 默认值
|
|
106738
|
+
}
|
|
106739
|
+
},
|
|
106740
|
+
|
|
106741
|
+
data() {
|
|
106742
|
+
return {
|
|
106743
|
+
isEdit: false,
|
|
106744
|
+
editArr: []
|
|
106745
|
+
};
|
|
106746
|
+
},
|
|
106747
|
+
created() {
|
|
106748
|
+
this.editArr.length = this.source.columns.length;
|
|
106749
|
+
},
|
|
106750
|
+
methods: {
|
|
106751
|
+
tableColumnsDBClick(talbeIndex, widget) {
|
|
106752
|
+
this.$set(this.editArr, talbeIndex, true);
|
|
106753
|
+
}
|
|
106754
|
+
}
|
|
106755
|
+
});
|
|
106756
|
+
;// CONCATENATED MODULE: ./src/form/modules/common/tableItem.vue?vue&type=script&lang=js&
|
|
106757
|
+
/* harmony default export */ var common_tableItemvue_type_script_lang_js_ = (tableItemvue_type_script_lang_js_);
|
|
106758
|
+
;// CONCATENATED MODULE: ./node_modules/_mini-css-extract-plugin@2.7.6@mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/_css-loader@6.8.1@css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/_vue-loader@15.10.1@vue-loader/lib/loaders/stylePostLoader.js!./node_modules/_postcss-loader@6.2.1@postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/_less-loader@5.0.0@less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/_vue-loader@15.10.1@vue-loader/lib/index.js??vue-loader-options!./src/form/modules/common/tableItem.vue?vue&type=style&index=0&id=b1812dae&prod&scoped=true&lang=less&
|
|
106759
|
+
// extracted by mini-css-extract-plugin
|
|
106760
|
+
|
|
106761
|
+
;// CONCATENATED MODULE: ./src/form/modules/common/tableItem.vue?vue&type=style&index=0&id=b1812dae&prod&scoped=true&lang=less&
|
|
106762
|
+
|
|
106763
|
+
// EXTERNAL MODULE: ./node_modules/_vue-loader@15.10.1@vue-loader/lib/runtime/componentNormalizer.js
|
|
106764
|
+
var componentNormalizer = __webpack_require__(8412);
|
|
106765
|
+
;// CONCATENATED MODULE: ./src/form/modules/common/tableItem.vue
|
|
106766
|
+
|
|
106767
|
+
|
|
106768
|
+
|
|
106769
|
+
;
|
|
106770
|
+
|
|
106771
|
+
|
|
106772
|
+
/* normalize component */
|
|
106773
|
+
|
|
106774
|
+
var component = (0,componentNormalizer/* default */.Z)(
|
|
106775
|
+
common_tableItemvue_type_script_lang_js_,
|
|
106776
|
+
render,
|
|
106777
|
+
staticRenderFns,
|
|
106778
|
+
false,
|
|
106779
|
+
null,
|
|
106780
|
+
"b1812dae",
|
|
106781
|
+
null
|
|
106782
|
+
|
|
106783
|
+
)
|
|
106784
|
+
|
|
106785
|
+
/* harmony default export */ var tableItem = (component.exports);
|
|
106786
|
+
|
|
106787
|
+
/***/ }),
|
|
106788
|
+
|
|
106595
106789
|
/***/ 3723:
|
|
106596
106790
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
106597
106791
|
|
|
@@ -107500,7 +107694,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__7203__;
|
|
|
107500
107694
|
/***/ (function(module) {
|
|
107501
107695
|
|
|
107502
107696
|
"use strict";
|
|
107503
|
-
module.exports = {"i8":"1.1.
|
|
107697
|
+
module.exports = {"i8":"1.1.41"};
|
|
107504
107698
|
|
|
107505
107699
|
/***/ })
|
|
107506
107700
|
|
|
@@ -107633,29 +107827,32 @@ if (typeof window !== 'undefined') {
|
|
|
107633
107827
|
// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
|
|
107634
107828
|
var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__(7203);
|
|
107635
107829
|
var external_commonjs_vue_commonjs2_vue_root_Vue_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_vue_commonjs2_vue_root_Vue_);
|
|
107636
|
-
;// CONCATENATED MODULE: ./node_modules/_vue-loader@15.10.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.10.1@vue-loader/lib/index.js??vue-loader-options!./src/form/modules/layout/layoutForPaper.vue?vue&type=template&id=
|
|
107830
|
+
;// CONCATENATED MODULE: ./node_modules/_vue-loader@15.10.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.10.1@vue-loader/lib/index.js??vue-loader-options!./src/form/modules/layout/layoutForPaper.vue?vue&type=template&id=57dc7d67&scoped=true&
|
|
107637
107831
|
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('a-spin',{staticClass:"layout layout-input-all-setting",class:{ 'no-border': !_vm.data.config.border, 'save-pdf': _vm.showLine, 'ant-form-noBorder': _vm.data.config.componentsNoBorder },attrs:{"spinning":_vm.formLoading,"tip":_vm.formLoadingTip}},[_c('a-form-model',{ref:"Form",attrs:{"hideRequiredMark":true,"model":_vm.models,"rules":_vm.rules,"wrapper-col":{}},on:{"update:rules":function($event){_vm.rules=$event}}},_vm._l((_vm.widgetList),function(list,listindex){return _c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.widgetList[0].length > 0),expression:"widgetList[0].length > 0"}],key:listindex,staticClass:"paper",style:(_vm.contentStyle)},[(listindex == 0)?_vm._t("default"):_vm._e(),(listindex == 0)?_c('div',{staticClass:"form-title",style:({ height: _vm.formNameHeight })},[_vm._v(" "+_vm._s(_vm.data.config.formName)+" ")]):_vm._e(),(_vm.data.config.pageHeader && listindex === 0)?_c('div',{style:(_vm.data.config.headerHeight),domProps:{"innerHTML":_vm._s(_vm.data.config.pageHeader)}}):_vm._e(),_c('div',{staticClass:"page-border",style:({ borderColor: _vm.data.config.borderColor })},[_vm._l((list),function(widget,index){return [(widget.type == 'table')?[(
|
|
107638
|
-
|
|
107639
|
-
|
|
107640
|
-
|
|
107641
|
-
|
|
107642
|
-
|
|
107643
|
-
|
|
107644
|
-
|
|
107645
|
-
|
|
107646
|
-
|
|
107647
|
-
|
|
107648
|
-
|
|
107649
|
-
|
|
107650
|
-
|
|
107651
|
-
|
|
107652
|
-
|
|
107653
|
-
|
|
107654
|
-
|
|
107655
|
-
|
|
107656
|
-
|
|
107657
|
-
|
|
107658
|
-
|
|
107832
|
+
widget.options.layoutModel === 'auto' ||
|
|
107833
|
+
widget.options.layoutModel === undefined
|
|
107834
|
+
)?_c('a-spin',{directives:[{name:"show",rawName:"v-show",value:(widget.options.canView),expression:"widget.options.canView"}],key:index,staticClass:"row-item",class:[widget.options.inline == true ? 'row-table' : ''],style:({ borderColor: _vm.data.config.borderColor }),attrs:{"spinning":_vm.tableLoading && !_vm.formLoading,"tip":"数据加载中"}},[(widget.options.inline)?_c('div',{staticClass:"table-left",style:({
|
|
107835
|
+
width: widget.options.labelWidth + 'px',
|
|
107836
|
+
borderColor: _vm.data.config.borderColor,
|
|
107837
|
+
backgroundColor: _vm.data.config.bgc,
|
|
107838
|
+
color: _vm.data.config.color,
|
|
107839
|
+
})},[_c('p',{staticStyle:{"position":"relative","margin-bottom":"0","padding-bottom":"0"}},[(widget.options.enableImport && !widget.options.disabled)?_c('span',{staticStyle:{"position":"absolute","display":"flex","height":"100%","align-items":"center"}},[_c('a-upload',{staticStyle:{"float":"left","margin":"0 5px"},attrs:{"action":_vm.actionUrl + "?formId=" + (_vm.data.formId) + "&tableKey=" + (widget.model),"headers":_vm.headers,"showUploadList":false},on:{"change":function (params) { return _vm.handleChange(widget, params); }}},[_c('a-button',[_c('a-icon',{attrs:{"type":"upload"}}),_vm._v("上传")],1)],1),_c('confirm-box',{staticStyle:{"float":"left","margin":"0 5px"},attrs:{"content":"注意:使用Excel模板导入仅支持文本、日期、下拉等内容,无法支持复杂的组件以及数据校验等,请确认!"},on:{"confirm":function($event){return _vm.downloadTableTemplate(widget)}}},[_c('a-button',[_vm._v("下载模板")])],1)],1):_vm._e(),_c('span',[_vm._v(_vm._s(widget.name))])])]):_c('div',{staticClass:"table-content",style:({ borderColor: _vm.data.config.borderColor })},[_c('p',{staticStyle:{"position":"relative","margin-bottom":"0"}},[(widget.options.enableImport && !widget.options.disabled)?_c('span',{staticStyle:{"position":"absolute","display":"flex","height":"100%","align-items":"center"}},[_c('a-upload',{staticStyle:{"float":"left","margin":"0 5px"},attrs:{"action":_vm.actionUrl + "?formId=" + (_vm.data.formId) + "&tableKey=" + (widget.model),"headers":_vm.headers,"showUploadList":false},on:{"change":function (params) { return _vm.handleChange(widget, params); }}},[_c('a-button',[_c('a-icon',{attrs:{"type":"upload"}}),_vm._v("上传")],1)],1),_c('confirm-box',{staticStyle:{"float":"left","margin":"0 5px"},attrs:{"content":"注意:使用Excel模板导入仅支持文本、日期、下拉等内容,无法支持复杂的组件以及数据校验等,请确认!"},on:{"confirm":function($event){return _vm.downloadTableTemplate(widget)}}},[_c('a-button',[_vm._v("下载模板")])],1)],1):_vm._e(),_c('span',[_vm._v(_vm._s(widget.name))])])]),_c('div',{staticClass:"table-right"},[_c('div',{staticClass:"sub-table-col sub-table-col-no-border"},[_vm._l((widget.columns),function(children,index){return _c('span',{directives:[{name:"show",rawName:"v-show",value:(children.type !== 'hidden'),expression:"children.type !== 'hidden'"}],key:index,class:[
|
|
107840
|
+
_vm.data.config.align,
|
|
107841
|
+
_vm.data.config.validate === true && children.options.required === true
|
|
107842
|
+
? 'is_required'
|
|
107843
|
+
: 'no_required' ],staticStyle:{"border-right":"1px solid #333","border-bottom":"1px solid #333"},style:({ borderColor: _vm.data.config.borderColor })},[_vm._v(_vm._s(children.name))])}),(!widget.options.hiddenOperateBtn && widget.columns.length > 0 && !widget.options.disabled)?_c('span',{staticClass:"last-one",style:({ borderColor: _vm.data.config.borderColor })},[_c('a-button',{attrs:{"size":"small","type":"primary"},on:{"click":function($event){return _vm.addToTableData(widget, widget.model, 'addModel', true)}}},[_vm._v("添加行")])],1):_vm._e()],2),(Array.isArray(_vm.tableData[widget.model]))?[_c('virtual-list',{staticClass:"virtual-list",attrs:{"keeps":50,"page-mode":"","data-key":function (ref) {
|
|
107844
|
+
var model = ref.model;
|
|
107845
|
+
var idx = ref.index;
|
|
107846
|
+
return model + idx},"data-sources":_vm.tableData[widget.model],"data-component":_vm.tableItem,"extra-props":{ widget: widget, models: _vm.models, data: _vm.data, rules: _vm.rules, handleDeleteRow: _vm.handleDeleteRow}}})]:_vm._e(),(
|
|
107847
|
+
widget.options.computingSub.length > 0 &&
|
|
107848
|
+
widget.options.computingMethod.length > 0 &&
|
|
107849
|
+
_vm.tableData &&
|
|
107850
|
+
_vm.tableData[widget.model] &&
|
|
107851
|
+
_vm.tableData[widget.model].length > 0
|
|
107852
|
+
)?_c('div',{staticClass:"computed-wrap"},[_c('div',{staticClass:"item"},[_c('div',[_vm._v("需统计字段")]),_vm._l((widget.options.computingSub),function(_item,key){return _c('div',{key:key},[_vm._v(" "+_vm._s(_vm.getSubName(_item, widget.columns))+" ")])})],2),_vm._l((widget.options.computingMethod),function(_methodItem,key){return _c('div',{key:key,staticClass:"item"},[_c('div',[_vm._v(_vm._s(_vm.getMethodName(_methodItem)))]),_vm._l((widget.options.computingSub),function(_subItem,it_key){return _c('div',{key:it_key},[_vm._v(" "+_vm._s(_vm.getMathResult(_methodItem, _vm.models[widget.model], _subItem))+" ")])})],2)})],2):_vm._e()],2)]):(widget.options.layoutModel === 'design')?_c('a-spin',{directives:[{name:"show",rawName:"v-show",value:(widget.options.canView),expression:"widget.options.canView"}],key:index,staticClass:"table_border row-item",style:({ borderColor: _vm.data.config.borderColor }),attrs:{"spinning":_vm.tableLoading && !_vm.formLoading,"tip":"数据加载中"}},[_c('tableComponent',{attrs:{"widget":widget,"tableData":_vm.tableData,"rules":_vm.rules,"models":_vm.models,"formId":_vm.data.formId,"index":index,"listindex":listindex},on:{"update:rules":function($event){_vm.rules=$event},"update:models":function($event){_vm.models=$event},"addToTableData":_vm.addToTableData,"handleDeleteRow":_vm.handleDeleteRow}})],1):_vm._e()]:(widget.type === 'grid')?_c('div',{directives:[{name:"show",rawName:"v-show",value:(widget.options.canView && widget.type != 'hidden'),expression:"widget.options.canView && widget.type != 'hidden'"}],key:index,staticClass:"row-item",style:({ borderColor: _vm.data.config.borderColor })},[_c('grid-component',{attrs:{"rules":_vm.rules,"models":_vm.models,"widget":widget,"index":index,"verifyNode":_vm.verifyNode,"suggest":_vm.suggest,"verifyLogs":_vm.verifyLogs,"config":_vm.data.config,"listindex":listindex},on:{"update:rules":function($event){_vm.rules=$event},"update:models":function($event){_vm.models=$event}}})],1):(widget.type == 'grid-lay-out')?_c('div',{directives:[{name:"show",rawName:"v-show",value:(widget.options.canView && widget.type != 'hidden'),expression:"widget.options.canView && widget.type != 'hidden'"}],key:index,staticClass:"row-item",class:widget.type == 'grid-lay-out' ? ' no-row-item ' : '',style:({ borderColor: _vm.data.config.borderColor })},[_c('grid-layout-component',{attrs:{"widget":widget,"rules":_vm.rules,"models":_vm.models,"index":index,"verifyNode":_vm.verifyNode,"suggest":_vm.suggest,"verifyLogs":_vm.verifyLogs,"listindex":listindex,"config":_vm.data.config},on:{"update:rules":function($event){_vm.rules=$event},"update:models":function($event){_vm.models=$event}}})],1):(widget.type == 'verify')?_c('div',{directives:[{name:"show",rawName:"v-show",value:(widget.options.canView && widget.type != 'hidden'),expression:"widget.options.canView && widget.type != 'hidden'"}],key:index,staticClass:"row-item",style:({ borderColor: _vm.data.config.borderColor })},[_c('verify-component',{attrs:{"widget":widget,"rules":_vm.rules,"models":_vm.models,"verifyNode":_vm.verifyNode,"verifyLogs":_vm.verifyLogs,"suggest":_vm.suggest},on:{"update:rules":function($event){_vm.rules=$event},"update:models":function($event){_vm.models=$event}}})],1):(widget.type == 'all-lay-out')?_c('div',{directives:[{name:"show",rawName:"v-show",value:(widget.options.canView && widget.type != 'hidden'),expression:"widget.options.canView && widget.type != 'hidden'"}],key:index,staticClass:"row-item",style:({ borderColor: _vm.data.config.borderColor })},[_c('all-layout-component',{attrs:{"widget":widget,"rules":_vm.rules,"models":_vm.models,"index":index,"listindex":listindex},on:{"update:rules":function($event){_vm.rules=$event},"update:models":function($event){_vm.models=$event}}})],1):(widget.type == 'placeholder')?_c('div',{directives:[{name:"show",rawName:"v-show",value:(widget.options.canView && widget.type != 'hidden'),expression:"widget.options.canView && widget.type != 'hidden'"}],key:index,class:{
|
|
107853
|
+
'item-bottom': !widget.options.border,
|
|
107854
|
+
'row-item': widget.options.border,
|
|
107855
|
+
},style:({ borderColor: _vm.data.config.borderColor })},[_c('layout-item',{attrs:{"widget":widget,"models":_vm.models,"rules":_vm.rules,"verifyNode":_vm.verifyNode,"verifyLogs":_vm.verifyLogs},on:{"update:models":function($event){_vm.models=$event},"update:rules":function($event){_vm.rules=$event}}})],1):_c('div',{directives:[{name:"show",rawName:"v-show",value:(widget.options.canView && widget.type != 'hidden'),expression:"widget.options.canView && widget.type != 'hidden'"}],key:index,staticClass:"row-item",style:({ borderColor: _vm.data.config.borderColor })},[_c('layout-item',{attrs:{"widget":widget,"models":_vm.models,"verifyNode":_vm.verifyNode,"verifyLogs":_vm.verifyLogs,"suggest":_vm.suggest,"rules":_vm.rules},on:{"update:models":function($event){_vm.models=$event},"update:rules":function($event){_vm.rules=$event}}})],1)]})],2),(_vm.data.config.pageFooter && listindex === _vm.widgetList.length - 1)?_c('div',{style:(_vm.data.config.footerHeight),domProps:{"innerHTML":_vm._s(_vm.data.config.pageFooter)}}):_vm._e()],2)}),0)],1)}
|
|
107659
107856
|
var staticRenderFns = []
|
|
107660
107857
|
|
|
107661
107858
|
|
|
@@ -107663,10 +107860,10 @@ var staticRenderFns = []
|
|
|
107663
107860
|
var layoutForPapervue_type_script_lang_js_ = __webpack_require__(7862);
|
|
107664
107861
|
;// CONCATENATED MODULE: ./src/form/modules/layout/layoutForPaper.vue?vue&type=script&lang=js&
|
|
107665
107862
|
/* harmony default export */ var layout_layoutForPapervue_type_script_lang_js_ = (layoutForPapervue_type_script_lang_js_/* default */.Z);
|
|
107666
|
-
;// CONCATENATED MODULE: ./node_modules/_mini-css-extract-plugin@2.7.6@mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/_css-loader@6.8.1@css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/_vue-loader@15.10.1@vue-loader/lib/loaders/stylePostLoader.js!./node_modules/_postcss-loader@6.2.1@postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/_less-loader@5.0.0@less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/_vue-loader@15.10.1@vue-loader/lib/index.js??vue-loader-options!./src/form/modules/layout/layoutForPaper.vue?vue&type=style&index=1&id=
|
|
107863
|
+
;// CONCATENATED MODULE: ./node_modules/_mini-css-extract-plugin@2.7.6@mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/_css-loader@6.8.1@css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/_vue-loader@15.10.1@vue-loader/lib/loaders/stylePostLoader.js!./node_modules/_postcss-loader@6.2.1@postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/_less-loader@5.0.0@less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/_vue-loader@15.10.1@vue-loader/lib/index.js??vue-loader-options!./src/form/modules/layout/layoutForPaper.vue?vue&type=style&index=1&id=57dc7d67&prod&lang=less&scoped=true&
|
|
107667
107864
|
// extracted by mini-css-extract-plugin
|
|
107668
107865
|
|
|
107669
|
-
;// CONCATENATED MODULE: ./src/form/modules/layout/layoutForPaper.vue?vue&type=style&index=1&id=
|
|
107866
|
+
;// CONCATENATED MODULE: ./src/form/modules/layout/layoutForPaper.vue?vue&type=style&index=1&id=57dc7d67&prod&lang=less&scoped=true&
|
|
107670
107867
|
|
|
107671
107868
|
// EXTERNAL MODULE: ./node_modules/_vue-loader@15.10.1@vue-loader/lib/runtime/componentNormalizer.js
|
|
107672
107869
|
var componentNormalizer = __webpack_require__(8412);
|
|
@@ -107685,7 +107882,7 @@ var component = (0,componentNormalizer/* default */.Z)(
|
|
|
107685
107882
|
staticRenderFns,
|
|
107686
107883
|
false,
|
|
107687
107884
|
null,
|
|
107688
|
-
"
|
|
107885
|
+
"57dc7d67",
|
|
107689
107886
|
null
|
|
107690
107887
|
|
|
107691
107888
|
)
|
|
@@ -111594,6 +111791,953 @@ var Container_component = (0,componentNormalizer/* default */.Z)(
|
|
|
111594
111791
|
)
|
|
111595
111792
|
|
|
111596
111793
|
/* harmony default export */ var Container = (Container_component.exports);
|
|
111794
|
+
;// CONCATENATED MODULE: ./src/components/VirtualList/virtual.js
|
|
111795
|
+
/**
|
|
111796
|
+
* virtual list core calculating center
|
|
111797
|
+
*/
|
|
111798
|
+
|
|
111799
|
+
const DIRECTION_TYPE = {
|
|
111800
|
+
FRONT: 'FRONT',
|
|
111801
|
+
// scroll up or left
|
|
111802
|
+
BEHIND: 'BEHIND' // scroll down or right
|
|
111803
|
+
};
|
|
111804
|
+
|
|
111805
|
+
const CALC_TYPE = {
|
|
111806
|
+
INIT: 'INIT',
|
|
111807
|
+
FIXED: 'FIXED',
|
|
111808
|
+
DYNAMIC: 'DYNAMIC'
|
|
111809
|
+
};
|
|
111810
|
+
const LEADING_BUFFER = 0;
|
|
111811
|
+
class Virtual {
|
|
111812
|
+
constructor(param, callUpdate) {
|
|
111813
|
+
this.init(param, callUpdate);
|
|
111814
|
+
}
|
|
111815
|
+
init(param, callUpdate) {
|
|
111816
|
+
// param data
|
|
111817
|
+
this.param = param;
|
|
111818
|
+
this.callUpdate = callUpdate;
|
|
111819
|
+
|
|
111820
|
+
// size data
|
|
111821
|
+
this.sizes = new Map();
|
|
111822
|
+
this.firstRangeTotalSize = 0;
|
|
111823
|
+
this.firstRangeAverageSize = 0;
|
|
111824
|
+
this.fixedSizeValue = 0;
|
|
111825
|
+
this.calcType = CALC_TYPE.INIT;
|
|
111826
|
+
|
|
111827
|
+
// scroll data
|
|
111828
|
+
this.offset = 0;
|
|
111829
|
+
this.direction = '';
|
|
111830
|
+
|
|
111831
|
+
// range data
|
|
111832
|
+
this.range = Object.create(null);
|
|
111833
|
+
if (param) {
|
|
111834
|
+
this.checkRange(0, param.keeps - 1);
|
|
111835
|
+
}
|
|
111836
|
+
|
|
111837
|
+
// benchmark test data
|
|
111838
|
+
// this.__bsearchCalls = 0
|
|
111839
|
+
// this.__getIndexOffsetCalls = 0
|
|
111840
|
+
}
|
|
111841
|
+
|
|
111842
|
+
destroy() {
|
|
111843
|
+
this.init(null, null);
|
|
111844
|
+
}
|
|
111845
|
+
|
|
111846
|
+
// return current render range
|
|
111847
|
+
getRange() {
|
|
111848
|
+
const range = Object.create(null);
|
|
111849
|
+
range.start = this.range.start;
|
|
111850
|
+
range.end = this.range.end;
|
|
111851
|
+
range.padFront = this.range.padFront;
|
|
111852
|
+
range.padBehind = this.range.padBehind;
|
|
111853
|
+
return range;
|
|
111854
|
+
}
|
|
111855
|
+
isBehind() {
|
|
111856
|
+
return this.direction === DIRECTION_TYPE.BEHIND;
|
|
111857
|
+
}
|
|
111858
|
+
isFront() {
|
|
111859
|
+
return this.direction === DIRECTION_TYPE.FRONT;
|
|
111860
|
+
}
|
|
111861
|
+
|
|
111862
|
+
// return start index offset
|
|
111863
|
+
getOffset(start) {
|
|
111864
|
+
return (start < 1 ? 0 : this.getIndexOffset(start)) + this.param.slotHeaderSize;
|
|
111865
|
+
}
|
|
111866
|
+
updateParam(key, value) {
|
|
111867
|
+
if (this.param && key in this.param) {
|
|
111868
|
+
// if uniqueIds change, find out deleted id and remove from size map
|
|
111869
|
+
if (key === 'uniqueIds') {
|
|
111870
|
+
this.sizes.forEach((v, key) => {
|
|
111871
|
+
if (!value.includes(key)) {
|
|
111872
|
+
this.sizes.delete(key);
|
|
111873
|
+
}
|
|
111874
|
+
});
|
|
111875
|
+
}
|
|
111876
|
+
this.param[key] = value;
|
|
111877
|
+
}
|
|
111878
|
+
}
|
|
111879
|
+
|
|
111880
|
+
// save each size map by id
|
|
111881
|
+
saveSize(id, size) {
|
|
111882
|
+
this.sizes.set(id, size);
|
|
111883
|
+
|
|
111884
|
+
// we assume size type is fixed at the beginning and remember first size value
|
|
111885
|
+
// if there is no size value different from this at next comming saving
|
|
111886
|
+
// we think it's a fixed size list, otherwise is dynamic size list
|
|
111887
|
+
if (this.calcType === CALC_TYPE.INIT) {
|
|
111888
|
+
this.fixedSizeValue = size;
|
|
111889
|
+
this.calcType = CALC_TYPE.FIXED;
|
|
111890
|
+
} else if (this.calcType === CALC_TYPE.FIXED && this.fixedSizeValue !== size) {
|
|
111891
|
+
this.calcType = CALC_TYPE.DYNAMIC;
|
|
111892
|
+
// it's no use at all
|
|
111893
|
+
delete this.fixedSizeValue;
|
|
111894
|
+
}
|
|
111895
|
+
|
|
111896
|
+
// calculate the average size only in the first range
|
|
111897
|
+
if (this.calcType !== CALC_TYPE.FIXED && typeof this.firstRangeTotalSize !== 'undefined') {
|
|
111898
|
+
if (this.sizes.size < Math.min(this.param.keeps, this.param.uniqueIds.length)) {
|
|
111899
|
+
this.firstRangeTotalSize = [...this.sizes.values()].reduce((acc, val) => acc + val, 0);
|
|
111900
|
+
this.firstRangeAverageSize = Math.round(this.firstRangeTotalSize / this.sizes.size);
|
|
111901
|
+
} else {
|
|
111902
|
+
// it's done using
|
|
111903
|
+
delete this.firstRangeTotalSize;
|
|
111904
|
+
}
|
|
111905
|
+
}
|
|
111906
|
+
}
|
|
111907
|
+
|
|
111908
|
+
// in some special situation (e.g. length change) we need to update in a row
|
|
111909
|
+
// try goiong to render next range by a leading buffer according to current direction
|
|
111910
|
+
handleDataSourcesChange() {
|
|
111911
|
+
let start = this.range.start;
|
|
111912
|
+
if (this.isFront()) {
|
|
111913
|
+
start = start - LEADING_BUFFER;
|
|
111914
|
+
} else if (this.isBehind()) {
|
|
111915
|
+
start = start + LEADING_BUFFER;
|
|
111916
|
+
}
|
|
111917
|
+
start = Math.max(start, 0);
|
|
111918
|
+
this.updateRange(this.range.start, this.getEndByStart(start));
|
|
111919
|
+
}
|
|
111920
|
+
|
|
111921
|
+
// when slot size change, we also need force update
|
|
111922
|
+
handleSlotSizeChange() {
|
|
111923
|
+
this.handleDataSourcesChange();
|
|
111924
|
+
}
|
|
111925
|
+
|
|
111926
|
+
// calculating range on scroll
|
|
111927
|
+
handleScroll(offset) {
|
|
111928
|
+
this.direction = offset < this.offset || offset === 0 ? DIRECTION_TYPE.FRONT : DIRECTION_TYPE.BEHIND;
|
|
111929
|
+
this.offset = offset;
|
|
111930
|
+
if (!this.param) {
|
|
111931
|
+
return;
|
|
111932
|
+
}
|
|
111933
|
+
if (this.direction === DIRECTION_TYPE.FRONT) {
|
|
111934
|
+
this.handleFront();
|
|
111935
|
+
} else if (this.direction === DIRECTION_TYPE.BEHIND) {
|
|
111936
|
+
this.handleBehind();
|
|
111937
|
+
}
|
|
111938
|
+
}
|
|
111939
|
+
|
|
111940
|
+
// ----------- public method end -----------
|
|
111941
|
+
|
|
111942
|
+
handleFront() {
|
|
111943
|
+
const overs = this.getScrollOvers();
|
|
111944
|
+
// should not change range if start doesn't exceed overs
|
|
111945
|
+
if (overs > this.range.start) {
|
|
111946
|
+
return;
|
|
111947
|
+
}
|
|
111948
|
+
|
|
111949
|
+
// move up start by a buffer length, and make sure its safety
|
|
111950
|
+
const start = Math.max(overs - this.param.buffer, 0);
|
|
111951
|
+
this.checkRange(start, this.getEndByStart(start));
|
|
111952
|
+
}
|
|
111953
|
+
handleBehind() {
|
|
111954
|
+
const overs = this.getScrollOvers();
|
|
111955
|
+
// range should not change if scroll overs within buffer
|
|
111956
|
+
if (overs < this.range.start + this.param.buffer) {
|
|
111957
|
+
return;
|
|
111958
|
+
}
|
|
111959
|
+
this.checkRange(overs, this.getEndByStart(overs));
|
|
111960
|
+
}
|
|
111961
|
+
|
|
111962
|
+
// return the pass overs according to current scroll offset
|
|
111963
|
+
getScrollOvers() {
|
|
111964
|
+
// if slot header exist, we need subtract its size
|
|
111965
|
+
const offset = this.offset - this.param.slotHeaderSize;
|
|
111966
|
+
if (offset <= 0) {
|
|
111967
|
+
return 0;
|
|
111968
|
+
}
|
|
111969
|
+
|
|
111970
|
+
// if is fixed type, that can be easily
|
|
111971
|
+
if (this.isFixedType()) {
|
|
111972
|
+
return Math.floor(offset / this.fixedSizeValue);
|
|
111973
|
+
}
|
|
111974
|
+
let low = 0;
|
|
111975
|
+
let middle = 0;
|
|
111976
|
+
let middleOffset = 0;
|
|
111977
|
+
let high = this.param.uniqueIds.length;
|
|
111978
|
+
while (low <= high) {
|
|
111979
|
+
// this.__bsearchCalls++
|
|
111980
|
+
middle = low + Math.floor((high - low) / 2);
|
|
111981
|
+
middleOffset = this.getIndexOffset(middle);
|
|
111982
|
+
if (middleOffset === offset) {
|
|
111983
|
+
return middle;
|
|
111984
|
+
} else if (middleOffset < offset) {
|
|
111985
|
+
low = middle + 1;
|
|
111986
|
+
} else if (middleOffset > offset) {
|
|
111987
|
+
high = middle - 1;
|
|
111988
|
+
}
|
|
111989
|
+
}
|
|
111990
|
+
return low > 0 ? --low : 0;
|
|
111991
|
+
}
|
|
111992
|
+
|
|
111993
|
+
// return a scroll offset from given index, can efficiency be improved more here?
|
|
111994
|
+
// although the call frequency is very high, its only a superposition of numbers
|
|
111995
|
+
getIndexOffset(givenIndex) {
|
|
111996
|
+
if (!givenIndex) {
|
|
111997
|
+
return 0;
|
|
111998
|
+
}
|
|
111999
|
+
let offset = 0;
|
|
112000
|
+
let indexSize = 0;
|
|
112001
|
+
for (let index = 0; index < givenIndex; index++) {
|
|
112002
|
+
// this.__getIndexOffsetCalls++
|
|
112003
|
+
indexSize = this.sizes.get(this.param.uniqueIds[index]);
|
|
112004
|
+
offset = offset + (typeof indexSize === 'number' ? indexSize : this.getEstimateSize());
|
|
112005
|
+
}
|
|
112006
|
+
return offset;
|
|
112007
|
+
}
|
|
112008
|
+
|
|
112009
|
+
// is fixed size type
|
|
112010
|
+
isFixedType() {
|
|
112011
|
+
return this.calcType === CALC_TYPE.FIXED;
|
|
112012
|
+
}
|
|
112013
|
+
|
|
112014
|
+
// return the real last index
|
|
112015
|
+
getLastIndex() {
|
|
112016
|
+
return this.param.uniqueIds.length - 1;
|
|
112017
|
+
}
|
|
112018
|
+
|
|
112019
|
+
// in some conditions range is broke, we need correct it
|
|
112020
|
+
// and then decide whether need update to next range
|
|
112021
|
+
checkRange(start, end) {
|
|
112022
|
+
const keeps = this.param.keeps;
|
|
112023
|
+
const total = this.param.uniqueIds.length;
|
|
112024
|
+
|
|
112025
|
+
// datas less than keeps, render all
|
|
112026
|
+
if (total <= keeps) {
|
|
112027
|
+
start = 0;
|
|
112028
|
+
end = this.getLastIndex();
|
|
112029
|
+
} else if (end - start < keeps - 1) {
|
|
112030
|
+
// if range length is less than keeps, corrent it base on end
|
|
112031
|
+
start = end - keeps + 1;
|
|
112032
|
+
}
|
|
112033
|
+
if (this.range.start !== start) {
|
|
112034
|
+
this.updateRange(start, end);
|
|
112035
|
+
}
|
|
112036
|
+
}
|
|
112037
|
+
|
|
112038
|
+
// setting to a new range and rerender
|
|
112039
|
+
updateRange(start, end) {
|
|
112040
|
+
this.range.start = start;
|
|
112041
|
+
this.range.end = end;
|
|
112042
|
+
this.range.padFront = this.getPadFront();
|
|
112043
|
+
this.range.padBehind = this.getPadBehind();
|
|
112044
|
+
this.callUpdate(this.getRange());
|
|
112045
|
+
}
|
|
112046
|
+
|
|
112047
|
+
// return end base on start
|
|
112048
|
+
getEndByStart(start) {
|
|
112049
|
+
const theoryEnd = start + this.param.keeps - 1;
|
|
112050
|
+
const truelyEnd = Math.min(theoryEnd, this.getLastIndex());
|
|
112051
|
+
return truelyEnd;
|
|
112052
|
+
}
|
|
112053
|
+
|
|
112054
|
+
// return total front offset
|
|
112055
|
+
getPadFront() {
|
|
112056
|
+
if (this.isFixedType()) {
|
|
112057
|
+
return this.fixedSizeValue * this.range.start;
|
|
112058
|
+
} else {
|
|
112059
|
+
return this.getIndexOffset(this.range.start);
|
|
112060
|
+
}
|
|
112061
|
+
}
|
|
112062
|
+
|
|
112063
|
+
// return total behind offset
|
|
112064
|
+
getPadBehind() {
|
|
112065
|
+
const end = this.range.end;
|
|
112066
|
+
const lastIndex = this.getLastIndex();
|
|
112067
|
+
if (this.isFixedType()) {
|
|
112068
|
+
return (lastIndex - end) * this.fixedSizeValue;
|
|
112069
|
+
}
|
|
112070
|
+
return (lastIndex - end) * this.getEstimateSize();
|
|
112071
|
+
}
|
|
112072
|
+
|
|
112073
|
+
// get the item estimate size
|
|
112074
|
+
getEstimateSize() {
|
|
112075
|
+
return this.isFixedType() ? this.fixedSizeValue : this.firstRangeAverageSize || this.param.estimateSize;
|
|
112076
|
+
}
|
|
112077
|
+
}
|
|
112078
|
+
;// CONCATENATED MODULE: ./src/components/VirtualList/props.js
|
|
112079
|
+
/**
|
|
112080
|
+
* props declaration for default, item and slot component
|
|
112081
|
+
*/
|
|
112082
|
+
|
|
112083
|
+
const VirtualProps = {
|
|
112084
|
+
dataKey: {
|
|
112085
|
+
type: [String, Function],
|
|
112086
|
+
required: true
|
|
112087
|
+
},
|
|
112088
|
+
dataSources: {
|
|
112089
|
+
type: Array,
|
|
112090
|
+
required: true
|
|
112091
|
+
},
|
|
112092
|
+
dataComponent: {
|
|
112093
|
+
type: [Object, Function],
|
|
112094
|
+
required: true
|
|
112095
|
+
},
|
|
112096
|
+
keeps: {
|
|
112097
|
+
type: Number,
|
|
112098
|
+
default: 30
|
|
112099
|
+
},
|
|
112100
|
+
extraProps: {
|
|
112101
|
+
type: Object
|
|
112102
|
+
},
|
|
112103
|
+
estimateSize: {
|
|
112104
|
+
type: Number,
|
|
112105
|
+
default: 50
|
|
112106
|
+
},
|
|
112107
|
+
direction: {
|
|
112108
|
+
type: String,
|
|
112109
|
+
default: 'vertical' // the other value is horizontal
|
|
112110
|
+
},
|
|
112111
|
+
|
|
112112
|
+
start: {
|
|
112113
|
+
type: Number,
|
|
112114
|
+
default: 0
|
|
112115
|
+
},
|
|
112116
|
+
offset: {
|
|
112117
|
+
type: Number,
|
|
112118
|
+
default: 0
|
|
112119
|
+
},
|
|
112120
|
+
topThreshold: {
|
|
112121
|
+
type: Number,
|
|
112122
|
+
default: 0
|
|
112123
|
+
},
|
|
112124
|
+
bottomThreshold: {
|
|
112125
|
+
type: Number,
|
|
112126
|
+
default: 0
|
|
112127
|
+
},
|
|
112128
|
+
pageMode: {
|
|
112129
|
+
type: Boolean,
|
|
112130
|
+
default: false
|
|
112131
|
+
},
|
|
112132
|
+
rootTag: {
|
|
112133
|
+
type: String,
|
|
112134
|
+
default: 'div'
|
|
112135
|
+
},
|
|
112136
|
+
wrapTag: {
|
|
112137
|
+
type: String,
|
|
112138
|
+
default: 'div'
|
|
112139
|
+
},
|
|
112140
|
+
wrapClass: {
|
|
112141
|
+
type: String,
|
|
112142
|
+
default: ''
|
|
112143
|
+
},
|
|
112144
|
+
wrapStyle: {
|
|
112145
|
+
type: Object
|
|
112146
|
+
},
|
|
112147
|
+
itemTag: {
|
|
112148
|
+
type: String,
|
|
112149
|
+
default: 'div'
|
|
112150
|
+
},
|
|
112151
|
+
itemClass: {
|
|
112152
|
+
type: String,
|
|
112153
|
+
default: ''
|
|
112154
|
+
},
|
|
112155
|
+
itemClassAdd: {
|
|
112156
|
+
type: Function
|
|
112157
|
+
},
|
|
112158
|
+
itemStyle: {
|
|
112159
|
+
type: Object
|
|
112160
|
+
},
|
|
112161
|
+
headerTag: {
|
|
112162
|
+
type: String,
|
|
112163
|
+
default: 'div'
|
|
112164
|
+
},
|
|
112165
|
+
headerClass: {
|
|
112166
|
+
type: String,
|
|
112167
|
+
default: ''
|
|
112168
|
+
},
|
|
112169
|
+
headerStyle: {
|
|
112170
|
+
type: Object
|
|
112171
|
+
},
|
|
112172
|
+
footerTag: {
|
|
112173
|
+
type: String,
|
|
112174
|
+
default: 'div'
|
|
112175
|
+
},
|
|
112176
|
+
footerClass: {
|
|
112177
|
+
type: String,
|
|
112178
|
+
default: ''
|
|
112179
|
+
},
|
|
112180
|
+
footerStyle: {
|
|
112181
|
+
type: Object
|
|
112182
|
+
},
|
|
112183
|
+
itemScopedSlots: {
|
|
112184
|
+
type: Object
|
|
112185
|
+
}
|
|
112186
|
+
};
|
|
112187
|
+
const ItemProps = {
|
|
112188
|
+
index: {
|
|
112189
|
+
type: Number
|
|
112190
|
+
},
|
|
112191
|
+
event: {
|
|
112192
|
+
type: String
|
|
112193
|
+
},
|
|
112194
|
+
tag: {
|
|
112195
|
+
type: String
|
|
112196
|
+
},
|
|
112197
|
+
horizontal: {
|
|
112198
|
+
type: Boolean
|
|
112199
|
+
},
|
|
112200
|
+
source: {
|
|
112201
|
+
type: Object
|
|
112202
|
+
},
|
|
112203
|
+
component: {
|
|
112204
|
+
type: [Object, Function]
|
|
112205
|
+
},
|
|
112206
|
+
slotComponent: {
|
|
112207
|
+
type: Function
|
|
112208
|
+
},
|
|
112209
|
+
uniqueKey: {
|
|
112210
|
+
type: [String, Number]
|
|
112211
|
+
},
|
|
112212
|
+
extraProps: {
|
|
112213
|
+
type: Object
|
|
112214
|
+
},
|
|
112215
|
+
scopedSlots: {
|
|
112216
|
+
type: Object
|
|
112217
|
+
}
|
|
112218
|
+
};
|
|
112219
|
+
const SlotProps = {
|
|
112220
|
+
event: {
|
|
112221
|
+
type: String
|
|
112222
|
+
},
|
|
112223
|
+
uniqueKey: {
|
|
112224
|
+
type: String
|
|
112225
|
+
},
|
|
112226
|
+
tag: {
|
|
112227
|
+
type: String
|
|
112228
|
+
},
|
|
112229
|
+
horizontal: {
|
|
112230
|
+
type: Boolean
|
|
112231
|
+
}
|
|
112232
|
+
};
|
|
112233
|
+
;// CONCATENATED MODULE: ./src/components/VirtualList/item.js
|
|
112234
|
+
/**
|
|
112235
|
+
* item and slot component both use similar wrapper
|
|
112236
|
+
* we need to know their size change at any time
|
|
112237
|
+
*/
|
|
112238
|
+
|
|
112239
|
+
|
|
112240
|
+
|
|
112241
|
+
const Wrapper = {
|
|
112242
|
+
created() {
|
|
112243
|
+
this.shapeKey = this.horizontal ? 'offsetWidth' : 'offsetHeight';
|
|
112244
|
+
},
|
|
112245
|
+
mounted() {
|
|
112246
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
112247
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
112248
|
+
this.dispatchSizeChange();
|
|
112249
|
+
});
|
|
112250
|
+
this.resizeObserver.observe(this.$el);
|
|
112251
|
+
}
|
|
112252
|
+
},
|
|
112253
|
+
// since componet will be reused, so disptach when updated
|
|
112254
|
+
updated() {
|
|
112255
|
+
// this.dispatchSizeChange()
|
|
112256
|
+
this.resizeObserver.observe(this.$el);
|
|
112257
|
+
},
|
|
112258
|
+
beforeDestroy() {
|
|
112259
|
+
if (this.resizeObserver) {
|
|
112260
|
+
this.resizeObserver.disconnect();
|
|
112261
|
+
this.resizeObserver = null;
|
|
112262
|
+
}
|
|
112263
|
+
},
|
|
112264
|
+
methods: {
|
|
112265
|
+
getCurrentSize() {
|
|
112266
|
+
return this.$el ? this.$el[this.shapeKey] : 0;
|
|
112267
|
+
},
|
|
112268
|
+
// tell parent current size identify by unqiue key
|
|
112269
|
+
dispatchSizeChange() {
|
|
112270
|
+
// this.$parent.$emit(this.event, this.uniqueKey, this.getCurrentSize(), this.hasInitial)
|
|
112271
|
+
}
|
|
112272
|
+
}
|
|
112273
|
+
};
|
|
112274
|
+
|
|
112275
|
+
// wrapping for slot
|
|
112276
|
+
const Slot = external_commonjs_vue_commonjs2_vue_root_Vue_default().component('virtual-list-slot', {
|
|
112277
|
+
mixins: [Wrapper],
|
|
112278
|
+
props: SlotProps,
|
|
112279
|
+
render(h) {
|
|
112280
|
+
const {
|
|
112281
|
+
tag,
|
|
112282
|
+
uniqueKey
|
|
112283
|
+
} = this;
|
|
112284
|
+
return h(tag, {
|
|
112285
|
+
key: uniqueKey,
|
|
112286
|
+
attrs: {
|
|
112287
|
+
role: uniqueKey
|
|
112288
|
+
}
|
|
112289
|
+
}, this.$slots.default);
|
|
112290
|
+
}
|
|
112291
|
+
});
|
|
112292
|
+
;// CONCATENATED MODULE: ./node_modules/_thread-loader@3.0.4@thread-loader/dist/cjs.js!./node_modules/_babel-loader@8.3.0@babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/_vue-loader@15.10.1@vue-loader/lib/index.js??vue-loader-options!./src/components/VirtualList/virtualListItem.vue?vue&type=script&lang=js&
|
|
112293
|
+
|
|
112294
|
+
|
|
112295
|
+
/* harmony default export */ var virtualListItemvue_type_script_lang_js_ = ({
|
|
112296
|
+
mixins: [Wrapper],
|
|
112297
|
+
props: ItemProps,
|
|
112298
|
+
name: 'virtual-list-item',
|
|
112299
|
+
render(h) {
|
|
112300
|
+
const {
|
|
112301
|
+
tag,
|
|
112302
|
+
component,
|
|
112303
|
+
extraProps = {},
|
|
112304
|
+
index,
|
|
112305
|
+
source,
|
|
112306
|
+
scopedSlots = {},
|
|
112307
|
+
uniqueKey,
|
|
112308
|
+
slotComponent
|
|
112309
|
+
} = this;
|
|
112310
|
+
const props = {
|
|
112311
|
+
...extraProps,
|
|
112312
|
+
source,
|
|
112313
|
+
index
|
|
112314
|
+
};
|
|
112315
|
+
return h(tag, {
|
|
112316
|
+
key: uniqueKey,
|
|
112317
|
+
attrs: {
|
|
112318
|
+
role: 'listitem'
|
|
112319
|
+
}
|
|
112320
|
+
}, [slotComponent ? slotComponent({
|
|
112321
|
+
item: source,
|
|
112322
|
+
index: index,
|
|
112323
|
+
scope: props
|
|
112324
|
+
}) : h(component, {
|
|
112325
|
+
props,
|
|
112326
|
+
scopedSlots: scopedSlots
|
|
112327
|
+
})]);
|
|
112328
|
+
}
|
|
112329
|
+
});
|
|
112330
|
+
;// CONCATENATED MODULE: ./src/components/VirtualList/virtualListItem.vue?vue&type=script&lang=js&
|
|
112331
|
+
/* harmony default export */ var VirtualList_virtualListItemvue_type_script_lang_js_ = (virtualListItemvue_type_script_lang_js_);
|
|
112332
|
+
;// CONCATENATED MODULE: ./src/components/VirtualList/virtualListItem.vue
|
|
112333
|
+
var virtualListItem_render, virtualListItem_staticRenderFns
|
|
112334
|
+
;
|
|
112335
|
+
|
|
112336
|
+
|
|
112337
|
+
|
|
112338
|
+
/* normalize component */
|
|
112339
|
+
;
|
|
112340
|
+
var virtualListItem_component = (0,componentNormalizer/* default */.Z)(
|
|
112341
|
+
VirtualList_virtualListItemvue_type_script_lang_js_,
|
|
112342
|
+
virtualListItem_render,
|
|
112343
|
+
virtualListItem_staticRenderFns,
|
|
112344
|
+
false,
|
|
112345
|
+
null,
|
|
112346
|
+
null,
|
|
112347
|
+
null
|
|
112348
|
+
|
|
112349
|
+
)
|
|
112350
|
+
|
|
112351
|
+
/* harmony default export */ var virtualListItem = (virtualListItem_component.exports);
|
|
112352
|
+
;// CONCATENATED MODULE: ./src/components/VirtualList/index.js
|
|
112353
|
+
|
|
112354
|
+
/**
|
|
112355
|
+
* virtual list default component
|
|
112356
|
+
*/
|
|
112357
|
+
|
|
112358
|
+
|
|
112359
|
+
|
|
112360
|
+
|
|
112361
|
+
|
|
112362
|
+
|
|
112363
|
+
const EVENT_TYPE = {
|
|
112364
|
+
ITEM: 'item_resize',
|
|
112365
|
+
SLOT: 'slot_resize'
|
|
112366
|
+
};
|
|
112367
|
+
const SLOT_TYPE = {
|
|
112368
|
+
HEADER: 'thead',
|
|
112369
|
+
// string value also use for aria role attribute
|
|
112370
|
+
FOOTER: 'tfoot'
|
|
112371
|
+
};
|
|
112372
|
+
const VirtualList = {
|
|
112373
|
+
props: VirtualProps,
|
|
112374
|
+
data() {
|
|
112375
|
+
return {
|
|
112376
|
+
range: null
|
|
112377
|
+
};
|
|
112378
|
+
},
|
|
112379
|
+
watch: {
|
|
112380
|
+
'dataSources.length'() {
|
|
112381
|
+
this.virtual.updateParam('uniqueIds', this.getUniqueIdFromDataSources());
|
|
112382
|
+
this.virtual.handleDataSourcesChange();
|
|
112383
|
+
},
|
|
112384
|
+
keeps(newValue) {
|
|
112385
|
+
this.virtual.updateParam('keeps', newValue);
|
|
112386
|
+
this.virtual.handleSlotSizeChange();
|
|
112387
|
+
},
|
|
112388
|
+
start(newValue) {
|
|
112389
|
+
this.scrollToIndex(newValue);
|
|
112390
|
+
},
|
|
112391
|
+
offset(newValue) {
|
|
112392
|
+
this.scrollToOffset(newValue);
|
|
112393
|
+
}
|
|
112394
|
+
},
|
|
112395
|
+
created() {
|
|
112396
|
+
this.isHorizontal = this.direction === 'horizontal';
|
|
112397
|
+
this.directionKey = this.isHorizontal ? 'scrollLeft' : 'scrollTop';
|
|
112398
|
+
this.installVirtual();
|
|
112399
|
+
|
|
112400
|
+
// listen item size change
|
|
112401
|
+
this.$on(EVENT_TYPE.ITEM, this.onItemResized);
|
|
112402
|
+
|
|
112403
|
+
// listen slot size change
|
|
112404
|
+
if (this.$slots.header || this.$slots.footer) {
|
|
112405
|
+
this.$on(EVENT_TYPE.SLOT, this.onSlotResized);
|
|
112406
|
+
}
|
|
112407
|
+
},
|
|
112408
|
+
activated() {
|
|
112409
|
+
// set back offset when awake from keep-alive
|
|
112410
|
+
this.scrollToOffset(this.virtual.offset);
|
|
112411
|
+
if (this.pageMode) {
|
|
112412
|
+
document.addEventListener('scroll', this.onScroll, {
|
|
112413
|
+
passive: false
|
|
112414
|
+
});
|
|
112415
|
+
}
|
|
112416
|
+
},
|
|
112417
|
+
deactivated() {
|
|
112418
|
+
if (this.pageMode) {
|
|
112419
|
+
document.removeEventListener('scroll', this.onScroll);
|
|
112420
|
+
}
|
|
112421
|
+
},
|
|
112422
|
+
mounted() {
|
|
112423
|
+
// set position
|
|
112424
|
+
if (this.start) {
|
|
112425
|
+
this.scrollToIndex(this.start);
|
|
112426
|
+
} else if (this.offset) {
|
|
112427
|
+
this.scrollToOffset(this.offset);
|
|
112428
|
+
}
|
|
112429
|
+
|
|
112430
|
+
// in page mode we bind scroll event to document
|
|
112431
|
+
if (this.pageMode) {
|
|
112432
|
+
this.updatePageModeFront();
|
|
112433
|
+
document.addEventListener('scroll', this.onScroll, {
|
|
112434
|
+
passive: false
|
|
112435
|
+
});
|
|
112436
|
+
}
|
|
112437
|
+
},
|
|
112438
|
+
beforeDestroy() {
|
|
112439
|
+
this.virtual.destroy();
|
|
112440
|
+
if (this.pageMode) {
|
|
112441
|
+
document.removeEventListener('scroll', this.onScroll);
|
|
112442
|
+
}
|
|
112443
|
+
},
|
|
112444
|
+
methods: {
|
|
112445
|
+
// get item size by id
|
|
112446
|
+
getSize(id) {
|
|
112447
|
+
return this.virtual.sizes.get(id);
|
|
112448
|
+
},
|
|
112449
|
+
// get the total number of stored (rendered) items
|
|
112450
|
+
getSizes() {
|
|
112451
|
+
return this.virtual.sizes.size;
|
|
112452
|
+
},
|
|
112453
|
+
// return current scroll offset
|
|
112454
|
+
getOffset() {
|
|
112455
|
+
if (this.pageMode) {
|
|
112456
|
+
return document.documentElement[this.directionKey] || document.body[this.directionKey];
|
|
112457
|
+
} else {
|
|
112458
|
+
const {
|
|
112459
|
+
root
|
|
112460
|
+
} = this.$refs;
|
|
112461
|
+
return root ? Math.ceil(root[this.directionKey]) : 0;
|
|
112462
|
+
}
|
|
112463
|
+
},
|
|
112464
|
+
// return client viewport size
|
|
112465
|
+
getClientSize() {
|
|
112466
|
+
const key = this.isHorizontal ? 'clientWidth' : 'clientHeight';
|
|
112467
|
+
if (this.pageMode) {
|
|
112468
|
+
return document.documentElement[key] || document.body[key];
|
|
112469
|
+
} else {
|
|
112470
|
+
const {
|
|
112471
|
+
root
|
|
112472
|
+
} = this.$refs;
|
|
112473
|
+
return root ? Math.ceil(root[key]) : 0;
|
|
112474
|
+
}
|
|
112475
|
+
},
|
|
112476
|
+
// return all scroll size
|
|
112477
|
+
getScrollSize() {
|
|
112478
|
+
const key = this.isHorizontal ? 'scrollWidth' : 'scrollHeight';
|
|
112479
|
+
if (this.pageMode) {
|
|
112480
|
+
return document.documentElement[key] || document.body[key];
|
|
112481
|
+
} else {
|
|
112482
|
+
const {
|
|
112483
|
+
root
|
|
112484
|
+
} = this.$refs;
|
|
112485
|
+
return root ? Math.ceil(root[key]) : 0;
|
|
112486
|
+
}
|
|
112487
|
+
},
|
|
112488
|
+
// set current scroll position to a expectant offset
|
|
112489
|
+
scrollToOffset(offset) {
|
|
112490
|
+
if (this.pageMode) {
|
|
112491
|
+
document.body[this.directionKey] = offset;
|
|
112492
|
+
document.documentElement[this.directionKey] = offset;
|
|
112493
|
+
} else {
|
|
112494
|
+
const {
|
|
112495
|
+
root
|
|
112496
|
+
} = this.$refs;
|
|
112497
|
+
if (root) {
|
|
112498
|
+
root[this.directionKey] = offset;
|
|
112499
|
+
}
|
|
112500
|
+
}
|
|
112501
|
+
},
|
|
112502
|
+
// set current scroll position to a expectant index
|
|
112503
|
+
scrollToIndex(index) {
|
|
112504
|
+
// scroll to bottom
|
|
112505
|
+
if (index >= this.dataSources.length - 1) {
|
|
112506
|
+
this.scrollToBottom();
|
|
112507
|
+
} else {
|
|
112508
|
+
const offset = this.virtual.getOffset(index);
|
|
112509
|
+
this.scrollToOffset(offset);
|
|
112510
|
+
}
|
|
112511
|
+
},
|
|
112512
|
+
// set current scroll position to bottom
|
|
112513
|
+
scrollToBottom() {
|
|
112514
|
+
const {
|
|
112515
|
+
shepherd
|
|
112516
|
+
} = this.$refs;
|
|
112517
|
+
if (shepherd) {
|
|
112518
|
+
const offset = shepherd[this.isHorizontal ? 'offsetLeft' : 'offsetTop'];
|
|
112519
|
+
this.scrollToOffset(offset);
|
|
112520
|
+
|
|
112521
|
+
// check if it's really scrolled to the bottom
|
|
112522
|
+
// maybe list doesn't render and calculate to last range
|
|
112523
|
+
// so we need retry in next event loop until it really at bottom
|
|
112524
|
+
setTimeout(() => {
|
|
112525
|
+
if (this.getOffset() + this.getClientSize() + 1 < this.getScrollSize()) {
|
|
112526
|
+
this.scrollToBottom();
|
|
112527
|
+
}
|
|
112528
|
+
}, 3);
|
|
112529
|
+
}
|
|
112530
|
+
},
|
|
112531
|
+
// when using page mode we need update slot header size manually
|
|
112532
|
+
// taking root offset relative to the browser as slot header size
|
|
112533
|
+
updatePageModeFront() {
|
|
112534
|
+
const {
|
|
112535
|
+
root
|
|
112536
|
+
} = this.$refs;
|
|
112537
|
+
if (root) {
|
|
112538
|
+
const rect = root.getBoundingClientRect();
|
|
112539
|
+
const {
|
|
112540
|
+
defaultView
|
|
112541
|
+
} = root.ownerDocument;
|
|
112542
|
+
const offsetFront = this.isHorizontal ? rect.left + defaultView.pageXOffset : rect.top + defaultView.pageYOffset;
|
|
112543
|
+
this.virtual.updateParam('slotHeaderSize', offsetFront);
|
|
112544
|
+
}
|
|
112545
|
+
},
|
|
112546
|
+
// reset all state back to initial
|
|
112547
|
+
reset() {
|
|
112548
|
+
this.virtual.destroy();
|
|
112549
|
+
this.scrollToOffset(0);
|
|
112550
|
+
this.installVirtual();
|
|
112551
|
+
},
|
|
112552
|
+
// ----------- public method end -----------
|
|
112553
|
+
|
|
112554
|
+
installVirtual() {
|
|
112555
|
+
this.virtual = new Virtual({
|
|
112556
|
+
slotHeaderSize: 0,
|
|
112557
|
+
slotFooterSize: 0,
|
|
112558
|
+
keeps: this.keeps,
|
|
112559
|
+
estimateSize: this.estimateSize,
|
|
112560
|
+
buffer: Math.round(this.keeps / 3),
|
|
112561
|
+
// recommend for a third of keeps
|
|
112562
|
+
uniqueIds: this.getUniqueIdFromDataSources()
|
|
112563
|
+
}, this.onRangeChanged);
|
|
112564
|
+
|
|
112565
|
+
// sync initial range
|
|
112566
|
+
this.range = this.virtual.getRange();
|
|
112567
|
+
},
|
|
112568
|
+
getUniqueIdFromDataSources() {
|
|
112569
|
+
const {
|
|
112570
|
+
dataKey
|
|
112571
|
+
} = this;
|
|
112572
|
+
return this.dataSources.map(dataSource => typeof dataKey === 'function' ? dataKey(dataSource) : dataSource[dataKey]);
|
|
112573
|
+
},
|
|
112574
|
+
// event called when each item mounted or size changed
|
|
112575
|
+
onItemResized(id, size) {
|
|
112576
|
+
this.virtual.saveSize(id, size);
|
|
112577
|
+
this.$emit('resized', id, size);
|
|
112578
|
+
},
|
|
112579
|
+
// event called when slot mounted or size changed
|
|
112580
|
+
onSlotResized(type, size, hasInit) {
|
|
112581
|
+
if (type === SLOT_TYPE.HEADER) {
|
|
112582
|
+
this.virtual.updateParam('slotHeaderSize', size);
|
|
112583
|
+
} else if (type === SLOT_TYPE.FOOTER) {
|
|
112584
|
+
this.virtual.updateParam('slotFooterSize', size);
|
|
112585
|
+
}
|
|
112586
|
+
if (hasInit) {
|
|
112587
|
+
this.virtual.handleSlotSizeChange();
|
|
112588
|
+
}
|
|
112589
|
+
},
|
|
112590
|
+
// here is the rerendering entry
|
|
112591
|
+
onRangeChanged(range) {
|
|
112592
|
+
this.range = range;
|
|
112593
|
+
},
|
|
112594
|
+
onScroll(evt) {
|
|
112595
|
+
const offset = this.getOffset();
|
|
112596
|
+
const clientSize = this.getClientSize();
|
|
112597
|
+
const scrollSize = this.getScrollSize();
|
|
112598
|
+
|
|
112599
|
+
// iOS scroll-spring-back behavior will make direction mistake
|
|
112600
|
+
if (offset < 0 || offset + clientSize > scrollSize + 1 || !scrollSize) {
|
|
112601
|
+
return;
|
|
112602
|
+
}
|
|
112603
|
+
this.virtual.handleScroll(offset);
|
|
112604
|
+
this.emitEvent(offset, clientSize, scrollSize, evt);
|
|
112605
|
+
},
|
|
112606
|
+
// emit event in special position
|
|
112607
|
+
emitEvent(offset, clientSize, scrollSize, evt) {
|
|
112608
|
+
this.$emit('scroll', evt, this.virtual.getRange());
|
|
112609
|
+
if (this.virtual.isFront() && !!this.dataSources.length && offset - this.topThreshold <= 0) {
|
|
112610
|
+
this.$emit('totop');
|
|
112611
|
+
} else if (this.virtual.isBehind() && offset + clientSize + this.bottomThreshold >= scrollSize) {
|
|
112612
|
+
this.$emit('tobottom');
|
|
112613
|
+
}
|
|
112614
|
+
},
|
|
112615
|
+
// get the real render slots based on range data
|
|
112616
|
+
// in-place patch strategy will try to reuse components as possible
|
|
112617
|
+
// so those components that are reused will not trigger lifecycle mounted
|
|
112618
|
+
getRenderSlots(h) {
|
|
112619
|
+
const slots = [];
|
|
112620
|
+
const {
|
|
112621
|
+
start,
|
|
112622
|
+
end
|
|
112623
|
+
} = this.range;
|
|
112624
|
+
const {
|
|
112625
|
+
dataSources,
|
|
112626
|
+
dataKey,
|
|
112627
|
+
itemClass,
|
|
112628
|
+
itemTag,
|
|
112629
|
+
itemStyle,
|
|
112630
|
+
isHorizontal,
|
|
112631
|
+
extraProps,
|
|
112632
|
+
dataComponent,
|
|
112633
|
+
itemScopedSlots
|
|
112634
|
+
} = this;
|
|
112635
|
+
const slotComponent = this.$scopedSlots && this.$scopedSlots.item;
|
|
112636
|
+
for (let index = start; index <= end; index++) {
|
|
112637
|
+
const dataSource = dataSources[index];
|
|
112638
|
+
if (dataSource) {
|
|
112639
|
+
const uniqueKey = typeof dataKey === 'function' ? dataKey(dataSource) : dataSource[dataKey];
|
|
112640
|
+
if (typeof uniqueKey === 'string' || typeof uniqueKey === 'number') {
|
|
112641
|
+
slots.push(h(virtualListItem, {
|
|
112642
|
+
props: {
|
|
112643
|
+
index,
|
|
112644
|
+
tag: itemTag,
|
|
112645
|
+
event: EVENT_TYPE.ITEM,
|
|
112646
|
+
horizontal: isHorizontal,
|
|
112647
|
+
uniqueKey: uniqueKey,
|
|
112648
|
+
source: dataSource,
|
|
112649
|
+
extraProps: extraProps,
|
|
112650
|
+
component: dataComponent,
|
|
112651
|
+
slotComponent: slotComponent,
|
|
112652
|
+
scopedSlots: itemScopedSlots
|
|
112653
|
+
},
|
|
112654
|
+
style: itemStyle,
|
|
112655
|
+
class: `${itemClass}${this.itemClassAdd ? ' ' + this.itemClassAdd(index) : ''}`
|
|
112656
|
+
}));
|
|
112657
|
+
} else {
|
|
112658
|
+
console.warn(`Cannot get the data-key '${dataKey}' from data-sources.`);
|
|
112659
|
+
}
|
|
112660
|
+
} else {
|
|
112661
|
+
console.warn(`Cannot get the index '${index}' from data-sources.`);
|
|
112662
|
+
}
|
|
112663
|
+
}
|
|
112664
|
+
return slots;
|
|
112665
|
+
}
|
|
112666
|
+
},
|
|
112667
|
+
// render function, a closer-to-the-compiler alternative to templates
|
|
112668
|
+
// https://vuejs.org/v2/guide/render-function.html#The-Data-Object-In-Depth
|
|
112669
|
+
render(h) {
|
|
112670
|
+
const {
|
|
112671
|
+
header,
|
|
112672
|
+
footer
|
|
112673
|
+
} = this.$slots;
|
|
112674
|
+
const {
|
|
112675
|
+
padFront,
|
|
112676
|
+
padBehind
|
|
112677
|
+
} = this.range;
|
|
112678
|
+
const {
|
|
112679
|
+
isHorizontal,
|
|
112680
|
+
pageMode,
|
|
112681
|
+
rootTag,
|
|
112682
|
+
wrapTag,
|
|
112683
|
+
wrapClass,
|
|
112684
|
+
wrapStyle,
|
|
112685
|
+
headerTag,
|
|
112686
|
+
headerClass,
|
|
112687
|
+
headerStyle,
|
|
112688
|
+
footerTag,
|
|
112689
|
+
footerClass,
|
|
112690
|
+
footerStyle
|
|
112691
|
+
} = this;
|
|
112692
|
+
const paddingStyle = {
|
|
112693
|
+
padding: isHorizontal ? `0px ${padBehind}px 0px ${padFront}px` : `${padFront}px 0px ${padBehind}px`
|
|
112694
|
+
};
|
|
112695
|
+
const wrapperStyle = wrapStyle ? Object.assign({}, wrapStyle, paddingStyle) : paddingStyle;
|
|
112696
|
+
return h(rootTag, {
|
|
112697
|
+
ref: 'root',
|
|
112698
|
+
on: {
|
|
112699
|
+
'&scroll': !pageMode && this.onScroll
|
|
112700
|
+
}
|
|
112701
|
+
}, [
|
|
112702
|
+
// header slot
|
|
112703
|
+
header ? h(Slot, {
|
|
112704
|
+
class: headerClass,
|
|
112705
|
+
style: headerStyle,
|
|
112706
|
+
props: {
|
|
112707
|
+
tag: headerTag,
|
|
112708
|
+
event: EVENT_TYPE.SLOT,
|
|
112709
|
+
uniqueKey: SLOT_TYPE.HEADER
|
|
112710
|
+
}
|
|
112711
|
+
}, header) : null,
|
|
112712
|
+
// main list
|
|
112713
|
+
h(wrapTag, {
|
|
112714
|
+
class: wrapClass,
|
|
112715
|
+
attrs: {
|
|
112716
|
+
role: 'group'
|
|
112717
|
+
},
|
|
112718
|
+
style: wrapperStyle
|
|
112719
|
+
}, this.getRenderSlots(h)),
|
|
112720
|
+
// footer slot
|
|
112721
|
+
footer ? h(Slot, {
|
|
112722
|
+
class: footerClass,
|
|
112723
|
+
style: footerStyle,
|
|
112724
|
+
props: {
|
|
112725
|
+
tag: footerTag,
|
|
112726
|
+
event: EVENT_TYPE.SLOT,
|
|
112727
|
+
uniqueKey: SLOT_TYPE.FOOTER
|
|
112728
|
+
}
|
|
112729
|
+
}, footer) : null,
|
|
112730
|
+
// an empty element use to scroll to bottom
|
|
112731
|
+
h('div', {
|
|
112732
|
+
ref: 'shepherd',
|
|
112733
|
+
style: {
|
|
112734
|
+
width: isHorizontal ? '0px' : '100%',
|
|
112735
|
+
height: isHorizontal ? '100%' : '0px'
|
|
112736
|
+
}
|
|
112737
|
+
})]);
|
|
112738
|
+
}
|
|
112739
|
+
};
|
|
112740
|
+
/* harmony default export */ var components_VirtualList = (VirtualList);
|
|
111597
112741
|
;// CONCATENATED MODULE: ./src/main.js
|
|
111598
112742
|
|
|
111599
112743
|
const version = (__webpack_require__(4147)/* .version */ .i8);
|
|
@@ -111603,6 +112747,7 @@ console.log("version:", version);
|
|
|
111603
112747
|
|
|
111604
112748
|
|
|
111605
112749
|
|
|
112750
|
+
|
|
111606
112751
|
const main_components = [layoutForPaper, Container, layoutItem["default"]];
|
|
111607
112752
|
const install = function (Vue, opts = {}) {
|
|
111608
112753
|
Vue.prototype = Object.assign(Vue.prototype, opts);
|
|
@@ -111610,6 +112755,7 @@ const install = function (Vue, opts = {}) {
|
|
|
111610
112755
|
main_components.forEach(component => {
|
|
111611
112756
|
Vue.component(component.name, component);
|
|
111612
112757
|
});
|
|
112758
|
+
Vue.component('virtual-list', components_VirtualList);
|
|
111613
112759
|
};
|
|
111614
112760
|
if (typeof window !== 'undefined' && window.Vue) {
|
|
111615
112761
|
install(window.Vue);
|