ylwl-cpscoms 1.0.0
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 +15 -0
- package/es/SlAlert/index.vue.js +58 -0
- package/es/SlAlert/index.vue2.js +37 -0
- package/es/SlAlert/index.vue3.js +6 -0
- package/es/SlDescriptions/index.vue.js +55 -0
- package/es/SlDescriptions/index.vue2.js +57 -0
- package/es/SlDescriptions/index.vue3.js +6 -0
- package/es/SlDescriptions/renderOptions.vue.js +25 -0
- package/es/SlDescriptions/renderOptions.vue2.js +31 -0
- package/es/SlDialog/dialogPlus.js +159 -0
- package/es/SlDialog/index.js +202 -0
- package/es/SlDrawer/index.js +54 -0
- package/es/SlForm/index.vue.js +26 -0
- package/es/SlForm/index.vue2.js +433 -0
- package/es/SlForm/index.vue3.js +6 -0
- package/es/SlForm/mixinRender.js +239 -0
- package/es/SlForm/otherItem/titleItem.vue.js +39 -0
- package/es/SlForm/otherItem/titleItem.vue2.js +20 -0
- package/es/SlForm/otherItem/titleItem.vue3.js +6 -0
- package/es/SlGuide/index.vue.js +38 -0
- package/es/SlGuide/index.vue2.js +133 -0
- package/es/SlGuide/index.vue3.js +6 -0
- package/es/SlGuide/index.vue4.js +6 -0
- package/es/SlMessageBox/index.js +46 -0
- package/es/SlPage/index.vue.js +147 -0
- package/es/SlPage/index.vue2.js +312 -0
- package/es/SlPage/index.vue3.js +6 -0
- package/es/SlTable/components/colSetting.vue.js +94 -0
- package/es/SlTable/components/colSetting.vue2.js +66 -0
- package/es/SlTable/components/colSetting.vue3.js +6 -0
- package/es/SlTable/index.vue.js +171 -0
- package/es/SlTable/index.vue2.js +390 -0
- package/es/SlTable/index.vue3.js +6 -0
- package/es/SlTitle/index.vue.js +41 -0
- package/es/SlTitle/index.vue2.js +26 -0
- package/es/SlTitle/index.vue3.js +6 -0
- package/es/_virtual/_rollupPluginBabelHelpers.js +247 -0
- package/es/index.js +41 -0
- package/es/node_modules/shepherd.js/dist/css/shepherd.css.js +7 -0
- package/es/node_modules/style-inject/dist/style-inject.es.js +28 -0
- package/es/node_modules/vue-runtime-helpers/dist/normalize-component.js +76 -0
- package/es/utils/index.js +51 -0
- package/package.json +106 -0
- package/src/SlAlert/SlAlert.stories.js +108 -0
- package/src/SlAlert/index.vue +54 -0
- package/src/SlAlert/remark.md +16 -0
- package/src/SlDescriptions/SlDescriptions.stories.js +119 -0
- package/src/SlDescriptions/index.vue +60 -0
- package/src/SlDescriptions/renderOptions.vue +27 -0
- package/src/SlDialog/README-PLUS.md +74 -0
- package/src/SlDialog/README.md +114 -0
- package/src/SlDialog/dialogPlus.js +160 -0
- package/src/SlDialog/index.js +170 -0
- package/src/SlDrawer/SlDrawer.stories.js +154 -0
- package/src/SlDrawer/index.js +62 -0
- package/src/SlForm/SlForm.stories.js +120 -0
- package/src/SlForm/index.css +141 -0
- package/src/SlForm/index.vue +365 -0
- package/src/SlForm/mixinRender.js +228 -0
- package/src/SlForm/otherItem/titleItem.vue +31 -0
- package/src/SlForm/remark.md +607 -0
- package/src/SlGuide/SlGuide.stories.js +100 -0
- package/src/SlGuide/index.vue +166 -0
- package/src/SlGuide/remark.md +90 -0
- package/src/SlMessageBox/index.js +35 -0
- package/src/SlPage/README.md +515 -0
- package/src/SlPage/SlPage.stories.js +125 -0
- package/src/SlPage/index.css +38 -0
- package/src/SlPage/index.vue +266 -0
- package/src/SlPage/remark.md +283 -0
- package/src/SlTable/SlTable.stories.js +118 -0
- package/src/SlTable/components/colSetting.vue +86 -0
- package/src/SlTable/index.vue +541 -0
- package/src/SlTitle/SlTitle.stories.js +98 -0
- package/src/SlTitle/index.vue +49 -0
- package/src/global.css +5 -0
- package/src/index.js +47 -0
- package/src/store/index.js +20 -0
- package/src/utils/index.js +47 -0
- package/src/utils/tableConfig.js +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## 使用
|
|
2
|
+
```js
|
|
3
|
+
|
|
4
|
+
// main.js
|
|
5
|
+
import Vue from 'vue'
|
|
6
|
+
import CpsbComponents from 'ylwl-cpsComs'
|
|
7
|
+
Vue.use(CpsbComponents)
|
|
8
|
+
|
|
9
|
+
// 之后所有页面可直接使用:
|
|
10
|
+
// <SlPage>, <SlTable>, <SlForm>, <SlDialog>, <SlTitle>,
|
|
11
|
+
// <SlAlert>, <SlDescriptions>, <SlGuide>
|
|
12
|
+
|
|
13
|
+
// 函数式组件:
|
|
14
|
+
import { createCommandDialog, showConfirmMessageBox } from 'ylwl-cpsComs'
|
|
15
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import script from './index.vue2.js';
|
|
2
|
+
import './index.vue3.js';
|
|
3
|
+
import normalizeComponent from '../node_modules/vue-runtime-helpers/dist/normalize-component.js';
|
|
4
|
+
|
|
5
|
+
/* script */
|
|
6
|
+
var __vue_script__ = script;
|
|
7
|
+
/* template */
|
|
8
|
+
var __vue_render__ = function __vue_render__() {
|
|
9
|
+
var _vm = this;
|
|
10
|
+
var _h = _vm.$createElement;
|
|
11
|
+
var _c = _vm._self._c || _h;
|
|
12
|
+
return _c("div", {
|
|
13
|
+
staticClass: "slMessage"
|
|
14
|
+
}, [_c("div", {
|
|
15
|
+
staticClass: "message-box"
|
|
16
|
+
}, [_c("div", {
|
|
17
|
+
staticClass: "message-title"
|
|
18
|
+
}, [_c("div", [_c("i", {
|
|
19
|
+
staticClass: "el-icon-warning"
|
|
20
|
+
}), _vm._v("\n 温馨提示\n "), _c("el-button", {
|
|
21
|
+
staticClass: "toggle-button",
|
|
22
|
+
attrs: {
|
|
23
|
+
size: "mini",
|
|
24
|
+
type: "text"
|
|
25
|
+
},
|
|
26
|
+
on: {
|
|
27
|
+
click: _vm.toggleMessage
|
|
28
|
+
}
|
|
29
|
+
}, [_vm._v("\n " + _vm._s(_vm.isMessageVisible ? "收起" : "展开") + "\n "), _c("i", {
|
|
30
|
+
class: _vm.isMessageVisible ? "el-icon-arrow-up" : "el-icon-arrow-down"
|
|
31
|
+
})])], 1), _vm._v(" "), _vm._t("operate")], 2), _vm._v(" "), _vm.isMessageVisible ? _c("div", {
|
|
32
|
+
staticClass: "message-row"
|
|
33
|
+
}, [_vm._t("message")], 2) : _vm._e()])]);
|
|
34
|
+
};
|
|
35
|
+
var __vue_staticRenderFns__ = [];
|
|
36
|
+
__vue_render__._withStripped = true;
|
|
37
|
+
|
|
38
|
+
/* style */
|
|
39
|
+
var __vue_inject_styles__ = undefined;
|
|
40
|
+
/* scoped */
|
|
41
|
+
var __vue_scope_id__ = "data-v-5d4ea765";
|
|
42
|
+
/* module identifier */
|
|
43
|
+
var __vue_module_identifier__ = undefined;
|
|
44
|
+
/* functional template */
|
|
45
|
+
var __vue_is_functional_template__ = false;
|
|
46
|
+
/* style inject */
|
|
47
|
+
|
|
48
|
+
/* style inject SSR */
|
|
49
|
+
|
|
50
|
+
/* style inject shadow dom */
|
|
51
|
+
|
|
52
|
+
var __vue_component__ = /*#__PURE__*/normalizeComponent({
|
|
53
|
+
render: __vue_render__,
|
|
54
|
+
staticRenderFns: __vue_staticRenderFns__
|
|
55
|
+
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
|
|
56
|
+
var SlAlert = __vue_component__;
|
|
57
|
+
|
|
58
|
+
export { SlAlert as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isMobileDevice } from '../utils/index.js';
|
|
2
|
+
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
//
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
//
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
//
|
|
17
|
+
//
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
//
|
|
22
|
+
//
|
|
23
|
+
|
|
24
|
+
var script = {
|
|
25
|
+
data: function data() {
|
|
26
|
+
return {
|
|
27
|
+
isMessageVisible: !isMobileDevice()
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
methods: {
|
|
31
|
+
toggleMessage: function toggleMessage() {
|
|
32
|
+
this.isMessageVisible = !this.isMessageVisible;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { script as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import styleInject from '../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".message-box[data-v-5d4ea765]{background:#fdf6ec;padding:5px 10px 10px}.message-title[data-v-5d4ea765]{align-items:center;color:#f59a23d8;display:flex;justify-content:space-between}.message-row[data-v-5d4ea765]{font-size:12px}";
|
|
4
|
+
styleInject(css_248z);
|
|
5
|
+
|
|
6
|
+
export { css_248z as default };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import script from './index.vue2.js';
|
|
2
|
+
import './index.vue3.js';
|
|
3
|
+
import normalizeComponent from '../node_modules/vue-runtime-helpers/dist/normalize-component.js';
|
|
4
|
+
|
|
5
|
+
/* script */
|
|
6
|
+
var __vue_script__ = script;
|
|
7
|
+
/* template */
|
|
8
|
+
var __vue_render__ = function __vue_render__() {
|
|
9
|
+
var _vm = this;
|
|
10
|
+
var _h = _vm.$createElement;
|
|
11
|
+
var _c = _vm._self._c || _h;
|
|
12
|
+
return _c("div", [_c("el-descriptions", _vm._b({
|
|
13
|
+
attrs: {
|
|
14
|
+
size: "small",
|
|
15
|
+
border: ""
|
|
16
|
+
}
|
|
17
|
+
}, "el-descriptions", _vm.elTableProps, false), _vm._l(_vm.renderData.model, function (item) {
|
|
18
|
+
return _vm.isShow(item) ? _c("el-descriptions-item", {
|
|
19
|
+
key: item.name
|
|
20
|
+
}, [_c("template", {
|
|
21
|
+
slot: "label"
|
|
22
|
+
}, [_vm._v("\n " + _vm._s(item.label) + "\n ")]), _vm._v(" "), !item.format && !item.template ? _c("span", [_vm._v(" " + _vm._s(_vm.renderData.data[item.prop] || _vm.renderData.data[item.prop] === 0 ? _vm.renderData.data[item.prop] : "-"))]) : _vm._e(), _vm._v(" "), item.format && _vm.renderData.data ? _c("renderOptions", {
|
|
23
|
+
attrs: {
|
|
24
|
+
"render-options": item.format,
|
|
25
|
+
data: _vm.renderData.data
|
|
26
|
+
}
|
|
27
|
+
}) : _vm._e(), _vm._v(" "), item.template ? _vm._t(item.template, null, {
|
|
28
|
+
data: _vm.renderData.data
|
|
29
|
+
}) : _vm._e()], 2) : _vm._e();
|
|
30
|
+
}))], 1);
|
|
31
|
+
};
|
|
32
|
+
var __vue_staticRenderFns__ = [];
|
|
33
|
+
__vue_render__._withStripped = true;
|
|
34
|
+
|
|
35
|
+
/* style */
|
|
36
|
+
var __vue_inject_styles__ = undefined;
|
|
37
|
+
/* scoped */
|
|
38
|
+
var __vue_scope_id__ = "data-v-66e3026a";
|
|
39
|
+
/* module identifier */
|
|
40
|
+
var __vue_module_identifier__ = undefined;
|
|
41
|
+
/* functional template */
|
|
42
|
+
var __vue_is_functional_template__ = false;
|
|
43
|
+
/* style inject */
|
|
44
|
+
|
|
45
|
+
/* style inject SSR */
|
|
46
|
+
|
|
47
|
+
/* style inject shadow dom */
|
|
48
|
+
|
|
49
|
+
var __vue_component__ = /*#__PURE__*/normalizeComponent({
|
|
50
|
+
render: __vue_render__,
|
|
51
|
+
staticRenderFns: __vue_staticRenderFns__
|
|
52
|
+
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
|
|
53
|
+
var SlDescriptions = __vue_component__;
|
|
54
|
+
|
|
55
|
+
export { SlDescriptions as default };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//
|
|
2
|
+
//
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
//
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
//
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
|
|
17
|
+
var script = {
|
|
18
|
+
name: 'SlDescriptions',
|
|
19
|
+
components: {
|
|
20
|
+
renderOptions: function renderOptions() {
|
|
21
|
+
return import('./renderOptions.vue.js');
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
props: {
|
|
25
|
+
renderData: {
|
|
26
|
+
type: Object,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
elTableProps: {
|
|
30
|
+
type: Object,
|
|
31
|
+
default: function _default() {
|
|
32
|
+
return {
|
|
33
|
+
size: 'small',
|
|
34
|
+
column: 2
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
data: function data() {
|
|
40
|
+
return {};
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
isShow: function isShow(item) {
|
|
44
|
+
if (item.isShow !== undefined) {
|
|
45
|
+
if (typeof item.isShow === 'function') {
|
|
46
|
+
return item.isShow(this.renderData.data);
|
|
47
|
+
} else {
|
|
48
|
+
return item.isShow;
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { script as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import script from './renderOptions.vue2.js';
|
|
2
|
+
import normalizeComponent from '../node_modules/vue-runtime-helpers/dist/normalize-component.js';
|
|
3
|
+
|
|
4
|
+
/* script */
|
|
5
|
+
var __vue_script__ = script;
|
|
6
|
+
|
|
7
|
+
/* template */
|
|
8
|
+
|
|
9
|
+
/* style */
|
|
10
|
+
var __vue_inject_styles__ = undefined;
|
|
11
|
+
/* scoped */
|
|
12
|
+
var __vue_scope_id__ = undefined;
|
|
13
|
+
/* module identifier */
|
|
14
|
+
var __vue_module_identifier__ = undefined;
|
|
15
|
+
/* functional template */
|
|
16
|
+
var __vue_is_functional_template__ = undefined;
|
|
17
|
+
/* style inject */
|
|
18
|
+
|
|
19
|
+
/* style inject SSR */
|
|
20
|
+
|
|
21
|
+
/* style inject shadow dom */
|
|
22
|
+
|
|
23
|
+
var __vue_component__ = /*#__PURE__*/normalizeComponent({}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
|
|
24
|
+
|
|
25
|
+
export { __vue_component__ as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var script = {
|
|
2
|
+
name: 'EcSystemsRenderOptions',
|
|
3
|
+
props: {
|
|
4
|
+
renderOptions: {
|
|
5
|
+
type: Function,
|
|
6
|
+
default: function _default() {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
data: {
|
|
11
|
+
type: Object,
|
|
12
|
+
default: function _default() {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
render: function render(h) {
|
|
18
|
+
if (this._props.renderOptions) {
|
|
19
|
+
var callback = this._props.renderOptions(h, this._props.data);
|
|
20
|
+
if (typeof callback === 'string') {
|
|
21
|
+
return h('span', callback);
|
|
22
|
+
} else {
|
|
23
|
+
return callback;
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { script as default };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
import { isMobileDevice } from '../utils/index.js';
|
|
4
|
+
|
|
5
|
+
// 🌟 核心魔法:注册一个全局的辅助组件,充当“传送门”(Portal)
|
|
6
|
+
if (!Vue.component('dialog-footer')) {
|
|
7
|
+
Vue.component('dialog-footer', {
|
|
8
|
+
inject: {
|
|
9
|
+
dialogCtx: {
|
|
10
|
+
default: null
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
mounted: function mounted() {
|
|
14
|
+
if (this.dialogCtx) {
|
|
15
|
+
this.dialogCtx.setFooterVNodes(this.$slots.default);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
updated: function updated() {
|
|
19
|
+
if (this.dialogCtx) {
|
|
20
|
+
this.dialogCtx.setFooterVNodes(this.$slots.default);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
destroyed: function destroyed() {
|
|
24
|
+
if (this.dialogCtx) {
|
|
25
|
+
this.dialogCtx.setFooterVNodes(null);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
render: function render(h) {
|
|
29
|
+
return h('div', {
|
|
30
|
+
style: {
|
|
31
|
+
display: 'none'
|
|
32
|
+
},
|
|
33
|
+
class: 'dialog-footer-portal'
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function createCommandDialogPlus(options) {
|
|
39
|
+
var defaultOptions = {
|
|
40
|
+
title: '提示',
|
|
41
|
+
width: '50%',
|
|
42
|
+
specialWidth: '',
|
|
43
|
+
closeOnClickModal: false,
|
|
44
|
+
contentComponent: null,
|
|
45
|
+
contentProps: {},
|
|
46
|
+
showClose: true,
|
|
47
|
+
closeOnPressEscape: false,
|
|
48
|
+
customClass: ''
|
|
49
|
+
};
|
|
50
|
+
var mergedOptions = _objectSpread2(_objectSpread2({}, defaultOptions), options);
|
|
51
|
+
var Constructor = Vue.extend({
|
|
52
|
+
provide: function provide() {
|
|
53
|
+
return {
|
|
54
|
+
dialogCtx: this
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
data: function data() {
|
|
58
|
+
return {
|
|
59
|
+
visible: false,
|
|
60
|
+
footerVNodes: null
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
created: function created() {
|
|
64
|
+
Object.assign(this, mergedOptions);
|
|
65
|
+
},
|
|
66
|
+
mounted: function mounted() {
|
|
67
|
+
var _this = this;
|
|
68
|
+
Vue.nextTick(function () {
|
|
69
|
+
_this.visible = true;
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
methods: {
|
|
73
|
+
handleBeforeClose: function handleBeforeClose(done) {
|
|
74
|
+
if (typeof done === 'function') {
|
|
75
|
+
done(); // 允许 el-dialog 执行关闭动画
|
|
76
|
+
} else {
|
|
77
|
+
this.visible = false;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
handleClose: function handleClose() {
|
|
81
|
+
var _this2 = this;
|
|
82
|
+
if (this._hasClosed) return;
|
|
83
|
+
this._hasClosed = true;
|
|
84
|
+
console.log('你肯定会执行吗啊');
|
|
85
|
+
if (typeof this.onClose === 'function') {
|
|
86
|
+
this.onClose(this);
|
|
87
|
+
}
|
|
88
|
+
this.$once('closed', function () {
|
|
89
|
+
_this2.$destroy();
|
|
90
|
+
if (_this2.$el && _this2.$el.parentNode) {
|
|
91
|
+
_this2.$el.parentNode.removeChild(_this2.$el);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
// 暴露给业务组件的关闭方法
|
|
96
|
+
closeDialog: function closeDialog() {
|
|
97
|
+
this.visible = false;
|
|
98
|
+
},
|
|
99
|
+
// 兼容以前的 confirm 逻辑(可选保留,为了向后兼容外层传入 onConfirm)
|
|
100
|
+
confirmDialog: function confirmDialog() {
|
|
101
|
+
if (typeof this.onConfirm === 'function') {
|
|
102
|
+
this.onConfirm();
|
|
103
|
+
}
|
|
104
|
+
this.visible = false; // 同样只修改 visible
|
|
105
|
+
},
|
|
106
|
+
// 供 <dialog-footer> 调用的方法
|
|
107
|
+
setFooterVNodes: function setFooterVNodes(vnodes) {
|
|
108
|
+
this.footerVNodes = vnodes;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
render: function render(h) {
|
|
112
|
+
var _this3 = this;
|
|
113
|
+
// 渲染主体业务组件
|
|
114
|
+
var dialogChildren = [h(this.contentComponent, {
|
|
115
|
+
props: this.contentProps,
|
|
116
|
+
ref: 'contentComponent',
|
|
117
|
+
on: {
|
|
118
|
+
// 业务组件可以通过 this.$emit('close') 主动关闭弹窗
|
|
119
|
+
close: this.closeDialog,
|
|
120
|
+
// 业务组件可以通过 this.$emit('confirm') 触发外层回调并关闭弹窗
|
|
121
|
+
confirm: this.confirmDialog
|
|
122
|
+
// 【新增】:允许业务组件透传任意自定义事件到外层
|
|
123
|
+
// 如果你的业务组件需要向外抛出自定义事件(如 'save-draft'),
|
|
124
|
+
// 可以在调用 createCommandDialog 时通过 on 属性传入监听器。
|
|
125
|
+
}
|
|
126
|
+
})];
|
|
127
|
+
if (this.footerVNodes) {
|
|
128
|
+
dialogChildren.push(h('template', {
|
|
129
|
+
slot: 'footer'
|
|
130
|
+
}, this.footerVNodes));
|
|
131
|
+
}
|
|
132
|
+
return h('el-dialog', {
|
|
133
|
+
props: {
|
|
134
|
+
title: this.title,
|
|
135
|
+
visible: this.visible,
|
|
136
|
+
width: isMobileDevice() ? '90%' : this.specialWidth ? this.specialWidth : this.width === '30%' ? '30%' : '50%',
|
|
137
|
+
'close-on-click-modal': this.closeOnClickModal,
|
|
138
|
+
showClose: this.showClose,
|
|
139
|
+
'close-on-press-escape': this.closeOnPressEscape,
|
|
140
|
+
customClass: this.customClass
|
|
141
|
+
},
|
|
142
|
+
on: {
|
|
143
|
+
'update:visible': function updateVisible(val) {
|
|
144
|
+
_this3.visible = val;
|
|
145
|
+
},
|
|
146
|
+
'before-close': this.handleBeforeClose,
|
|
147
|
+
close: this.handleClose,
|
|
148
|
+
closed: function closed() {
|
|
149
|
+
_this3.$emit('closed');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}, dialogChildren);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
var instance = new Constructor().$mount();
|
|
156
|
+
document.body.appendChild(instance.$el);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { createCommandDialogPlus };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
import { Button } from 'element-ui';
|
|
4
|
+
import { isMobileDevice } from '../utils/index.js';
|
|
5
|
+
|
|
6
|
+
function createCommandDialog(options) {
|
|
7
|
+
var defaultOptions = {
|
|
8
|
+
title: '提示',
|
|
9
|
+
width: '50%',
|
|
10
|
+
specialWidth: '',
|
|
11
|
+
closeOnClickModal: false,
|
|
12
|
+
contentComponent: null,
|
|
13
|
+
contentProps: {},
|
|
14
|
+
footerBtns: [],
|
|
15
|
+
cancelButtonText: '取消',
|
|
16
|
+
confirmButtonText: '确定',
|
|
17
|
+
isShowBtn: true,
|
|
18
|
+
showClose: true,
|
|
19
|
+
closeOnPressEscape: false,
|
|
20
|
+
customClass: ''
|
|
21
|
+
};
|
|
22
|
+
var mergedOptions = _objectSpread2(_objectSpread2({}, defaultOptions), options);
|
|
23
|
+
var Constructor = Vue.extend({
|
|
24
|
+
data: function data() {
|
|
25
|
+
return {
|
|
26
|
+
visible: false // 初始状态为 false
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
created: function created() {
|
|
30
|
+
// 在 created 钩子中,将配置项直接浅拷贝到 this 实例上
|
|
31
|
+
Object.assign(this, mergedOptions);
|
|
32
|
+
},
|
|
33
|
+
mounted: function mounted() {
|
|
34
|
+
var _this = this;
|
|
35
|
+
Vue.nextTick(function () {
|
|
36
|
+
_this.visible = true;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
methods: {
|
|
40
|
+
handleBeforeClose: function handleBeforeClose() {
|
|
41
|
+
this.visible = false;
|
|
42
|
+
},
|
|
43
|
+
handleClose: function handleClose(done) {
|
|
44
|
+
var _this2 = this;
|
|
45
|
+
this.handleBeforeClose();
|
|
46
|
+
if (typeof this.onClose === 'function') {
|
|
47
|
+
this.onClose(this);
|
|
48
|
+
}
|
|
49
|
+
this.$once('closed', function () {
|
|
50
|
+
_this2.$destroy();
|
|
51
|
+
document.body.removeChild(_this2.$el);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
handleCancel: function handleCancel() {
|
|
55
|
+
this.handleBeforeClose();
|
|
56
|
+
if (typeof this.onCancel === 'function') {
|
|
57
|
+
this.onCancel();
|
|
58
|
+
}
|
|
59
|
+
this.handleClose();
|
|
60
|
+
},
|
|
61
|
+
handleConfirm: function handleConfirm() {
|
|
62
|
+
var _this3 = this;
|
|
63
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
64
|
+
var shouldClose, result, _t;
|
|
65
|
+
return _regenerator().w(function (_context) {
|
|
66
|
+
while (1) switch (_context.p = _context.n) {
|
|
67
|
+
case 0:
|
|
68
|
+
// body组件中统一confirm方法(不能用在别的地方)
|
|
69
|
+
shouldClose = true;
|
|
70
|
+
if (!_this3.$refs.contentComponent.confirm) {
|
|
71
|
+
_context.n = 4;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
_context.p = 1;
|
|
75
|
+
_context.n = 2;
|
|
76
|
+
return _this3.$refs.contentComponent.confirm();
|
|
77
|
+
case 2:
|
|
78
|
+
result = _context.v;
|
|
79
|
+
if (result === false) shouldClose = false;
|
|
80
|
+
_context.n = 4;
|
|
81
|
+
break;
|
|
82
|
+
case 3:
|
|
83
|
+
_context.p = 3;
|
|
84
|
+
_t = _context.v;
|
|
85
|
+
console.error('弹窗确认时发生错误:', _t);
|
|
86
|
+
shouldClose = false;
|
|
87
|
+
case 4:
|
|
88
|
+
if (typeof _this3.onConfirm === 'function' && shouldClose) {
|
|
89
|
+
_this3.onConfirm();
|
|
90
|
+
}
|
|
91
|
+
if (shouldClose) {
|
|
92
|
+
_this3.handleClose();
|
|
93
|
+
}
|
|
94
|
+
case 5:
|
|
95
|
+
return _context.a(2);
|
|
96
|
+
}
|
|
97
|
+
}, _callee, null, [[1, 3]]);
|
|
98
|
+
}))();
|
|
99
|
+
},
|
|
100
|
+
// 函数 return false 弹窗不消失; 不返回或者true 弹窗消失
|
|
101
|
+
footerBtnsClick: function footerBtnsClick(type) {
|
|
102
|
+
var _this4 = this;
|
|
103
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
104
|
+
var result;
|
|
105
|
+
return _regenerator().w(function (_context2) {
|
|
106
|
+
while (1) switch (_context2.n) {
|
|
107
|
+
case 0:
|
|
108
|
+
if (!(_this4.$refs.contentComponent && _this4.$refs.contentComponent[type])) {
|
|
109
|
+
_context2.n = 2;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
_context2.n = 1;
|
|
113
|
+
return _this4.$refs.contentComponent[type]();
|
|
114
|
+
case 1:
|
|
115
|
+
result = _context2.v;
|
|
116
|
+
if (result !== false) {
|
|
117
|
+
_this4.handleClose();
|
|
118
|
+
}
|
|
119
|
+
_context2.n = 3;
|
|
120
|
+
break;
|
|
121
|
+
case 2:
|
|
122
|
+
_this4.handleClose();
|
|
123
|
+
case 3:
|
|
124
|
+
return _context2.a(2);
|
|
125
|
+
}
|
|
126
|
+
}, _callee2);
|
|
127
|
+
}))();
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
render: function render(h) {
|
|
131
|
+
var _this5 = this;
|
|
132
|
+
var footerContent = this.footerBtns.length ? h('div', this.footerBtns.map(function (item) {
|
|
133
|
+
return h(Button, {
|
|
134
|
+
props: {
|
|
135
|
+
type: item.type || 'default',
|
|
136
|
+
size: 'small'
|
|
137
|
+
},
|
|
138
|
+
on: {
|
|
139
|
+
click: function click() {
|
|
140
|
+
return _this5.footerBtnsClick(item.value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, item.label);
|
|
144
|
+
})) : h('div', [h(Button, {
|
|
145
|
+
props: {
|
|
146
|
+
type: 'default',
|
|
147
|
+
size: 'small'
|
|
148
|
+
},
|
|
149
|
+
on: {
|
|
150
|
+
click: this.handleCancel
|
|
151
|
+
}
|
|
152
|
+
}, this.cancelButtonText), h(Button, {
|
|
153
|
+
props: {
|
|
154
|
+
type: 'primary',
|
|
155
|
+
size: 'small'
|
|
156
|
+
},
|
|
157
|
+
on: {
|
|
158
|
+
click: this.handleConfirm
|
|
159
|
+
}
|
|
160
|
+
}, this.confirmButtonText)]);
|
|
161
|
+
return h('el-dialog', {
|
|
162
|
+
props: {
|
|
163
|
+
title: this.title,
|
|
164
|
+
visible: this.visible,
|
|
165
|
+
width: isMobileDevice() ? '90%' : this.specialWidth ? this.specialWidth : this.width === '30%' ? '30%' : '50%',
|
|
166
|
+
'close-on-click-modal': this.closeOnClickModal,
|
|
167
|
+
showClose: this.showClose,
|
|
168
|
+
'close-on-press-escape': this.closeOnPressEscape,
|
|
169
|
+
customClass: this.customClass
|
|
170
|
+
},
|
|
171
|
+
on: {
|
|
172
|
+
'update:visible': function updateVisible(val) {
|
|
173
|
+
_this5.visible = val;
|
|
174
|
+
},
|
|
175
|
+
'before-close': this.handleBeforeClose,
|
|
176
|
+
'close': this.handleClose,
|
|
177
|
+
'closed': function closed() {
|
|
178
|
+
_this5.$emit('closed');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, [h(this.contentComponent, {
|
|
182
|
+
props: this.contentProps,
|
|
183
|
+
ref: 'contentComponent',
|
|
184
|
+
scopedSlots: this.$scopedSlots,
|
|
185
|
+
on: {
|
|
186
|
+
onClose: function onClose() {
|
|
187
|
+
_this5.handleClose();
|
|
188
|
+
},
|
|
189
|
+
onConfirm: function onConfirm() {
|
|
190
|
+
_this5.handleConfirm();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}), !this.isShowBtn ? '' : h('template', {
|
|
194
|
+
slot: 'footer'
|
|
195
|
+
}, [footerContent])]);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
var instance = new Constructor().$mount();
|
|
199
|
+
document.body.appendChild(instance.$el);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { createCommandDialog };
|