书签功能 查询和更新
This commit is contained in:
+11
-4
@@ -4,15 +4,22 @@ const search_bookmark = (params: Object) => {
|
||||
url: '/bookmark',
|
||||
method: 'get',
|
||||
headers: {},
|
||||
// data: params
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
const put_bookmark = (params: Object) => {
|
||||
return request({
|
||||
url: '/bookmark',
|
||||
url: '/bookmark/insert',
|
||||
method: 'put',
|
||||
headers: {},
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
const update_bookmark = (params: Object) => {
|
||||
return request({
|
||||
url: '/bookmark/update',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
@@ -35,4 +42,4 @@ const delete_bookmarks = (params: Object) => {
|
||||
})
|
||||
}
|
||||
|
||||
export { search_bookmark, put_bookmark, delete_bookmark, delete_bookmarks }
|
||||
export { search_bookmark, put_bookmark, delete_bookmark, delete_bookmarks, update_bookmark }
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import request from '../utils/request'
|
||||
const bookmark_type = () => {
|
||||
return request({
|
||||
url: '/master/bookmark/type',
|
||||
method: 'get',
|
||||
data: {}
|
||||
})
|
||||
}
|
||||
|
||||
export { bookmark_type }
|
||||
@@ -1,16 +1,20 @@
|
||||
<template>
|
||||
<div class="dashboard">
|
||||
<el-form :model="form">
|
||||
<el-form :model="dialog_form">
|
||||
<el-form-item label="分类" :label-width="formLabelWidth">
|
||||
<el-select v-model="form.type" placeholder="请选择">
|
||||
<el-option label="Java" value="Java" />
|
||||
<el-option label="Python" value="Python" />
|
||||
<el-select v-model="dialog_form.bk_type_id" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="(item, index) in types"
|
||||
:key="index"
|
||||
:value="item.bk_type_id"
|
||||
:label="item.bk_type_name"
|
||||
/>
|
||||
</el-select>
|
||||
<el-form-item label="备注" :label-width="formLabelWidth">
|
||||
<el-input v-model="form.comment" autocomplete="off" />
|
||||
<el-input v-model="dialog_form.comment" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="url" :label-width="formLabelWidth">
|
||||
<el-input v-model="form.url" autocomplete="off" />
|
||||
<el-input v-model="dialog_form.url" autocomplete="off" />
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -24,34 +28,45 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { update_bookmark, put_bookmark } from '../../api/bookmark'
|
||||
const formLabelWidth = '140px'
|
||||
|
||||
const form = reactive({
|
||||
type: '',
|
||||
comment: '',
|
||||
url: ''
|
||||
})
|
||||
|
||||
// type Props = {
|
||||
// id: number,
|
||||
// type: string,
|
||||
// comment: string,
|
||||
// url: string
|
||||
// }
|
||||
|
||||
// const ttt = defineProps<Props>()
|
||||
// form.comment = ttt.comment
|
||||
// form.type = ttt.type
|
||||
// form.url = ttt.url
|
||||
type Props = {
|
||||
types: any[],
|
||||
dialog_form: any,
|
||||
operate_code: String
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits(['on-concel', 'on-submit'])
|
||||
const concel = () => {
|
||||
emit('on-concel')
|
||||
}
|
||||
const submit = () => {
|
||||
emit('on-submit', form)
|
||||
|
||||
const params = {
|
||||
bk_id: props.dialog_form.bk_id,
|
||||
bk_type_id: props.dialog_form.bk_type_id,
|
||||
comment: props.dialog_form.comment,
|
||||
url: props.dialog_form.url,
|
||||
}
|
||||
|
||||
if (props.operate_code == '0') {
|
||||
put_bookmark(params).then(response => {
|
||||
emit('on-submit', props.dialog_form)
|
||||
})
|
||||
} else if (props.operate_code == '1') {
|
||||
update_bookmark(params).then(response => {
|
||||
emit('on-submit', props.dialog_form)
|
||||
})
|
||||
} else if (props.operate_code == '2') {
|
||||
update_bookmark(params).then(response => {
|
||||
emit('on-submit', props.dialog_form)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style scoped>.el-button--text {
|
||||
margin-right: 15px;
|
||||
|
||||
+72
-35
@@ -3,8 +3,8 @@
|
||||
<el-form>
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<!-- <el-form-item>
|
||||
<el-autocomplete
|
||||
<el-form-item>
|
||||
<!-- <el-autocomplete
|
||||
v-model="search_data.drug"
|
||||
poper-class="my-autocomplete"
|
||||
:fetch-suggestions="query"
|
||||
@@ -15,20 +15,22 @@
|
||||
<template slot-scope="{item}">
|
||||
<span class="value">{{ item.value }}</span>
|
||||
</template>
|
||||
</el-autocomplete>
|
||||
</el-form-item>-->
|
||||
</el-autocomplete>-->
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col>
|
||||
<el-button type="primary" @click="doSearch">检索</el-button>
|
||||
<el-button type="primary" @click="doSearch('')">检索</el-button>
|
||||
<el-button type="primary" @click="handleInsert">添加</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-tag class="ml-2 click-icon" type="success">Java</el-tag>
|
||||
<el-tag class="ml-2 click-icon" type="success">Xml</el-tag>
|
||||
<el-tag class="ml-2 click-icon" type="success">Html</el-tag>
|
||||
<el-tag class="ml-2 click-icon" type="success">ddo</el-tag>
|
||||
<el-button type="primary" @click="openDialog">添加</el-button>
|
||||
</el-row>
|
||||
<div class="tag_list">
|
||||
<el-tag
|
||||
class="ml-2 click-icon"
|
||||
type="success"
|
||||
v-for="(item) in bookmark_types"
|
||||
@click="doSearch(item.id)"
|
||||
>{{ item.type }}</el-tag>
|
||||
</div>
|
||||
</el-form>
|
||||
<div></div>
|
||||
|
||||
@@ -40,7 +42,7 @@
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column type="index" label="index" width="180" />
|
||||
<el-table-column prop="type" label="分类" width="180" />
|
||||
<el-table-column prop="bk_type_name" label="分类" width="180" />
|
||||
<el-table-column prop="comment" label="名称" width="180" />
|
||||
<el-table-column class="click-icon" prop="url" label="url" />
|
||||
<el-table-column class="click-icon" prop label="操作">
|
||||
@@ -60,7 +62,9 @@
|
||||
</div>
|
||||
<el-dialog v-model="dialogFormVisible" title="添加书签">
|
||||
<bookmark_dialog
|
||||
:inputdata="currentDialogData"
|
||||
:dialog_form="currentDialogData"
|
||||
:operate_code="operate"
|
||||
:types="bookmark_types"
|
||||
@on-concel="closeDialog"
|
||||
@on-submit="doSubmit"
|
||||
></bookmark_dialog>
|
||||
@@ -70,20 +74,37 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue'
|
||||
import { query } from '../../service/search'
|
||||
import { search_bookmark, put_bookmark } from '../../api/bookmark'
|
||||
import { search_bookmark } from '../../api/bookmark'
|
||||
import { bookmark_type } from '../../api/master'
|
||||
import bookmark_dialog from './dialog.vue'
|
||||
import type { ElTable } from 'element-plus'
|
||||
|
||||
|
||||
const bookmark_types = reactive<any[]>([])
|
||||
bookmark_type().then(response => {
|
||||
response.data.forEach((element: String) => {
|
||||
const item = element.split("|")
|
||||
const row = {
|
||||
bk_type_id: item[0],
|
||||
bk_type_name: item[1]
|
||||
}
|
||||
bookmark_types.push(row)
|
||||
})
|
||||
})
|
||||
|
||||
// 定义书签格式
|
||||
type Bookmark = {
|
||||
id: number,
|
||||
type: String,
|
||||
bk_type_id: number,
|
||||
bk_type_name: String,
|
||||
comment: String,
|
||||
url: String
|
||||
}
|
||||
|
||||
// dialog表示flag
|
||||
let dialogFormVisible = ref(false)
|
||||
// 操作code
|
||||
let operate = ref<String>('')
|
||||
const search_data = reactive({
|
||||
drug: '1'
|
||||
})
|
||||
@@ -91,8 +112,9 @@ const search_data = reactive({
|
||||
const tableData = reactive<Bookmark[]>([])
|
||||
// 响应式dialog数据
|
||||
const currentDialogData = reactive<Bookmark>({
|
||||
id: -1,
|
||||
type: '',
|
||||
id: 0,
|
||||
bk_type_id: 0,
|
||||
bk_type_name: '',
|
||||
comment: '',
|
||||
url: ''
|
||||
})
|
||||
@@ -111,13 +133,20 @@ const toggleSelection = (rows?: Bookmark[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const handleInsert = () => {
|
||||
operate.value = '0'
|
||||
// currentDialogData
|
||||
dialogFormVisible.value = true
|
||||
}
|
||||
const handleDelete = (index: number, bookmark: Bookmark) => {
|
||||
operate.value = '2'
|
||||
dialogFormVisible.value = true
|
||||
}
|
||||
const handleEdit = (index: number, bookmark: Bookmark) => {
|
||||
Object.assign(currentDialogData, bookmark)
|
||||
openDialog()
|
||||
}
|
||||
|
||||
const handleDelete = (index: number, bookmark: Bookmark) => {
|
||||
|
||||
operate.value = '1'
|
||||
dialogFormVisible.value = true
|
||||
}
|
||||
|
||||
const handleSelectionChange = (val: Bookmark[]) => {
|
||||
@@ -125,14 +154,20 @@ const handleSelectionChange = (val: Bookmark[]) => {
|
||||
multipleSelection.value = val
|
||||
}
|
||||
|
||||
const doSearch = () => {
|
||||
|
||||
const doSearch = (type_id: String) => {
|
||||
console.log(type_id)
|
||||
const param = {
|
||||
type_id: type_id
|
||||
}
|
||||
tableData.splice(0, tableData.length)
|
||||
search_bookmark(1).then(response => {
|
||||
console.log(response.data)
|
||||
search_bookmark(param).then(response => {
|
||||
response.data.forEach((item: Bookmark, index: number) => {
|
||||
console.log(item)
|
||||
const row = {
|
||||
id: index + 1,
|
||||
type: item.type,
|
||||
bk_type_id: item.bk_type_id,
|
||||
bk_type_name: item.bk_type_name,
|
||||
comment: item.comment,
|
||||
url: item.url
|
||||
}
|
||||
@@ -140,25 +175,27 @@ const doSearch = () => {
|
||||
})
|
||||
})
|
||||
}
|
||||
const openDialog = () => {
|
||||
dialogFormVisible.value = true
|
||||
}
|
||||
|
||||
const closeDialog = () => {
|
||||
dialogFormVisible.value = false
|
||||
}
|
||||
const doSubmit = (form: any) => {
|
||||
put_bookmark(form).then(response => {
|
||||
|
||||
})
|
||||
dialogFormVisible.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.dashboard {
|
||||
/* .dashboard {
|
||||
background-color: beige;
|
||||
} */
|
||||
.tag_list {
|
||||
display: flex;
|
||||
border-top: 1px solid rgba(151, 151, 151, 0.3);
|
||||
border-bottom: 1px solid rgba(151, 151, 151, 0.3);
|
||||
}
|
||||
.click-icon {
|
||||
width: 40px;
|
||||
margin: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user