xs-common-plugins 1.2.6 → 1.2.7
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/README.md +6 -0
- package/package.json +1 -1
- package/src/common/common.js +117 -87
package/README.md
CHANGED
package/package.json
CHANGED
package/src/common/common.js
CHANGED
|
@@ -246,103 +246,133 @@ common.confirm = (that, message, title, callBack) => {
|
|
|
246
246
|
*
|
|
247
247
|
*/
|
|
248
248
|
common.popup = (options) => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
249
|
+
if (!options) return;
|
|
250
|
+
const { title, component, srcData, width, showButton, callBack, props, dialogCfg } = common.clone(options);
|
|
251
|
+
if (!component) return;
|
|
252
|
+
|
|
253
|
+
const div = document.createElement("div");
|
|
254
|
+
document.body.appendChild(div);
|
|
255
|
+
|
|
256
|
+
const dialogComponent = {
|
|
257
|
+
components: {
|
|
258
|
+
child: component
|
|
259
|
+
},
|
|
260
|
+
props: {
|
|
261
|
+
title: {
|
|
262
|
+
type: String,
|
|
263
|
+
default: '弹窗组件',
|
|
264
|
+
},
|
|
265
|
+
srcData: {
|
|
266
|
+
type: Object,
|
|
267
|
+
default: null,
|
|
268
|
+
},
|
|
269
|
+
showButton: {
|
|
270
|
+
type: Boolean,
|
|
271
|
+
default: true,
|
|
272
|
+
},
|
|
273
|
+
width: {
|
|
274
|
+
type: String,
|
|
275
|
+
default: '30%',
|
|
276
|
+
},
|
|
277
|
+
dialogCfg: {
|
|
278
|
+
type: Object,
|
|
279
|
+
default: null,
|
|
280
|
+
},
|
|
281
|
+
props: {
|
|
282
|
+
type: Object,
|
|
283
|
+
default: null,
|
|
284
|
+
},
|
|
285
|
+
callBack: {
|
|
286
|
+
type: Function,
|
|
287
|
+
default: null,
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
data() {
|
|
291
|
+
return {
|
|
292
|
+
visible: true,
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
methods: {
|
|
296
|
+
confirm() {
|
|
297
|
+
if (this.$refs.child.confirm) {
|
|
298
|
+
this.$refs.child.confirm();
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
beforeClose(done) {
|
|
302
|
+
if (this.$refs.child.beforeClose) {
|
|
303
|
+
this.$refs.child.beforeClose(done);
|
|
304
|
+
} else {
|
|
305
|
+
done();
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
cancel() {
|
|
309
|
+
this.visible = false;
|
|
310
|
+
},
|
|
311
|
+
close(res) {
|
|
312
|
+
if (this.callBack) {
|
|
313
|
+
this.callBack(res);
|
|
314
|
+
}
|
|
315
|
+
this.visible = false;
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
template: `
|
|
319
|
+
<div>
|
|
320
|
+
<el-dialog :title="title" :visible.sync="visible" :width="width" :before-close="beforeClose" v-bind="dialogCfg" append-to-body>
|
|
321
|
+
<child ref="child" :srcData="srcData" v-bind="props" @close="close" @cancel="cancel"/>
|
|
322
|
+
<div v-if="showButton" style="text-align: right;">
|
|
323
|
+
<el-button size="medium" type="primary" @click="confirm">确认</el-button>
|
|
324
|
+
<el-button size="medium" @click="cancel">取消</el-button>
|
|
325
|
+
</div>
|
|
326
|
+
</el-dialog>
|
|
327
|
+
</div>
|
|
328
|
+
`,
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
return new Vue({
|
|
332
|
+
el: div,
|
|
333
|
+
render(h) {
|
|
334
|
+
return h(dialogComponent, {
|
|
335
|
+
props: {
|
|
336
|
+
title,
|
|
337
|
+
srcData,
|
|
338
|
+
width,
|
|
339
|
+
showButton,
|
|
340
|
+
callBack,
|
|
341
|
+
props,
|
|
342
|
+
dialogCfg,
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
|
+
},
|
|
346
|
+
});
|
|
307
347
|
}
|
|
308
348
|
|
|
349
|
+
|
|
350
|
+
|
|
309
351
|
/**
|
|
310
352
|
* 深度拷贝
|
|
311
353
|
*/
|
|
312
354
|
common.clone = (obj) => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
copy.setTime(obj.getTime());
|
|
321
|
-
return copy;
|
|
322
|
-
}
|
|
323
|
-
//数组类型
|
|
324
|
-
if (obj instanceof Array) {
|
|
325
|
-
let copy = [];
|
|
326
|
-
for (let i = 0; index < obj.length; index++) {
|
|
327
|
-
copy[i] = common.clone(obj[i])
|
|
328
|
-
}
|
|
329
|
-
return copy
|
|
330
|
-
}
|
|
331
|
-
//对象类型
|
|
332
|
-
if (obj instanceof Object) {
|
|
333
|
-
let copy = {}
|
|
334
|
-
for (const key in obj) {
|
|
335
|
-
if (Object.hasOwnProperty.call(object, key)) {
|
|
336
|
-
copy[key] = common.copy(obj[key])
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return copy
|
|
340
|
-
}
|
|
355
|
+
if (obj === null || typeof obj !== 'object') {
|
|
356
|
+
return obj;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (obj instanceof Date) {
|
|
360
|
+
return new Date(obj.getTime());
|
|
361
|
+
}
|
|
341
362
|
|
|
342
|
-
|
|
363
|
+
const clone = Array.isArray(obj) ? [] : {};
|
|
364
|
+
|
|
365
|
+
for (const key in obj) {
|
|
366
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
367
|
+
clone[key] = common.clone(obj[key]);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return clone;
|
|
343
372
|
}
|
|
344
373
|
|
|
345
374
|
|
|
375
|
+
|
|
346
376
|
/**
|
|
347
377
|
*导出数据报表
|
|
348
378
|
*@param query 默认 列表上的 query 条件去掉 data
|