style: 统一部门新增按钮样式,添加一键删除多个部门功能
统一部门新增按钮样式,添加一键删除多个部门功能
This commit is contained in:
@@ -1,13 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
|
|
||||||
<el-form
|
<el-form
|
||||||
|
size="mini"
|
||||||
:model="dataMap.queryParams"
|
:model="dataMap.queryParams"
|
||||||
ref="queryForm"
|
ref="queryForm"
|
||||||
:inline="true"
|
:inline="true"
|
||||||
v-show="dataMap.showSearch"
|
v-show="dataMap.showSearch"
|
||||||
>
|
>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="success" :icon="Plus" @click="handleAdd">新增</el-button>
|
||||||
|
<el-button type="danger" :icon="Delete" :disabled="dataMap.single" @click="handleDelete">删除
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="部门名称"
|
|
||||||
prop="name"
|
prop="name"
|
||||||
>
|
>
|
||||||
<el-input
|
<el-input
|
||||||
@@ -18,7 +25,6 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="状态"
|
|
||||||
prop="status"
|
prop="status"
|
||||||
>
|
>
|
||||||
<el-select
|
<el-select
|
||||||
@@ -55,30 +61,15 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row
|
|
||||||
:gutter="10"
|
|
||||||
class="mb8"
|
|
||||||
>
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
:icon="Plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
>
|
|
||||||
新增
|
|
||||||
</el-button>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
v-loading="dataMap.loading"
|
v-loading="dataMap.loading"
|
||||||
:data="dataMap.deptList"
|
:data="dataMap.deptList"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
default-expand-all
|
default-expand-all
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
|
@selection-change = "handleSelectionChange"
|
||||||
>
|
>
|
||||||
|
<el-table-column type="selection" width="55" align="center"/>
|
||||||
<el-table-column prop="name" label="部门名称"/>
|
<el-table-column prop="name" label="部门名称"/>
|
||||||
<el-table-column prop="status" label="状态" width="100">
|
<el-table-column prop="status" label="状态" width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@@ -195,8 +186,15 @@ import {listDept, getDept, delDept, updateDept, addDept, getDeptSelectList} from
|
|||||||
import TreeSelect from '@/components/TreeSelect/Index.vue'
|
import TreeSelect from '@/components/TreeSelect/Index.vue'
|
||||||
import {ElForm, ElMessage, ElMessageBox} from 'element-plus'
|
import {ElForm, ElMessage, ElMessageBox} from 'element-plus'
|
||||||
import {del} from "@api/system/client";
|
import {del} from "@api/system/client";
|
||||||
|
import {deleteDict} from "@api/system/dict";
|
||||||
|
|
||||||
const dataMap = reactive({
|
const dataMap = reactive({
|
||||||
|
// 选中ID数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
isAdd: false,
|
isAdd: false,
|
||||||
originOptions: [],
|
originOptions: [],
|
||||||
@@ -257,6 +255,14 @@ const dataMap = reactive({
|
|||||||
const queryForm = ref(ElForm)
|
const queryForm = ref(ElForm)
|
||||||
const formDialog = ref(ElForm)
|
const formDialog = ref(ElForm)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除按钮
|
||||||
|
* */
|
||||||
|
function handleSelectionChange(selection: any) {
|
||||||
|
dataMap.ids = selection.map((item: any) => item.id)
|
||||||
|
dataMap.single = selection.length === 0
|
||||||
|
}
|
||||||
|
|
||||||
/** 查询部门列表 */
|
/** 查询部门列表 */
|
||||||
function getList() {
|
function getList() {
|
||||||
dataMap.loading = true
|
dataMap.loading = true
|
||||||
@@ -362,13 +368,13 @@ function submitForm() {
|
|||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
async function handleDelete(row: any) {
|
async function handleDelete(row: any) {
|
||||||
|
const ids = [row.id || dataMap.ids].join(',')
|
||||||
ElMessageBox.confirm(`确认删除${row.name}部门?`, '警告', {
|
ElMessageBox.confirm(`确认删除已选中的数据项?`, '警告', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
delDept(row.id).then(rps=>{
|
delDept(ids).then(rps=>{
|
||||||
getList()
|
getList()
|
||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
}).catch(e=>{
|
}).catch(e=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user