umy-ui-table 1.2.0
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/LICENSE +21 -0
- package/README.md +111 -0
- package/lib/button.js +1 -0
- package/lib/icon.js +1 -0
- package/lib/index.js +1 -0
- package/lib/locale/format.js +56 -0
- package/lib/locale/index.js +72 -0
- package/lib/locale/lang/en.js +123 -0
- package/lib/locale/lang/zh-CN.js +119 -0
- package/lib/mixins/locale.js +17 -0
- package/lib/theme-chalk/base.css +0 -0
- package/lib/theme-chalk/button.css +1 -0
- package/lib/theme-chalk/fonts/element-icons.ttf +0 -0
- package/lib/theme-chalk/fonts/element-icons.woff +0 -0
- package/lib/theme-chalk/fonts/iconfont.1785562768224.ttf +0 -0
- package/lib/theme-chalk/fonts/iconfont.1785562768224.woff +0 -0
- package/lib/theme-chalk/fonts/iconfont.1785562768224.woff2 +0 -0
- package/lib/theme-chalk/icon.css +1 -0
- package/lib/theme-chalk/index.css +1 -0
- package/lib/theme-chalk/u-table-column.css +0 -0
- package/lib/theme-chalk/u-table.css +1 -0
- package/lib/theme-chalk/ux-grid.css +1 -0
- package/lib/theme-chalk/ux-table-column.css +0 -0
- package/lib/u-table-column.js +1 -0
- package/lib/u-table.js +1 -0
- package/lib/umd/locale/en.js +139 -0
- package/lib/umd/locale/zh-CN.js +135 -0
- package/lib/umy-ui.common.js +1 -0
- package/lib/utils/svg.js +33 -0
- package/lib/utils/types.js +35 -0
- package/lib/utils/util.js +268 -0
- package/lib/ux-grid.js +1 -0
- package/lib/ux-table-column.js +1 -0
- package/package.json +117 -0
- package/packages/button/index.js +7 -0
- package/packages/button/src/button-group.vue +10 -0
- package/packages/button/src/button.vue +166 -0
- package/packages/checkbox/index.js +8 -0
- package/packages/checkbox/src/checkbox-button.vue +199 -0
- package/packages/checkbox/src/checkbox-group.vue +48 -0
- package/packages/checkbox/src/checkbox.vue +222 -0
- package/packages/checkbox-button/index.js +8 -0
- package/packages/checkbox-group/index.js +8 -0
- package/packages/icon/index.js +7 -0
- package/packages/icon/src/icon.vue +40 -0
- package/packages/input/index.js +2 -0
- package/packages/input/src/calcTextareaHeight.js +104 -0
- package/packages/input/src/input.vue +424 -0
- package/packages/option/index.js +2 -0
- package/packages/pagination/index.js +2 -0
- package/packages/pagination/src/pager.vue +163 -0
- package/packages/pagination/src/pagination.js +386 -0
- package/packages/scrollbar/index.js +8 -0
- package/packages/scrollbar/src/bar.js +92 -0
- package/packages/scrollbar/src/main.js +130 -0
- package/packages/scrollbar/src/util.js +34 -0
- package/packages/select/index.js +2 -0
- package/packages/select/src/navigation-mixin.js +54 -0
- package/packages/select/src/option-group.vue +60 -0
- package/packages/select/src/option.vue +163 -0
- package/packages/select/src/select-dropdown.vue +74 -0
- package/packages/select/src/select.vue +889 -0
- package/packages/table/index.js +8 -0
- package/packages/table/src/config.js +123 -0
- package/packages/table/src/dropdown.js +28 -0
- package/packages/table/src/filter-panel.vue +194 -0
- package/packages/table/src/layout-observer.js +68 -0
- package/packages/table/src/store/current.js +71 -0
- package/packages/table/src/store/expand.js +65 -0
- package/packages/table/src/store/helper.js +37 -0
- package/packages/table/src/store/index.js +145 -0
- package/packages/table/src/store/tree.js +208 -0
- package/packages/table/src/store/watcher.js +448 -0
- package/packages/table/src/table-body.js +493 -0
- package/packages/table/src/table-column.js +381 -0
- package/packages/table/src/table-footer.js +174 -0
- package/packages/table/src/table-header.js +537 -0
- package/packages/table/src/table-layout.js +231 -0
- package/packages/table/src/table.vue +741 -0
- package/packages/table/src/util.js +256 -0
- package/packages/tag/index.js +8 -0
- package/packages/tag/src/tag.vue +58 -0
- package/packages/tools/directives/mousewheel.js +18 -0
- package/packages/tools/directives/repeat-click.js +24 -0
- package/packages/tools/locale/format.js +46 -0
- package/packages/tools/locale/index.js +48 -0
- package/packages/tools/locale/lang/en.js +120 -0
- package/packages/tools/locale/lang/zh-CN.js +116 -0
- package/packages/tools/mixins/emitter.js +33 -0
- package/packages/tools/mixins/focus.js +9 -0
- package/packages/tools/mixins/locale.js +9 -0
- package/packages/tools/mixins/migrating.js +54 -0
- package/packages/tools/transitions/collapse-transition.js +77 -0
- package/packages/tools/utils/after-leave.js +27 -0
- package/packages/tools/utils/aria-dialog.js +90 -0
- package/packages/tools/utils/aria-utils.js +122 -0
- package/packages/tools/utils/clickoutside.js +76 -0
- package/packages/tools/utils/date-util.js +292 -0
- package/packages/tools/utils/date.js +368 -0
- package/packages/tools/utils/dom.js +227 -0
- package/packages/tools/utils/menu/aria-menubar.js +14 -0
- package/packages/tools/utils/menu/aria-menuitem.js +49 -0
- package/packages/tools/utils/menu/aria-submenu.js +59 -0
- package/packages/tools/utils/merge.js +15 -0
- package/packages/tools/utils/popper.js +1276 -0
- package/packages/tools/utils/popup/index.js +218 -0
- package/packages/tools/utils/popup/popup-manager.js +194 -0
- package/packages/tools/utils/resize-event.js +35 -0
- package/packages/tools/utils/scroll-into-view.js +27 -0
- package/packages/tools/utils/scrollbar-width.js +29 -0
- package/packages/tools/utils/shared.js +7 -0
- package/packages/tools/utils/svg.js +1 -0
- package/packages/tools/utils/types.js +28 -0
- package/packages/tools/utils/util.js +241 -0
- package/packages/tools/utils/vdom.js +5 -0
- package/packages/tools/utils/vue-popper.js +198 -0
- package/packages/tooltip/index.js +8 -0
- package/packages/tooltip/src/main.js +241 -0
- package/packages/u-table/index.js +4 -0
- package/packages/u-table/revise-el-table-mixins/index.js +10 -0
- package/packages/u-table/revise-el-table-mixins/table-extend.js +60 -0
- package/packages/u-table/revise-el-table-mixins/table.mixins.js +261 -0
- package/packages/u-table/revise-el-table-mixins/virtual-table-body-render.js +132 -0
- package/packages/u-table/src/u-table.vue +248 -0
- package/packages/u-table/u-table-mixins/index.js +483 -0
- package/packages/u-table/u-table-tree-mixins/methods.js +120 -0
- package/packages/u-table/u-table-tree-mixins/u-table-tree-mixins.js +161 -0
- package/packages/u-table-column/index.js +8 -0
- package/packages/utils/common.js +27 -0
- package/packages/ux-grid/index.js +6 -0
- package/packages/ux-grid/mixins/index.js +707 -0
- package/packages/ux-grid/src/interceptor.js +6 -0
- package/packages/ux-grid/src/ux-grid.vue +301 -0
- package/packages/ux-table-column/index.js +10 -0
- package/tools/locale/format.js +46 -0
- package/tools/locale/index.js +54 -0
- package/tools/locale/lang/en.js +120 -0
- package/tools/locale/lang/zh-CN.js +116 -0
- package/tools/mixins/locale.js +9 -0
- package/tools/utils/svg.js +1 -0
- package/tools/utils/types.js +28 -0
- package/tools/utils/util.js +241 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="plTableBox"
|
|
4
|
+
:class="{ uxbeautifyTableClass: beautifyTable }"
|
|
5
|
+
:style="[plTableHeight]"
|
|
6
|
+
>
|
|
7
|
+
<vxe-table
|
|
8
|
+
ref="singleTable"
|
|
9
|
+
class="singleTable"
|
|
10
|
+
style="width: 100%"
|
|
11
|
+
:data="data"
|
|
12
|
+
:columns="columns"
|
|
13
|
+
:loading="loading"
|
|
14
|
+
:show-footer="summaryMethod ? showSummary : false"
|
|
15
|
+
:max-height="newMaxHeight"
|
|
16
|
+
:height="newHeight"
|
|
17
|
+
:mergeCells="mergeCells"
|
|
18
|
+
:validConfig="validConfig"
|
|
19
|
+
:auto-resize="widthResize"
|
|
20
|
+
:edit-rules="rules"
|
|
21
|
+
:border="beautifyTable ? false : border"
|
|
22
|
+
:scroll-y="scrollYConfig"
|
|
23
|
+
:scroll-x="scrollXConfig"
|
|
24
|
+
context-menu
|
|
25
|
+
:stripe="stripe"
|
|
26
|
+
:row-key="rowKey"
|
|
27
|
+
:column-key="columnKey"
|
|
28
|
+
:row-id="rowId"
|
|
29
|
+
:keep-source="keepSource"
|
|
30
|
+
:size="size"
|
|
31
|
+
:edit-config="editConfig"
|
|
32
|
+
:seq-config="indexConfig"
|
|
33
|
+
:expand-config="expandConfig"
|
|
34
|
+
:keyboard-config="keyboardConfig"
|
|
35
|
+
:mouse-config="mouseConfig"
|
|
36
|
+
:checkbox-config="checkboxConfig"
|
|
37
|
+
:tree-config="treeConfig"
|
|
38
|
+
:sort-config="sortConfig"
|
|
39
|
+
:show-header="showHeader"
|
|
40
|
+
:show-overflow="showOverflow"
|
|
41
|
+
:footer-method="footerMethod"
|
|
42
|
+
:show-header-overflow="showHeaderOverflow"
|
|
43
|
+
:show-footer-overflow="showFooterOverflow"
|
|
44
|
+
:highlight-current-row="highlightCurrentRow"
|
|
45
|
+
:highlight-hover-row="highlightCurrentRow"
|
|
46
|
+
:row-class-name="rowClassName"
|
|
47
|
+
:cell-class-name="cellClassName"
|
|
48
|
+
:header-row-class-name="headerRowClassName"
|
|
49
|
+
:header-cell-class-name="headerCellClassName"
|
|
50
|
+
:header-row-style="headerRowStyle"
|
|
51
|
+
:header-cell-style="headerCellStyle"
|
|
52
|
+
:row-style="rowStyle"
|
|
53
|
+
:cell-style="cellStyle"
|
|
54
|
+
:span-method="spanMethod ? arraySpanMethod : null"
|
|
55
|
+
@current-change="currentChange"
|
|
56
|
+
@checkbox-change="plSelect"
|
|
57
|
+
@resizable-change="headerDragend"
|
|
58
|
+
@cell-mouseenter="cellMouseEnter"
|
|
59
|
+
@cell-mouseleave="cellMouseLeave"
|
|
60
|
+
@cell-click="cellClick"
|
|
61
|
+
@cell-dblclick="cellDblclick"
|
|
62
|
+
@cell-context-menu="rowContextmenu"
|
|
63
|
+
@header-cell-context-menu="headerContextmenu"
|
|
64
|
+
@radio-change="radioChange"
|
|
65
|
+
@header-cell-click="headerClick"
|
|
66
|
+
@checkbox-all="selectAll"
|
|
67
|
+
@filter-change="filterChange"
|
|
68
|
+
@sort-change="sortChange"
|
|
69
|
+
@edit-closed="editClosed"
|
|
70
|
+
@edit-actived="editActived"
|
|
71
|
+
@edit-disabled="editDisabled"
|
|
72
|
+
@toggle-tree-expand="toggleTreeExpandEv"
|
|
73
|
+
@toggle-row-expand="expChang"
|
|
74
|
+
@keydown="keydown"
|
|
75
|
+
@edit-currently-active="editCurrentlyActive"
|
|
76
|
+
@scroll="tableBodyScroll"
|
|
77
|
+
@init-rendered="initRendered"
|
|
78
|
+
@data-rendered="dataRendered"
|
|
79
|
+
>
|
|
80
|
+
<!--无数据布局-->
|
|
81
|
+
<template slot="empty">
|
|
82
|
+
<slot name="empty">{{ emptyText }}</slot>
|
|
83
|
+
</template>
|
|
84
|
+
<slot />
|
|
85
|
+
</vxe-table>
|
|
86
|
+
<div class="myPagination" v-if="paginationShow" ref="myPagination">
|
|
87
|
+
<el-pagination
|
|
88
|
+
@size-change="handleSizeChange"
|
|
89
|
+
@current-change="handleCurrentChange"
|
|
90
|
+
:current-page="newcurrentPage"
|
|
91
|
+
:pager-count="pagerCount"
|
|
92
|
+
:page-sizes="pageSizes"
|
|
93
|
+
:page-size="newPageSize"
|
|
94
|
+
:layout="layout"
|
|
95
|
+
:total="total"
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
<div class="plDialog" ref="plDialog">
|
|
99
|
+
<div style="width: 100%;height: 100%;" v-if="plDialogFals">
|
|
100
|
+
<div class="table-cus-header">{{ fieldTitle }}</div>
|
|
101
|
+
<div class="checkListBox">
|
|
102
|
+
<draggable
|
|
103
|
+
tag="ul"
|
|
104
|
+
:options="{ disabled: !fieldSort }"
|
|
105
|
+
v-model="newDialogData"
|
|
106
|
+
>
|
|
107
|
+
<li v-for="(item, index) in newDialogData" :key="index">
|
|
108
|
+
<el-checkbox v-model="item.state" :disabled="item.disabled">{{
|
|
109
|
+
item.name
|
|
110
|
+
}}</el-checkbox>
|
|
111
|
+
<template v-if="showDialogIcon">
|
|
112
|
+
<i
|
|
113
|
+
class="iconfont"
|
|
114
|
+
:class="[moveDownIcon || 'el-icon-bottom']"
|
|
115
|
+
@click="handleField('下移', index, newDialogData)"
|
|
116
|
+
v-if="index !== newDialogData.length - 1"
|
|
117
|
+
/>
|
|
118
|
+
<i
|
|
119
|
+
class="iconfont"
|
|
120
|
+
:class="[moveUpIcon || 'el-icon-top']"
|
|
121
|
+
@click="handleField('上移', index, newDialogData)"
|
|
122
|
+
v-if="index !== 0"
|
|
123
|
+
/>
|
|
124
|
+
</template>
|
|
125
|
+
<i
|
|
126
|
+
class="iconfont"
|
|
127
|
+
:class="[amendBtnIcon || 'el-icon-edit']"
|
|
128
|
+
v-if="showAmend"
|
|
129
|
+
@click="amendField(item, index)"
|
|
130
|
+
/>
|
|
131
|
+
</li>
|
|
132
|
+
</draggable>
|
|
133
|
+
</div>
|
|
134
|
+
<div class="table-cus-footer">
|
|
135
|
+
<el-button @click="closeModal()">取消</el-button>
|
|
136
|
+
<el-button type="primary" @click="confirmField">确定</el-button>
|
|
137
|
+
<el-button type="warning" @click="reset">重置</el-button>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</template>
|
|
143
|
+
|
|
144
|
+
<script type="text/babel">
|
|
145
|
+
import Vue from "vue";
|
|
146
|
+
import draggable from "vuedraggable";
|
|
147
|
+
import ElPagination from "../../pagination";
|
|
148
|
+
import ElCheckbox from "../../checkbox";
|
|
149
|
+
import ElButton from "../../button";
|
|
150
|
+
// 直接用 vxe-table@3.22.9 的 VxeTable 作内核(替代原 umy-table 内置的 elx-grid)
|
|
151
|
+
// 注意:不用 VxeGrid,因为 VxeGrid 3.x 不渲染默认插槽,槽位式 ux-table-column 列会全部丢失;
|
|
152
|
+
// VxeTable 原生支持默认插槽列收集(隐藏容器 vxe-table-slots + provide/inject)
|
|
153
|
+
import VxeTable from "vxe-table/lib/table";
|
|
154
|
+
import uxGridMixin from "../mixins";
|
|
155
|
+
import { parseHeight, isArrayFn } from "../../utils/common";
|
|
156
|
+
|
|
157
|
+
export default {
|
|
158
|
+
name: "UxGrid",
|
|
159
|
+
mixins: [uxGridMixin],
|
|
160
|
+
components: { draggable, ElPagination, ElCheckbox, ElButton, VxeTable },
|
|
161
|
+
data() {
|
|
162
|
+
return {
|
|
163
|
+
_times: "", // 弹框定时器
|
|
164
|
+
plDialogFals: false, // 侧滑弹框是否开启
|
|
165
|
+
newDialogData: [], // 新自定义字段的数据
|
|
166
|
+
aBox: "", // 蒙层节点
|
|
167
|
+
newPageSize: "", // 每页条数
|
|
168
|
+
newcurrentPage: "", // 当前页
|
|
169
|
+
newHeight: null, // 表格高度
|
|
170
|
+
newMaxHeight: null, // 表格最大高度
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
computed: {
|
|
174
|
+
// span-method 与 vxe 虚拟滚动不兼容(官方 warnLog: scrollErrProp),存在时自动关闭虚拟;
|
|
175
|
+
// merge-cells 与虚拟滚动兼容(vxe 对合并单元格行不做虚拟占位),无需关闭(用户显式传 scrollY/scrollX 且带 enabled 时尊重用户)
|
|
176
|
+
scrollYConfig() {
|
|
177
|
+
const propsData = this.$options.propsData || {};
|
|
178
|
+
if (
|
|
179
|
+
this.spanMethod &&
|
|
180
|
+
!(propsData.scrollY && propsData.scrollY.enabled !== undefined)
|
|
181
|
+
) {
|
|
182
|
+
return Object.assign({}, this.scrollY, { enabled: false });
|
|
183
|
+
}
|
|
184
|
+
return this.scrollY;
|
|
185
|
+
},
|
|
186
|
+
scrollXConfig() {
|
|
187
|
+
const propsData = this.$options.propsData || {};
|
|
188
|
+
if (
|
|
189
|
+
this.spanMethod &&
|
|
190
|
+
!(propsData.scrollX && propsData.scrollX.enabled !== undefined)
|
|
191
|
+
) {
|
|
192
|
+
return Object.assign({}, this.scrollX, { enabled: false });
|
|
193
|
+
}
|
|
194
|
+
return this.scrollX;
|
|
195
|
+
},
|
|
196
|
+
plTableHeight() {
|
|
197
|
+
if (this.height) {
|
|
198
|
+
return {
|
|
199
|
+
height: this.height + "px",
|
|
200
|
+
};
|
|
201
|
+
} else if (this.maxHeight) {
|
|
202
|
+
const maxHeight = parseHeight(this.maxHeight);
|
|
203
|
+
if (typeof maxHeight === "number") {
|
|
204
|
+
return {
|
|
205
|
+
"max-height": this.maxHeight + "px",
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return {};
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
watch: {
|
|
213
|
+
columns: {
|
|
214
|
+
handler(val) {
|
|
215
|
+
if (val && val.length && this.$refs.singleTable) {
|
|
216
|
+
this.$refs.singleTable.loadColumn(val);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
data: {
|
|
221
|
+
immediate: true,
|
|
222
|
+
handler(val) {
|
|
223
|
+
if (!isArrayFn(val)) {
|
|
224
|
+
throw new Error("表格数据需要的是数组格式,请检查你的数据格式");
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
currentPage(val) {
|
|
229
|
+
this.newcurrentPage = val;
|
|
230
|
+
},
|
|
231
|
+
pageSize(val) {
|
|
232
|
+
this.newPageSize = val;
|
|
233
|
+
},
|
|
234
|
+
height: {
|
|
235
|
+
immediate: true,
|
|
236
|
+
handler() {
|
|
237
|
+
this.setHeight();
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
maxHeight: {
|
|
241
|
+
immediate: true,
|
|
242
|
+
handler() {
|
|
243
|
+
this.setHeight();
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
created() {
|
|
248
|
+
this.newPageSize = this.pageSize;
|
|
249
|
+
this.newcurrentPage = this.currentPage;
|
|
250
|
+
},
|
|
251
|
+
mounted() {
|
|
252
|
+
this.$ready = true;
|
|
253
|
+
// columns prop 是 vxe-grid 独有能力,VxeTable 不提供该 prop,需手动 loadColumn;
|
|
254
|
+
// 未传 columns 时走槽位式 ux-table-column 收集(VxeTable 原生支持,见 watch staticColumns)
|
|
255
|
+
if (this.columns && this.columns.length) {
|
|
256
|
+
this.$nextTick(() => {
|
|
257
|
+
this.$refs.singleTable &&
|
|
258
|
+
this.$refs.singleTable.loadColumn(this.columns);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
methods: {
|
|
263
|
+
// 自定义字段按钮事件
|
|
264
|
+
handleField(name, index, arr) {
|
|
265
|
+
switch (name) {
|
|
266
|
+
case "上移":
|
|
267
|
+
arr = this.swapItems(arr, index, index - 1);
|
|
268
|
+
break;
|
|
269
|
+
case "下移":
|
|
270
|
+
arr = this.swapItems(arr, index, index + 1);
|
|
271
|
+
break;
|
|
272
|
+
default:
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
this.$emit("handle-field", name, index);
|
|
276
|
+
},
|
|
277
|
+
// 交换后的数据
|
|
278
|
+
swapItems(arr, index1, index2) {
|
|
279
|
+
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
|
|
280
|
+
return arr;
|
|
281
|
+
},
|
|
282
|
+
// 设置表格高度
|
|
283
|
+
setHeight() {
|
|
284
|
+
if (!this.$ready && this.paginationShow)
|
|
285
|
+
return Vue.nextTick(() => this.setHeight());
|
|
286
|
+
const { myPagination } = this.$refs;
|
|
287
|
+
if (this.height) {
|
|
288
|
+
this.newHeight =
|
|
289
|
+
parseHeight(this.height) -
|
|
290
|
+
(myPagination ? myPagination.offsetHeight : 0);
|
|
291
|
+
this.newMaxHeight = null;
|
|
292
|
+
} else if (this.maxHeight) {
|
|
293
|
+
this.newMaxHeight =
|
|
294
|
+
parseHeight(this.maxHeight) -
|
|
295
|
+
(myPagination ? myPagination.offsetHeight : 0);
|
|
296
|
+
this.newHeight = null;
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import VxeColumn from 'vxe-table/lib/column';
|
|
2
|
+
|
|
3
|
+
// vxe-table 3.x 的 column 组件,保持 UxTableColumn 名称以兼容 <ux-table-column> 标签
|
|
4
|
+
const UxTableColumn = Object.assign({}, VxeColumn, { name: 'UxTableColumn' });
|
|
5
|
+
|
|
6
|
+
UxTableColumn.install = function(Vue) {
|
|
7
|
+
Vue.component(UxTableColumn.name, UxTableColumn);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default UxTableColumn;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { hasOwn } from 'umy-ui/tools/utils/util';
|
|
2
|
+
|
|
3
|
+
const RE_NARGS = /(%|)\{([0-9a-zA-Z_]+)\}/g;
|
|
4
|
+
/**
|
|
5
|
+
* String format template
|
|
6
|
+
* - Inspired:
|
|
7
|
+
* https://github.com/Matt-Esch/string-template/index.js
|
|
8
|
+
*/
|
|
9
|
+
export default function(Vue) {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* template
|
|
13
|
+
*
|
|
14
|
+
* @param {String} string
|
|
15
|
+
* @param {Array} ...args
|
|
16
|
+
* @return {String}
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
function template(string, ...args) {
|
|
20
|
+
if (args.length === 1 && typeof args[0] === 'object') {
|
|
21
|
+
args = args[0];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!args || !args.hasOwnProperty) {
|
|
25
|
+
args = {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return string.replace(RE_NARGS, (match, prefix, i, index) => {
|
|
29
|
+
let result;
|
|
30
|
+
|
|
31
|
+
if (string[index - 1] === '{' &&
|
|
32
|
+
string[index + match.length] === '}') {
|
|
33
|
+
return i;
|
|
34
|
+
} else {
|
|
35
|
+
result = hasOwn(args, i) ? args[i] : null;
|
|
36
|
+
if (result === null || result === undefined) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return template;
|
|
46
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import defaultLang from 'umy-ui/tools/locale/lang/zh-CN';
|
|
2
|
+
// 如果是按需加载,设置u-table的locale(本地 u-table 组件统一使用 packages/tools/locale)
|
|
3
|
+
import tableLocale from '../../packages/tools/locale'
|
|
4
|
+
import Vue from 'vue';
|
|
5
|
+
import deepmerge from 'deepmerge';
|
|
6
|
+
import Format from './format';
|
|
7
|
+
|
|
8
|
+
const format = Format(Vue);
|
|
9
|
+
let lang = defaultLang;
|
|
10
|
+
let merged = false;
|
|
11
|
+
let i18nHandler = function() {
|
|
12
|
+
const vuei18n = Object.getPrototypeOf(this || Vue).$t;
|
|
13
|
+
if (typeof vuei18n === 'function' && !!Vue.locale) {
|
|
14
|
+
if (!merged) {
|
|
15
|
+
merged = true;
|
|
16
|
+
Vue.locale(
|
|
17
|
+
Vue.config.lang,
|
|
18
|
+
deepmerge(lang, Vue.locale(Vue.config.lang) || {}, { clone: true })
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return vuei18n.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const t = function(path, options) {
|
|
26
|
+
let value = i18nHandler.apply(this, arguments);
|
|
27
|
+
if (value !== null && value !== undefined) return value;
|
|
28
|
+
const array = path.split('.');
|
|
29
|
+
let current = lang;
|
|
30
|
+
for (let i = 0, j = array.length; i < j; i++) {
|
|
31
|
+
const property = array[i];
|
|
32
|
+
value = current[property];
|
|
33
|
+
if (i === j - 1) {
|
|
34
|
+
return format(value, options)
|
|
35
|
+
}
|
|
36
|
+
if (!value) return '';
|
|
37
|
+
current = value;
|
|
38
|
+
}
|
|
39
|
+
return '';
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const use = function(l) {
|
|
43
|
+
lang = l || lang;
|
|
44
|
+
if (l) {
|
|
45
|
+
// 如果是按需加载,设置u-table语言
|
|
46
|
+
tableLocale.use(l)
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const i18n = function(fn) {
|
|
51
|
+
i18nHandler = fn || i18nHandler;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default { use, t, i18n };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
el: {
|
|
3
|
+
colorpicker: {
|
|
4
|
+
confirm: 'OK',
|
|
5
|
+
clear: 'Clear'
|
|
6
|
+
},
|
|
7
|
+
datepicker: {
|
|
8
|
+
now: 'Now',
|
|
9
|
+
today: 'Today',
|
|
10
|
+
cancel: 'Cancel',
|
|
11
|
+
clear: 'Clear',
|
|
12
|
+
confirm: 'OK',
|
|
13
|
+
selectDate: 'Select date',
|
|
14
|
+
selectTime: 'Select time',
|
|
15
|
+
startDate: 'Start Date',
|
|
16
|
+
startTime: 'Start Time',
|
|
17
|
+
endDate: 'End Date',
|
|
18
|
+
endTime: 'End Time',
|
|
19
|
+
prevYear: 'Previous Year',
|
|
20
|
+
nextYear: 'Next Year',
|
|
21
|
+
prevMonth: 'Previous Month',
|
|
22
|
+
nextMonth: 'Next Month',
|
|
23
|
+
year: '',
|
|
24
|
+
month1: 'January',
|
|
25
|
+
month2: 'February',
|
|
26
|
+
month3: 'March',
|
|
27
|
+
month4: 'April',
|
|
28
|
+
month5: 'May',
|
|
29
|
+
month6: 'June',
|
|
30
|
+
month7: 'July',
|
|
31
|
+
month8: 'August',
|
|
32
|
+
month9: 'September',
|
|
33
|
+
month10: 'October',
|
|
34
|
+
month11: 'November',
|
|
35
|
+
month12: 'December',
|
|
36
|
+
week: 'week',
|
|
37
|
+
weeks: {
|
|
38
|
+
sun: 'Sun',
|
|
39
|
+
mon: 'Mon',
|
|
40
|
+
tue: 'Tue',
|
|
41
|
+
wed: 'Wed',
|
|
42
|
+
thu: 'Thu',
|
|
43
|
+
fri: 'Fri',
|
|
44
|
+
sat: 'Sat'
|
|
45
|
+
},
|
|
46
|
+
months: {
|
|
47
|
+
jan: 'Jan',
|
|
48
|
+
feb: 'Feb',
|
|
49
|
+
mar: 'Mar',
|
|
50
|
+
apr: 'Apr',
|
|
51
|
+
may: 'May',
|
|
52
|
+
jun: 'Jun',
|
|
53
|
+
jul: 'Jul',
|
|
54
|
+
aug: 'Aug',
|
|
55
|
+
sep: 'Sep',
|
|
56
|
+
oct: 'Oct',
|
|
57
|
+
nov: 'Nov',
|
|
58
|
+
dec: 'Dec'
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
select: {
|
|
62
|
+
loading: 'Loading',
|
|
63
|
+
noMatch: 'No matching data',
|
|
64
|
+
noData: 'No data',
|
|
65
|
+
placeholder: 'Select'
|
|
66
|
+
},
|
|
67
|
+
cascader: {
|
|
68
|
+
noMatch: 'No matching data',
|
|
69
|
+
loading: 'Loading',
|
|
70
|
+
placeholder: 'Select',
|
|
71
|
+
noData: 'No data'
|
|
72
|
+
},
|
|
73
|
+
pagination: {
|
|
74
|
+
goto: 'Go to',
|
|
75
|
+
pagesize: '/page',
|
|
76
|
+
total: 'Total {total}',
|
|
77
|
+
pageClassifier: ''
|
|
78
|
+
},
|
|
79
|
+
messagebox: {
|
|
80
|
+
title: 'Message',
|
|
81
|
+
confirm: 'OK',
|
|
82
|
+
cancel: 'Cancel',
|
|
83
|
+
error: 'Illegal input'
|
|
84
|
+
},
|
|
85
|
+
upload: {
|
|
86
|
+
deleteTip: 'press delete to remove',
|
|
87
|
+
delete: 'Delete',
|
|
88
|
+
preview: 'Preview',
|
|
89
|
+
continue: 'Continue'
|
|
90
|
+
},
|
|
91
|
+
table: {
|
|
92
|
+
emptyText: 'No Data',
|
|
93
|
+
confirmFilter: 'Confirm',
|
|
94
|
+
resetFilter: 'Reset',
|
|
95
|
+
clearFilter: 'All',
|
|
96
|
+
sumText: 'Sum'
|
|
97
|
+
},
|
|
98
|
+
tree: {
|
|
99
|
+
emptyText: 'No Data'
|
|
100
|
+
},
|
|
101
|
+
transfer: {
|
|
102
|
+
noMatch: 'No matching data',
|
|
103
|
+
noData: 'No data',
|
|
104
|
+
titles: ['List 1', 'List 2'], // to be translated
|
|
105
|
+
filterPlaceholder: 'Enter keyword', // to be translated
|
|
106
|
+
noCheckedFormat: '{total} items', // to be translated
|
|
107
|
+
hasCheckedFormat: '{checked}/{total} checked' // to be translated
|
|
108
|
+
},
|
|
109
|
+
image: {
|
|
110
|
+
error: 'FAILED'
|
|
111
|
+
},
|
|
112
|
+
pageHeader: {
|
|
113
|
+
title: 'Back' // to be translated
|
|
114
|
+
},
|
|
115
|
+
popconfirm: {
|
|
116
|
+
confirmButtonText: 'Yes',
|
|
117
|
+
cancelButtonText: 'No'
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
el: {
|
|
3
|
+
colorpicker: {
|
|
4
|
+
confirm: '确定',
|
|
5
|
+
clear: '清空'
|
|
6
|
+
},
|
|
7
|
+
datepicker: {
|
|
8
|
+
now: '此刻',
|
|
9
|
+
today: '今天',
|
|
10
|
+
cancel: '取消',
|
|
11
|
+
clear: '清空',
|
|
12
|
+
confirm: '确定',
|
|
13
|
+
selectDate: '选择日期',
|
|
14
|
+
selectTime: '选择时间',
|
|
15
|
+
startDate: '开始日期',
|
|
16
|
+
startTime: '开始时间',
|
|
17
|
+
endDate: '结束日期',
|
|
18
|
+
endTime: '结束时间',
|
|
19
|
+
prevYear: '前一年',
|
|
20
|
+
nextYear: '后一年',
|
|
21
|
+
prevMonth: '上个月',
|
|
22
|
+
nextMonth: '下个月',
|
|
23
|
+
year: '年',
|
|
24
|
+
month1: '1 月',
|
|
25
|
+
month2: '2 月',
|
|
26
|
+
month3: '3 月',
|
|
27
|
+
month4: '4 月',
|
|
28
|
+
month5: '5 月',
|
|
29
|
+
month6: '6 月',
|
|
30
|
+
month7: '7 月',
|
|
31
|
+
month8: '8 月',
|
|
32
|
+
month9: '9 月',
|
|
33
|
+
month10: '10 月',
|
|
34
|
+
month11: '11 月',
|
|
35
|
+
month12: '12 月',
|
|
36
|
+
// week: '周次',
|
|
37
|
+
weeks: {
|
|
38
|
+
sun: '日',
|
|
39
|
+
mon: '一',
|
|
40
|
+
tue: '二',
|
|
41
|
+
wed: '三',
|
|
42
|
+
thu: '四',
|
|
43
|
+
fri: '五',
|
|
44
|
+
sat: '六'
|
|
45
|
+
},
|
|
46
|
+
months: {
|
|
47
|
+
jan: '一月',
|
|
48
|
+
feb: '二月',
|
|
49
|
+
mar: '三月',
|
|
50
|
+
apr: '四月',
|
|
51
|
+
may: '五月',
|
|
52
|
+
jun: '六月',
|
|
53
|
+
jul: '七月',
|
|
54
|
+
aug: '八月',
|
|
55
|
+
sep: '九月',
|
|
56
|
+
oct: '十月',
|
|
57
|
+
nov: '十一月',
|
|
58
|
+
dec: '十二月'
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
select: {
|
|
62
|
+
loading: '加载中',
|
|
63
|
+
noMatch: '无匹配数据',
|
|
64
|
+
noData: '无数据',
|
|
65
|
+
placeholder: '请选择'
|
|
66
|
+
},
|
|
67
|
+
cascader: {
|
|
68
|
+
noMatch: '无匹配数据',
|
|
69
|
+
loading: '加载中',
|
|
70
|
+
placeholder: '请选择',
|
|
71
|
+
noData: '暂无数据'
|
|
72
|
+
},
|
|
73
|
+
pagination: {
|
|
74
|
+
goto: '前往',
|
|
75
|
+
pagesize: '条/页',
|
|
76
|
+
total: '共 {total} 条',
|
|
77
|
+
pageClassifier: '页'
|
|
78
|
+
},
|
|
79
|
+
messagebox: {
|
|
80
|
+
title: '提示',
|
|
81
|
+
confirm: '确定',
|
|
82
|
+
cancel: '取消',
|
|
83
|
+
error: '输入的数据不合法!'
|
|
84
|
+
},
|
|
85
|
+
upload: {
|
|
86
|
+
deleteTip: '按 delete 键可删除',
|
|
87
|
+
delete: '删除',
|
|
88
|
+
preview: '查看图片',
|
|
89
|
+
continue: '继续上传'
|
|
90
|
+
},
|
|
91
|
+
table: {
|
|
92
|
+
emptyText: '暂无数据',
|
|
93
|
+
confirmFilter: '筛选',
|
|
94
|
+
resetFilter: '重置',
|
|
95
|
+
clearFilter: '全部',
|
|
96
|
+
sumText: '合计'
|
|
97
|
+
},
|
|
98
|
+
tree: {
|
|
99
|
+
emptyText: '暂无数据'
|
|
100
|
+
},
|
|
101
|
+
transfer: {
|
|
102
|
+
noMatch: '无匹配数据',
|
|
103
|
+
noData: '无数据',
|
|
104
|
+
titles: ['列表 1', '列表 2'],
|
|
105
|
+
filterPlaceholder: '请输入搜索内容',
|
|
106
|
+
noCheckedFormat: '共 {total} 项',
|
|
107
|
+
hasCheckedFormat: '已选 {checked}/{total} 项'
|
|
108
|
+
},
|
|
109
|
+
image: {
|
|
110
|
+
error: '加载失败'
|
|
111
|
+
},
|
|
112
|
+
pageHeader: {
|
|
113
|
+
title: '返回'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|