|
|
@@ -1,147 +1,283 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <BasicTable :rowSelection="{ type: 'checkbox' }" @register="registerTable" :clickToRowSelect="false">
|
|
|
- <template #toolbar>
|
|
|
- <Authority>
|
|
|
- <a-button type="primary" @click="handleCreate">新增角色</a-button>
|
|
|
- </Authority>
|
|
|
- <Authority>
|
|
|
- <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消" @confirm="handleDeleteOrBatchDelete(null)">
|
|
|
- <a-button type="primary" color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
|
|
|
- </Popconfirm>
|
|
|
- </Authority>
|
|
|
- </template>
|
|
|
- <template #status="{ record }">
|
|
|
- <Switch :checked="record.status === 1" :loading="record.pendingStatus" checkedChildren="启用" unCheckedChildren="禁用"
|
|
|
- @change="(checked: boolean) => statusChange(checked, record)" />
|
|
|
- </template>
|
|
|
- <template #action="{ record }">
|
|
|
- <TableAction :actions="[
|
|
|
- {
|
|
|
- label: '编辑',
|
|
|
- icon: 'clarity:note-edit-line',
|
|
|
- onClick: handleEdit.bind(null, record),
|
|
|
- },
|
|
|
- {
|
|
|
- label: '删除',
|
|
|
- icon: 'ant-design:delete-outlined',
|
|
|
- color: 'error',
|
|
|
- ifShow: record.roleType != RoleEnum.SYS_ADMIN,
|
|
|
- popConfirm: {
|
|
|
- title: '是否确认删除',
|
|
|
- confirm: handleDeleteOrBatchDelete.bind(null, record),
|
|
|
- },
|
|
|
- },
|
|
|
- ]" />
|
|
|
- </template>
|
|
|
- </BasicTable>
|
|
|
- <RoleDrawer @register="registerDrawer" @success="handleSuccess" />
|
|
|
- </div>
|
|
|
+ <div class="p-4">
|
|
|
+ <div class="tag-header">
|
|
|
+ <div class="tag-title">标签管理</div>
|
|
|
+ <div class="handle-btns">
|
|
|
+ <span class="label">查询类型:</span>
|
|
|
+ <a-select v-model:value="searchType" style="width: 120px">
|
|
|
+ <a-select-option value="name">标签名称</a-select-option>
|
|
|
+ <a-select-option value="code">标签编码</a-select-option>
|
|
|
+ <a-select-option value="type">标签类型</a-select-option>
|
|
|
+ <a-select-option value="time">创建时间</a-select-option>
|
|
|
+ </a-select>
|
|
|
+ <a-input v-model:value="searchValue" placeholder="输入关键字查询" allow-clear />
|
|
|
+ <a-button class="btn" type="primary" @click="searchTable">查询</a-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="tag-body">
|
|
|
+ <div class="body-header">
|
|
|
+ <div class="item-title">标签列表</div>
|
|
|
+ <div class="table-btns">
|
|
|
+ <a-button class="btn" type="primary" @click="addHandle">新增标签</a-button>
|
|
|
+ <a-button class="btn" :disabled="!hasSelected" @click="delAllData">批量删除</a-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="body-content">
|
|
|
+ <a-table :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" :columns="columns"
|
|
|
+ :data-source="tableData" :bordered="true" @change="tableChange">
|
|
|
+ <template #operation="{ record }">
|
|
|
+ <a-tooltip title="编辑" color="yellow">
|
|
|
+ <a>
|
|
|
+ <EditOutlined />
|
|
|
+ </a>
|
|
|
+ </a-tooltip>
|
|
|
+ <a-popconfirm v-if="tableData.length" title="确定删除该标签?" @confirm="onDelete(record.key)">
|
|
|
+ <a-tooltip title="删除" color="red">
|
|
|
+ <a>
|
|
|
+ <DeleteOutlined />
|
|
|
+ </a>
|
|
|
+ </a-tooltip>
|
|
|
+ </a-popconfirm>
|
|
|
+ </template>
|
|
|
+ </a-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <TagDrawer :formData="formData" :drawerTitle="drawerTitle" @onSubmit="onSubmit" ref="drawerRef">
|
|
|
+ </TagDrawer>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
-<script lang="ts">
|
|
|
-import { defineComponent, nextTick } from 'vue';
|
|
|
-import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
|
|
-import { delRole, getRoleListByPage, setRoleStatus } from '/@/api/system/system';
|
|
|
-import { useDrawer } from '/@/components/Drawer';
|
|
|
-import RoleDrawer from './RoleDrawer.vue';
|
|
|
-import { columns, searchFormSchema } from './role.data';
|
|
|
-import { RoleEnum } from '/@/enums/roleEnum';
|
|
|
-import { Authority } from '/@/components/Authority';
|
|
|
-import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
|
|
|
-import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
-import { Switch, Popconfirm } from 'ant-design-vue';
|
|
|
-import { roleList } from '/@/api/sys/user';
|
|
|
+
|
|
|
+<script>
|
|
|
+import { defineComponent, reactive, ref, toRefs, computed, onMounted, watch } from 'vue';
|
|
|
+import TagDrawer from './TagDrawer.vue';
|
|
|
+import { structureList, getPositionList, delPosition } from '/@/api/sys/position';
|
|
|
+import { message } from 'ant-design-vue';
|
|
|
+import { EditOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
|
|
+import moment from 'moment'
|
|
|
|
|
|
export default defineComponent({
|
|
|
- name: 'RoleManagement',
|
|
|
- components: { BasicTable, RoleDrawer, TableAction, Authority, Switch, Popconfirm },
|
|
|
- setup() {
|
|
|
- const [registerDrawer, { openDrawer }] = useDrawer();
|
|
|
- function handleSuccess() {
|
|
|
- reload();
|
|
|
- }
|
|
|
- const [registerTable, { setProps, reload, setSelectedRowKeys }] = useTable({
|
|
|
- title: '角色列表',
|
|
|
- api: roleList,
|
|
|
- columns,
|
|
|
- formConfig: {
|
|
|
- labelWidth: 120,
|
|
|
- schemas: searchFormSchema,
|
|
|
- },
|
|
|
- useSearchForm: true,
|
|
|
- showTableSetting: true,
|
|
|
- bordered: true,
|
|
|
- showIndexColumn: false,
|
|
|
- actionColumn: {
|
|
|
- width: 200,
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'action',
|
|
|
- slots: { customRender: 'action' },
|
|
|
- fixed: 'right',
|
|
|
- },
|
|
|
- });
|
|
|
- const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } =
|
|
|
- useBatchDelete(delRole, handleSuccess, setProps);
|
|
|
- selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
|
|
|
- // Demo:status为1的选择框禁用
|
|
|
- if (record.status === 1) {
|
|
|
- return { disabled: true };
|
|
|
- } else {
|
|
|
- return { disabled: false };
|
|
|
- }
|
|
|
- };
|
|
|
- nextTick(() => {
|
|
|
- setProps(selectionOptions);
|
|
|
- });
|
|
|
-
|
|
|
- function handleCreate() {
|
|
|
- openDrawer(true, {
|
|
|
- isUpdate: false,
|
|
|
- });
|
|
|
- }
|
|
|
+ name: 'tag',
|
|
|
+ components: { TagDrawer, EditOutlined, DeleteOutlined },
|
|
|
+ setup() {
|
|
|
+ const drawerRef = ref(null)
|
|
|
+ onMounted(() => {
|
|
|
+ for (let i = 0; i < 40; i++) {
|
|
|
+ data.tableData.push({
|
|
|
+ name: `标签${i}`,
|
|
|
+ code: `编码${i}`,
|
|
|
+ type: `类型${i}`,
|
|
|
+ state: `状态${i}`,
|
|
|
+ time: `时间${i}`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const data = reactive({
|
|
|
+ tableData: [],//表格数据
|
|
|
+ selectedRowKeys: [],//选中的key
|
|
|
+ searchType: "name",//查询类型
|
|
|
+ searchValue: "",//查询值
|
|
|
+ formData: {
|
|
|
+ name: "",
|
|
|
+ code: "",
|
|
|
+ type: "",
|
|
|
+ px: "",
|
|
|
+ },
|
|
|
+ drawerTitle:"新增标签"
|
|
|
+ });
|
|
|
|
|
|
- function handleEdit(record: Recordable) {
|
|
|
- openDrawer(true, {
|
|
|
- record,
|
|
|
- isUpdate: true,
|
|
|
- });
|
|
|
- console.log(record)
|
|
|
- }
|
|
|
+ const filteredInfo = ref({
|
|
|
+ name: null,
|
|
|
+ code: null,
|
|
|
+ type: null,
|
|
|
+ time: null
|
|
|
+ });
|
|
|
+ const sortedInfo = ref();
|
|
|
+ const columns = computed(() => {
|
|
|
+ const filtered = filteredInfo.value || {};
|
|
|
+ const sorted = sortedInfo.value || {};
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ title: '标签名称',
|
|
|
+ dataIndex: 'name',
|
|
|
+ key: 'name',
|
|
|
+ filteredValue: filtered.name || null,
|
|
|
+ onFilter: (value, record) => record.name.includes(value),
|
|
|
+ sorter: (a, b) => a.name.length - b.name.length,
|
|
|
+ sortOrder: sorted.columnKey === 'name' && sorted.order,
|
|
|
+ width: "500px"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '标签编码',
|
|
|
+ dataIndex: 'code',
|
|
|
+ key: 'code',
|
|
|
+ filteredValue: filtered.code || null,
|
|
|
+ onFilter: (value, record) => record.code.includes(value),
|
|
|
+ sorter: (a, b) => a.code.length - b.code.length,
|
|
|
+ sortOrder: sorted.columnKey === 'code' && sorted.order,
|
|
|
+ width: "400px"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '标签类型',
|
|
|
+ dataIndex: 'type',
|
|
|
+ key: 'type',
|
|
|
+ filteredValue: filtered.type || null,
|
|
|
+ onFilter: (value, record) => record.type.includes(value),
|
|
|
+ sorter: (a, b) => a.type.length - b.type.length,
|
|
|
+ sortOrder: sorted.columnKey === 'type' && sorted.order,
|
|
|
+ width: "230px"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '启用状态',
|
|
|
+ dataIndex: 'state',
|
|
|
+ key: 'state',
|
|
|
+ filteredValue: filtered.state || null,
|
|
|
+ onFilter: (value, record) => record.state.includes(value),
|
|
|
+ width: "100px"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建时间',
|
|
|
+ dataIndex: 'time',
|
|
|
+ key: 'time',
|
|
|
+ filteredValue: filtered.time || null,
|
|
|
+ onFilter: (value, record) => record.time.includes(value),
|
|
|
+ sorter: (a, b) => a.time.length - b.time.length,
|
|
|
+ sortOrder: sorted.columnKey === 'time' && sorted.order,
|
|
|
+ width: "230px"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'operation',
|
|
|
+ slots: {
|
|
|
+ customRender: 'operation',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ });
|
|
|
+ const tableChange = (pagination, filters, sorter) => {
|
|
|
+ filteredInfo.value = filters;
|
|
|
+ sortedInfo.value = sorter;
|
|
|
+ };
|
|
|
+ const searchTable = () => {
|
|
|
+ filteredInfo.value[data.searchType] = [data.searchValue]
|
|
|
+ }
|
|
|
|
|
|
- const statusChange = async (checked, record) => {
|
|
|
- setProps({
|
|
|
- loading: true,
|
|
|
- });
|
|
|
- setSelectedRowKeys([]);
|
|
|
- resetSelectedRowKeys();
|
|
|
- const newStatus = checked ? 1 : 0;
|
|
|
- const { createMessage } = useMessage();
|
|
|
- try {
|
|
|
- await setRoleStatus(record.id, newStatus);
|
|
|
- if (newStatus) {
|
|
|
- createMessage.success(`启用成功`);
|
|
|
- } else {
|
|
|
- createMessage.success('禁用成功');
|
|
|
+ const hasSelected = computed(() => data.selectedRowKeys.length > 0);
|
|
|
+ const delAllData = () => {
|
|
|
+ setTimeout(() => {
|
|
|
+ message.success('删除成功')
|
|
|
+ data.selectedRowKeys = [];
|
|
|
+ }, 1000);
|
|
|
+ };
|
|
|
+ const onSelectChange = selectedRowKeys => {
|
|
|
+ data.selectedRowKeys = selectedRowKeys;
|
|
|
+ };
|
|
|
+ const onSubmit = (e) => {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- } finally {
|
|
|
- setProps({
|
|
|
- loading: false,
|
|
|
- });
|
|
|
- reload();
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- return {
|
|
|
- registerTable,
|
|
|
- registerDrawer,
|
|
|
- handleCreate,
|
|
|
- handleEdit,
|
|
|
- handleSuccess,
|
|
|
- RoleEnum,
|
|
|
- hasBatchDelete,
|
|
|
- handleDeleteOrBatchDelete,
|
|
|
- statusChange,
|
|
|
- };
|
|
|
- },
|
|
|
+ return {
|
|
|
+ drawerRef,
|
|
|
+ filteredInfo,
|
|
|
+ sortedInfo,
|
|
|
+ columns,
|
|
|
+ hasSelected,
|
|
|
+ ...toRefs(data),
|
|
|
+ // func
|
|
|
+ tableChange,
|
|
|
+ searchTable,
|
|
|
+ delAllData,
|
|
|
+ onSelectChange,
|
|
|
+ onSubmit
|
|
|
+ };
|
|
|
+ },
|
|
|
});
|
|
|
</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.p-4 {
|
|
|
+ height: 100%;
|
|
|
+
|
|
|
+ .tag-header {
|
|
|
+ padding: 10px;
|
|
|
+ width: 100%;
|
|
|
+ height: 70px;
|
|
|
+ background-color: #fff;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .tag-title {
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 500;
|
|
|
+ margin-left: 20px;
|
|
|
+ user-select: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .handle-btns {
|
|
|
+ margin-right: 20px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .label {
|
|
|
+ width: 150px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .tag-body {
|
|
|
+ padding: 0 30px;
|
|
|
+ margin-top: 20px;
|
|
|
+ width: 100%;
|
|
|
+ // height: 800px;
|
|
|
+ height: calc(100% - 90px);
|
|
|
+ background-color: #fff;
|
|
|
+
|
|
|
+ .body-header {
|
|
|
+ display: flex;
|
|
|
+ height: 80px;
|
|
|
+ width: 100%;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .item-title {
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ font-size: 16px;
|
|
|
+ user-select: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .table-btns {
|
|
|
+ .btn {
|
|
|
+ margin-right: 10px;
|
|
|
+
|
|
|
+ &:last-child {
|
|
|
+ margin-right: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .body-content {
|
|
|
+ padding-bottom: 20px;
|
|
|
+ height: calc(100% - 80px);
|
|
|
+
|
|
|
+ a {
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}</style>
|