Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-ui
Commits
1ceb7419
提交
1ceb7419
authored
1月 14, 2025
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(post): 重构给岗位分配考勤规则
同上
上级
b7b16f3f
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
86 行增加
和
27 行删除
+86
-27
index.vue
src/components/OpenDialog/index.vue
+65
-21
index.vue
src/views/system/post/index.vue
+21
-6
没有找到文件。
src/components/OpenDialog/index.vue
浏览文件 @
1ceb7419
<
template
>
<
template
>
<div>
<div>
<el-form
<el-form
:model=
"form"
:model=
"form"
inline
>
inline
>
<el-form-item
v-for=
"(obj, key) in form"
<el-form-item
v-for=
"(obj, key) in form"
:key=
"key"
:key=
"key"
...
@@ -16,14 +15,15 @@
...
@@ -16,14 +15,15 @@
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<!-- 添加表格和其他内容 -->
<!-- 添加表格和其他内容 -->
<el-table
ref=
"
myTable
"
<el-table
ref=
"
tableRef
"
:data=
"tableData"
:data=
"tableData"
v-loading=
"tableLoading"
v-loading=
"tableLoading"
highlight-selection-row
highlight-selection-row
@
select=
"selectFn"
:row-key=
"nodeKey"
@
select-all=
"selectAllFn"
>
:select-on-indeterminate=
"false"
<el-table-column
v-if=
"tableData.length > 0"
@
select=
"select"
type=
"selection"
@
select-all=
"selectAll"
>
<el-table-column
type=
"selection"
width=
"50"
>
width=
"50"
>
</el-table-column>
</el-table-column>
<el-table-column
v-for=
"obj in tableHeaderList"
<el-table-column
v-for=
"obj in tableHeaderList"
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
<
script
setup
>
<
script
setup
>
import
{
debounce
}
from
'@/utils'
;
import
{
debounce
}
from
'@/utils'
;
const
tableRef
=
ref
(
null
)
// 表格实例
const
form
=
ref
({});
// 表单对象
const
form
=
ref
({});
// 表单对象
const
tableHeaderList
=
ref
([]);
const
tableHeaderList
=
ref
([]);
const
tableData
=
ref
([]);
const
tableData
=
ref
([]);
...
@@ -48,20 +49,56 @@ const isOnlyLoadData = ref(false); // 仅加载数据(因为标签和数据是
...
@@ -48,20 +49,56 @@ const isOnlyLoadData = ref(false); // 仅加载数据(因为标签和数据是
const
props
=
defineProps
({
const
props
=
defineProps
({
// 结构+数据
// 结构+数据
modelValue
:
{
structData
:
{
type
:
Object
,
type
:
Object
,
required
:
true
required
:
true
},
},
// 选择的数据(要和 structData 里的 rows 数据一致)
modelValue
:
{
type
:
Array
,
default
:
()
=>
[],
required
:
true
},
// 查询参数
// 查询参数
queryParams
:
{
queryParams
:
{
type
:
Object
,
type
:
Object
,
required
:
true
default
:
()
=>
({})
},
// 关键数据的属性
nodeKey
:
{
type
:
String
,
default
:
'id'
},
// 是否单选
isRadio
:
{
type
:
Boolean
,
default
:
false
}
}
});
});
const
emits
=
defineEmits
([
'sel'
,
'update:queryParams'
]);
const
emits
=
defineEmits
([
'
update:modelValue'
,
'
sel'
,
'update:queryParams'
]);
watch
(()
=>
props
.
modelValue
,
(
newValue
)
=>
{
// 更新表格行选中
const
updateCheck
=
(
newValue
)
=>
{
nextTick
(()
=>
{
if
(
newValue
.
length
>
0
)
{
// 遍历对比,选中/取消选中
props
.
structData
.
rows
.
forEach
(
o
=>
{
// 参数 2:决定选中与否
tableRef
.
value
.
toggleRowSelection
(
o
,
newValue
.
some
(
item
=>
item
[
props
.
nodeKey
]
===
o
[
props
.
nodeKey
]),
false
)
})
}
else
{
tableRef
.
value
.
clearSelection
()
}
})
}
watch
(()
=>
props
.
modelValue
,
updateCheck
,
{
deep
:
true
,
immediate
:
true
})
watch
(()
=>
props
.
structData
,
(
newValue
)
=>
{
// 加载结构
// 加载结构
if
(
!
isOnlyLoadData
.
value
)
{
if
(
!
isOnlyLoadData
.
value
)
{
// 准备表单结构
// 准备表单结构
...
@@ -73,6 +110,7 @@ watch(() => props.modelValue, (newValue) => {
...
@@ -73,6 +110,7 @@ watch(() => props.modelValue, (newValue) => {
// 加载数据
// 加载数据
tableData
.
value
=
newValue
.
rows
;
tableData
.
value
=
newValue
.
rows
;
tableLoading
.
value
=
false
;
tableLoading
.
value
=
false
;
updateCheck
(
props
.
modelValue
)
},
{
},
{
deep
:
true
,
deep
:
true
,
immediate
:
true
immediate
:
true
...
@@ -96,19 +134,25 @@ const sel = debounce(() => {
...
@@ -96,19 +134,25 @@ const sel = debounce(() => {
emits
(
'sel'
);
emits
(
'sel'
);
});
});
const
selectAllFn
=
(
rows
)
=>
{
// 全选
if
(
!
props
.
isCheckBox
)
{
const
selectAll
=
(
selection
)
=>
{
table
.
clearSelection
();
if
(
props
.
isRadio
)
{
emits
(
'input'
,
[]);
// 实现单选
emits
(
'update:modelValue'
,
selection
.
length
>
0
?
[
selection
[
selection
.
length
-
1
]]
:
[]);
}
else
{
// 实现多选
emits
(
'update:modelValue'
,
selection
);
}
}
};
};
// 手动选中
const
selectFn
=
(
rows
)
=>
{
const
select
=
(
rows
)
=>
{
if
(
!
props
.
isCheckBox
)
{
if
(
props
.
isRadio
)
{
table
.
clearSelection
();
// 实现单选
rows
.
length
>
0
&&
table
.
toggleRowSelection
(
rows
[
rows
.
length
-
1
]);
emits
(
'update:modelValue'
,
rows
.
length
>
0
?
[
rows
[
rows
.
length
-
1
]]
:
[]);
}
else
{
// 实现多选
emits
(
'update:modelValue'
,
rows
);
}
}
emits
(
'input'
,
rows
.
length
>
0
?
[
rows
[
rows
.
length
-
1
]]
:
[]);
};
};
</
script
>
</
script
>
...
...
src/views/system/post/index.vue
浏览文件 @
1ceb7419
...
@@ -169,17 +169,21 @@
...
@@ -169,17 +169,21 @@
<
template
#
reference
>
<
template
#
reference
>
<el-input-tag
v-model=
"form.ruleList"
<el-input-tag
v-model=
"form.ruleList"
tag-type=
"primary"
tag-type=
"primary"
tag-effect=
"plain"
tag-effect=
"light"
placeholder=
"选择考勤规则"
>
placeholder=
"选择考勤规则"
clearable
>
<template
#
tag=
"
{ value }">
<template
#
tag=
"
{ value }">
<div
class=
"flex items-center"
>
>
<div
class=
"flex items-center"
@
click
.
stop
>
<span>
{{
value
}}
</span>
<span>
{{
value
.
ruleName
}}
</span>
</div>
</div>
</
template
>
</
template
>
</el-input-tag>
</el-input-tag>
</template>
</template>
<open-dialog
v-model=
"attStruData"
<open-dialog
v-model=
"form.ruleList"
:structData=
"attStruData"
v-model:queryParams=
"attQuery"
v-model:queryParams=
"attQuery"
nodeKey=
"ruleId"
isRadio
@
sel=
"getAttOpenDialog"
/>
@
sel=
"getAttOpenDialog"
/>
</el-popover>
</el-popover>
</el-form-item>
</el-form-item>
...
@@ -230,7 +234,9 @@
...
@@ -230,7 +234,9 @@
const
attStruData
=
ref
({});
// 考勤开窗结构+对象
const
attStruData
=
ref
({});
// 考勤开窗结构+对象
const
data
=
reactive
({
const
data
=
reactive
({
form
:
{},
form
:
{
},
queryParams
:
{
queryParams
:
{
pageNum
:
1
,
pageNum
:
1
,
pageSize
:
10
,
pageSize
:
10
,
...
@@ -263,6 +269,10 @@
...
@@ -263,6 +269,10 @@
attStruData
.
value
=
data
attStruData
.
value
=
data
}
}
getAttOpenDialog
()
getAttOpenDialog
()
// 考勤规则改变
const
ruleChange
=
(
val
)
=>
{
console
.
log
(
val
)
}
/** 取消按钮 */
/** 取消按钮 */
function
cancel
()
{
function
cancel
()
{
...
@@ -315,6 +325,9 @@
...
@@ -315,6 +325,9 @@
const
postId
=
row
.
postId
||
ids
.
value
;
const
postId
=
row
.
postId
||
ids
.
value
;
getPost
(
postId
).
then
(
response
=>
{
getPost
(
postId
).
then
(
response
=>
{
form
.
value
=
response
.
data
;
form
.
value
=
response
.
data
;
form
.
value
.
ruleList
=
[
attStruData
.
value
.
rows
.
find
(
o
=>
{
return
o
.
ruleId
===
response
.
data
.
ruleId
})]
open
.
value
=
true
;
open
.
value
=
true
;
title
.
value
=
"修改岗位"
;
title
.
value
=
"修改岗位"
;
});
});
...
@@ -323,6 +336,8 @@
...
@@ -323,6 +336,8 @@
/** 提交按钮 */
/** 提交按钮 */
function
submitForm
()
{
function
submitForm
()
{
proxy
.
$refs
[
"postRef"
].
validate
(
valid
=>
{
proxy
.
$refs
[
"postRef"
].
validate
(
valid
=>
{
form
.
value
.
ruleId
=
form
.
value
.
ruleList
[
0
].
ruleId
form
.
value
.
ruleName
=
form
.
value
.
ruleList
[
0
].
ruleName
if
(
valid
)
{
if
(
valid
)
{
if
(
form
.
value
.
postId
!=
undefined
)
{
if
(
form
.
value
.
postId
!=
undefined
)
{
updatePost
(
form
.
value
).
then
(
response
=>
{
updatePost
(
form
.
value
).
then
(
response
=>
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论