vue2-client 1.8.47 → 1.8.49

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,130 +1,167 @@
1
- <template>
2
- <div class="search-bar">
3
- <a-input
4
- class="search-input"
5
- v-model="searchInput"
6
- placeholder="请输入查询的内容"
7
- @pressEnter="onSearch(searchInput)">
8
- </a-input>
9
- <a-button-group size="large" class="btn_group">
10
- <a-button @click="onSearch(searchInput)" :loading="loading">
11
- <a-icon type="search" />搜索
12
- </a-button>
13
- <a-tooltip>
14
- <template slot="title">
15
- 将该结果收藏到收藏夹
16
- </template>
17
- <a-button class="star_button" @click="onSaveToFavorites(undefined)">
18
- <a-icon type="star" v-show="!favoriteState"/>
19
- <a-icon type="star" v-show="favoriteState" theme="filled"/>
20
- </a-button>
21
- </a-tooltip>
22
- <a-tooltip>
23
- <template slot="title">
24
- 收藏夹
25
- </template>
26
- <a-popover @visibleChange="favoriteListVisibleAction" title="收藏夹" placement="bottomRight" trigger="click">
27
- <template slot="content">
28
- <FavoriteList ref="favoriteList" @saveToFavorites="onSaveToFavorites" @openFavorites="openFavorites"/>
29
- </template>
30
- <a-button>
31
- <a-icon type="menu" />
32
- </a-button>
33
- </a-popover>
34
- </a-tooltip>
35
- </a-button-group>
36
- </div>
37
- </template>
38
-
39
- <script>
40
- import FavoriteList from './FavoriteList.vue'
41
-
42
- export default {
43
- name: 'SearchBar',
44
- components: { FavoriteList },
45
- data () {
46
- return {
47
- searchInput: '', // 绑定搜索输入框的数据,
48
- favoriteState: false, // 是否收藏
49
- obj: undefined,
50
- favoriteListVisible: false,
51
- loading: false
52
- }
53
- },
54
- methods: {
55
- // 处理搜索操作
56
- onSearch (value) {
57
- this.loading = true
58
- // 触发父组件的搜索事件,传递搜索输入的值
59
- this.$emit('search', value, () => { this.loading = false })
60
- },
61
- // 处理打开收藏操作
62
- openFavorites (uuid) {
63
- this.$emit('openFavorites', uuid)
64
- },
65
- // 处理收藏操作
66
- onSaveToFavorites (uuid) {
67
- // 触发父组件的保存到收藏夹事件,传递当前搜索的uuid
68
- let thisUUid
69
- if (uuid) {
70
- thisUUid = uuid
71
- } else if (this.obj) {
72
- thisUUid = this.obj.uuid
73
- } else {
74
- thisUUid = undefined
75
- }
76
- this.$emit('saveToFavorites', thisUUid)
77
- },
78
- // 收藏夹显示隐藏的回调
79
- favoriteListVisibleAction (visible) {
80
- if (this.$refs.favoriteList && visible) {
81
- this.$refs.favoriteList.loadData()
82
- }
83
- },
84
- init () {
85
- this.searchInput = ''
86
- this.obj = undefined
87
- this.favoriteState = false
88
- },
89
- setObj (obj) {
90
- this.obj = obj
91
- this.searchInput = obj.question
92
- this.favoriteState = obj.isFavorite
93
- },
94
- setFavorite (uuid, isFavorite) {
95
- if (this.obj && uuid === this.obj.uuid) {
96
- this.favoriteState = isFavorite
97
- }
98
- this.favoriteListVisibleAction(true)
99
- }
100
- }
101
- }
102
- </script>
103
-
104
- <style lang="less" scoped>
105
- .search-bar {
106
- display: flex;
107
- justify-content: center;
108
- padding: 25px 0;
109
- margin-bottom: 20px;
110
- :deep(.ant-input) {
111
- padding: 4px 80px 4px 40px;
112
- height: 48px;
113
- font-size: 16px;
114
- }
115
- .btn_group {
116
- padding-left: 6px;
117
- :deep(.ant-btn) {
118
- height: 100%;
119
- color: #4F93FE;
120
- }
121
- .star_button {
122
- color: #ffba00;
123
- }
124
- }
125
- }
126
-
127
- .search-input {
128
- width: 40%;
129
- }
130
- </style>
1
+ <template>
2
+ <div class="search-bar">
3
+ <a-auto-complete
4
+ class="search-input"
5
+ placeholder="请输入查询的内容"
6
+ option-label-prop="title"
7
+ @select="onSearch"
8
+ @search="handleSearch"
9
+ >
10
+ <template slot="dataSource">
11
+ <a-select-option v-for="item in dataSourceResults" :key="item.category" :title="item.category">
12
+ <span>{{ item.category.substr(0,item.category.indexOf(searchInput)) }}</span>
13
+ <span style="color: red">{{ searchInput }}</span>
14
+ <span>{{ item.category.substr(item.category.indexOf(searchInput)+searchInput.length) }}</span>
15
+ </a-select-option>
16
+ </template>
17
+ <a-input
18
+ v-model="searchInput"
19
+ placeholder="请输入查询的内容"
20
+ @pressEnter="onSearch(searchInput)">
21
+ </a-input>
22
+ </a-auto-complete>
23
+ <a-button-group size="large" class="btn_group">
24
+ <a-button @click="onSearch(searchInput)" :loading="loading">
25
+ <a-icon type="search"/>
26
+ 搜索
27
+ </a-button>
28
+ </a-button-group>
29
+ </div>
30
+ </template>
31
+
32
+ <script>
33
+ import FavoriteList from './FavoriteList.vue'
34
+ import { post } from '@/services/api'
35
+
36
+ export default {
37
+ name: 'SearchBar',
38
+ components: { FavoriteList },
39
+ data () {
40
+ return {
41
+ searchInput: '', // 绑定搜索输入框的数据,
42
+ favoriteState: false, // 是否收藏
43
+ obj: undefined,
44
+ favoriteListVisible: false,
45
+ loading: false,
46
+ dataSource: [],
47
+ dataSourceResults: [],
48
+ }
49
+ },
50
+ computed: {
51
+ },
52
+ mounted () {
53
+ this.init()
54
+ },
55
+ methods: {
56
+ handleSearch (value) {
57
+ if (value) {
58
+ this.dataSourceResults = this.dataSource.filter(
59
+ item => item.category.indexOf(value) !== -1
60
+ )
61
+ } else {
62
+ this.dataSourceResults = []
63
+ }
64
+ },
65
+ // 处理搜索操作
66
+ onSearch (value) {
67
+ this.loading = true
68
+ // 触发父组件的搜索事件,传递搜索输入的值
69
+ this.$emit('search', value, () => {
70
+ this.loading = false
71
+ })
72
+ },
73
+ // // 处理打开收藏操作
74
+ // openFavorites (uuid) {
75
+ // this.$emit('openFavorites', uuid)
76
+ // },
77
+ // 收藏夹显示隐藏的回调
78
+ favoriteListVisibleAction (visible) {
79
+ if (this.$refs.favoriteList && visible) {
80
+ this.$refs.favoriteList.loadData()
81
+ }
82
+ },
83
+ init () {
84
+ post('/api/af-system/logic/openapi/getCommonData', {
85
+ type: 'ai-evaluation',
86
+ content: '11'
87
+ }).then(res => {
88
+ // todo docker 接口没更新 模拟数据
89
+ res.data = [
90
+ {
91
+ f_input_date: '2024-02-27 20:22:54',
92
+ id: 1,
93
+ f_json: '{"date":"2024-02-27 20:21:51","evaluation":true,"question":"查询近三个月各销售人员的销售情况","data":[],"uuid":"461fb4d7-1cc3-4959-82b7-899c6b66a25a","isFavorite":true}',
94
+ f_type: 'ai-evaluation'
95
+ },
96
+ {
97
+ f_input_date: '2024-02-27 20:22:54',
98
+ id: 1,
99
+ f_json: '{"date":"2024-02-27 20:21:51","evaluation":true,"question":"查询近三个月各销售人员的销售情况","data":[],"uuid":"461fb4d7-1cc3-4959-82b7-899c6b66a25a","isFavorite":true}',
100
+ f_type: 'ai-evaluation'
101
+ },
102
+ {
103
+ f_input_date: '2024-02-27 20:22:54',
104
+ id: 1,
105
+ f_json: '{"date":"2024-02-27 20:21:51","evaluation":true,"question":"查询近三个月各销售人员的销售情况","data":[],"uuid":"461fb4d7-1cc3-4959-82b7-899c6b66a25a","isFavorite":true}',
106
+ f_type: 'ai-evaluation'
107
+ }
108
+ ]
109
+ // 提取 json 中的 question, 并去重
110
+ this.dataSource = res.data.map(item => JSON.parse(item.f_json).question)
111
+ .filter((item, index, arr) => arr.indexOf(item) === index)
112
+ .map(item => ({ category: item }))
113
+ })
114
+ this.searchInput = ''
115
+ this.obj = undefined
116
+ this.favoriteState = false
117
+ },
118
+ setObj (obj) {
119
+ this.obj = obj
120
+ this.searchInput = obj.question
121
+ this.favoriteState = obj.isFavorite
122
+ },
123
+ setFavorite (uuid, isFavorite) {
124
+ if (this.obj && uuid === this.obj.uuid) {
125
+ this.favoriteState = isFavorite
126
+ }
127
+ this.favoriteListVisibleAction(true)
128
+ }
129
+ }
130
+ }
131
+ </script>
132
+
133
+ <style lang="less" scoped>
134
+ .search-bar {
135
+ display: flex;
136
+ justify-content: center;
137
+ padding: 25px 0;
138
+ margin-bottom: 20px;
139
+
140
+ :deep(.ant-input) {
141
+ padding: 4px 80px 4px 40px;
142
+ height: 48px;
143
+ font-size: 16px;
144
+ }
145
+
146
+ .btn_group {
147
+ padding-left: 6px;
148
+
149
+ :deep(.ant-btn) {
150
+ height: 100%;
151
+ color: #4F93FE;
152
+ }
153
+
154
+ .star_button {
155
+ color: #ffba00;
156
+ }
157
+ }
158
+
159
+ :deep(.ant-select-selection--single) {
160
+ height: 100%;
161
+ }
162
+ }
163
+
164
+ .search-input {
165
+ width: 40%;
166
+ }
167
+ </style>