@idooel/components 0.0.1-beta.21 → 0.0.1-beta.22
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/dist/@idooel/components.esm.js +954 -584
- package/dist/@idooel/components.umd.js +964 -592
- package/package.json +49 -46
- package/packages/alert/index.js +4 -4
- package/packages/alert/src/index.vue +45 -45
- package/packages/batch-export/index.js +4 -4
- package/packages/batch-export/src/index.vue +108 -106
- package/packages/button/index.js +4 -4
- package/packages/button/src/index.vue +54 -54
- package/packages/checkbox/index.js +4 -4
- package/packages/checkbox/src/index.vue +43 -43
- package/packages/composite-components/attachment/src/index.vue +14 -14
- package/packages/composite-components/button-group/index.js +4 -4
- package/packages/composite-components/button-group/src/index.vue +53 -45
- package/packages/composite-components/modal-import/index.js +4 -4
- package/packages/composite-components/modal-import/src/index.vue +27 -27
- package/packages/composite-components/search-area/index.js +4 -4
- package/packages/composite-components/search-area/src/index.vue +225 -225
- package/packages/composite-components/search-area/src/label.vue +35 -35
- package/packages/date/index.js +4 -4
- package/packages/date/src/index.vue +39 -39
- package/packages/date-range/index.js +4 -4
- package/packages/date-range/src/index.vue +47 -47
- package/packages/form/index.js +4 -4
- package/packages/form/src/index.vue +212 -212
- package/packages/form-group-model/index.js +4 -4
- package/packages/form-group-model/src/index.vue +273 -273
- package/packages/form-model/index.js +4 -4
- package/packages/form-model/src/index.vue +165 -165
- package/packages/icon/index.js +4 -4
- package/packages/icon/src/index.vue +31 -31
- package/packages/img-crop/index.js +5 -0
- package/packages/img-crop/src/index.vue +181 -0
- package/packages/index.js +89 -84
- package/packages/input/index.js +4 -4
- package/packages/input/src/index.vue +35 -35
- package/packages/input-number/index.js +4 -4
- package/packages/input-number/src/index.vue +23 -23
- package/packages/modal/index.js +4 -4
- package/packages/modal/src/index.vue +146 -141
- package/packages/radio/index.js +4 -4
- package/packages/radio/src/index.vue +51 -51
- package/packages/select/index.js +4 -4
- package/packages/select/src/index.vue +92 -92
- package/packages/select-entity/index.js +4 -4
- package/packages/select-entity/src/index.vue +113 -113
- package/packages/step-model/index.js +4 -4
- package/packages/step-model/src/index.vue +196 -173
- package/packages/table/index.js +4 -4
- package/packages/table/src/action.vue +131 -131
- package/packages/table/src/index.vue +157 -157
- package/packages/tabs/index.js +4 -4
- package/packages/tabs/src/index.vue +55 -54
- package/packages/text-editor/index.js +5 -0
- package/packages/text-editor/src/index.vue +73 -0
- package/packages/textarea/index.js +4 -4
- package/packages/textarea/src/index.vue +57 -57
- package/packages/theme/form.scss +21 -21
- package/packages/theme/index.scss +31 -27
- package/packages/theme/styleClass.scss +3 -0
- package/packages/theme/variables.scss +55 -55
- package/packages/tpl/index.js +4 -4
- package/packages/tpl/src/index.vue +55 -55
- package/packages/tree/index.js +4 -4
- package/packages/tree/src/TreeNode.vue +29 -29
- package/packages/tree/src/index.vue +101 -101
- package/packages/tree-table-model/index.js +4 -4
- package/packages/tree-table-model/src/index.vue +314 -314
- package/packages/upload/index.js +4 -4
- package/packages/upload/src/index.vue +348 -348
- package/packages/utils/index.js +23 -23
- package/scripts/rollup.config.js +35 -35
- package/scripts/rollup.esm.config.js +11 -11
- package/scripts/rollup.umd.config.js +14 -14
|
@@ -1,166 +1,166 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="form__model--wrapper">
|
|
3
|
-
<div class="form-model__title" v-if="title">
|
|
4
|
-
{{ title }}
|
|
5
|
-
</div>
|
|
6
|
-
<div class="form-model__content">
|
|
7
|
-
<ele-form :ref="formRef" :elements="elements"></ele-form>
|
|
8
|
-
</div>
|
|
9
|
-
<div class="form-model__footer" v-if="footerMeta">
|
|
10
|
-
<ele-button-group v-on="assignAttrForEvents" :data-source="footerElements"></ele-button-group>
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
import EleButtonGroup from '../../composite-components/button-group/src/index.vue'
|
|
17
|
-
import { BUILT_IN_EVENT_NAMES, parseFieldMap, RESERVE_EVENT_NAMES } from '../../utils'
|
|
18
|
-
import { v4 as uuidv4 } from 'uuid'
|
|
19
|
-
import { net } from '@idooel/shared'
|
|
20
|
-
export default {
|
|
21
|
-
name: 'ele-form-model',
|
|
22
|
-
components: {
|
|
23
|
-
EleButtonGroup
|
|
24
|
-
},
|
|
25
|
-
props: {
|
|
26
|
-
title: {
|
|
27
|
-
type: String
|
|
28
|
-
},
|
|
29
|
-
formMeta: {
|
|
30
|
-
type: Object
|
|
31
|
-
},
|
|
32
|
-
footerMeta: {
|
|
33
|
-
type: Object
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
data() {
|
|
37
|
-
return {}
|
|
38
|
-
},
|
|
39
|
-
computed: {
|
|
40
|
-
formRef () {
|
|
41
|
-
return uuidv4()
|
|
42
|
-
},
|
|
43
|
-
assignAttrForEvents () {
|
|
44
|
-
const events = this.footerElements.reduce((ret, ele) => {
|
|
45
|
-
ret[ele.eventName] = (e) => {
|
|
46
|
-
this.$emit(ele.eventName || 'click', { ...e, formModel: this.formModels })
|
|
47
|
-
}
|
|
48
|
-
return ret
|
|
49
|
-
}, {})
|
|
50
|
-
return {
|
|
51
|
-
...this.$listeners,
|
|
52
|
-
...events,
|
|
53
|
-
[BUILT_IN_EVENT_NAMES.SUBMIT]: this[BUILT_IN_EVENT_NAMES.SUBMIT],
|
|
54
|
-
[BUILT_IN_EVENT_NAMES.CANCEL]: this[BUILT_IN_EVENT_NAMES.CANCEL]
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
elements () {
|
|
58
|
-
const { elements } = this.formMeta
|
|
59
|
-
return elements
|
|
60
|
-
},
|
|
61
|
-
preRequest () {
|
|
62
|
-
const { preRequest } = this.formMeta
|
|
63
|
-
return preRequest
|
|
64
|
-
},
|
|
65
|
-
infoRequest () {
|
|
66
|
-
const { infoRequest } = this.formMeta
|
|
67
|
-
return infoRequest
|
|
68
|
-
},
|
|
69
|
-
submitRequest () {
|
|
70
|
-
const { submitRequest } = this.formMeta
|
|
71
|
-
return submitRequest
|
|
72
|
-
},
|
|
73
|
-
footerElements () {
|
|
74
|
-
const { elements } = this.footerMeta
|
|
75
|
-
return elements.call(this)
|
|
76
|
-
},
|
|
77
|
-
formModels () {
|
|
78
|
-
return this.$refs[this.formRef].getFieldsValue()
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
methods: {
|
|
82
|
-
execFieldMap (fieldMap = {}, dataSource = {}) {
|
|
83
|
-
const ret = parseFieldMap(fieldMap, { _route: this.$route.query, ...dataSource})
|
|
84
|
-
return ret
|
|
85
|
-
},
|
|
86
|
-
async submitRequestTrigger (props = {}) {
|
|
87
|
-
const { url, requestType, headers = {}, params = {}, fieldMap = {} } = this.submitRequest
|
|
88
|
-
if (!url) return
|
|
89
|
-
const ret = await net[requestType.toLowerCase()](url, { ...params, ...this.execFieldMap(fieldMap, { ...this.formModels }), ...this.formModels }, { headers }).then(resp => {
|
|
90
|
-
console.log(resp.data)
|
|
91
|
-
this.$emit(BUILT_IN_EVENT_NAMES.SUBMIT, { ...props, formModel: { ...this.formModels, ...resp.data || {} } })
|
|
92
|
-
return resp.data
|
|
93
|
-
})
|
|
94
|
-
return ret
|
|
95
|
-
},
|
|
96
|
-
async infoRequestTrigger () {
|
|
97
|
-
const { url, requestType, params = {}, fieldMap = {}, headers = {} } = this.infoRequest
|
|
98
|
-
if (!url) return
|
|
99
|
-
net[requestType.toLowerCase()](url, { ...params, ...this.execFieldMap(fieldMap) }, { ...headers }).then(resp => {
|
|
100
|
-
const { data = {} } = resp
|
|
101
|
-
this.setFieldsValue(data)
|
|
102
|
-
this.$emit(RESERVE_EVENT_NAMES.INIT_FORM, { ...data })
|
|
103
|
-
})
|
|
104
|
-
},
|
|
105
|
-
async preRequestTrigger () {
|
|
106
|
-
const { url, requestType = 'GET', params = {}, fieldMap = {}, headers = {} } = this.preRequest
|
|
107
|
-
if (!url) return
|
|
108
|
-
const { data } = await net[requestType.toLowerCase()](url, { ...params, ...fieldMap }, { ...headers })
|
|
109
|
-
this.$emit(RESERVE_EVENT_NAMES.INIT_FORM, { ...data })
|
|
110
|
-
},
|
|
111
|
-
setFieldsValue (props) {
|
|
112
|
-
this.$refs[this.formRef].setFieldsValue(props)
|
|
113
|
-
},
|
|
114
|
-
validateFields () {
|
|
115
|
-
return this.$refs[this.formRef].validateFields()
|
|
116
|
-
},
|
|
117
|
-
[BUILT_IN_EVENT_NAMES.SUBMIT] (props = {}) {
|
|
118
|
-
const status = this.$refs[this.formRef].validateFields()
|
|
119
|
-
if (status) {
|
|
120
|
-
//TODO fieldMap
|
|
121
|
-
return this.submitRequestTrigger(props)
|
|
122
|
-
} else {
|
|
123
|
-
return false
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
[BUILT_IN_EVENT_NAMES.CANCEL] (props = {}) {
|
|
127
|
-
this.$emit(BUILT_IN_EVENT_NAMES.CANCEL, { ...props })
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
async mounted() {
|
|
131
|
-
await this.preRequestTrigger()
|
|
132
|
-
await this.infoRequestTrigger()
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
</script>
|
|
136
|
-
|
|
137
|
-
<style lang="scss" scoped>
|
|
138
|
-
.form__model--wrapper {
|
|
139
|
-
width: 100%;
|
|
140
|
-
height: 100%;
|
|
141
|
-
overflow: auto;
|
|
142
|
-
background: #fff;
|
|
143
|
-
.form-model__title {
|
|
144
|
-
height: 56px;
|
|
145
|
-
padding: 0 16px;
|
|
146
|
-
display: flex;
|
|
147
|
-
flex-direction: row;
|
|
148
|
-
align-items: center;
|
|
149
|
-
border-bottom: 1px solid var(--idooel-form-title-border-color);
|
|
150
|
-
}
|
|
151
|
-
.form-model__content {
|
|
152
|
-
padding: 16px;
|
|
153
|
-
}
|
|
154
|
-
.form-model__footer {
|
|
155
|
-
/* width: 100%; */
|
|
156
|
-
height: 64px;
|
|
157
|
-
position: fixed;
|
|
158
|
-
bottom: 0;
|
|
159
|
-
display: flex;
|
|
160
|
-
float: right;
|
|
161
|
-
flex-direction: row;
|
|
162
|
-
align-items: center;
|
|
163
|
-
justify-content: end;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="form__model--wrapper">
|
|
3
|
+
<div class="form-model__title" v-if="title">
|
|
4
|
+
{{ title }}
|
|
5
|
+
</div>
|
|
6
|
+
<div class="form-model__content">
|
|
7
|
+
<ele-form :ref="formRef" :elements="elements"></ele-form>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="form-model__footer" v-if="footerMeta">
|
|
10
|
+
<ele-button-group v-on="assignAttrForEvents" :data-source="footerElements"></ele-button-group>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import EleButtonGroup from '../../composite-components/button-group/src/index.vue'
|
|
17
|
+
import { BUILT_IN_EVENT_NAMES, parseFieldMap, RESERVE_EVENT_NAMES } from '../../utils'
|
|
18
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
19
|
+
import { net } from '@idooel/shared'
|
|
20
|
+
export default {
|
|
21
|
+
name: 'ele-form-model',
|
|
22
|
+
components: {
|
|
23
|
+
EleButtonGroup
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
title: {
|
|
27
|
+
type: String
|
|
28
|
+
},
|
|
29
|
+
formMeta: {
|
|
30
|
+
type: Object
|
|
31
|
+
},
|
|
32
|
+
footerMeta: {
|
|
33
|
+
type: Object
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
data() {
|
|
37
|
+
return {}
|
|
38
|
+
},
|
|
39
|
+
computed: {
|
|
40
|
+
formRef () {
|
|
41
|
+
return uuidv4()
|
|
42
|
+
},
|
|
43
|
+
assignAttrForEvents () {
|
|
44
|
+
const events = this.footerElements.reduce((ret, ele) => {
|
|
45
|
+
ret[ele.eventName] = (e) => {
|
|
46
|
+
this.$emit(ele.eventName || 'click', { ...e, formModel: this.formModels })
|
|
47
|
+
}
|
|
48
|
+
return ret
|
|
49
|
+
}, {})
|
|
50
|
+
return {
|
|
51
|
+
...this.$listeners,
|
|
52
|
+
...events,
|
|
53
|
+
[BUILT_IN_EVENT_NAMES.SUBMIT]: this[BUILT_IN_EVENT_NAMES.SUBMIT],
|
|
54
|
+
[BUILT_IN_EVENT_NAMES.CANCEL]: this[BUILT_IN_EVENT_NAMES.CANCEL]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
elements () {
|
|
58
|
+
const { elements } = this.formMeta
|
|
59
|
+
return elements
|
|
60
|
+
},
|
|
61
|
+
preRequest () {
|
|
62
|
+
const { preRequest } = this.formMeta
|
|
63
|
+
return preRequest
|
|
64
|
+
},
|
|
65
|
+
infoRequest () {
|
|
66
|
+
const { infoRequest } = this.formMeta
|
|
67
|
+
return infoRequest
|
|
68
|
+
},
|
|
69
|
+
submitRequest () {
|
|
70
|
+
const { submitRequest } = this.formMeta
|
|
71
|
+
return submitRequest
|
|
72
|
+
},
|
|
73
|
+
footerElements () {
|
|
74
|
+
const { elements } = this.footerMeta
|
|
75
|
+
return elements.call(this)
|
|
76
|
+
},
|
|
77
|
+
formModels () {
|
|
78
|
+
return this.$refs[this.formRef].getFieldsValue()
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
methods: {
|
|
82
|
+
execFieldMap (fieldMap = {}, dataSource = {}) {
|
|
83
|
+
const ret = parseFieldMap(fieldMap, { _route: this.$route.query, ...dataSource})
|
|
84
|
+
return ret
|
|
85
|
+
},
|
|
86
|
+
async submitRequestTrigger (props = {}) {
|
|
87
|
+
const { url, requestType, headers = {}, params = {}, fieldMap = {} } = this.submitRequest
|
|
88
|
+
if (!url) return
|
|
89
|
+
const ret = await net[requestType.toLowerCase()](url, { ...params, ...this.execFieldMap(fieldMap, { ...this.formModels }), ...this.formModels }, { headers }).then(resp => {
|
|
90
|
+
console.log(resp.data)
|
|
91
|
+
this.$emit(BUILT_IN_EVENT_NAMES.SUBMIT, { ...props, formModel: { ...this.formModels, ...resp.data || {} } })
|
|
92
|
+
return resp.data
|
|
93
|
+
})
|
|
94
|
+
return ret
|
|
95
|
+
},
|
|
96
|
+
async infoRequestTrigger () {
|
|
97
|
+
const { url, requestType, params = {}, fieldMap = {}, headers = {} } = this.infoRequest
|
|
98
|
+
if (!url) return
|
|
99
|
+
net[requestType.toLowerCase()](url, { ...params, ...this.execFieldMap(fieldMap) }, { ...headers }).then(resp => {
|
|
100
|
+
const { data = {} } = resp
|
|
101
|
+
this.setFieldsValue(data)
|
|
102
|
+
this.$emit(RESERVE_EVENT_NAMES.INIT_FORM, { ...data })
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
async preRequestTrigger () {
|
|
106
|
+
const { url, requestType = 'GET', params = {}, fieldMap = {}, headers = {} } = this.preRequest
|
|
107
|
+
if (!url) return
|
|
108
|
+
const { data } = await net[requestType.toLowerCase()](url, { ...params, ...fieldMap }, { ...headers })
|
|
109
|
+
this.$emit(RESERVE_EVENT_NAMES.INIT_FORM, { ...data })
|
|
110
|
+
},
|
|
111
|
+
setFieldsValue (props) {
|
|
112
|
+
this.$refs[this.formRef].setFieldsValue(props)
|
|
113
|
+
},
|
|
114
|
+
validateFields () {
|
|
115
|
+
return this.$refs[this.formRef].validateFields()
|
|
116
|
+
},
|
|
117
|
+
[BUILT_IN_EVENT_NAMES.SUBMIT] (props = {}) {
|
|
118
|
+
const status = this.$refs[this.formRef].validateFields()
|
|
119
|
+
if (status) {
|
|
120
|
+
//TODO fieldMap
|
|
121
|
+
return this.submitRequestTrigger(props)
|
|
122
|
+
} else {
|
|
123
|
+
return false
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[BUILT_IN_EVENT_NAMES.CANCEL] (props = {}) {
|
|
127
|
+
this.$emit(BUILT_IN_EVENT_NAMES.CANCEL, { ...props })
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
async mounted() {
|
|
131
|
+
await this.preRequestTrigger()
|
|
132
|
+
await this.infoRequestTrigger()
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
</script>
|
|
136
|
+
|
|
137
|
+
<style lang="scss" scoped>
|
|
138
|
+
.form__model--wrapper {
|
|
139
|
+
width: 100%;
|
|
140
|
+
height: 100%;
|
|
141
|
+
overflow: auto;
|
|
142
|
+
background: #fff;
|
|
143
|
+
.form-model__title {
|
|
144
|
+
height: 56px;
|
|
145
|
+
padding: 0 16px;
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-direction: row;
|
|
148
|
+
align-items: center;
|
|
149
|
+
border-bottom: 1px solid var(--idooel-form-title-border-color);
|
|
150
|
+
}
|
|
151
|
+
.form-model__content {
|
|
152
|
+
padding: 16px;
|
|
153
|
+
}
|
|
154
|
+
.form-model__footer {
|
|
155
|
+
/* width: 100%; */
|
|
156
|
+
height: 64px;
|
|
157
|
+
position: fixed;
|
|
158
|
+
bottom: 0;
|
|
159
|
+
display: flex;
|
|
160
|
+
float: right;
|
|
161
|
+
flex-direction: row;
|
|
162
|
+
align-items: center;
|
|
163
|
+
justify-content: end;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
166
|
</style>
|
package/packages/icon/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import EleIcon from './src/index.vue'
|
|
2
|
-
|
|
3
|
-
EleIcon.install = Vue => Vue.component(EleIcon.name, EleIcon)
|
|
4
|
-
|
|
1
|
+
import EleIcon from './src/index.vue'
|
|
2
|
+
|
|
3
|
+
EleIcon.install = Vue => Vue.component(EleIcon.name, EleIcon)
|
|
4
|
+
|
|
5
5
|
export default EleIcon
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<a-icon
|
|
3
|
-
v-if="isAntIcon"
|
|
4
|
-
:type="type"
|
|
5
|
-
:theme="theme">
|
|
6
|
-
</a-icon>
|
|
7
|
-
<i :class="['iconfont', type]" v-else></i>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script>
|
|
11
|
-
export default {
|
|
12
|
-
name: 'ele-icon',
|
|
13
|
-
props: {
|
|
14
|
-
type: {
|
|
15
|
-
type: String,
|
|
16
|
-
default: ''
|
|
17
|
-
},
|
|
18
|
-
theme: {
|
|
19
|
-
type: String
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
computed: {
|
|
23
|
-
isAntIcon() {
|
|
24
|
-
const prefix = this.type.slice(0, 5)
|
|
25
|
-
if (prefix === 'icon-') {
|
|
26
|
-
return false
|
|
27
|
-
}
|
|
28
|
-
return true
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<a-icon
|
|
3
|
+
v-if="isAntIcon"
|
|
4
|
+
:type="type"
|
|
5
|
+
:theme="theme">
|
|
6
|
+
</a-icon>
|
|
7
|
+
<i :class="['iconfont', type]" v-else></i>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
export default {
|
|
12
|
+
name: 'ele-icon',
|
|
13
|
+
props: {
|
|
14
|
+
type: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: ''
|
|
17
|
+
},
|
|
18
|
+
theme: {
|
|
19
|
+
type: String
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
computed: {
|
|
23
|
+
isAntIcon() {
|
|
24
|
+
const prefix = this.type.slice(0, 5)
|
|
25
|
+
if (prefix === 'icon-') {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
32
|
</script>
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<EleModal
|
|
4
|
+
:ref="getEleModal"
|
|
5
|
+
:title="title"
|
|
6
|
+
:cancelText="cancelText"
|
|
7
|
+
:maskClosable="maskClosable"
|
|
8
|
+
:size="size"
|
|
9
|
+
v-model="showTestModal"
|
|
10
|
+
:showDefaultFooter="true"
|
|
11
|
+
>
|
|
12
|
+
<div class="ele-imgCrop__wrapper">
|
|
13
|
+
<div class="ele-imgCrop__left ele-imgCrop__item">
|
|
14
|
+
<div class="ele-imgCrop__noImg">
|
|
15
|
+
<input @change="handleChange" ref="input" type="file" accept="image/png, image/jpeg, image/jpg" id="fileinput1" class="ele-imgCrop__update"/>
|
|
16
|
+
<ele-icon type="icon-InBox" class="ele-imgCrop__icon"></ele-icon>
|
|
17
|
+
<span class="ele-imgCrop__font1" :class="isFail ? 'ele-imgCrop__error' : ''">单击或拖动文件到该区域以上传</span>
|
|
18
|
+
<span class="ele-imgCrop__font2" :class="isFail ? 'ele-imgCrop__error2' : ''">文件小于100M</span>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="margin-t-8">
|
|
21
|
+
<span class="ele-imgCrop__font1 ele-imgCrop__tips" :class="isFail? 'ele-imgCrop__error' : ''">{{ imgtips }}</span>
|
|
22
|
+
<a-icon type="close" style="float: right; line-height: 24px;"/>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="ele-imgCrop__right ele-imgCrop__item">
|
|
26
|
+
<span class="ele-imgCrop__font2">左侧上传图片后可预览</span>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</EleModal>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script>
|
|
34
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
35
|
+
import EleModal from '../../modal/src/index.vue'
|
|
36
|
+
import EleIcon from '../../icon/src/index.vue'
|
|
37
|
+
export default {
|
|
38
|
+
name: 'ele-img-crop',
|
|
39
|
+
components: {
|
|
40
|
+
EleModal,
|
|
41
|
+
EleIcon
|
|
42
|
+
},
|
|
43
|
+
model: {
|
|
44
|
+
prop: 'value'
|
|
45
|
+
},
|
|
46
|
+
props: {
|
|
47
|
+
maskClosable: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default () {
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
size: {
|
|
54
|
+
type: String,
|
|
55
|
+
default () {
|
|
56
|
+
return 'big'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
showTestModal: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default () {
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
data () {
|
|
67
|
+
return {
|
|
68
|
+
haveImg: false,
|
|
69
|
+
imgtips: '照片名称',
|
|
70
|
+
isFail: false,
|
|
71
|
+
title: '图像裁剪',
|
|
72
|
+
cancelText: '取消'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
methods: {
|
|
76
|
+
openModal () {
|
|
77
|
+
this.$refs[this.getEleModal].openModal()
|
|
78
|
+
},
|
|
79
|
+
handleChange (e) {
|
|
80
|
+
let file = e.target.files ? e.target.files[0] : e.target
|
|
81
|
+
const allowedExtensions = ['png', 'jpeg', 'jpg']
|
|
82
|
+
// 获取文件后缀名
|
|
83
|
+
const fileExtension = file.name.split('.').pop().toLowerCase()
|
|
84
|
+
if (!allowedExtensions.includes(fileExtension)) {
|
|
85
|
+
this.$Message.error('不支持该文件类型')
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
console.log((file.size / 1048576).toFixed(2))
|
|
89
|
+
if ((file.size / 1048576).toFixed(2) > 1) {
|
|
90
|
+
//大于1M,超大
|
|
91
|
+
this.imgtips = '上传失败(网络传输等问题/文件格式不符/文件大小超出限制)'
|
|
92
|
+
this.isFail = true
|
|
93
|
+
} else {
|
|
94
|
+
this.imgtips = file.name
|
|
95
|
+
this.isFail = false
|
|
96
|
+
}
|
|
97
|
+
this.haveImg = true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
computed: {
|
|
101
|
+
getEleModal () {
|
|
102
|
+
return uuidv4()
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<style lang="scss" scoped>
|
|
109
|
+
::v-deep .ant-modal-body {
|
|
110
|
+
padding: 16px;
|
|
111
|
+
}
|
|
112
|
+
::v-deep .ant-modal-header {
|
|
113
|
+
padding: 16px;
|
|
114
|
+
}
|
|
115
|
+
.ele-imgCrop__wrapper {
|
|
116
|
+
display: flex;
|
|
117
|
+
gap: 16px;
|
|
118
|
+
justify-content: center;
|
|
119
|
+
margin-bottom: 30px;
|
|
120
|
+
.ele-imgCrop__left {
|
|
121
|
+
.ele-imgCrop__noImg {
|
|
122
|
+
display: flex;
|
|
123
|
+
flex-direction: column;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
align-items: center;
|
|
126
|
+
width: 100%;
|
|
127
|
+
height: 100%;
|
|
128
|
+
position: relative;
|
|
129
|
+
.ele-imgCrop__font1 {
|
|
130
|
+
color: var(--idoole-black-008);
|
|
131
|
+
font-size: 16px;
|
|
132
|
+
line-height: 24px !important;
|
|
133
|
+
}
|
|
134
|
+
.ele-imgCrop__font2 {
|
|
135
|
+
color: var(--idoole-black-06);
|
|
136
|
+
font-size: 14px;
|
|
137
|
+
line-height: 22px;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
.ele-imgCrop__update {
|
|
141
|
+
position: absolute;
|
|
142
|
+
top: 0;
|
|
143
|
+
left: 0;
|
|
144
|
+
width: 100%;
|
|
145
|
+
height: 100%;
|
|
146
|
+
opacity: 0;
|
|
147
|
+
cursor: pointer;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
.ele-imgCrop__right {
|
|
151
|
+
position: relative;
|
|
152
|
+
span {
|
|
153
|
+
position: absolute;
|
|
154
|
+
top: 50%;
|
|
155
|
+
left: 50%;
|
|
156
|
+
transform: translate(-50%, -50%);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
.ele-imgCrop__item {
|
|
160
|
+
width: 480px;
|
|
161
|
+
height: 300px;
|
|
162
|
+
border-radius: 2px;
|
|
163
|
+
border: 1px dashed var(--idooel-form-title-border-color);
|
|
164
|
+
background: var(--idooel-form-upload-bg-color);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
.ele-imgCrop__tips {
|
|
168
|
+
float: left;
|
|
169
|
+
width: 80%;
|
|
170
|
+
}
|
|
171
|
+
.ele-imgCrop__error {
|
|
172
|
+
color: var(--idooel-form-border-err-color) !important;
|
|
173
|
+
}
|
|
174
|
+
.ele-imgCrop__error2 {
|
|
175
|
+
color: var(--idooel-img-crop-err-color) !important;
|
|
176
|
+
}
|
|
177
|
+
.ele-imgCrop__icon {
|
|
178
|
+
font-size: 48px;
|
|
179
|
+
color: var(--idooel-link-06);
|
|
180
|
+
}
|
|
181
|
+
</style>
|