@tongfun/tf-widget 0.1.18 → 0.1.19

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.
@@ -22,14 +22,14 @@
22
22
  <el-button v-debounce type="primary" size="mini" @click="refresh(false,true)">刷新 </el-button>
23
23
  <!-- <el-button type="primary" size="mini">批改</el-button> -->
24
24
  <slot name="importAndExport" />
25
- <slot name="buttons" />
25
+ <slot name="buttons" :ids="ids" :rows="selectedRows" />
26
26
  </div>
27
27
 
28
28
  <!-- 搜索输入框 -->
29
- <TListSearch class="common-table-buttons-search" @search="handleSuggestMultiCondition($event)" />
29
+ <TListSearch ref="tListSearchRef" class="common-table-buttons-search" @search="handleSuggestMultiCondition($event)" />
30
30
  </div>
31
31
  <!--过滤方案-->
32
- <Tplan :fields-option="tableLayout" @change="handlePlanConditionChange" />
32
+ <Tplan ref="TplanRef" :fields-option="tableLayout" @change="handlePlanConditionChange" />
33
33
  </div>
34
34
 
35
35
  <!--
@@ -51,12 +51,13 @@
51
51
  @dbRowClick 也是双击事件,但是当前行的数据被事件发射出来
52
52
  -->
53
53
  <Ttable
54
+ ref="TtableRef"
54
55
  class="t-table"
55
56
  :layout="tableLayout"
56
57
  :sum="tableSum"
57
58
  show-summary
58
59
  :data="tableData"
59
- :disable-sum="disableSum"
60
+ :enable-sum="enableSum"
60
61
  :enable-group="enableGroup"
61
62
  enable-group-edit
62
63
  :page-size="query.pageSize"
@@ -119,7 +120,7 @@ export default {
119
120
  type: Boolean,
120
121
  default: false
121
122
  },
122
- disableSum: {
123
+ enableSum: {
123
124
  type: Boolean,
124
125
  default: false
125
126
  }
@@ -18,8 +18,8 @@ const typeEnum = {
18
18
  ],
19
19
 
20
20
  /**
21
- * 时间类型
22
- */
21
+ * 时间类型
22
+ */
23
23
  // 短时间
24
24
  date: [
25
25
  { label: '大于', value: 'TIME_MORE_SHORT' },
@@ -62,9 +62,8 @@ const typeEnum = {
62
62
  ],
63
63
 
64
64
  /**
65
- * 枚举类型
66
- *
67
- */
65
+ * 枚举类型
66
+ */
68
67
  enum: [
69
68
  { label: '等于', value: 'ENUM_EQUAL', strict: true },
70
69
  { label: '不等于', value: 'ENUM_UNEQUAL', isFrezz: true },
@@ -73,8 +72,8 @@ const typeEnum = {
73
72
  ],
74
73
 
75
74
  /**
76
- * 数字类型
77
- */
75
+ * 数字类型
76
+ */
78
77
  number: [
79
78
  { label: '大于', value: 'NUMBER_MORE' },
80
79
  { label: '大于等于', value: 'NUMBER_MORE_EQUAL' },
@@ -9,6 +9,9 @@ export default {
9
9
  methods: {
10
10
  // 跳转到新增页面
11
11
  insert () {
12
+ if (this.$listeners.insert) {
13
+ return this.$emit('insert')
14
+ }
12
15
  const randomStr = Math.random().toString(36).slice(8)
13
16
  this.$router.replace(`${this.$route.path}/insert/${randomStr}`)
14
17
  },
@@ -20,6 +23,9 @@ export default {
20
23
  if (this.selectedRows.length > 1) {
21
24
  return this.$message.warning('只允许选择一条数据')
22
25
  }
26
+ if (this.$listeners.update) {
27
+ return this.$emit('update', this.selectedRows[0])
28
+ }
23
29
  const randomStr = Math.random().toString(36).slice(8)
24
30
  this.$router.replace(`${this.$route.path}/update/${randomStr}/${this.ids[0]}`)
25
31
  },
@@ -36,9 +42,7 @@ export default {
36
42
  }).then(async () => {
37
43
  const { code, msg } = await del({
38
44
  target: this.target,
39
- params: {
40
- ids: this.ids.join(',')
41
- }
45
+ ids: this.ids
42
46
  })
43
47
  if (code !== 0) {
44
48
  return this.$message.error(msg)
@@ -64,12 +68,24 @@ export default {
64
68
  this.syncData.tableSelectionClear = false
65
69
  }
66
70
  if (clearCondition) {
67
- this.query.conditionAlwaysList = []
71
+ // 清空右上角搜索框的条件
72
+ this.$refs.tListSearchRef.reset()
73
+ this.searchSuggestCondition = []
74
+
75
+ // 清空分组条件
68
76
  this.query.conditionGroup = null
69
- this.query.conditionMultiList = []
77
+
78
+ // 清空表头条件
79
+ // 清空过滤器显示状态,和快捷过滤条件缓存,通过事件方式将操作改为异步提升速度(好像也没有提升多少)
70
80
  this.query.conditionQuickList = []
81
+ this.$refs.TtableRef.$emit('headConditionClear')
82
+
71
83
  this.query.pageNum = 1
72
84
  this.query.pageSize = 200
85
+
86
+ // 通知方案切换到默认方案 ,然后触发查询
87
+ this.$refs.TplanRef.resetToDefaultPlan()
88
+ return
73
89
  }
74
90
  this.getTableData(false, true)
75
91
  }
@@ -13,6 +13,11 @@ export default {
13
13
  return {
14
14
  value: ''
15
15
  }
16
+ },
17
+ methods: {
18
+ reset () {
19
+ this.value = ''
20
+ }
16
21
  }
17
22
 
18
23
  }
@@ -26,7 +31,6 @@ export default {
26
31
  border:none ;
27
32
  border-radius: 0;
28
33
  border-bottom: 1px solid #a7a1a1;
29
-
30
34
  }
31
35
  }
32
36
  </style>
@@ -30,8 +30,8 @@
30
30
  :visible.sync="showExpanse"
31
31
  :plan-names="planNameList"
32
32
  :content="currentPlan"
33
- @listChange="handleListChange"
34
- @change="handleChange"
33
+ @listChange="getFilterPlan"
34
+ @change="$emit('change',$event)"
35
35
  />
36
36
  </div>
37
37
  </template>
@@ -93,7 +93,7 @@ export default {
93
93
  methods: {
94
94
  /**
95
95
  * 获取方案列表
96
- * 并切换到指定方案(选中状态)
96
+ * 并切换到指定方案(为选中状态)
97
97
  */
98
98
  async getFilterPlan (selectId) {
99
99
  const res = await getFilterPlan(this.target)
@@ -102,7 +102,6 @@ export default {
102
102
  }
103
103
  this.planList = res.data
104
104
  this.currentPlanId = selectId || this.planList.find(item => item.isDefault).id
105
- !selectId && this.$refs.planContentRef.$emit('doSearch')
106
105
  },
107
106
 
108
107
  /**
@@ -112,6 +111,18 @@ export default {
112
111
  this.getFilterPlan(planId)
113
112
  },
114
113
 
114
+ /**
115
+ * 将方案重置到默认方案
116
+ */
117
+ resetToDefaultPlan () {
118
+ const defaultPlanContent = this.planList.find(item => item.isDefault)
119
+ const defaultPlanId = defaultPlanContent?.id
120
+ if (this.currentPlanId === defaultPlanId) {
121
+ return this.$refs.planContentRef.loadPlanContent(defaultPlanContent, true)
122
+ }
123
+ this.currentPlanId = defaultPlanId
124
+ },
125
+
115
126
  /**
116
127
  * 方案被点击切换方法并查询数据
117
128
  */
@@ -120,15 +131,9 @@ export default {
120
131
  return
121
132
  }
122
133
  this.currentPlanId = planId
123
- this.$refs.planContentRef.$emit('doSearch')
134
+ // this.$refs.planContentRef.$emit('doSearch')
124
135
  },
125
136
 
126
- /**
127
- *
128
- */
129
- handleChange (condition) {
130
- this.$emit('change', condition)
131
- },
132
137
  /**
133
138
  * 方案列表的拖动
134
139
  */
@@ -86,7 +86,6 @@ export default {
86
86
  },
87
87
  data () {
88
88
  return {
89
- doSearch: false,
90
89
  errorMsg: '',
91
90
  planContent: {
92
91
  name: '',
@@ -98,29 +97,23 @@ export default {
98
97
  inject: ['target'],
99
98
  watch: {
100
99
  content (newValue) {
101
- const contentCopy = JSON.parse(JSON.stringify(newValue))
102
- // 后端大佬骗人,高级过滤条件没有值不一定都是空数组,还有可能是null
100
+ this.loadPlanContent(newValue)
101
+ }
102
+ },
103
+ methods: {
104
+ // 加载一个方案数据,处理方案的数据,并发射条件变更事件
105
+ loadPlanContent (content, immediate = false) {
106
+ const contentCopy = JSON.parse(JSON.stringify(content))
103
107
  contentCopy.contentsList = contentCopy.contentsList || []
104
- // 后端大佬没有给常用默认值的时候,前端自行添加默认值
105
108
  for (const alwaysItem of contentCopy.schemeUsefulList) {
106
109
  if (!alwaysItem.values.length) {
107
110
  alwaysItem.values.push('-1')
108
111
  }
109
112
  }
110
-
111
113
  this.planContent = contentCopy
112
- if (this.doSearch) {
113
- this.conditionChange()
114
- this.doSearch = false
115
- }
116
- }
117
- },
118
- created () {
119
- this.$on('doSearch', () => {
120
- this.doSearch = true
121
- })
122
- },
123
- methods: {
114
+ this.conditionChange()
115
+ },
116
+ // 点击方案内容外侧收起方案详情弹窗
124
117
  handleClickOut () {
125
118
  if (!this.visible) return
126
119
  this.$emit('update:visible', false)
@@ -8,10 +8,11 @@
8
8
  <!-- 表格记录 -->
9
9
  <div class="t-table-right">
10
10
  <TableRecords
11
+ ref="tableRecordsRef"
11
12
  :layout="layout"
12
13
  :is-selector="isSelector"
13
14
  :sum="sum"
14
- :disable-sum="disableSum"
15
+ :enable-sum="enableSum"
15
16
  :data="data"
16
17
  :update-in-dialog="updateInDialog"
17
18
  :page-size="pageSize"
@@ -78,7 +79,7 @@ export default {
78
79
  type: Boolean,
79
80
  default: false
80
81
  },
81
- disableSum: {
82
+ enableSum: {
82
83
  type: Boolean,
83
84
  default: false
84
85
  }
@@ -88,6 +89,14 @@ export default {
88
89
 
89
90
  }
90
91
  },
92
+ created () {
93
+ this.$on('headConditionClear', () => {
94
+ this.$refs.tableRecordsRef.initTableFilterData()
95
+ })
96
+ },
97
+ beforeDestroy () {
98
+ this.$off('headConditionClear')
99
+ },
91
100
  provide () {
92
101
  return {
93
102
  enableGroupEdit: this.enableGroupEdit
@@ -4,7 +4,7 @@
4
4
  <el-input v-model="search" placeholder="请输入节点名称" />
5
5
 
6
6
  <!-- 节点展示 -->
7
- <el-scrollbar class="scrollbar">
7
+ <el-scrollbar :class="[queryType === 'LIST' ? 'scrollbar' :'in-selector']">
8
8
  <el-tree
9
9
  ref="treeRef"
10
10
  :data="dataTree"
@@ -75,7 +75,7 @@ export default {
75
75
  this.$refs.treeRef.filter(value)
76
76
  }
77
77
  },
78
- inject: ['target'],
78
+ inject: ['target', 'queryType'],
79
79
  created () {
80
80
  this.getGroupTree()
81
81
  },
@@ -154,16 +154,17 @@ export default {
154
154
 
155
155
  <style scoped lang='less'>
156
156
  .table-group {
157
- height:100%;
157
+ height:70vh;
158
158
  .scrollbar{
159
- height:calc(100% - 40px);
159
+ height:70vh;
160
+ }
161
+ .in-selector {
162
+ height:53vh;
160
163
  }
161
164
  ::v-deep .el-scrollbar__wrap {
162
165
  overflow-x:hidden;
163
166
  }
164
167
  background-color: #fff;
165
- // margin-right:10px;
166
- // border-radius:5px;
167
168
  box-sizing: border-box;
168
169
  border: 1px solid #e8eaec;
169
170
  border-right: 0px;
@@ -2,7 +2,6 @@
2
2
  <!-- 排序的提示插件 -->
3
3
  <div>
4
4
  <el-popover
5
-
6
5
  :value="item.isShowFilter"
7
6
  width="200"
8
7
  trigger="manual"
@@ -21,7 +20,6 @@
21
20
  <div class="list-icon">
22
21
  <i v-show="radioItem.value === tableFilterData[item.field].operator" class="el-icon-check" />
23
22
  </div>
24
-
25
23
  </div>
26
24
  </div>
27
25
  <div class="context-list header-input">
@@ -55,7 +53,6 @@
55
53
  <div class="list-icon">
56
54
  <i v-show="tableFilterData[item.field].value.includes(option.enumId)" class="el-icon-check" />
57
55
  </div>
58
-
59
56
  </div>
60
57
  </div>
61
58
  <div class="context-list">
@@ -71,7 +68,6 @@
71
68
  style=""
72
69
  @mouseup.stop="handleFilterClick"
73
70
  />
74
-
75
71
  </el-popover>
76
72
  </div>
77
73
  </template>
@@ -1,5 +1,7 @@
1
1
  <template>
2
2
  <div ref="tableRecords" class="table-records">
3
+ <!-- {{ tableFilterData }} -->
4
+ <!-- {{ layout }} -->
3
5
  <div class="table-wrapper">
4
6
  <ux-grid
5
7
  ref="dataRecordsRef"
@@ -8,7 +10,7 @@
8
10
  size="mini"
9
11
  column-key
10
12
  beautify-table
11
- :show-summary="showSummary && !disableSum"
13
+ :show-summary="showSummaryComp"
12
14
  :summary-method="summaryMethod"
13
15
  :width-resize="true"
14
16
  :highlight-current-row="false"
@@ -107,7 +109,7 @@ export default {
107
109
  type: Boolean,
108
110
  default: false
109
111
  },
110
- disableSum: {
112
+ enableSum: {
111
113
  type: Boolean,
112
114
  default: false
113
115
  }
@@ -124,21 +126,21 @@ export default {
124
126
  }
125
127
  },
126
128
  computed: {
127
-
129
+ showSummaryComp () {
130
+ return this.queryType === 'LIST'
131
+ }
128
132
  },
129
133
  watch: {
130
134
  layout: {
131
135
  handler (newVal) {
132
- // 初始化绑定tableFilterData
133
- // 如果tableFilterData有内容则抛出
134
136
  if (Object.keys(this.tableFilterData).length !== 0) {
135
137
  return
136
138
  }
137
- // 初始化tableFilterData的数据
138
- newVal.length > 0 && newVal.forEach(e => {
139
- if (e.isId) this.idField = e.field
140
- this.$set(this.tableFilterData, e.field, { field: e.field, operator: '', value: '', fieldType: e.componentType })
141
- })
139
+ this.initTableFilterData()
140
+ // newVal.length > 0 && newVal.forEach(e => {
141
+ // if (e.isId) this.idField = e.field
142
+ // this.$set(this.tableFilterData, e.field, { field: e.field, operator: '', value: '', fieldType: e.componentType })
143
+ // })
142
144
  },
143
145
  immediate: true
144
146
  },
@@ -175,10 +177,18 @@ export default {
175
177
  }
176
178
  },
177
179
  methods: {
178
- handleClearSelected () {
179
- this.$refs.dataRecordsRef.clearSelection()
180
- this.clearSelectedRows()
180
+ /**
181
+ * 表头过滤
182
+ */
183
+ // 初始化或清空表头过滤的缓存容器
184
+ initTableFilterData () {
185
+ this.layout.length && this.layout.forEach(e => {
186
+ if (e.isId) this.idField = e.field
187
+ this.$set(this.tableFilterData, e.field, { field: e.field, operator: '', value: '', fieldType: e.componentType })
188
+ this.$set(e, 'isShowIcon', false)
189
+ })
181
190
  },
191
+ // 表头过滤触发了过滤事件
182
192
  filterClick (value, index) {
183
193
  if (!this.isSingleFilter) {
184
194
  return
@@ -189,6 +199,10 @@ export default {
189
199
  }
190
200
  this.filterSelectedId = index
191
201
  },
202
+ handleClearSelected () {
203
+ this.$refs.dataRecordsRef.clearSelection()
204
+ this.clearSelectedRows()
205
+ },
192
206
  // 清空已选
193
207
  clearSelectedRows () {
194
208
  this.selectedRows.splice(0, this.selectedRows.length)
@@ -276,7 +290,10 @@ export default {
276
290
  ::v-deep .plTableBox{
277
291
  .elx-table--body-wrapper{
278
292
  height: calc(90vh - 230px );//修改以适应合计行的添加,
279
- // margin-bottom: 10px;
293
+ overflow-x:hidden;
294
+ }
295
+ .elx-table:not(.is--empty).show--foot.scroll--x .elx-table--body-wrapper{
296
+ overflow-x: hidden !important;
280
297
  }
281
298
  .elx-table--footer-wrapper{
282
299
  margin-top: 0px!important;
@@ -317,8 +334,4 @@ export default {
317
334
  }
318
335
  }
319
336
  }
320
- ::v-deep .elx-table:not(.is--empty).show--foot.scroll--x .elx-table--body-wrapper{
321
- overflow-x: hidden !important;
322
- }
323
-
324
337
  </style>
@@ -28,6 +28,7 @@
28
28
  :modal-append-to-body="modalAppendToBody"
29
29
  @open="getTableData"
30
30
  >
31
+ <!-- {{ limitation }} -->
31
32
  <div class="dataDialog">
32
33
  <Ttable
33
34
  class="t-table"
@@ -222,6 +223,7 @@ export default {
222
223
  position: relative;
223
224
  .plTableBox .elx-table--body-wrapper{
224
225
  height: calc(59vh - 80px);
226
+ overflow-x:scroll;
225
227
  }
226
228
  .el-pagination{
227
229
  right: 0;
@@ -142,13 +142,7 @@ export default {
142
142
  },
143
143
  computed: {
144
144
  groupList () {
145
- let list = []
146
- if (this.data && this.data[0]) {
147
- list = this.data[0]
148
- }
149
- // todo: 下面的方式eslint报错,而且下面的是啥逻辑啊,需要追踪数据后确定
150
- // return this.data[0] && this.data || []
151
- return list
145
+ return (this.data && this.data[0]) || []
152
146
  },
153
147
  selectMap () {
154
148
  return this.createSelectMap(this.data)
@@ -32,7 +32,7 @@
32
32
 
33
33
  <script>
34
34
  import { getGroupTree } from '@/api/tableV3.js'
35
- import GroupDialog from '../children/group-components/group-dialog.vue'
35
+ import GroupDialog from './group-components/group-dialog'
36
36
  // 使用该组件必穿一个target
37
37
 
38
38
  export default {
@@ -34,7 +34,7 @@
34
34
  :index="secondMenuItem.path"
35
35
  >
36
36
  <svg-icon
37
- :icon-class="firstMenuItem.icon"
37
+ :icon-class="secondMenuItem.icon"
38
38
  style="height: 15px; width: 15px; margin-right: 10px"
39
39
  />
40
40
  <span>{{ secondMenuItem.title }}</span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tongfun/tf-widget",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "tf-widget",
5
5
  "main": "lib/tf-widget.umd.js",
6
6
  "private": false,
@@ -6,7 +6,7 @@ export default {
6
6
  /**
7
7
  * 通用过滤查询参数
8
8
  */
9
- // 搜索建议和右上角全局搜索的快速搜索条件(因为接口进行了复用)
9
+ // 被指定为搜索建议的查询的字段列表
10
10
  suggestFieldList: [],
11
11
  // 搜索建议的高级条件
12
12
  searchSuggestCondition: [],
@@ -96,7 +96,6 @@ export default {
96
96
  multiResult.forEach((item, index) => {
97
97
  item.sort = index
98
98
  })
99
-
100
99
  return multiResult
101
100
  },
102
101
  // 限定查询范围的条件
@@ -106,14 +105,14 @@ export default {
106
105
  }
107
106
  const result = []
108
107
  for (const key in this.limitation) {
109
- const fieldItem = this.tableLayout.find(v => v.filed === key)
108
+ const fieldItem = this.tableLayout.find(v => v.field === key)
110
109
  if (!fieldItem) continue
111
110
 
112
111
  let value = ''
113
112
  if (fieldItem.componentValueType === 'PARAM_BASIC') {
114
- value = this.limitation[key].name
113
+ value = this.limitation[key]?.name
115
114
  } else if (fieldItem.componentValueType === 'PARAM_ENUM') {
116
- value = this.limitation[key].id
115
+ value = this.limitation[key]?.id
117
116
  } else {
118
117
  value = this.limitation[key]
119
118
  }
@@ -175,7 +174,7 @@ export default {
175
174
  pageSize: 20
176
175
  }
177
176
 
178
- !this.disableSum && getSum && await this.getTableSum()
177
+ this.enableSum && getSum && await this.getTableSum()
179
178
  try {
180
179
  // 查询数据之前赋值高级过滤条件
181
180
  queryParams.conditionMultiList = this.multiCondition
@@ -188,12 +187,13 @@ export default {
188
187
  if (isSuggest) {
189
188
  return res.data.record
190
189
  }
191
- this.syncData.tableLoading = false
192
190
  this.tableData.total = Number(res.data.total)
193
191
  this.tableData.records = res.data.record
194
192
  } catch (err) {
195
193
  // 恢复成默认值
196
194
  this.syncData.tableSelectionClear = true
195
+ } finally {
196
+ this.syncData.tableLoading = false
197
197
  }
198
198
  },
199
199
  // 表格数据合计
@@ -268,6 +268,7 @@ export default {
268
268
  // 每页条数变化
269
269
  handleSizeChange (newSize) {
270
270
  this.query.pageSize = newSize
271
+ this.query.pageNum = 1
271
272
  this.getTableData(false, false)
272
273
  },
273
274
  // 翻页
@@ -1 +0,0 @@
1
- .el-popover .context-list .list-item[data-v-fcd31cd8]{display:flex;margin:1px 0;padding:2px 8px;justify-content:space-between}.el-popover .context-list .list-item[data-v-fcd31cd8]:hover{background-color:#e7ebfd}.el-popover .context-list .list-item-active[data-v-fcd31cd8]{color:#3b68fc;background-color:#e7ebfd}.el-popover .context-list[data-v-fcd31cd8] .el-input .el-input__inner{height:30px}.el-popover .context-list[data-v-fcd31cd8]:last-child{margin-top:4px;width:100%;display:flex;justify-content:space-between}.el-popover .header-input[data-v-fcd31cd8]{margin-top:5px}.el-popover .filter-icon[data-v-fcd31cd8]{outline:none;width:15px;height:15px;cursor:pointer}