You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fu-hsi-web/src/views/promptManagement/PromptConfig/index.vue

152 lines
4.5 KiB
Vue

7 months ago
<template>
6 months ago
<div ref="htmlContent" class="content">
7 months ago
<cs-search title="提示词检索" :data="searchData" :span="6" direction="row" @onSearch="onSearch" @getData="onSearch" />
<div class="index-content">
<div class="header">
6 months ago
<el-radio-group v-model="type" size="large" @change="handleChange">
<el-radio-button label="">全部</el-radio-button>
<el-radio-button v-for="(item,index) in promptType" :key="index" :label="item.value">{{ item.label }}</el-radio-button>
<!-- <el-radio-button label="2">已分析</el-radio-button> -->
</el-radio-group>
<el-button type="primary" icon="el-icon-circle-plus-outline" style="position: absolute;right: 24px;top: 12px;" @click="handleAdd"></el-button>
7 months ago
<vxe-grid v-bind="gridOptions" style="margin-top: 20px">
<template #operate="{row}">
<el-button type="text" @click="handleEdit(row)"></el-button>
<el-button type="text" style="color: red" @click="handleDel(row)"></el-button>
</template>
6 months ago
<template #type="{row}">
<span>{{ getTypeName(row.type) }}</span>
</template>
7 months ago
</vxe-grid>
<div style="text-align: center">
<cs-page
:page.sync="queryForm.page"
:limit.sync="queryForm.size"
:total="queryForm.total"
@pagination="fetchData"
/>
</div>
</div>
</div>
</div>
</template>
<script>
import mixin from '@/views/mixin'
6 months ago
import { queryPromptList, delPrompt } from '@/api/promptManagement'
7 months ago
export default {
6 months ago
name: 'PromptConfig',
7 months ago
mixins: [mixin],
data() {
return {
// 筛选数据
searchData: [
6 months ago
{ label: '提示词名称', model: 'name', type: 'input' }
// { label: '提示词类型', model: 'type', type: 'select', option: JSON.parse(sessionStorage.getItem('prompt_type')) }
7 months ago
],
6 months ago
promptType: JSON.parse(sessionStorage.getItem('prompt_type')),
6 months ago
type: '',
7 months ago
// 表格配置
gridOptions: {
...mixin.data().gridOptions,
columns: [
6 months ago
{ title: '序号', type: 'seq', width: 80 },
6 months ago
{ title: '提示词名称', field: 'name', width: '300px' },
6 months ago
{ title: '提示词类型', field: 'type', slots: { default: 'type' }, width: '200px' },
6 months ago
{ title: '匹配值', field: 'matchNum', width: '200px' },
{ title: '提示词', field: 'prompt' },
{ title: '操作', slots: { default: 'operate' }, width: '150px' }
7 months ago
],
data: []
}
}
},
activated() {
this.fetchData()
},
7 months ago
mounted() {
this.tableHeight(390)
},
methods: {
// 数据查询
fetchData() {
6 months ago
queryPromptList({ ...this.searchFormData, type: this.type, page: this.queryForm.page, size: this.queryForm.size }).then(res => {
6 months ago
this.gridOptions.data = res.data.records
7 months ago
this.queryForm.total = res.data.total
})
},
6 months ago
// 切换tab
handleChange(val) {
this.type = val
this.queryForm.page = 1
this.fetchData()
},
6 months ago
getTypeName(val) {
for (const item of this.promptType) {
if (item.value === val) {
return item.label
}
}
},
7 months ago
// 新增
handleAdd() {
6 months ago
this.$router.push({ path: `/add-prompt` })
7 months ago
},
6 months ago
// 编辑
handleEdit(row) {
this.$router.push({ path: `/edit-prompt/${row.id}` })
},
7 months ago
// 删除
handleDel(row) {
6 months ago
this.$baseConfirm('确定要删除吗?', null, async() => {
const { code, msg } = await delPrompt({
id: row.id
})
code === 200 ? this.$baseMessage.success(msg || '删除成功!') : this.$baseMessage.error(msg || '删除失败!')
this.fetchData()
})
7 months ago
},
// 筛选
onSearch(data, callback) {
this.searchFormData = Object.assign({}, data)
this.queryForm.page = 1
this.fetchData()
if (callback) callback(true)
}
}
}
</script>
<style scoped lang="scss">
.content {
height: 100%;
.index-content {
border-radius: 8px;
background: white;
padding: 20px;
box-sizing: border-box;
margin-top: 10px;
height: calc(100% - 120px);
}
.expand-details {
background: #F6F6F6;
padding: 8px 20px;
box-sizing: border-box;
}
6 months ago
.header {
position: relative;
}
7 months ago
}
::v-deep {
.text-blue {
color: #005AA8;
}
.header-blue {
background: #F2F6FA;
6 months ago
7 months ago
}
}
</style>