dpzvc-ui 1.2.1 → 1.2.3

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.
@@ -1,174 +1,75 @@
1
1
  /**
2
- * Created by admin on 2017/5/10.
2
+ * Created by admin on 2025/12/10
3
+ * Rewritten for Vue 2.7 + Vue CLI (runtime-only)
3
4
  */
4
- import Prompt from '../prompt/prompt.vue'
5
- import Vue from 'vue'
6
-
7
- import {camelcaseToHyphen} from '../../utils/util'
8
-
9
- const prefixCls = 'v-lc-modal';
10
-
11
- Prompt.newInstance = properties => {
12
-
13
- let _props = properties || {};
14
-
15
- let props = '';
16
-
17
- Object.keys(_props).forEach(prop => {
18
-
19
- props += ' :' + camelcaseToHyphen(prop) + '=' + prop
20
- })
21
-
22
-
23
- const div = document.createElement('div');
24
-
25
- document.body.appendChild(div);
26
-
27
- const propmt = new Vue({
28
- el: div,
29
-
30
- template: `<Prompt ${props} v-model="visible"
31
- :width="width"
32
- :text="text"
33
- :title="title"
34
- :ok-text="okText"
35
- :cancle-text="cancleText"
36
- :loading="loading"
37
- :spec="spec"
38
- :message="message"
39
- :validator="validator"
40
- :on-ok="onOk"
41
- :on-cancle="onCancle"> </Prompt>`,
42
- components: {
43
- Prompt
44
- },
45
- data: Object.assign(_props, {
46
- text:'',
47
- placeholderText: '请输入',
48
- visible: false,
49
- width: '70%',
50
- title: '',
51
- okText: '确定',
52
- cancleText: '取消',
53
- loading: false,
54
- showCancle: true,
55
- spec: '',
56
- message: '',
57
- validator: null,
58
- onOk:function(){},
59
- onCancle:function(prop){},
60
- onRemove:function(){}
61
- }),
62
- methods: {
63
- cancle(){
64
- this.$children[0].visible = false;
65
- this.onCancle();
66
- this.remove();
67
- },
68
- ok(){
69
- if (this.loading) {
70
- this.buttonLoading = true;
71
- } else {
72
- this.visible = false;
73
- this.remove();
74
- }
75
-
76
- this.onOk()
77
- },
78
- remove(){
79
- this.$children[0].visible = false;
80
- setTimeout(() => {
81
- this.destroy();
82
- }, 300)
83
- },
84
- destroy(){
85
- this.$destroy();
86
- document.body.removeChild(this.$el);
87
- this.onRemove()
88
- },
89
- mounted(){
90
-
91
-
92
- },
93
- }
94
- }).$children[0]
95
-
96
-
97
- return {
98
-
99
- show(props){
100
-
101
- propmt.$parent.showCancle = props.showCancle;
102
- propmt.$parent.onRemove = props.onRemove;
103
- propmt.visible = true;
104
5
 
105
- if ('width' in props) {
106
- propmt.$parent.width = props.width
107
- }
108
-
109
- if ('text' in props) {
110
- propmt.$parent.text = props.text
111
- }
112
-
113
- if ('spec' in props) {
114
- propmt.$parent.spec = props.spec
115
- }
116
-
117
- if ('title' in props) {
118
-
119
- propmt.$parent.title = props.title
120
- }
121
-
122
-
123
-
124
- if ('placeholderText' in props) {
125
- propmt.$parent.placeholderText = props.placeholderText
126
- }
127
-
128
- if ('content' in props) {
129
- propmt.$parent.body = props.body
130
- }
131
-
132
-
133
- if ('okText' in props) {
134
- propmt.$parent.okText = props.okText
135
- }
136
-
137
- if ('cancleText' in props) {
138
- propmt.$parent.cancleText = props.cancleText
139
- }
140
-
141
- if ('onCancle' in props) {
142
- propmt.$parent.onCancle = props.onCancle
143
- }
144
-
145
- if ('onOk' in props) {
146
- propmt.$parent.onOk = props.onOk
147
- }
148
-
149
- if ('loading' in props) {
150
- propmt.$parent.loading = props.loading
151
- }
152
-
153
- if ('message' in props) {
154
- propmt.$parent.message = props.message
155
- }
156
-
157
- if ('validator' in props) {
158
- propmt.$parent.validator = props.validator
159
- }
160
-
161
- console.log(propmt.$parent)
162
- },
163
- remove () {
164
-
165
- propmt.visible = false;
166
- propmt.$parent.buttonLoading = false;
167
- propmt.$parent.remove();
6
+ import Vue from 'vue'
7
+ import Prompt from '../prompt/prompt.vue'
168
8
 
169
- },
170
- component: propmt
9
+ Prompt.newInstance = (properties = {}) => {
10
+ // 1. 创建构造器
11
+ const PromptConstructor = Vue.extend(Prompt)
12
+
13
+ // 2. 初始化 props(等价你之前 data + v-model)
14
+ const instance = new PromptConstructor({
15
+ propsData: {
16
+ // 外部传入
17
+ ...properties,
18
+
19
+ // 默认值(保持你原来的语义)
20
+ visible: false,
21
+ text: '',
22
+ placeholderText: '请输入',
23
+ width: '70%',
24
+ title: '',
25
+ okText: '确定',
26
+ cancleText: '取消',
27
+ loading: false,
28
+ showCancle: true,
29
+ spec: '',
30
+ message: '',
31
+ validator: null,
32
+ onOk: () => {},
33
+ onCancle: () => {},
171
34
  }
172
- };
173
-
174
- export default Prompt;
35
+ })
36
+
37
+ // 3. 挂载到 DOM
38
+ instance.$mount()
39
+ document.body.appendChild(instance.$el)
40
+
41
+ // 4. 移除逻辑(统一)
42
+ const destroy = () => {
43
+ instance.visible = false
44
+ setTimeout(() => {
45
+ instance.$destroy()
46
+ instance.$el && document.body.removeChild(instance.$el)
47
+ instance.onRemove && instance.onRemove()
48
+ }, 300)
49
+ }
50
+
51
+ return {
52
+ /**
53
+ * 显示 Prompt
54
+ */
55
+ show(props = {}) {
56
+ Object.keys(props).forEach(key => {
57
+ instance[key] = props[key]
58
+ })
59
+ instance.visible = true
60
+ },
61
+
62
+ /**
63
+ * 关闭 Prompt
64
+ */
65
+ remove() {
66
+ instance.visible = false
67
+ instance.buttonLoading = false
68
+ destroy()
69
+ },
70
+
71
+ component: instance
72
+ }
73
+ }
74
+
75
+ export default Prompt