|
|
@@ -18,8 +18,13 @@
|
|
|
<div class="body-header">
|
|
|
<div class="item-title">标签列表</div>
|
|
|
<div class="table-btns">
|
|
|
- <a-button class="btn" type="primary" @click="openDialog('add')">新增标签</a-button>
|
|
|
- <a-button class="btn" :disabled="!hasSelected" @click="delAllData">批量删除</a-button>
|
|
|
+ <a-button class="btn" type="primary" @click="getTagsData" title="刷新">
|
|
|
+ <RedoOutlined />
|
|
|
+ </a-button>
|
|
|
+ <a-button class="btn" type="primary" @click="openDialog('add', {})">新增标签</a-button>
|
|
|
+ <a-popconfirm :title="delAllBtnTitle" @confirm="delAllData">
|
|
|
+ <a-button class="btn" :disabled="!hasSelected">批量删除</a-button>
|
|
|
+ </a-popconfirm>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="body-content">
|
|
|
@@ -27,11 +32,11 @@
|
|
|
:data-source="tableData" :bordered="true" @change="tableChange">
|
|
|
<template #operation="{ record }">
|
|
|
<a-tooltip title="编辑" color="yellow">
|
|
|
- <a @click="openDialog('edit')">
|
|
|
+ <a @click="openDialog('edit', record)">
|
|
|
<EditOutlined />
|
|
|
</a>
|
|
|
</a-tooltip>
|
|
|
- <a-popconfirm v-if="tableData.length" title="确定删除该标签?" @confirm="onDelete(record.key)">
|
|
|
+ <a-popconfirm v-if="tableData.length" title="确定删除该标签?" @confirm="onDelete(record.id)">
|
|
|
<a-tooltip title="删除" color="red">
|
|
|
<a>
|
|
|
<DeleteOutlined />
|
|
|
@@ -42,7 +47,8 @@
|
|
|
</a-table>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <TagDrawer v-if="ifShowDialog" @closeDialog="ifShowDialog = false" :formData="formData" :drawerTitle="drawerTitle" @onSubmit="onSubmit" ref="drawerRef">
|
|
|
+ <TagDrawer v-if="ifShowDialog" @closeDialog="ifShowDialog = false" :formData="formData" :drawerTitle="drawerTitle"
|
|
|
+ @onSubmit="onSubmit" ref="drawerRef">
|
|
|
</TagDrawer>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -50,15 +56,15 @@
|
|
|
<script>
|
|
|
import { defineComponent, reactive, ref, toRefs, computed, onMounted, watch } from 'vue';
|
|
|
import TagDrawer from './TagDrawer.vue';
|
|
|
-import { getAllTags } from '/@/api/sys/tag';
|
|
|
+import { getAllTags, deleteTag } from '/@/api/sys/tag';
|
|
|
import { message } from 'ant-design-vue';
|
|
|
-import { EditOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
|
|
+import { EditOutlined, DeleteOutlined, RedoOutlined } from '@ant-design/icons-vue';
|
|
|
import moment from 'moment'
|
|
|
import { session } from '/@/utils/Memory';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'tag',
|
|
|
- components: { TagDrawer, EditOutlined, DeleteOutlined },
|
|
|
+ components: { TagDrawer, EditOutlined, DeleteOutlined, RedoOutlined },
|
|
|
setup() {
|
|
|
const drawerRef = ref(null)
|
|
|
onMounted(() => {
|
|
|
@@ -70,7 +76,9 @@ export default defineComponent({
|
|
|
searchType: "name",//查询类型
|
|
|
searchValue: "",//查询值
|
|
|
formData: {
|
|
|
+ id: "",
|
|
|
name: "",
|
|
|
+ codeName: "",
|
|
|
code: "",
|
|
|
type: "",
|
|
|
px: "",
|
|
|
@@ -80,15 +88,17 @@ export default defineComponent({
|
|
|
});
|
|
|
//获取所有标签
|
|
|
const getTagsData = () => {
|
|
|
+ data.tableData = []
|
|
|
+ data.selectedRowKeys = []
|
|
|
let param = {
|
|
|
- 1:session.getItem('tokenV2')
|
|
|
+ 1: session.getItem('tokenV2')
|
|
|
}
|
|
|
getAllTags(param).then(res => {
|
|
|
let resData = JSON.parse(res.result)
|
|
|
- resData.forEach((item,index) => {
|
|
|
+ resData.forEach((item, index) => {
|
|
|
data.tableData.push({
|
|
|
key: item.id,
|
|
|
- state:`状态${index+1}`,
|
|
|
+ state: `状态${index + 1}`,
|
|
|
time: moment(item.createtime).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
...item
|
|
|
})
|
|
|
@@ -176,44 +186,68 @@ export default defineComponent({
|
|
|
}
|
|
|
//判断是否选中数据
|
|
|
const hasSelected = computed(() => data.selectedRowKeys.length > 0);
|
|
|
+ //删除提示
|
|
|
+ const delAllBtnTitle = computed(() => `确定删除${data.selectedRowKeys.length}个标签?`)
|
|
|
//删除所有选中的数据
|
|
|
const delAllData = () => {
|
|
|
- setTimeout(() => {
|
|
|
- message.success('删除成功')
|
|
|
+ let param = {
|
|
|
+ 1: session.getItem('tokenV2'),
|
|
|
+ 2: JSON.stringify({}),
|
|
|
+ 3: JSON.stringify(data.selectedRowKeys)
|
|
|
+ }
|
|
|
+ deleteTag(param).then(res => {
|
|
|
+ message.success('操作成功');
|
|
|
+ getTagsData();
|
|
|
data.selectedRowKeys = [];
|
|
|
- }, 1000);
|
|
|
+ })
|
|
|
};
|
|
|
//表格行选中事件
|
|
|
const onSelectChange = selectedRowKeys => {
|
|
|
data.selectedRowKeys = selectedRowKeys;
|
|
|
};
|
|
|
//新增或修改数据,打开弹窗
|
|
|
- const openDialog = (flag) => {
|
|
|
+ const openDialog = (flag, record) => {
|
|
|
if (flag === 'add') {
|
|
|
data.formData = {
|
|
|
+ id: "",
|
|
|
name: "",
|
|
|
+ codeName: "",
|
|
|
code: "",
|
|
|
type: "",
|
|
|
px: "",
|
|
|
}
|
|
|
data.drawerTitle = '新增标签'
|
|
|
data.ifShowDialog = true
|
|
|
- // drawerRef.value.showDrawer()
|
|
|
+ } else {
|
|
|
+ data.formData = {
|
|
|
+ id: record.id,
|
|
|
+ name: record.name,
|
|
|
+ code: record.code,
|
|
|
+ codeName: record.codeName,
|
|
|
+ type: record.type,
|
|
|
+ px: record.px,
|
|
|
+ }
|
|
|
+ data.drawerTitle = '修改标签'
|
|
|
+ data.ifShowDialog = true
|
|
|
}
|
|
|
}
|
|
|
+ //删除单个数据
|
|
|
+ const onDelete = (id) => {
|
|
|
+ let param = {
|
|
|
+ 1: session.getItem('tokenV2'),
|
|
|
+ 2: JSON.stringify({}),
|
|
|
+ 3: JSON.stringify([id])
|
|
|
+ }
|
|
|
+ deleteTag(param).then(res => {
|
|
|
+ message.success('操作成功');
|
|
|
+ getTagsData();
|
|
|
+ })
|
|
|
+ }
|
|
|
//弹窗确认
|
|
|
const onSubmit = (e) => {
|
|
|
+ data.ifShowDialog = false
|
|
|
if (e) {
|
|
|
- data.position.data = []
|
|
|
- data.position.currentId = ""
|
|
|
- let params = {
|
|
|
- zwId: data.posts.currentId
|
|
|
- }
|
|
|
- getPositionList(params).then(res => {
|
|
|
- if (res.datas && res.datas.length) {
|
|
|
- data.position.data = res.datas
|
|
|
- }
|
|
|
- })
|
|
|
+ getTagsData();
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
@@ -222,12 +256,14 @@ export default defineComponent({
|
|
|
sortedInfo,
|
|
|
columns,
|
|
|
hasSelected,
|
|
|
+ delAllBtnTitle,
|
|
|
...toRefs(data),
|
|
|
// func
|
|
|
getTagsData,
|
|
|
tableChange,
|
|
|
searchTable,
|
|
|
delAllData,
|
|
|
+ onDelete,
|
|
|
onSelectChange,
|
|
|
openDialog,
|
|
|
onSubmit
|