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