Merge branch 'main' of https://dd3skj.picp.vip/zhaoxinyu/hmc_gbhd
# Conflicts: # backend/application.yaml # backend/src/main/resources/application.yaml
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@ public class ClientAuthController {
|
||||
@ApiOperation(value = "短信登录", nickname = "/sms-login", httpMethod = "POST")
|
||||
public Object doSmsLogin(ClientLoginBody loginBody, HttpServletRequest req) {
|
||||
try {
|
||||
String token = clientAuthService.doSmsLogin(loginBody);
|
||||
String token = clientAuthService.doLogin(loginBody);
|
||||
return Result.success().addData(token);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
||||
@@ -48,6 +48,16 @@ public class Client_user extends BaseModel implements Serializable {
|
||||
@Comment("单位ID")
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
@Comment("密码")
|
||||
private String password;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
@Comment("盐")
|
||||
private String salt;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
@Comment("openId")
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface ClientAuthService {
|
||||
* @param loginBody 登录信息
|
||||
* @return token
|
||||
*/
|
||||
String doSmsLogin(ClientLoginBody loginBody);
|
||||
String doLogin(ClientLoginBody loginBody);
|
||||
|
||||
/**
|
||||
* 注册
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.budwk.app.client.auth.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.utils.PwdUtil;
|
||||
import com.budwk.app.client.auth.vo.ClientLoginBody;
|
||||
import com.budwk.app.client.auth.models.Client_user;
|
||||
import com.budwk.app.client.auth.vo.ClientRegisterBody;
|
||||
@@ -11,6 +13,9 @@ import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@IocBean
|
||||
public class ClientAuthServiceImpl implements ClientAuthService {
|
||||
@@ -21,23 +26,34 @@ public class ClientAuthServiceImpl implements ClientAuthService {
|
||||
private ValidateService validateService;
|
||||
|
||||
@Override
|
||||
public String doSmsLogin(ClientLoginBody loginBody) {
|
||||
public String doLogin(ClientLoginBody loginBody) {
|
||||
Client_user user = null;
|
||||
int count = dao.count(Client_user.class, Cnd.where(Client_user::getPhone, "=", loginBody.getPhone()));
|
||||
if (count == 0) {
|
||||
// // 自动注册
|
||||
// user = new Client_user();
|
||||
// user.setPhone(loginBody.getPhone());
|
||||
// user.setUserName("用户" + loginBody.getPhone());
|
||||
// dao.insert(user);
|
||||
throw new BaseException("手机号码不存在");
|
||||
}
|
||||
|
||||
validateService.checkSMSCode(loginBody.getPhone(), loginBody.getSmsCode());
|
||||
user = dao.fetch(Client_user.class, Cnd.where(Client_user::getPhone, "=", loginBody.getPhone()));
|
||||
|
||||
if (user == null) {
|
||||
throw new BaseException("用户登录失败");
|
||||
throw new BaseException("用户不存在");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(loginBody.getLoginMethod()) || !List.of("sms", "password").contains(loginBody.getLoginMethod())) {
|
||||
throw new BaseException("登录方式不正确");
|
||||
}
|
||||
|
||||
if (loginBody.getLoginMethod().equals("sms")) {
|
||||
validateService.checkSMSCode(loginBody.getPhone(), loginBody.getSmsCode());
|
||||
}
|
||||
|
||||
if (loginBody.getLoginMethod().equals("password")) {
|
||||
String hashedPassword = PwdUtil.getPassword(loginBody.getPassword(), user.getSalt());
|
||||
if (!Strings.sNull(hashedPassword).equalsIgnoreCase(user.getPassword())) {
|
||||
throw new BaseException("密码不正确");
|
||||
}
|
||||
}
|
||||
|
||||
StpClientUtil.STP.login(user.getId());
|
||||
StpClientUtil.STP.checkLogin();
|
||||
return StpClientUtil.STP.getTokenValue();
|
||||
|
||||
@@ -9,4 +9,8 @@ public class ClientLoginBody {
|
||||
|
||||
private String smsCode;
|
||||
|
||||
private String password;
|
||||
|
||||
private String loginMethod;
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -81,6 +81,7 @@ public class ClientActivityController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询报名人员
|
||||
* 报名人不见得参加活动
|
||||
|
||||
+14
@@ -117,4 +117,18 @@ public class ClientItemController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消项目报名
|
||||
* @param signVO
|
||||
* @return
|
||||
*/
|
||||
@At("/cancel-team-sign-up")
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
@SaCheckLogin(type = StpClientUtil.TYPE)
|
||||
public synchronized Result cancelTeamSignUp(ClientActivitySignVO signVO) {
|
||||
clientItemService.cancelTeamSignUp(signVO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -1,9 +1,12 @@
|
||||
package com.budwk.app.client.module.activity.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.client.module.activity.vo.ClientActivitySignVO;
|
||||
import com.budwk.app.client.module.activity.vo.ClientItemSignUpVO;
|
||||
import com.budwk.app.module.activity.models.ActivityItemUser;
|
||||
|
||||
public interface ClientItemService extends BaseService<ActivityItemUser> {
|
||||
void signUp(ClientItemSignUpVO signVO);
|
||||
|
||||
void cancelTeamSignUp(ClientActivitySignVO signVO);
|
||||
}
|
||||
|
||||
+7
@@ -2,6 +2,7 @@ package com.budwk.app.client.module.activity.service.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.client.module.activity.service.ClientItemService;
|
||||
import com.budwk.app.client.module.activity.vo.ClientActivitySignVO;
|
||||
import com.budwk.app.client.module.activity.vo.ClientItemSignUpVO;
|
||||
import com.budwk.app.module.activity.models.ActGroupUser;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
@@ -59,4 +60,10 @@ public class ClientItemServiceImpl extends BaseServiceImpl<ActivityItemUser> imp
|
||||
}
|
||||
insert(userList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTeamSignUp(ClientActivitySignVO signVO) {
|
||||
clear(Cnd.where(ActivityItemUser::getActivityId, "=", signVO.getActivityId())
|
||||
.and(ActivityItemUser::getItemId, "=", signVO.getItemId()));
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
public class ClientActivitySignVO {
|
||||
|
||||
private Long activityId;
|
||||
private Long itemId;
|
||||
|
||||
private String unitId;
|
||||
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ public class ActUserController {
|
||||
@At
|
||||
@SaCheckPermission("activity.user")
|
||||
public Result getActivityList(String year){
|
||||
List<Activity> activityList = dao.query(Activity.class, Cnd.where("YEAR(startTime)", "=", year).and(Activity::getDelFlag, "=", false));
|
||||
List<Activity> activityList = dao.query(Activity.class, Cnd.NEW().andEX("YEAR(startTime)", "=", year).and(Activity::getDelFlag, "=", false));
|
||||
return Result.success(activityList);
|
||||
}
|
||||
|
||||
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
package com.budwk.app.module.activity.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.page.PageForm;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.module.activity.models.ActWonderfulMoment;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
import com.budwk.app.module.activity.service.ActWonderfulMomentService;
|
||||
import com.budwk.app.web.commons.auth.satoken.StpClientUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName ActWonderfulMomentController
|
||||
* @Author JyuHsin
|
||||
* @Date 2025/5/6 15:30
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@Slf4j
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/activity/wonderfulMoment")
|
||||
public class ActWonderfulMomentController {
|
||||
|
||||
@Inject
|
||||
private ActWonderfulMomentService wonderfulMomentService;
|
||||
|
||||
@At("")
|
||||
@SaCheckPermission("activity.wonderfulMoment")
|
||||
@Ok("beetl:/platform/activity/wonderfulMoment/index.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.wonderfulMoment")
|
||||
public Result pageData(PageForm pageForm, String startTime, String endTime){
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and("title", "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
}
|
||||
cnd.andEX("publishTime", ">=", startTime);
|
||||
cnd.andEX("publishTime", "<=", endTime);
|
||||
cnd.desc("publishTime");
|
||||
Pagination pagination = wonderfulMomentService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("activity.wonderfulMoment")
|
||||
public Result onHandle(@Param("wonderfulMoment") ActWonderfulMoment wonderfulMoment) {
|
||||
if(wonderfulMoment.getId() == null) {
|
||||
wonderfulMoment.setPublishTime(DateUtil.now());
|
||||
}
|
||||
wonderfulMomentService.insertOrUpdate(wonderfulMoment);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("activity.wonderfulMoment")
|
||||
public Result onDelete(Long id) {
|
||||
wonderfulMomentService.delete(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckLogin(type = StpClientUtil.TYPE)
|
||||
public Result getWonderfulMoment(@Param("id") Long id) {
|
||||
Cnd cnd = Cnd.where("published", "=", true).andEX("id", "=", id);
|
||||
cnd.desc("publishTime");
|
||||
List<ActWonderfulMoment> momentList = wonderfulMomentService.query(cnd);
|
||||
List<NutMap> result = new ArrayList<>();
|
||||
for (ActWonderfulMoment wonderfulMoment : momentList) {
|
||||
NutMap nutMap = Lang.obj2map(wonderfulMoment, NutMap.class);
|
||||
DateTime dateTime = DateUtil.parse(wonderfulMoment.getPublishTime());
|
||||
//如果是今天
|
||||
if(DateUtil.isSameDay(dateTime, new Date())) {
|
||||
nutMap.put("time", "今天" + DateUtil.format(dateTime, "HH:mm"));
|
||||
} else {
|
||||
nutMap.put("time", DateUtil.betweenDay(dateTime, new Date(), false) + "天前");
|
||||
}
|
||||
result.add(nutMap);
|
||||
}
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@At("/getWonderfulMomentById/?")
|
||||
@SaCheckLogin(type = StpClientUtil.TYPE)
|
||||
public Result getWonderfulMomentById(Long id) {
|
||||
ActWonderfulMoment moment = wonderfulMomentService.fetch(id);
|
||||
return Result.success(moment);
|
||||
}
|
||||
|
||||
@At("/handleWonderfulMoment/?")
|
||||
@SaCheckLogin(type = StpClientUtil.TYPE)
|
||||
public Result handleWonderfulMoment(Long id) {
|
||||
ActWonderfulMoment moment = wonderfulMomentService.fetch(id);
|
||||
moment.setReadCount(moment.getReadCount() + 1);
|
||||
wonderfulMomentService.update(moment);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
+9
@@ -1,5 +1,6 @@
|
||||
package com.budwk.app.module.activity.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.budwk.app.base.page.PageForm;
|
||||
@@ -8,6 +9,7 @@ import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
import com.budwk.app.module.activity.models.ActivityItem;
|
||||
import com.budwk.app.module.activity.service.ActivityManageService;
|
||||
import com.budwk.app.web.commons.auth.satoken.StpClientUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
@@ -163,4 +165,11 @@ public class ActivityManageController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckLogin(type = StpClientUtil.TYPE)
|
||||
public Result getActivity() {
|
||||
List<Activity> activityList = activityService.query(Cnd.NEW());
|
||||
return Result.success(activityList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.budwk.app.module.activity.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
/**
|
||||
* @ClassName ActWonderfulMoment
|
||||
* @Author JyuHsin
|
||||
* @Date 2025/5/6 15:28
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@Data
|
||||
@Comment("活动项目队伍得分表")
|
||||
@Table("act_wonderful_moment")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class ActWonderfulMoment extends BaseModel {
|
||||
|
||||
@Id
|
||||
@Comment("ID")
|
||||
private Long id;
|
||||
|
||||
@Column
|
||||
@Comment("标题")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String title;
|
||||
|
||||
@Column
|
||||
@Comment("发布内容")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String content;
|
||||
|
||||
@Column
|
||||
@Comment("发布时间")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String publishTime;
|
||||
|
||||
@Column
|
||||
@Comment("封面图")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 500)
|
||||
private String cover;
|
||||
|
||||
@Column
|
||||
@Comment("是否发布")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean published;
|
||||
|
||||
@Column
|
||||
@Comment("阅读次数")
|
||||
@Default(value = "0")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer readCount;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.budwk.app.module.activity.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.module.activity.models.ActWonderfulMoment;
|
||||
|
||||
/**
|
||||
* @ClassName ActWonderfulMomentService
|
||||
* @Author JyuHsin
|
||||
* @Date 2025/5/6 15:30
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
public interface ActWonderfulMomentService extends BaseService<ActWonderfulMoment> {
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.budwk.app.module.activity.service.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.module.activity.models.ActWonderfulMoment;
|
||||
import com.budwk.app.module.activity.service.ActWonderfulMomentService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* @ClassName ActWonderfulMomentServiceImpl
|
||||
* @Author JyuHsin
|
||||
* @Date 2025/5/6 15:31
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class ActWonderfulMomentServiceImpl extends BaseServiceImpl<ActWonderfulMoment> implements ActWonderfulMomentService {
|
||||
public ActWonderfulMomentServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,22 @@
|
||||
:on-exceed="handleExceed"
|
||||
:file-list="fileList"
|
||||
>
|
||||
<i class="el-icon-plus"></i>
|
||||
<i slot="default" class="el-icon-plus"></i>
|
||||
<div slot="file" slot-scope="{file}">
|
||||
<img class="el-upload-list__item-thumbnail" :src="'/open/file/upload/download?filepath=' + file.url" alt=""
|
||||
style="var(--box-width, '100px') !important;height: var(--box-height, '100px') !important">
|
||||
<span class="el-upload-list__item-actions">
|
||||
<span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
|
||||
<i class="el-icon-zoom-in"></i>
|
||||
</span>
|
||||
<span class="el-upload-list__item-delete" @click="handleRemove(file)">
|
||||
<i class="el-icon-delete"></i>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
<el-dialog :visible.sync="dialogVisible" append-to-body>
|
||||
<img width="100%" :src="dialogImageUrl" alt="">
|
||||
<img width="100%" :src="'/open/file/upload/download?filepath=' + dialogImageUrl" alt="">
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -124,4 +136,4 @@ module.exports = {
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -78,6 +78,9 @@ const addOrUpdate = {
|
||||
{{form.files}}
|
||||
<file-upload v-model="form.files" accept=".pdf"></file-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="封面图" prop="cover">
|
||||
<image-upload v-model="form.cover" :max-count="1"></image-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
|
||||
@@ -31,15 +31,15 @@ const itemForm = {
|
||||
<el-table-column label="报名人数">
|
||||
<template #default="{row}">
|
||||
<el-input-number v-model="row.num" :disabled="row.isTeamApply"
|
||||
placeholder="请输入报名人数"></el-input-number>
|
||||
placeholder="请输入报名人数" style="width: 100%"></el-input-number>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="图片">
|
||||
<template #default="{row}">
|
||||
{{row.img}}
|
||||
<image-upload v-model="row.img" :maxCount="1"></image-upload>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="图片">
|
||||
<template #default="{row}">
|
||||
{{row.img}}
|
||||
<image-upload v-model="row.img" :max-count="1"></image-upload>
|
||||
</template>
|
||||
</el-table-column>-->
|
||||
<el-table-column label="操作" fixed="right" width="100px">
|
||||
<template #default="{$index}">
|
||||
<el-button type="text" class="text-danger" @click="removeRow($index)">删除</el-button>
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
const addOrUpdate = {
|
||||
template: /*language=HTML*/ `
|
||||
<el-dialog :title="form.id ? '修改' : '新增'" :visible.sync="visible" width="70%">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入标题"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="内容" prop="content">
|
||||
<text-editor v-model="form.content" :height="300"></text-editor>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否发布" prop="published">
|
||||
<el-switch
|
||||
v-model="form.published"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="封面图" prop="cover">
|
||||
<image-upload v-model="form.cover" :max-count="1"></image-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
`,
|
||||
data() {
|
||||
return {
|
||||
title: '',
|
||||
visible: false,
|
||||
form: {
|
||||
published: true,
|
||||
},
|
||||
rules: {
|
||||
title: [{required: true, message: '请输入标题', trigger: ['blur', 'change']}],
|
||||
content: [{required: true, message: '请输入内容', trigger: ['blur', 'change']}],
|
||||
cover: [{required: true, message: '请上传封面图', trigger: ['blur', 'change']}],
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onOpen(row) {
|
||||
this.visible = true
|
||||
if (row?.id) {
|
||||
this.$nextTick(() => {
|
||||
this.form = JSON.parse(JSON.stringify(row))
|
||||
})
|
||||
} else {
|
||||
this.form = {published: true}
|
||||
}
|
||||
},
|
||||
onSubmit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.$confirm('您确定要提交吗?', '提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消'
|
||||
}).then(() => {
|
||||
$.post('/platform/activity/wonderfulMoment/onHandle', {"wonderfulMoment": JSON.stringify(this.form)}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(this.form.id ? '修改成功' : '新增成功')
|
||||
this.$emit('refresh')
|
||||
this.visible = false
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<!--#
|
||||
layout("/layouts/platform_1.html"){
|
||||
#-->
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<div id="app">
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">标题</div>
|
||||
<div class="search-item-option">
|
||||
<el-input v-model="pageForm.searchKeyword" clearable placeholder="请输入标题"></el-input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">开始时间</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker
|
||||
v-model="pageForm.startTime"
|
||||
type="date"
|
||||
placeholder="请选择发布开始时间"
|
||||
value-format="yyyy-MM-dd"
|
||||
>
|
||||
</el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">结束时间</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker
|
||||
v-model="pageForm.endTime"
|
||||
type="date"
|
||||
placeholder="请选择发布结束时间"
|
||||
value-format="yyyy-MM-dd"
|
||||
>
|
||||
</el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-query">
|
||||
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mt-3">
|
||||
<el-row type="flex" style="justify-content: flex-end" class="mb-3">
|
||||
<el-button icon="el-icon-plus" type="primary" size="small" @click="$refs.addOrUpdateRef.onOpen()">新增精彩瞬间</el-button>
|
||||
</el-row>
|
||||
<el-table v-loading="tableLoading" show-overflow-tooltip :data="tableData">
|
||||
<el-table-column label="序号" type="index" header-align="center" align="center" width="50"></el-table-column>
|
||||
<el-table-column label="标题" prop="title"></el-table-column>
|
||||
<el-table-column label="发布时间" prop="publishTime"></el-table-column>
|
||||
<el-table-column label="阅读次数" prop="readCount"></el-table-column>
|
||||
<el-table-column label="发布状态" prop="published">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
@change="(val) => {publishedChange(val, row)}"
|
||||
v-model="row.published"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949">
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" width="250">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="$refs.addOrUpdateRef.onOpen(row)">修改</el-button>
|
||||
<el-button type="text" class="text-danger" @click="onTableRowDelete(row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
</el-card>
|
||||
|
||||
<add-or-update ref="addOrUpdateRef" @refresh="doSearch"></add-or-update>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
<!--#include('addOrUpdate.js'){}#-->
|
||||
new Vue({
|
||||
el: "#app",
|
||||
mixins: [initTableMixins],
|
||||
components: {
|
||||
"add-or-update": addOrUpdate,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pageForm: {
|
||||
activityId: '',
|
||||
},
|
||||
activityList: [],
|
||||
tableDeleteUrl: "/platform/activity/wonderfulMoment/onDelete"
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onTableRowDelete(id) {
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
this.$confirm('确定删除该数据吗?', '提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消'
|
||||
}).then(() => {
|
||||
$.post(this.tableDeleteUrl, {id}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success("删除成功")
|
||||
this.pageData()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
}).catch(() => {})
|
||||
},
|
||||
publishedChange(val, row) {
|
||||
const params = JSON.parse(JSON.stringify(row))
|
||||
this.$set(params, 'published', val)
|
||||
$.post('/platform/activity/wonderfulMoment/onHandle', {"wonderfulMoment": JSON.stringify(params)}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success("修改成功")
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
async getActivityList(){
|
||||
const resp = await $.post('/platform/activity/user/getActivityList')
|
||||
this.activityList = resp.data
|
||||
},
|
||||
},
|
||||
async created() {
|
||||
this.getActivityList()
|
||||
await this.pageData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
Reference in New Issue
Block a user