imatrix-ui 0.2.3-up → 0.2.5-up

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,1164 +1,1188 @@
1
- <template>
2
- <div>
3
- <search-form
4
- v-if="hasLoadedColumns"
5
- v-show="showSearch"
6
- ref="sf"
7
- :columns="columns"
8
- :code="code"
9
- :url="url"
10
- :pagination="pagination"
11
- :query="query"
12
- :search-param="searchFormContent"
13
- :init-search-props="initSearchProps"
14
- :grid-id="gridId"
15
- @search="search"
16
- @reset="resetSearch"
17
- />
18
- <div class="nine-grid-area">
19
- <div
20
- :id="gridId"
21
- :style="'height:' + height + 'px;overflow-y: auto;overflow-x: hidden;'"
22
- >
23
- <el-row :gutter="24">
24
- <el-col
25
- v-if="isHasCreate"
26
- id="_addCardId_"
27
- v-permission="createPermission"
28
- :span="colSpan"
29
- >
30
- <el-card
31
- :body-style="{ padding: '0px' }"
32
- style="
33
- border-radius: 4px;
34
- background: #ffffff;
35
- border: 1px solid #e5e8ef;
36
- "
37
- >
38
- <div class="add-screen" @click="add">
39
- <em class="el-icon-plus" />
40
- <span style="margin-top: 7px">
41
- {{ $t('superNineGrid.add') }}</span
42
- >
43
- </div>
44
- </el-card>
45
- </el-col>
46
- <el-col
47
- v-for="(params, index) in gridData"
48
- :key="params.id"
49
- :span="colSpan"
50
- >
51
- <el-card
52
- :body-style="{ padding: '0px' }"
53
- :style="{
54
- border:
55
- selectionIds.indexOf(params.id) > -1
56
- ? '1px solid #005EBA'
57
- : '',
58
- }"
59
- shadow="hover"
60
- >
61
- <div
62
- style="height: 160px"
63
- @mouseenter="enter(index)"
64
- @mouseleave="leave()"
65
- @click="clickContent(params)"
66
- >
67
- <!-- <transition name="fade">
68
- <div v-if="seen && index === current" class="popContainer">
69
- <div class="else-button">
70
- <template v-for="button in operations">
71
- <template v-if="isShowButton(params, button)">
72
- <el-tooltip v-if="button.icon" :key="button.name" v-permission="button.permission?button.permission:'true'" class="item" effect="dark" :content="button.name" placement="top">
73
- <em :class="button.icon +' icons'" @click.stop="buttonClick(button.event, params)" />
74
- </el-tooltip>
75
- <em v-else :key="button.name" v-permission="button.permission?button.permission:'true'" :class="button.name +' icons'" @click.stop="buttonClick(button.event, params)">{{ button.name }} </em>
76
- </template>
77
- </template>
78
- </div>
79
- </div>
80
- </transition> -->
81
- <!-- <img v-if="props && props.imageUrl && objectPropValue(params, propCloumns.imageUrl, props.imageUrl)" :src="defaultShowImageAction+objectPropValue(params, propCloumns.imageUrl, props.imageUrl)" alt="加载失败" class="image"> -->
82
- <!-- <img v-if="true || (props && props.imageUrl)" :src="defaultShowImageAction+'fa7ae05e-0f0e-4cc0-b24a-69aea4408233'" alt="加载失败" class="image"> -->
83
- <!-- <div v-else class="image" style="padding: 20px; text-align: center;"> -->
84
- <div
85
- class="image"
86
- style="padding: 15px; box-sizing: border-box"
87
- >
88
- <div>
89
- <el-tooltip
90
- effect="dark"
91
- :content="'系统编码:' + params.code"
92
- placement="top-start"
93
- >
94
- <div
95
- v-if="props && props.content"
96
- style="display: inline-block"
97
- >
98
- {{
99
- getPropValue('content', params) +
100
- getLength(params.code)
101
- }}
102
- </div>
103
- <div
104
- v-else-if="props && props.title"
105
- style="display: inline-block"
106
- >
107
- {{
108
- getPropValue('title', params) + getLength(params.code)
109
- }}
110
- </div>
111
- </el-tooltip>
112
- <div
113
- v-if="showEnableButton(params)"
114
- style="
115
- margin-left: 2px;
116
- color: #00b42a;
117
- background-color: #e8ffea;
118
- width: 68px;
119
- text-align: center;
120
- display: inline-block;
121
- "
122
- >
123
- <em class="el-icon-success" />
124
- <span
125
- :title="getPropValue('subTitle', params)"
126
- style="margin-left: 4px"
127
- >{{ getPropValue('subTitle', params) }}</span
128
- >
129
- </div>
130
- </div>
131
- <div class="button-style">
132
- 操作
133
- <template v-for="button in operations">
134
- <template v-if="isShowButton(params, button)">
135
- <el-tooltip
136
- v-if="button.icon"
137
- v-permission="
138
- button.permission ? button.permission : 'true'
139
- "
140
- :content="button.name"
141
- class="item"
142
- effect="dark"
143
- placement="top"
144
- >
145
- <em
146
- :class="button.icon + ' icons'"
147
- @click.stop="buttonClick(button.event, params)"
148
- />
149
- </el-tooltip>
150
- <em
151
- v-else
152
- v-permission="
153
- button.permission ? button.permission : 'true'
154
- "
155
- :class="button.name + ' icons'"
156
- @click.stop="buttonClick(button.event, params)"
157
- >{{ button.name }}
158
- </em>
159
- </template>
160
- </template>
161
- </div>
162
- <div
163
- v-if="isShowEnableState"
164
- style="float: right; margin-top: 28px"
165
- >
166
- <el-button
167
- v-if="showEnableButton(params)"
168
- size="mini"
169
- @click.stop="changeState(params)"
170
- >
171
- 禁用
172
- </el-button>
173
- <el-button
174
- v-else
175
- size="mini"
176
- type="primary"
177
- @click.stop="changeState(params)"
178
- >
179
- 启用
180
- </el-button>
181
- </div>
182
- </div>
183
- </div>
184
- <!-- <el-divider />
185
- <div style="padding: 10px 10px 10px 10px;">
186
- <div class="bottom clearfix">
187
- <time class="name">
188
- <span v-if="props && props.title">
189
- <el-checkbox v-if="multiple" :value="selectionModels['select'+params.id]" :true-label="params.id" :false-label="'false-'+params.id" :title="getPropValue('title', params)" style="width: 100%" @change="changeChecked($event, index)">
190
- {{ getPropValue('title', params) }}
191
- <span :style="getTitleStyle(params)"> {{ getPropValue('title', params) }}</span>
192
- </el-checkbox>
193
- <el-radio v-else-if="isShowRadio" v-model="currentId" :label="params.id" :title="getPropValue('title', params)" style="width: 100%" @change="changeSelectWhenRadio($event, index)">
194
- {{ getPropValue('title', params) }}
195
- <span :style="getTitleStyle(params)"> {{ getPropValue('title', params) }}</span>
196
- </el-radio>
197
- <span v-else :style="getTitleStyle(params)" :title="getPropValue('title', params)"> {{ getPropValue('title', params) }}</span>
198
- </span>
199
- <span v-else-if="props && props.content">
200
- <el-checkbox v-if="multiple" :value="selectionModels['select'+params.id]" :true-label="params.id" :false-label="'false-'+params.id" :title="getPropValue('content', params)" style="width: 100%" @change="changeChecked($event, index)">{{ getPropValue('content', params) }}</el-checkbox>
201
- <el-radio v-else-if="isShowRadio" v-model="currentId" :label="params.id" :title="getPropValue('content', params)" style="width: 100%" @change="changeSelectWhenRadio($event, index)">{{ getPropValue('content', params) }}</el-radio>
202
- <span v-else :title="getPropValue('content', params)" style="width: 100%"> {{ getPropValue('content', params) }}</span>
203
- </span>
204
- <span v-else>
205
- <el-checkbox v-if="multiple" :value="selectionModels['select'+params.id]" :true-label="params.id" :false-label="'false-'+params.id" @change="changeChecked($event, index)">{{ index + 1 }}</el-checkbox>
206
- <el-radio v-else-if="isShowRadio" v-model="currentId" :label="params.id" @change="changeSelectWhenRadio($event, index)">{{ index + 1 }}</el-radio>
207
- <span v-else> {{ index + 1 }}</span>
208
- </span>
209
- </time>
210
- <time v-if="props && props.subTitle" class="state">
211
- <span :title="getPropValue('subTitle', params)" style="width: 100%">{{ getPropValue('subTitle', params) }}</span>
212
- </time>
213
- </div>
214
- </div> -->
215
- </el-card>
216
- </el-col>
217
- </el-row>
218
- </div>
219
- <el-pagination
220
- v-if="pagination"
221
- v-model:current-page="currentPage"
222
- :page-sizes="pagination.pageSizes"
223
- :page-size="pagination.pageSize"
224
- :layout="pagination.layout"
225
- :total="pagination.total"
226
- @size-change="handleSizeChange"
227
- @current-change="handleCurrentChange"
228
- />
229
- </div>
230
- </div>
231
- </template>
232
-
233
- <script>
234
- import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
235
- import customFormatter from './custom-formatter'
236
- import SearchForm from './search-form.vue'
237
- import { getGridParams, getTableHeight, isHasOptionFunction } from './utils'
238
- import store from './store'
239
- import superGridService from './super-grid-service'
240
- import apis from './apis'
241
- import Sortable from 'sortablejs'
242
- import { addDynamicProp } from './utils'
243
- import * as Vue from 'vue'
244
- export default {
245
- name: 'SuperNineGrid',
246
- components: {
247
- SearchForm,
248
- },
249
- props: {
250
- code: {
251
- type: String,
252
- default: '',
253
- },
254
- url: {
255
- type: String,
256
- default: '',
257
- },
258
- options: {
259
- type: Object,
260
- default: function () {
261
- return {}
262
- },
263
- },
264
- },
265
- data() {
266
- let mergeFields = []
267
- if (
268
- this.options &&
269
- this.options.mergeFields &&
270
- this.options.mergeFields !== ''
271
- ) {
272
- mergeFields = this.options.mergeFields.split(',')
273
- }
274
- const defaultShowImageAction =
275
- window.$vueApp.config.globalProperties.baseAPI +
276
- '/component/super-form/show-image?serverPath='
277
- const gridId =
278
- this.options && this.options.id ? this.options.id : '_nineGrid'
279
- const storeId = this.code + '~' + gridId
280
- const isShowRadio =
281
- this.options && this.options.showRadio !== undefined
282
- ? this.options.showRadio
283
- : false
284
- return {
285
- isLoading: false,
286
- currentPage: 1,
287
- showColumnConfig: false,
288
- basicInfo: {
289
- summary: 'no',
290
- },
291
- columns: [],
292
- pagination: null,
293
- query: null,
294
- lineEdit: null,
295
- gridData: [],
296
- sortInfo: null,
297
- pageSize: null,
298
- showSearch: false,
299
- height: null,
300
- isSql: false, // 是否是sql查询
301
- hasLoadData: false,
302
- mergeFields,
303
- hasLoadedColumns: false, // 是否已经加载了列配置
304
- seen: false,
305
- current: null,
306
- isHasCreate: true, // 是否需要新建按钮
307
- screenBaseUrl: null,
308
- props: null, // 属性配置
309
- operations: [], // 指向格子时出现的操作按钮集合
310
- propCloumns: null, // 属性字段配置详细信息
311
- multiple: false, // 是否需要多选
312
- createPermission: 'true', // 新建权限编码,默认是有权限的
313
- urlToSaveOrder: null, // 拖动格子后台保存接口路径
314
- selections: [], // 选中的记录集合
315
- selectionIds: [], // 选中的记录id集合
316
- selectionModels: {}, // 选中的记录对象
317
- searchFormContent: null,
318
- initSearchProps: [], // 初始查询的字段属性名集合
319
- defaultShowImageAction, // 显示图片的路径
320
- gridId,
321
- storeId,
322
- currentId: null, // 当前点击的记录id
323
- isShowRadio, // 单选时是否显示单选按钮
324
- titleStyle: null, // 标题的样式对象,格式为:{ color: 'green', fontWeight: 'bold'}
325
- isShowEnableState: false,
326
- colSpan: 6,
327
- }
328
- },
329
- computed: {},
330
- provide() {
331
- return {}
332
- },
333
- created() {
334
- store.set(this.code + '~' + this.gridId, getGridParams())
335
- store.set('_nine_list_code', this.code + '~' + this.gridId)
336
- this.initSetting()
337
- this.initialize()
338
- // this.showDemo()
339
- },
340
- mounted() {
341
- this.$watch(
342
- 'showSearch',
343
- function (newVal, oldVal) {
344
- this.$nextTick(() => {
345
- let tableHeight = getTableHeight(newVal, this.$refs.sf)
346
- const newHeight = this.resizeHeight()
347
- if (newHeight) {
348
- tableHeight = newHeight
349
- }
350
- this.height = tableHeight
351
- })
352
- },
353
- {
354
- immediate: true,
355
- deep: true,
356
- }
357
- )
358
-
359
- this.$watch(
360
- 'hasLoadData',
361
- function (newVal, oldVal) {
362
- if (newVal === true) {
363
- this.$nextTick(() => {
364
- this.rowDrop()
365
- const gridParams = store.get(this.storeId)
366
- if (isHasOptionFunction('gridComplete', this.storeId)) {
367
- gridParams.options.gridComplete.call(this, {
368
- gridData: this.gridData,
369
- columns: gridParams.columns,
370
- superGrid: this.$refs.superGrid,
371
- })
372
- }
373
- const newHeight = this.resizeHeight()
374
- if (newHeight) {
375
- this.height = newHeight
376
- }
377
- })
378
- }
379
- },
380
- {
381
- immediate: true,
382
- deep: true,
383
- }
384
- )
385
- },
386
- methods: {
387
- ...superGridService,
388
- ...apis,
389
- ...customFormatter,
390
- getTitleStyle(entity) {
391
- // 九宫格的标题自定义样式
392
- if (this.options && this.options.titleStyle) {
393
- return this.options.titleStyle.call(this, entity)
394
- }
395
- return { width: '100%' }
396
- },
397
- // 获得属性值
398
- getPropValue(type, entity) {
399
- let value = ''
400
- const gridParams = store.get(this.storeId)
401
- if (type === 'content') {
402
- let content = ''
403
- if (isHasOptionFunction('setContent', this.storeId)) {
404
- content = gridParams.options.getContent.call(this, entity)
405
- }
406
- if (content === undefined || content === '') {
407
- if (this.props && this.props.content) {
408
- content = this.objectPropValue(
409
- entity,
410
- this.propCloumns.content,
411
- this.props.content
412
- )
413
- } else if (this.props && this.props.title) {
414
- content = this.objectPropValue(
415
- entity,
416
- this.propCloumns.title,
417
- this.props.title
418
- )
419
- }
420
- }
421
- value = content
422
- } else if (type === 'title') {
423
- let content = ''
424
- if (isHasOptionFunction('setTitle', this.storeId)) {
425
- content = gridParams.options.setTitle.call(this, entity)
426
- }
427
- if (content === undefined || content === '') {
428
- if (this.props && this.props.title) {
429
- content = this.objectPropValue(
430
- entity,
431
- this.propCloumns.title,
432
- this.props.title
433
- )
434
- } else if (this.props && this.props.content) {
435
- content = this.objectPropValue(
436
- entity,
437
- this.propCloumns.content,
438
- this.props.content
439
- )
440
- }
441
- }
442
- value = content
443
- } else if (type === 'subTitle') {
444
- let content = ''
445
- if (isHasOptionFunction('setSubTitle', this.storeId)) {
446
- content = gridParams.options.setSubTitle.call(this, entity)
447
- }
448
- if (content === undefined || content === '') {
449
- if (this.props && this.props.subTitle) {
450
- content = this.objectPropValue(
451
- entity,
452
- this.propCloumns.subTitle,
453
- this.props.subTitle
454
- )
455
- }
456
- }
457
- value = content
458
- }
459
- if (value === undefined) {
460
- value = ''
461
- }
462
- return value
463
- },
464
- resizeHeight() {
465
- const gridParams = store.get(this.storeId)
466
- if (isHasOptionFunction('resizeHeight', this.storeId)) {
467
- let searchHeight = 0
468
- if (this.showSearch === true) {
469
- if (this.$refs.sf) {
470
- // 获得查询区高度
471
- searchHeight = this.$refs.sf.$el.offsetHeight
472
- }
473
- }
474
- return gridParams.options.resizeHeight.call(this, {
475
- code: this.code,
476
- height: this.height,
477
- searchHeight: searchHeight,
478
- })
479
- }
480
- },
481
- enter(index) {
482
- this.seen = true
483
- this.current = index
484
- },
485
- leave() {
486
- this.seen = false
487
- this.current = null
488
- },
489
- initSetting() {
490
- const gridParams = store.get(this.storeId)
491
- if (typeof this.options !== 'undefined') {
492
- Object.assign(gridParams.options, this.options)
493
- } else {
494
- gridParams.options = {}
495
- }
496
- if (this.options && typeof this.options.isHasCreate !== 'undefined') {
497
- this.isHasCreate = this.options.isHasCreate
498
- }
499
- if (this.options && typeof this.options.props !== 'undefined') {
500
- this.props = this.options.props
501
- }
502
- if (this.options && typeof this.options.operations !== 'undefined') {
503
- this.operations = this.options.operations
504
- }
505
- if (
506
- this.options &&
507
- typeof this.options.createPermission !== 'undefined'
508
- ) {
509
- this.createPermission = this.options.createPermission
510
- }
511
- if (this.options && typeof this.options.multiple !== 'undefined') {
512
- this.multiple = this.options.multiple
513
- }
514
- if (
515
- this.options &&
516
- typeof this.options.isShowEnableState !== 'undefined'
517
- ) {
518
- this.isShowEnableState = this.options.isShowEnableState
519
- }
520
- if (this.options && typeof this.options.colSpan !== 'undefined') {
521
- this.colSpan = this.options.colSpan
522
- }
523
- },
524
- // 获得各属性对应的字段配置
525
- getPropColumns() {
526
- if (this.columns && this.columns.length > 0) {
527
- // imageUrl:{column}, content: {column}, title: {}, subTitle:{}
528
- this.propCloumns = {}
529
- this.columns.forEach((column) => {
530
- if (this.props.imageUrl && this.props.imageUrl === column.prop) {
531
- this.propCloumns.imageUrl = column
532
- }
533
- if (this.props.content && this.props.content === column.prop) {
534
- this.propCloumns.content = column
535
- }
536
- if (this.props.title && this.props.title === column.prop) {
537
- this.propCloumns.title = column
538
- }
539
- if (this.props.subTitle && this.props.subTitle === column.prop) {
540
- this.propCloumns.subTitle = column
541
- }
542
- })
543
- }
544
- },
545
- fetchData(searchParam, isSearch) {
546
- return new Promise((resolve, reject) => {
547
- // 获得各属性对应的字段配置
548
- this.getPropColumns()
549
- this.isLoading = true
550
- this.hasLoadData = false
551
- if (isSearch === undefined || isSearch === false) {
552
- // 如果不是查询时才需要从缓存中获得结果
553
- // 如果是刷新当前列表,则需要获得缓存中的window.sessionStorage
554
- const isRefreshList = window.sessionStorage.getItem(
555
- 'refreshList-' + this.storeId
556
- )
557
- // console.log('fetchData--isRefreshList--', isRefreshList)
558
- if (isRefreshList !== undefined && isRefreshList === 'true') {
559
- const searchParamJson = window.sessionStorage.getItem(
560
- 'searchParam-' + this.storeId
561
- )
562
- // console.log('fetchData--searchParamJson--', searchParamJson)
563
- // console.log('fetchData--pagination--', this.pagination)
564
- if (
565
- searchParamJson !== undefined &&
566
- searchParamJson !== null &&
567
- searchParamJson !== ''
568
- ) {
569
- searchParam = JSON.parse(searchParamJson)
570
- const pagination = searchParam.pagination
571
- if (pagination) {
572
- this.currentPage = pagination.currentPage
573
- this.pagination.pageSize = pagination.pageSize
574
- this.pagination.showTotal = pagination.showTotal
575
- }
576
- this.getInitSearchForm(searchParam.searchForm)
577
- // this.searchFormContent = searchParam.searchForm
578
- }
579
- }
580
- }
581
- window.sessionStorage.removeItem('refreshList-' + this.storeId)
582
- if (searchParam === undefined) {
583
- searchParam = this.getSearchParam()
584
- }
585
- const gridParams = store.get(this.storeId)
586
- let param = searchParam
587
- if (gridParams.options.extraParam) {
588
- param = {
589
- searchParam: searchParam,
590
- }
591
- if (gridParams.options.extraParam) {
592
- for (const paramName in gridParams.options.extraParam) {
593
- param[paramName] = gridParams.options.extraParam[paramName]
594
- }
595
- }
596
- }
597
- // 导出需要这两个参数
598
- gridParams.searchParam = searchParam
599
- gridParams.url = this.url
600
- const requestUrl = this.url
601
- // 缓存查询条件及当前页数
602
- window.sessionStorage.setItem(
603
- 'searchParam-' + this.storeId,
604
- JSON.stringify(param)
605
- )
606
- this.$http
607
- .post(requestUrl, param)
608
- .then((data) => {
609
- // 对数据做序列化,比如:处理xss攻击
610
- if (isHasOptionFunction('gridDataLoaded', this.storeId)) {
611
- const gridData = gridParams.options.gridDataLoaded.call(this, {
612
- gridData: data.data,
613
- columns: gridParams.columns,
614
- })
615
- if (gridData) {
616
- this.gridData = gridData
617
- } else {
618
- this.gridData = data.data
619
- }
620
- } else {
621
- this.gridData = data.data
622
- }
623
- if (!this.gridData) {
624
- this.gridData = []
625
- }
626
-
627
- if (this.pagination !== null) {
628
- this.pagination.total = data.total
629
- }
630
-
631
- gridParams.gridData = this.gridData
632
- // 完成深拷贝,复制一份对象,行编辑时使用
633
- gridParams.orgGridData = [].concat(
634
- JSON.parse(JSON.stringify(this.gridData))
635
- )
636
-
637
- gridParams.pagination = this.pagination
638
- gridParams.loaded = true
639
- this.hasLoadData = true
640
- resolve()
641
- })
642
- .catch((error) => {
643
- if (isHasOptionFunction('loadError', this.storeId)) {
644
- gridParams.options.loadError.call(this, this.code, error)
645
- }
646
- reject(error)
647
- })
648
- })
649
- },
650
- getLength(paramsData) {
651
- if (paramsData && paramsData.length > 5) {
652
- return '(' + paramsData.substring(0, 5) + '...' + ')'
653
- } else if (paramsData) {
654
- return '(' + paramsData + ')'
655
- } else {
656
- return ''
657
- }
658
- },
659
- // 获得初始查询条件对象
660
- getInitSearchForm(searchFormArr) {
661
- const gridParams = store.get(this.storeId)
662
- if (searchFormArr && searchFormArr.length > 0) {
663
- this.searchFormContent = {}
664
- searchFormArr.forEach((item) => {
665
- // 获得的是"isDeleted"
666
- let prop = item.propName
667
- // 获得的是“deleted”
668
- const columnProp = item.columnProp
669
- const dataType = item.dataType
670
- if (dataType && dataType === 'BOOLEAN') {
671
- prop = columnProp
672
- }
673
- this.initSearchProps.push(prop)
674
- const propValue = item.propValue
675
- if (prop.indexOf('.') > 0) {
676
- // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
677
- addDynamicProp(this.searchFormContent, prop, propValue)
678
- } else {
679
- this.searchFormContent[prop] = propValue
680
- }
681
- })
682
- gridParams.searchForm = searchFormArr
683
- // 调用查询api方法,该方法中调用了@showSearch方法,用于控制“查询”按钮改名为“取消查询”
684
- this.showSearchForm()
685
- } else {
686
- gridParams.searchForm = null
687
- }
688
- },
689
- showDemo() {
690
- this.isLoading = true
691
- this.$http
692
- .get(this.url)
693
- .then((data) => {
694
- Object.assign(this, data)
695
- const gridParams = store.get(this.storeId)
696
-
697
- gridParams.listCode = this.code
698
-
699
- gridParams.columns = this.columns
700
- if (gridParams.columns && this.options.dynamicColumns) {
701
- for (var i = 0; i < this.options.dynamicColumns.length; i++) {
702
- this.options.dynamicColumns[i].dynamic = true
703
- gridParams.columns.push(this.options.dynamicColumns[i])
704
- }
705
- }
706
- gridParams.lineEdit = this.lineEdit
707
- gridParams.basicInfo = this.basicInfo
708
- gridParams.pagination = this.pagination
709
- gridParams.query = this.query
710
-
711
- this.gridData = data.gridData
712
- // 对数据做序列化,比如:处理xss攻击
713
- if (isHasOptionFunction('gridDataLoaded', this.storeId)) {
714
- const gridData = gridParams.options.gridDataLoaded.call(
715
- this,
716
- data.gridData
717
- )
718
- if (gridData) {
719
- this.gridData = gridData
720
- } else {
721
- this.gridData = data.gridData
722
- }
723
- } else {
724
- this.gridData = data.gridData
725
- }
726
-
727
- if (this.pagination != null) {
728
- this.pagination.total = data.total
729
- }
730
- if (!this.gridData) {
731
- this.gridData = []
732
- }
733
- gridParams.gridData = this.gridData
734
- // 完成深拷贝,复制一份对象,行编辑时使用
735
- gridParams.orgGridData = [].concat(
736
- JSON.parse(JSON.stringify(this.gridData))
737
- )
738
- gridParams.pagination = this.pagination
739
-
740
- if (isHasOptionFunction('gridComplete', this.storeId)) {
741
- gridParams.options.gridComplete.call(
742
- this,
743
- this.gridData,
744
- gridParams.columns
745
- )
746
- }
747
- })
748
- .catch((error) => {
749
- if (isHasOptionFunction('loadError', this.storeId)) {
750
- const gridParams = store.get(this.storeId)
751
- gridParams.options.loadError.call(this, this.code, error)
752
- }
753
- })
754
- },
755
- search(searchForm) {
756
- const vm = this
757
- return new Promise((resolve, reject) => {
758
- const gridParams = store.get(vm.storeId)
759
- if (typeof searchForm !== 'undefined' && searchForm !== null) {
760
- gridParams.searchForm = searchForm
761
- } else {
762
- gridParams.searchForm = null
763
- }
764
-
765
- vm.fetchData(vm.getSearchParam(), true)
766
- .then((data) => {
767
- if (
768
- gridParams.options !== undefined &&
769
- gridParams.options.isHiddenSearchForm !== undefined &&
770
- gridParams.options.isHiddenSearchForm === true
771
- ) {
772
- // 查询时,是否隐藏查询区域,默认是不隐藏查询区域
773
- vm.showSearch = false
774
- $emit(vm, 'cancel-search')
775
- }
776
- if (vm.$refs.sf) {
777
- vm.$refs.sf.loading = false
778
- }
779
- resolve(data)
780
- })
781
- .catch((error) => {
782
- if (vm.$refs.sf) {
783
- vm.$refs.sf.loading = false
784
- }
785
- reject(error)
786
- })
787
- })
788
- },
789
- getSearchParam() {
790
- const searchParam = {
791
- code: this.code,
792
- }
793
- const gridParams = store.get(this.storeId)
794
- if (this.pagination !== null) {
795
- const pagination = {
796
- currentPage: this.currentPage,
797
- pageSize: this.pagination.pageSize,
798
- showTotal: this.pagination.showTotal,
799
- }
800
- if (this.pageSize !== null) {
801
- // 表示更改了每页显示的数据条数
802
- pagination.pageSize = this.pageSize
803
- }
804
- searchParam.pagination = pagination
805
- }
806
- // 排序信息
807
- if (this.sortInfo !== null) {
808
- // 表示更改了排序信息
809
- searchParam.sorts = this.sortInfo
810
- }
811
- if (this.mergeFields && this.mergeFields.length > 0) {
812
- if (!searchParam.sorts) {
813
- searchParam.sorts = []
814
- }
815
- const mergeFieldsArr = []
816
- for (const mergeField of this.mergeFields) {
817
- let flag = true
818
- for (const so of searchParam.sorts) {
819
- if (so.prop === mergeField) {
820
- flag = false
821
- break
822
- }
823
- }
824
- if (flag) {
825
- mergeFieldsArr.push({
826
- prop: mergeField,
827
- order: 'ascending',
828
- })
829
- }
830
- }
831
- mergeFieldsArr.push(...searchParam.sorts)
832
- searchParam.sorts = mergeFieldsArr
833
- }
834
- // 是否有初始过滤条件
835
- if (
836
- gridParams.options &&
837
- typeof gridParams.options.initSearchForm !== 'undefined'
838
- ) {
839
- searchParam.initSearchForm = gridParams.options.initSearchForm
840
- }
841
- if (typeof gridParams.searchForm !== 'undefined') {
842
- searchParam.searchForm = gridParams.searchForm
843
- } else {
844
- searchParam.searchForm = []
845
- }
846
- return searchParam
847
- },
848
- handleSizeChange(val) {
849
- this.pageSize = val
850
- this.fetchData(this.getSearchParam())
851
- },
852
- handleCurrentChange(val) {
853
- this.fetchData(this.getSearchParam())
854
- },
855
- handleSortChange({ column, prop, order }) {
856
- if (prop !== null) {
857
- // 当点击第3次时,prop会是空,表示清空排序字段,还原原顺序
858
- this.sortInfo = [
859
- {
860
- prop: prop,
861
- order: order,
862
- },
863
- ]
864
- } else {
865
- this.sortInfo = null
866
- }
867
- this.fetchData(this.getSearchParam())
868
- $emit(this, 'sort-change', { column, prop, order })
869
- },
870
- resetSearch() {
871
- this.search(null, false)
872
- },
873
- // 新建事件
874
- add() {
875
- $emit(this, 'add')
876
- },
877
- // 操作按钮的点击事件
878
- buttonClick(event, data) {
879
- if (event) {
880
- if (typeof event === 'function') {
881
- event.call(this, data)
882
- } else {
883
- $emit(this, event, data)
884
- }
885
- }
886
- },
887
- // 点击内容区域的事件
888
- clickContent(data) {
889
- this.changeSelect(data)
890
- $emit(this, 'click', data)
891
- },
892
- // 格子拖拽
893
- rowDrop() {
894
- if (this.urlToSaveOrder) {
895
- let urlToSaveOrder = this.urlToSaveOrder
896
- if (
897
- urlToSaveOrder.indexOf('http:') < 0 ||
898
- urlToSaveOrder.indexOf('https:') < 0
899
- ) {
900
- // 表示是相对路径,需要拼接全路径
901
- let baseURL = window.$vueApp.config.globalProperties.baseURL
902
- if (baseURL.lastIndexOf('/') === baseURL.length - 1) {
903
- // 表示以斜线结尾
904
- // 去掉斜线
905
- baseURL = baseURL.substring(0, baseURL.length - 1)
906
- }
907
- if (urlToSaveOrder.indexOf('/') > 0) {
908
- // 表示不是以斜线开头,需要开头加“/”
909
- urlToSaveOrder = '/' + urlToSaveOrder
910
- }
911
- urlToSaveOrder = baseURL + urlToSaveOrder
912
- }
913
- const tbody = document.querySelector('#' + this.gridId + ' .el-row')
914
- if (tbody != null) {
915
- const vm = this
916
- Sortable.create(tbody, {
917
- draggable: '.col-content',
918
- onEnd({ newIndex, oldIndex }) {
919
- const addCardId = document.querySelector(
920
- '#' + vm.gridId + ' #_addCardId_'
921
- )
922
- if (addCardId != null) {
923
- // 表示存在新建区域,则序号需要减1
924
- if (oldIndex > 0) {
925
- oldIndex = oldIndex - 1
926
- }
927
- if (newIndex > 0) {
928
- newIndex = newIndex - 1
929
- }
930
- }
931
- const params = {
932
- oldIndex: oldIndex,
933
- newIndex: newIndex,
934
- gridData: vm.gridData,
935
- }
936
- vm.$http.post(urlToSaveOrder, params).then((data) => {
937
- const currRow = vm.gridData.splice(oldIndex, 1)[0]
938
- vm.gridData.splice(newIndex, 0, currRow)
939
- vm.refresh().then(() => {
940
- $emit(vm, 'afterDrag', params)
941
- })
942
- })
943
- },
944
- })
945
- }
946
- }
947
- },
948
- // 多选按钮的change事件
949
- changeChecked(label, index) {
950
- const entity = this.gridData[index]
951
- if ((label + '').indexOf('false-') >= 0) {
952
- // 表示取消勾选记录
953
- this.unselect(entity)
954
- } else {
955
- // 表示勾选记录
956
- this.select(entity)
957
- }
958
- },
959
- unselect(entity) {
960
- const id = entity.id
961
- const index = this.selectionIds.indexOf(id)
962
- if (index > -1) {
963
- this.selections.splice(index, 1)
964
- this.selectionIds.splice(index, 1)
965
- }
966
- $emit(this, 'unselect', entity, this.selections)
967
- this.selectionModels['select' + id] = 'false-' + id
968
- // console.log('unselect---this.selections=', this.selections)
969
- },
970
- select(entity) {
971
- const id = entity.id
972
- if (this.selectionIds.indexOf(id) < 0) {
973
- this.selectionIds[this.selectionIds.length] = id
974
- this.selections[this.selections.length] = entity
975
- }
976
- $emit(this, 'select', entity, this.selections)
977
- this.selectionModels['select' + id] = id
978
- // console.log('select---this.selections=', this.selections)
979
- },
980
- // 单选按钮的change事件
981
- changeSelectWhenRadio(label, index) {
982
- const entity = this.gridData[index]
983
- this.selectionIds = []
984
- this.selections = []
985
- this.selectionModels = {}
986
- this.select(entity)
987
- },
988
- changeSelect(data) {
989
- const id = data.id
990
- if (this.multiple === true) {
991
- // 多选时
992
- if (this.selectionIds && this.selectionIds.indexOf(id) >= 0) {
993
- // 表示需要取消选中
994
- this.unselect(data)
995
- } else {
996
- // 表示需要选中
997
- this.select(data)
998
- }
999
- } else {
1000
- // 单选时
1001
- this.currentId = id
1002
- this.selectionIds = []
1003
- this.selections = []
1004
- this.selectionModels = {}
1005
- this.select(data)
1006
- }
1007
- },
1008
- isShowButton(entity, button) {
1009
- const val = this.isShowButtonFun(entity, button)
1010
- if (val === undefined) {
1011
- return true
1012
- }
1013
- return val
1014
- },
1015
- // 是否显示启用禁用按钮
1016
- showEnableButton(entity) {
1017
- const gridParams = store.get(this.storeId)
1018
- if (isHasOptionFunction('showEnableButton', this.storeId)) {
1019
- return gridParams.options.showEnableButton.call(this, entity)
1020
- }
1021
- return false
1022
- },
1023
- // 启用禁用按钮显示状态
1024
- changeState(entity) {
1025
- const gridParams = store.get(this.storeId)
1026
- if (isHasOptionFunction('changeState', this.storeId)) {
1027
- return gridParams.options.changeState.call(this, entity)
1028
- }
1029
- return false
1030
- },
1031
- },
1032
- emits: [
1033
- 'sort-change',
1034
- ,
1035
- 'click',
1036
- 'afterDrag',
1037
- 'unselect',
1038
- 'select',
1039
- 'cancel-search',
1040
- 'add',
1041
- ,
1042
- ],
1043
- }
1044
- </script>
1045
-
1046
- <style lang="scss" rel="stylesheet/scss" scoped>
1047
- .nine-grid-area {
1048
- padding: 10px;
1049
- .el-row {
1050
- margin-bottom: 20px;
1051
- &:last-child {
1052
- margin-bottom: 0;
1053
- }
1054
- }
1055
- .el-col-5 {
1056
- width: 20%;
1057
- }
1058
- .el-col {
1059
- border-radius: 4px;
1060
- margin-bottom: 10px;
1061
- }
1062
- .name {
1063
- font-size: 12px;
1064
- color: #555;
1065
- float: left;
1066
- width: 80%;
1067
- text-align: left;
1068
- }
1069
- .bottom {
1070
- // margin-top: 13px;
1071
- line-height: 13px;
1072
- // background: aquamarine;
1073
- }
1074
- .state {
1075
- font-size: 12px;
1076
- margin-top: 1.5px;
1077
- float: right;
1078
- line-height: 1;
1079
- display: flex;
1080
- align-items: right;
1081
- color: #999;
1082
- width: 20%;
1083
- text-align: right;
1084
- }
1085
- .image {
1086
- width: 100%;
1087
- display: block;
1088
- height: 200px;
1089
- }
1090
- .clearfix:before,
1091
- .clearfix:after {
1092
- display: table;
1093
- content: '';
1094
- }
1095
- .clearfix:after {
1096
- clear: both;
1097
- }
1098
- .input-with-select {
1099
- // background-color: #fff;
1100
- width: 200px;
1101
- float: right;
1102
- }
1103
- .popContainer {
1104
- position: absolute;
1105
- width: 23.15%;
1106
- display: block;
1107
- height: 200px;
1108
- background: rgba(0, 0, 0, 0.5);
1109
- text-align: right;
1110
- }
1111
- .fade-enter-active,
1112
- .fade-leave-active {
1113
- transition: opacity 0.5s;
1114
- }
1115
- .fade-enter,
1116
- .fade-leave-to {
1117
- opacity: 0;
1118
- }
1119
- .icons {
1120
- color: #adb5bd;
1121
- margin: 10px 10px 0px 0px;
1122
- cursor: pointer;
1123
- }
1124
- .release-status {
1125
- display: block;
1126
- width: 8px;
1127
- height: 8px;
1128
- margin-right: 8px;
1129
- border-radius: 100%;
1130
- }
1131
- .add-screen {
1132
- display: flex;
1133
- flex-direction: column;
1134
- justify-content: center;
1135
- align-items: center;
1136
- cursor: pointer;
1137
- height: 160px;
1138
- // background-color: #fff;
1139
- // border: 1px solid #7693f5;
1140
- // box-shadow: 0 2px 8px 0 rgba(104,130,218,.4);
1141
- font-size: 12px;
1142
- color: #666666;
1143
- font-family: Source Han Sans CN;
1144
- font-weight: regular;
1145
- font-size: 14px;
1146
- line-height: 14px;
1147
- letter-spacing: 0px;
1148
- text-align: left;
1149
- }
1150
- .el-divider--horizontal {
1151
- margin: 5px 0;
1152
- }
1153
- .button-style {
1154
- margin-top: 28px;
1155
- color: #606266;
1156
- font-family: Source Han Sans CN;
1157
- font-weight: regular;
1158
- font-size: 14px;
1159
- line-height: 14px;
1160
- letter-spacing: 0px;
1161
- text-align: left;
1162
- }
1163
- }
1164
- </style>
1
+ <template>
2
+ <div>
3
+ <search-form
4
+ v-if="hasLoadedColumns"
5
+ v-show="showSearch"
6
+ ref="sf"
7
+ :code="code"
8
+ :columns="columns"
9
+ :grid-id="gridId"
10
+ :init-search-props="initSearchProps"
11
+ :pagination="pagination"
12
+ :query="query"
13
+ :search-param="searchFormContent"
14
+ :url="url"
15
+ @reset="resetSearch"
16
+ @search="search"
17
+ />
18
+ <div class="nine-grid-area">
19
+ <div
20
+ :id="gridId"
21
+ :style="'height:' + height + 'px;overflow-y: auto;overflow-x: hidden;'"
22
+ >
23
+ <el-row :gutter="24">
24
+ <el-col
25
+ v-if="isHasCreate"
26
+ id="_addCardId_"
27
+ v-permission="createPermission"
28
+ :span="colSpan"
29
+ >
30
+ <el-card
31
+ :body-style="{ padding: '0px' }"
32
+ style="
33
+ border-radius: 4px;
34
+ background: #ffffff;
35
+ border: 1px solid #e5e8ef;
36
+ "
37
+ >
38
+ <div class="add-screen" @click="add">
39
+ <em class="el-icon-plus"/>
40
+ <span style="margin-top: 7px">
41
+ {{ $t('superNineGrid.add') }}</span
42
+ >
43
+ </div>
44
+ </el-card>
45
+ </el-col>
46
+ <el-col
47
+ v-for="(params, index) in gridData"
48
+ :key="params.id"
49
+ :span="colSpan"
50
+ >
51
+ <el-card
52
+ :body-style="{ padding: '0px' }"
53
+ :style="{
54
+ border:
55
+ selectionIds.indexOf(params.id) > -1
56
+ ? '1px solid #005EBA'
57
+ : '',
58
+ }"
59
+ shadow="hover"
60
+ >
61
+ <div
62
+ style="height: 160px"
63
+ @click="clickContent(params)"
64
+ @mouseenter="enter(index)"
65
+ @mouseleave="leave()"
66
+ >
67
+ <!-- <transition name="fade">
68
+ <div v-if="seen && index === current" class="popContainer">
69
+ <div class="else-button">
70
+ <template v-for="button in operations">
71
+ <template v-if="isShowButton(params, button)">
72
+ <el-tooltip v-if="button.icon" :key="button.name" v-permission="button.permission?button.permission:'true'" class="item" effect="dark" :content="button.name" placement="top">
73
+ <em :class="button.icon +' icons'" @click.stop="buttonClick(button.event, params)" />
74
+ </el-tooltip>
75
+ <em v-else :key="button.name" v-permission="button.permission?button.permission:'true'" :class="button.name +' icons'" @click.stop="buttonClick(button.event, params)">{{ button.name }} </em>
76
+ </template>
77
+ </template>
78
+ </div>
79
+ </div>
80
+ </transition> -->
81
+ <!-- <img v-if="props && props.imageUrl && objectPropValue(params, propCloumns.imageUrl, props.imageUrl)" :src="defaultShowImageAction+objectPropValue(params, propCloumns.imageUrl, props.imageUrl)" alt="加载失败" class="image"> -->
82
+ <!-- <img v-if="true || (props && props.imageUrl)" :src="defaultShowImageAction+'fa7ae05e-0f0e-4cc0-b24a-69aea4408233'" alt="加载失败" class="image"> -->
83
+ <!-- <div v-else class="image" style="padding: 20px; text-align: center;"> -->
84
+ <div
85
+ class="image"
86
+ style="padding: 15px; box-sizing: border-box"
87
+ >
88
+ <div>
89
+ <el-tooltip
90
+ :content="'系统编码:' + params.code"
91
+ effect="dark"
92
+ placement="top-start"
93
+ >
94
+ <div
95
+ v-if="props && props.content"
96
+ style="display: inline-block"
97
+ >
98
+ {{
99
+ getPropValue('content', params) +
100
+ getLength(params.code)
101
+ }}
102
+ </div>
103
+ <div
104
+ v-else-if="props && props.title"
105
+ style="display: inline-block"
106
+ >
107
+ {{
108
+ getPropValue('title', params) + getLength(params.code)
109
+ }}
110
+ </div>
111
+ </el-tooltip>
112
+ <div
113
+ v-if="showEnableButton(params)"
114
+ style="
115
+ margin-left: 2px;
116
+ color: #00b42a;
117
+ background-color: #e8ffea;
118
+ width: 68px;
119
+ text-align: center;
120
+ display: inline-block;
121
+ "
122
+ >
123
+ <el-icon>
124
+ <SuccessFilled/>
125
+ </el-icon>
126
+ <span
127
+ :title="getPropValue('subTitle', params)"
128
+ style="margin-left: 4px"
129
+ >{{ getPropValue('subTitle', params) }}</span
130
+ >
131
+ </div>
132
+ </div>
133
+ <div class="button-style">
134
+ 操作
135
+ <template v-for="button in operations">
136
+ <template v-if="isShowButton(params, button)">
137
+ <el-tooltip
138
+ v-if="button.icon"
139
+ v-permission="
140
+ button.permission ? button.permission : 'true'
141
+ "
142
+ :content="button.name"
143
+ class="item"
144
+ effect="dark"
145
+ placement="top"
146
+ style="background-color: red"
147
+ >
148
+ <el-icon :class="button.icon + ' icons'" @click.stop="buttonClick(button.event, params)">
149
+ <component :is="button.icon"/>
150
+ </el-icon>
151
+ </el-tooltip>
152
+ <em
153
+ v-else
154
+ v-permission="
155
+ button.permission ? button.permission : 'true'
156
+ "
157
+ :class="button.name + ' icons'"
158
+ @click.stop="buttonClick(button.event, params)"
159
+ >{{ button.name }}
160
+ </em>
161
+ </template>
162
+ </template>
163
+ </div>
164
+ <div
165
+ v-if="isShowEnableState"
166
+ style="float: right; margin-top: 28px"
167
+ >
168
+ <el-button
169
+ v-if="showEnableButton(params)"
170
+ size="mini"
171
+ @click.stop="changeState(params)"
172
+ >
173
+ 禁用
174
+ </el-button>
175
+ <el-button
176
+ v-else
177
+ size="mini"
178
+ type="primary"
179
+ @click.stop="changeState(params)"
180
+ >
181
+ 启用
182
+ </el-button>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ <!-- <el-divider />
187
+ <div style="padding: 10px 10px 10px 10px;">
188
+ <div class="bottom clearfix">
189
+ <time class="name">
190
+ <span v-if="props && props.title">
191
+ <el-checkbox v-if="multiple" :value="selectionModels['select'+params.id]" :true-label="params.id" :false-label="'false-'+params.id" :title="getPropValue('title', params)" style="width: 100%" @change="changeChecked($event, index)">
192
+ {{ getPropValue('title', params) }}
193
+ <span :style="getTitleStyle(params)"> {{ getPropValue('title', params) }}</span>
194
+ </el-checkbox>
195
+ <el-radio v-else-if="isShowRadio" v-model="currentId" :label="params.id" :title="getPropValue('title', params)" style="width: 100%" @change="changeSelectWhenRadio($event, index)">
196
+ {{ getPropValue('title', params) }}
197
+ <span :style="getTitleStyle(params)"> {{ getPropValue('title', params) }}</span>
198
+ </el-radio>
199
+ <span v-else :style="getTitleStyle(params)" :title="getPropValue('title', params)"> {{ getPropValue('title', params) }}</span>
200
+ </span>
201
+ <span v-else-if="props && props.content">
202
+ <el-checkbox v-if="multiple" :value="selectionModels['select'+params.id]" :true-label="params.id" :false-label="'false-'+params.id" :title="getPropValue('content', params)" style="width: 100%" @change="changeChecked($event, index)">{{ getPropValue('content', params) }}</el-checkbox>
203
+ <el-radio v-else-if="isShowRadio" v-model="currentId" :label="params.id" :title="getPropValue('content', params)" style="width: 100%" @change="changeSelectWhenRadio($event, index)">{{ getPropValue('content', params) }}</el-radio>
204
+ <span v-else :title="getPropValue('content', params)" style="width: 100%"> {{ getPropValue('content', params) }}</span>
205
+ </span>
206
+ <span v-else>
207
+ <el-checkbox v-if="multiple" :value="selectionModels['select'+params.id]" :true-label="params.id" :false-label="'false-'+params.id" @change="changeChecked($event, index)">{{ index + 1 }}</el-checkbox>
208
+ <el-radio v-else-if="isShowRadio" v-model="currentId" :label="params.id" @change="changeSelectWhenRadio($event, index)">{{ index + 1 }}</el-radio>
209
+ <span v-else> {{ index + 1 }}</span>
210
+ </span>
211
+ </time>
212
+ <time v-if="props && props.subTitle" class="state">
213
+ <span :title="getPropValue('subTitle', params)" style="width: 100%">{{ getPropValue('subTitle', params) }}</span>
214
+ </time>
215
+ </div>
216
+ </div> -->
217
+ </el-card>
218
+ </el-col>
219
+ </el-row>
220
+ </div>
221
+ <el-pagination
222
+ v-if="pagination"
223
+ v-model:current-page="currentPage"
224
+ :layout="pagination.layout"
225
+ :page-size="pagination.pageSize"
226
+ :page-sizes="pagination.pageSizes"
227
+ :total="pagination.total"
228
+ @size-change="handleSizeChange"
229
+ @current-change="handleCurrentChange"
230
+ />
231
+ </div>
232
+ </div>
233
+ </template>
234
+
235
+ <script>
236
+ import {$emit} from '../../utils/gogocodeTransfer'
237
+ import customFormatter from './custom-formatter'
238
+ import SearchForm from './search-form.vue'
239
+ import {addDynamicProp, getGridParams, getTableHeight, isHasOptionFunction} from './utils'
240
+ import store from './store'
241
+ import superGridService from './super-grid-service'
242
+ import apis from './apis'
243
+ import Sortable from 'sortablejs'
244
+
245
+ export default {
246
+ name: 'SuperNineGrid',
247
+ components: {
248
+ SearchForm,
249
+ },
250
+ props: {
251
+ code: {
252
+ type: String,
253
+ default: '',
254
+ },
255
+ url: {
256
+ type: String,
257
+ default: '',
258
+ },
259
+ options: {
260
+ type: Object,
261
+ default: function () {
262
+ return {}
263
+ },
264
+ },
265
+ },
266
+ data() {
267
+ let mergeFields = []
268
+ if (
269
+ this.options &&
270
+ this.options.mergeFields &&
271
+ this.options.mergeFields !== ''
272
+ ) {
273
+ mergeFields = this.options.mergeFields.split(',')
274
+ }
275
+ const defaultShowImageAction =
276
+ window.$vueApp.config.globalProperties.baseAPI +
277
+ '/component/super-form/show-image?serverPath='
278
+ const gridId =
279
+ this.options && this.options.id ? this.options.id : '_nineGrid'
280
+ const storeId = this.code + '~' + gridId
281
+ const isShowRadio =
282
+ this.options && this.options.showRadio !== undefined
283
+ ? this.options.showRadio
284
+ : false
285
+ return {
286
+ isLoading: false,
287
+ currentPage: 1,
288
+ showColumnConfig: false,
289
+ basicInfo: {
290
+ summary: 'no',
291
+ },
292
+ columns: [],
293
+ pagination: null,
294
+ query: null,
295
+ lineEdit: null,
296
+ gridData: [],
297
+ sortInfo: null,
298
+ pageSize: null,
299
+ showSearch: false,
300
+ height: null,
301
+ isSql: false, // 是否是sql查询
302
+ hasLoadData: false,
303
+ mergeFields,
304
+ hasLoadedColumns: false, // 是否已经加载了列配置
305
+ seen: false,
306
+ current: null,
307
+ isHasCreate: true, // 是否需要新建按钮
308
+ screenBaseUrl: null,
309
+ props: null, // 属性配置
310
+ operations: [], // 指向格子时出现的操作按钮集合
311
+ propCloumns: null, // 属性字段配置详细信息
312
+ multiple: false, // 是否需要多选
313
+ createPermission: 'true', // 新建权限编码,默认是有权限的
314
+ urlToSaveOrder: null, // 拖动格子后台保存接口路径
315
+ selections: [], // 选中的记录集合
316
+ selectionIds: [], // 选中的记录id集合
317
+ selectionModels: {}, // 选中的记录对象
318
+ searchFormContent: null,
319
+ initSearchProps: [], // 初始查询的字段属性名集合
320
+ defaultShowImageAction, // 显示图片的路径
321
+ gridId,
322
+ storeId,
323
+ currentId: null, // 当前点击的记录id
324
+ isShowRadio, // 单选时是否显示单选按钮
325
+ titleStyle: null, // 标题的样式对象,格式为:{ color: 'green', fontWeight: 'bold'}
326
+ isShowEnableState: false,
327
+ colSpan: 6,
328
+ }
329
+ },
330
+ computed: {},
331
+ provide() {
332
+ return {}
333
+ },
334
+ created() {
335
+ store.set(this.code + '~' + this.gridId, getGridParams())
336
+ store.set('_nine_list_code', this.code + '~' + this.gridId)
337
+ this.initSetting()
338
+ this.initialize()
339
+ // this.showDemo()
340
+ console.log('%c描述-232041', 'color:#2E3435;background:#F8BB07;padding:3px;border-radius:2px', this.operations);
341
+ },
342
+ mounted() {
343
+ this.$watch(
344
+ 'showSearch',
345
+ function (newVal, oldVal) {
346
+ this.$nextTick(() => {
347
+ let tableHeight = getTableHeight(newVal, this.$refs.sf)
348
+ const newHeight = this.resizeHeight()
349
+ if (newHeight) {
350
+ tableHeight = newHeight
351
+ }
352
+ this.height = tableHeight
353
+ })
354
+ },
355
+ {
356
+ immediate: true,
357
+ deep: true,
358
+ }
359
+ )
360
+
361
+ this.$watch(
362
+ 'hasLoadData',
363
+ function (newVal, oldVal) {
364
+ if (newVal === true) {
365
+ this.$nextTick(() => {
366
+ this.rowDrop()
367
+ const gridParams = store.get(this.storeId)
368
+ if (isHasOptionFunction('gridComplete', this.storeId)) {
369
+ gridParams.options.gridComplete.call(this, {
370
+ gridData: this.gridData,
371
+ columns: gridParams.columns,
372
+ superGrid: this.$refs.superGrid,
373
+ })
374
+ }
375
+ const newHeight = this.resizeHeight()
376
+ if (newHeight) {
377
+ this.height = newHeight
378
+ }
379
+ })
380
+ }
381
+ },
382
+ {
383
+ immediate: true,
384
+ deep: true,
385
+ }
386
+ )
387
+ },
388
+ methods: {
389
+ ...superGridService,
390
+ ...apis,
391
+ ...customFormatter,
392
+ getTitleStyle(entity) {
393
+ // 九宫格的标题自定义样式
394
+ if (this.options && this.options.titleStyle) {
395
+ return this.options.titleStyle.call(this, entity)
396
+ }
397
+ return {width: '100%'}
398
+ },
399
+ // 获得属性值
400
+ getPropValue(type, entity) {
401
+ let value = ''
402
+ const gridParams = store.get(this.storeId)
403
+ if (type === 'content') {
404
+ let content = ''
405
+ if (isHasOptionFunction('setContent', this.storeId)) {
406
+ content = gridParams.options.getContent.call(this, entity)
407
+ }
408
+ if (content === undefined || content === '') {
409
+ if (this.props && this.props.content) {
410
+ content = this.objectPropValue(
411
+ entity,
412
+ this.propCloumns.content,
413
+ this.props.content
414
+ )
415
+ } else if (this.props && this.props.title) {
416
+ content = this.objectPropValue(
417
+ entity,
418
+ this.propCloumns.title,
419
+ this.props.title
420
+ )
421
+ }
422
+ }
423
+ value = content
424
+ } else if (type === 'title') {
425
+ let content = ''
426
+ if (isHasOptionFunction('setTitle', this.storeId)) {
427
+ content = gridParams.options.setTitle.call(this, entity)
428
+ }
429
+ if (content === undefined || content === '') {
430
+ if (this.props && this.props.title) {
431
+ content = this.objectPropValue(
432
+ entity,
433
+ this.propCloumns.title,
434
+ this.props.title
435
+ )
436
+ } else if (this.props && this.props.content) {
437
+ content = this.objectPropValue(
438
+ entity,
439
+ this.propCloumns.content,
440
+ this.props.content
441
+ )
442
+ }
443
+ }
444
+ value = content
445
+ } else if (type === 'subTitle') {
446
+ let content = ''
447
+ if (isHasOptionFunction('setSubTitle', this.storeId)) {
448
+ content = gridParams.options.setSubTitle.call(this, entity)
449
+ }
450
+ if (content === undefined || content === '') {
451
+ if (this.props && this.props.subTitle) {
452
+ content = this.objectPropValue(
453
+ entity,
454
+ this.propCloumns.subTitle,
455
+ this.props.subTitle
456
+ )
457
+ }
458
+ }
459
+ value = content
460
+ }
461
+ if (value === undefined) {
462
+ value = ''
463
+ }
464
+ return value
465
+ },
466
+ resizeHeight() {
467
+ const gridParams = store.get(this.storeId)
468
+ if (isHasOptionFunction('resizeHeight', this.storeId)) {
469
+ let searchHeight = 0
470
+ if (this.showSearch === true) {
471
+ if (this.$refs.sf) {
472
+ // 获得查询区高度
473
+ searchHeight = this.$refs.sf.$el.offsetHeight
474
+ }
475
+ }
476
+ return gridParams.options.resizeHeight.call(this, {
477
+ code: this.code,
478
+ height: this.height,
479
+ searchHeight: searchHeight,
480
+ })
481
+ }
482
+ },
483
+ enter(index) {
484
+ this.seen = true
485
+ this.current = index
486
+ },
487
+ leave() {
488
+ this.seen = false
489
+ this.current = null
490
+ },
491
+ initSetting() {
492
+ const gridParams = store.get(this.storeId)
493
+ if (typeof this.options !== 'undefined') {
494
+ Object.assign(gridParams.options, this.options)
495
+ } else {
496
+ gridParams.options = {}
497
+ }
498
+ if (this.options && typeof this.options.isHasCreate !== 'undefined') {
499
+ this.isHasCreate = this.options.isHasCreate
500
+ }
501
+ if (this.options && typeof this.options.props !== 'undefined') {
502
+ this.props = this.options.props
503
+ }
504
+ if (this.options && typeof this.options.operations !== 'undefined') {
505
+ this.operations = this.options.operations
506
+ }
507
+ if (
508
+ this.options &&
509
+ typeof this.options.createPermission !== 'undefined'
510
+ ) {
511
+ this.createPermission = this.options.createPermission
512
+ }
513
+ if (this.options && typeof this.options.multiple !== 'undefined') {
514
+ this.multiple = this.options.multiple
515
+ }
516
+ if (
517
+ this.options &&
518
+ typeof this.options.isShowEnableState !== 'undefined'
519
+ ) {
520
+ this.isShowEnableState = this.options.isShowEnableState
521
+ }
522
+ if (this.options && typeof this.options.colSpan !== 'undefined') {
523
+ this.colSpan = this.options.colSpan
524
+ }
525
+ },
526
+ // 获得各属性对应的字段配置
527
+ getPropColumns() {
528
+ if (this.columns && this.columns.length > 0) {
529
+ // imageUrl:{column}, content: {column}, title: {}, subTitle:{}
530
+ this.propCloumns = {}
531
+ this.columns.forEach((column) => {
532
+ if (this.props.imageUrl && this.props.imageUrl === column.prop) {
533
+ this.propCloumns.imageUrl = column
534
+ }
535
+ if (this.props.content && this.props.content === column.prop) {
536
+ this.propCloumns.content = column
537
+ }
538
+ if (this.props.title && this.props.title === column.prop) {
539
+ this.propCloumns.title = column
540
+ }
541
+ if (this.props.subTitle && this.props.subTitle === column.prop) {
542
+ this.propCloumns.subTitle = column
543
+ }
544
+ })
545
+ }
546
+ },
547
+ fetchData(searchParam, isSearch) {
548
+ return new Promise((resolve, reject) => {
549
+ // 获得各属性对应的字段配置
550
+ this.getPropColumns()
551
+ this.isLoading = true
552
+ this.hasLoadData = false
553
+ if (isSearch === undefined || isSearch === false) {
554
+ // 如果不是查询时才需要从缓存中获得结果
555
+ // 如果是刷新当前列表,则需要获得缓存中的window.sessionStorage
556
+ const isRefreshList = window.sessionStorage.getItem(
557
+ 'refreshList-' + this.storeId
558
+ )
559
+ // console.log('fetchData--isRefreshList--', isRefreshList)
560
+ if (isRefreshList !== undefined && isRefreshList === 'true') {
561
+ const searchParamJson = window.sessionStorage.getItem(
562
+ 'searchParam-' + this.storeId
563
+ )
564
+ // console.log('fetchData--searchParamJson--', searchParamJson)
565
+ // console.log('fetchData--pagination--', this.pagination)
566
+ if (
567
+ searchParamJson !== undefined &&
568
+ searchParamJson !== null &&
569
+ searchParamJson !== ''
570
+ ) {
571
+ searchParam = JSON.parse(searchParamJson)
572
+ const pagination = searchParam.pagination
573
+ if (pagination) {
574
+ this.currentPage = pagination.currentPage
575
+ this.pagination.pageSize = pagination.pageSize
576
+ this.pagination.showTotal = pagination.showTotal
577
+ }
578
+ this.getInitSearchForm(searchParam.searchForm)
579
+ // this.searchFormContent = searchParam.searchForm
580
+ }
581
+ }
582
+ }
583
+ window.sessionStorage.removeItem('refreshList-' + this.storeId)
584
+ if (searchParam === undefined) {
585
+ searchParam = this.getSearchParam()
586
+ }
587
+ const gridParams = store.get(this.storeId)
588
+ let param = searchParam
589
+ if (gridParams.options.extraParam) {
590
+ param = {
591
+ searchParam: searchParam,
592
+ }
593
+ if (gridParams.options.extraParam) {
594
+ for (const paramName in gridParams.options.extraParam) {
595
+ param[paramName] = gridParams.options.extraParam[paramName]
596
+ }
597
+ }
598
+ }
599
+ // 导出需要这两个参数
600
+ gridParams.searchParam = searchParam
601
+ gridParams.url = this.url
602
+ const requestUrl = this.url
603
+ // 缓存查询条件及当前页数
604
+ window.sessionStorage.setItem(
605
+ 'searchParam-' + this.storeId,
606
+ JSON.stringify(param)
607
+ )
608
+ this.$http
609
+ .post(requestUrl, param)
610
+ .then((data) => {
611
+ // 对数据做序列化,比如:处理xss攻击
612
+ if (isHasOptionFunction('gridDataLoaded', this.storeId)) {
613
+ const gridData = gridParams.options.gridDataLoaded.call(this, {
614
+ gridData: data.data,
615
+ columns: gridParams.columns,
616
+ })
617
+ if (gridData) {
618
+ this.gridData = gridData
619
+ } else {
620
+ this.gridData = data.data
621
+ }
622
+ } else {
623
+ this.gridData = data.data
624
+ }
625
+ if (!this.gridData) {
626
+ this.gridData = []
627
+ }
628
+
629
+ if (this.pagination !== null) {
630
+ this.pagination.total = data.total
631
+ }
632
+
633
+ gridParams.gridData = this.gridData
634
+ // 完成深拷贝,复制一份对象,行编辑时使用
635
+ gridParams.orgGridData = [].concat(
636
+ JSON.parse(JSON.stringify(this.gridData))
637
+ )
638
+
639
+ gridParams.pagination = this.pagination
640
+ gridParams.loaded = true
641
+ this.hasLoadData = true
642
+ resolve()
643
+ })
644
+ .catch((error) => {
645
+ if (isHasOptionFunction('loadError', this.storeId)) {
646
+ gridParams.options.loadError.call(this, this.code, error)
647
+ }
648
+ reject(error)
649
+ })
650
+ })
651
+ },
652
+ getLength(paramsData) {
653
+ if (paramsData && paramsData.length > 5) {
654
+ return '(' + paramsData.substring(0, 5) + '...' + ')'
655
+ } else if (paramsData) {
656
+ return '(' + paramsData + ')'
657
+ } else {
658
+ return ''
659
+ }
660
+ },
661
+ // 获得初始查询条件对象
662
+ getInitSearchForm(searchFormArr) {
663
+ const gridParams = store.get(this.storeId)
664
+ if (searchFormArr && searchFormArr.length > 0) {
665
+ this.searchFormContent = {}
666
+ searchFormArr.forEach((item) => {
667
+ // 获得的是"isDeleted"
668
+ let prop = item.propName
669
+ // 获得的是“deleted”
670
+ const columnProp = item.columnProp
671
+ const dataType = item.dataType
672
+ if (dataType && dataType === 'BOOLEAN') {
673
+ prop = columnProp
674
+ }
675
+ this.initSearchProps.push(prop)
676
+ const propValue = item.propValue
677
+ if (prop.indexOf('.') > 0) {
678
+ // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
679
+ addDynamicProp(this.searchFormContent, prop, propValue)
680
+ } else {
681
+ this.searchFormContent[prop] = propValue
682
+ }
683
+ })
684
+ gridParams.searchForm = searchFormArr
685
+ // 调用查询api方法,该方法中调用了@showSearch方法,用于控制“查询”按钮改名为“取消查询”
686
+ this.showSearchForm()
687
+ } else {
688
+ gridParams.searchForm = null
689
+ }
690
+ },
691
+ showDemo() {
692
+ this.isLoading = true
693
+ this.$http
694
+ .get(this.url)
695
+ .then((data) => {
696
+ Object.assign(this, data)
697
+ const gridParams = store.get(this.storeId)
698
+
699
+ gridParams.listCode = this.code
700
+
701
+ gridParams.columns = this.columns
702
+ if (gridParams.columns && this.options.dynamicColumns) {
703
+ for (var i = 0; i < this.options.dynamicColumns.length; i++) {
704
+ this.options.dynamicColumns[i].dynamic = true
705
+ gridParams.columns.push(this.options.dynamicColumns[i])
706
+ }
707
+ }
708
+ gridParams.lineEdit = this.lineEdit
709
+ gridParams.basicInfo = this.basicInfo
710
+ gridParams.pagination = this.pagination
711
+ gridParams.query = this.query
712
+
713
+ this.gridData = data.gridData
714
+ // 对数据做序列化,比如:处理xss攻击
715
+ if (isHasOptionFunction('gridDataLoaded', this.storeId)) {
716
+ const gridData = gridParams.options.gridDataLoaded.call(
717
+ this,
718
+ data.gridData
719
+ )
720
+ if (gridData) {
721
+ this.gridData = gridData
722
+ } else {
723
+ this.gridData = data.gridData
724
+ }
725
+ } else {
726
+ this.gridData = data.gridData
727
+ }
728
+
729
+ if (this.pagination != null) {
730
+ this.pagination.total = data.total
731
+ }
732
+ if (!this.gridData) {
733
+ this.gridData = []
734
+ }
735
+ gridParams.gridData = this.gridData
736
+ // 完成深拷贝,复制一份对象,行编辑时使用
737
+ gridParams.orgGridData = [].concat(
738
+ JSON.parse(JSON.stringify(this.gridData))
739
+ )
740
+ gridParams.pagination = this.pagination
741
+
742
+ if (isHasOptionFunction('gridComplete', this.storeId)) {
743
+ gridParams.options.gridComplete.call(
744
+ this,
745
+ this.gridData,
746
+ gridParams.columns
747
+ )
748
+ }
749
+ })
750
+ .catch((error) => {
751
+ if (isHasOptionFunction('loadError', this.storeId)) {
752
+ const gridParams = store.get(this.storeId)
753
+ gridParams.options.loadError.call(this, this.code, error)
754
+ }
755
+ })
756
+ },
757
+ search(searchForm) {
758
+ const vm = this
759
+ return new Promise((resolve, reject) => {
760
+ const gridParams = store.get(vm.storeId)
761
+ if (typeof searchForm !== 'undefined' && searchForm !== null) {
762
+ gridParams.searchForm = searchForm
763
+ } else {
764
+ gridParams.searchForm = null
765
+ }
766
+
767
+ vm.fetchData(vm.getSearchParam(), true)
768
+ .then((data) => {
769
+ if (
770
+ gridParams.options !== undefined &&
771
+ gridParams.options.isHiddenSearchForm !== undefined &&
772
+ gridParams.options.isHiddenSearchForm === true
773
+ ) {
774
+ // 查询时,是否隐藏查询区域,默认是不隐藏查询区域
775
+ vm.showSearch = false
776
+ $emit(vm, 'cancel-search')
777
+ }
778
+ if (vm.$refs.sf) {
779
+ vm.$refs.sf.loading = false
780
+ }
781
+ resolve(data)
782
+ })
783
+ .catch((error) => {
784
+ if (vm.$refs.sf) {
785
+ vm.$refs.sf.loading = false
786
+ }
787
+ reject(error)
788
+ })
789
+ })
790
+ },
791
+ getSearchParam() {
792
+ const searchParam = {
793
+ code: this.code,
794
+ }
795
+ const gridParams = store.get(this.storeId)
796
+ if (this.pagination !== null) {
797
+ const pagination = {
798
+ currentPage: this.currentPage,
799
+ pageSize: this.pagination.pageSize,
800
+ showTotal: this.pagination.showTotal,
801
+ }
802
+ if (this.pageSize !== null) {
803
+ // 表示更改了每页显示的数据条数
804
+ pagination.pageSize = this.pageSize
805
+ }
806
+ searchParam.pagination = pagination
807
+ }
808
+ // 排序信息
809
+ if (this.sortInfo !== null) {
810
+ // 表示更改了排序信息
811
+ searchParam.sorts = this.sortInfo
812
+ }
813
+ if (this.mergeFields && this.mergeFields.length > 0) {
814
+ if (!searchParam.sorts) {
815
+ searchParam.sorts = []
816
+ }
817
+ const mergeFieldsArr = []
818
+ for (const mergeField of this.mergeFields) {
819
+ let flag = true
820
+ for (const so of searchParam.sorts) {
821
+ if (so.prop === mergeField) {
822
+ flag = false
823
+ break
824
+ }
825
+ }
826
+ if (flag) {
827
+ mergeFieldsArr.push({
828
+ prop: mergeField,
829
+ order: 'ascending',
830
+ })
831
+ }
832
+ }
833
+ mergeFieldsArr.push(...searchParam.sorts)
834
+ searchParam.sorts = mergeFieldsArr
835
+ }
836
+ // 是否有初始过滤条件
837
+ if (
838
+ gridParams.options &&
839
+ typeof gridParams.options.initSearchForm !== 'undefined'
840
+ ) {
841
+ searchParam.initSearchForm = gridParams.options.initSearchForm
842
+ }
843
+ if (typeof gridParams.searchForm !== 'undefined') {
844
+ searchParam.searchForm = gridParams.searchForm
845
+ } else {
846
+ searchParam.searchForm = []
847
+ }
848
+ return searchParam
849
+ },
850
+ handleSizeChange(val) {
851
+ this.pageSize = val
852
+ this.fetchData(this.getSearchParam())
853
+ },
854
+ handleCurrentChange(val) {
855
+ this.fetchData(this.getSearchParam())
856
+ },
857
+ handleSortChange({column, prop, order}) {
858
+ if (prop !== null) {
859
+ // 当点击第3次时,prop会是空,表示清空排序字段,还原原顺序
860
+ this.sortInfo = [
861
+ {
862
+ prop: prop,
863
+ order: order,
864
+ },
865
+ ]
866
+ } else {
867
+ this.sortInfo = null
868
+ }
869
+ this.fetchData(this.getSearchParam())
870
+ $emit(this, 'sort-change', {column, prop, order})
871
+ },
872
+ resetSearch() {
873
+ this.search(null, false)
874
+ },
875
+ // 新建事件
876
+ add() {
877
+ $emit(this, 'add')
878
+ },
879
+ // 操作按钮的点击事件
880
+ buttonClick(event, data) {
881
+ if (event) {
882
+ if (typeof event === 'function') {
883
+ event.call(this, data)
884
+ } else {
885
+ $emit(this, event, data)
886
+ }
887
+ }
888
+ },
889
+ // 点击内容区域的事件
890
+ clickContent(data) {
891
+ this.changeSelect(data)
892
+ $emit(this, 'click', data)
893
+ },
894
+ // 格子拖拽
895
+ rowDrop() {
896
+ if (this.urlToSaveOrder) {
897
+ let urlToSaveOrder = this.urlToSaveOrder
898
+ if (
899
+ urlToSaveOrder.indexOf('http:') < 0 ||
900
+ urlToSaveOrder.indexOf('https:') < 0
901
+ ) {
902
+ // 表示是相对路径,需要拼接全路径
903
+ let baseURL = window.$vueApp.config.globalProperties.baseURL
904
+ if (baseURL.lastIndexOf('/') === baseURL.length - 1) {
905
+ // 表示以斜线结尾
906
+ // 去掉斜线
907
+ baseURL = baseURL.substring(0, baseURL.length - 1)
908
+ }
909
+ if (urlToSaveOrder.indexOf('/') > 0) {
910
+ // 表示不是以斜线开头,需要开头加“/”
911
+ urlToSaveOrder = '/' + urlToSaveOrder
912
+ }
913
+ urlToSaveOrder = baseURL + urlToSaveOrder
914
+ }
915
+ const tbody = document.querySelector('#' + this.gridId + ' .el-row')
916
+ if (tbody != null) {
917
+ const vm = this
918
+ Sortable.create(tbody, {
919
+ draggable: '.col-content',
920
+ onEnd({newIndex, oldIndex}) {
921
+ const addCardId = document.querySelector(
922
+ '#' + vm.gridId + ' #_addCardId_'
923
+ )
924
+ if (addCardId != null) {
925
+ // 表示存在新建区域,则序号需要减1
926
+ if (oldIndex > 0) {
927
+ oldIndex = oldIndex - 1
928
+ }
929
+ if (newIndex > 0) {
930
+ newIndex = newIndex - 1
931
+ }
932
+ }
933
+ const params = {
934
+ oldIndex: oldIndex,
935
+ newIndex: newIndex,
936
+ gridData: vm.gridData,
937
+ }
938
+ vm.$http.post(urlToSaveOrder, params).then((data) => {
939
+ const currRow = vm.gridData.splice(oldIndex, 1)[0]
940
+ vm.gridData.splice(newIndex, 0, currRow)
941
+ vm.refresh().then(() => {
942
+ $emit(vm, 'afterDrag', params)
943
+ })
944
+ })
945
+ },
946
+ })
947
+ }
948
+ }
949
+ },
950
+ // 多选按钮的change事件
951
+ changeChecked(label, index) {
952
+ const entity = this.gridData[index]
953
+ if ((label + '').indexOf('false-') >= 0) {
954
+ // 表示取消勾选记录
955
+ this.unselect(entity)
956
+ } else {
957
+ // 表示勾选记录
958
+ this.select(entity)
959
+ }
960
+ },
961
+ unselect(entity) {
962
+ const id = entity.id
963
+ const index = this.selectionIds.indexOf(id)
964
+ if (index > -1) {
965
+ this.selections.splice(index, 1)
966
+ this.selectionIds.splice(index, 1)
967
+ }
968
+ $emit(this, 'unselect', entity, this.selections)
969
+ this.selectionModels['select' + id] = 'false-' + id
970
+ // console.log('unselect---this.selections=', this.selections)
971
+ },
972
+ select(entity) {
973
+ const id = entity.id
974
+ if (this.selectionIds.indexOf(id) < 0) {
975
+ this.selectionIds[this.selectionIds.length] = id
976
+ this.selections[this.selections.length] = entity
977
+ }
978
+ $emit(this, 'select', entity, this.selections)
979
+ this.selectionModels['select' + id] = id
980
+ // console.log('select---this.selections=', this.selections)
981
+ },
982
+ // 单选按钮的change事件
983
+ changeSelectWhenRadio(label, index) {
984
+ const entity = this.gridData[index]
985
+ this.selectionIds = []
986
+ this.selections = []
987
+ this.selectionModels = {}
988
+ this.select(entity)
989
+ },
990
+ changeSelect(data) {
991
+ const id = data.id
992
+ if (this.multiple === true) {
993
+ // 多选时
994
+ if (this.selectionIds && this.selectionIds.indexOf(id) >= 0) {
995
+ // 表示需要取消选中
996
+ this.unselect(data)
997
+ } else {
998
+ // 表示需要选中
999
+ this.select(data)
1000
+ }
1001
+ } else {
1002
+ // 单选时
1003
+ this.currentId = id
1004
+ this.selectionIds = []
1005
+ this.selections = []
1006
+ this.selectionModels = {}
1007
+ this.select(data)
1008
+ }
1009
+ },
1010
+ isShowButton(entity, button) {
1011
+ const val = this.isShowButtonFun(entity, button)
1012
+ if (val === undefined) {
1013
+ return true
1014
+ }
1015
+ return val
1016
+ },
1017
+ // 是否显示启用禁用按钮
1018
+ showEnableButton(entity) {
1019
+ const gridParams = store.get(this.storeId)
1020
+ if (isHasOptionFunction('showEnableButton', this.storeId)) {
1021
+ return gridParams.options.showEnableButton.call(this, entity)
1022
+ }
1023
+ return false
1024
+ },
1025
+ // 启用禁用按钮显示状态
1026
+ changeState(entity) {
1027
+ const gridParams = store.get(this.storeId)
1028
+ if (isHasOptionFunction('changeState', this.storeId)) {
1029
+ return gridParams.options.changeState.call(this, entity)
1030
+ }
1031
+ return false
1032
+ },
1033
+ },
1034
+ emits: [
1035
+ 'sort-change',
1036
+ ,
1037
+ 'click',
1038
+ 'afterDrag',
1039
+ 'unselect',
1040
+ 'select',
1041
+ 'cancel-search',
1042
+ 'add',
1043
+ ,
1044
+ ],
1045
+ }
1046
+ </script>
1047
+
1048
+ <style lang="scss" rel="stylesheet/scss" scoped>
1049
+ .nine-grid-area {
1050
+ padding: 10px;
1051
+
1052
+ .el-row {
1053
+ margin-bottom: 20px;
1054
+
1055
+ &:last-child {
1056
+ margin-bottom: 0;
1057
+ }
1058
+ }
1059
+
1060
+ .el-col-5 {
1061
+ width: 20%;
1062
+ max-width: 20%;
1063
+ padding-left: 12px;
1064
+ padding-right: 12px;
1065
+ }
1066
+
1067
+ .el-col {
1068
+ border-radius: 4px;
1069
+ margin-bottom: 10px;
1070
+ }
1071
+
1072
+ .name {
1073
+ font-size: 12px;
1074
+ color: #555;
1075
+ float: left;
1076
+ width: 80%;
1077
+ text-align: left;
1078
+ }
1079
+
1080
+ .bottom {
1081
+ // margin-top: 13px;
1082
+ line-height: 13px;
1083
+ // background: aquamarine;
1084
+ }
1085
+
1086
+ .state {
1087
+ font-size: 12px;
1088
+ margin-top: 1.5px;
1089
+ float: right;
1090
+ line-height: 1;
1091
+ display: flex;
1092
+ align-items: right;
1093
+ color: #999;
1094
+ width: 20%;
1095
+ text-align: right;
1096
+ }
1097
+
1098
+ .image {
1099
+ width: 100%;
1100
+ display: block;
1101
+ height: 200px;
1102
+ }
1103
+
1104
+ .clearfix:before,
1105
+ .clearfix:after {
1106
+ display: table;
1107
+ content: '';
1108
+ }
1109
+
1110
+ .clearfix:after {
1111
+ clear: both;
1112
+ }
1113
+
1114
+ .input-with-select {
1115
+ // background-color: #fff;
1116
+ width: 200px;
1117
+ float: right;
1118
+ }
1119
+
1120
+ .popContainer {
1121
+ position: absolute;
1122
+ width: 23.15%;
1123
+ display: block;
1124
+ height: 200px;
1125
+ background: rgba(0, 0, 0, 0.5);
1126
+ text-align: right;
1127
+ }
1128
+
1129
+ .fade-enter-active,
1130
+ .fade-leave-active {
1131
+ transition: opacity 0.5s;
1132
+ }
1133
+
1134
+ .fade-enter,
1135
+ .fade-leave-to {
1136
+ opacity: 0;
1137
+ }
1138
+
1139
+ .icons {
1140
+ color: #adb5bd;
1141
+ margin: 10px 10px 0px 0px;
1142
+ cursor: pointer;
1143
+ }
1144
+
1145
+ .release-status {
1146
+ display: block;
1147
+ width: 8px;
1148
+ height: 8px;
1149
+ margin-right: 8px;
1150
+ border-radius: 100%;
1151
+ }
1152
+
1153
+ .add-screen {
1154
+ display: flex;
1155
+ flex-direction: column;
1156
+ justify-content: center;
1157
+ align-items: center;
1158
+ cursor: pointer;
1159
+ height: 160px;
1160
+ // background-color: #fff;
1161
+ // border: 1px solid #7693f5;
1162
+ // box-shadow: 0 2px 8px 0 rgba(104,130,218,.4);
1163
+ font-size: 12px;
1164
+ color: #666666;
1165
+ font-family: Source Han Sans CN;
1166
+ font-weight: regular;
1167
+ font-size: 14px;
1168
+ line-height: 14px;
1169
+ letter-spacing: 0px;
1170
+ text-align: left;
1171
+ }
1172
+
1173
+ .el-divider--horizontal {
1174
+ margin: 5px 0;
1175
+ }
1176
+
1177
+ .button-style {
1178
+ margin-top: 28px;
1179
+ color: #606266;
1180
+ font-family: Source Han Sans CN;
1181
+ font-weight: regular;
1182
+ font-size: 14px;
1183
+ line-height: 14px;
1184
+ letter-spacing: 0px;
1185
+ text-align: left;
1186
+ }
1187
+ }
1188
+ </style>