This commit is contained in:
parent
8a8c9334d1
commit
cfbf23bd68
|
|
@ -5,10 +5,10 @@ VITE_APP_TITLE = 短信发送小工具
|
|||
VITE_APP_ENV = 'production'
|
||||
|
||||
# 短信发送小工具/生产环境
|
||||
VITE_APP_BASE_API = '/ynDigitalGadgets-prod-api'
|
||||
VITE_APP_BASE_API = '/ynMessage-prod-api/ynMessage'
|
||||
|
||||
#静态资源路径(服务器目录)
|
||||
VITE_APP_PUBLIC_PATH = '/ynDigitalGadgets'
|
||||
VITE_APP_PUBLIC_PATH = '/ynMessage'
|
||||
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 11 KiB |
|
|
@ -29,8 +29,8 @@ export function addJob(data) {
|
|||
// 修改定时任务调度
|
||||
export function updateJob(data) {
|
||||
return request({
|
||||
url: '/job',
|
||||
method: 'put',
|
||||
url: '/job/edit',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
|
@ -38,8 +38,11 @@ export function updateJob(data) {
|
|||
// 删除定时任务调度
|
||||
export function delJob(jobId) {
|
||||
return request({
|
||||
url: '/job/' + jobId,
|
||||
method: 'delete'
|
||||
url: '/job/delete/',
|
||||
method: 'POST',
|
||||
data: {
|
||||
jobId: jobId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 11 KiB |
|
|
@ -277,8 +277,17 @@ const onPersonSelectionChange = (selection) => {
|
|||
return
|
||||
}
|
||||
|
||||
// 更新直接选择的人员ID列表
|
||||
directSelectedPersonIds.value = selection.map((item) => item.id)
|
||||
// 获取当前过滤后可见的人员ID集合
|
||||
const visiblePersonIds = new Set(filteredPersonList.value.map((item) => item.id))
|
||||
|
||||
// 获取当前选中的可见人员ID集合
|
||||
const selectedVisibleIds = new Set(selection.map((item) => item.id))
|
||||
|
||||
// 保留不在当前过滤列表中的已选人员(这些人员被搜索过滤掉了,但应该保留)
|
||||
const preservedIds = directSelectedPersonIds.value.filter((id) => !visiblePersonIds.has(id))
|
||||
|
||||
// 合并保留的ID和当前选中的可见ID
|
||||
directSelectedPersonIds.value = [...preservedIds, ...selectedVisibleIds]
|
||||
|
||||
// 触发更新,合并所有选中的人员
|
||||
updateSelectedPersons()
|
||||
|
|
@ -333,7 +342,17 @@ const onGroupSelectionChange = (selection) => {
|
|||
return
|
||||
}
|
||||
|
||||
selectedGroupIds.value = selection.map((group) => group.id)
|
||||
// 获取当前过滤后可见的分组ID集合
|
||||
const visibleGroupIds = new Set(filteredGroupList.value.map((item) => item.id))
|
||||
|
||||
// 获取当前选中的可见分组ID集合
|
||||
const selectedVisibleIds = new Set(selection.map((group) => group.id))
|
||||
|
||||
// 保留不在当前过滤列表中的已选分组(这些分组被搜索过滤掉了,但应该保留)
|
||||
const preservedIds = selectedGroupIds.value.filter((id) => !visibleGroupIds.has(id))
|
||||
|
||||
// 合并保留的ID和当前选中的可见ID
|
||||
selectedGroupIds.value = [...preservedIds, ...selectedVisibleIds]
|
||||
|
||||
// 触发更新,合并所有选中的人员
|
||||
updateSelectedPersons()
|
||||
|
|
@ -401,34 +420,38 @@ const syncGroupTableSelection = () => {
|
|||
|
||||
// 移除单个人员
|
||||
const handleRemovePerson = (personId) => {
|
||||
// 检查该人员是否来自分组
|
||||
const groupsToRemove = []
|
||||
// 检查该人员是否在直接选择列表中
|
||||
const isDirectSelected = directSelectedPersonIds.value.includes(personId)
|
||||
|
||||
// 检查该人员是否来自分组
|
||||
const groupsContainingPerson = []
|
||||
selectedGroupIds.value.forEach((groupId) => {
|
||||
const group = groupList.value.find((g) => g.id === groupId)
|
||||
if (group && group.workerList && Array.isArray(group.workerList)) {
|
||||
const hasPerson = group.workerList.some((w) => w.id === personId)
|
||||
if (hasPerson) {
|
||||
groupsToRemove.push(groupId)
|
||||
groupsContainingPerson.push(groupId)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (groupsToRemove.length > 0) {
|
||||
// 如果人员来自分组,移除对应的分组
|
||||
selectedGroupIds.value = selectedGroupIds.value.filter((id) => !groupsToRemove.includes(id))
|
||||
updateSelectedPersons()
|
||||
nextTick(() => {
|
||||
syncGroupTableSelection()
|
||||
})
|
||||
} else {
|
||||
// 如果人员是直接选择的,从直接选择列表中移除
|
||||
// 如果人员既在直接选择列表中,又在分组中,只移除直接选择,保留分组
|
||||
if (isDirectSelected) {
|
||||
directSelectedPersonIds.value = directSelectedPersonIds.value.filter(
|
||||
(id) => id !== personId,
|
||||
)
|
||||
updateSelectedPersons()
|
||||
} else if (groupsContainingPerson.length > 0) {
|
||||
// 如果人员只来自分组(不在直接选择列表中),移除对应的分组
|
||||
selectedGroupIds.value = selectedGroupIds.value.filter(
|
||||
(id) => !groupsContainingPerson.includes(id),
|
||||
)
|
||||
nextTick(() => {
|
||||
syncGroupTableSelection()
|
||||
})
|
||||
}
|
||||
|
||||
updateSelectedPersons()
|
||||
|
||||
// 同步人员表格
|
||||
nextTick(() => {
|
||||
syncPersonTableSelection()
|
||||
|
|
@ -482,42 +505,31 @@ const getGroupList = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
// 监听 modelValue 变化,同步表格选中状态和区分直接选择的人员
|
||||
// 监听 modelValue 变化,仅在初始化时同步(避免干扰用户操作)
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
// 如果内部状态已经有数据,说明是用户操作导致的,不需要反向同步
|
||||
// 只在初始化时(两个列表都为空)才同步
|
||||
if (directSelectedPersonIds.value.length > 0 || selectedGroupIds.value.length > 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!newVal || newVal.length === 0) {
|
||||
directSelectedPersonIds.value = []
|
||||
return
|
||||
}
|
||||
|
||||
// 区分哪些是直接选择的人员,哪些是来自分组的
|
||||
const directSelectedIds = []
|
||||
const groupPersonIds = new Set()
|
||||
|
||||
// 收集所有分组中的人员ID
|
||||
selectedGroupIds.value.forEach((groupId) => {
|
||||
const group = groupList.value.find((g) => g.id === groupId)
|
||||
if (group && group.workerList && Array.isArray(group.workerList)) {
|
||||
group.workerList.forEach((worker) => {
|
||||
if (worker && worker.id) {
|
||||
groupPersonIds.add(worker.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 如果人员不在分组中,则认为是直接选择的
|
||||
newVal.forEach((person) => {
|
||||
if (person && person.id && !groupPersonIds.has(person.id)) {
|
||||
directSelectedIds.push(person.id)
|
||||
}
|
||||
})
|
||||
|
||||
directSelectedPersonIds.value = directSelectedIds
|
||||
// 初始化时,尝试区分哪些是直接选择的人员
|
||||
// 由于此时还没有分组数据,先假设所有人员都是直接选择的
|
||||
// 等分组数据加载后,会通过 updateSelectedPersons 重新计算
|
||||
const personIds = newVal.map((p) => p.id).filter(Boolean)
|
||||
directSelectedPersonIds.value = personIds
|
||||
|
||||
if (activeTab.value === 'person') {
|
||||
syncPersonTableSelection()
|
||||
nextTick(() => {
|
||||
syncPersonTableSelection()
|
||||
})
|
||||
}
|
||||
},
|
||||
{ deep: true, immediate: true },
|
||||
|
|
|
|||
|
|
@ -4,4 +4,5 @@ export const bus = mitt()
|
|||
// 定义事件名称常量
|
||||
export const BUS_EVENTS = {
|
||||
REFRESH_OPTIONS: 'REFRESH_OPTIONS', // 刷新下拉选项信号
|
||||
REFRESH_LOOP_SEND_LIST: 'REFRESH_LOOP_SEND_LIST', // 刷新循环发送任务列表
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ const rules = {
|
|||
workerName: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
sex: [{ required: true, message: '请选择性别', trigger: 'change' }],
|
||||
phone: [
|
||||
{ required: true, message: '请输入电话', trigger: 'blur' },
|
||||
{
|
||||
pattern: /^1[3-9]\d{9}$/,
|
||||
message: '请输入正确的手机号码',
|
||||
|
|
|
|||
|
|
@ -3,41 +3,33 @@ import CryptoUtil from "../../../api/crypto.js";
|
|||
|
||||
// 根据下拉数据构建搜索表单配置
|
||||
// 注意:这里不直接发请求,只依赖调用方传入的 options,避免在模块顶层使用组合式 API
|
||||
export const buildFormColumns = (
|
||||
positionOptions = [],
|
||||
natureOptions = [],
|
||||
categoryOptions = [],
|
||||
) => [
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'name',
|
||||
placeholder: '请输入姓名',
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
prop: 'sex',
|
||||
placeholder: '请选择性别',
|
||||
options: [
|
||||
{
|
||||
label: '男',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '女',
|
||||
value: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
prop: 'positionId',
|
||||
placeholder: '请选择部门',
|
||||
options: positionOptions.map((item) => ({
|
||||
label: item.value,
|
||||
value: item.id,
|
||||
})),
|
||||
},
|
||||
]
|
||||
export const buildFormColumns = [
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'orgName',
|
||||
placeholder: '请输入部门名称',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'workerName',
|
||||
placeholder: '请输入姓名',
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
prop: 'sex',
|
||||
placeholder: '请选择性别',
|
||||
options: [
|
||||
{
|
||||
label: '男',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '女',
|
||||
value: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
export const tableColumns = [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<!-- 人员管理 -->
|
||||
<ComTable
|
||||
ref="comTableRef"
|
||||
:form-columns="[]"
|
||||
:form-columns="buildFormColumns"
|
||||
:table-columns="tableColumns"
|
||||
:load-data="listPersonAPI"
|
||||
:show-toolbar="true"
|
||||
|
|
@ -99,7 +99,7 @@ import ComDialog from '@/components/ComDialog/index.vue'
|
|||
import AddAndEditForm from './addAndEditForm.vue'
|
||||
import CryptoUtil from '../../../api/crypto.js'
|
||||
|
||||
const { tableColumns, dialogConfig } = config
|
||||
const { tableColumns, dialogConfig, buildFormColumns } = config
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const formRef = ref(null)
|
||||
|
|
@ -157,7 +157,8 @@ const actionColumns = [
|
|||
orgId: orgId || null,
|
||||
orgName: orgName || '',
|
||||
workerName: workerName || '',
|
||||
phone: phone ? CryptoUtil.decrypt(phone) : '',
|
||||
// phone: phone ? CryptoUtil.decrypt(phone) : '',
|
||||
phone,
|
||||
sex: sex !== undefined ? sex * 1 : 1,
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -138,7 +138,6 @@
|
|||
:data="formData.recipientList"
|
||||
border
|
||||
style="margin-top: 10px"
|
||||
max-height="200"
|
||||
>
|
||||
<el-table-column align="center" prop="workerName" label="姓名" />
|
||||
<el-table-column align="center" prop="phone" label="电话" />
|
||||
|
|
@ -211,6 +210,7 @@ import {
|
|||
import ComButton from '@/components/ComButton/index.vue'
|
||||
import ComDialog from '@/components/ComDialog/index.vue'
|
||||
import PersonPicker from '@/components/PersonPicker/index.vue'
|
||||
import { bus, BUS_EVENTS } from '@/utils/bus'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
|
@ -373,6 +373,8 @@ const onSubmit = async () => {
|
|||
const result = await API(params)
|
||||
if (result.code === 200) {
|
||||
proxy.$modal.msgSuccess(mode.value === 'edit' ? '编辑成功' : '新增成功')
|
||||
// 通知父页面刷新列表
|
||||
bus.emit(BUS_EVENTS.REFRESH_LOOP_SEND_LIST)
|
||||
onBack()
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -563,7 +565,12 @@ onMounted(() => {
|
|||
}
|
||||
|
||||
.page-footer {
|
||||
margin-top: 12px;
|
||||
position: sticky;
|
||||
bottom: 10px;
|
||||
background: #fff;
|
||||
z-index: 10;
|
||||
border-top: 1px solid #e4e7ed;
|
||||
padding-top: 15px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
</template>
|
||||
|
||||
<script setup name="LoopSend">
|
||||
import { ref, computed, getCurrentInstance, onMounted, reactive } from 'vue'
|
||||
import { ref, computed, getCurrentInstance, onMounted, onUnmounted, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { debounce } from 'lodash-es'
|
||||
import {
|
||||
|
|
@ -59,6 +59,7 @@ import ComTable from '@/components/ComTable/index.vue'
|
|||
import ComButton from '@/components/ComButton/index.vue'
|
||||
import ComDialog from '@/components/ComDialog/index.vue'
|
||||
import SendDetails from './sendDetails.vue'
|
||||
import { bus, BUS_EVENTS } from '@/utils/bus'
|
||||
|
||||
const router = useRouter()
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
|
@ -118,7 +119,7 @@ const actionColumns = [
|
|||
|
||||
handler: (row) => {
|
||||
proxy.$modal.confirm('是否确认删除该循环发送任务?').then(async () => {
|
||||
const result = await delLoopSendAPI({ id: row.id })
|
||||
const result = await delLoopSendAPI({ id: row.id, jobId: row.jobId })
|
||||
if (result.code === 200) {
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
comTableRef.value?.refresh()
|
||||
|
|
@ -237,8 +238,20 @@ const onCloseSendDetailsDialog = (visible) => {
|
|||
sendDetailsDialogConfig.outerVisible = visible
|
||||
}
|
||||
|
||||
// 监听刷新列表事件
|
||||
const handleRefreshList = () => {
|
||||
comTableRef.value?.refresh()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getSmsBalance()
|
||||
// 监听刷新列表事件
|
||||
bus.on(BUS_EVENTS.REFRESH_LOOP_SEND_LIST, handleRefreshList)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
// 组件卸载时移除事件监听
|
||||
bus.off(BUS_EVENTS.REFRESH_LOOP_SEND_LIST, handleRefreshList)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,282 +1,361 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
|
||||
<el-form-item label="部门名称" prop="deptName">
|
||||
<el-input
|
||||
v-model="queryParams.deptName"
|
||||
placeholder="请输入部门名称"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="部门状态" clearable style="width: 200px">
|
||||
<el-option
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
|
||||
<el-form-item label="部门名称" prop="deptName">
|
||||
<el-input
|
||||
v-model="queryParams.deptName"
|
||||
placeholder="请输入部门名称"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="部门状态"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['system:dept:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="Sort"
|
||||
@click="toggleExpandAll"
|
||||
>展开/折叠</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['system:dept:add']"
|
||||
>新增</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="info" plain icon="Sort" @click="toggleExpandAll"
|
||||
>展开/折叠</el-button
|
||||
>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-if="refreshTable"
|
||||
v-loading="loading"
|
||||
:data="deptList"
|
||||
row-key="deptId"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
|
||||
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_normal_disable" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']">新增</el-button>
|
||||
<el-button v-if="scope.row.parentId != 0" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-table
|
||||
v-if="refreshTable"
|
||||
v-loading="loading"
|
||||
:data="deptList"
|
||||
row-key="deptId"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
|
||||
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_normal_disable" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:dept:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Plus"
|
||||
@click="handleAdd(scope.row)"
|
||||
v-hasPermi="['system:dept:add']"
|
||||
>新增</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="scope.row.parentId != 0"
|
||||
link
|
||||
type="primary"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:dept:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加或修改部门对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||
<el-form ref="deptRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-row>
|
||||
<el-col :span="24" v-if="form.parentId !== 0">
|
||||
<el-form-item label="上级部门" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="form.parentId"
|
||||
:data="deptOptions"
|
||||
:props="{ value: 'deptId', label: 'deptName', children: 'children' }"
|
||||
value-key="deptId"
|
||||
placeholder="选择上级部门"
|
||||
check-strictly
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="部门名称" prop="deptName">
|
||||
<el-input v-model="form.deptName" placeholder="请输入部门名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="显示排序" prop="orderNum">
|
||||
<el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="负责人" prop="leader">
|
||||
<el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系电话" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="部门状态">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>{{ dict.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<!-- 添加或修改部门对话框 -->
|
||||
<ComDialog :dialog-config="dialogConfig" @closeDialogOuter="onCloseDialogOuter">
|
||||
<template #outerContent>
|
||||
<el-form ref="deptRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-row>
|
||||
<el-col :span="24" v-if="form.parentId !== 0">
|
||||
<el-form-item label="上级部门" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="form.parentId"
|
||||
:data="deptOptions"
|
||||
:props="{
|
||||
value: 'deptId',
|
||||
label: 'deptName',
|
||||
children: 'children',
|
||||
}"
|
||||
value-key="deptId"
|
||||
placeholder="选择上级部门"
|
||||
check-strictly
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="部门名称" prop="deptName">
|
||||
<el-input v-model="form.deptName" placeholder="请输入部门名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="显示排序" prop="orderNum">
|
||||
<el-input-number
|
||||
v-model="form.orderNum"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="负责人" prop="leader">
|
||||
<el-input
|
||||
v-model="form.leader"
|
||||
placeholder="请输入负责人"
|
||||
maxlength="20"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系电话" prop="phone">
|
||||
<el-input
|
||||
v-model="form.phone"
|
||||
placeholder="请输入联系电话"
|
||||
maxlength="11"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input
|
||||
v-model="form.email"
|
||||
placeholder="请输入邮箱"
|
||||
maxlength="50"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="部门状态">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>{{ dict.label }}</el-radio
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<el-row class="common-btn-row">
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
</el-row>
|
||||
</template>
|
||||
</ComDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Dept">
|
||||
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"
|
||||
import {
|
||||
listDept,
|
||||
getDept,
|
||||
delDept,
|
||||
addDept,
|
||||
updateDept,
|
||||
listDeptExcludeChild,
|
||||
} from '@/api/system/dept'
|
||||
import ComDialog from '@/components/ComDialog/index.vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { sys_normal_disable } = proxy.useDict("sys_normal_disable")
|
||||
const { sys_normal_disable } = proxy.useDict('sys_normal_disable')
|
||||
|
||||
const deptList = ref([])
|
||||
const open = ref(false)
|
||||
const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const title = ref("")
|
||||
const deptOptions = ref([])
|
||||
const isExpandAll = ref(true)
|
||||
const refreshTable = ref(true)
|
||||
|
||||
// 弹框配置
|
||||
const dialogConfig = reactive({
|
||||
outerVisible: false,
|
||||
outerTitle: '',
|
||||
outerWidth: '600px',
|
||||
minHeight: '320px',
|
||||
maxHeight: '80vh',
|
||||
})
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
deptName: undefined,
|
||||
status: undefined
|
||||
},
|
||||
rules: {
|
||||
parentId: [{ required: true, message: "上级部门不能为空", trigger: "blur" }],
|
||||
deptName: [{ required: true, message: "部门名称不能为空", trigger: "blur" }],
|
||||
orderNum: [{ required: true, message: "显示排序不能为空", trigger: "blur" }],
|
||||
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
||||
phone: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }]
|
||||
},
|
||||
form: {},
|
||||
queryParams: {
|
||||
deptName: undefined,
|
||||
status: undefined,
|
||||
},
|
||||
rules: {
|
||||
parentId: [{ required: true, message: '上级部门不能为空', trigger: 'blur' }],
|
||||
deptName: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }],
|
||||
orderNum: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }],
|
||||
email: [{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }],
|
||||
phone: [
|
||||
{
|
||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||
message: '请输入正确的手机号码',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
/** 查询部门列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listDept(queryParams.value).then(response => {
|
||||
deptList.value = proxy.handleTree(response.data, "deptId")
|
||||
loading.value = false
|
||||
})
|
||||
loading.value = true
|
||||
listDept(queryParams.value).then((response) => {
|
||||
deptList.value = proxy.handleTree(response.data, 'deptId')
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/** 取消按钮 */
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
dialogConfig.outerVisible = false
|
||||
reset()
|
||||
}
|
||||
|
||||
/** 关闭弹框统一处理 */
|
||||
function onCloseDialogOuter(visible) {
|
||||
dialogConfig.outerVisible = visible
|
||||
if (!visible) {
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
function reset() {
|
||||
form.value = {
|
||||
deptId: undefined,
|
||||
parentId: undefined,
|
||||
deptName: undefined,
|
||||
orderNum: 0,
|
||||
leader: undefined,
|
||||
phone: undefined,
|
||||
email: undefined,
|
||||
status: "0"
|
||||
}
|
||||
proxy.resetForm("deptRef")
|
||||
form.value = {
|
||||
deptId: undefined,
|
||||
parentId: undefined,
|
||||
deptName: undefined,
|
||||
orderNum: 0,
|
||||
leader: undefined,
|
||||
phone: undefined,
|
||||
email: undefined,
|
||||
status: '0',
|
||||
}
|
||||
proxy.resetForm('deptRef')
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
getList()
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
proxy.resetForm('queryRef')
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd(row) {
|
||||
reset()
|
||||
listDept().then(response => {
|
||||
deptOptions.value = proxy.handleTree(response.data, "deptId")
|
||||
})
|
||||
if (row != undefined) {
|
||||
form.value.parentId = row.deptId
|
||||
}
|
||||
open.value = true
|
||||
title.value = "添加部门"
|
||||
reset()
|
||||
listDept().then((response) => {
|
||||
deptOptions.value = proxy.handleTree(response.data, 'deptId')
|
||||
})
|
||||
if (row != undefined) {
|
||||
form.value.parentId = row.deptId
|
||||
}
|
||||
dialogConfig.outerTitle = '添加部门'
|
||||
dialogConfig.outerVisible = true
|
||||
}
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
function toggleExpandAll() {
|
||||
refreshTable.value = false
|
||||
isExpandAll.value = !isExpandAll.value
|
||||
nextTick(() => {
|
||||
refreshTable.value = true
|
||||
})
|
||||
refreshTable.value = false
|
||||
isExpandAll.value = !isExpandAll.value
|
||||
nextTick(() => {
|
||||
refreshTable.value = true
|
||||
})
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
listDeptExcludeChild(row.deptId).then(response => {
|
||||
deptOptions.value = proxy.handleTree(response.data, "deptId")
|
||||
})
|
||||
getDept(row.deptId).then(response => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = "修改部门"
|
||||
})
|
||||
reset()
|
||||
listDeptExcludeChild(row.deptId).then((response) => {
|
||||
deptOptions.value = proxy.handleTree(response.data, 'deptId')
|
||||
})
|
||||
getDept(row.deptId).then((response) => {
|
||||
form.value = response.data
|
||||
dialogConfig.outerTitle = '修改部门'
|
||||
dialogConfig.outerVisible = true
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["deptRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (form.value.deptId != undefined) {
|
||||
updateDept(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addDept(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
proxy.$refs['deptRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.value.deptId != undefined) {
|
||||
updateDept(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess('修改成功')
|
||||
dialogConfig.outerVisible = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addDept(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess('新增成功')
|
||||
dialogConfig.outerVisible = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
proxy.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function() {
|
||||
return delDept(row.deptId)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
proxy.$modal
|
||||
.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?')
|
||||
.then(function () {
|
||||
return delDept(row.deptId)
|
||||
})
|
||||
.then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
getList()
|
||||
|
|
|
|||
|
|
@ -539,11 +539,11 @@ const appStore = useAppStore()
|
|||
const { proxy } = getCurrentInstance()
|
||||
const { sys_normal_disable, sys_user_sex } = proxy.useDict('sys_normal_disable', 'sys_user_sex')
|
||||
|
||||
const { options: allPositionAndInspectionStationOptions } = useOptions(
|
||||
'allPositionAndInspectionStationOptions',
|
||||
getInspectionStationSelectAPI,
|
||||
{},
|
||||
)
|
||||
// const { options: allPositionAndInspectionStationOptions } = useOptions(
|
||||
// 'allPositionAndInspectionStationOptions',
|
||||
// getInspectionStationSelectAPI,
|
||||
// {},
|
||||
// )
|
||||
|
||||
const userList = ref([])
|
||||
const loading = ref(true)
|
||||
|
|
|
|||
Loading…
Reference in New Issue