Files
UNION_NJUST/src/main/resources/views/platform/clothing/register.html
T

343 lines
16 KiB
HTML

<!--#
layout("/layouts/platform.html"){
#-->
<style>
.el-input-group {
width: auto;
}
.el-input {
width: auto;
}
.user_body .el-card__body {
height: 100%;
}
</style>
<div id="app" v-cloak>
<guava ref="guava">
<el-card shadow="never">
<div class="search">
<div class="search-item">
<div class="search-item-label">年&emsp;&emsp;度:</div>
<div class="search-item-option">
<el-date-picker
style="width: 100%"
placeholder="全部年度"
type="year" clearable @change="handleYearChange"
v-model="pageForm.year"
value-format="yyyy">
</el-date-picker>
</div>
</div>
<div class="search-item">
<div class="search-item-label">项目名称:</div>
<div class="search-item-option">
<el-select v-model="pageForm.projectId" placeholder="请选择项目名称" filterable :loading="projectLoading"
@change="doSearch" style="width: 100%">
<el-option
v-for="item in projectList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
</div>
<div class="search-item">
<div class="search-item-label" style="white-space: nowrap;">
近两年内:
<el-tooltip content="按所选活动的报名年度,检查相邻年度活动中相同运动项目的购衣记录;补录往年活动也会查重" placement="top">
<i class="el-icon-question" style="cursor: help;"></i>
</el-tooltip>
</div>
<div class="search-item-option">
<el-radio-group @change="(val) => doSearch()" v-model="pageForm.isBuy">
<el-radio-button :label="true">已购买</el-radio-button>
<el-radio-button :label="false">未购买</el-radio-button>
</el-radio-group>
</div>
</div>
</div>
</el-card>
<el-card class="user_body" shadow="never" style="margin-top: 10px; height: calc(100vh - 170px);">
<tree-layout>
<template #tree>
<div style="padding: 0 20px;border-right: 2px solid rgb(240,240,240);">
<el-input
placeholder="输入关键字进行查找"
v-model="filterText" clearable>
</el-input>
</div>
<el-tree :data="treeUnionList" ref="tree" :expand-on-click-node="false" class="v-tree"
:props="defaultProps"
default-expand-all
@node-click="handleNodeClick" :filter-node-method="filterNode"
highlight-current style="padding: 10px 0">
<div class="custom-tree-node" style="display: inline-block;"
slot-scope="{ node, data }">
<div v-if="node.level === 1" style="font-size: 16px;" class="v-node">
<i class="el-icon-office-building"></i>&nbsp;
{{ data.unionname }}
</div>
<div v-if="node.level==2" style="font-size: 15px" :title="data.unionname" class="v-node">
<i class="el-icon-school"></i>
&nbsp; {{ data.unionname }}
</div>
</div>
</el-tree>
</template>
<template>
<div style="padding: 0px 20px">
<div>
<vi-title2 :title="(pageForm.isBuy ? '已购买' : '未购买') + '人员名单'">
<template slot="func">
<el-input placeholder="请输入内容" clearable v-model="pageForm.searchKeyword"
@keyup.enter.native="doSearch">
<el-select v-model="pageForm.searchName" slot="prepend" placeholder="查询类型"
style="width: 120px;">
<el-option label="姓名" value="u.username"></el-option>
<el-option label="工号" value="u.loginname"></el-option>
</el-select>
</el-input>
<el-select @change="doSearch" filterable clearable v-model="pageForm.sex" placeholder="请选择性别">
<el-option label="男" value="男"></el-option>
<el-option label="女" value="女"></el-option>
</el-select>
</template>
</vi-title2>
</div>
<el-table ref="multipleTable" v-loading="tableLoading" @selection-change="handleSelectionChange" :data="userData" max-height="600"
:row-key="(val) => val.id">
<el-table-column :reserve-selection="true" :selectable="canSelectUser" type="selection" width="55"></el-table-column>
<el-table-column label="姓名" prop="username" align="center" header-align="center" show-overflow-tooltip></el-table-column>
<el-table-column label="工号" prop="loginname" align="center" header-align="center" show-overflow-tooltip></el-table-column>
<el-table-column label="性别" prop="sex" align="center" header-align="center" show-overflow-tooltip></el-table-column>
<el-table-column label="单位" prop="unitname" align="center" header-align="center" show-overflow-tooltip></el-table-column>
<el-table-column label="所属工会" prop="unionname" align="center" header-align="center" show-overflow-tooltip></el-table-column>
<el-table-column label="联系方式" prop="mobile" align="center" header-align="center" show-overflow-tooltip></el-table-column>
<el-table-column v-if="pageForm.isBuy" label="购买来源" align="center" header-align="center">
<template slot-scope="scope">{{scope.row.canRemove ? '当前活动' : '两年内同类活动'}}</template>
</el-table-column>
</el-table>
<div style="display: flex; justify-content: space-between; margin-top: 6px">
<div> <!--#include("/layouts/pagination.html"){}#--></div>
<div>
<el-row justify="end" type="flex">
<el-button v-if="!pageForm.isBuy" @click="doHandler" :loading="formLoading" type="primary">提交</el-button>
<el-button v-else @click="doHandler" :loading="formLoading" type="danger">移除</el-button>
</el-row>
</div>
</div>
</div>
</template>
</tree-layout>
</el-card>
</guava>
</div>
<script>
const vue = new Vue({
el: '#app',
mixins: [initTableMixins],
components: {
'tree-layout': httpVueLoader('/components/plugins/TreeLayout.vue'),
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
data() {
return {
pageForm: {
year: null,
isBuy: false,
searchName: 'u.username'
},
projectList: [],
projectLoading: false,
userData: [],
userValue: [],
treeUnionList: [],
filterText: '',
defaultProps: {
children: 'childrens',
label: 'unionname',
disabled: 'disabled'
},
}
},
methods: {
handleSelectionChange(val) {
this.$set(this, 'userValue', val.length > 0 ? val.map(o => o.id) : [])
},
// 其他同类活动的历史购买只能查看;移除操作仅处理当前活动的登记。
canSelectUser(row) {
return !this.pageForm.isBuy || row.canRemove
},
filterNode(value, data, node) {
if (!value || node.level === 1) return true;
return data.unionname.indexOf(value) !== -1
},
handleNodeClick(data, node) {
if (node.level === 1 && "${@shiro.hasRole('sysadmin')||@shiro.hasRole('A06')}" !== 'true') {
return
}
if (data) {
this.pageForm.unionId = data.unioncode
this.pageData()
}
},
doHandler() {
if(!this.pageForm.projectId) {
this.notifyWarning('请选择项目!')
return
}
if(this.userValue.length === 0) {
this.notifyWarning('请选择人员!')
return
}
this.$confirm('您选择了' + this.userValue.length + '人, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$set(this, 'formLoading', true)
return $.post('/platform/clothing/register/doHandler', {
ids: JSON.stringify(this.userValue),
projectId: this.pageForm.projectId,
isBuy: this.pageForm.isBuy,
})
.then((resp) => {
if (resp.code === 0) {
this.doSearch()
this.notifySuccess(resp.msg)
} else {
this.notifyWarning(resp.msg)
}
}, () => {
this.notifyWarning('提交失败,请刷新名单后重试')
})
.always(() => {
this.$set(this, 'formLoading', false)
})
}).catch(() => {})
},
doSearch() {
this.$refs.multipleTable.clearSelection()
this.pageData()
},
// 查询与所选活动报名年度相差不超过一年、同类运动项目的购买状态。
pageData() {
const projectId = this.pageForm.projectId
const isBuy = this.pageForm.isBuy
this.$set(this, 'tableLoading', true)
return $.post('/platform/clothing/register/pageData', this.pageForm)
.then((resp) => {
if (this.pageForm.projectId !== projectId || this.pageForm.isBuy !== isBuy) return
if (resp.code === 0) {
this.$set(this, 'userData', resp.data.list)
this.$set(this.pageForm, 'totalCount', resp.data.totalCount)
} else {
this.$set(this, 'userData', [])
this.$set(this.pageForm, 'totalCount', 0)
this.$message.error(resp.msg)
}
}, () => {
if (this.pageForm.projectId !== projectId || this.pageForm.isBuy !== isBuy) return
this.$set(this, 'userData', [])
this.$set(this.pageForm, 'totalCount', 0)
this.$message.error('人员名单加载失败')
})
.always(() => {
this.$set(this, 'tableLoading', false)
})
},
// 年度为空时获取全部已提交活动;指定年度时按活动报名开始时间筛选。
getBuyClothesProject(year) {
this.$set(this, 'projectLoading', true)
return $.post('/platform/clothing/register/getBuyClothesProject', {year: year})
.then((resp) => {
if (resp.code === 0) return resp.data || []
this.notifyWarning(resp.msg)
return []
}, () => {
this.notifyWarning('活动列表加载失败')
return []
})
.always(() => {
this.$set(this, 'projectLoading', false)
})
},
// 切换年度时清除原项目,避免用上一年度的活动ID继续查询或登记。
refreshProjects() {
const year = this.pageForm.year
this.$set(this.pageForm, 'projectId', null)
this.$set(this, 'projectList', [])
this.$set(this, 'userData', [])
this.$set(this, 'userValue', [])
return this.getBuyClothesProject(year).then((projects) => {
if (this.pageForm.year !== year) return
this.$set(this, 'projectList', projects)
if (projects.length > 0) {
this.$set(this.pageForm, 'projectId', projects[0].id)
}
})
},
handleYearChange() {
const year = this.pageForm.year
this.refreshProjects().then(() => {
if (this.pageForm.year === year) this.doSearch()
})
},
unionTree() {
return $.post('/platform/clothing/register/getTreeUnionList').then((resp) => {
if (resp.code !== 0) return
this.$set(this, 'sysadmin', resp.data.sysadmin)
this.$set(this, 'treeUnionList', [resp.data])
if (this.sysadmin) {
this.handleNodeClick({unioncode: ''}, {level: 1})
} else {
let data;
if (resp.data.childrens === null || resp.data.childrens === undefined) {
data = {
unioncode: ''
}
} else {
data = {
unioncode: Array.isArray(resp.data.childrens) ? resp.data.childrens[0].unioncode : resp.data.childrens.unioncode
}
}
this.handleNodeClick(data, {
level: 2, data: data
})
}
}, () => {
this.notifyWarning('工会列表加载失败')
}).always(() => {})
},
},
created() {
this.refreshProjects().then(() => {
this.unionTree()
})
}
})
</script>
<!--#
}
#-->