bootstrap-table-vue.esm.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. //
  2. //
  3. //
  4. //
  5. const $ = window.jQuery;
  6. const deepCopy = arg => {
  7. if (arg === undefined) {
  8. return arg
  9. }
  10. return $.extend(true, Array.isArray(arg) ? [] : {}, arg)
  11. };
  12. var script = {
  13. name: 'BootstrapTable',
  14. props: {
  15. columns: {
  16. type: Array,
  17. require: true
  18. },
  19. data: {
  20. type: [Array, Object],
  21. default () {
  22. return undefined
  23. }
  24. },
  25. options: {
  26. type: Object,
  27. default () {
  28. return {}
  29. }
  30. }
  31. },
  32. mounted () {
  33. this.$table = $(this.$el);
  34. this.$table.on('all.bs.table', (e, name, args) => {
  35. let eventName = $.fn.bootstrapTable.events[name];
  36. eventName = eventName.replace(/([A-Z])/g, '-$1').toLowerCase();
  37. this.$emit('on-all', ...args);
  38. this.$emit(eventName, ...args);
  39. });
  40. this._initTable();
  41. },
  42. methods: {
  43. _initTable () {
  44. const options = {
  45. ...deepCopy(this.options),
  46. columns: deepCopy(this.columns),
  47. data: deepCopy(this.data)
  48. };
  49. if (!this._hasInit) {
  50. this.$table.bootstrapTable(options);
  51. this._hasInit = true;
  52. } else {
  53. this.refreshOptions(options);
  54. }
  55. },
  56. ...(() => {
  57. const res = {};
  58. for (const method of $.fn.bootstrapTable.methods) {
  59. res[method] = function (...args) {
  60. return this.$table.bootstrapTable(method, ...args)
  61. };
  62. }
  63. return res
  64. })()
  65. },
  66. watch: {
  67. options: {
  68. handler () {
  69. this._initTable();
  70. },
  71. deep: true
  72. },
  73. columns: {
  74. handler () {
  75. this._initTable();
  76. },
  77. deep: true
  78. },
  79. data: {
  80. handler () {
  81. this.load(deepCopy(this.data));
  82. },
  83. deep: true
  84. }
  85. }
  86. };
  87. function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
  88. if (typeof shadowMode !== 'boolean') {
  89. createInjectorSSR = createInjector;
  90. createInjector = shadowMode;
  91. shadowMode = false;
  92. }
  93. // Vue.extend constructor export interop.
  94. const options = typeof script === 'function' ? script.options : script;
  95. // render functions
  96. if (template && template.render) {
  97. options.render = template.render;
  98. options.staticRenderFns = template.staticRenderFns;
  99. options._compiled = true;
  100. // functional template
  101. if (isFunctionalTemplate) {
  102. options.functional = true;
  103. }
  104. }
  105. // scopedId
  106. if (scopeId) {
  107. options._scopeId = scopeId;
  108. }
  109. let hook;
  110. if (moduleIdentifier) {
  111. // server build
  112. hook = function (context) {
  113. // 2.3 injection
  114. context =
  115. context || // cached call
  116. (this.$vnode && this.$vnode.ssrContext) || // stateful
  117. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
  118. // 2.2 with runInNewContext: true
  119. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  120. context = __VUE_SSR_CONTEXT__;
  121. }
  122. // inject component styles
  123. if (style) {
  124. style.call(this, createInjectorSSR(context));
  125. }
  126. // register component module identifier for async chunk inference
  127. if (context && context._registeredComponents) {
  128. context._registeredComponents.add(moduleIdentifier);
  129. }
  130. };
  131. // used by ssr in case component is cached and beforeCreate
  132. // never gets called
  133. options._ssrRegister = hook;
  134. }
  135. else if (style) {
  136. hook = shadowMode
  137. ? function (context) {
  138. style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
  139. }
  140. : function (context) {
  141. style.call(this, createInjector(context));
  142. };
  143. }
  144. if (hook) {
  145. if (options.functional) {
  146. // register for functional component in vue file
  147. const originalRender = options.render;
  148. options.render = function renderWithStyleInjection(h, context) {
  149. hook.call(context);
  150. return originalRender(h, context);
  151. };
  152. }
  153. else {
  154. // inject component registration as beforeCreate hook
  155. const existing = options.beforeCreate;
  156. options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
  157. }
  158. }
  159. return script;
  160. }
  161. /* script */
  162. const __vue_script__ = script;
  163. /* template */
  164. var __vue_render__ = function () {
  165. var _vm = this;
  166. var _h = _vm.$createElement;
  167. var _c = _vm._self._c || _h;
  168. return _c("table")
  169. };
  170. var __vue_staticRenderFns__ = [];
  171. __vue_render__._withStripped = true;
  172. /* style */
  173. const __vue_inject_styles__ = undefined;
  174. /* scoped */
  175. const __vue_scope_id__ = undefined;
  176. /* module identifier */
  177. const __vue_module_identifier__ = undefined;
  178. /* functional template */
  179. const __vue_is_functional_template__ = false;
  180. /* style inject */
  181. /* style inject SSR */
  182. /* style inject shadow dom */
  183. const __vue_component__ = /*#__PURE__*/normalizeComponent(
  184. { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
  185. __vue_inject_styles__,
  186. __vue_script__,
  187. __vue_scope_id__,
  188. __vue_is_functional_template__,
  189. __vue_module_identifier__,
  190. false,
  191. undefined,
  192. undefined,
  193. undefined
  194. );
  195. export { __vue_component__ as default };