|
@@ -14,7 +14,7 @@
|
|
|
</div>
|
|
|
<div class="filter-control">
|
|
|
<el-button type="primary" @click="getList">查询</el-button>
|
|
|
- <el-button v-permission="'tag:list:add'" type="primary" @click="selectionTagDialog = true">选择标签</el-button>
|
|
|
+ <el-button v-permission="'tag:list:add'" type="primary" @click="handleSelectionTagDialog">选择标签</el-button>
|
|
|
<el-button v-permission="'tag:list:del'" type="danger" :disabled="disabled" @click="handleDeleteTag">
|
|
|
删除
|
|
|
</el-button>
|
|
@@ -41,7 +41,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="添加时间" align="center" width="200">
|
|
|
<template slot-scope="{ row }">
|
|
|
- <span v-if="row.searchTime">{{ row.searchTime | parseTime }}</span>
|
|
|
+ <span v-if="row.pickTime">{{ row.pickTime | parseTime }}</span>
|
|
|
<span v-else>-</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -57,7 +57,7 @@
|
|
|
:total="total"
|
|
|
:page.sync="listQuery.pageNum"
|
|
|
:limit.sync="listQuery.pageSize"
|
|
|
- @pagination="fetchKeywordList"
|
|
|
+ @pagination="fetchShopLabelList"
|
|
|
/>
|
|
|
|
|
|
<!-- 选择标签 -->
|
|
@@ -72,19 +72,19 @@
|
|
|
<div class="filter-control">
|
|
|
<span>标签:</span>
|
|
|
<el-input
|
|
|
- v-model="listQuery.keyword"
|
|
|
+ v-model="labelQuery.keyword"
|
|
|
placeholder="标签"
|
|
|
clearable
|
|
|
- @keyup.enter.native="getList"
|
|
|
- @clear="getList"
|
|
|
+ @keyup.enter.native="fetchLabelList"
|
|
|
+ @clear="fetchLabelList"
|
|
|
/>
|
|
|
</div>
|
|
|
<div class="filter-control">
|
|
|
- <el-button type="primary" @click="getList">查询</el-button>
|
|
|
+ <el-button type="primary" @click="fetchLabelList">查询</el-button>
|
|
|
<el-button type="primary" @click="handleAddTag">新增标签</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <el-table ref="table" v-loading="isLoading" :data="supplierList" height="400px" border @selection-change="handleSelectionTagChange">
|
|
|
+ <el-table ref="table" v-loading="isLoading" :data="labelList" height="340px" border @selection-change="handleSelectionTagChange">
|
|
|
<el-table-column type="selection" width="55" />
|
|
|
<el-table-column prop="keyword" label="标签" align="center" />
|
|
|
<el-table-column prop="frequency" label="搜索次数" width="120" align="center" sortable />
|
|
@@ -96,14 +96,14 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="添加时间" align="center" width="200">
|
|
|
<template slot-scope="{ row }">
|
|
|
- <span v-if="row.searchTime">{{ row.searchTime | parseTime }}</span>
|
|
|
+ <span v-if="row.addTime">{{ row.addTime | parseTime }}</span>
|
|
|
<span v-else>-</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<div slot="footer">
|
|
|
<el-button @click="selectionTagDialog = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="handleSelectionTagConfirm">确 定</el-button>
|
|
|
+ <el-button type="primary" :disabled="labelDisabled" @click="handleSelectionTagConfirm">确 定</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
@@ -129,82 +129,29 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { parseTime } from '@/utils'
|
|
|
-import { addKeyword, deleteKeyword, fetchKeywordList, importKeywordXlsx } from '@/api/library/keyword'
|
|
|
-import { export_json_to_excel } from '@/vendor/Export2Excel'
|
|
|
+import { fetchShopLabelList, fetchLabelList, relevanceInsertLabel, delShopLabelList, addInsertSearch } from '@/api/user/supplier/supplier'
|
|
|
export default {
|
|
|
data() {
|
|
|
- const pickerOptions = {
|
|
|
- shortcuts: [
|
|
|
- {
|
|
|
- text: '近1年',
|
|
|
- onClick(picker) {
|
|
|
- const end = new Date()
|
|
|
- const start = new Date()
|
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 365)
|
|
|
- picker.$emit('pick', [start, end])
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- text: '近半年',
|
|
|
- onClick(picker) {
|
|
|
- const end = new Date()
|
|
|
- const start = new Date()
|
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 183)
|
|
|
- picker.$emit('pick', [start, end])
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- text: '近1月',
|
|
|
- onClick(picker) {
|
|
|
- const end = new Date()
|
|
|
- const start = new Date()
|
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
|
|
|
- picker.$emit('pick', [start, end])
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- text: '近1周',
|
|
|
- onClick(picker) {
|
|
|
- const end = new Date()
|
|
|
- const start = new Date()
|
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
|
|
|
- picker.$emit('pick', [start, end])
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- text: '昨天',
|
|
|
- onClick(picker) {
|
|
|
- const end = new Date()
|
|
|
- const start = new Date()
|
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24)
|
|
|
- picker.$emit('pick', [start, end])
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
return {
|
|
|
isLoading: true,
|
|
|
- pickerOptions,
|
|
|
- time: '',
|
|
|
+ relevanceId: null,
|
|
|
listQuery: {
|
|
|
+ relevanceId: '',
|
|
|
keyword: '',
|
|
|
- beginTime: '',
|
|
|
- endTime: '',
|
|
|
- labelStatus: 1,
|
|
|
- searchTimeCode: '',
|
|
|
- fromSearch: '',
|
|
|
pageNum: 1,
|
|
|
pageSize: 10
|
|
|
},
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
currentList: [],
|
|
|
- currentTabsList: [],
|
|
|
searchDialog: false,
|
|
|
- visibleKeyword: '',
|
|
|
addTagDialog: false,
|
|
|
selectionTagDialog: false,
|
|
|
+ labelQuery: {
|
|
|
+ keyword: '', // 标签名
|
|
|
+ pageNum: 1, // 页码
|
|
|
+ pageSize: 100// 页面数据数
|
|
|
+ },
|
|
|
tagForm: {
|
|
|
keyword: ''
|
|
|
},
|
|
@@ -220,53 +167,36 @@ export default {
|
|
|
importFormRules: {
|
|
|
fileUrl: [{ required: true, message: '文件不能为空', trigger: ['change'] }]
|
|
|
},
|
|
|
- supplierList: [
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' },
|
|
|
- { frequency: '45454', keyword: '综合供应商公司似手打发送到', searchTime: '2022-09-16 10:37:12', parseTime: '2022-09-16 10:37:12' }
|
|
|
- ]
|
|
|
+ labelList: [],
|
|
|
+ labelCurrentList: []
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
disabled() {
|
|
|
return this.currentList.length === 0
|
|
|
+ },
|
|
|
+ labelDisabled() {
|
|
|
+ return this.labelCurrentList.length === 0
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
+ this.relevanceId = this.$route.query.relevanceId
|
|
|
+ this.listQuery = { ...this.listQuery, ...this.$route.query }
|
|
|
+ console.log('listQuery', this.listQuery)
|
|
|
this.getList()
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取关键词列表
|
|
|
getList() {
|
|
|
this.listQuery.pageNum = 1
|
|
|
- if (this.time && this.time.length > 0) {
|
|
|
- this.listQuery.beginTime = this.time[0]
|
|
|
- this.listQuery.endTime = this.time[1]
|
|
|
- } else {
|
|
|
- this.listQuery.beginTime = ''
|
|
|
- this.listQuery.endTime = ''
|
|
|
- }
|
|
|
- this.fetchKeywordList()
|
|
|
+ this.fetchShopLabelList()
|
|
|
},
|
|
|
|
|
|
- // 获取关键词列表
|
|
|
- async fetchKeywordList() {
|
|
|
+ // 获取供应商标签列表
|
|
|
+ async fetchShopLabelList() {
|
|
|
try {
|
|
|
this.isLoading = true
|
|
|
- const res = await fetchKeywordList(this.listQuery)
|
|
|
+ const res = await fetchShopLabelList(this.listQuery)
|
|
|
this.list = res.data.results
|
|
|
this.total = res.data.totalRecord
|
|
|
this.isLoading = false
|
|
@@ -275,9 +205,24 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 显示选择标签列表
|
|
|
+ handleSelectionTagDialog() {
|
|
|
+ this.selectionTagDialog = true
|
|
|
+ this.fetchLabelList()
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取标签列表
|
|
|
+ async fetchLabelList() {
|
|
|
+ try {
|
|
|
+ const res = await fetchLabelList(this.labelQuery)
|
|
|
+ this.labelList = res.data.results
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
// 选中标签项
|
|
|
handleSelectionTagChange(current) {
|
|
|
- this.currentTabsList = current
|
|
|
+ this.labelCurrentList = current
|
|
|
},
|
|
|
|
|
|
// 选中列表项
|
|
@@ -285,33 +230,32 @@ export default {
|
|
|
this.currentList = current
|
|
|
},
|
|
|
|
|
|
- // 去搜索
|
|
|
- handleSearch(keyword) {
|
|
|
- this.visibleKeyword = keyword
|
|
|
- this.searchDialog = true
|
|
|
- },
|
|
|
// 添加标签
|
|
|
handleAddTag() {
|
|
|
this.selectionTagDialog = false
|
|
|
this.addTagDialog = true
|
|
|
},
|
|
|
+
|
|
|
// 添加标签取消
|
|
|
closeAddTagDialog() {
|
|
|
this.$refs.tagForm.resetFields()
|
|
|
this.addTagDialog = false
|
|
|
},
|
|
|
|
|
|
- // 添加标签确定
|
|
|
- async handleAddTagConfirm() {
|
|
|
+ // 选择标签确定
|
|
|
+ async handleSelectionTagConfirm() {
|
|
|
+ const ids = this.labelCurrentList.map((item) => item.id).join(',')
|
|
|
try {
|
|
|
- await this.$refs.tagForm.validate()
|
|
|
- this.addTagSubmit()
|
|
|
+ await relevanceInsertLabel({ relevanceId: this.relevanceId, keywordIds: ids })
|
|
|
+ this.$message.success('添加成功')
|
|
|
+ this.selectionTagDialog = false
|
|
|
+ this.getList()
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
}
|
|
|
},
|
|
|
- // 选择标签确定
|
|
|
- async handleSelectionTagConfirm() {
|
|
|
+ // 添加标签确定
|
|
|
+ async handleAddTagConfirm() {
|
|
|
try {
|
|
|
await this.$refs.tagForm.validate()
|
|
|
this.addTagSubmit()
|
|
@@ -322,19 +266,19 @@ export default {
|
|
|
// 提交添加标签信息
|
|
|
async addTagSubmit() {
|
|
|
try {
|
|
|
- await addKeyword(this.tagForm)
|
|
|
+ await addInsertSearch(this.tagForm)
|
|
|
this.$message.success('添加标签成功')
|
|
|
- this.getList()
|
|
|
+ this.closeAddTagDialog()
|
|
|
+ this.handleSelectionTagDialog()
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
}
|
|
|
- this.closeAddTagDialog()
|
|
|
},
|
|
|
|
|
|
// 删除标签
|
|
|
async handleDeleteTag(row) {
|
|
|
try {
|
|
|
- await this.$confirm('确定删除已选标签?', {
|
|
|
+ await this.$confirm('确定删除选中的标签吗?', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
@@ -345,110 +289,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 提交删除标签操作
|
|
|
+ // 提交删除关联标签操作
|
|
|
async deleteTagSubmit(row) {
|
|
|
const keywords = row instanceof Event ? this.currentList : [].concat(row)
|
|
|
const ids = keywords.map((item) => item.id).join(',')
|
|
|
try {
|
|
|
- await deleteKeyword({ id: ids })
|
|
|
- this.$message.success('已忽略所选关键词')
|
|
|
+ await delShopLabelList({ labelIds: ids })
|
|
|
+ this.$message.success('操作成功')
|
|
|
this.getList()
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
}
|
|
|
- },
|
|
|
-
|
|
|
- // 导入关键词
|
|
|
- async handleImport() {},
|
|
|
-
|
|
|
- // 导入关键词取消
|
|
|
- closeImportDialog() {
|
|
|
- this.$refs.importForm.resetFields()
|
|
|
- this.importDialog = false
|
|
|
- },
|
|
|
-
|
|
|
- // 导入关键词确定
|
|
|
- async handleImportConfirm() {
|
|
|
- console.log(1)
|
|
|
- try {
|
|
|
- await this.$refs.importForm.validate()
|
|
|
- this.importSumbit()
|
|
|
- } catch (error) {
|
|
|
- console.log(error)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- async importSumbit() {
|
|
|
- const file = this.fileList.length > 0 && this.fileList[0]
|
|
|
- if (!file) return
|
|
|
- try {
|
|
|
- const formData = new FormData()
|
|
|
- this.fileList = []
|
|
|
- this.importDialog = false
|
|
|
- formData.append('keywordFile', file.raw)
|
|
|
- await importKeywordXlsx(formData)
|
|
|
- this.$message.success('导入标签成功')
|
|
|
- this.getList()
|
|
|
- } catch (error) {
|
|
|
- console.log(error)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- // 导出
|
|
|
- async handleExport() {
|
|
|
- try {
|
|
|
- await this.$confirm('确定将所选标签导出为xlsx?', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
- // 导出数据格式化
|
|
|
- const filterVal = ['index', 'keyword', 'frequency', 'fromSearch', 'searchTime', 'addTime']
|
|
|
- const data = this.formatJson(filterVal, this.currentList.slice(0))
|
|
|
- export_json_to_excel({
|
|
|
- header: ['序号', '标签', '搜索次数', '来源', '最近搜索时间', '添加时间'],
|
|
|
- data,
|
|
|
- filename: '标签列表'
|
|
|
- })
|
|
|
- } catch (error) {
|
|
|
- this.$message.info('已取消导出操作')
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- formatJson(filterVal, jsonData) {
|
|
|
- return jsonData.map((v, index) =>
|
|
|
- filterVal.map((key) => {
|
|
|
- if (['searchTime', 'addTime'].includes(key)) {
|
|
|
- return parseTime(v[key])
|
|
|
- }
|
|
|
- if (key === 'index') return index + 1
|
|
|
- if (key === 'fromSearch') {
|
|
|
- const t = ['单个添加', '系统推荐', '导入']
|
|
|
- return t[v[key] - 1]
|
|
|
- }
|
|
|
- return v[key]
|
|
|
- })
|
|
|
- )
|
|
|
- },
|
|
|
-
|
|
|
- // 文件上传成功
|
|
|
- handleUploadSuccess(response, file, fileList) {
|
|
|
- this.importForm.fileUrl = response.url
|
|
|
- this.fileList = fileList
|
|
|
- },
|
|
|
-
|
|
|
- // 上传文件删除
|
|
|
- handleUploadRemove(file, fileList) {
|
|
|
- this.fileList = fileList
|
|
|
- },
|
|
|
-
|
|
|
- handleUploadChange(file, fileList) {
|
|
|
- this.fileList = fileList
|
|
|
- this.importForm.fileUrl = file.name
|
|
|
- },
|
|
|
-
|
|
|
- indexMethod(index) {
|
|
|
- return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
|
|
|
}
|
|
|
}
|
|
|
}
|