|
@@ -45,7 +45,7 @@
|
|
|
</div>
|
|
|
|
|
|
<!-- 关键词列表 -->
|
|
|
- <el-table v-loading="isLoading" :data="list" border @selection-change="handleSelectionChange">
|
|
|
+ <el-table ref="table" v-loading="isLoading" :data="list" border @selection-change="handleSelectionChange">
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
<el-table-column label="序号" :index="indexMethod" type="index" sortable="custom" align="center" width="80" />
|
|
|
<el-table-column prop="keyword" label="关键词" align="center" />
|
|
@@ -86,7 +86,7 @@
|
|
|
|
|
|
<script>
|
|
|
import SearchModel from '@/components/SearchModel'
|
|
|
-import { parseTime } from '@/utils'
|
|
|
+import { getYestodayTime, parseTime } from '@/utils'
|
|
|
import { fetchKeywordList, joinKeywordLibrary } from '@/api/library/keyword'
|
|
|
import { export_json_to_excel } from '@/vendor/Export2Excel'
|
|
|
|
|
@@ -134,9 +134,7 @@ export default {
|
|
|
{
|
|
|
text: '昨天',
|
|
|
onClick(picker) {
|
|
|
- const end = new Date()
|
|
|
- const start = new Date()
|
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24)
|
|
|
+ const { start, end } = getYestodayTime()
|
|
|
picker.$emit('pick', [start, end])
|
|
|
}
|
|
|
}
|
|
@@ -215,13 +213,19 @@ export default {
|
|
|
// 添加到标签库提交
|
|
|
async addLibrarySubmit(row) {
|
|
|
const keywords = row instanceof Event ? this.currentList : [].concat(row)
|
|
|
- const ids = keywords.map((item) => item.id).join(',')
|
|
|
+ let ids = keywords.filter((item) => item.labelStatus === 0).map((item) => item.id)
|
|
|
+ if (keywords.length > ids.length) {
|
|
|
+ this.$refs.table.clearSelection()
|
|
|
+ return this.$message.info('已添加到标签库的标签不可重复添加')
|
|
|
+ }
|
|
|
+ ids = ids.join(',')
|
|
|
try {
|
|
|
await joinKeywordLibrary({ id: ids })
|
|
|
this.$message.success('添加关键词库成功')
|
|
|
keywords.forEach((item) => {
|
|
|
item.labelStatus = 1
|
|
|
})
|
|
|
+ this.$refs.table.clearSelection()
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
}
|
|
@@ -277,6 +281,10 @@ export default {
|
|
|
|
|
|
indexMethod(index) {
|
|
|
return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
|
|
|
+ },
|
|
|
+
|
|
|
+ isSelectable(row) {
|
|
|
+ return row.labelStatus === 0
|
|
|
}
|
|
|
}
|
|
|
}
|