Skip to content

Commit af8251f

Browse files
author
xutao15
committed
add component modal
1 parent ec9e9c3 commit af8251f

File tree

25 files changed

+2412
-240
lines changed

25 files changed

+2412
-240
lines changed

dist/components/index/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/components/index/index.vue

Lines changed: 0 additions & 93 deletions
This file was deleted.

dist/components/index/style/css.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/components/index/style/index.css

Lines changed: 0 additions & 71 deletions
This file was deleted.

dist/components/index/style/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/components/index/style/index.less

Lines changed: 0 additions & 70 deletions
This file was deleted.

dist/components/modal/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import modal from 'modal.vue'
2+
3+
export default modal

dist/components/modal/modal.vue

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<template>
2+
<div>
3+
<div class="i-modal-mask" :class="[visible ? 'i-modal-mask-show' : '', iClass, iClassMask]"></div>
4+
<div class="i-modal" :class="[visible ? 'i-modal-show' : '', iClass]">
5+
<div class="i-modal-main">
6+
<div class="i-modal-content">
7+
<div class="i-modal-title" v-if="title">{{ title }}</div>
8+
<div class="i-modal-body"><slot></slot></div>
9+
<div class="i-modal-actions" v-if="actions.length">
10+
<block v-if="actionMode === 'horizontal'">
11+
<div class="i-modal-grid">
12+
<div v-for="(item, index) in actions" :key="index" :class="[actions.length === index + 1 ? 'i-modal-grid-item-last' : 'i-modal-grid-item']">
13+
<button class="i-btn i-btn-long i-btn-ghost i-btn-square" :data-index="index" @click="handleClickItem" plain="true">
14+
<view class="i-modal-btn-loading" v-if="item.loading"></view>
15+
<i-icon v-if="item.icon" :type="item.icon" i-class="i-modal-btn-icon"></i-icon>
16+
<view class="i-modal-btn-text" :style="{color: item.color}">{{ item.name }}</view>
17+
</button>
18+
</div>
19+
</div>
20+
</block>
21+
<block v-else>
22+
<div class="i-modal-action-vertical" v-for="(item, index) in actions" :key="item.name">
23+
<button class="i-btn i-btn-long i-btn-ghost i-btn-square" :data-index="index" @click="handleClickItem" plain="true">
24+
<view class="i-modal-btn-loading" v-if="item.loading"></view>
25+
<i-icon v-if="item.icon" :type="item.icon" i-class="i-modal-btn-icon"></i-icon>
26+
<view class="i-modal-btn-text" :style="item.color ? 'color: ' + item.color : ''">{{ item.name }}</view>
27+
</button>
28+
</div>
29+
</block>
30+
</div>
31+
<div class="i-modal-actions" v-else>
32+
<div class="i-modal-grid" v-if="showOk">
33+
<div class="i-modal-grid-item" v-if="showCancel">
34+
<button class="i-btn i-btn-long i-btn-ghost i-btn-square i-modal-btn-cancel" long="true" type="ghost" @click="handleClickCancel" plain="true">{{cancelText}}</button>
35+
</div>
36+
<div class="i-modal-grid-item-last" v-if="showOk">
37+
<button class="i-btn i-btn-long i-btn-ghost i-btn-square i-modal-btn-ok" long="true" type="ghost" @click="handleClickOk" plain="true">{{okText}}</button>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
</div>
43+
</div>
44+
</div>
45+
</template>
46+
<script>
47+
import icon from '../icon/icon'
48+
export default {
49+
components: {
50+
'i-icon': icon
51+
},
52+
props: {
53+
visible: {
54+
type: Boolean,
55+
default: false
56+
},
57+
title: {
58+
type: String,
59+
default: ''
60+
},
61+
showOk: {
62+
type: Boolean,
63+
default: true
64+
},
65+
showCancel: {
66+
type: Boolean,
67+
default: true
68+
},
69+
okText: {
70+
type: String,
71+
default: '确定'
72+
},
73+
cancelText: {
74+
type: String,
75+
default: '取消'
76+
},
77+
actions: {
78+
type: Array,
79+
default: []
80+
},
81+
actionMode: {
82+
type: String,
83+
default: 'horizontal'
84+
},
85+
iClass: {
86+
type: String,
87+
default: ''
88+
},
89+
iClassMask: {
90+
type: String,
91+
default: ''
92+
}
93+
},
94+
methods: {
95+
handleClickItem(evt) {
96+
const target = evt.currentTarget || evt.target
97+
const dataSet = target && target.dataset
98+
const {index} = dataSet
99+
this.$emit('click', {index})
100+
},
101+
handleClickOk() {
102+
this.$emit('ok')
103+
},
104+
handleClickCancel() {
105+
this.$emit('cancel')
106+
}
107+
}
108+
}
109+
</script>

dist/components/modal/style/css.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './modal.css'

dist/components/modal/style/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './modal.less'

0 commit comments

Comments
 (0)