doway-coms 1.6.71 → 1.6.73

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.
@@ -0,0 +1,262 @@
1
+ <template>
2
+ <div class="content-card">
3
+ <!-- 查询框 -->
4
+ <div style="margin: 10px 10px 10px 0px">
5
+ <a-input
6
+ ref="searchInput"
7
+ v-model="searchField"
8
+ placeholder="搜索添加更多字段"
9
+ ><a-icon slot="prefix" type="search" />
10
+ </a-input>
11
+ </div>
12
+ <div :style="{ height: height-160+'px', overflow:'auto' }" class="field-content">
13
+ <div class="field-card">
14
+ <div class="card-tltle">显示字段</div>
15
+ <div ref="dragForm">
16
+ <div
17
+ :class="{ 'not-sort': searchField }"
18
+ v-for="item in columns.filter(x=> x.visible && showField(x.title))"
19
+ :key="item.currentKey"
20
+ :data-id="item.currentKey"
21
+ class="drag-row show-sort"
22
+ >
23
+ <div style="margin-right: 7px;">
24
+ <img src="../../styles/icon/drag.svg" alt="" style="width: 20px" >
25
+ </div>
26
+ <div>{{ item.title }}</div>
27
+ <div style="margin-left: auto;"><a-switch v-model="item.visible" @change="onCheckboxChange(item)" size="small"/></div>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ <div class="field-card">
32
+ <div class="card-tltle">未显示字段</div>
33
+ <div ref="notShownField">
34
+ <div
35
+ v-for="(item, index) in columns.filter(x=> !x.visible)"
36
+ :key="index"
37
+ :data-id="index"
38
+ class="drag-row"
39
+ >
40
+ <div>{{ item.title }}</div>
41
+ <div style="margin-left: auto;"><a-switch v-model="item.visible" @change="onCheckboxChange(item)" size="small"/></div>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ </div>
47
+ </template>
48
+ <script>
49
+ import {
50
+ Row,
51
+ Col,
52
+ Input,
53
+ Checkbox,
54
+ Button,
55
+ Icon,
56
+ Switch,
57
+ } from "ant-design-vue";
58
+ import Sortable from 'sortablejs'
59
+ import { saveUserModuleDataFieldApi } from "../../utils/api";
60
+ export default {
61
+ components: {
62
+ "a-icon": Icon,
63
+ "a-row": Row,
64
+ "a-col": Col,
65
+ "a-input": Input,
66
+ "a-checkbox": Checkbox,
67
+ "a-button": Button,
68
+ "a-switch": Switch,
69
+ },
70
+ props: {
71
+ userDefineColumns: {
72
+ type: Array,
73
+ default: function () {
74
+ return [];
75
+ },
76
+ },
77
+ height: {
78
+ type: Number,
79
+ default: function () {
80
+ return 0;
81
+ },
82
+ },
83
+ moduleCode: {
84
+ type: String,
85
+ default: function () {
86
+ return '';
87
+ },
88
+ },
89
+ dataCode: {
90
+ type: String,
91
+ default: function () {
92
+ return '';
93
+ },
94
+ },
95
+ },
96
+ data() {
97
+ return {
98
+ searchField: null,
99
+ // 接收所有字段数据
100
+ adjustUserDefineColumns: [],
101
+ // 可显示字段数据
102
+ columns:[],
103
+ // 改变后顺序记录数组
104
+ currentSortKeys: [],
105
+ // 拖拽表单配置
106
+ options: {}
107
+ }
108
+ },
109
+ created() {
110
+ this.adjustUserDefineColumns = this.userDefineColumns;
111
+ // 设置唯一标识,用于保存时找到字段并重新排序
112
+ this.adjustUserDefineColumns.forEach((x, index)=> x.currentKey = index + x.field)
113
+ this.columns = [];
114
+ this.adjustUserDefineColumns.forEach((item) => {
115
+ // 去除操作列和序号、多选框列
116
+ if (item.field === "operation" || item.field == undefined) {
117
+ return;
118
+ }
119
+ const column = {
120
+ currentKey: item.currentKey,
121
+ field: item.field,
122
+ title: item.title,
123
+ visible: item.visible,
124
+ width: item.width,
125
+ filters: item.filters,
126
+ order: item.order,
127
+ }
128
+ this.columns.push(column);
129
+ })
130
+ },
131
+ mounted() {
132
+ // 初始排序数组
133
+ this.currentSortKeys = this.columns.map(x=>x.currentKey)
134
+ this.setOptions()
135
+ },
136
+ methods: {
137
+ // 配置方法
138
+ setOptions() {
139
+ var vm = this
140
+ //获取对象
141
+ var el = vm.$refs.dragForm
142
+ //设置配置
143
+ vm.options = {
144
+ group:'sortableDrag',
145
+ animation: 200,
146
+ sort: true,
147
+ filter: ".not-sort", // not-sort用来控制筛选时不可拖拽
148
+ forceFallback: true, // 禁用html5原生拖拽行为,使得可以同时使用拖拽及鼠标滚轴
149
+ //拖动结束
150
+ onEnd: function (evt) {
151
+ //获取拖动后的排序
152
+ vm.currentSortKeys = sortable.toArray()
153
+ // 调取保存
154
+ vm.saveSortable()
155
+ },
156
+ };
157
+ //初始化
158
+ var sortable = Sortable.create(el, vm.options);
159
+ },
160
+ onCheckboxChange() {
161
+ let vm = this
162
+ // 在渲染切换后获取渲染后div内容,进行赋值
163
+ this.$nextTick(()=>{
164
+ let sortableElement = vm.$refs.dragForm
165
+ let sortKeys = []
166
+ for (let i = 0; i < sortableElement.children.length; i++) {
167
+ sortKeys.push(sortableElement.children[i].dataset.id)
168
+ }
169
+ vm.currentSortKeys = sortKeys
170
+ this.saveSortable()
171
+ })
172
+ // 保存之前将显示字段数组删除当前的
173
+ },
174
+ // 保存拖拽后排序
175
+ saveSortable() {
176
+ let vm = this
177
+ let postData = {
178
+ moduleCode: vm.moduleCode,
179
+ dataCode: vm.dataCode,
180
+ fields: [],
181
+ }
182
+ let currentDrag = JSON.parse(JSON.stringify(vm.currentSortKeys))
183
+ // 将不显示数组最后放入
184
+ let notShowColumns = vm.columns.filter(x=>!x.visible).map(i=>i.currentKey)
185
+ currentDrag.push(...notShowColumns)
186
+ // 循环按照当前顺序赋值序号
187
+ currentDrag.forEach((item, index) => {
188
+ let tempObject = vm.columns.find(x => x.currentKey == item)
189
+ let tempData = {
190
+ field: tempObject.field,
191
+ sort: index + 1,
192
+ hidden: !tempObject.visible,
193
+ width: tempObject.width,
194
+ extraInfo:{}
195
+ }
196
+ if (tempObject.filters && tempObject.filters[0].data.bindingValues.length) {
197
+ tempObject.filters[0].checked = true;
198
+ tempData.extraInfo.filterExpression = tempObject.filters
199
+ }
200
+ if (tempObject.order) {
201
+ tempData.extraInfo.order = tempObject.order
202
+ }
203
+ postData.fields.push(tempData)
204
+ })
205
+ saveUserModuleDataFieldApi(postData)
206
+ .then(res => {
207
+ // 返回表格组件触发更新
208
+ vm.$emit('saveSeqConfig',postData, res.content)
209
+ })
210
+ .catch((err) => {
211
+ console.debug(err)
212
+ })
213
+ .finally(() => {})
214
+ },
215
+ showField(title) {
216
+ let isShow = true
217
+ if (this.searchField && (title.indexOf(this.searchField) == -1)) {
218
+ isShow = false
219
+ }
220
+ return isShow
221
+ }
222
+ },
223
+ }
224
+ </script>
225
+ <style scoped lang="scss">
226
+ .content-card {
227
+ font-weight: 600;
228
+ min-width: 240px;
229
+ }
230
+ .show-sort:hover {
231
+ background-color: #f7f7f7;
232
+ }
233
+ .drag-row {
234
+ padding-right: 5px;
235
+ font-size: 15px;
236
+ height: 36px;
237
+ display: flex;
238
+ align-items: center;
239
+ }
240
+ /* 修改滚动条整体样式 */
241
+ .field-content::-webkit-scrollbar {
242
+ width: 7px; /* 设置滚动条宽度 */
243
+ }
244
+ /* 修改滚动条轨道样式 */
245
+ .field-content::-webkit-scrollbar-track {
246
+ background-color: #f1f1f1; /* 设置轨道背景色 */
247
+ }
248
+ /* 修改滚动条滑块样式 */
249
+ .field-content::-webkit-scrollbar-thumb {
250
+ background-color: #888; /* 设置滑块背景色 */
251
+ }
252
+ /* 修改滚动条滑块在hover状态下的样式 */
253
+ .field-content::-webkit-scrollbar-thumb:hover {
254
+ background-color: #555; /* 设置滑块hover时背景色 */
255
+ }
256
+ .field-card {
257
+ margin: 10px 10px 0px 0px;
258
+ .card-tltle {
259
+ margin-bottom: 10px;
260
+ }
261
+ }
262
+ </style>