This commit is contained in:
@jyuhsin
2025-03-25 11:23:50 +08:00
parent 5f71d519dd
commit 7084976d72
7 changed files with 149 additions and 227 deletions
@@ -72,7 +72,7 @@ public class SiteManageController {
@At
@ViReturn
public Object doEdit(@Param("data") ActivitySiteInfo activitySiteInfo) {
siteInfoService.updateIgnoreNull(activitySiteInfo);
siteInfoService.update(activitySiteInfo);
return null;
}
@@ -2,6 +2,7 @@ package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.lang.util.NutMap;
import java.util.List;
@@ -86,4 +87,9 @@ public class ActivitySiteInfo {
@Comment("预约时间")
@ColDefine(type = ColType.MYSQL_JSON)
private List<Integer> openWeekTime;
@Column
@Comment("场地的禁用时间")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> notApplyTimeList;
}
@@ -45,67 +45,22 @@ public class SendMsg {
* @throws IOException
*/
public void sendTextMesg(String toUser,String contentValue) throws IOException {
String token = getToken(CORPID,CORPSECRET);
String postData = createPostData(toUser, "text",AGENTID, "content", contentValue);
String response = post("utf-8", CONTENT_TYPE,"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=", postData, token);
System.out.println("获取到的token======>" + token);
System.out.println("请求数据======>" + postData);
System.out.println("发送微信的响应数据======>" + response);
}
public String getToken(String corpId, String corpSecret) throws IOException {
String resp = toAuth( "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + corpId + "&corpsecret=" + corpSecret);//拼接字符串得到url
Map<String, Object> map = gson.fromJson(resp,
new TypeToken<Map<String, Object>>() {
}.getType());
System.out.println(map);
return map.get("access_token").toString();
return "";
}
protected String toAuth(String Get_Token_Url) throws IOException {
httpClient = HttpClients.createDefault();
httpGet = new HttpGet(Get_Token_Url);
CloseableHttpResponse response = httpClient.execute(httpGet);
System.out.println(response.toString());
String resp;
try {
HttpEntity entity = response.getEntity();
System.out.println(response.getAllHeaders());
resp = EntityUtils.toString(entity, "utf-8");
EntityUtils.consume(entity);
} finally {
response.close();
}
return resp;
return "";
}
private String createPostData(String touser, String msgtype, int agent_id, String contentKey, String contentValue) {
Map<String,Object> weChatData = new HashMap<>();
weChatData.put("touser",touser);
weChatData.put("agentid",agent_id);
weChatData.put("msgtype",msgtype);
Map<Object, Object> content = new HashMap<Object, Object>();
content.put(contentKey, contentValue);
weChatData.put("text",content);
System.out.println(gson.toJson(weChatData));
return gson.toJson(weChatData);
return "";
}
private String post(String charset, String contentType, String url, String data, String token) throws IOException {
CloseableHttpClient httpclient = HttpClients.createDefault();
httpPost = new HttpPost(url + token);
httpPost.setHeader(CONTENT_TYPE, contentType);
httpPost.setEntity(new StringEntity(data, charset));
CloseableHttpResponse response = httpclient.execute(httpPost);
String resp;
try {
HttpEntity entity = response.getEntity();
resp = EntityUtils.toString(entity, charset);
EntityUtils.consume(entity);
} finally {
response.close();
}
return resp;
return "";
}
@@ -7,23 +7,23 @@
<template slot="dateCell" slot-scope="{date, data}">
<div class="div-Calendar">
<p :class="data.isSelected ? 'is-selected' : ''">
{{ data.day.split('-').slice(1).join('-') }} {{ data.isSelected ? '√' : '' }}
{{ data.day.split('-').slice(1).join('-') }} {{ data.isSelected ? '✔️' : '' }}
</p>
<div v-if="$.parseJSON(role) === true" v-for="item in viewData.site_info">
<div v-if="data.day.toString()==item.reserve_day"
<div v-if="data.day.toString() === item.reserve_day"
:style="{backgroundColor:([0].includes(item.stateaudittype)?'#FAECD9':'#E0F4D9')}">
<el-row :gutter="20" style="line-height: 30px;margin-bottom: 10px;">
<el-col :span="4">
<el-button v-if="[0].includes(item.stateaudittype)" type="warning"
size="mini" circle>待
</el-button>
<el-button v-if="item.stateaudittype==3" type="success" size="mini" circle>通
</el-button>
</el-col>
<el-col :span="20" style="font-size: 10px">
<b>{{ item.reserve_person }}</b>:{{ item.start_time }}-{{ item.end_time }}
</el-col>
</el-row>
<el-row style="line-height: 20px">
<el-col :span="4" style="font-size: 10px">
<span v-if="[0].includes(item.stateaudittype)">待审</span>
<span v-if="item.stateaudittype==3">通过</span>
<span v-if="item.stateaudittype==1">拒绝</span>
</el-col>
<el-col :span="20" style="font-size: 10px">
<span>
<b>{{item.reserve_person}}</b>:{{item.start_time}}-{{item.end_time}}
</span>
</el-col>
</el-row>
</div>
</div>
</div>
@@ -11,7 +11,6 @@ layout("/mobile/platform.html"){
align-items: center;
color: white;
}
.day {
background-color: #14497e;
display: inline-block;
@@ -22,12 +21,10 @@ layout("/mobile/platform.html"){
margin-right: 6px;
font-size: 14px;
}
.time {
width: 72%;
text-align: center;
}
.state {
width: 80px;
height: 36px;
@@ -36,31 +33,25 @@ layout("/mobile/platform.html"){
border-radius: 2px;
color: #929292;
}
.container {
padding: 10px 0px;
padding: 10px 0;
background-color: white;
width: 95%;
margin: 0 auto;
border-radius: 6px;
margin-top: 10px;
}
tr {
line-height: 36px;
}
.van-action-sheet__content {
padding: 10px;
font-size: 15px;
}
.title {
margin: 10px 0px;
margin: 10px 0;
color: grey;
}
.top-calendar {
height: 70px;
max-height: 70px;
@@ -73,14 +64,12 @@ layout("/mobile/platform.html"){
align-items: center;
background-color: #0e78c5;
}
.calendar-left {
width: calc(100% - 20px);
overflow-x: auto;
display: flex;
height: 90%;
}
.calendar-left-day {
min-width: 65px;
height: 100%;
@@ -90,20 +79,17 @@ layout("/mobile/platform.html"){
justify-content: center;
align-items: center;
color: #FFF;
border-radius: 10px;
}
.left-day-active {
background-color: #0000cc;
}
.day-info-month {
.left-day-disabled {
background-color: lightgrey;
}
.day-info-week {
margin-bottom: 5px;
}
.calendar-right {
width: 30px;
max-width: 30px;
@@ -115,19 +101,21 @@ layout("/mobile/platform.html"){
justify-content: center;
margin-left: 5px;
}
.top_pop .van-popup {
top: 46px;
}
.van-action-sheet {
max-height: 90%;
}
.van-empty {
position: revert;
transform: none;
top: 0;
left: 0;
}
</style>
<div id="app" v-cloak>
<!--top栏-->
<van-nav-bar
:title="site.name"
left-arrow
@@ -139,39 +127,39 @@ layout("/mobile/platform.html"){
<div class="top-calendar">
<div class="calendar-left">
<div class="calendar-left-day" :class="moment(item).unix() == selectDate.unix() ? 'left-day-active':''"
<div
:class="getDayClass(item)"
@click="dayClick(item)"
v-for="item in weekList">
<div class="day-info-week">
{{getWeekTextByDate(item)}}
{{getWeekTextByDate(item.day)}}
</div>
<div class="day-info-month">
{{moment(item).format('MM-DD')}}
{{moment(item.day).format('MM-DD')}}
</div>
</div>
</div>
<div class="calendar-right">
<van-icon size="16" color="white" name="arrow-down" @click="calendarVisible=true"></van-icon>
<van-calendar class="top_pop" v-model="calendarVisible" color="#246fb4" position="top" @confirm="onConfirm"
:default-date="selectDate.toDate()"
:default-date="selectDate?.toDate()"
:formatter="calendarFormatter"
title="选择开始日期"></van-calendar>
</div>
</div>
<div class="container">
<table>
<table v-if="weekList.find(o => o.day === selectDate)?.disabled === false">
<tr v-for="item in timeData">
<td class="time">{{item.start_time + '-' + item.end_time}}</td>
<td>
<div v-if="isCanRe(item)===3" class="state" style="background-color: #0e78c5;color: #fff3f3">
已预约
</div>
<div v-if="isCanRe(item) === 2" class="state" style="background-color: #fff4f2; color: #cc5a45">约满
<div v-if="isCanRe(item) === 2" class="state" style="background-color: #fff4f2; color: #cc5a45">
约满
</div>
<div @click="chooseTime(item)" v-if="isCanRe(item) === 1" class="state"
style="background-color: #e8ffef; color: #52986a">
<div @click="chooseTime(item)" v-if="isCanRe(item) === 1" class="state" style="background-color: #e8ffef; color: #52986a">
<span v-if="!times.map(o => o.fullDay).includes(selectDate.format('YYYY-MM-DD') + ' ' + item.start_time + '-' + item.end_time)">可预约</span>
<span v-else>
<van-icon name="passed" size="26" style="line-height: 36px;position: unset"></van-icon>
@@ -179,9 +167,9 @@ layout("/mobile/platform.html"){
</div>
<div v-if="isCanRe(item) === 0" class="state">已过期</div>
</td>
</tr>
</table>
<van-empty v-else image="error" :description="moment(selectDate).format('YYYY-MM-DD') + '不能预约'"></van-empty>
</div>
<div style="position: fixed; bottom: 0; width: 100%">
@@ -203,17 +191,6 @@ layout("/mobile/platform.html"){
</div>
</van-cell>
<van-cell title="预约地点">{{site.name}}</van-cell>
<!--<van-field
v-model="joinUser"
rows="2"
autosize
label="参加人员"
type="textarea"
maxlength="50"
placeholder="请输入参加人员"
show-word-limit
></van-field>-->
<van-field
v-model="message"
rows="4"
@@ -236,16 +213,12 @@ layout("/mobile/platform.html"){
<script>
moment.locale('zh_cn');
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURI(r[2]);
return null;
}
<!--# include("/platform/activity/includeJs/activityUtil.js"){} #-->
const siteTypeUtil = new typeUtil()
const vue = new Vue({
el: '#app',
mixins: [mobileMixins],
@@ -304,6 +277,15 @@ layout("/mobile/platform.html"){
}
},
methods: {
getDayClass(row) {
let classStr = 'calendar-left-day'
if(row.disabled) {
classStr += ' left-day-disabled'
} else {
classStr += moment(row.day).unix() === this.selectDate.unix() ? ' left-day-active' : ''
}
return classStr
},
close(f) {
if (this.times.length === 1) {
vant.Toast('必须保留一个时间段')
@@ -317,35 +299,27 @@ layout("/mobile/platform.html"){
this.setWeekList(this.selectDate)
this.calendarVisible = false
},
//这里要排除掉休息日
setWeekList(startDate) {
const wk = []
let d = null
do {
d = moment(startDate).day()
if(!this.site.openWeekTime.includes(d)) {
startDate = moment(startDate).add(1, 'd')
}
} while (!this.site.openWeekTime.includes(d))
wk.push(moment(startDate))
let count = 1
let count = 0
while (wk.length < 7) {
const addDate = moment(startDate).add(count, 'd')
const nextDay = addDate.day()
//这里不是休息日才能加到数组里
/*if (addDate.day() !== 0 && addDate.day() !== 6 && !this.holidays.includes(moment(addDate).format('YYYY-MM-DD'))) {
wk.push(addDate)
}*/
if(this.site.openWeekTime.includes(nextDay)) {
wk.push(addDate)
}
const addDateFormat = moment(addDate).format('YYYY-MM-DD')
wk.push({
day: addDate,
disabled: !this.site.openWeekTime.includes(addDate.day()) || this.site.notApplyTimeList.includes(addDateFormat)
})
count++
}
this.weekList = wk
},
dayClick(date) {
this.selectDate = date
this.getReserve()
dayClick(item) {
this.selectDate = item.day
if(item.disabled) {
this.$toast(moment(item.day).format('YYYY-MM-DD') + '不可预约')
} else {
this.getReserve()
}
},
reserve() {
if (this.times.length === 0) {
@@ -390,13 +364,10 @@ layout("/mobile/platform.html"){
isCanRe(item) {
const now = new Date()
const end = moment().format('YYYY-MM-DD') + ' ' + item.end_time + ':00'
const itemFullTime = this.selectDate.format('YYYY-MM-DD') + " " + item.start_time + "-" + item.end_time
if (this.alreadyReserveRecord.includes(itemFullTime)) {
return 3
}
if (now.getTime() >= new Date(end).getTime() && this.selectDate.format('YYYY-MM-DD') === moment().format('YYYY-MM-DD')) {
return 0
} else {
@@ -407,7 +378,6 @@ layout("/mobile/platform.html"){
}
}
},
async onLoad() {
this.loading = true
const resp = await $.post('/mobile/activity/site/info/getDetail', {id: this.site_id})
@@ -436,28 +406,18 @@ layout("/mobile/platform.html"){
this.alreadyReserveRecord = resp.data.map(v => v.reserve_day + " " + v.start_time + "-" + v.end_time)
}
},
//获取最新的一个工作日设为当前时间
getLatestWorkDay() {
/*const weekNum = moment().day()
let selectDate = null
if (weekNum === 0) {
//周日
selectDate = moment().add(1, 'd')
} else if (weekNum === 6) {
//周六
selectDate = moment().add(2, 'd')
} else {
selectDate = moment()
}*/
let today = moment().format('YYYY-MM-DD')
let d
do {
d = moment(today).day()
if(!this.site.openWeekTime.includes(d)) {
today = moment(today).add(1, 'd')
let selectDate = moment()
if(this.site.workday === true) {
if (selectDate.day() === 0) {
//周日
selectDate = moment().add(1, 'd')
} else if (selectDate.day() === 6) {
//周六
selectDate = moment().add(2, 'd')
}
} while (!this.site.openWeekTime.includes(d))
return today
}
return selectDate
}
},
async created() {
@@ -158,27 +158,24 @@ layout("/layouts/platform.html"){
<el-row :gutter="20">
<el-col :span="6">
<el-form-item prop="sexLimit" label="性别限制">
<el-radio-group v-model="formData.sexLimit" size="medium">
<el-radio-button label="0">不限制</el-radio-button>
<el-radio-button label="1">男</el-radio-button>
<el-radio-button label="2">女</el-radio-button>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item prop="state" label="开启状态">
<el-radio-group v-model="formData.state" size="medium">
<el-radio-button :label="true">开启</el-radio-button>
<el-radio-button :label="false">禁用</el-radio-button>
</el-radio-group>
<el-switch v-model="formData.state" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
</el-form-item>
</el-col>
<el-col :span="6">
<el-col :span="3">
<el-form-item prop="state" label="是否多次预约">
<el-radio-group v-model="formData.multiple" size="medium">
<el-radio-button :label="true">允许</el-radio-button>
<el-radio-button :label="false">不允许</el-radio-button>
</el-radio-group>
<el-switch v-model="formData.multiple" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
</el-form-item>
</el-col>
<!--<el-col :span="4">
<el-form-item prop="state" label="限定工作日预约">
<el-switch v-model="formData.workday" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</el-form-item>
</el-col>-->
<el-col :span="12">
<el-form-item prop="typeId" label="场地类型">
<el-select v-model="formData.typeId" style="width: 100%" filterable
@@ -191,15 +188,7 @@ layout("/layouts/platform.html"){
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item prop="sexLimit" label="性别限制">
<el-radio-group v-model="formData.sexLimit" size="medium">
<el-radio-button label="0">不限制</el-radio-button>
<el-radio-button label="1">男</el-radio-button>
<el-radio-button label="2">女</el-radio-button>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="openWeekTime" label="预约时间">
<el-select v-model="formData.openWeekTime" style="width: 100%" filterable
@@ -214,6 +203,18 @@ layout("/layouts/platform.html"){
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="notApplyTimeList" label="禁用时间">
<el-date-picker
style="width: 100%"
v-model="formData.notApplyTimeList"
type="dates"
value-format="yyyy-MM-dd"
clearable
placeholder="请选择禁用时间">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
</el-form>
<vi-title2 title="添加场次">
@@ -5,52 +5,41 @@ layout("/layouts/platform.html"){
.text {
font-size: 14px;
}
.e-item {
margin-bottom: 10px;
}
.el-divider--horizontal {
margin: 5px 0;
}
.v-tab .el-card__header {
padding: 10px 15px;
font-weight: bold;
}
.reserve_btn {
font-size: 16px;
float: right;
padding: 3px 0
}
.is-selected {
color: #1989FA;
}
.div-Calendar {
box-sizing: border-box;
height: 100%;
}
.el-carousel__button {
background-color: #c0c4cc;
}
.el-carousel__container {
height: 260px;
}
.el-button--mini.is-circle {
padding: 5px;
font-size: 1px;
}
.slider {
position: relative;
}
.cover {
position: absolute;
height: 6px;
@@ -58,7 +47,6 @@ layout("/layouts/platform.html"){
margin: 16px 0;
z-index: 999;
}
.cover2 {
position: absolute;
height: 6px;
@@ -66,43 +54,39 @@ layout("/layouts/platform.html"){
margin: 16px 0;
z-index: 1000;
}
.el-slider__marks-text {
margin-top: 10px !important;
}
.el-slider__stop {
z-index: 1001;
}
.el-slider__bar {
z-index: 1000;
}
.el-slider__marks-text {
min-width: 40px !important;
}
.el-slider__button-wrapper {
display: none !important;
}
.textDia h2 {
text-align: center;
}
.textDia h4 {
line-height: 26px;
}
.textDia .el-dialog__header {
display: none;
}
.textDia .el-dialog__body {
padding: 10px 20px;
}
.el-calendar-day:has(.not-allow-day) {
background-color: #F5F5F5;
}
.div-Calendar p {
margin: 0;
}
</style>
<div id="app" v-cloak>
<guava ref="guava">
@@ -280,21 +264,16 @@ layout("/layouts/platform.html"){
删除
</el-dropdown-item>
<!--# } #-->
<el-dropdown-item
v-if="scope.row.reserve_person_id === '${@shiro.getPrincipalProperty('id')}'"
:command="{type:'cancel',data:scope.row}">
撤销预约
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-row class="el-pagination-container">
<el-pagination
@size-change="pageSizeChange"
@@ -334,25 +313,24 @@ layout("/layouts/platform.html"){
</el-row>
<el-calendar v-model="reserve_time">
<template slot="dateCell" slot-scope="{date, data}">
<div class="div-Calendar" @click="pushDay(data)">
<div :class="getDayClass(data)" @click="pushDay(data)">
<p :style="dayArray.includes(data.day) ? 'color: #246fb4' : ''">
{{ data.day.split('-').slice(1).join('-') }} {{ dayArray.includes(data.day) ? '√' : ''}}
{{ data.day.split('-').slice(1).join('-') }} {{ dayArray.includes(data.day) ? '✔️' : ''}}
</p>
<div v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('xghng')||@shiro.hasRole('A06')}"
v-for="item in reserveViewData">
<div v-if="data.day.toString()==item.reserve_day"
:style="{backgroundColor:([0].includes(item.stateaudittype)?'#FAECD9':item.reserve_state==30?'#E0F4D9':'#FEE2E2')}">
<el-row :gutter="20" style="line-height: 30px;margin-bottom: 10px;">
<el-col :span="4">
<el-button v-if="[0].includes(item.stateaudittype)" type="warning"
size="mini" circle>待
</el-button>
<el-button v-if="item.stateaudittype==3" type="success" size="mini" circle>通
</el-button>
<el-button v-if="item.stateaudittype==1" type="danger" size="mini" circle>拒
</el-button>
<el-row style="line-height: 20px">
<el-col :span="4" style="font-size: 10px">
<span v-if="[0].includes(item.stateaudittype)">待审</span>
<span v-if="item.stateaudittype==3">通过</span>
<span v-if="item.stateaudittype==1">拒绝</span>
</el-col>
<el-col :span="20" style="font-size: 10px"><b>{{item.reserve_person}}</b>:{{item.start_time}}-{{item.end_time}}
<el-col :span="20" style="font-size: 10px">
<span>
<b>{{item.reserve_person}}</b>:{{item.start_time}}-{{item.end_time}}
</span>
</el-col>
</el-row>
</div>
@@ -584,7 +562,7 @@ layout("/layouts/platform.html"){
},
components: {
'guava': httpVueLoader('/components/plugins/Guava.vue'),
'reserve-info': httpVueLoader('/components/activity/site/ReserveInfo.vue'),
'reserve-info': httpVueLoader('/components/activity/site/ReserveInfo.vue?v=1.0.0'),
},
methods: {
diaOpen() {
@@ -757,12 +735,28 @@ layout("/layouts/platform.html"){
this.openReserve(data)
}
},
getDayClass(data) {
const d = new Date(data.day).getDay()
let classStr = 'div-Calendar'
if(this.infoViewData.openweektime) {
const openWeedTime = JSON.parse(this.infoViewData.openweektime)
if(!openWeedTime.includes(d)) {
classStr += ' not-allow-day';
}
}
if(this.infoViewData.notapplytimelist) {
const notApplyTimeList = JSON.parse(this.infoViewData.notapplytimelist)
if(notApplyTimeList.includes(data.day)) {
classStr += ' not-allow-day';
}
}
if(moment(data.day).unix() < moment().unix()) {
classStr += ' not-allow-day';
}
return classStr
},
pushDay(data) {
const d = new Date(data.day).getDay()
/*if (this.textData.workday === true && (d === 0 || d === 6 || this.holidays.includes(data.day))) {
this.$notify.warning({title: '警告', message: '抱歉,该场地只能预约工作日'});
return
}*/
if(this.infoViewData.openweektime) {
const openWeedTime = JSON.parse(this.infoViewData.openweektime)
if(!openWeedTime.includes(d)) {
@@ -770,6 +764,13 @@ layout("/layouts/platform.html"){
return
}
}
if(this.infoViewData.notapplytimelist) {
const notApplyTimeList = JSON.parse(this.infoViewData.notapplytimelist)
if(notApplyTimeList.includes(data.day)) {
this.$message.warning(data.day + "不能预约")
return
}
}
if (data.day < moment(new Date()).format('YYYY-MM-DD')) {
this.$message.warning('你选择的日期已过')
return
@@ -782,7 +783,6 @@ layout("/layouts/platform.html"){
}
},
async openAdd() {
//查询用户点击的这一天已经被预约的时间段
/*if(this.textData.multiple === false) {
const da = await this.findReserveInfoByClickDay(this.textData.id, data.day)