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