书签 删除功能
This commit is contained in:
+2
-4
@@ -24,12 +24,10 @@ const update_bookmark = (params: Object) => {
|
||||
})
|
||||
}
|
||||
|
||||
const delete_bookmark = (params: Object) => {
|
||||
const delete_bookmark = (query: number) => {
|
||||
return request({
|
||||
url: '/bookmark',
|
||||
url: '/bookmark/delete/' + query,
|
||||
method: 'delete',
|
||||
headers: {},
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps<{ msg: string }>()
|
||||
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>{{ msg }}</h1>
|
||||
|
||||
<p>
|
||||
Recommended IDE setup:
|
||||
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
|
||||
+
|
||||
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
|
||||
</p>
|
||||
|
||||
<p>See <code>README.md</code> for more information.</p>
|
||||
|
||||
<p>
|
||||
<a href="https://vitejs.dev/guide/features.html" target="_blank">
|
||||
Vite Docs
|
||||
</a>
|
||||
|
|
||||
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
|
||||
</p>
|
||||
|
||||
<button type="button" @click="count++">count is: {{ count }}</button>
|
||||
<p>
|
||||
Edit
|
||||
<code>components/HelloWorld.vue</code> to test hot module replacement.
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
|
||||
label {
|
||||
margin: 0 0.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
code {
|
||||
background-color: #eee;
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
color: #304455;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="concel">取消</el-button>
|
||||
<el-button type="primary" @click="submit">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
type Props = {
|
||||
delete_id: any
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits(['on-concel', 'on-submit'])
|
||||
const concel = () => {
|
||||
emit('on-concel')
|
||||
}
|
||||
const submit = () => {
|
||||
emit('on-submit', props.delete_id)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.dashboard {
|
||||
background-color: beige;
|
||||
}
|
||||
</style>
|
||||
@@ -2,10 +2,11 @@
|
||||
<div class="dashboard">
|
||||
<el-form :model="dialog_form">
|
||||
<el-form-item label="分类" :label-width="formLabelWidth">
|
||||
<el-select v-model="dialog_form.bk_type_id" placeholder="请选择">
|
||||
<el-select v-model="dialog_form.bk_type_name" placeholder>
|
||||
<el-option
|
||||
v-for="(item, index) in types"
|
||||
:key="index"
|
||||
:selected="index == 1 ? 'selected' : ''"
|
||||
:value="item.bk_type_id"
|
||||
:label="item.bk_type_name"
|
||||
/>
|
||||
@@ -28,7 +29,9 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue';
|
||||
import { update_bookmark, put_bookmark } from '../../api/bookmark'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
const formLabelWidth = '140px'
|
||||
|
||||
type Props = {
|
||||
@@ -43,7 +46,6 @@ const concel = () => {
|
||||
emit('on-concel')
|
||||
}
|
||||
const submit = () => {
|
||||
|
||||
const params = {
|
||||
bk_id: props.dialog_form.bk_id,
|
||||
bk_type_id: props.dialog_form.bk_type_id,
|
||||
@@ -53,15 +55,15 @@ const submit = () => {
|
||||
|
||||
if (props.operate_code == '0') {
|
||||
put_bookmark(params).then(response => {
|
||||
emit('on-submit', props.dialog_form)
|
||||
emit('on-submit')
|
||||
})
|
||||
} else if (props.operate_code == '1') {
|
||||
update_bookmark(params).then(response => {
|
||||
emit('on-submit', props.dialog_form)
|
||||
emit('on-submit')
|
||||
})
|
||||
} else if (props.operate_code == '2') {
|
||||
update_bookmark(params).then(response => {
|
||||
emit('on-submit', props.dialog_form)
|
||||
emit('on-submit')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+54
-20
@@ -29,7 +29,7 @@
|
||||
type="success"
|
||||
v-for="(item) in bookmark_types"
|
||||
@click="doSearch(item.id)"
|
||||
>{{ item.type }}</el-tag>
|
||||
>{{ item.bk_type_name }}</el-tag>
|
||||
</div>
|
||||
</el-form>
|
||||
<div></div>
|
||||
@@ -47,12 +47,11 @@
|
||||
<el-table-column class="click-icon" prop="url" label="url" />
|
||||
<el-table-column class="click-icon" prop label="操作">
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="handleDelete(scope.$index, scope.row)"
|
||||
>Delete</el-button>
|
||||
<el-icon :size="20" @click="copyNumber(scope.row)" class="click-icon">
|
||||
<CopyDocument />
|
||||
</el-icon>
|
||||
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
|
||||
<el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -60,6 +59,7 @@
|
||||
<el-button @click="toggleSelection([tableData[1], tableData[2]])">反选</el-button>
|
||||
<el-button @click="toggleSelection()">清除</el-button>
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogFormVisible" title="添加书签">
|
||||
<bookmark_dialog
|
||||
:dialog_form="currentDialogData"
|
||||
@@ -69,15 +69,24 @@
|
||||
@on-submit="doSubmit"
|
||||
></bookmark_dialog>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="dialogVisible">
|
||||
<delete_dialog :delete_id="currentDialogData.bk_id" @on-submit="doDelete"></delete_dialog>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue'
|
||||
import { search_bookmark } from '../../api/bookmark'
|
||||
import { search_bookmark, delete_bookmark } from '../../api/bookmark'
|
||||
import { bookmark_type } from '../../api/master'
|
||||
import bookmark_dialog from './dialog.vue'
|
||||
import delete_dialog from '../../components/operate/deleteDialog.vue'
|
||||
import type { ElTable } from 'element-plus'
|
||||
import { CopyDocument } from "@element-plus/icons-vue";
|
||||
import { ElNotification } from 'element-plus'
|
||||
import copy from 'copy-to-clipboard';
|
||||
import { h } from 'vue'
|
||||
|
||||
|
||||
const bookmark_types = reactive<any[]>([])
|
||||
@@ -94,15 +103,13 @@ bookmark_type().then(response => {
|
||||
|
||||
// 定义书签格式
|
||||
type Bookmark = {
|
||||
id: number,
|
||||
bk_id: number,
|
||||
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({
|
||||
@@ -112,9 +119,9 @@ const search_data = reactive({
|
||||
const tableData = reactive<Bookmark[]>([])
|
||||
// 响应式dialog数据
|
||||
const currentDialogData = reactive<Bookmark>({
|
||||
id: 0,
|
||||
bk_type_id: 0,
|
||||
bk_type_name: '',
|
||||
bk_id: -1,
|
||||
bk_type_id: 1,
|
||||
bk_type_name: '未分类',
|
||||
comment: '',
|
||||
url: ''
|
||||
})
|
||||
@@ -134,15 +141,27 @@ const toggleSelection = (rows?: Bookmark[]) => {
|
||||
}
|
||||
|
||||
|
||||
// dialog表示flag
|
||||
let dialogFormVisible = ref(false)
|
||||
let dialogVisible = ref(false)
|
||||
|
||||
// 操作-》添加
|
||||
const handleInsert = () => {
|
||||
operate.value = '0'
|
||||
// currentDialogData
|
||||
currentDialogData.bk_id = -1
|
||||
currentDialogData.bk_type_id = 1
|
||||
currentDialogData.bk_type_name = '未分类'
|
||||
currentDialogData.comment = ''
|
||||
currentDialogData.url = ''
|
||||
dialogFormVisible.value = true
|
||||
}
|
||||
// 操作-》删除
|
||||
const handleDelete = (index: number, bookmark: Bookmark) => {
|
||||
Object.assign(currentDialogData, bookmark)
|
||||
operate.value = '2'
|
||||
dialogFormVisible.value = true
|
||||
dialogVisible.value = true
|
||||
}
|
||||
// 操作-》编辑
|
||||
const handleEdit = (index: number, bookmark: Bookmark) => {
|
||||
Object.assign(currentDialogData, bookmark)
|
||||
operate.value = '1'
|
||||
@@ -150,7 +169,6 @@ const handleEdit = (index: number, bookmark: Bookmark) => {
|
||||
}
|
||||
|
||||
const handleSelectionChange = (val: Bookmark[]) => {
|
||||
console.log(val)
|
||||
multipleSelection.value = val
|
||||
}
|
||||
|
||||
@@ -165,7 +183,7 @@ const doSearch = (type_id: String) => {
|
||||
response.data.forEach((item: Bookmark, index: number) => {
|
||||
console.log(item)
|
||||
const row = {
|
||||
id: index + 1,
|
||||
bk_id: item.bk_id,
|
||||
bk_type_id: item.bk_type_id,
|
||||
bk_type_name: item.bk_type_name,
|
||||
comment: item.comment,
|
||||
@@ -176,15 +194,31 @@ const doSearch = (type_id: String) => {
|
||||
})
|
||||
}
|
||||
|
||||
const doDelete = (delete_id: any) => {
|
||||
let query = delete_id
|
||||
delete_bookmark(query).then(response => {
|
||||
dialogVisible.value = false
|
||||
})
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
const closeDialog = () => {
|
||||
dialogFormVisible.value = false
|
||||
}
|
||||
const doSubmit = (form: any) => {
|
||||
const doSubmit = () => {
|
||||
dialogFormVisible.value = false
|
||||
}
|
||||
// 复制转换成功的数值,并提示 复制成功 信息
|
||||
const copyNumber = (record: Bookmark) => {
|
||||
copy(record.url + "")
|
||||
ElNotification({
|
||||
title: '',
|
||||
message: h('i', { style: 'color: teal' }, '复制成功'),
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style scoped>
|
||||
/* .dashboard {
|
||||
background-color: beige;
|
||||
} */
|
||||
|
||||
Reference in New Issue
Block a user