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