dpzvc-ui 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/LICENSE +21 -0
- package/README.md +46 -0
- package/build-style.js +42 -0
- package/dist/dpzvc.js +17605 -0
- package/dist/styles/dpzvc.css +1 -0
- package/dist-prod/index.html +26 -0
- package/dist-prod/main.js +1 -0
- package/dist-prod/vendor.bundle.js +1 -0
- package/package.json +88 -0
- package/src/components/Indicator/Indicator.vue +77 -0
- package/src/components/Indicator/index.js +153 -0
- package/src/components/Text/Number.vue +201 -0
- package/src/components/Text/index.js +7 -0
- package/src/components/Text/textBar.vue +142 -0
- package/src/components/action-sheet/actionSheet.vue +91 -0
- package/src/components/action-sheet/index.js +5 -0
- package/src/components/app.vue +66 -0
- package/src/components/badge/badge.vue +77 -0
- package/src/components/badge/index.js +5 -0
- package/src/components/button/button.vue +122 -0
- package/src/components/button/index.js +5 -0
- package/src/components/card/card.vue +59 -0
- package/src/components/card/index.js +5 -0
- package/src/components/cell/cell.vue +103 -0
- package/src/components/cell/index.js +5 -0
- package/src/components/cell-swipe/cell-swipe.vue +148 -0
- package/src/components/cell-swipe/index.js +5 -0
- package/src/components/checkBox/checkbox-group.vue +76 -0
- package/src/components/checkBox/checkbox.vue +107 -0
- package/src/components/checkBox/index.js +8 -0
- package/src/components/header/header.vue +82 -0
- package/src/components/header/index.js +5 -0
- package/src/components/loadMore/index.js +5 -0
- package/src/components/loadMore/loadmore.vue +293 -0
- package/src/components/message/confirm.js +52 -0
- package/src/components/message/index.js +132 -0
- package/src/components/message/message.vue +135 -0
- package/src/components/message/messageGroup.vue +74 -0
- package/src/components/modal/confirm.js +161 -0
- package/src/components/modal/index.js +63 -0
- package/src/components/modal/modal.vue +144 -0
- package/src/components/picker/area-picker/area-picker.vue +223 -0
- package/src/components/picker/area-picker/props.js +17 -0
- package/src/components/picker/date-picker/date-picker.vue +291 -0
- package/src/components/picker/date-picker/props.js +24 -0
- package/src/components/picker/index.js +5 -0
- package/src/components/picker/normal-picker/normal-picker.vue +107 -0
- package/src/components/picker/normal-picker/props.js +20 -0
- package/src/components/picker/picker-slot.vue +206 -0
- package/src/components/picker/picker.vue +111 -0
- package/src/components/popup/index.js +5 -0
- package/src/components/popup/popup.vue +117 -0
- package/src/components/progress/index.js +5 -0
- package/src/components/progress/progress.vue +77 -0
- package/src/components/prompt/confirm.js +174 -0
- package/src/components/prompt/index.js +50 -0
- package/src/components/prompt/prompt.vue +166 -0
- package/src/components/radioBox/index.js +8 -0
- package/src/components/radioBox/radiobox-group.vue +74 -0
- package/src/components/radioBox/radiobox.vue +117 -0
- package/src/components/rater/index.js +5 -0
- package/src/components/rater/rater.vue +164 -0
- package/src/components/slideBar/index.js +6 -0
- package/src/components/slideBar/slideBar.vue +269 -0
- package/src/components/spinner/behavior/blade.vue +22 -0
- package/src/components/spinner/behavior/double-bounce.vue +22 -0
- package/src/components/spinner/behavior/fading-circle.vue +37 -0
- package/src/components/spinner/behavior/snake.vue +32 -0
- package/src/components/spinner/behavior/triple-bounce.vue +41 -0
- package/src/components/spinner/index.js +5 -0
- package/src/components/spinner/props.js +25 -0
- package/src/components/spinner/spinner.vue +74 -0
- package/src/components/swipe/index.js +5 -0
- package/src/components/swipe/swipe.vue +399 -0
- package/src/components/switchbar/index.js +5 -0
- package/src/components/switchbar/switchbar.vue +83 -0
- package/src/components/tab/index.js +6 -0
- package/src/components/tab/tab.vue +95 -0
- package/src/components/toTop/index.js +5 -0
- package/src/components/toTop/topTop.vue +76 -0
- package/src/components/upload/index.js +5 -0
- package/src/components/upload/upload.vue +200 -0
- package/src/config/config.js +17 -0
- package/src/directives/clickoutside.js +32 -0
- package/src/directives/tranferDom.js +65 -0
- package/src/index.js +83 -0
- package/src/lib/MegaPixImage.js +253 -0
- package/src/lib/exif.js +808 -0
- package/src/main.js +76 -0
- package/src/mixin/emitter.js +41 -0
- package/src/mixin/input.js +41 -0
- package/src/router.js +229 -0
- package/src/styles/base/font.less +99 -0
- package/src/styles/base/reset.less +69 -0
- package/src/styles/base/variable.less +108 -0
- package/src/styles/components/actionSheet.less +43 -0
- package/src/styles/components/badge.less +79 -0
- package/src/styles/components/button.less +123 -0
- package/src/styles/components/card.less +31 -0
- package/src/styles/components/cell-swipe.less +20 -0
- package/src/styles/components/cell.less +71 -0
- package/src/styles/components/checkBox.less +111 -0
- package/src/styles/components/editor.less +3 -0
- package/src/styles/components/header.less +70 -0
- package/src/styles/components/indicator.less +37 -0
- package/src/styles/components/loadmore.less +48 -0
- package/src/styles/components/message.less +57 -0
- package/src/styles/components/modal.less +82 -0
- package/src/styles/components/number.less +58 -0
- package/src/styles/components/picker.less +150 -0
- package/src/styles/components/popup.less +46 -0
- package/src/styles/components/progress.less +50 -0
- package/src/styles/components/prompt.less +37 -0
- package/src/styles/components/radioBox.less +136 -0
- package/src/styles/components/slide-Bar.less +147 -0
- package/src/styles/components/spinner.less +328 -0
- package/src/styles/components/swipe.less +125 -0
- package/src/styles/components/switchBar.less +88 -0
- package/src/styles/components/tab.less +69 -0
- package/src/styles/components/text.less +80 -0
- package/src/styles/components/toTop.less +26 -0
- package/src/styles/components/upload.less +23 -0
- package/src/styles/index.less +38 -0
- package/src/styles/utils/1px.less +204 -0
- package/src/styles/utils/animation.less +131 -0
- package/src/styles/utils/nowrap.less +19 -0
- package/src/template/index.ejs +26 -0
- package/src/utils/util.js +203 -0
- package/src/vconsole-resources.min.js +6 -0
- package/src/vconsole-sources.min.js +6 -0
- package/src/vconsole.min.js +7 -0
- package/src/views/ActionSheet.vue +33 -0
- package/src/views/Badge.vue +40 -0
- package/src/views/Button.vue +40 -0
- package/src/views/Card.vue +52 -0
- package/src/views/Cell.vue +21 -0
- package/src/views/CellSwipe.vue +85 -0
- package/src/views/CheckBox.vue +53 -0
- package/src/views/Header.vue +47 -0
- package/src/views/Indicator.vue +69 -0
- package/src/views/LoadMore.vue +54 -0
- package/src/views/Message.vue +42 -0
- package/src/views/Modal.vue +32 -0
- package/src/views/Picker.vue +50 -0
- package/src/views/Popup.vue +87 -0
- package/src/views/Progress.vue +32 -0
- package/src/views/Prompt.vue +31 -0
- package/src/views/RadioBox.vue +55 -0
- package/src/views/Rater.vue +39 -0
- package/src/views/SlideBar.vue +47 -0
- package/src/views/Spinner.vue +15 -0
- package/src/views/Swipe.vue +34 -0
- package/src/views/SwitchBar.vue +36 -0
- package/src/views/Tab.vue +41 -0
- package/src/views/Text.vue +64 -0
- package/src/views/ToTop.vue +17 -0
- package/src/views/Upload.vue +44 -0
- package/src/views/guide.vue +159 -0
- package/src/views/index.vue +435 -0
- package/webpack.base.config.js +74 -0
- package/webpack.dev.config.js +67 -0
- package/webpack.dist.dev.config.js +44 -0
- package/webpack.dist.prod.config.js +50 -0
- package/webpack.prod.config.js +72 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by admin on 2017/5/10.
|
|
3
|
+
*/
|
|
4
|
+
import Prompt from './confirm'
|
|
5
|
+
|
|
6
|
+
let promptInstance;
|
|
7
|
+
|
|
8
|
+
function getPromptInstance(){
|
|
9
|
+
|
|
10
|
+
promptInstance = promptInstance || Prompt.newInstance({
|
|
11
|
+
|
|
12
|
+
closable:true,
|
|
13
|
+
maskClosable:false,
|
|
14
|
+
footerHide:false
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
return promptInstance;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function confirm (options) {
|
|
21
|
+
|
|
22
|
+
let instance = getPromptInstance();
|
|
23
|
+
|
|
24
|
+
options.onRemove = function () {
|
|
25
|
+
|
|
26
|
+
promptInstance = null;
|
|
27
|
+
}
|
|
28
|
+
console.log(options)
|
|
29
|
+
instance.show(options);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Prompt.info = function (props = {}) {
|
|
34
|
+
|
|
35
|
+
props.showCancle = true;
|
|
36
|
+
|
|
37
|
+
return confirm(props);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Prompt.remove = function (){
|
|
42
|
+
if(!promptInstance) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const instance = getPromptInstance();
|
|
47
|
+
instance.remove();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default Prompt
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<Modal v-model="visible" :width="width" :title="title" :style="styles" :mask-closable="maskClosable">
|
|
4
|
+
|
|
5
|
+
<div class="dpzvc-modal-header-inner ellipse-fir" v-html="title" slot="header"></div>
|
|
6
|
+
<div class="dpzvc-prompt-body-inner" slot="body">
|
|
7
|
+
<div class="dpzvc-prompt-content">
|
|
8
|
+
<span class="dpzvc-prompt-spec">{{spec}}</span>
|
|
9
|
+
<TextBar v-model="text" type="text" :placeholder="placeholder" ></TextBar>
|
|
10
|
+
<div class="dpzvc-prompt-error" v-if="!!message" v-html="message"></div>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<template slot="footer">
|
|
14
|
+
<v-button :styles="{background:'#ffffff',color:'red'}" @click="ok"><span slot="button-inner">{{okText}}</span></v-button>
|
|
15
|
+
<v-button :styles="{background:'#ffffff',color:'#ccc'}" @click="cancle" ><span slot="button-inner">{{cancleText}}</span></v-button>
|
|
16
|
+
</template>
|
|
17
|
+
</Modal>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
|
|
24
|
+
import Modal from '../modal/modal.vue'
|
|
25
|
+
import TextBar from '../Text/textBar.vue'
|
|
26
|
+
import VButton from '../button/button.vue'
|
|
27
|
+
export default {
|
|
28
|
+
props:{
|
|
29
|
+
|
|
30
|
+
val: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ''
|
|
33
|
+
},
|
|
34
|
+
value:{
|
|
35
|
+
type:Boolean,
|
|
36
|
+
default:false
|
|
37
|
+
},
|
|
38
|
+
closable: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true
|
|
41
|
+
},
|
|
42
|
+
maskClosable: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: true
|
|
45
|
+
},
|
|
46
|
+
title: {
|
|
47
|
+
type: String
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
width: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: '220px'
|
|
53
|
+
},
|
|
54
|
+
okText: {
|
|
55
|
+
type: String,
|
|
56
|
+
default () {
|
|
57
|
+
return '确定';
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
cancleText: {
|
|
61
|
+
type: String,
|
|
62
|
+
default () {
|
|
63
|
+
return '取消';
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
loading: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: false
|
|
69
|
+
},
|
|
70
|
+
styles: {
|
|
71
|
+
type: Object
|
|
72
|
+
},
|
|
73
|
+
spec:{
|
|
74
|
+
type:String,
|
|
75
|
+
default:'提示',
|
|
76
|
+
},
|
|
77
|
+
validator:{
|
|
78
|
+
type:[Object,RegExp],
|
|
79
|
+
default:null
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
msg:String,
|
|
83
|
+
placeholderText:String,
|
|
84
|
+
onOk:{
|
|
85
|
+
type:Function,
|
|
86
|
+
default:function(){}
|
|
87
|
+
},
|
|
88
|
+
onCancle:{
|
|
89
|
+
type:Function,
|
|
90
|
+
default:function(){}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
},
|
|
94
|
+
data(){
|
|
95
|
+
return {
|
|
96
|
+
visible:this.value,
|
|
97
|
+
buttonLoading:false,
|
|
98
|
+
text:this.val,
|
|
99
|
+
placeholder:this.placeholderText,
|
|
100
|
+
message:this.msg
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
components:{
|
|
104
|
+
Modal,
|
|
105
|
+
TextBar,
|
|
106
|
+
VButton
|
|
107
|
+
},
|
|
108
|
+
mounted(){
|
|
109
|
+
|
|
110
|
+
},
|
|
111
|
+
watch:{
|
|
112
|
+
val(val){
|
|
113
|
+
this.text = val
|
|
114
|
+
},
|
|
115
|
+
loading(val) {
|
|
116
|
+
this.buttonLoading = val
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
methods:{
|
|
120
|
+
ok(){
|
|
121
|
+
let valid = true;
|
|
122
|
+
if (this.validator) {
|
|
123
|
+
let type = Object.prototype.toString.call(this.validator);
|
|
124
|
+
switch (type) {
|
|
125
|
+
case '[object RegExp]':
|
|
126
|
+
valid = this.validator.test(this.text);
|
|
127
|
+
break;
|
|
128
|
+
case '[object Function]':
|
|
129
|
+
valid = this.validator(this.text);
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
valid = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (valid !== true) {
|
|
136
|
+
|
|
137
|
+
if (typeof valid === 'string') {
|
|
138
|
+
this.message = valid;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.support = true;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (this.loading) {
|
|
146
|
+
this.buttonLoading = true;
|
|
147
|
+
} else {
|
|
148
|
+
this.visible = false;
|
|
149
|
+
}
|
|
150
|
+
if (this.onOk && typeof this.onOk =='function') this.onOk(this.text);
|
|
151
|
+
this.$emit('on-ok',this.text)
|
|
152
|
+
},
|
|
153
|
+
cancle(){
|
|
154
|
+
this.visible = false;
|
|
155
|
+
if (this.onCancle && typeof this.onCancle =='function') this.onCancle();
|
|
156
|
+
|
|
157
|
+
this.$emit('on-cancle')
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
},
|
|
161
|
+
beforeDestroy(){
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
</script>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
|
|
9
|
+
import {findComponentsDownward} from "../../utils/util"
|
|
10
|
+
const prefixCls = 'dpzvc-radioBoxGroup'
|
|
11
|
+
export default {
|
|
12
|
+
name:'radioBoxGroup',
|
|
13
|
+
props:{
|
|
14
|
+
value:{
|
|
15
|
+
type:[String,Boolean,Number]
|
|
16
|
+
},
|
|
17
|
+
vertical:{
|
|
18
|
+
type:Boolean,
|
|
19
|
+
default:false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
mounted(){
|
|
23
|
+
this.updateModel()
|
|
24
|
+
},
|
|
25
|
+
data(){
|
|
26
|
+
return {
|
|
27
|
+
currentValue:this.value,
|
|
28
|
+
children:findComponentsDownward(this,'radioBox')
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
computed:{
|
|
32
|
+
classes(){
|
|
33
|
+
return [
|
|
34
|
+
`${prefixCls}`,
|
|
35
|
+
{
|
|
36
|
+
[`${prefixCls}-vertical`]:this.vertical
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
methods:{
|
|
43
|
+
change(data){
|
|
44
|
+
this.currentValue = data.value;
|
|
45
|
+
this.updateModel();
|
|
46
|
+
this.$emit('input',data.value);
|
|
47
|
+
this.$emit('on-change',data.value);
|
|
48
|
+
this.$emit('on-form-change',data.value)
|
|
49
|
+
},
|
|
50
|
+
updateModel(){
|
|
51
|
+
let value = this.value;
|
|
52
|
+
this.children = findComponentsDownward(this,'radioBox');
|
|
53
|
+
this.children.forEach((child)=>{
|
|
54
|
+
child.model = value == child.label;
|
|
55
|
+
child.isGroup = true;
|
|
56
|
+
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
watch:{
|
|
61
|
+
value(){
|
|
62
|
+
this.updateModel();
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<style scoped >
|
|
69
|
+
.dpzvc-radioBoxGroup-vertical {
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label :class="classes">
|
|
3
|
+
<span :class="wrapperClasses">
|
|
4
|
+
<span :class="innerClasses">
|
|
5
|
+
<input type="radio"
|
|
6
|
+
:disabled="disable"
|
|
7
|
+
:checked="model"
|
|
8
|
+
@change="change"
|
|
9
|
+
:class="inputClass"/>
|
|
10
|
+
</span>
|
|
11
|
+
</span>
|
|
12
|
+
<slot v-if="show"><span ref="slot">{{label}}</span></slot>
|
|
13
|
+
</label>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
import {findComponentUpward} from '../../utils/util'
|
|
18
|
+
import Emitter from '../../mixin/emitter'
|
|
19
|
+
const prefixCls = 'dpzvc-radiobox';
|
|
20
|
+
export default {
|
|
21
|
+
name: 'radioBox',
|
|
22
|
+
mixins: [Emitter],
|
|
23
|
+
props: {
|
|
24
|
+
disable: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
},
|
|
28
|
+
label: {
|
|
29
|
+
type: [Number, String]
|
|
30
|
+
},
|
|
31
|
+
value: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
computed: {
|
|
38
|
+
classes(){
|
|
39
|
+
return [
|
|
40
|
+
`${prefixCls}`,
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
wrapperClasses(){
|
|
45
|
+
return [
|
|
46
|
+
`${prefixCls}-wrapper`,
|
|
47
|
+
{
|
|
48
|
+
[`${prefixCls}-checked`]: this.model,
|
|
49
|
+
[`${prefixCls}-disable`]: this.disable,
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
innerClasses(){
|
|
55
|
+
return [
|
|
56
|
+
`${prefixCls}-inner`
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
inputClass(){
|
|
60
|
+
return [
|
|
61
|
+
`${prefixCls}-input`
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
data(){
|
|
66
|
+
return {
|
|
67
|
+
isGroup: false,
|
|
68
|
+
model: this.value,
|
|
69
|
+
show:true,
|
|
70
|
+
parent: findComponentUpward(this, 'radioBoxGroup')
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
mounted(){
|
|
74
|
+
if (this.parent) {
|
|
75
|
+
|
|
76
|
+
this.isGroup = true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!this.isGroup) {
|
|
80
|
+
|
|
81
|
+
this.model = this.value
|
|
82
|
+
if (this.$refs.slot && this.$refs.slot.innerHtml == '') {
|
|
83
|
+
this.show = false
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
} else {
|
|
87
|
+
this.parent.updateModel();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
},
|
|
91
|
+
methods: {
|
|
92
|
+
change(e){
|
|
93
|
+
if (this.disable) return;
|
|
94
|
+
const checked = e.target.checked;
|
|
95
|
+
this.model = checked;
|
|
96
|
+
this.$emit('input', checked);
|
|
97
|
+
|
|
98
|
+
if (this.isGroup && this.label !== undefined) {
|
|
99
|
+
this.parent.change({value: this.label, checked: this.model})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!this.isGroup) {
|
|
103
|
+
this.$emit('on-change', checked);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
watch: {
|
|
110
|
+
|
|
111
|
+
value(){
|
|
112
|
+
this.model = this.value
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
</script>
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes">
|
|
3
|
+
<span :class="starClass" v-for="(item,key) in max" :style="parentStyles(key)">
|
|
4
|
+
{{star}}
|
|
5
|
+
<span :style="childStyles(key)" @click="changeValue(key)">{{star}}</span>
|
|
6
|
+
</span>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
|
|
12
|
+
const prefixCls = 'dpzvc-rater';
|
|
13
|
+
export default {
|
|
14
|
+
props: {
|
|
15
|
+
value: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: -1
|
|
18
|
+
},
|
|
19
|
+
distance: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default: 10
|
|
22
|
+
},
|
|
23
|
+
max:{
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 5
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 18
|
|
30
|
+
},
|
|
31
|
+
star: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: '★'
|
|
34
|
+
},
|
|
35
|
+
defaultColor: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: '#ccc'
|
|
38
|
+
},
|
|
39
|
+
activeColor: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: '#f5a623'
|
|
42
|
+
},
|
|
43
|
+
disabled:{
|
|
44
|
+
type:Boolean,
|
|
45
|
+
default:false
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
data(){
|
|
49
|
+
return {
|
|
50
|
+
currentValue : this.value,
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
methods: {
|
|
54
|
+
|
|
55
|
+
changeValue(i){
|
|
56
|
+
|
|
57
|
+
if (this.disabled) return
|
|
58
|
+
this.currentValue = i+1;
|
|
59
|
+
|
|
60
|
+
},
|
|
61
|
+
parentStyles(index){
|
|
62
|
+
|
|
63
|
+
const values = Number(this.currentValue);
|
|
64
|
+
const max = Number(this.max);
|
|
65
|
+
|
|
66
|
+
let obj = {};
|
|
67
|
+
obj.fontSize = `${this.size}px`;
|
|
68
|
+
if (!isNaN(values)) {
|
|
69
|
+
|
|
70
|
+
obj.color = this.defaultColor;
|
|
71
|
+
|
|
72
|
+
if (index + 1 < max) {
|
|
73
|
+
obj.marginRight = `${this.distance}px`;
|
|
74
|
+
} else {
|
|
75
|
+
obj.marginRight = `0px`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return obj
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return false;
|
|
82
|
+
|
|
83
|
+
},
|
|
84
|
+
childStyles(index){
|
|
85
|
+
|
|
86
|
+
const values = Number(this.currentValue);
|
|
87
|
+
const max = Number(this.max);
|
|
88
|
+
|
|
89
|
+
let obj = {};
|
|
90
|
+
obj.fontSize = `${this.size}px`;
|
|
91
|
+
if (!isNaN(values)) {
|
|
92
|
+
|
|
93
|
+
if (index + 1 < max) {
|
|
94
|
+
|
|
95
|
+
obj.marginRight = `${this.distance}px`;
|
|
96
|
+
} else {
|
|
97
|
+
obj.marginRight = `0px`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let valueArr = String(values).split('.');
|
|
101
|
+
if(index +1 <= Number(valueArr[0])) {
|
|
102
|
+
obj.color = this.activeColor;
|
|
103
|
+
}
|
|
104
|
+
if (!valueArr.length<2&&Number(valueArr[1])>=5 && index+1 === Number(valueArr[0])+1) {
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
obj.width = '50%';
|
|
108
|
+
obj.color = this.activeColor
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return obj
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return false;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
computed:{
|
|
120
|
+
classes(){
|
|
121
|
+
return [
|
|
122
|
+
`${prefixCls}`
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
starClass(){
|
|
126
|
+
return [
|
|
127
|
+
`${prefixCls}-star`
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
watch:{
|
|
132
|
+
value(val){
|
|
133
|
+
this.currentValue = val
|
|
134
|
+
},
|
|
135
|
+
currentValue(val){
|
|
136
|
+
this.$emit('input',val)
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
</script>
|
|
142
|
+
|
|
143
|
+
<style lang="less">
|
|
144
|
+
.dpzvc-rater {
|
|
145
|
+
|
|
146
|
+
&-star {
|
|
147
|
+
color: #e9e9e9;
|
|
148
|
+
position: relative;
|
|
149
|
+
display: inline-block;
|
|
150
|
+
> span {
|
|
151
|
+
position: absolute;
|
|
152
|
+
height: 100%;
|
|
153
|
+
content: '★';
|
|
154
|
+
left: 0;
|
|
155
|
+
top: 0;
|
|
156
|
+
color: #e9e9e9;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
</style>
|