@luzhaoqi/test 0.0.14 → 0.0.16

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.
Files changed (2) hide show
  1. package/dist/lib-cjs.js +1340 -84
  2. package/package.json +1 -1
package/dist/lib-cjs.js CHANGED
@@ -17506,9 +17506,8 @@ const localCache = {
17506
17506
  function query() {
17507
17507
  const obj = {};
17508
17508
  if (this.queryParams && this.queryParams.constructor === Object) {
17509
- const queryParams = this._.cloneDeep(this.queryParams);
17509
+ const queryParams = _.cloneDeep(this.queryParams);
17510
17510
  Object.keys(queryParams).forEach((item) => {
17511
- console.log(item);
17512
17511
  if (item.startsWith('$')) {
17513
17512
  delete queryParams[item];
17514
17513
  }
@@ -17517,7 +17516,7 @@ function query() {
17517
17516
  }
17518
17517
 
17519
17518
  if (this.pageParams && this.pageParams.constructor === Object) {
17520
- const pageParams = this._.cloneDeep(this.pageParams);
17519
+ const pageParams = _.cloneDeep(this.pageParams);
17521
17520
  delete pageParams.total;
17522
17521
  Object.assign(obj, pageParams);
17523
17522
  }
@@ -17593,7 +17592,7 @@ var variables = {"menuColor":"#bfcbd9","menuLightColor":"rgba(0, 0, 0, 0.7)","me
17593
17592
 
17594
17593
  // import Item from './Item.vue'
17595
17594
 
17596
- var script = {
17595
+ var script$3 = {
17597
17596
  name: 'k-icon',
17598
17597
  data() {
17599
17598
  return {
@@ -17702,10 +17701,10 @@ var normalizeComponent_1 = normalizeComponent;
17702
17701
  var __vue_normalize__ = /*@__PURE__*/getDefaultExportFromCjs(normalizeComponent_1);
17703
17702
 
17704
17703
  /* script */
17705
- const __vue_script__ = script;
17704
+ const __vue_script__$3 = script$3;
17706
17705
 
17707
17706
  /* template */
17708
- var __vue_render__ = function () {
17707
+ var __vue_render__$3 = function () {
17709
17708
  var _vm = this;
17710
17709
  var _h = _vm.$createElement;
17711
17710
  var _c = _vm._self._c || _h;
@@ -17717,17 +17716,17 @@ var __vue_render__ = function () {
17717
17716
  _vm._v("\n " + _vm._s(_vm.variables) + "\n"),
17718
17717
  ])
17719
17718
  };
17720
- var __vue_staticRenderFns__ = [];
17721
- __vue_render__._withStripped = true;
17719
+ var __vue_staticRenderFns__$3 = [];
17720
+ __vue_render__$3._withStripped = true;
17722
17721
 
17723
17722
  /* style */
17724
- const __vue_inject_styles__ = undefined;
17723
+ const __vue_inject_styles__$3 = undefined;
17725
17724
  /* scoped */
17726
- const __vue_scope_id__ = undefined;
17725
+ const __vue_scope_id__$3 = undefined;
17727
17726
  /* module identifier */
17728
- const __vue_module_identifier__ = undefined;
17727
+ const __vue_module_identifier__$3 = undefined;
17729
17728
  /* functional template */
17730
- const __vue_is_functional_template__ = false;
17729
+ const __vue_is_functional_template__$3 = false;
17731
17730
  /* style inject */
17732
17731
 
17733
17732
  /* style inject SSR */
@@ -17736,22 +17735,22 @@ __vue_render__._withStripped = true;
17736
17735
 
17737
17736
 
17738
17737
 
17739
- const __vue_component__ = /*#__PURE__*/__vue_normalize__(
17740
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
17741
- __vue_inject_styles__,
17742
- __vue_script__,
17743
- __vue_scope_id__,
17744
- __vue_is_functional_template__,
17745
- __vue_module_identifier__,
17738
+ const __vue_component__$3 = /*#__PURE__*/__vue_normalize__(
17739
+ { render: __vue_render__$3, staticRenderFns: __vue_staticRenderFns__$3 },
17740
+ __vue_inject_styles__$3,
17741
+ __vue_script__$3,
17742
+ __vue_scope_id__$3,
17743
+ __vue_is_functional_template__$3,
17744
+ __vue_module_identifier__$3,
17746
17745
  false,
17747
17746
  undefined,
17748
17747
  undefined,
17749
17748
  undefined
17750
17749
  );
17751
17750
 
17752
- __vue_component__.install = function (Vue, option) {
17751
+ __vue_component__$3.install = function (Vue, option) {
17753
17752
  setGolbalData(Vue, option);
17754
- Vue.component(__vue_component__.name, __vue_component__);
17753
+ Vue.component(__vue_component__$3.name, __vue_component__$3);
17755
17754
  };
17756
17755
 
17757
17756
  var axios$3 = {exports: {}};
@@ -18869,7 +18868,7 @@ var followRedirects = {exports: {}};
18869
18868
 
18870
18869
  var src = {exports: {}};
18871
18870
 
18872
- var browser = {exports: {}};
18871
+ var browser$1 = {exports: {}};
18873
18872
 
18874
18873
  /**
18875
18874
  * Helpers.
@@ -19329,7 +19328,7 @@ function requireCommon () {
19329
19328
  var hasRequiredBrowser;
19330
19329
 
19331
19330
  function requireBrowser () {
19332
- if (hasRequiredBrowser) return browser.exports;
19331
+ if (hasRequiredBrowser) return browser$1.exports;
19333
19332
  hasRequiredBrowser = 1;
19334
19333
  (function (module, exports) {
19335
19334
  /**
@@ -19599,8 +19598,8 @@ function requireBrowser () {
19599
19598
  return '[UnexpectedJSONParseError]: ' + error.message;
19600
19599
  }
19601
19600
  };
19602
- } (browser, browser.exports));
19603
- return browser.exports;
19601
+ } (browser$1, browser$1.exports));
19602
+ return browser$1.exports;
19604
19603
  }
19605
19604
 
19606
19605
  var node = {exports: {}};
@@ -93894,14 +93893,14 @@ function createAxios(Vue) {
93894
93893
  }
93895
93894
  }
93896
93895
 
93897
- function install$2(Vue, option = {}) {
93896
+ function install$3(Vue, option = {}) {
93898
93897
  setGolbalData(Vue, option);
93899
93898
  const $http = createAxios(Vue);
93900
93899
  Vue.prototype.$z.$http = $http;
93901
93900
  }
93902
93901
 
93903
93902
  var RequestZ = {
93904
- install: install$2
93903
+ install: install$3
93905
93904
  };
93906
93905
 
93907
93906
  var nprogress = {exports: {}};
@@ -94404,89 +94403,1342 @@ function chuli(arr) {
94404
94403
  }
94405
94404
 
94406
94405
  function createRouter(Vue) {
94407
- console.log(Vue._installedPlugins);
94408
-
94406
+ // 判断是否已经use过VueRouter
94409
94407
  const VueRouterObj = Vue._installedPlugins.filter((item) => {
94410
94408
  return item.name === 'VueRouter'
94411
94409
  });
94412
- if (VueRouterObj && VueRouterObj[0]) {
94413
- console.log(111111);
94414
- } else {
94415
- console.log(22222);
94410
+ if (!(VueRouterObj && VueRouterObj[0])) {
94416
94411
  Vue.use(VueRouter);
94417
- }
94418
- console.log(VueRouterObj);
94419
- console.log(33333);
94420
- const $z = Vue.prototype.$z;
94421
- if ($z.router) {
94422
- const defaultConfig = {
94423
- mode: 'history', // 去掉url中的#
94424
- scrollBehavior: () => ({ y: 0 }),
94425
- routes: []
94426
- };
94427
- const routerOption = $z.router || {};
94428
- let { beforeEach, afterEach, whiteList } = routerOption;
94429
- delete $z.router.beforeEach;
94430
- delete $z.router.afterEach;
94431
- Object.assign(defaultConfig, routerOption);
94432
- chuli(defaultConfig.routes);
94433
- const router = new VueRouter(defaultConfig);
94434
- router.beforeEach((to, from, next) => {
94435
- if (beforeEach) {
94436
- beforeEach(to, from, next);
94437
- } else {
94438
- NProgress.start();
94439
- const httpOption = $z.http || {};
94440
- const token = getCookie(httpOption.tokenKey || 'Admin-Token');
94441
- if (!whiteList) {
94442
- whiteList = ['/login', '/register'];
94443
- }
94444
- if (token) {
94445
- if (to.path === '/login') {
94446
- next({ path: '/' });
94447
- NProgress.done();
94412
+ const $z = Vue.prototype.$z;
94413
+ if ($z.router) {
94414
+ const defaultConfig = {
94415
+ mode: 'history', // 去掉url中的#
94416
+ scrollBehavior: () => ({ y: 0 }),
94417
+ routes: []
94418
+ };
94419
+ const routerOption = $z.router || {};
94420
+ let { beforeEach, afterEach, whiteList } = routerOption;
94421
+ delete $z.router.beforeEach;
94422
+ delete $z.router.afterEach;
94423
+ Object.assign(defaultConfig, routerOption);
94424
+ chuli(defaultConfig.routes);
94425
+ const router = new VueRouter(defaultConfig);
94426
+ router.beforeEach((to, from, next) => {
94427
+ if (beforeEach) {
94428
+ beforeEach(to, from, next);
94429
+ } else {
94430
+ NProgress.start();
94431
+ const httpOption = $z.http || {};
94432
+ const token = getCookie(httpOption.tokenKey || 'Admin-Token');
94433
+ if (!whiteList) {
94434
+ whiteList = ['/login', '/register'];
94435
+ }
94436
+ if (token) {
94437
+ if (to.path === '/login') {
94438
+ next({ path: '/' });
94439
+ NProgress.done();
94440
+ } else {
94441
+ // 判断是不是第一次 需要动态加载路由
94442
+ {
94443
+ next();
94444
+ }
94445
+ }
94448
94446
  } else {
94449
- // 判断是不是第一次 需要动态加载路由
94450
- {
94447
+ // 没有token
94448
+ if (whiteList.indexOf(to.path) !== -1) {
94449
+ // 在免登录白名单,直接进入
94451
94450
  next();
94451
+ } else {
94452
+ next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
94453
+ NProgress.done();
94452
94454
  }
94453
94455
  }
94454
- } else {
94455
- // 没有token
94456
- if (whiteList.indexOf(to.path) !== -1) {
94457
- // 在免登录白名单,直接进入
94458
- next();
94459
- } else {
94460
- next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
94461
- NProgress.done();
94462
- }
94463
94456
  }
94457
+ });
94458
+ router.afterEach(() => {
94459
+ if (afterEach) {
94460
+ afterEach();
94461
+ }
94462
+ NProgress.done();
94463
+ });
94464
+
94465
+ Vue.prototype.$z.router = router;
94466
+ }
94467
+ }
94468
+ }
94469
+
94470
+ function install$2(Vue, option = {}) {
94471
+ setGolbalData(Vue, option);
94472
+ createRouter(Vue);
94473
+ }
94474
+
94475
+ var RouterZ = {
94476
+ install: install$2
94477
+ };
94478
+
94479
+ //
94480
+ //
94481
+ //
94482
+ //
94483
+ //
94484
+ //
94485
+ //
94486
+ //
94487
+ //
94488
+ //
94489
+ //
94490
+ //
94491
+ //
94492
+ //
94493
+ //
94494
+ //
94495
+ //
94496
+ //
94497
+ //
94498
+ //
94499
+ //
94500
+ //
94501
+ //
94502
+ //
94503
+ //
94504
+ //
94505
+ //
94506
+ //
94507
+ //
94508
+ //
94509
+ //
94510
+ //
94511
+ //
94512
+ //
94513
+ //
94514
+ //
94515
+ //
94516
+ //
94517
+ //
94518
+ //
94519
+ //
94520
+ //
94521
+ //
94522
+ //
94523
+ //
94524
+ //
94525
+ //
94526
+ //
94527
+ //
94528
+ //
94529
+ //
94530
+ //
94531
+ //
94532
+ //
94533
+ //
94534
+ //
94535
+ //
94536
+ //
94537
+ //
94538
+ //
94539
+ //
94540
+ //
94541
+ //
94542
+ //
94543
+ //
94544
+ //
94545
+ //
94546
+ //
94547
+
94548
+ var script$2 = {
94549
+ name: 'z-table',
94550
+ computed: {
94551
+ globalConfig() {
94552
+ if (!this.pageParamsConfig.isDefault) {
94553
+ return this.pageParamsConfig
94554
+ } else if (this.$z.list) {
94555
+ return this.$z.list
94556
+ }
94557
+ return this.pageParamsConfig
94558
+ }
94559
+ },
94560
+ props: {
94561
+ // 表格配置
94562
+ tableOption: {
94563
+ type: Object,
94564
+ required: true,
94565
+ default() {
94566
+ return {
94567
+ api: function () {
94568
+ return Promise.resolve()
94569
+ },
94570
+ column: []
94571
+ }
94572
+ }
94573
+ },
94574
+ // 表格数据
94575
+ tableData: {
94576
+ type: Array,
94577
+ default: () => {
94578
+ return []
94579
+ }
94580
+ },
94581
+ // 页码配置
94582
+ pageParamsConfig: {
94583
+ type: Object,
94584
+ default: () => {
94585
+ return {
94586
+ pageSize: 'pageSize',
94587
+ pageNum: 'pageNum',
94588
+ isDefault: true
94589
+ }
94590
+ }
94591
+ },
94592
+ // 页码参数
94593
+ pageParams: {
94594
+ type: Object,
94595
+ default: () => {
94596
+ return {
94597
+ pageSize: 10,
94598
+ pageNum: 1
94599
+ }
94600
+ }
94601
+ },
94602
+ total: {
94603
+ type: Number,
94604
+ default: 0
94605
+ },
94606
+ // 禁用
94607
+ disabled: {
94608
+ type: Boolean,
94609
+ default: () => false
94610
+ },
94611
+ // 等待
94612
+ loading: {
94613
+ type: Boolean,
94614
+ default: () => false
94615
+ }
94616
+ },
94617
+ methods: {
94618
+ // 计算序号
94619
+ getIndex(index) {
94620
+ return index + 1 + (this.pageParams[this.globalConfig.pageNum] - 1) * this.pageParams[this.globalConfig.pageSize]
94621
+ },
94622
+ // 分数数量改变
94623
+ handleSizeChange() {
94624
+ this.pageParams[this.globalConfig.pageNum] = 1;
94625
+ this.$emit('getData');
94626
+ },
94627
+ // 页码改变
94628
+ handleCurrentChange() {
94629
+ this.$emit('getData');
94630
+ }
94631
+ }
94632
+ };
94633
+
94634
+ var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
94635
+ function createInjector(context) {
94636
+ return function (id, style) {
94637
+ return addStyle(id, style);
94638
+ };
94639
+ }
94640
+ var HEAD;
94641
+ var styles = {};
94642
+
94643
+ function addStyle(id, css) {
94644
+ var group = isOldIE ? css.media || 'default' : id;
94645
+ var style = styles[group] || (styles[group] = {
94646
+ ids: new Set(),
94647
+ styles: []
94648
+ });
94649
+
94650
+ if (!style.ids.has(id)) {
94651
+ style.ids.add(id);
94652
+ var code = css.source;
94653
+
94654
+ if (css.map) {
94655
+ // https://developer.chrome.com/devtools/docs/javascript-debugging
94656
+ // this makes source maps inside style tags work properly in Chrome
94657
+ code += '\n/*# sourceURL=' + css.map.sources[0] + ' */'; // http://stackoverflow.com/a/26603875
94658
+
94659
+ code += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) + ' */';
94660
+ }
94661
+
94662
+ if (!style.element) {
94663
+ style.element = document.createElement('style');
94664
+ style.element.type = 'text/css';
94665
+ if (css.media) style.element.setAttribute('media', css.media);
94666
+
94667
+ if (HEAD === undefined) {
94668
+ HEAD = document.head || document.getElementsByTagName('head')[0];
94669
+ }
94670
+
94671
+ HEAD.appendChild(style.element);
94672
+ }
94673
+
94674
+ if ('styleSheet' in style.element) {
94675
+ style.styles.push(code);
94676
+ style.element.styleSheet.cssText = style.styles.filter(Boolean).join('\n');
94677
+ } else {
94678
+ var index = style.ids.size - 1;
94679
+ var textNode = document.createTextNode(code);
94680
+ var nodes = style.element.childNodes;
94681
+ if (nodes[index]) style.element.removeChild(nodes[index]);
94682
+ if (nodes.length) style.element.insertBefore(textNode, nodes[index]);else style.element.appendChild(textNode);
94683
+ }
94684
+ }
94685
+ }
94686
+
94687
+ var browser = createInjector;
94688
+
94689
+
94690
+ var __vue_create_injector__ = /*@__PURE__*/getDefaultExportFromCjs(browser);
94691
+
94692
+ /* script */
94693
+ const __vue_script__$2 = script$2;
94694
+
94695
+ /* template */
94696
+ var __vue_render__$2 = function () {
94697
+ var _vm = this;
94698
+ var _h = _vm.$createElement;
94699
+ var _c = _vm._self._c || _h;
94700
+ return _c(
94701
+ "div",
94702
+ { staticClass: "z-table-comp" },
94703
+ [
94704
+ _vm.$slots.leftMenu || _vm.$slots.rightMenu
94705
+ ? _c("div", { staticClass: "z-table-header-btn-group" }, [
94706
+ _c("div", { staticClass: "leftMenu" }, [_vm._t("leftMenu")], 2),
94707
+ _vm._v(" "),
94708
+ _c("div", { staticClass: "rightMenu" }, [_vm._t("rightMenu")], 2),
94709
+ ])
94710
+ : _vm._e(),
94711
+ _vm._v(" "),
94712
+ _c(
94713
+ "el-table",
94714
+ {
94715
+ directives: [
94716
+ {
94717
+ name: "loading",
94718
+ rawName: "v-loading",
94719
+ value: _vm.loading,
94720
+ expression: "loading",
94721
+ },
94722
+ ],
94723
+ ref: "table",
94724
+ attrs: { data: _vm.tableData, border: _vm.tableOption.border },
94725
+ },
94726
+ [
94727
+ _vm._l(_vm.tableOption.column, function (o, i) {
94728
+ return [
94729
+ o.type && !o.prop
94730
+ ? _c("el-table-column", {
94731
+ key: "item" + i,
94732
+ attrs: {
94733
+ type: o.type,
94734
+ width: o.width || 60,
94735
+ label: o.label,
94736
+ index: _vm.getIndex(i),
94737
+ align: o.align || "center",
94738
+ },
94739
+ })
94740
+ : o.slot && o.prop === "menu"
94741
+ ? _c("el-table-column", {
94742
+ key: "item" + i,
94743
+ attrs: {
94744
+ align: o.align || "center",
94745
+ label: o.label,
94746
+ width: o.width || null,
94747
+ },
94748
+ scopedSlots: _vm._u(
94749
+ [
94750
+ {
94751
+ key: "default",
94752
+ fn: function (ref) {
94753
+ var row = ref.row;
94754
+ var $index = ref.$index;
94755
+ return [
94756
+ _c(
94757
+ "div",
94758
+ { staticClass: "btn-box" },
94759
+ [
94760
+ _vm._t(o.prop, null, {
94761
+ row: row,
94762
+ $index: $index,
94763
+ }),
94764
+ ],
94765
+ 2
94766
+ ),
94767
+ ]
94768
+ },
94769
+ },
94770
+ ],
94771
+ null,
94772
+ true
94773
+ ),
94774
+ })
94775
+ : o.slot
94776
+ ? _c("el-table-column", {
94777
+ key: "item" + i,
94778
+ attrs: {
94779
+ align: o.align || "center",
94780
+ label: o.label,
94781
+ width: o.width || null,
94782
+ },
94783
+ scopedSlots: _vm._u(
94784
+ [
94785
+ {
94786
+ key: "default",
94787
+ fn: function (ref) {
94788
+ var row = ref.row;
94789
+ var $index = ref.$index;
94790
+ return [
94791
+ _c(
94792
+ "div",
94793
+ { staticClass: "z-cell" },
94794
+ [
94795
+ _vm._t(o.prop, null, {
94796
+ row: row,
94797
+ $index: $index,
94798
+ }),
94799
+ ],
94800
+ 2
94801
+ ),
94802
+ ]
94803
+ },
94804
+ },
94805
+ ],
94806
+ null,
94807
+ true
94808
+ ),
94809
+ })
94810
+ : _c("el-table-column", {
94811
+ key: "item" + i,
94812
+ attrs: {
94813
+ align: o.align || "center",
94814
+ label: o.label,
94815
+ prop: o.prop,
94816
+ width: o.width || null,
94817
+ },
94818
+ }),
94819
+ ]
94820
+ }),
94821
+ ],
94822
+ 2
94823
+ ),
94824
+ _vm._v(" "),
94825
+ _vm.tableOption.pagination || _vm.tableOption.pagination === undefined
94826
+ ? _c(
94827
+ "div",
94828
+ { staticClass: "pagination-box" },
94829
+ [
94830
+ _c("el-pagination", {
94831
+ attrs: {
94832
+ background: "",
94833
+ "page-sizes": [10, 20, 30, 40, 50, 100],
94834
+ "page-size": _vm.pageParams[_vm.globalConfig.pageSize],
94835
+ "current-page": _vm.pageParams[_vm.globalConfig.pageNum],
94836
+ layout: "total, sizes, prev, pager, next, jumper",
94837
+ total: _vm.total,
94838
+ },
94839
+ on: {
94840
+ "size-change": _vm.handleSizeChange,
94841
+ "current-change": _vm.handleCurrentChange,
94842
+ "update:pageSize": function ($event) {
94843
+ return _vm.$set(
94844
+ _vm.pageParams,
94845
+ _vm.globalConfig.pageSize,
94846
+ $event
94847
+ )
94848
+ },
94849
+ "update:page-size": function ($event) {
94850
+ return _vm.$set(
94851
+ _vm.pageParams,
94852
+ _vm.globalConfig.pageSize,
94853
+ $event
94854
+ )
94855
+ },
94856
+ "update:currentPage": function ($event) {
94857
+ return _vm.$set(
94858
+ _vm.pageParams,
94859
+ _vm.globalConfig.pageNum,
94860
+ $event
94861
+ )
94862
+ },
94863
+ "update:current-page": function ($event) {
94864
+ return _vm.$set(
94865
+ _vm.pageParams,
94866
+ _vm.globalConfig.pageNum,
94867
+ $event
94868
+ )
94869
+ },
94870
+ },
94871
+ }),
94872
+ ],
94873
+ 1
94874
+ )
94875
+ : _vm._e(),
94876
+ ],
94877
+ 1
94878
+ )
94879
+ };
94880
+ var __vue_staticRenderFns__$2 = [];
94881
+ __vue_render__$2._withStripped = true;
94882
+
94883
+ /* style */
94884
+ const __vue_inject_styles__$2 = function (inject) {
94885
+ if (!inject) return
94886
+ inject("data-v-7bdbe6c8_0", { source: ".z-table-comp .z-table-header-btn-group[data-v-7bdbe6c8] {\n padding-bottom: 10px;\n display: flex;\n}\n.z-table-comp .z-table-header-btn-group .leftMenu[data-v-7bdbe6c8] {\n flex: 1;\n margin-right: 20px;\n}\n.z-table-comp .btn-box[data-v-7bdbe6c8] {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n}\n.z-table-comp .btn-box[data-v-7bdbe6c8] .el-button {\n padding: 0 !important;\n}\n.z-table-comp .pagination-box[data-v-7bdbe6c8] {\n text-align: right;\n}\n.z-table-comp .pagination-box[data-v-7bdbe6c8] .el-pagination {\n margin-top: 25px;\n}\n\n/*# sourceMappingURL=table.vue.map */", map: {"version":3,"sources":["D:\\workspace-my\\gitee\\rollup-demo\\lib\\packages\\table\\table.vue","table.vue"],"names":[],"mappings":"AA8JA;EACA,oBAAA;EACA,aAAA;AC7JA;AD8JA;EACA,OAAA;EACA,kBAAA;AC5JA;AD+JA;EACA,aAAA;EACA,mBAAA;EACA,uBAAA;EACA,WAAA;AC7JA;AD8JA;EACA,qBAAA;AC5JA;AD+JA;EACA,iBAAA;AC7JA;AD8JA;EACA,gBAAA;AC5JA;;AAEA,oCAAoC","file":"table.vue","sourcesContent":["<template>\r\n <div class=\"z-table-comp\">\r\n <!-- 头部按钮-->\r\n <div class=\"z-table-header-btn-group\" v-if=\"$slots.leftMenu || $slots.rightMenu\">\r\n <div class=\"leftMenu\">\r\n <slot name=\"leftMenu\"></slot>\r\n </div>\r\n <div class=\"rightMenu\">\r\n <slot name=\"rightMenu\"></slot>\r\n </div>\r\n </div>\r\n <!-- 表格 -->\r\n <el-table v-loading=\"loading\" :data=\"tableData\" ref=\"table\" :border=\"tableOption.border\">\r\n <template v-for=\"(o, i) in tableOption.column\">\r\n <!-- 序号和选中 -->\r\n <el-table-column\r\n :key=\"'item' + i\"\r\n v-if=\"o.type && !o.prop\"\r\n :type=\"o.type\"\r\n :width=\"o.width || 60\"\r\n :label=\"o.label\"\r\n :index=\"getIndex(i)\"\r\n :align=\"o.align || 'center'\"\r\n />\r\n <!-- 操作按钮 -->\r\n <el-table-column\r\n :align=\"o.align || 'center'\"\r\n :key=\"'item' + i\"\r\n v-else-if=\"o.slot && o.prop === 'menu'\"\r\n :label=\"o.label\"\r\n :width=\"o.width || null\"\r\n >\r\n <template #default=\"{ row, $index }\">\r\n <div class=\"btn-box\">\r\n <slot :name=\"o.prop\" :row=\"row\" :$index=\"$index\"></slot>\r\n </div>\r\n </template>\r\n </el-table-column>\r\n <!-- 插槽 -->\r\n <el-table-column :align=\"o.align || 'center'\" :key=\"'item' + i\" v-else-if=\"o.slot\" :label=\"o.label\" :width=\"o.width || null\">\r\n <template #default=\"{ row, $index }\">\r\n <div class=\"z-cell\">\r\n <slot :name=\"o.prop\" :row=\"row\" :$index=\"$index\"></slot>\r\n </div>\r\n </template>\r\n </el-table-column>\r\n <!-- 针对其他默认情况 -->\r\n <el-table-column :align=\"o.align || 'center'\" :key=\"'item' + i\" v-else :label=\"o.label\" :prop=\"o.prop\" :width=\"o.width || null\">\r\n </el-table-column>\r\n </template>\r\n </el-table>\r\n <div class=\"pagination-box\" v-if=\"tableOption.pagination || tableOption.pagination === undefined\">\r\n <!-- hide-on-single-page-->\r\n <el-pagination\r\n background\r\n @size-change=\"handleSizeChange\"\r\n @current-change=\"handleCurrentChange\"\r\n :page-sizes=\"[10, 20, 30, 40, 50, 100]\"\r\n :page-size.sync=\"pageParams[globalConfig.pageSize]\"\r\n :current-page.sync=\"pageParams[globalConfig.pageNum]\"\r\n layout=\"total, sizes, prev, pager, next, jumper\"\r\n :total=\"total\"\r\n >\r\n </el-pagination>\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script>\r\nexport default {\r\n name: 'z-table',\r\n computed: {\r\n globalConfig() {\r\n if (!this.pageParamsConfig.isDefault) {\r\n return this.pageParamsConfig\r\n } else if (this.$z.list) {\r\n return this.$z.list\r\n }\r\n return this.pageParamsConfig\r\n }\r\n },\r\n props: {\r\n // 表格配置\r\n tableOption: {\r\n type: Object,\r\n required: true,\r\n default() {\r\n return {\r\n api: function () {\r\n return Promise.resolve()\r\n },\r\n column: []\r\n }\r\n }\r\n },\r\n // 表格数据\r\n tableData: {\r\n type: Array,\r\n default: () => {\r\n return []\r\n }\r\n },\r\n // 页码配置\r\n pageParamsConfig: {\r\n type: Object,\r\n default: () => {\r\n return {\r\n pageSize: 'pageSize',\r\n pageNum: 'pageNum',\r\n isDefault: true\r\n }\r\n }\r\n },\r\n // 页码参数\r\n pageParams: {\r\n type: Object,\r\n default: () => {\r\n return {\r\n pageSize: 10,\r\n pageNum: 1\r\n }\r\n }\r\n },\r\n total: {\r\n type: Number,\r\n default: 0\r\n },\r\n // 禁用\r\n disabled: {\r\n type: Boolean,\r\n default: () => false\r\n },\r\n // 等待\r\n loading: {\r\n type: Boolean,\r\n default: () => false\r\n }\r\n },\r\n methods: {\r\n // 计算序号\r\n getIndex(index) {\r\n return index + 1 + (this.pageParams[this.globalConfig.pageNum] - 1) * this.pageParams[this.globalConfig.pageSize]\r\n },\r\n // 分数数量改变\r\n handleSizeChange() {\r\n this.pageParams[this.globalConfig.pageNum] = 1\r\n this.$emit('getData')\r\n },\r\n // 页码改变\r\n handleCurrentChange() {\r\n this.$emit('getData')\r\n }\r\n }\r\n}\r\n</script>\r\n\r\n<style scoped lang=\"scss\">\r\n.z-table-comp {\r\n .z-table-header-btn-group {\r\n padding-bottom: 10px;\r\n display: flex;\r\n .leftMenu {\r\n flex: 1;\r\n margin-right: 20px;\r\n }\r\n }\r\n .btn-box {\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 100%;\r\n ::v-deep .el-button {\r\n padding: 0 !important;\r\n }\r\n }\r\n .pagination-box {\r\n text-align: right;\r\n ::v-deep .el-pagination {\r\n margin-top: 25px;\r\n }\r\n }\r\n}\r\n</style>\r\n",".z-table-comp .z-table-header-btn-group {\n padding-bottom: 10px;\n display: flex;\n}\n.z-table-comp .z-table-header-btn-group .leftMenu {\n flex: 1;\n margin-right: 20px;\n}\n.z-table-comp .btn-box {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n}\n.z-table-comp .btn-box ::v-deep .el-button {\n padding: 0 !important;\n}\n.z-table-comp .pagination-box {\n text-align: right;\n}\n.z-table-comp .pagination-box ::v-deep .el-pagination {\n margin-top: 25px;\n}\n\n/*# sourceMappingURL=table.vue.map */"]}, media: undefined });
94887
+
94888
+ };
94889
+ /* scoped */
94890
+ const __vue_scope_id__$2 = "data-v-7bdbe6c8";
94891
+ /* module identifier */
94892
+ const __vue_module_identifier__$2 = undefined;
94893
+ /* functional template */
94894
+ const __vue_is_functional_template__$2 = false;
94895
+ /* style inject SSR */
94896
+
94897
+ /* style inject shadow dom */
94898
+
94899
+
94900
+
94901
+ const __vue_component__$2 = /*#__PURE__*/__vue_normalize__(
94902
+ { render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 },
94903
+ __vue_inject_styles__$2,
94904
+ __vue_script__$2,
94905
+ __vue_scope_id__$2,
94906
+ __vue_is_functional_template__$2,
94907
+ __vue_module_identifier__$2,
94908
+ false,
94909
+ __vue_create_injector__,
94910
+ undefined,
94911
+ undefined
94912
+ );
94913
+
94914
+ __vue_component__$2.install = function (Vue, option = {}) {
94915
+ setGolbalData(Vue, option);
94916
+ Vue.component(__vue_component__$2.name, __vue_component__$2);
94917
+ };
94918
+
94919
+ //
94920
+ //
94921
+ //
94922
+ //
94923
+ //
94924
+ //
94925
+ //
94926
+ //
94927
+ //
94928
+ //
94929
+ //
94930
+ //
94931
+ //
94932
+ //
94933
+ //
94934
+ //
94935
+ //
94936
+ //
94937
+ //
94938
+ //
94939
+ //
94940
+ //
94941
+ //
94942
+ //
94943
+
94944
+ var script$1 = {
94945
+ name: 'z-list',
94946
+ props: {
94947
+ // 表格配置
94948
+ tableOption: {
94949
+ type: Object,
94950
+ required: true,
94951
+ default() {
94952
+ return {
94953
+ api: function () {
94954
+ return Promise.resolve()
94955
+ },
94956
+ column: []
94957
+ }
94958
+ }
94959
+ }
94960
+ },
94961
+ computed: {
94962
+ slotArr() {
94963
+ let arr = this.tableOption.column || [];
94964
+ arr = arr.filter((item) => {
94965
+ return item.slot
94966
+ });
94967
+ return arr
94968
+ },
94969
+ globalConfig() {
94970
+ const obj = {
94971
+ pageSize: 'pageSize',
94972
+ pageNum: 'pageNum',
94973
+ total: 'total',
94974
+ res: 'rows'
94975
+ };
94976
+ if (this.$Z && this.$Z.list) {
94977
+ Object.assign(obj, this.$Z.list);
94978
+ }
94979
+ return obj
94980
+ }
94981
+ },
94982
+ data() {
94983
+ return {
94984
+ // 分页参数
94985
+ pageParams: {
94986
+ // pageSize: 10,
94987
+ // pageNum: 1
94988
+ },
94989
+ total: 0,
94990
+ // 搜索参数
94991
+ queryParams: {},
94992
+ // 表格数据
94993
+ tableData: [],
94994
+ loading: false
94995
+ }
94996
+ },
94997
+ created() {
94998
+ this.resetPageParams();
94999
+ },
95000
+ mounted() {
95001
+ this.handleQuery();
95002
+ },
95003
+ methods: {
95004
+ handleQuery() {
95005
+ this.pageParams[this.globalConfig.pageNum] = 1;
95006
+ this.getList();
95007
+ },
95008
+ resetPageParams() {
95009
+ this.pageParams = {
95010
+ [this.globalConfig.pageSize]: 10,
95011
+ [this.globalConfig.pageNum]: 1
95012
+ };
95013
+ },
95014
+ resetQuery() {
95015
+ const data = this.$options.data();
95016
+ this.queryParams = data.queryParams;
95017
+ this.resetPageParams();
95018
+ this.handleQuery();
95019
+ },
95020
+ getList() {
95021
+ // loading 好像有问题
95022
+ this.loading = true;
95023
+ // setTimeout(() => {
95024
+ // 带入隐藏值进行搜索
95025
+ if (this.tableOption.hiddenQuery) {
95026
+ this.queryParams = {
95027
+ ...this.tableOption.hiddenQuery,
95028
+ ...this.queryParams
95029
+ };
95030
+ }
95031
+ this.tableOption
95032
+ .api({
95033
+ [this.globalConfig.pageSize]: this.pageParams[this.globalConfig.pageSize],
95034
+ [this.globalConfig.pageNum]: this.pageParams[this.globalConfig.pageNum],
95035
+ ...this.queryParams
95036
+ })
95037
+ .then((res) => {
95038
+ this.tableData = res[this.globalConfig.res];
95039
+ this.total = res[this.globalConfig.total];
95040
+ this.loading = false;
95041
+ });
95042
+ // }, 200)
95043
+ }
95044
+ }
95045
+ };
95046
+
95047
+ /* script */
95048
+ const __vue_script__$1 = script$1;
95049
+
95050
+ /* template */
95051
+ var __vue_render__$1 = function () {
95052
+ var _vm = this;
95053
+ var _h = _vm.$createElement;
95054
+ var _c = _vm._self._c || _h;
95055
+ return _c(
95056
+ "div",
95057
+ { staticClass: "z-list-comp" },
95058
+ [
95059
+ _c(
95060
+ "el-form",
95061
+ { ref: "queryForm", attrs: { model: _vm.queryParams, inline: true } },
95062
+ [
95063
+ _vm._t("form", null, { queryParams: _vm.queryParams }),
95064
+ _vm._v(" "),
95065
+ _c(
95066
+ "el-form-item",
95067
+ [
95068
+ _c(
95069
+ "el-button",
95070
+ {
95071
+ attrs: { type: "primary", icon: "el-icon-search" },
95072
+ on: { click: _vm.handleQuery },
95073
+ },
95074
+ [_vm._v("搜索")]
95075
+ ),
95076
+ _vm._v(" "),
95077
+ _c(
95078
+ "el-button",
95079
+ {
95080
+ attrs: { icon: "el-icon-refresh" },
95081
+ on: { click: _vm.resetQuery },
95082
+ },
95083
+ [_vm._v("重置")]
95084
+ ),
95085
+ ],
95086
+ 1
95087
+ ),
95088
+ ],
95089
+ 2
95090
+ ),
95091
+ _vm._v(" "),
95092
+ _c("z-table", {
95093
+ attrs: {
95094
+ loading: _vm.loading,
95095
+ tableOption: _vm.tableOption,
95096
+ tableData: _vm.tableData,
95097
+ pageParams: _vm.pageParams,
95098
+ total: _vm.total,
95099
+ },
95100
+ on: { getData: _vm.getList },
95101
+ scopedSlots: _vm._u(
95102
+ [
95103
+ {
95104
+ key: "leftMenu",
95105
+ fn: function () {
95106
+ return [_vm._t("leftMenu")]
95107
+ },
95108
+ proxy: true,
95109
+ },
95110
+ {
95111
+ key: "rightMenu",
95112
+ fn: function () {
95113
+ return [_vm._t("rightMenu")]
95114
+ },
95115
+ proxy: true,
95116
+ },
95117
+ _vm._l(_vm.slotArr, function (o) {
95118
+ return {
95119
+ key: o.prop,
95120
+ fn: function (scope) {
95121
+ return [_vm._t(o.prop, null, null, scope)]
95122
+ },
95123
+ }
95124
+ }),
95125
+ ],
95126
+ null,
95127
+ true
95128
+ ),
95129
+ }),
95130
+ _vm._v(" "),
95131
+ _vm._t("default"),
95132
+ ],
95133
+ 2
95134
+ )
95135
+ };
95136
+ var __vue_staticRenderFns__$1 = [];
95137
+ __vue_render__$1._withStripped = true;
95138
+
95139
+ /* style */
95140
+ const __vue_inject_styles__$1 = function (inject) {
95141
+ if (!inject) return
95142
+ inject("data-v-378264cd_0", { source: "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", map: {"version":3,"sources":[],"names":[],"mappings":"","file":"list.vue"}, media: undefined });
95143
+
95144
+ };
95145
+ /* scoped */
95146
+ const __vue_scope_id__$1 = "data-v-378264cd";
95147
+ /* module identifier */
95148
+ const __vue_module_identifier__$1 = undefined;
95149
+ /* functional template */
95150
+ const __vue_is_functional_template__$1 = false;
95151
+ /* style inject SSR */
95152
+
95153
+ /* style inject shadow dom */
95154
+
95155
+
95156
+
95157
+ const __vue_component__$1 = /*#__PURE__*/__vue_normalize__(
95158
+ { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
95159
+ __vue_inject_styles__$1,
95160
+ __vue_script__$1,
95161
+ __vue_scope_id__$1,
95162
+ __vue_is_functional_template__$1,
95163
+ __vue_module_identifier__$1,
95164
+ false,
95165
+ __vue_create_injector__,
95166
+ undefined,
95167
+ undefined
95168
+ );
95169
+
95170
+ __vue_component__$1.install = function (Vue, option = {}) {
95171
+ setGolbalData(Vue, option);
95172
+ Vue.component(__vue_component__$1.name, __vue_component__$1);
95173
+ };
95174
+
95175
+ /**
95176
+ * @classdesc 字典数据
95177
+ * @property {String} label 标签
95178
+ * @property {*} value 标签
95179
+ * @property {Object} raw 原始数据
95180
+ */
95181
+ class DictData {
95182
+ constructor(label, value, raw) {
95183
+ this.label = label;
95184
+ this.value = value;
95185
+ this.raw = raw;
95186
+ }
95187
+ }
95188
+
95189
+ function dictConverter (dict, dictMeta) {
95190
+ const label = determineDictField(dict, dictMeta.labelField, ...options.DEFAULT_LABEL_FIELDS);
95191
+ const value = determineDictField(dict, dictMeta.valueField, ...options.DEFAULT_VALUE_FIELDS);
95192
+ return new DictData(dict[label], dict[value], dict)
95193
+ }
95194
+
95195
+ /**
95196
+ * 确定字典字段
95197
+ * @param {DictData} dict
95198
+ * @param {...String} fields
95199
+ */
95200
+ function determineDictField(dict, ...fields) {
95201
+ return fields.find((f) => Object.prototype.hasOwnProperty.call(dict, f))
95202
+ }
95203
+
95204
+ const options = {
95205
+ metas: {
95206
+ '*': {
95207
+ /**
95208
+ * 字典请求,方法签名为function(dictMeta: DictMeta): Promise
95209
+ */
95210
+ request: (dictMeta) => {
95211
+ console.log(`load dict ${dictMeta.type}`);
95212
+ return Promise.resolve([])
95213
+ },
95214
+ /**
95215
+ * 字典响应数据转换器,方法签名为function(response: Object, dictMeta: DictMeta): DictData
95216
+ */
95217
+ responseConverter,
95218
+ labelField: 'label',
95219
+ valueField: 'value'
95220
+ }
95221
+ },
95222
+ /**
95223
+ * 默认标签字段
95224
+ */
95225
+ DEFAULT_LABEL_FIELDS: ['label', 'name', 'title'],
95226
+ /**
95227
+ * 默认值字段
95228
+ */
95229
+ DEFAULT_VALUE_FIELDS: ['value', 'id', 'uid', 'key']
95230
+ };
95231
+
95232
+ /**
95233
+ * 映射字典
95234
+ * @param {Object} response 字典数据
95235
+ * @param {DictMeta} dictMeta 字典元数据
95236
+ * @returns {DictData}
95237
+ */
95238
+ function responseConverter(response, dictMeta) {
95239
+ const dicts = response.content instanceof Array ? response.content : response;
95240
+ if (dicts === undefined) {
95241
+ console.warn(`no dict data of "${dictMeta.type}" found in the response`);
95242
+ return []
95243
+ }
95244
+ return dicts.map((d) => dictConverter(d, dictMeta))
95245
+ }
95246
+
95247
+ function mergeOptions(src) {
95248
+ mergeRecursive(options, src);
95249
+ }
95250
+
95251
+ /**
95252
+ * @classdesc 字典元数据
95253
+ * @property {String} type 类型
95254
+ * @property {Function} request 请求
95255
+ * @property {String} label 标签字段
95256
+ * @property {String} value 值字段
95257
+ */
95258
+ class DictMeta {
95259
+ constructor(options) {
95260
+ this.type = options.type;
95261
+ this.request = options.request;
95262
+ this.responseConverter = options.responseConverter;
95263
+ this.labelField = options.labelField;
95264
+ this.valueField = options.valueField;
95265
+ this.lazy = options.lazy === true;
95266
+ }
95267
+ }
95268
+
95269
+ /**
95270
+ * 解析字典元数据
95271
+ * @param {Object} options
95272
+ * @returns {DictMeta}
95273
+ */
95274
+ DictMeta.parse = function (options$1) {
95275
+ let opts = null;
95276
+ if (typeof options$1 === 'string') {
95277
+ opts = options.metas[options$1] || {};
95278
+ opts.type = options$1;
95279
+ } else if (typeof options$1 === 'object') {
95280
+ opts = options$1;
95281
+ }
95282
+ opts = mergeRecursive(options.metas['*'], opts);
95283
+ return new DictMeta(opts)
95284
+ };
95285
+
95286
+ const DEFAULT_DICT_OPTIONS = {
95287
+ types: []
95288
+ };
95289
+
95290
+ /**
95291
+ * @classdesc 字典
95292
+ * @property {Object} label 标签对象,内部属性名为字典类型名称
95293
+ * @property {Object} dict 字段数组,内部属性名为字典类型名称
95294
+ * @property {Array.<DictMeta>} _dictMetas 字典元数据数组
95295
+ */
95296
+ class Dict {
95297
+ constructor(Vue) {
95298
+ this.owner = null;
95299
+ this.label = {};
95300
+ this.type = {};
95301
+ this.Vue = Vue;
95302
+ }
95303
+
95304
+ init(options) {
95305
+ if (options instanceof Array) {
95306
+ options = { types: options };
95307
+ }
95308
+ const opts = mergeRecursive(DEFAULT_DICT_OPTIONS, options);
95309
+ if (opts.types === undefined) {
95310
+ throw new Error('need dict types')
95311
+ }
95312
+ const ps = [];
95313
+ this._dictMetas = opts.types.map((t) => DictMeta.parse(t));
95314
+ this._dictMetas.forEach((dictMeta) => {
95315
+ const type = dictMeta.type;
95316
+ this.Vue.set(this.label, type, {});
95317
+ this.Vue.set(this.type, type, []);
95318
+ if (dictMeta.lazy) {
95319
+ return
94464
95320
  }
95321
+ ps.push(loadDict(this, dictMeta));
94465
95322
  });
94466
- router.afterEach(() => {
94467
- if (afterEach) {
94468
- afterEach();
95323
+ return Promise.all(ps)
95324
+ }
95325
+
95326
+ /**
95327
+ * 重新加载字典
95328
+ * @param {String} type 字典类型
95329
+ */
95330
+ reloadDict(type) {
95331
+ const dictMeta = this._dictMetas.find((e) => e.type === type);
95332
+ if (dictMeta === undefined) {
95333
+ return Promise.reject(`the dict meta of ${type} was not found`)
95334
+ }
95335
+ return loadDict(this, dictMeta)
95336
+ }
95337
+
95338
+ /**
95339
+ * 设置form表单的默认值
95340
+ * @param arr dict的数据
95341
+ * @param form 表单数据
95342
+ * @param key 需要修改的字段,可以是字符串或者数据
95343
+ */
95344
+ setDictForm(arr, form, key) {
95345
+ if (arr.length > 0) {
95346
+ let keyArr = key;
95347
+ if (!Array.isArray(key)) {
95348
+ keyArr = [key];
94469
95349
  }
94470
- NProgress.done();
95350
+ keyArr.forEach((item) => {
95351
+ if (typeof item === 'string') {
95352
+ item = {
95353
+ key: item,
95354
+ index: 0
95355
+ };
95356
+ }
95357
+ form[item.key] = arr[item.index].value;
95358
+ });
95359
+ }
95360
+ }
95361
+ }
95362
+
95363
+ /**
95364
+ * 加载字典
95365
+ * @param {Dict} dict 字典
95366
+ * @param {DictMeta} dictMeta 字典元数据
95367
+ * @returns {Promise}
95368
+ */
95369
+ function loadDict(dict, dictMeta) {
95370
+ return dictMeta.request(dictMeta).then((response) => {
95371
+ const type = dictMeta.type;
95372
+ let dicts = dictMeta.responseConverter(response, dictMeta);
95373
+ if (!(dicts instanceof Array)) {
95374
+ console.error('the return of responseConverter must be Array.<DictData>');
95375
+ dicts = [];
95376
+ } else if (dicts.filter((d) => d instanceof DictData).length !== dicts.length) {
95377
+ console.error('the type of elements in dicts must be DictData');
95378
+ dicts = [];
95379
+ }
95380
+ dict.type[type].splice(0, Number.MAX_SAFE_INTEGER, ...dicts);
95381
+ dicts.forEach((d) => {
95382
+ dict.Vue.set(dict.label[type], d.value, d.label);
94471
95383
  });
95384
+ return dicts
95385
+ })
95386
+ }
95387
+
95388
+ function DataDict (Vue, options) {
95389
+ mergeOptions(options);
95390
+ Vue.mixin({
95391
+ data() {
95392
+ if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) {
95393
+ return {}
95394
+ }
95395
+ const dict = new Dict(Vue);
95396
+ dict.owner = this;
95397
+ return {
95398
+ dict
95399
+ }
95400
+ },
95401
+ created() {
95402
+ if (!(this.dict instanceof Dict)) {
95403
+ return
95404
+ }
95405
+ options.onCreated && options.onCreated(this.dict);
95406
+ this.dict.init(this.$options.dicts).then(() => {
95407
+ options.onReady && options.onReady(this.dict);
95408
+ this.$nextTick(() => {
95409
+ this.$emit('dictReady', this.dict);
95410
+ if (this.$options.methods && this.$options.methods.onDictReady instanceof Function) {
95411
+ this.$options.methods.onDictReady.call(this, this.dict);
95412
+ }
95413
+ });
95414
+ });
95415
+ }
95416
+ });
95417
+ }
95418
+
95419
+ const state = {
95420
+ dict: new Array()
95421
+ };
95422
+ const mutations = {
95423
+ SET_DICT: (state, { key, value }) => {
95424
+ if (key !== null && key !== '') {
95425
+ state.dict.push({
95426
+ key: key,
95427
+ value: value
95428
+ });
95429
+ }
95430
+ },
95431
+ REMOVE_DICT: (state, key) => {
95432
+ try {
95433
+ for (let i = 0; i < state.dict.length; i++) {
95434
+ if (state.dict[i].key == key) {
95435
+ state.dict.splice(i, i);
95436
+ return true
95437
+ }
95438
+ }
95439
+ } catch (e) {
95440
+ console.log(e);
95441
+ }
95442
+ },
95443
+ CLEAN_DICT: (state) => {
95444
+ state.dict = new Array();
95445
+ }
95446
+ };
94472
95447
 
94473
- Vue.prototype.$z.router = router;
95448
+ const actions = {
95449
+ // 设置字典
95450
+ setDict({ commit }, data) {
95451
+ commit('SET_DICT', data);
95452
+ },
95453
+ // 删除字典
95454
+ removeDict({ commit }, key) {
95455
+ commit('REMOVE_DICT', key);
95456
+ },
95457
+ // 清空字典
95458
+ cleanDict({ commit }) {
95459
+ commit('CLEAN_DICT');
95460
+ }
95461
+ };
95462
+
95463
+ // 为vuex添加模块,存储dict数据
95464
+ function registerStateModule(store) {
95465
+ if (!store || !store.hasModule) return
95466
+ if (!store.hasModule('dict')) {
95467
+ const statesModule = {
95468
+ namespaced: true,
95469
+ state,
95470
+ mutations,
95471
+ actions
95472
+ };
95473
+ store.registerModule('dict', statesModule);
94474
95474
  }
94475
95475
  }
94476
95476
 
95477
+ function searchDictByKey(dict, key) {
95478
+ if (key == null && key == '') {
95479
+ return null
95480
+ }
95481
+ try {
95482
+ for (let i = 0; i < dict.length; i++) {
95483
+ if (dict[i].key == key) {
95484
+ return dict[i].value
95485
+ }
95486
+ }
95487
+ } catch (e) {
95488
+ return null
95489
+ }
95490
+ }
95491
+
94477
95492
  function install$1(Vue, option = {}) {
94478
95493
  setGolbalData(Vue, option);
94479
- createRouter(Vue);
95494
+ const z = Vue.prototype.$z;
95495
+ const dictOption = (z && z.dict) || {};
95496
+ const store = z.store;
95497
+ if (!store) {
95498
+ console.warn('缺少store参数');
95499
+ }
95500
+ registerStateModule(store);
95501
+ let getDicts = function (dictType) {
95502
+ const $http = Vue.prototype.$z.$http;
95503
+ if ($http) {
95504
+ return $http.request({
95505
+ url: (dictOption.dictApi || '/system/dict/data/type/') + dictType,
95506
+ method: 'get'
95507
+ })
95508
+ } else {
95509
+ Promise.resolve([]);
95510
+ }
95511
+ };
95512
+ if (typeof dictOption.dictApi === 'function') {
95513
+ getDicts = dictOption.dictApi;
95514
+ }
95515
+ Vue.use(DataDict, {
95516
+ metas: {
95517
+ '*': {
95518
+ labelField: dictOption.label || 'dictLabel', // 后台返回的字段
95519
+ valueField: dictOption.value || 'dictValue', // 后台返回的字段
95520
+ request(dictMeta) {
95521
+ if (store) {
95522
+ const storeDict = searchDictByKey(store.state.dict.dict, dictMeta.type);
95523
+ if (storeDict) {
95524
+ return new Promise((resolve) => {
95525
+ resolve(storeDict);
95526
+ })
95527
+ } else {
95528
+ return new Promise((resolve, reject) => {
95529
+ getDicts(dictMeta.type)
95530
+ .then((res) => {
95531
+ store.dispatch('dict/setDict', { key: dictMeta.type, value: res });
95532
+ resolve(res);
95533
+ })
95534
+ .catch((error) => {
95535
+ reject(error);
95536
+ });
95537
+ })
95538
+ }
95539
+ } else {
95540
+ return new Promise((resolve) => {
95541
+ resolve([]);
95542
+ })
95543
+ }
95544
+ }
95545
+ }
95546
+ }
95547
+ });
94480
95548
  }
94481
95549
 
94482
- var RouterZ = {
95550
+ var DictZ = {
94483
95551
  install: install$1
94484
95552
  };
94485
95553
 
95554
+ //
95555
+ //
95556
+ //
95557
+ //
95558
+ //
95559
+ //
95560
+ //
95561
+ //
95562
+ //
95563
+ //
95564
+ //
95565
+ //
95566
+ //
95567
+ //
95568
+ //
95569
+ //
95570
+ //
95571
+ //
95572
+ //
95573
+ //
95574
+ //
95575
+ //
95576
+ //
95577
+ //
95578
+ //
95579
+
95580
+ var script = {
95581
+ name: 'z-dict-tag',
95582
+ props: {
95583
+ options: {
95584
+ type: Array,
95585
+ default: null
95586
+ },
95587
+ value: [Number, String, Array],
95588
+ // 当未找到匹配的数据时,显示value
95589
+ showValue: {
95590
+ type: Boolean,
95591
+ default: true
95592
+ }
95593
+ },
95594
+ data() {
95595
+ return {
95596
+ unmatchArray: [] // 记录未匹配的项
95597
+ }
95598
+ },
95599
+ computed: {
95600
+ values() {
95601
+ if (this.value !== null && typeof this.value !== 'undefined') {
95602
+ return Array.isArray(this.value) ? this.value : [String(this.value)]
95603
+ } else {
95604
+ return []
95605
+ }
95606
+ },
95607
+ unmatch() {
95608
+ this.unmatchArray = [];
95609
+ if (this.value !== null && typeof this.value !== 'undefined') {
95610
+ // 传入值为非数组
95611
+ if (!Array.isArray(this.value)) {
95612
+ if (this.options.some((v) => v.value == this.value)) return false
95613
+ this.unmatchArray.push(this.value);
95614
+ return true
95615
+ }
95616
+ // 传入值为Array
95617
+ this.value.forEach((item) => {
95618
+ if (!this.options.some((v) => v.value == item)) this.unmatchArray.push(item);
95619
+ });
95620
+ return true
95621
+ }
95622
+ // 没有value不显示
95623
+ return false
95624
+ }
95625
+ },
95626
+ filters: {
95627
+ handleArray(array) {
95628
+ if (array.length === 0) return ''
95629
+ return array.reduce((pre, cur) => {
95630
+ return pre + ' ' + cur
95631
+ })
95632
+ }
95633
+ }
95634
+ };
95635
+
95636
+ /* script */
95637
+ const __vue_script__ = script;
95638
+
95639
+ /* template */
95640
+ var __vue_render__ = function () {
95641
+ var _vm = this;
95642
+ var _h = _vm.$createElement;
95643
+ var _c = _vm._self._c || _h;
95644
+ return _c(
95645
+ "div",
95646
+ [
95647
+ _vm._l(_vm.options, function (item, index) {
95648
+ return [
95649
+ _vm.values.includes(item.value)
95650
+ ? [
95651
+ item.raw.listClass == "default" || item.raw.listClass == ""
95652
+ ? _c(
95653
+ "span",
95654
+ {
95655
+ key: item.value,
95656
+ class: item.raw.cssClass,
95657
+ attrs: { index: index },
95658
+ },
95659
+ [_vm._v(_vm._s(item.label + " "))]
95660
+ )
95661
+ : _c(
95662
+ "el-tag",
95663
+ {
95664
+ key: item.value,
95665
+ class: item.raw.cssClass,
95666
+ attrs: {
95667
+ "disable-transitions": true,
95668
+ index: index,
95669
+ type:
95670
+ item.raw.listClass == "primary"
95671
+ ? ""
95672
+ : item.raw.listClass,
95673
+ },
95674
+ },
95675
+ [
95676
+ _vm._v(
95677
+ "\n " + _vm._s(item.label + " ") + "\n "
95678
+ ),
95679
+ ]
95680
+ ),
95681
+ ]
95682
+ : _vm._e(),
95683
+ ]
95684
+ }),
95685
+ _vm._v(" "),
95686
+ _vm.unmatch && _vm.showValue
95687
+ ? [
95688
+ _vm._v(
95689
+ "\n " +
95690
+ _vm._s(_vm._f("handleArray")(_vm.unmatchArray)) +
95691
+ "\n "
95692
+ ),
95693
+ ]
95694
+ : _vm._e(),
95695
+ ],
95696
+ 2
95697
+ )
95698
+ };
95699
+ var __vue_staticRenderFns__ = [];
95700
+ __vue_render__._withStripped = true;
95701
+
95702
+ /* style */
95703
+ const __vue_inject_styles__ = function (inject) {
95704
+ if (!inject) return
95705
+ inject("data-v-4dd7787c_0", { source: "\n.el-tag + .el-tag[data-v-4dd7787c] {\r\n margin-left: 10px;\n}\r\n", map: {"version":3,"sources":["D:\\workspace-my\\gitee\\rollup-demo\\lib\\packages\\dictTag\\dictTag.vue"],"names":[],"mappings":";AAmFA;EACA,iBAAA;AACA","file":"dictTag.vue","sourcesContent":["<template>\r\n <div>\r\n <template v-for=\"(item, index) in options\">\r\n <template v-if=\"values.includes(item.value)\">\r\n <span v-if=\"item.raw.listClass == 'default' || item.raw.listClass == ''\" :key=\"item.value\" :index=\"index\" :class=\"item.raw.cssClass\">{{\r\n item.label + ' '\r\n }}</span>\r\n <el-tag\r\n v-else\r\n :disable-transitions=\"true\"\r\n :key=\"item.value\"\r\n :index=\"index\"\r\n :type=\"item.raw.listClass == 'primary' ? '' : item.raw.listClass\"\r\n :class=\"item.raw.cssClass\"\r\n >\r\n {{ item.label + ' ' }}\r\n </el-tag>\r\n </template>\r\n </template>\r\n <template v-if=\"unmatch && showValue\">\r\n {{ unmatchArray | handleArray }}\r\n </template>\r\n </div>\r\n</template>\r\n\r\n<script>\r\nexport default {\r\n name: 'z-dict-tag',\r\n props: {\r\n options: {\r\n type: Array,\r\n default: null\r\n },\r\n value: [Number, String, Array],\r\n // 当未找到匹配的数据时,显示value\r\n showValue: {\r\n type: Boolean,\r\n default: true\r\n }\r\n },\r\n data() {\r\n return {\r\n unmatchArray: [] // 记录未匹配的项\r\n }\r\n },\r\n computed: {\r\n values() {\r\n if (this.value !== null && typeof this.value !== 'undefined') {\r\n return Array.isArray(this.value) ? this.value : [String(this.value)]\r\n } else {\r\n return []\r\n }\r\n },\r\n unmatch() {\r\n this.unmatchArray = []\r\n if (this.value !== null && typeof this.value !== 'undefined') {\r\n // 传入值为非数组\r\n if (!Array.isArray(this.value)) {\r\n if (this.options.some((v) => v.value == this.value)) return false\r\n this.unmatchArray.push(this.value)\r\n return true\r\n }\r\n // 传入值为Array\r\n this.value.forEach((item) => {\r\n if (!this.options.some((v) => v.value == item)) this.unmatchArray.push(item)\r\n })\r\n return true\r\n }\r\n // 没有value不显示\r\n return false\r\n }\r\n },\r\n filters: {\r\n handleArray(array) {\r\n if (array.length === 0) return ''\r\n return array.reduce((pre, cur) => {\r\n return pre + ' ' + cur\r\n })\r\n }\r\n }\r\n}\r\n</script>\r\n<style scoped>\r\n.el-tag + .el-tag {\r\n margin-left: 10px;\r\n}\r\n</style>\r\n"]}, media: undefined });
95706
+
95707
+ };
95708
+ /* scoped */
95709
+ const __vue_scope_id__ = "data-v-4dd7787c";
95710
+ /* module identifier */
95711
+ const __vue_module_identifier__ = undefined;
95712
+ /* functional template */
95713
+ const __vue_is_functional_template__ = false;
95714
+ /* style inject SSR */
95715
+
95716
+ /* style inject shadow dom */
95717
+
95718
+
95719
+
95720
+ const __vue_component__ = /*#__PURE__*/__vue_normalize__(
95721
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
95722
+ __vue_inject_styles__,
95723
+ __vue_script__,
95724
+ __vue_scope_id__,
95725
+ __vue_is_functional_template__,
95726
+ __vue_module_identifier__,
95727
+ false,
95728
+ __vue_create_injector__,
95729
+ undefined,
95730
+ undefined
95731
+ );
95732
+
95733
+ __vue_component__.install = function (Vue, option = {}) {
95734
+ setGolbalData(Vue, option);
95735
+ Vue.component(__vue_component__.name, __vue_component__);
95736
+ };
95737
+
94486
95738
  if (typeof window !== 'undefined' && window.Vue) {
94487
95739
  install(window.Vue);
94488
95740
  }
94489
- const components = [__vue_component__, RequestZ, RouterZ];
95741
+ const components = [__vue_component__$3, RequestZ, RouterZ, __vue_component__$2, __vue_component__$1, DictZ, __vue_component__];
94490
95742
  const install = (Vue, option = {}) => {
94491
95743
  setGolbalData(Vue, option);
94492
95744
  components.forEach((component) => {
@@ -94497,7 +95749,11 @@ var index = {
94497
95749
  install
94498
95750
  };
94499
95751
 
94500
- exports.IconZ = __vue_component__;
95752
+ exports.DictTagZ = __vue_component__;
95753
+ exports.DictZ = DictZ;
95754
+ exports.IconZ = __vue_component__$3;
95755
+ exports.ListZ = __vue_component__$1;
94501
95756
  exports.RequestZ = RequestZ;
94502
95757
  exports.RouterZ = RouterZ;
95758
+ exports.TableZ = __vue_component__$2;
94503
95759
  exports.default = index;