olp-table 5.3.1 → 5.3.4
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/.env.build +1 -0
- package/README.md +26 -0
- package/babel.config.js +5 -0
- package/jsconfig.json +22 -0
- package/{olp-table.common.js → olp-table/olp-table.common.js} +5 -5
- package/{olp-table.umd.js → olp-table/olp-table.umd.js} +5 -5
- package/{olp-table.umd.min.js → olp-table/olp-table.umd.min.js} +3 -3
- package/package.json +92 -12
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/rmMode.bat +1 -0
- package/src/App.vue +199 -0
- package/src/api/crud.js +22 -0
- package/src/api/dist.js +6 -0
- package/src/assets/iconfont/iconfont.css +20 -0
- package/src/assets/iconfont/iconfont.json +16 -0
- package/src/assets/iconfont/iconfont.ttf +0 -0
- package/src/assets/iconfont/iconfont.woff +0 -0
- package/src/assets/iconfont/iconfont.woff2 +0 -0
- package/src/assets/logo.png +0 -0
- package/src/components/auto-height/index.vue +75 -0
- package/src/components/codemirror-tag.vue +100 -0
- package/src/components/lazy-load-select.vue +107 -0
- package/src/components/ol-dialog-excel.vue +112 -0
- package/src/components/ol-dialog-import.vue +304 -0
- package/src/components/ol-dialog-json.vue +82 -0
- package/src/components/ol-dialog-table.vue +81 -0
- package/src/components/ol-dialog-upload-file.vue +208 -0
- package/src/components/ol-dict-tag.vue +271 -0
- package/src/components/ol-select-dom.vue +71 -0
- package/src/components/ol-table-filter.vue +28 -0
- package/src/components/ol-table-render.vue +44 -0
- package/src/components/ol-table-select.vue +150 -0
- package/src/components/pinia-init.vue +18 -0
- package/src/components/table/model/ModelMixins.js +43 -0
- package/src/components/table/model/model-index.vue +121 -0
- package/src/components/table/model/ot-left-right.vue +18 -0
- package/src/components/table/model/ot-left-tree-right-table.scss +14 -0
- package/src/components/table/model/ot-left-tree-right-table.vue +41 -0
- package/src/components/table/model/ot-top-1-bottom-2.vue +39 -0
- package/src/components/table/model/ot-top-2-bottom-1.vue +38 -0
- package/src/components/table/model/ot-top-2-bottom-2.vue +38 -0
- package/src/components/table/model/ot-top-bottom.vue +18 -0
- package/src/components/table/model/splitpanesModel.css +22 -0
- package/src/components/table/model/splitpanesModel.vue +54 -0
- package/src/components/table/ol-form/index.vue +537 -0
- package/src/components/table/ol-form-v3/index.vue +455 -0
- package/src/components/table/ol-main-form-sub-table/index.vue +601 -0
- package/src/components/table/ol-pager/index.vue +46 -0
- package/src/components/table/ol-table/components/ol-table-column-config/columnIndex.vue +233 -0
- package/src/components/table/ol-table/components/ol-table-column-config/index.vue +145 -0
- package/src/components/table/ol-table/components/ol-table-column-dict-color/index.vue +88 -0
- package/src/components/table/ol-table/index.vue +232 -0
- package/src/components/table/ol-table-operate/index.vue +61 -0
- package/src/components/table/ol-table-search/index.vue +17 -0
- package/src/components/table/ol-table-tool-btn/index.vue +60 -0
- package/src/components/tree/components/o-tree.vue +289 -0
- package/src/components/tree/index.vue +46 -0
- package/src/components/v-component/index.vue +43 -0
- package/src/config/dev-config.js +5 -0
- package/src/config/prod-config.js +5 -0
- package/src/config/shared-config.js +20 -0
- package/src/data.js +9378 -0
- package/src/directives/permission/hasPermi.js +63 -0
- package/src/directives/permission/hasRole.js +30 -0
- package/src/main.js +55 -0
- package/src/mixins/VTMixin/DefaultMethods.js +749 -0
- package/src/mixins/VTMixin/OTMixinBody.js +105 -0
- package/src/mixins/VTMixin/OTMixinBodyFooter.js +93 -0
- package/src/mixins/VTMixin/OTMixinBodyMethods.js +420 -0
- package/src/mixins/VTMixin/OTMixinColumnMethod.js +450 -0
- package/src/mixins/VTMixin/OTMixinInitMethod.js +130 -0
- package/src/mixins/VTMixin/OTMixinPager.js +38 -0
- package/src/mixins/VTMixin/OTMixinSortable.js +43 -0
- package/src/mixins/VTMixin/index.js +18 -0
- package/src/package/index.js +20 -0
- package/src/plugins/axios.js +61 -0
- package/src/store/dict.js +76 -0
- package/src/store/dictType.js +52 -0
- package/src/store/permi.js +45 -0
- package/src/styles/common.scss +37 -0
- package/src/styles/index.scss +48 -0
- package/src/styles/theme.scss +32 -0
- package/src/utils/AESCRUDUtils.js +87 -0
- package/src/utils/DateUtils.js +35 -0
- package/src/utils/ExcelUtil.js +159 -0
- package/src/utils/TableSortUtil.js +91 -0
- package/src/utils/columnProp.js +3 -0
- package/src/utils/groupCompute.js +68 -0
- package/src/utils/http/httpFactory.js +92 -0
- package/src/utils/http/httpFactory2.js +79 -0
- package/src/utils/http/httpUtil.js +123 -0
- package/src/utils/http/httpUtils.js +38 -0
- package/src/utils/loadStyle.js +14 -0
- package/src/utils/message.js +56 -0
- package/src/utils/object.js +80 -0
- package/src/utils/security/TokenUtil.js +19 -0
- package/src/utils/tree.js +54 -0
- package/src/utils/util.js +127 -0
- package/src/views/Test/index.vue +77 -0
- package/src/views/Test/index2.vue +33 -0
- package/src/views/components/btn-config/index.vue +202 -0
- package/src/views/components/option-config/index.vue +192 -0
- package/src/views/db/chineseToEnglish.vue +127 -0
- package/src/views/db/filed.vue +395 -0
- package/src/views/db/index.vue +192 -0
- package/src/views/db/preview/index.vue +139 -0
- package/src/views/db/preview/left.vue +204 -0
- package/src/views/db/preview/right.vue +466 -0
- package/src/views/groupTable/index.vue +137 -0
- package/src/views/groupTable/ol-table-column-config/columnIndex.vue +194 -0
- package/src/views/groupTable/ol-table-column-config/index.vue +92 -0
- package/src/views/table/add-or-edit/config/base-config/index.vue +539 -0
- package/src/views/table/add-or-edit/config/base-config/table-form.vue +333 -0
- package/src/views/table/add-or-edit/config/column-config/header-config.vue +475 -0
- package/src/views/table/add-or-edit/config/column-config/index.vue +790 -0
- package/src/views/table/add-or-edit/config/data/column.js +218 -0
- package/src/views/table/add-or-edit/config/data/crud.js +122 -0
- package/src/views/table/add-or-edit/config/data/events.js +109 -0
- package/src/views/table/add-or-edit/config/data/method.js +127 -0
- package/src/views/table/add-or-edit/config/data/option.js +725 -0
- package/src/views/table/add-or-edit/config/data/page.js +79 -0
- package/src/views/table/add-or-edit/config/field-config/filed-config-table.vue +42 -0
- package/src/views/table/add-or-edit/config/field-config/index.vue +91 -0
- package/src/views/table/add-or-edit/config/form-config/index.vue +1179 -0
- package/src/views/table/add-or-edit/config/index.vue +376 -0
- package/src/views/table/add-or-edit/config/initFormObject.js +25 -0
- package/src/views/table/add-or-edit/config/script-config/LeftMeun.vue +71 -0
- package/src/views/table/add-or-edit/config/script-config/index.vue +70 -0
- package/src/views/table/add-or-edit/config/table-config/btn-config.vue +340 -0
- package/src/views/table/add-or-edit/config/table-config/btn-sort.vue +132 -0
- package/src/views/table/add-or-edit/config/table-config/index.vue +446 -0
- package/src/views/table/add-or-edit/configOld/dataTags/filed-config-table-model.vue +41 -0
- package/src/views/table/add-or-edit/configOld/dataTags/filed-config.vue +74 -0
- package/src/views/table/add-or-edit/configOld/dataTags/index.vue +439 -0
- package/src/views/table/add-or-edit/configOld/dataTags/set-table-sql.vue +79 -0
- package/src/views/table/add-or-edit/configOld/dataTags/table-on-config.vue +74 -0
- package/src/views/table/add-or-edit/configOld/index.vue +127 -0
- package/src/views/table/add-or-edit/configOld/tableTags/columnConfig.js +5 -0
- package/src/views/table/add-or-edit/configOld/tableTags/index.vue +353 -0
- package/src/views/table/add-or-edit/configOld/tableTags/operation-but-config.vue +75 -0
- package/src/views/table/add-or-edit/configOld/tableTags/tool-but-config.vue +92 -0
- package/src/views/table/add-or-edit/index.vue +201 -0
- package/src/views/table/add-or-edit/themeModel/index.vue +53 -0
- package/src/views/table/add-or-edit/themeModel/init-model-table.vue +48 -0
- package/src/views/table/add-or-edit/themeModel/init-model.vue +81 -0
- package/src/views/table/add-or-edit/themeModel/left-right.vue +24 -0
- package/src/views/table/add-or-edit/themeModel/left-tree-right-table.vue +75 -0
- package/src/views/table/add-or-edit/themeModel/olTableSearchModelMixins.js +42 -0
- package/src/views/table/add-or-edit/themeModel/splitpanesThemeModel.vue +49 -0
- package/src/views/table/add-or-edit/themeModel/top-1-bottom-2.vue +29 -0
- package/src/views/table/add-or-edit/themeModel/top-2-bottom-1.vue +32 -0
- package/src/views/table/add-or-edit/themeModel/top-2-bottom-2.vue +32 -0
- package/src/views/table/add-or-edit/themeModel/top-bottom.vue +14 -0
- package/src/views/table/index.vue +43 -0
- package/src/views/table/index2.vue +199 -0
- package/src/views/table/preview/index.vue +29 -0
- package/src/views/tree/components/config-core-data.vue +85 -0
- package/src/views/tree/components/config-core-table.vue +362 -0
- package/src/views/tree/components/config-core-tree/data/events.js +95 -0
- package/src/views/tree/components/config-core-tree/data/option.js +88 -0
- package/src/views/tree/components/config-core-tree/data/prop.js +28 -0
- package/src/views/tree/components/config-core-tree/index.vue +181 -0
- package/src/views/tree/components/config-core.vue +42 -0
- package/src/views/tree/components/form-config/index.vue +967 -0
- package/src/views/tree/index.vue +424 -0
- package/vue.config.js +44 -0
- /package/{demo.html → olp-table/demo.html} +0 -0
- /package/{fonts → olp-table/fonts}/iconfont.1720006583309.7e4906d9.woff +0 -0
- /package/{fonts → olp-table/fonts}/iconfont.1720006583309.947a27f0.ttf +0 -0
- /package/{olp-table.css → olp-table/olp-table.css} +0 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<vxe-grid
|
|
4
|
+
v-bind="option"
|
|
5
|
+
v-if="show"
|
|
6
|
+
ref="tableRef"
|
|
7
|
+
@edit-closed="editClosedEvent"
|
|
8
|
+
:data="configData.form[props.type].filter(o => o.alignMode == props.alignMode)">
|
|
9
|
+
<template #toolbar_buttons>
|
|
10
|
+
<el-button @click="onAdd">新增</el-button>
|
|
11
|
+
</template>
|
|
12
|
+
<template #switch_default="{ row,column }">
|
|
13
|
+
<el-switch
|
|
14
|
+
active-value="1"
|
|
15
|
+
inactive-value="0"
|
|
16
|
+
v-model="row[column.field]"
|
|
17
|
+
/>
|
|
18
|
+
</template>
|
|
19
|
+
<template #checkedBox_default="{ column, row,rowIndex }">
|
|
20
|
+
<el-checkbox v-model="row[column.field]" :disabled="row['code'] == 'add' || row['code'] == 'edit'"
|
|
21
|
+
@change="checkbox" true-value="1"
|
|
22
|
+
false-value="0"/>
|
|
23
|
+
</template>
|
|
24
|
+
<template #codemirror="{ row,column }">
|
|
25
|
+
<olCodemirrorTag v-model="row[column.field]"/>
|
|
26
|
+
</template>
|
|
27
|
+
<template #operation="{ row,rowIndex }">
|
|
28
|
+
<el-button @click="removeBtn(row, rowIndex)" type="danger" circle plain>
|
|
29
|
+
<el-icon>
|
|
30
|
+
<Delete/>
|
|
31
|
+
</el-icon>
|
|
32
|
+
</el-button>
|
|
33
|
+
</template>
|
|
34
|
+
</vxe-grid>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
<script setup>
|
|
38
|
+
import {Delete} from '@element-plus/icons-vue'
|
|
39
|
+
import {defineExpose, defineProps, inject, nextTick, onMounted, reactive, ref} from "vue";
|
|
40
|
+
import {getNewArrData, updateSortCall} from "@/utils/TableSortUtil";
|
|
41
|
+
import VXETable from "vxe-table";
|
|
42
|
+
|
|
43
|
+
const configData = inject("configData")
|
|
44
|
+
const updateBtnData = inject('updateBtnData', Function, true)
|
|
45
|
+
const props = defineProps({
|
|
46
|
+
type: {
|
|
47
|
+
required: true,
|
|
48
|
+
type: String
|
|
49
|
+
}, alignMode: {
|
|
50
|
+
required: true,
|
|
51
|
+
type: String
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
const tableRef = ref();
|
|
55
|
+
const show = ref(true)
|
|
56
|
+
const option = reactive({
|
|
57
|
+
expandConfig: {
|
|
58
|
+
trigger: "cell"
|
|
59
|
+
},
|
|
60
|
+
rowConfig: {
|
|
61
|
+
isCurrent: true
|
|
62
|
+
},
|
|
63
|
+
align: 'center',
|
|
64
|
+
editConfig: {
|
|
65
|
+
trigger: 'click',
|
|
66
|
+
mode: 'cell',
|
|
67
|
+
showStatus: true,
|
|
68
|
+
beforeEditMethod: ({column, row}) => {
|
|
69
|
+
const field = column.field
|
|
70
|
+
if ((row.code == 'add' || row.code == 'edit') && field == "code") {
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
pagerConfig: {
|
|
77
|
+
enabled: false
|
|
78
|
+
},
|
|
79
|
+
toolbarConfig: {
|
|
80
|
+
slots: {
|
|
81
|
+
buttons: 'toolbar_buttons'
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
scrollX: {enabled: true, gt: 1},
|
|
85
|
+
scrollY: {enabled: true, gt: 1},
|
|
86
|
+
height: 350,
|
|
87
|
+
index: true,
|
|
88
|
+
searchBtn: false,
|
|
89
|
+
emptyBtn: false,
|
|
90
|
+
menu: false,
|
|
91
|
+
header: false,
|
|
92
|
+
columns: [
|
|
93
|
+
/* {
|
|
94
|
+
title: '序号',
|
|
95
|
+
field: 'sort',
|
|
96
|
+
width: 80,
|
|
97
|
+
},*/
|
|
98
|
+
{
|
|
99
|
+
type: "seq",
|
|
100
|
+
className: 'move',
|
|
101
|
+
width: 60,
|
|
102
|
+
title: "序号",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
title: '按钮名称',
|
|
106
|
+
field: 'name',
|
|
107
|
+
editRender: {name: 'input'},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
title: '定义编码',
|
|
111
|
+
field: 'code',
|
|
112
|
+
editRender: {
|
|
113
|
+
name: 'input', events: {
|
|
114
|
+
change: ({row}) => {
|
|
115
|
+
setTimeout(() => {
|
|
116
|
+
if (row.code != '') {
|
|
117
|
+
row.clickCallBackMethod = row.code + "ButClick"
|
|
118
|
+
} else {
|
|
119
|
+
row.clickCallBackMethod = ''
|
|
120
|
+
}
|
|
121
|
+
}, 100)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
}, {
|
|
126
|
+
title: '图标',
|
|
127
|
+
field: 'icon',
|
|
128
|
+
editRender: {name: 'input'},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
title: '主题',
|
|
132
|
+
field: 'status',
|
|
133
|
+
editRender: {name: 'input'},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
title: '是否启用表单',
|
|
137
|
+
field: 'isForm',
|
|
138
|
+
slots: {
|
|
139
|
+
// 使用插槽模板渲染
|
|
140
|
+
default: 'checkedBox_default',
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
title: '单击回调方法',
|
|
145
|
+
visible: props.type == 'toolButOptions',
|
|
146
|
+
field: 'clickCallBackMethod',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
title: '自定义函数',
|
|
150
|
+
field: 'customFunction',
|
|
151
|
+
slots: {
|
|
152
|
+
// 使用插槽模板渲染
|
|
153
|
+
default: 'codemirror',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
title: '参数1',
|
|
158
|
+
field: 'beforeFunction',
|
|
159
|
+
slots: {
|
|
160
|
+
// 使用插槽模板渲染
|
|
161
|
+
default: 'codemirror',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
title: '参数2',
|
|
166
|
+
field: 'afterFunction',
|
|
167
|
+
slots: {
|
|
168
|
+
// 使用插槽模板渲染
|
|
169
|
+
default: 'codemirror',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
title: 'json',
|
|
174
|
+
field: 'json',
|
|
175
|
+
slots: {
|
|
176
|
+
// 使用插槽模板渲染
|
|
177
|
+
default: 'codemirror',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
title: '默认',
|
|
182
|
+
children: [
|
|
183
|
+
{
|
|
184
|
+
title: '禁用',
|
|
185
|
+
field: 'defaultDisabled',
|
|
186
|
+
visible: props.type == 'toolButOptions',
|
|
187
|
+
width: 80,
|
|
188
|
+
slots: {
|
|
189
|
+
// 使用插槽模板渲染
|
|
190
|
+
default: 'switch_default',
|
|
191
|
+
},
|
|
192
|
+
}, {
|
|
193
|
+
title: '显示',
|
|
194
|
+
field: 'defaultShow',
|
|
195
|
+
visible: props.type == 'toolButOptions',
|
|
196
|
+
width: 80,
|
|
197
|
+
slots: {
|
|
198
|
+
// 使用插槽模板渲染
|
|
199
|
+
default: 'switch_default',
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
title: '回调方法',
|
|
206
|
+
children: [
|
|
207
|
+
{
|
|
208
|
+
title: '单击(click)',
|
|
209
|
+
field: 'clickCallBackMethod',
|
|
210
|
+
visible: props.type != 'toolButOptions',
|
|
211
|
+
}, {
|
|
212
|
+
title: '显示(show)',
|
|
213
|
+
field: 'showCallBack',
|
|
214
|
+
visible: props.type != 'toolButOptions',
|
|
215
|
+
slots: {
|
|
216
|
+
// 使用插槽模板渲染
|
|
217
|
+
default: 'codemirror',
|
|
218
|
+
},
|
|
219
|
+
}, {
|
|
220
|
+
title: '禁用(disabled)',
|
|
221
|
+
field: 'disabledCallBack',
|
|
222
|
+
visible: props.type != 'toolButOptions',
|
|
223
|
+
slots: {
|
|
224
|
+
// 使用插槽模板渲染
|
|
225
|
+
default: 'codemirror',
|
|
226
|
+
},
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
}, {
|
|
230
|
+
title: '操作',
|
|
231
|
+
field: 'operation',
|
|
232
|
+
width: 80,
|
|
233
|
+
slots: {
|
|
234
|
+
// 使用插槽模板渲染
|
|
235
|
+
default: 'operation',
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
});
|
|
240
|
+
const checkbox = (params) => {
|
|
241
|
+
console.log(params)
|
|
242
|
+
}
|
|
243
|
+
const onAdd = () => {
|
|
244
|
+
let newBtn = {
|
|
245
|
+
name: '',
|
|
246
|
+
code: '',
|
|
247
|
+
defaultShow: '1',
|
|
248
|
+
deleted: 0,
|
|
249
|
+
isForm: 0,
|
|
250
|
+
seq: getDataSource().length + 1,
|
|
251
|
+
sort: getDataSource().length + 1
|
|
252
|
+
}
|
|
253
|
+
if (props.alignMode) {
|
|
254
|
+
newBtn.alignMode = props.alignMode;
|
|
255
|
+
}
|
|
256
|
+
configData.form[props.type].push(newBtn)
|
|
257
|
+
loadData();
|
|
258
|
+
setTimeout(() => {
|
|
259
|
+
tableRef.value.setEditRow(tableRef.value.getData(newBtn.sort), 'name')
|
|
260
|
+
}, 500)
|
|
261
|
+
}
|
|
262
|
+
const removeBtn = (row, rowIndex) => {
|
|
263
|
+
configData.form[props.type].splice(rowIndex, 1)
|
|
264
|
+
let index = 0;
|
|
265
|
+
for (var obj of configData.form[props.type.replaceAll("Options", "")]) {
|
|
266
|
+
if (obj == row.code) {
|
|
267
|
+
configData.form[props.type.replaceAll("Options", "")].splice(index, 1)
|
|
268
|
+
return
|
|
269
|
+
}
|
|
270
|
+
index++;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const editClosedEvent = ({row, column}) => {
|
|
274
|
+
const $table = tableRef.value
|
|
275
|
+
if ($table) {
|
|
276
|
+
const field = column.field
|
|
277
|
+
const cellValue = row[field]
|
|
278
|
+
// 判断单元格值是否被修改
|
|
279
|
+
if ($table.isUpdateByRow(row, field)) {
|
|
280
|
+
setTimeout(() => {
|
|
281
|
+
VXETable.modal.message({
|
|
282
|
+
content: `局部保存成功! ${field}=${cellValue}`,
|
|
283
|
+
status: 'success'
|
|
284
|
+
})
|
|
285
|
+
// 局部更新单元格为已保存状态
|
|
286
|
+
$table.reloadRow(row, null, field)
|
|
287
|
+
}, 300)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
updateBtnData(configData.form[props.type], props.type)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function getDataSource() {
|
|
294
|
+
if (props.alignMode) {
|
|
295
|
+
return configData.form[props.type].filter(o => o.alignMode == props.alignMode)
|
|
296
|
+
}
|
|
297
|
+
return configData.form[props.type];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function loadData() {
|
|
301
|
+
tableRef.value.reloadData(getDataSource())
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function updateSort(oldIndex, newIndex) {
|
|
305
|
+
let newsArr = getNewArrData(oldIndex, newIndex, getDataSource())
|
|
306
|
+
let index = 0;
|
|
307
|
+
for (const obj of newsArr) {
|
|
308
|
+
obj.sort = ++index;
|
|
309
|
+
}
|
|
310
|
+
show.value = false;
|
|
311
|
+
let reverseArr = configData.form[props.type].filter(o => o.alignMode != props.alignMode)
|
|
312
|
+
for (let reverseArrElement of reverseArr) {
|
|
313
|
+
newsArr.push(reverseArrElement)
|
|
314
|
+
}
|
|
315
|
+
configData.form[props.type] = newsArr
|
|
316
|
+
nextTick(() => {
|
|
317
|
+
show.value = true;
|
|
318
|
+
nextTick(() => {
|
|
319
|
+
updateSortCall(tableRef, updateSort)
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
onMounted(() => {
|
|
325
|
+
nextTick(() => {
|
|
326
|
+
updateSortCall(tableRef, updateSort)
|
|
327
|
+
})
|
|
328
|
+
})
|
|
329
|
+
defineExpose({
|
|
330
|
+
loadData
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
</script>
|
|
334
|
+
|
|
335
|
+
<style lang="scss">
|
|
336
|
+
.newBtn {
|
|
337
|
+
background: #f2f8fe
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
</style>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="height: 55vh">
|
|
3
|
+
<vxe-grid
|
|
4
|
+
:key="key"
|
|
5
|
+
v-if="tableShow"
|
|
6
|
+
v-bind="option"
|
|
7
|
+
ref="sortTableRef"
|
|
8
|
+
row-class-name="default-row"
|
|
9
|
+
:data="list">
|
|
10
|
+
<template #sort-slot>
|
|
11
|
+
<div style="display: flex;justify-content: center;align-items: center">
|
|
12
|
+
<el-icon>
|
|
13
|
+
<SemiSelect/>
|
|
14
|
+
</el-icon>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
</vxe-grid>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
<script setup>
|
|
21
|
+
import {SemiSelect} from '@element-plus/icons-vue'
|
|
22
|
+
import Sortable from "sortablejs";
|
|
23
|
+
import {defineExpose,defineProps, nextTick, onMounted, reactive, ref} from "vue";
|
|
24
|
+
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
list: {
|
|
27
|
+
type: Array,
|
|
28
|
+
default: () => {
|
|
29
|
+
return []
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
const list = reactive(JSON.parse(JSON.stringify(props.list)));
|
|
34
|
+
const sortTableRef = ref();
|
|
35
|
+
const sorter = ref()
|
|
36
|
+
const tableShow = ref(true)
|
|
37
|
+
const key = ref(0)
|
|
38
|
+
|
|
39
|
+
const option = reactive({
|
|
40
|
+
height: 'auto',
|
|
41
|
+
columns: [
|
|
42
|
+
{
|
|
43
|
+
width: 100,
|
|
44
|
+
title: '',
|
|
45
|
+
slots: {
|
|
46
|
+
default: 'sort-slot'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: '序号',
|
|
51
|
+
width: 100,
|
|
52
|
+
field: 'form.sortSeq',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: '名称',
|
|
56
|
+
field: 'form.name',
|
|
57
|
+
search: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: '编码',
|
|
61
|
+
field: 'form.code',
|
|
62
|
+
search: true,
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const startSort = () => {
|
|
69
|
+
let el = sortTableRef.value.$el.querySelector(".vxe-table--body-wrapper tbody")
|
|
70
|
+
sorter.value = Sortable.create(el, {
|
|
71
|
+
animation: 150,
|
|
72
|
+
sort: true,
|
|
73
|
+
handle: '.vxe-body--row',
|
|
74
|
+
// 结束拖拽
|
|
75
|
+
onEnd: function ({oldIndex, newIndex}) {
|
|
76
|
+
console.log(list)
|
|
77
|
+
if (oldIndex == newIndex) return;
|
|
78
|
+
let dire = newIndex > oldIndex ? 1 : -1; // 1: 向下, -1: 向上
|
|
79
|
+
list[oldIndex].form.sortSeq = list[newIndex].form.sortSeq
|
|
80
|
+
// 从拖拽位置开始
|
|
81
|
+
let cur = oldIndex
|
|
82
|
+
while (cur != newIndex) {
|
|
83
|
+
cur += dire
|
|
84
|
+
list[cur].form.sortSeq -= dire // 向反方向挪动一个单位
|
|
85
|
+
}
|
|
86
|
+
//调整数据顺序,防止数据混乱
|
|
87
|
+
cur = oldIndex
|
|
88
|
+
while (cur != newIndex) {
|
|
89
|
+
let temp = list[cur];
|
|
90
|
+
list[cur] = list[cur + dire];
|
|
91
|
+
list[cur + dire] = temp;
|
|
92
|
+
cur += dire
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
const setList = (data) => {
|
|
99
|
+
key.value++
|
|
100
|
+
nextTick(() => {
|
|
101
|
+
list.length = 0
|
|
102
|
+
for (let item of data) {
|
|
103
|
+
item.form.sortSeq = item.form.seq
|
|
104
|
+
list.push(item)
|
|
105
|
+
}
|
|
106
|
+
sortTableRef.value.reloadData(list)
|
|
107
|
+
startSort()
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onMounted(() => {
|
|
112
|
+
startSort()
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
defineExpose({
|
|
116
|
+
list,
|
|
117
|
+
setList,
|
|
118
|
+
tableShow
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<style>
|
|
124
|
+
.default-row {
|
|
125
|
+
cursor: move;
|
|
126
|
+
user-select: none;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.default-row:hover {
|
|
130
|
+
background-color: rgba(192, 192, 192, .1);
|
|
131
|
+
}
|
|
132
|
+
</style>
|