leisure-core 1.0.2 → 1.0.3
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/index.js +223 -0
- package/le-area/index.js +7 -0
- package/le-area/src/main.vue +112 -0
- package/le-button/index.js +7 -0
- package/le-button/src/main.vue +47 -0
- package/le-button-attach/index.js +6 -0
- package/le-button-attach/src/main.vue +171 -0
- package/le-button-msg/index.js +7 -0
- package/le-button-msg/src/main.vue +65 -0
- package/le-button-qr/index.js +7 -0
- package/le-button-qr/src/main.vue +96 -0
- package/le-date-picker/index.js +7 -0
- package/le-date-picker/src/main.vue +67 -0
- package/le-date-picker-auto/index.js +6 -0
- package/le-date-picker-auto/src/main.vue +131 -0
- package/le-dialog-container/index.js +7 -0
- package/le-dialog-container/src/main.vue +80 -0
- package/le-form/index.js +7 -0
- package/le-form/src/main.vue +13 -0
- package/le-form-item/index.js +7 -0
- package/le-form-item/src/main.vue +13 -0
- package/le-home/index.js +7 -0
- package/le-home/src/LeHeaderMenu.vue +60 -0
- package/le-home/src/main.vue +1307 -0
- package/le-home/src/sub.vue +82 -0
- package/le-image/index.js +7 -0
- package/le-image/src/main.vue +53 -0
- package/le-input/index.js +7 -0
- package/le-input/src/main.vue +15 -0
- package/le-input-advanced/index.js +7 -0
- package/le-input-advanced/src/main.vue +71 -0
- package/le-input-number/index.js +7 -0
- package/le-input-number/src/main.vue +15 -0
- package/le-input-validate/index.js +6 -0
- package/le-input-validate/src/main.vue +469 -0
- package/le-libs/js/drag.js +78 -0
- package/le-libs/js/event.js +3 -0
- package/le-libs/js/hrequest.js +76 -0
- package/le-libs/js/hrequestFile.js +62 -0
- package/le-libs/js/info.js +7 -0
- package/le-libs/js/tokens.js +13 -0
- package/le-libs/mixins/main.js +48 -0
- package/le-list/index.js +7 -0
- package/le-list/src/main.vue +645 -0
- package/le-list-form/index.js +7 -0
- package/le-list-form/src/main.vue +474 -0
- package/le-login/index.js +7 -0
- package/le-login/src/ForgotPassword.vue +613 -0
- package/le-login/src/main.vue +982 -0
- package/le-media/index.js +7 -0
- package/le-media/src/main.vue +298 -0
- package/le-media-list/index.js +7 -0
- package/le-media-list/src/main.vue +178 -0
- package/le-media-upload/index.js +7 -0
- package/le-media-upload/src/main.vue +329 -0
- package/le-menu/index.js +7 -0
- package/le-menu/src/main.vue +248 -0
- package/le-report/index.js +6 -0
- package/le-report/src/main.vue +1747 -0
- package/le-report/src/rmixins.js +30 -0
- package/le-role/index.js +7 -0
- package/le-role/src/main.vue +183 -0
- package/le-role/src/sub.vue +79 -0
- package/le-role-user/index.js +7 -0
- package/le-role-user/src/main.vue +160 -0
- package/le-role-user/src/sub.vue +90 -0
- package/le-select/index.js +7 -0
- package/le-select/src/main.vue +49 -0
- package/le-select-multi/index.js +6 -0
- package/le-select-multi/src/main.vue +816 -0
- package/le-select-option/index.js +7 -0
- package/le-select-option/src/main.vue +69 -0
- package/le-select-search/index.js +7 -0
- package/le-select-search/src/main.vue +46 -0
- package/le-span/index.js +7 -0
- package/le-span/src/main.vue +29 -0
- package/le-table-edit/index.js +6 -0
- package/le-table-edit/src/main.vue +689 -0
- package/le-theme/common/vars.css +131 -0
- package/le-theme/iconfont/iconfont.css +125 -0
- package/le-theme/iconfont/iconfont.ttf +0 -0
- package/le-theme/iconfont/iconfont.woff +0 -0
- package/le-theme/iconfont/iconfont.woff2 +0 -0
- package/le-theme/index.js +189 -0
- package/le-theme/pages/index.css +15 -0
- package/le-upload/index.js +7 -0
- package/le-upload/src/main.vue +134 -0
- package/le-upload-table/index.js +6 -0
- package/le-upload-table/src/main.vue +648 -0
- package/le-url/index.js +7 -0
- package/le-url/src/main.vue +27 -0
- package/le-video/index.js +7 -0
- package/le-video/src/main.vue +42 -0
- package/package.json +1 -6
package/index.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import LeDrag from "./le-libs/js/drag.js";
|
|
2
|
+
// import leMixins from "./le-libs/mixins/main.js";
|
|
3
|
+
import {
|
|
4
|
+
parseTime,
|
|
5
|
+
formatMoney,
|
|
6
|
+
formatCurrency,
|
|
7
|
+
} from "leisure-js/common/dformat";
|
|
8
|
+
import LeTheme from "./le-theme"; // 一键换肤服务:引入 vars.css + LeTheme API
|
|
9
|
+
import LeLogin from "./le-login/index.js";
|
|
10
|
+
import LeHome from "./le-home/index.js";
|
|
11
|
+
import LeButton from "./le-button/index.js";
|
|
12
|
+
import LeButtonQr from "./le-button-qr/index.js";
|
|
13
|
+
import LeButtonMsg from "./le-button-msg/index.js";
|
|
14
|
+
import LeDialogContainer from "./le-dialog-container/index.js";
|
|
15
|
+
|
|
16
|
+
import LeMedia from "./le-media/index.js";
|
|
17
|
+
import LeMediaUpload from "./le-media-upload/index.js";
|
|
18
|
+
import LeMediaList from "./le-media-list/index.js";
|
|
19
|
+
|
|
20
|
+
// import LeButtonUpload from "./le-button-upload/index.js";
|
|
21
|
+
// import LeButtonSelectMedia from "./le-button-select-media/index.js";
|
|
22
|
+
import LeImage from "./le-image/index.js";
|
|
23
|
+
// import LeImageContainer from "./le-image-container/index.js";
|
|
24
|
+
|
|
25
|
+
import LeUpload from "./le-upload/index.js";
|
|
26
|
+
|
|
27
|
+
// import { LeHelp, LeHelpDetail } from "./le-help/index.js";
|
|
28
|
+
|
|
29
|
+
import LeSelect from "./le-select/index.js";
|
|
30
|
+
import LeSelectSearch from "./le-select-search/index.js";
|
|
31
|
+
import LeInput from "./le-input/index.js";
|
|
32
|
+
import LeForm from "./le-form/index";
|
|
33
|
+
import LeFormItem from "./le-form-item/index";
|
|
34
|
+
import LeInputNumber from "./le-input-number/index.js";
|
|
35
|
+
import LeSelectOption from "./le-select-option/index.js";
|
|
36
|
+
import LeVideo from "./le-video/index.js";
|
|
37
|
+
import LeList from "./le-list/index.js";
|
|
38
|
+
import LeListForm from "./le-list-form/index.js";
|
|
39
|
+
import LeDatePicker from "./le-date-picker/index.js";
|
|
40
|
+
import LeUrl from "./le-url/index.js";
|
|
41
|
+
import LeSpan from "./le-span/index.js";
|
|
42
|
+
import LeInputAdvanced from "./le-input-advanced/index.js";
|
|
43
|
+
// import LeButtonAudit from "./le-button-audit/index.js";
|
|
44
|
+
import LeInputValidate from "./le-input-validate/index.js";
|
|
45
|
+
import LeDatePickerAuto from "./le-date-picker-auto/index.js";
|
|
46
|
+
import LeTableEdit from "./le-table-edit/index.js";
|
|
47
|
+
import LeButtonAttach from "./le-button-attach/index.js";
|
|
48
|
+
import LeSelectMulti from "./le-select-multi/index.js";
|
|
49
|
+
import LeUploadTable from "./le-upload-table/index.js";
|
|
50
|
+
import LeReport from "./le-report/index.js";
|
|
51
|
+
import LeArea from "./le-area/index.js";
|
|
52
|
+
import LeMenu from "./le-menu/index.js";
|
|
53
|
+
import LeRole from "./le-role/index.js";
|
|
54
|
+
import LeRoleUser from "./le-role-user/index.js";
|
|
55
|
+
|
|
56
|
+
const components = [
|
|
57
|
+
LeButton,
|
|
58
|
+
LeButtonQr,
|
|
59
|
+
LeButtonMsg,
|
|
60
|
+
LeDialogContainer,
|
|
61
|
+
LeLogin,
|
|
62
|
+
LeHome,
|
|
63
|
+
|
|
64
|
+
LeMedia,
|
|
65
|
+
LeMediaUpload,
|
|
66
|
+
LeMediaList,
|
|
67
|
+
|
|
68
|
+
// LeButtonUpload,
|
|
69
|
+
// LeButtonSelectMedia,
|
|
70
|
+
// LeImageContainer,
|
|
71
|
+
LeImage,
|
|
72
|
+
|
|
73
|
+
LeUpload,
|
|
74
|
+
|
|
75
|
+
// LeHelp,
|
|
76
|
+
// LeHelpDetail,
|
|
77
|
+
|
|
78
|
+
LeSelect,
|
|
79
|
+
LeSelectSearch,
|
|
80
|
+
LeInput,
|
|
81
|
+
LeInputNumber,
|
|
82
|
+
LeForm,
|
|
83
|
+
LeFormItem,
|
|
84
|
+
LeSelectOption,
|
|
85
|
+
LeVideo,
|
|
86
|
+
LeListForm,
|
|
87
|
+
LeList,
|
|
88
|
+
LeDatePicker,
|
|
89
|
+
LeSpan,
|
|
90
|
+
LeUrl,
|
|
91
|
+
LeInputAdvanced,
|
|
92
|
+
// LeButtonAudit,
|
|
93
|
+
LeInputValidate,
|
|
94
|
+
LeDatePickerAuto,
|
|
95
|
+
LeTableEdit,
|
|
96
|
+
LeButtonAttach,
|
|
97
|
+
LeSelectMulti,
|
|
98
|
+
LeUploadTable,
|
|
99
|
+
LeReport,
|
|
100
|
+
LeArea,
|
|
101
|
+
LeMenu,
|
|
102
|
+
LeRole,
|
|
103
|
+
LeRoleUser,
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
const install = function (Vue) {
|
|
107
|
+
if (install.installed) return;
|
|
108
|
+
|
|
109
|
+
components.forEach((component) => {
|
|
110
|
+
Vue.component(component.name, component);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
Vue.prototype.parseTime = parseTime;
|
|
114
|
+
Vue.prototype.formatMoney = formatMoney;
|
|
115
|
+
Vue.prototype.formatCurrency = formatCurrency;
|
|
116
|
+
|
|
117
|
+
// 一键换肤服务:挂载到 Vue 原型,组件内使用方式 this.$leTheme.set("dark")
|
|
118
|
+
Vue.prototype.$leTheme = LeTheme;
|
|
119
|
+
// 在 install 流程里初始化 LeTheme,从 localStorage 恢复上次选择的皮肤
|
|
120
|
+
LeTheme.init();
|
|
121
|
+
|
|
122
|
+
Vue.directive("permission", {
|
|
123
|
+
inserted: function (el, bindings) {
|
|
124
|
+
let buttons = bindings.value;
|
|
125
|
+
if (buttons && buttons.length > 0) {
|
|
126
|
+
let btnConfigs = JSON.parse(buttons);
|
|
127
|
+
if (btnConfigs && btnConfigs.length > 0) {
|
|
128
|
+
for (let i = 0; i < btnConfigs.length; i++) {
|
|
129
|
+
let btnConfig = btnConfigs[i];
|
|
130
|
+
if (btnConfig.id == el.id && btnConfig.permission == "no") {
|
|
131
|
+
if (!el || !el.parentNode) return;
|
|
132
|
+
el.parentNode.removeChild(el);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
Vue.directive("el-drag-dialog", LeDrag);
|
|
141
|
+
// Vue.directive("rtable", {
|
|
142
|
+
// bind(el) {
|
|
143
|
+
// const { componentInstance: $table } = vnode;
|
|
144
|
+
// let tableTop = el.getBoundingClientRect().top;
|
|
145
|
+
// let body = window.innerHeight - tableTop - 90;
|
|
146
|
+
// el.style["max-height"] = `${body}px`;
|
|
147
|
+
// el.style["overflow-y"] = "auto";
|
|
148
|
+
// console.log(el);
|
|
149
|
+
// el.setAttribute("ref", "eltablemain");
|
|
150
|
+
// el.setAttribute(":max-height", "elTableMaxHeight");
|
|
151
|
+
// el.setAttribute(":header-cell-style", "{ 'text-align': 'center' }");
|
|
152
|
+
// el.setAttribute(":cell-style", "{ 'text-align': 'center' }");
|
|
153
|
+
// },
|
|
154
|
+
// });
|
|
155
|
+
|
|
156
|
+
Vue.directive("rfooter", {
|
|
157
|
+
//参数支持"center"
|
|
158
|
+
bind(el, binding, vnode) {
|
|
159
|
+
let param = binding.value;
|
|
160
|
+
if (!param) {
|
|
161
|
+
param = "right";
|
|
162
|
+
}
|
|
163
|
+
el.setAttribute(
|
|
164
|
+
"style",
|
|
165
|
+
`display:flex;display:-webkit-flex;justify-content:${param};margin-bottom:-20px`,
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
//判断是否是直接引入文件
|
|
172
|
+
if (typeof window !== "undefined" && window.Vue) {
|
|
173
|
+
window["el-drag-dialog"] = LeDrag;
|
|
174
|
+
install(window.Vue);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export default {
|
|
178
|
+
install,
|
|
179
|
+
LeButton,
|
|
180
|
+
LeButtonQr,
|
|
181
|
+
LeButtonMsg,
|
|
182
|
+
LeDialogContainer,
|
|
183
|
+
LeLogin,
|
|
184
|
+
LeHome,
|
|
185
|
+
|
|
186
|
+
LeMedia,
|
|
187
|
+
LeMediaUpload,
|
|
188
|
+
LeMediaList,
|
|
189
|
+
|
|
190
|
+
// LeButtonUpload,
|
|
191
|
+
// LeButtonSelectMedia,
|
|
192
|
+
// LeImageContainer,
|
|
193
|
+
LeImage,
|
|
194
|
+
LeUpload,
|
|
195
|
+
// LeHelp,
|
|
196
|
+
// LeHelpDetail,
|
|
197
|
+
LeSelect,
|
|
198
|
+
LeSelectSearch,
|
|
199
|
+
LeInput,
|
|
200
|
+
LeInputNumber,
|
|
201
|
+
LeForm,
|
|
202
|
+
LeFormItem,
|
|
203
|
+
LeSelectOption,
|
|
204
|
+
LeVideo,
|
|
205
|
+
LeListForm,
|
|
206
|
+
LeList,
|
|
207
|
+
LeDatePicker,
|
|
208
|
+
LeUrl,
|
|
209
|
+
LeSpan,
|
|
210
|
+
LeInputAdvanced,
|
|
211
|
+
// LeButtonAudit,
|
|
212
|
+
LeInputValidate,
|
|
213
|
+
LeDatePickerAuto,
|
|
214
|
+
LeTableEdit,
|
|
215
|
+
LeButtonAttach,
|
|
216
|
+
LeSelectMulti,
|
|
217
|
+
LeUploadTable,
|
|
218
|
+
LeReport,
|
|
219
|
+
LeArea,
|
|
220
|
+
LeMenu,
|
|
221
|
+
LeRole,
|
|
222
|
+
LeRoleUser,
|
|
223
|
+
};
|
package/le-area/index.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-cascader
|
|
3
|
+
v-model="value"
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
v-on="$listeners"
|
|
6
|
+
clearable
|
|
7
|
+
:ref="elcascader"
|
|
8
|
+
:props="props"
|
|
9
|
+
@change="handleChange"
|
|
10
|
+
></el-cascader>
|
|
11
|
+
</template>
|
|
12
|
+
<script>
|
|
13
|
+
import { getAreas } from "@/api/system-area.js";
|
|
14
|
+
export default {
|
|
15
|
+
name: "le-area",
|
|
16
|
+
props: {
|
|
17
|
+
level: {
|
|
18
|
+
type: [String, Number],
|
|
19
|
+
default: "2",
|
|
20
|
+
},
|
|
21
|
+
initCode: {
|
|
22
|
+
type: [String, Number],
|
|
23
|
+
default: "0",
|
|
24
|
+
},
|
|
25
|
+
isAny: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false,
|
|
28
|
+
},
|
|
29
|
+
initArea: {
|
|
30
|
+
type: Array,
|
|
31
|
+
default: () => [],
|
|
32
|
+
},
|
|
33
|
+
elcascader: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
value: [],
|
|
41
|
+
props: {
|
|
42
|
+
label: "name",
|
|
43
|
+
value: "code",
|
|
44
|
+
checkStrictly: false,
|
|
45
|
+
lazy: true,
|
|
46
|
+
lazyLoad: this.LoadData,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
watch: {
|
|
51
|
+
isAny: {
|
|
52
|
+
handler(val) {
|
|
53
|
+
this.props.checkStrictly = val;
|
|
54
|
+
},
|
|
55
|
+
immediate: true,
|
|
56
|
+
},
|
|
57
|
+
initArea: {
|
|
58
|
+
handler(val) {
|
|
59
|
+
this.value = val;
|
|
60
|
+
},
|
|
61
|
+
immediate: true,
|
|
62
|
+
deep: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
mounted() {
|
|
67
|
+
if (this.initArea && this.initArea.length > 0) {
|
|
68
|
+
this.value = this.initArea;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
methods: {
|
|
72
|
+
setInitArea(initArea) {
|
|
73
|
+
this.value = initArea;
|
|
74
|
+
},
|
|
75
|
+
clearInitArea() {
|
|
76
|
+
this.value = [];
|
|
77
|
+
},
|
|
78
|
+
LoadData(node, resolve) {
|
|
79
|
+
let nodes = [];
|
|
80
|
+
let { level } = node;
|
|
81
|
+
let param = {};
|
|
82
|
+
param.pcode = level == 0 ? this.initCode : node.value;
|
|
83
|
+
getAreas(param).then((res) => {
|
|
84
|
+
nodes = res.data.data;
|
|
85
|
+
nodes.forEach((item) => {
|
|
86
|
+
item.leaf = item.type == this.level ? true : false;
|
|
87
|
+
});
|
|
88
|
+
resolve(nodes);
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
handleChange(currentValue) {
|
|
92
|
+
let selectValue = {};
|
|
93
|
+
selectValue.code = currentValue;
|
|
94
|
+
if (!selectValue.code || selectValue.code.length <= 0) return;
|
|
95
|
+
let cascader = this.$refs[this.elcascader];
|
|
96
|
+
if (cascader) {
|
|
97
|
+
const nodes = cascader.getCheckedNodes();
|
|
98
|
+
if (nodes && nodes.length > 0) {
|
|
99
|
+
console.log(nodes[0].pathLabels);
|
|
100
|
+
const labels = nodes[0].pathLabels;
|
|
101
|
+
selectValue.name = labels.join("");
|
|
102
|
+
this.$emit("areaChange", selectValue);
|
|
103
|
+
} else {
|
|
104
|
+
console.log("area control node 不存:");
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
console.log("area control err:", "elcascader ref 不存在");
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
</script>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-button
|
|
3
|
+
v-bind="$attrs"
|
|
4
|
+
v-on="$listeners"
|
|
5
|
+
:class="['customClass', $attrs.class]"
|
|
6
|
+
:style="$attrs.style"
|
|
7
|
+
:id="id"
|
|
8
|
+
:type="type"
|
|
9
|
+
:size="size"
|
|
10
|
+
v-permission="$route.params.btns"
|
|
11
|
+
v-if="disp"
|
|
12
|
+
><slot></slot>{{ text }}</el-button
|
|
13
|
+
>
|
|
14
|
+
</template>
|
|
15
|
+
<script>
|
|
16
|
+
export default {
|
|
17
|
+
name: "le-button",
|
|
18
|
+
props: {
|
|
19
|
+
id: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "",
|
|
22
|
+
},
|
|
23
|
+
type: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "primary",
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "small",
|
|
30
|
+
},
|
|
31
|
+
permission: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "$route.params.btns",
|
|
34
|
+
},
|
|
35
|
+
text: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "",
|
|
38
|
+
},
|
|
39
|
+
disp: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
methods: {
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="le-button-attach">
|
|
3
|
+
<el-upload
|
|
4
|
+
action=""
|
|
5
|
+
:http-request="uploadFile"
|
|
6
|
+
:before-upload="beforeUpload"
|
|
7
|
+
:show-file-list="false"
|
|
8
|
+
:multiple="multiple"
|
|
9
|
+
:accept="acceptTypes"
|
|
10
|
+
:disabled="disabled"
|
|
11
|
+
:class="{ 'is-disabled': disabled }"
|
|
12
|
+
>
|
|
13
|
+
<el-button
|
|
14
|
+
:type="type"
|
|
15
|
+
:size="size"
|
|
16
|
+
:icon="icon"
|
|
17
|
+
:disabled="disabled"
|
|
18
|
+
:loading="loading"
|
|
19
|
+
v-if="false"
|
|
20
|
+
>
|
|
21
|
+
{{ buttonText }}
|
|
22
|
+
</el-button>
|
|
23
|
+
</el-upload>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script>
|
|
28
|
+
export default {
|
|
29
|
+
name: "le-button-attach",
|
|
30
|
+
props: {
|
|
31
|
+
// 是否允许多选
|
|
32
|
+
multiple: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false,
|
|
35
|
+
},
|
|
36
|
+
// 按钮文字
|
|
37
|
+
buttonText: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "导入Excel",
|
|
40
|
+
},
|
|
41
|
+
// 按钮类型
|
|
42
|
+
type: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "primary",
|
|
45
|
+
},
|
|
46
|
+
// 按钮尺寸
|
|
47
|
+
size: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "small",
|
|
50
|
+
},
|
|
51
|
+
// 按钮图标
|
|
52
|
+
icon: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "el-icon-upload",
|
|
55
|
+
},
|
|
56
|
+
// 是否禁用
|
|
57
|
+
disabled: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
61
|
+
// 文件大小限制(MB)
|
|
62
|
+
maxSize: {
|
|
63
|
+
type: Number,
|
|
64
|
+
default: 10,
|
|
65
|
+
},
|
|
66
|
+
// 上传函数,接收文件
|
|
67
|
+
uploadFunction: {
|
|
68
|
+
type: Function,
|
|
69
|
+
required: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
data() {
|
|
73
|
+
return {
|
|
74
|
+
// 接受的Excel文件类型
|
|
75
|
+
acceptTypes: ".xlsx, .xls, .csv",
|
|
76
|
+
// 加载状态
|
|
77
|
+
loading: false,
|
|
78
|
+
// 上传中状态
|
|
79
|
+
uploading: false,
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
methods: {
|
|
83
|
+
/**
|
|
84
|
+
* 上传前校验
|
|
85
|
+
*/
|
|
86
|
+
beforeUpload(file) {
|
|
87
|
+
// 校验文件类型
|
|
88
|
+
const isExcel = /\.(xlsx|xls|csv)$/i.test(file.name);
|
|
89
|
+
if (!isExcel) {
|
|
90
|
+
this.$message.error("只能上传Excel文件(.xlsx, .xls, .csv)!");
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 校验文件大小
|
|
95
|
+
const isLt10M = file.size / 1024 / 1024 < this.maxSize;
|
|
96
|
+
if (!isLt10M) {
|
|
97
|
+
this.$message.error(`上传文件大小不能超过 ${this.maxSize}MB!`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this.loading = true;
|
|
102
|
+
|
|
103
|
+
// 触发上传前事件
|
|
104
|
+
this.$emit("before-upload", file);
|
|
105
|
+
|
|
106
|
+
return true;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 上传文件
|
|
111
|
+
*/
|
|
112
|
+
async uploadFile(param) {
|
|
113
|
+
if (this.uploading) {
|
|
114
|
+
this.$message.warning("正在上传中,请稍候...");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.uploading = true;
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
// 调用上传函数,只传入文件
|
|
122
|
+
const res = await this.uploadFunction(param.file);
|
|
123
|
+
|
|
124
|
+
// 上传成功处理
|
|
125
|
+
this.loading = false;
|
|
126
|
+
this.uploading = false;
|
|
127
|
+
|
|
128
|
+
// 触发成功事件
|
|
129
|
+
this.$emit("success", res.data, param.file);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
this.loading = false;
|
|
132
|
+
this.uploading = false;
|
|
133
|
+
|
|
134
|
+
// 上传失败
|
|
135
|
+
const errorMessage =
|
|
136
|
+
error.message ||
|
|
137
|
+
error.response?.data?.info ||
|
|
138
|
+
error.response?.data?.message ||
|
|
139
|
+
"文件上传失败,请重试";
|
|
140
|
+
this.$message.error(errorMessage);
|
|
141
|
+
this.$emit("error", error, param.file);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 手动触发上传(用于外部调用)
|
|
147
|
+
*/
|
|
148
|
+
triggerUpload() {
|
|
149
|
+
this.$el.querySelector(".el-upload__input").click();
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<style lang="scss" scoped>
|
|
156
|
+
.le-button-attach {
|
|
157
|
+
display: inline-block;
|
|
158
|
+
|
|
159
|
+
::v-deep .el-upload {
|
|
160
|
+
display: inline-block;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
&.is-disabled {
|
|
164
|
+
cursor: not-allowed;
|
|
165
|
+
|
|
166
|
+
::v-deep .el-upload {
|
|
167
|
+
cursor: not-allowed;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
</style>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-popconfirm
|
|
3
|
+
v-bind="$attrs"
|
|
4
|
+
v-on="$listeners"
|
|
5
|
+
:class="['customClass', $attrs.class]"
|
|
6
|
+
:title="title"
|
|
7
|
+
:id="id"
|
|
8
|
+
@confirm="click"
|
|
9
|
+
:v-permission="permission"
|
|
10
|
+
style="margin-left: 2px; margin-right: 2px"
|
|
11
|
+
v-if="disp"
|
|
12
|
+
>
|
|
13
|
+
<template #reference>
|
|
14
|
+
<le-button :type="type" :size="size" :text="text">
|
|
15
|
+
<slot></slot>
|
|
16
|
+
</le-button>
|
|
17
|
+
</template>
|
|
18
|
+
</el-popconfirm>
|
|
19
|
+
</template>
|
|
20
|
+
<script>
|
|
21
|
+
import LeButton from "../../le-button/index";
|
|
22
|
+
export default {
|
|
23
|
+
name: "le-button-msg",
|
|
24
|
+
components: { LeButton },
|
|
25
|
+
props: {
|
|
26
|
+
id: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: "",
|
|
29
|
+
},
|
|
30
|
+
type: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "primary",
|
|
33
|
+
},
|
|
34
|
+
size: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: "small",
|
|
37
|
+
},
|
|
38
|
+
permission: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: "$route.params.btns",
|
|
41
|
+
},
|
|
42
|
+
text: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "",
|
|
45
|
+
},
|
|
46
|
+
title: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "该操作不可逆,确定删除?",
|
|
49
|
+
},
|
|
50
|
+
isDispSlot: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
disp: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: true,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
click(param) {
|
|
61
|
+
this.$emit("click", param);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
</script>
|