福利整改

This commit is contained in:
2026-11-16 08:46:29 +08:00
parent d5077d092c
commit b6cb965bf4
16 changed files with 908 additions and 33 deletions
@@ -74,6 +74,7 @@ const filterUser = {
</el-select>
</search-item>
<!-- 福利模块暂不提供三级单位筛选,保留控件代码便于恢复。
<search-item label="三级单位">
<el-select clearable filterable placeholder="请先选择所属单位" style="width: 100%"
v-model="pageForm.threeUnitId">
@@ -85,6 +86,7 @@ const filterUser = {
</el-option>
</el-select>
</search-item>
-->
<search-item label="人员类型:">
<dict-select clearable code="USER_PERSON_TYPE"
@@ -94,6 +96,7 @@ const filterUser = {
v-model="pageForm.personTypes"></dict-select>
</search-item>
<!-- 福利模块暂不提供人员属性筛选,保留控件代码便于恢复。
<search-item label="人员属性:">
<dict-select clearable code="USER_ATTRIBUTE"
multiple
@@ -101,6 +104,7 @@ const filterUser = {
placeholder="请选择人员属性"
v-model="pageForm.userAttributes"></dict-select>
</search-item>
-->
<search-item label="在职状态:">
<dict-select clearable code="USER_STATE"
@@ -61,14 +61,24 @@ layout("/layouts/platform.html"){
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in unitOptions"></el-option>
</el-select>
</search-item>
<search-item label="人员分类">
<dict-select v-model="pageForm.aidFundMemberUserType" placeholder="请选择人员分类" @change="doSearch"
code="AIDFUND_MEMBER_USER_TYPE"></dict-select>
</search-item>
<search-item label="人员属性">
<dict-select v-model="pageForm.userAttribute" placeholder="请选择人员属性" @change="doSearch"
code="USER_ATTRIBUTE"></dict-select>
</search-item>
<!-- 福利模块暂不提供人员分类、人员属性筛选,保留控件代码便于恢复。
<search-item label="人员分类">
<dict-select
v-model="pageForm.aidFundMemberUserType"
placeholder="请选择人员分类"
@change="doSearch"
code="AIDFUND_MEMBER_USER_TYPE"
></dict-select>
</search-item>
<search-item label="人员属性">
<dict-select
v-model="pageForm.userAttribute"
placeholder="请选择人员属性"
@change="doSearch"
code="USER_ATTRIBUTE"
></dict-select>
</search-item>
-->
<template #actions>
<el-button @click="resetSearch">重置</el-button>
</template>
@@ -0,0 +1,505 @@
const batchSelectDialog = {
template: /*language=HTML*/ `
<div>
<el-dialog
class="welfare-batch-dialog"
title="一键分配套餐"
width="820px"
top="6vh"
:visible="visible"
:close-on-click-modal="false"
:close-on-press-escape="!formLoading"
:show-close="!formLoading"
:before-close="onClose">
<div v-loading="tableLoading">
<p class="welfare-batch-subtitle">为尚未选择福利的人员统一分配套餐</p>
<el-alert
title="仅分配给未选择人员,已选择人员不受影响"
type="info"
show-icon
:closable="false">
</el-alert>
<el-alert
v-if="loadError"
class="welfare-batch-error"
:title="loadError"
type="error"
show-icon
:closable="false">
</el-alert>
<template v-if="project.id">
<div class="welfare-batch-overview">
<div class="welfare-batch-project">
<span>福利项目</span>
<strong>{{ project.name }}</strong>
</div>
<div class="welfare-batch-people">
<span>待分配人数</span>
<strong>{{ unSelectedCount }} 人</strong>
</div>
</div>
<div class="welfare-batch-rules">
<strong>项目选择规则</strong>
<div>{{ ruleText }}</div>
<div v-if="systemDefaultOption" class="welfare-batch-muted">
系统默认套餐自动选中,不可取消,份数计入可选上限。
</div>
</div>
<div class="welfare-batch-heading">
<strong>选择福利套餐</strong>
<span>每人已选 <b>{{ selectedCount }}</b> / {{ selectionLimit }} 份</span>
</div>
<div class="welfare-batch-options">
<div
v-for="option in options"
:key="option.id"
class="welfare-batch-option"
:class="{ 'is-selected': option.selectNum > 0 }">
<el-radio
v-if="isSingle"
:value="selectedRadioId"
:label="option.id"
:disabled="formLoading || !!systemDefaultOption"
@change="selectSingle(option)">
<span class="welfare-batch-radio-label">选择{{ option.optionName }}</span>
</el-radio>
<el-image
class="welfare-batch-image"
:src="imageUrl(option.imgUrl)"
fit="contain">
<div slot="error" class="welfare-batch-image-empty">
<i class="el-icon-picture-outline"></i>
</div>
</el-image>
<div class="welfare-batch-option-content">
<div class="welfare-batch-option-title">
<strong>{{ option.optionName }}</strong>
<el-tag v-if="option.isSystemDefault" size="mini">系统默认</el-tag>
</div>
<div v-if="option.simpleDesc || option.supplier" class="welfare-batch-muted">
{{ option.simpleDesc || option.supplier }}
</div>
</div>
<span v-if="isSingle && option.selectNum > 0" class="welfare-batch-selected">已选择</span>
<el-input-number
v-if="!isSingle"
size="small"
:value="option.selectNum"
:min="option.isSystemDefault ? 1 : 0"
:max="optionMax(option)"
:precision="0"
:step="1"
:step-strictly="true"
:disabled="formLoading"
@change="changeQuantity(option, $event)">
</el-input-number>
</div>
</div>
<p v-if="selectedCount >= selectionLimit" class="welfare-batch-muted welfare-batch-limit">
已达项目可选上限,可调整选择后重新分配。
</p>
<p v-if="unSelectedCount === 0" class="welfare-batch-muted welfare-batch-limit">
当前没有需要分配的未选人员。
</p>
<div class="welfare-batch-summary">
<strong>
每位未选人员将获得:
<span>{{ selectionSummary || '请先选择福利套餐' }}</span>
</strong>
<div class="welfare-batch-muted">
共 {{ unSelectedCount }} 人,每人 {{ selectedCount }} 份;提交时重新核验,已选择人员自动跳过。
</div>
</div>
</template>
</div>
<template slot="footer">
<el-button :disabled="formLoading" @click="onClose()">取消</el-button>
<el-button
type="primary"
:loading="formLoading"
:disabled="!canSubmit"
@click="submit">
确认分配({{ unSelectedCount }}人)
</el-button>
</template>
</el-dialog>
<slot></slot>
</div>
`,
data() {
return {
visible: false,
tableLoading: false,
formLoading: false,
projectId: "",
unionId: "",
project: {},
options: [],
unSelectedCount: 0,
loadError: "",
requestVersion: 0
}
},
computed: {
isSingle() {
return this.project.isCheckBox === "radio"
},
selectionLimit() {
return this.isSingle ? 1 : Number(this.project.multiSelectNum || 0)
},
systemDefaultOption() {
return this.options.find((option) => option.isSystemDefault)
},
selectedRadioId() {
const selected = this.options.find((option) => option.selectNum > 0)
return selected ? selected.id : ""
},
selectedCount() {
return this.options.reduce((total, option) => total + option.selectNum, 0)
},
ruleText() {
if (this.isSingle) {
return "单选 · 每人选择 1 份"
}
const multipleRule = this.project.singleOptionSupportMultipleSelection
? "同一套餐可选多份" : "同一套餐最多 1 份"
return "多选 · 每人最多 " + this.selectionLimit + " 份 · " + multipleRule
},
selectionSummary() {
return this.options
.filter((option) => option.selectNum > 0)
.map((option) => option.optionName + " × " + option.selectNum + " 份")
.join(" + ")
},
canSubmit() {
return !!this.project.id && !this.loadError && !this.tableLoading && !this.formLoading
&& this.unSelectedCount > 0 && this.selectedCount > 0
&& this.selectedCount <= this.selectionLimit
}
},
methods: {
/**
* projectId 为当前福利项目 ID,unionId 为页面工会筛选。
* 初始化接口返回 data.project(项目规则及 options)和 data.unSelectedCount(未选人数)。
* 每次打开重新加载;请求版本号防止关闭后迟到的响应覆盖下一次弹框。
*/
onOpen(projectId, unionId) {
this.projectId = projectId
this.unionId = unionId || ""
this.project = {}
this.options = []
this.unSelectedCount = 0
this.loadError = ""
this.visible = true
this.tableLoading = true
this.requestVersion += 1
const version = this.requestVersion
return this.$axios.post("/platform/welfare/statistics/batchSelectInfo", {
projectId: this.projectId,
unionId: this.unionId
})
.then((res) => {
if (version !== this.requestVersion || !this.visible) {
return
}
this.project = res.data.project
this.unSelectedCount = Number(res.data.unSelectedCount)
this.options = this.project.options.map((option) => ({
...option,
selectNum: option.isSystemDefault ? 1 : 0
}))
})
.catch((error) => {
if (version === this.requestVersion) {
this.loadError = error.msg || error.message || "加载失败,请关闭后重试"
}
})
.finally(() => {
if (version === this.requestVersion) {
this.tableLoading = false
}
})
},
// 提交期间不允许关闭,避免请求仍在执行时再次打开并重复提交。
onClose(done) {
if (this.formLoading) {
return
}
this.requestVersion += 1
this.visible = false
this.tableLoading = false
if (typeof done === "function") {
done()
}
},
imageUrl(value) {
return commonUtil.getFileUrl(value)
},
// 单选项目按 1 份计数,系统默认套餐存在时不能切换到其他套餐。
selectSingle(option) {
if (this.formLoading || this.systemDefaultOption) {
return
}
this.options.forEach((item) => {
this.$set(item, "selectNum", item.id === option.id ? 1 : 0)
})
},
// 每项上限取项目剩余份数与单项上限的较小值,默认套餐保留至少 1 份。
optionMax(option) {
const perOptionLimit = this.project.singleOptionSupportMultipleSelection ? this.selectionLimit : 1
const remaining = this.selectionLimit - this.selectedCount + option.selectNum
return Math.max(option.isSystemDefault ? 1 : 0, Math.min(perOptionLimit, remaining))
},
changeQuantity(option, value) {
if (this.formLoading) {
return
}
const minimum = option.isSystemDefault ? 1 : 0
const quantity = Number(value)
if (!Number.isInteger(quantity)) {
this.$set(option, "selectNum", minimum)
return
}
this.$set(option, "selectNum", Math.max(minimum, Math.min(this.optionMax(option), quantity)))
},
/**
* 只提交套餐 ID 和每人份数;人员、题目归属及有效规则由后端重新核验。
* 返回 Result.data.assignedCount 为实际分配人数,skippedCount 为范围内已选人数。
*/
submit() {
if (!this.canSubmit) {
return
}
const selectedOptions = this.options
.filter((option) => option.selectNum > 0)
.map((option) => ({
id: option.id,
selectNum: option.selectNum
}))
this.formLoading = true
return this.$axios.post("/platform/welfare/statistics/doSelectByAdmin", {
projectId: this.projectId,
unionId: this.unionId,
welfareOptions: JSON.stringify(selectedOptions)
})
.then((res) => {
this.$message.success(res.msg)
this.visible = false
this.$emit("success")
})
.catch(() => {
// 全局拦截器已显示接口错误,保留当前选择供用户检查或重试。
})
.finally(() => {
this.formLoading = false
})
}
},
style: /*language=CSS*/ `
/deep/ .welfare-batch-dialog .el-dialog {
display: flex;
flex-direction: column;
max-width: calc(100vw - 40px);
max-height: 88vh;
}
/deep/ .welfare-batch-dialog .el-dialog__header {
flex-shrink: 0;
}
/deep/ .welfare-batch-dialog .el-dialog__title {
font-weight: 600;
}
/deep/ .welfare-batch-dialog .el-dialog__body {
min-height: 0;
padding: 0 24px 12px;
overflow-y: auto;
}
/deep/ .welfare-batch-subtitle {
margin: 0 0 20px;
color: #909399;
}
/deep/ .welfare-batch-dialog .el-alert--info {
background-color: #ecf5ff;
color: #409eff;
}
/deep/ .welfare-batch-error {
margin-top: 16px;
}
/deep/ .welfare-batch-overview {
display: flex;
align-items: center;
gap: 24px;
margin: 22px 0;
}
/deep/ .welfare-batch-project {
display: flex;
flex: 1;
gap: 16px;
min-width: 0;
}
/deep/ .welfare-batch-project > span {
flex-shrink: 0;
}
/deep/ .welfare-batch-project strong {
overflow-wrap: anywhere;
}
/deep/ .welfare-batch-people {
display: flex;
align-items: center;
flex-shrink: 0;
gap: 16px;
}
/deep/ .welfare-batch-people strong {
font-size: 20px;
color: #409eff;
}
/deep/ .welfare-batch-rules {
padding: 14px 16px;
border-radius: 4px;
background: #f5f7fa;
line-height: 26px;
}
/deep/ .welfare-batch-heading {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
margin: 20px 0 12px;
}
/deep/ .welfare-batch-heading > strong {
font-size: 16px;
}
/deep/ .welfare-batch-heading b {
color: #409eff;
}
/deep/ .welfare-batch-options {
max-height: 340px;
overflow-y: auto;
}
/deep/ .welfare-batch-option {
display: flex;
align-items: center;
gap: 14px;
padding: 12px 16px;
border: 1px solid #dcdfe6;
border-radius: 4px;
}
/deep/ .welfare-batch-option + .welfare-batch-option {
margin-top: 10px;
}
/deep/ .welfare-batch-option.is-selected {
border-color: #409eff;
background: #ecf5ff;
}
/deep/ .welfare-batch-option .el-radio {
margin-right: 0;
}
/deep/ .welfare-batch-option .el-radio__label {
padding-left: 0;
}
/deep/ .welfare-batch-radio-label {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
}
/deep/ .welfare-batch-image {
width: 64px;
height: 64px;
flex-shrink: 0;
border-radius: 4px;
}
/deep/ .welfare-batch-image-empty {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background: #f5f7fa;
color: #c0c4cc;
font-size: 24px;
}
/deep/ .welfare-batch-option-content {
flex: 1;
min-width: 0;
line-height: 24px;
overflow-wrap: anywhere;
}
/deep/ .welfare-batch-option-title {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
/deep/ .welfare-batch-option .el-input-number {
flex-shrink: 0;
width: 130px;
}
/deep/ .welfare-batch-selected {
flex-shrink: 0;
color: #409eff;
}
/deep/ .welfare-batch-muted {
color: #909399;
font-size: 13px;
line-height: 22px;
}
/deep/ .welfare-batch-limit {
margin: 10px 0 0;
}
/deep/ .welfare-batch-summary {
margin-top: 18px;
padding-top: 14px;
border-top: 1px solid #ebeef5;
line-height: 26px;
overflow-wrap: anywhere;
}
/deep/ .welfare-batch-summary strong span {
color: #409eff;
}
/deep/ .welfare-batch-dialog .el-dialog__footer {
flex-shrink: 0;
padding: 14px 24px 20px;
border-top: 1px solid #ebeef5;
}
`
}
@@ -45,6 +45,14 @@ layout("/layouts/platform.html"){
导出汇总表
</el-button>
</template>
<el-button
:disabled="!pageForm.projectId"
@click="openBatchSelect"
icon="el-icon-present"
size="small"
type="primary">
一键分配套餐
</el-button>
</table-tool>
<el-table
:data="tableData"
@@ -84,18 +92,21 @@ layout("/layouts/platform.html"){
<selected-user ref="selectedUserRef"></selected-user>
<unselected-user ref="unSelectedUserRef"></unselected-user>
<batch-select-dialog ref="batchSelectRef" @success="doSearch"></batch-select-dialog>
</div>
<script nonce="${cspNonce!}">
<!--#include('selectedUser.js'){}#-->
<!--#include('unSelectedUser.js'){}#-->
<!--#include('batchSelectDialog.js'){}#-->
new Vue({
el: "#app",
mixins: [initTableMixins],
components: {
"selected-user": selectedUser,
"unselected-user": unSelectedUser
"unselected-user": unSelectedUser,
"batch-select-dialog": batchSelectDialog
},
store,
data() {
@@ -113,6 +124,14 @@ layout("/layouts/platform.html"){
}
},
methods: {
// 仅传递当前项目与页面工会筛选,弹框重新读取真实项目规则和未选人数。
openBatchSelect() {
if (!this.pageForm.projectId) {
this.$message.warning("请先选择福利项目")
return
}
this.$refs.batchSelectRef.onOpen(this.pageForm.projectId, this.pageForm.unionId)
},
resetSearch() {
this.pageForm.year = new Date().getFullYear().toString()
const isBranchChairman = !this.$auth.hasRoleOr(["SYSADMIN", "SCHOOL_UNION_ADMIN", "SCHOOL_UNION_WELFARE_ADMIN"]) &&
@@ -147,14 +166,19 @@ layout("/layouts/platform.html"){
})
},
async pageData() {
pageData() {
this.tableLoading = true
const resp = await this.$axios.post("/platform/welfare/statistics/pageData", this.pageForm)
if (resp.code === 0) {
this.tableColumns = resp.data.tableColumn
this.tableData = resp.data.tableList
}
this.tableLoading = false
// 批量分配成功后复用原统计接口,动态套餐列和人数一起刷新。
return this.$axios.post("/platform/welfare/statistics/pageData", this.pageForm)
.then((resp) => {
if (resp.code === 0) {
this.tableColumns = resp.data.tableColumn
this.tableData = resp.data.tableList
}
})
.finally(() => {
this.tableLoading = false
})
},
async getWelfareProjectList() {
const res = await this.$axios.post("/platform/welfare/project/mange/getWelfareList", { year: this.pageForm.year })
@@ -76,6 +76,7 @@ const addUser = {
</el-select>
</search-item>
<!-- 福利模块暂不提供三级单位筛选,保留控件代码便于恢复。
<search-item label="三级单位">
<el-select clearable filterable placeholder="请先选择所属单位" style="width: 100%"
v-model="pageForm.threeUnitId">
@@ -87,6 +88,7 @@ const addUser = {
</el-option>
</el-select>
</search-item>
-->
<search-item label="人员类型:">
<dict-select clearable code="USER_PERSON_TYPE"
@@ -96,6 +98,7 @@ const addUser = {
v-model="pageForm.personTypes"></dict-select>
</search-item>
<!-- 福利模块暂不提供人员属性筛选,保留控件代码便于恢复。
<search-item label="人员属性:">
<dict-select clearable code="USER_ATTRIBUTE"
multiple
@@ -103,6 +106,7 @@ const addUser = {
placeholder="请选择人员属性"
v-model="pageForm.userAttributes"></dict-select>
</search-item>
-->
<search-item label="在职状态:">
<dict-select clearable code="USER_STATE"
@@ -88,6 +88,7 @@ layout("/layouts/platform.html"){
</el-select>
</search-item>
<!-- 福利模块暂不提供三级单位筛选,保留控件代码便于恢复。
<search-item label="三级单位">
<el-select
clearable
@@ -101,6 +102,7 @@ layout("/layouts/platform.html"){
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in threeUnitOptions"></el-option>
</el-select>
</search-item>
-->
<search-item label="人员类型:">
<dict-select
@@ -124,14 +126,27 @@ layout("/layouts/platform.html"){
v-model="pageForm.userStates"
></dict-select>
</search-item>
<search-item label="人员分类">
<dict-select v-model="pageForm.aidFundMemberUserType" placeholder="请选择人员分类" @change="doSearch"
code="AIDFUND_MEMBER_USER_TYPE"></dict-select>
</search-item>
<search-item label="人员属性">
<dict-select v-model="pageForm.userAttributes" placeholder="请选择人员属性" @change="doSearch"
code="USER_ATTRIBUTE" clearable multiple collapse-tags></dict-select>
</search-item>
<!-- 福利模块暂不提供人员分类、人员属性筛选,保留控件代码便于恢复。
<search-item label="人员分类">
<dict-select
v-model="pageForm.aidFundMemberUserType"
placeholder="请选择人员分类"
@change="doSearch"
code="AIDFUND_MEMBER_USER_TYPE"
></dict-select>
</search-item>
<search-item label="人员属性">
<dict-select
v-model="pageForm.userAttributes"
placeholder="请选择人员属性"
@change="doSearch"
code="USER_ATTRIBUTE"
clearable
multiple
collapse-tags
></dict-select>
</search-item>
-->
<!-- <search-item label="所选福利:">-->
<!-- <el-select clearable placeholder="请选择所选福利" style="width: 100%" v-model="pageForm.optionId">-->
@@ -2005,10 +2005,13 @@ layout("/layouts/platform_h5.html"){
this.selectRadioOption(option.id)
return
}
if (option.isSystemDefault) return
// 切换单选项时,旧步进器归零也会触发 change;仅允许当前选中项主动归零时取消选择。
if (option.isSystemDefault || this.selectedRadioId !== option.id) {
return
}
this.selectedRadioId = ""
this.projectInfo.options.forEach((item) => {
item.selectNum = 0
this.$set(item, "selectNum", 0)
})
return
}