This commit is contained in:
@jyuhsin
2024-09-20 10:01:52 +08:00
parent ca104cd831
commit dd30ea7322
4 changed files with 151 additions and 18 deletions
@@ -13,10 +13,14 @@ import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Chain; import org.nutz.dao.Chain;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json; import org.nutz.json.Json;
import org.nutz.lang.Lang; import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.*; import org.nutz.mvc.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@@ -99,11 +103,44 @@ public class MMeetingMineController {
@Ok("json:full") @Ok("json:full")
@ViReturn @ViReturn
@RequiresAuthentication @RequiresAuthentication
public Object findMyMeetPeriod(@Param("meetingId") String meetingId) { public Object findMyMeetPeriod(@Param("meetingId") String meetingId,
@Param("userId") String userId,
@Param("helpLeave") Boolean helpLeave) {
if (StrUtil.isBlank(meetingId)) { if (StrUtil.isBlank(meetingId)) {
return Result.error("参数错误"); return Result.error("参数错误");
} }
return meetingMineService.findMyMeetPeriod(meetingId); return meetingMineService.findMyMeetPeriod(meetingId, helpLeave, userId);
}
@At("/searchUser")
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object searchUser(@Param("query") String query, @Param("meetId") String meetId) {
Sql sql = Sqls.create("""
SELECT
u.id,
u.username,
u.loginname,
u.sex,
u.unionname,
u.unitname
FROM
`meeting_time_period_user` pu
LEFT JOIN USER u ON pu.userId = u.id
$condition
limit 50
""").setParam("meetId", meetId);
Cnd cnd = Cnd.NEW();
if (Strings.isNotBlank(query)) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.orLike("u.username", query);
group.orLike("u.loginname", query);
cnd.and(group);
}
cnd.and("meetingId", "=", meetId);
sql.setCondition(cnd);
return meetingMineService.listMap(sql);
} }
/** /**
@@ -27,7 +27,7 @@ public interface MeetingMineService extends ViService {
* *
* @return * @return
*/ */
List<Object> findMyMeetPeriod(String meetingId); List<Object> findMyMeetPeriod(String meetingId, Boolean helpLeave, String userId);
/** /**
* 请假 * 请假
@@ -75,7 +75,7 @@ public class MeetingMineServiceImpl extends ViServiceImpl implements MeetingMine
} }
@Override @Override
public List<Object> findMyMeetPeriod(String meetingId) { public List<Object> findMyMeetPeriod(String meetingId, Boolean helpLeave, String userId) {
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
tp.id AS tpid, tp.id AS tpid,
@@ -94,7 +94,7 @@ public class MeetingMineServiceImpl extends ViServiceImpl implements MeetingMine
"""); """);
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.and("tp.meetingId", "=", meetingId); cnd.and("tp.meetingId", "=", meetingId);
cnd.and("tpu.userId", "=", ShiroUtil.getPrincipalProperty("id")); cnd.and("tpu.userId", "=", helpLeave ? userId : ShiroUtil.getPrincipalProperty("id"));
sql.setCondition(cnd); sql.setCondition(cnd);
return listMap(sql); return listMap(sql);
} }
@@ -237,13 +237,20 @@ layout("/mobile/platform.html"){
<van-button v-if="o.isJoin === true" size="small" disabled color="grey">已签到</van-button>--> <van-button v-if="o.isJoin === true" size="small" disabled color="grey">已签到</van-button>-->
<van-button <van-button
:disabled="moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false" :disabled="moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false"
@click="needLeave(o, false)" @click="needLeave(o, true, true)"
color="#1867b0" size="small" style="margin-right: 8px"
v-if="${@shiro.hasRole('H04')}"
type="primary">替他人请假
</van-button>
<van-button
:disabled="moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false"
@click="needLeave(o, false, false)"
color="#1867b0" size="small" style="margin-right: 8px" color="#1867b0" size="small" style="margin-right: 8px"
type="primary">查看请假状态 type="primary">查看请假状态
</van-button> </van-button>
<van-button <van-button
:disabled="moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false" :disabled="moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false"
@click="needLeave(o, true)" @click="needLeave(o, true, false)"
color="#1867b0" size="small" style="margin-right: 8px" color="#1867b0" size="small" style="margin-right: 8px"
type="primary">我要请假 type="primary">我要请假
</van-button> </van-button>
@@ -275,16 +282,28 @@ layout("/mobile/platform.html"){
</div> </div>
<div class="content"> <div class="content">
<div class="van-doc-card" v-for="(item, index) in timeList"> <van-field
v-if="helpLeave"
v-model="needLeaveUser.userName"
label="请假人"
readonly=""
@click="helpUserShow = true"
placeholder="请点击选择请假人"
input-align="right"
></van-field>
<div v-if="timeList.length > 0" class="van-doc-card" v-for="(item, index) in timeList">
<div> <div>
<div><span style="color: grey">会议名称:</span>{{item.timePeriodName}}</div> <div>
<span style="color: grey">会议名称:</span>
<span>{{item.timePeriodName}}</span>
</div>
</div> </div>
<div @click="leaveClick(item, index)" <div @click="leaveClick(item, index)"
style="display: flex; justify-content: space-between"> style="display: flex; justify-content: space-between">
<div> <div>
<div> <div>
<span style="color: grey">会议时间:</span> <span style="color: grey">会议时间:</span>
{{moment(item.startTime).format('YYYY-MM-DD HH:mm')}} <span>{{moment(item.startTime).format('YYYY-MM-DD HH:mm')}}</span>
</div> </div>
<!--<div><span style="color: grey">结束时间:</span>{{moment(item.endTime).format('YYYY-MM-DD HH:mm')}}</div>--> <!--<div><span style="color: grey">结束时间:</span>{{moment(item.endTime).format('YYYY-MM-DD HH:mm')}}</div>-->
</div> </div>
@@ -297,12 +316,15 @@ layout("/mobile/platform.html"){
</div> </div>
</div> </div>
<div v-if="item.isJoin === false"> <div v-if="item.isJoin === false">
<div><span style="color: grey">审核状态:</span>{{item.stateName}}</div> <div>
<span style="color: grey">审核状态:</span>
<span>{{item.stateName}}</span>
</div>
</div> </div>
<div> <div>
<span style="float: left; color: grey">请假原因:</span> <span style="float: left; color: grey">请假原因:</span>
<van-field :disabled="item.isJoin === false" placeholder="请输入请假原因" rows="1" <van-field :disabled="item.isJoin === false" placeholder="请输入请假原因" rows="1"
style="font-size: 12px; padding: 0; width: 70%; line-height: 20px" style="font-size: 12px; padding: 0; width: 70%; line-height: 20px; margin-left: 69px"
type="textarea" autosize type="textarea" autosize
v-model="item.leaveReason"></van-field> v-model="item.leaveReason"></van-field>
</div> </div>
@@ -318,6 +340,7 @@ layout("/mobile/platform.html"){
</van-button> </van-button>
</div> </div>
</div> </div>
</div> </div>
<div v-if="flag === true"> <div v-if="flag === true">
<div style="display: flex; justify-content: space-evenly; position: fixed; bottom: 20px; width: 100%"> <div style="display: flex; justify-content: space-evenly; position: fixed; bottom: 20px; width: 100%">
@@ -330,6 +353,24 @@ layout("/mobile/platform.html"){
</div> </div>
</div> </div>
</van-action-sheet> </van-action-sheet>
<van-popup position="bottom" round v-model="helpUserShow" :style="{ height: '70%' }" closeable>
<van-search v-model="searchResult" show-action style="padding: 10px;margin-top: 45px" placeholder="请输入工号或姓名搜索"
@input="delaySearch">
</van-search>
<van-cell-group>
<div>
<van-checkbox-group style="text-align: center">
<van-cell-group>
<van-cell v-for="(item, index) in userList" :key="item.index" clickable
:title="item.name"
@click="toResult(item.loginname)">
</van-cell>
</van-cell-group>
</van-checkbox-group>
</div>
</van-cell-group>
</van-popup>
</div> </div>
<script> <script>
@@ -340,6 +381,14 @@ layout("/mobile/platform.html"){
mixins: [mobileMixins], mixins: [mobileMixins],
data() { data() {
return { return {
searchResult: '',
userList: [],
helpUserShow: false,
needLeaveUser: {
userName: '',
userId: '',
},
helpLeave: false,
timeList: [], timeList: [],
checked: [], checked: [],
checkboxRefs: [], checkboxRefs: [],
@@ -361,12 +410,34 @@ layout("/mobile/platform.html"){
} }
}, },
methods: { methods: {
async delaySearch(query) {
if (query) {
const data = await this.searchUser(query)
data.forEach(v => {
v.name = v.username + '(' + v.loginname + ')'
return v
})
this.userList = data
}
},
async searchUser(query) {
const res = await $.post('/mobile/meeting/mine/searchUser', {query: query, meetId: this.clickRow.id})
return res.data
},
toResult(loginname) {
this.timeList = []
const data = this.userList.find(o => o.loginname === loginname)
this.$set(this.needLeaveUser, 'userName', data.username)
this.$set(this.needLeaveUser, 'userId', data.id)
this.helpUserShow = false
this.findTimeList(this.clickRow)
},
refreshApply(o) { refreshApply(o) {
vant.Dialog.confirm({ vant.Dialog.confirm({
title: '温馨提示', title: '温馨提示',
message: '您确定要重新申请吗?', message: '您确定要重新申请吗?',
}).then(async () => { }).then(async () => {
await this.needLeave(this.clickRow, true) await this.needLeave(this.clickRow, true, false)
this.timeList.forEach((re, index) => { this.timeList.forEach((re, index) => {
if (re.stateAuditType === 1) { if (re.stateAuditType === 1) {
re.isJoin = null re.isJoin = null
@@ -437,23 +508,39 @@ layout("/mobile/platform.html"){
this.loading = false this.loading = false
}) })
}, },
async needLeave(o, flag) { async needLeave(o, flag, helpLeave) {
this.flag = flag this.flag = flag
this.clickRow = o this.clickRow = o
this.helpLeave = helpLeave
this.timeList = []
this.needLeaveUser = {
userName: '',
userId: '',
}
if (moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false) { if (moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false) {
vant.Toast('抱歉,已过请假截止时间'); vant.Toast('抱歉,已过请假截止时间');
return return
} }
this.leaveReason = '' this.leaveReason = ''
this.checked = [] this.checked = []
const res = await $.post('/mobile/meeting/mine/findMyMeetPeriod', {meetingId: o.id}) if(helpLeave) {
this.leaveShow = true
} else {
await this.findTimeList(o)
}
},
async findTimeList(o) {
const res = await $.post('/mobile/meeting/mine/findMyMeetPeriod', {
meetingId: o.id,
helpLeave: this.helpLeave,
userId: this.needLeaveUser.userId
})
if (res.code === 0) { if (res.code === 0) {
this.timeList = res.data this.timeList = res.data
if (this.timeList.length === 0) { if (this.timeList.length === 0) {
vant.Toast('您暂无可请假的假时间段'); vant.Toast('暂无可请假的假时间段');
return return
} }
this.leaveShow = true this.leaveShow = true
this.$nextTick(function () { this.$nextTick(function () {
this.timeList.forEach((re, index) => { this.timeList.forEach((re, index) => {
@@ -474,7 +561,7 @@ layout("/mobile/platform.html"){
} }
const array = this.timeList.find(o => o.stateCode === null || o.stateCode < this.clickRow.firstState) const array = this.timeList.find(o => o.stateCode === null || o.stateCode < this.clickRow.firstState)
if (array === undefined) { if (array === undefined) {
vant.Toast('您的所有请假均已处于审核阶段'); vant.Toast('所有请假均已处于审核阶段');
return return
} }
const paramArray = [] const paramArray = []
@@ -502,6 +589,15 @@ layout("/mobile/platform.html"){
if (valid) { if (valid) {
return return
} }
if(this.helpLeave) {
const confirm = await vant.Dialog.confirm({
title: '提示',
message: '您确定要替' + this.needLeaveUser.userName + '报名吗?',
})
if (confirm !== 'confirm') {
return
}
}
const resp = await $.post('/mobile/meeting/mine/askForLeave', { const resp = await $.post('/mobile/meeting/mine/askForLeave', {
meetingId: this.clickRow.id, meetingId: this.clickRow.id,
data: JSON.stringify(paramArray) data: JSON.stringify(paramArray)