vue2-client 1.8.79 → 1.8.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.8.79",
3
+ "version": "1.8.81",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -42,7 +42,6 @@ export default {
42
42
  pieChart: null,
43
43
  columnChart: null,
44
44
  lineChart: null,
45
- intervalId: null,
46
45
  componentKey: 0,
47
46
  commonOptions: {
48
47
  tooltip: {
@@ -63,14 +62,6 @@ export default {
63
62
  },
64
63
  mounted () {
65
64
  this.initData()
66
- // 定时刷新图表
67
- this.intervalId = setInterval(() => {
68
- this.renderLineChart()
69
- }, 3000)
70
- },
71
- beforeDestroy () {
72
- // 组件销毁时清除定时器
73
- clearInterval(this.intervalId)
74
65
  },
75
66
  props: {
76
67
  rawData: {
@@ -97,19 +88,33 @@ export default {
97
88
  },
98
89
  initializeOptions () {
99
90
  if (this.rawData.length > 0) {
100
- const firstRow = this.rawData[0]
101
- this.groupOptions = Object.keys(firstRow).filter(key => typeof firstRow[key] === 'string' ||
91
+ const row = this.rawData[0]
92
+ this.groupOptions = Object.keys(row).filter(key => typeof row[key] === 'string' ||
102
93
  this.isYearArray(this.rawData, key))
103
- this.valueOptions = Object.keys(firstRow).filter(key => typeof firstRow[key] === 'number' &&
104
- !this.isYearArray(this.rawData, key))
94
+ this.valueOptions = Object.keys(row).filter(key => {
95
+ return !isNaN(parseFloat(row[key])) && isFinite(row[key]) && !this.isYear(row[key])
96
+ })
97
+ console.warn(this.valueOptions)
105
98
  }
106
99
  },
107
100
  isYearArray (arr, key) {
108
- return arr.every(item => this.isYear(item[key]))
101
+ if (arr.some(item => this.isYear(item[key]))) {
102
+ this.updateNonYearItems(arr, key)
103
+ return true
104
+ }
105
+ return false
106
+ },
107
+ // 修改数组中不满足条件的元素的特定键值为1970
108
+ updateNonYearItems (arr, key) {
109
+ arr.forEach(item => {
110
+ if (!this.isYear(item[key])) {
111
+ item[key] = 1970
112
+ }
113
+ })
109
114
  },
110
115
  // 判断数值或者字符串是不是年份
111
116
  isYear (value) {
112
- return /^20\d{2}$/.test(value)
117
+ return /^(19|20)\d{2}$/.test(value)
113
118
  },
114
119
  updateCharts () {
115
120
  this.renderPieChart()
@@ -28,7 +28,7 @@ export default {
28
28
  props: {
29
29
  tableData: {
30
30
  type: Array,
31
- required: true
31
+ default: () => ([])
32
32
  }
33
33
  },
34
34
  watch: {
@@ -43,6 +43,9 @@ export default {
43
43
  async initData () {
44
44
  try {
45
45
  // 从数据第一项推断列信息
46
+ if (this.tableData.length === 0) {
47
+ return
48
+ }
46
49
  const sample = this.tableData[0]
47
50
  this.tableColumns = Object.keys(sample).map(key => ({
48
51
  title: key, // 使用键名作为列标题
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <a-card class="question-history" id="question-history" size="small" :bordered="false" :bodyStyle="{ height:'100%', overflowY: 'auto'}">
3
- <a-tabs v-model="activeKey" :tabBarStyle="{ textAlign: 'center',height:'100%',postion:'' }" tabPosition="top">
3
+ <a-tabs v-model="activeKey" :tabBarStyle="{ textAlign: 'center',height:'100%' }" tabPosition="top">
4
4
  <a-tab-pane key="1" tab="对话历史">
5
5
  <a-list item-layout="horizontal" :data-source="questions">
6
6
  <a-list-item
@@ -95,6 +95,8 @@ export default {
95
95
  this.favorites.push(datum.data)
96
96
  }
97
97
  }
98
+ this.questions.sort((a, b) => new Date(b.date) - new Date(a.date))
99
+ this.favorites.sort((a, b) => new Date(b.date) - new Date(a.date))
98
100
  }
99
101
  )
100
102
  },
@@ -1,13 +1,21 @@
1
1
  <template>
2
2
  <div class="search-bar">
3
+ <a-select default-value="all" class="select" @change="handleChange">
4
+ <a-select-option v-for="d in selectOption" :key="d.value">
5
+ {{ d.text }}
6
+ </a-select-option>
7
+ </a-select>
3
8
  <a-auto-complete
4
9
  v-model="searchInput"
5
10
  class="search-input"
11
+ ref="autoComplete"
6
12
  placeholder="请输入查询的内容"
7
13
  option-label-prop="title"
14
+ :open="true"
8
15
  @select="onSearch"
9
- @search="handleSearch"
16
+ @search="fetchFunction"
10
17
  >
18
+ <a-spin v-if="searching" slot="notFoundContent" size="small" />
11
19
  <template slot="dataSource">
12
20
  <a-select-option v-for="item in dataSourceResults" :key="item.category" :title="item.category">
13
21
  <span>{{ item.category.substr(0,item.category.indexOf(searchInput)) }}</span>
@@ -33,19 +41,30 @@
33
41
  <script>
34
42
  import FavoriteList from './FavoriteList.vue'
35
43
  import { post } from '@vue2-client/services/api'
44
+ import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
36
45
 
37
46
  export default {
38
47
  name: 'SearchBar',
39
48
  components: { FavoriteList },
40
49
  data () {
50
+ // 检索去抖
51
+ this.fetchFunction = debounce(this.fetchFunction, 300)
41
52
  return {
53
+ // 最后检索版本
54
+ lastFetchId: 0,
55
+ searching: false,
42
56
  searchInput: '', // 绑定搜索输入框的数据,
43
57
  favoriteState: false, // 是否收藏
44
58
  obj: undefined,
45
59
  favoriteListVisible: false,
46
60
  loading: false,
47
- dataSource: [],
48
61
  dataSourceResults: [],
62
+ selectOption: [
63
+ { value: 'all', text: '全部' },
64
+ { value: '合同', text: '合同类' },
65
+ { value: '项目', text: '项目类' },
66
+ { value: '人员', text: '人员类' },
67
+ ]
49
68
  }
50
69
  },
51
70
  computed: {
@@ -54,13 +73,39 @@ export default {
54
73
  this.init()
55
74
  },
56
75
  methods: {
57
- handleSearch (value) {
58
- if (value) {
59
- this.dataSourceResults = this.dataSource.filter(
60
- item => item.category.indexOf(value) !== -1
61
- )
76
+ handleChange (value) {
77
+ if (value === 'all') {
78
+ this.searchInput = ''
62
79
  } else {
63
- this.dataSourceResults = []
80
+ this.searchInput = value
81
+ }
82
+ this.dataSourceResults = []
83
+ this.fetchFunction(this.searchInput)
84
+ this.$refs.autoComplete.focus()
85
+ },
86
+ fetchFunction (value) {
87
+ this.dataSourceResults = []
88
+ if (value) {
89
+ this.searching = true
90
+ this.lastFetchId += 1
91
+ const fetchId = this.lastFetchId
92
+ post('/api/af-system/logic/openapi/getCommonData', {
93
+ type: 'ai-question',
94
+ content: value
95
+ }).then(res => {
96
+ if (fetchId !== this.lastFetchId) {
97
+ return
98
+ }
99
+ if (res != null && Array.isArray(res)) {
100
+ // 提取 json 中的 question, 并去重
101
+ this.dataSourceResults = res.map(item => JSON.parse(item.f_json).question)
102
+ .filter((item, index, arr) => arr.indexOf(item) === index)
103
+ .map(item => ({ category: item }))
104
+ console.warn(this.dataSourceResults)
105
+ }
106
+ }).finally(() => {
107
+ this.searching = false
108
+ })
64
109
  }
65
110
  },
66
111
  // 处理搜索操作
@@ -82,15 +127,6 @@ export default {
82
127
  }
83
128
  },
84
129
  init () {
85
- post('/api/af-system/logic/openapi/getCommonData', {
86
- type: 'ai-evaluation',
87
- content: '11'
88
- }).then(res => {
89
- // 提取 json 中的 question, 并去重
90
- this.dataSource = res.map(item => JSON.parse(item.f_json).question)
91
- .filter((item, index, arr) => arr.indexOf(item) === index)
92
- .map(item => ({ category: item }))
93
- })
94
130
  this.searchInput = ''
95
131
  this.obj = undefined
96
132
  this.favoriteState = false
@@ -143,6 +179,18 @@ export default {
143
179
  padding: 4px 80px 4px 40px;
144
180
  font-size: 16px;
145
181
  }
182
+ .select {
183
+ width: 100px;
184
+ height: 48px;
185
+ padding-right: 6px;
186
+ font-size: 16px;
187
+ text-align: center;
188
+ :deep(.ant-select-selection-selected-value) {
189
+ width: 100px;
190
+ height: 48px;
191
+ line-height: 48px;
192
+ }
193
+ }
146
194
  }
147
195
 
148
196
  </style>
@@ -121,6 +121,15 @@ export default {
121
121
  // age: Math.floor(Math.random() * 100) + 1
122
122
  // }
123
123
  // ]
124
+ // 保存到数据库中
125
+ post('/api/af-system/logic/openapi/addCommonData', {
126
+ type: 'ai-question',
127
+ content: {
128
+ uuid: uuid,
129
+ question: value,
130
+ date: formatDate('now')
131
+ }
132
+ })
124
133
  if (Array.isArray(res)) {
125
134
  this.addTab(uuid, value, res, false)
126
135
  } else {