@ddwl/ddwl-ui 1.3.18 → 1.4.1
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/index.common.js +443 -372
- package/dist/index.umd.js +4574 -4503
- package/dist/index.umd.min.js +4 -4
- package/package.json +1 -1
- package/src/lib/install/index.js +48 -0
- package/src/main.js +0 -2
- package/src/packages/import-file/index.vue +29 -25
- package/src/packages/upload/index.vue +5 -0
package/package.json
CHANGED
package/src/lib/install/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import previewVue from '../../packages/file-preview/index.vue'
|
|
2
|
+
import importVue from '../../packages/import-file/index.vue'
|
|
2
3
|
|
|
3
4
|
export default (Vue) => {
|
|
4
5
|
// 文件预览
|
|
@@ -10,4 +11,51 @@ export default (Vue) => {
|
|
|
10
11
|
instance.defaultIndex = defaultIndex
|
|
11
12
|
instance.list = list
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
// 文件导入
|
|
16
|
+
Vue.prototype.$importFile = ({
|
|
17
|
+
width = '520px',
|
|
18
|
+
title = '文件导入',
|
|
19
|
+
templateUrl = '',
|
|
20
|
+
token = '',
|
|
21
|
+
templateDownloadMethod = null,
|
|
22
|
+
fileType = ['xlsx', 'xls'],
|
|
23
|
+
fileSize = 5,
|
|
24
|
+
slotRender = null
|
|
25
|
+
}) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const Import = Vue.extend(importVue)
|
|
28
|
+
const instance = new Import()
|
|
29
|
+
const el = instance.$mount().$el
|
|
30
|
+
document.body.appendChild(el)
|
|
31
|
+
|
|
32
|
+
instance.value = true
|
|
33
|
+
instance.width = width
|
|
34
|
+
instance.title = title
|
|
35
|
+
instance.templateUrl = templateUrl
|
|
36
|
+
instance.token = token
|
|
37
|
+
instance.templateDownloadMethod = templateDownloadMethod
|
|
38
|
+
instance.fileType = fileType
|
|
39
|
+
instance.fileSize = fileSize
|
|
40
|
+
instance.slotRender = slotRender
|
|
41
|
+
|
|
42
|
+
const destroy = () => {
|
|
43
|
+
instance.$destroy()
|
|
44
|
+
el.parentNode && el.parentNode.removeChild(el)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
instance.$on('submit', async (callback, file) => {
|
|
48
|
+
try {
|
|
49
|
+
resolve({ file, callback })
|
|
50
|
+
} catch (e) {
|
|
51
|
+
callback(new Error(e))
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
instance.$on('close', () => {
|
|
56
|
+
reject()
|
|
57
|
+
Vue.nextTick(destroy)
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
}
|
|
13
61
|
}
|
package/src/main.js
CHANGED
|
@@ -6,7 +6,6 @@ import Drawer from './packages/drawer'
|
|
|
6
6
|
import FilterTree from './packages/filter-tree'
|
|
7
7
|
import Form from './packages/form'
|
|
8
8
|
import FormItem from './packages/form-item'
|
|
9
|
-
import ImportFile from './packages/import-file'
|
|
10
9
|
import Menu from './packages/menu'
|
|
11
10
|
import Popconfirm from './packages/popconfirm'
|
|
12
11
|
import Render from './packages/render'
|
|
@@ -31,7 +30,6 @@ const components = [
|
|
|
31
30
|
FilterTree,
|
|
32
31
|
Form,
|
|
33
32
|
FormItem,
|
|
34
|
-
ImportFile,
|
|
35
33
|
Menu,
|
|
36
34
|
Popconfirm,
|
|
37
35
|
Render,
|
|
@@ -39,27 +39,27 @@
|
|
|
39
39
|
模板下载
|
|
40
40
|
</el-button>
|
|
41
41
|
</el-form>
|
|
42
|
-
<
|
|
42
|
+
<div v-if="slotRender">
|
|
43
|
+
<d-render :render="slotRender" />
|
|
44
|
+
</div>
|
|
45
|
+
<div v-else>
|
|
43
46
|
<p>1. 支持导入格式为{{ fileType.join('、') }}的文件,且文件大小不可超过{{ fileSize }}M</p>
|
|
44
47
|
<p>2. 模板的表头不可更改,不可删除</p>
|
|
45
48
|
<p>3. 若导入数据存在编码一致的情况则会更新原有数据</p>
|
|
46
49
|
<p>4. 若导入过程中有问题,需调整模板内容后再重新导入</p>
|
|
47
|
-
</
|
|
50
|
+
</div>
|
|
48
51
|
</d-dialog>
|
|
49
52
|
</template>
|
|
50
53
|
|
|
51
54
|
<script>
|
|
52
55
|
import DDialog from '../dialog'
|
|
56
|
+
import DRender from '../render'
|
|
53
57
|
|
|
54
58
|
export default {
|
|
55
59
|
name: 'DImportFile',
|
|
56
|
-
components: { DDialog },
|
|
57
|
-
model: {
|
|
58
|
-
prop: 'modelValue',
|
|
59
|
-
event: 'change'
|
|
60
|
-
},
|
|
60
|
+
components: { DDialog, DRender },
|
|
61
61
|
props: {
|
|
62
|
-
|
|
62
|
+
value: {
|
|
63
63
|
default: false,
|
|
64
64
|
type: Boolean
|
|
65
65
|
},
|
|
@@ -75,6 +75,10 @@ export default {
|
|
|
75
75
|
default: '',
|
|
76
76
|
type: String
|
|
77
77
|
},
|
|
78
|
+
token: {
|
|
79
|
+
default: '',
|
|
80
|
+
type: String
|
|
81
|
+
},
|
|
78
82
|
templateDownloadMethod: {
|
|
79
83
|
type: Function,
|
|
80
84
|
default: null
|
|
@@ -86,26 +90,32 @@ export default {
|
|
|
86
90
|
fileSize: {
|
|
87
91
|
default: 5,
|
|
88
92
|
type: Number
|
|
93
|
+
},
|
|
94
|
+
slotRender: {
|
|
95
|
+
default: null,
|
|
96
|
+
type: Function
|
|
89
97
|
}
|
|
90
98
|
},
|
|
91
99
|
data() {
|
|
92
100
|
return {
|
|
101
|
+
visible: false,
|
|
93
102
|
fileList: [],
|
|
94
103
|
form: {
|
|
95
104
|
file: ''
|
|
96
105
|
}
|
|
97
106
|
}
|
|
98
107
|
},
|
|
99
|
-
|
|
108
|
+
watch: {
|
|
109
|
+
value: {
|
|
110
|
+
handler(value) {
|
|
111
|
+
this.visible = value
|
|
112
|
+
}
|
|
113
|
+
},
|
|
100
114
|
visible: {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.form.file = ''
|
|
106
|
-
this.fileList = []
|
|
107
|
-
this.$refs.importForm.clearValidate()
|
|
108
|
-
this.$emit('change', value)
|
|
115
|
+
handler(value) {
|
|
116
|
+
if (!value) {
|
|
117
|
+
this.$emit('close', value)
|
|
118
|
+
}
|
|
109
119
|
}
|
|
110
120
|
}
|
|
111
121
|
},
|
|
@@ -114,13 +124,7 @@ export default {
|
|
|
114
124
|
if (this.templateDownloadMethod) {
|
|
115
125
|
this.templateDownloadMethod()
|
|
116
126
|
} else {
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
token = JSON.parse(window.localStorage.getItem('userInfo')).token
|
|
120
|
-
} catch (e) {
|
|
121
|
-
token = ''
|
|
122
|
-
}
|
|
123
|
-
window.location.href = `${this.templateUrl}?authToken=${token}`
|
|
127
|
+
window.location.href = `${this.templateUrl}?authToken=${this.token}`
|
|
124
128
|
}
|
|
125
129
|
},
|
|
126
130
|
uploadChange(file, fileList) {
|
|
@@ -146,7 +150,7 @@ export default {
|
|
|
146
150
|
return
|
|
147
151
|
}
|
|
148
152
|
try {
|
|
149
|
-
this.$emit('submit', this.form.file
|
|
153
|
+
this.$emit('submit', callback, this.form.file)
|
|
150
154
|
} catch (e) {
|
|
151
155
|
callback(new Error(false))
|
|
152
156
|
}
|