@ddwl/ddwl-ui 1.1.5-beta.4 → 1.1.6

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,173 +1,173 @@
1
- <template>
2
- <d-dialog
3
- v-model="visible"
4
- form-refs="importForm"
5
- :width="width"
6
- :title="title"
7
- submit-btn-text="导入"
8
- submit-btn-icon="el-icon-upload2"
9
- @submit="submit"
10
- >
11
- <el-form
12
- ref="importForm"
13
- :model="form"
14
- :inline="true"
15
- >
16
- <el-form-item
17
- class="import-form-item"
18
- prop="file"
19
- label="选择文件"
20
- :rules="[
21
- { required: true, message: '请选择文件' }
22
- ]"
23
- >
24
- <div class="custom-file-input">
25
- <div class="custom-file-content">
26
- {{ form.file ? form.file.name : '请选择' }}
27
- </div>
28
- <el-upload
29
- :file-list="fileList"
30
- :show-file-list="false"
31
- :auto-upload="false"
32
- action=""
33
- :on-change="uploadChange"
34
- >
35
- <el-button
36
- type="primary"
37
- icon="el-icon-folder"
38
- />
39
- </el-upload>
40
- </div>
41
- </el-form-item>
42
- <el-button
43
- v-show="templateUrl"
44
- icon="el-icon-paperclip"
45
- type="text"
46
- @click="downloadFile"
47
- >
48
- 模板下载
49
- </el-button>
50
- </el-form>
51
- <slot>
52
- <p>1. 支持导入格式为{{ fileType.join('、') }}的文件,且文件大小不可超过{{ fileSize }}M</p>
53
- <p>2. 模板的表头不可更改,不可删除</p>
54
- <p>3. 若导入数据存在编码一致的情况则会更新原有数据</p>
55
- <p>4. 若导入过程中有问题,需调整模板内容后再重新导入</p>
56
- </slot>
57
- </d-dialog>
58
- </template>
59
-
60
- <script>
61
- import DDialog from '../dialog'
62
-
63
- export default {
64
- name: 'DImportFile',
65
- components: { DDialog },
66
- model: {
67
- prop: 'modelValue',
68
- event: 'change'
69
- },
70
- props: {
71
- modelValue: {
72
- default: false,
73
- type: Boolean
74
- },
75
- width: {
76
- default: '520px',
77
- type: String
78
- },
79
- title: {
80
- default: '',
81
- type: String
82
- },
83
- templateUrl: {
84
- default: '',
85
- type: String
86
- },
87
- fileType: {
88
- default: () => ['xlsx', 'xls'],
89
- type: Array
90
- },
91
- fileSize: {
92
- default: 5,
93
- type: Number
94
- }
95
- },
96
- data () {
97
- return {
98
- fileList: [],
99
- form: {
100
- file: ''
101
- }
102
- }
103
- },
104
- computed: {
105
- visible: {
106
- get () {
107
- return this.modelValue
108
- },
109
- set (value) {
110
- this.form.file = ''
111
- this.fileList = []
112
- this.$refs.importForm.clearValidate()
113
- this.$emit('change', value)
114
- }
115
- }
116
- },
117
- methods: {
118
- downloadFile () {
119
- let token
120
- try {
121
- token = JSON.parse(window.localStorage.getItem('userInfo')).token
122
- } catch (e) {
123
- token = ''
124
- }
125
- window.location.href = `${this.templateUrl}?authToken=${token}`
126
- },
127
- uploadChange (file, fileList) {
128
- const isLimit = file.size / 1024 / 1024 < this.fileSize
129
- const isType = this.fileType.includes(file.name.substr(file.name.lastIndexOf('.') + 1).toLocaleLowerCase())
130
- if (!isType) {
131
- this.$message.error(`请上传正确的文件格式(${this.fileType.join('、')})`)
132
- return false
133
- }
134
- if (!isLimit) {
135
- this.$message.error(`上传文件大小不能超过${this.fileSize}MB`)
136
- return false
137
- }
138
- this.fileList = fileList
139
- this.form.file = file.raw
140
- },
141
- async submit (callback) {
142
- if (!this.form.file) {
143
- this.$message.error('请选择导入文件')
144
- callback(new Error(false))
145
- return
146
- }
147
- try {
148
- this.$emit('submit', this.form.file, callback)
149
- } catch (e) {
150
- callback(new Error(false))
151
- }
152
- }
153
- }
154
- }
155
- </script>
156
-
157
- <style lang="scss" scoped>
158
- .custom-file-input {
159
- display: flex;
160
- width: 230px;
161
- .custom-file-content {
162
- width: 100%;
163
- height: 32px;
164
- border: 1px solid #dcdfe6;
165
- border-right: none;
166
- border-radius: 2px 0 0 2px;
167
- padding: 0 8px;
168
- white-space: nowrap;
169
- overflow: hidden;
170
- text-overflow: ellipsis;
171
- }
172
- }
173
- </style>
1
+ <template>
2
+ <d-dialog
3
+ v-model="visible"
4
+ form-refs="importForm"
5
+ :width="width"
6
+ :title="title"
7
+ submit-btn-text="导入"
8
+ submit-btn-icon="el-icon-upload2"
9
+ @submit="submit"
10
+ >
11
+ <el-form
12
+ ref="importForm"
13
+ :model="form"
14
+ :inline="true"
15
+ >
16
+ <el-form-item
17
+ class="import-form-item"
18
+ prop="file"
19
+ label="选择文件"
20
+ :rules="[
21
+ { required: true, message: '请选择文件' }
22
+ ]"
23
+ >
24
+ <div class="custom-file-input">
25
+ <div class="custom-file-content">
26
+ {{ form.file ? form.file.name : '请选择' }}
27
+ </div>
28
+ <el-upload
29
+ :file-list="fileList"
30
+ :show-file-list="false"
31
+ :auto-upload="false"
32
+ action=""
33
+ :on-change="uploadChange"
34
+ >
35
+ <el-button
36
+ type="primary"
37
+ icon="el-icon-folder"
38
+ />
39
+ </el-upload>
40
+ </div>
41
+ </el-form-item>
42
+ <el-button
43
+ v-show="templateUrl"
44
+ icon="el-icon-paperclip"
45
+ type="text"
46
+ @click="downloadFile"
47
+ >
48
+ 模板下载
49
+ </el-button>
50
+ </el-form>
51
+ <slot>
52
+ <p>1. 支持导入格式为{{ fileType.join('、') }}的文件,且文件大小不可超过{{ fileSize }}M</p>
53
+ <p>2. 模板的表头不可更改,不可删除</p>
54
+ <p>3. 若导入数据存在编码一致的情况则会更新原有数据</p>
55
+ <p>4. 若导入过程中有问题,需调整模板内容后再重新导入</p>
56
+ </slot>
57
+ </d-dialog>
58
+ </template>
59
+
60
+ <script>
61
+ import DDialog from '../dialog'
62
+
63
+ export default {
64
+ name: 'DImportFile',
65
+ components: { DDialog },
66
+ model: {
67
+ prop: 'modelValue',
68
+ event: 'change'
69
+ },
70
+ props: {
71
+ modelValue: {
72
+ default: false,
73
+ type: Boolean
74
+ },
75
+ width: {
76
+ default: '520px',
77
+ type: String
78
+ },
79
+ title: {
80
+ default: '',
81
+ type: String
82
+ },
83
+ templateUrl: {
84
+ default: '',
85
+ type: String
86
+ },
87
+ fileType: {
88
+ default: () => ['xlsx', 'xls'],
89
+ type: Array
90
+ },
91
+ fileSize: {
92
+ default: 5,
93
+ type: Number
94
+ }
95
+ },
96
+ data () {
97
+ return {
98
+ fileList: [],
99
+ form: {
100
+ file: ''
101
+ }
102
+ }
103
+ },
104
+ computed: {
105
+ visible: {
106
+ get () {
107
+ return this.modelValue
108
+ },
109
+ set (value) {
110
+ this.form.file = ''
111
+ this.fileList = []
112
+ this.$refs.importForm.clearValidate()
113
+ this.$emit('change', value)
114
+ }
115
+ }
116
+ },
117
+ methods: {
118
+ downloadFile () {
119
+ let token
120
+ try {
121
+ token = JSON.parse(window.localStorage.getItem('userInfo')).token
122
+ } catch (e) {
123
+ token = ''
124
+ }
125
+ window.location.href = `${this.templateUrl}?authToken=${token}`
126
+ },
127
+ uploadChange (file, fileList) {
128
+ const isLimit = file.size / 1024 / 1024 < this.fileSize
129
+ const isType = this.fileType.includes(file.name.substr(file.name.lastIndexOf('.') + 1).toLocaleLowerCase())
130
+ if (!isType) {
131
+ this.$message.error(`请上传正确的文件格式(${this.fileType.join('、')})`)
132
+ return false
133
+ }
134
+ if (!isLimit) {
135
+ this.$message.error(`上传文件大小不能超过${this.fileSize}MB`)
136
+ return false
137
+ }
138
+ this.fileList = fileList
139
+ this.form.file = file.raw
140
+ },
141
+ async submit (callback) {
142
+ if (!this.form.file) {
143
+ this.$message.error('请选择导入文件')
144
+ callback(new Error(false))
145
+ return
146
+ }
147
+ try {
148
+ this.$emit('submit', this.form.file, callback)
149
+ } catch (e) {
150
+ callback(new Error(false))
151
+ }
152
+ }
153
+ }
154
+ }
155
+ </script>
156
+
157
+ <style lang="scss" scoped>
158
+ .custom-file-input {
159
+ display: flex;
160
+ width: 230px;
161
+ .custom-file-content {
162
+ width: 100%;
163
+ height: 32px;
164
+ border: 1px solid #dcdfe6;
165
+ border-right: none;
166
+ border-radius: 2px 0 0 2px;
167
+ padding: 0 8px;
168
+ white-space: nowrap;
169
+ overflow: hidden;
170
+ text-overflow: ellipsis;
171
+ }
172
+ }
173
+ </style>
@@ -1,66 +1,66 @@
1
- <!-- 菜单 -->
2
- <template>
3
- <el-menu
4
- class="d-menu"
5
- :default-active="isVertical ? $route.path : activeMenu"
6
- :router="isVertical"
7
- unique-opened
8
- :mode="mode"
9
- @select="menuSelect">
10
- <menu-item v-for="item in data" :key="item.name" :data="item" :mode="mode"></menu-item>
11
- </el-menu>
12
- </template>
13
-
14
- <script>
15
- import MenuItem from './menuItem.vue'
16
- export default {
17
- name: 'DMenu',
18
- components: { MenuItem },
19
- props: {
20
- data: {
21
- type: Array,
22
- default: () => []
23
- },
24
- mode: {
25
- type: String,
26
- default: 'vertical'
27
- }
28
- },
29
- data () {
30
- return {
31
- activeMenu: ''
32
- }
33
- },
34
- computed: {
35
- isVertical () {
36
- return this.mode === 'vertical'
37
- }
38
- },
39
- watch: {
40
- '$route.path': {
41
- handler (path) {
42
- if (!this.isVertical) {
43
- if (this.activeMenu && path.substring(0, this.activeMenu.length) === this.activeMenu) return
44
- const data = this.data.find(item => path.substring(0, item.path.length) === item.path)
45
- this.activeMenu = data?.path
46
- this.$emit('select', data, false)
47
- }
48
- },
49
- immediate: true
50
- }
51
- },
52
- methods: {
53
- menuSelect (index) {
54
- if (this.isVertical) return
55
- const data = this.data.find(item => item.path === index)
56
- this.$emit('select', data, true)
57
- }
58
- }
59
- }
60
- </script>
61
-
62
- <style lang='scss' scoped>
63
- .d-menu {
64
- height: 100%;
65
- }
66
- </style>
1
+ <!-- 菜单 -->
2
+ <template>
3
+ <el-menu
4
+ class="d-menu"
5
+ :default-active="isVertical ? $route.path : activeMenu"
6
+ :router="isVertical"
7
+ unique-opened
8
+ :mode="mode"
9
+ @select="menuSelect">
10
+ <menu-item v-for="item in data" :key="item.name" :data="item" :mode="mode"></menu-item>
11
+ </el-menu>
12
+ </template>
13
+
14
+ <script>
15
+ import MenuItem from './menuItem.vue'
16
+ export default {
17
+ name: 'DMenu',
18
+ components: { MenuItem },
19
+ props: {
20
+ data: {
21
+ type: Array,
22
+ default: () => []
23
+ },
24
+ mode: {
25
+ type: String,
26
+ default: 'vertical'
27
+ }
28
+ },
29
+ data () {
30
+ return {
31
+ activeMenu: ''
32
+ }
33
+ },
34
+ computed: {
35
+ isVertical () {
36
+ return this.mode === 'vertical'
37
+ }
38
+ },
39
+ watch: {
40
+ '$route.path': {
41
+ handler (path) {
42
+ if (!this.isVertical) {
43
+ if (this.activeMenu && path.substring(0, this.activeMenu.length) === this.activeMenu) return
44
+ const data = this.data.find(item => path.substring(0, item.path.length) === item.path)
45
+ this.activeMenu = data?.path
46
+ this.$emit('select', data, false)
47
+ }
48
+ },
49
+ immediate: true
50
+ }
51
+ },
52
+ methods: {
53
+ menuSelect (index) {
54
+ if (this.isVertical) return
55
+ const data = this.data.find(item => item.path === index)
56
+ this.$emit('select', data, true)
57
+ }
58
+ }
59
+ }
60
+ </script>
61
+
62
+ <style lang='scss' scoped>
63
+ .d-menu {
64
+ height: 100%;
65
+ }
66
+ </style>
@@ -1,90 +1,90 @@
1
- <!-- 菜单子项 -->
2
- <template>
3
- <el-submenu
4
- v-if="mode === 'vertical' && data.children && data.children.length"
5
- :index="data.path"
6
- >
7
- <template slot="title">
8
- <img
9
- v-if="data.meta.icon"
10
- class="mr8 menu-icon"
11
- :src="data.meta.icon"
12
- >
13
- <span>{{ data.meta.title }}</span>
14
- </template>
15
- <menu-item
16
- v-for="item in data.children"
17
- :key="item.name"
18
- :data="item"
19
- />
20
- </el-submenu>
21
- <el-menu-item
22
- v-else
23
- :index="data.path"
24
- >
25
- <template slot="title">
26
- <div
27
- v-if="data.meta.icon"
28
- class="menu-icon-box"
29
- >
30
- <img
31
- class="menu-icon"
32
- :src="data.meta.icon"
33
- >
34
- </div>
35
- <span
36
- v-if="data.meta.isNewWindow"
37
- class="ml6 ellipsis flex-1"
38
- @click.stop="openNewWindow(data)"
39
- >{{ data.meta.title }}</span>
40
- <span
41
- v-else
42
- class="ml6 ellipsis flex-1"
43
- >{{ data.meta.title }}</span>
44
- </template>
45
- </el-menu-item>
46
- </template>
47
-
48
- <script>
49
- export default {
50
- name: 'MenuItem',
51
- components: {},
52
- props: {
53
- data: {
54
- type: Object,
55
- default: () => ({})
56
- },
57
- mode: {
58
- type: String,
59
- default: 'vertical'
60
- }
61
- },
62
- data () {
63
- return {
64
- }
65
- },
66
- computed: {},
67
- created () {},
68
- methods: {
69
- openNewWindow (data) {
70
- window.open(data.path, '_blank')
71
- }
72
- }
73
- }
74
- </script>
75
-
76
- <style lang='scss' scoped>
77
- .menu-icon-box {
78
- width: 26px;
79
- height: 26px;
80
- border-radius: 50%;
81
- background-color: #fff;
82
- display: flex;
83
- align-items: center;
84
- justify-content: center;
85
- }
86
- .menu-icon {
87
- width: 16px;
88
- height: 16px;
89
- }
90
- </style>
1
+ <!-- 菜单子项 -->
2
+ <template>
3
+ <el-submenu
4
+ v-if="mode === 'vertical' && data.children && data.children.length"
5
+ :index="data.path"
6
+ >
7
+ <template slot="title">
8
+ <img
9
+ v-if="data.meta.icon"
10
+ class="mr8 menu-icon"
11
+ :src="data.meta.icon"
12
+ >
13
+ <span>{{ data.meta.title }}</span>
14
+ </template>
15
+ <menu-item
16
+ v-for="item in data.children"
17
+ :key="item.name"
18
+ :data="item"
19
+ />
20
+ </el-submenu>
21
+ <el-menu-item
22
+ v-else
23
+ :index="data.path"
24
+ >
25
+ <template slot="title">
26
+ <div
27
+ v-if="data.meta.icon"
28
+ class="menu-icon-box"
29
+ >
30
+ <img
31
+ class="menu-icon"
32
+ :src="data.meta.icon"
33
+ >
34
+ </div>
35
+ <span
36
+ v-if="data.meta.isNewWindow"
37
+ class="ml6 ellipsis flex-1"
38
+ @click.stop="openNewWindow(data)"
39
+ >{{ data.meta.title }}</span>
40
+ <span
41
+ v-else
42
+ class="ml6 ellipsis flex-1"
43
+ >{{ data.meta.title }}</span>
44
+ </template>
45
+ </el-menu-item>
46
+ </template>
47
+
48
+ <script>
49
+ export default {
50
+ name: 'MenuItem',
51
+ components: {},
52
+ props: {
53
+ data: {
54
+ type: Object,
55
+ default: () => ({})
56
+ },
57
+ mode: {
58
+ type: String,
59
+ default: 'vertical'
60
+ }
61
+ },
62
+ data () {
63
+ return {
64
+ }
65
+ },
66
+ computed: {},
67
+ created () {},
68
+ methods: {
69
+ openNewWindow (data) {
70
+ window.open(data.path, '_blank')
71
+ }
72
+ }
73
+ }
74
+ </script>
75
+
76
+ <style lang='scss' scoped>
77
+ .menu-icon-box {
78
+ width: 26px;
79
+ height: 26px;
80
+ border-radius: 50%;
81
+ background-color: #fff;
82
+ display: flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+ }
86
+ .menu-icon {
87
+ width: 16px;
88
+ height: 16px;
89
+ }
90
+ </style>