目录
1、第一层页面的效果图
1.第一个页面及接口配置
会务管理指南列表
注:如果该页面是一个列表,只需配置"数据回显的接口"及"按钮跳转的表单或列表"
数据回显在页面里配置,按钮跳转页在组件里配置
回显接口配置
(get请求,请求参数params不需要带任何参数,第一个页面不需要)
页面回显的dataQL语法
hint FRAGMENT_SQL_COLUMN_CASE = 'hump'
hint FRAGMENT_SQL_OPEN_PACKAGE = 'off'
hint FRAGMENT_SQL_QUERY_BY_PAGE = true
hint FRAGMENT_SQL_QUERY_BY_PAGE_NUMBER_OFFSET = 1
import 'net.hasor.dataql.fx.basic.CollectionUdfSource' as collect;
var auth = @@sql(userId)<%
SELECT role_id FROM sys_user_role
WHERE user_id = #{userId}
%>
var meetIds = @@sql(userId)<%
SELECT meet_id FROM meet_info_admin
WHERE user_id = #{userId}
%>
// 用于抽出id的方法
var foo = (dat, arrayObj) -> {
var tmpArray = dat => [ # ];
if (tmpArray[0] == dat) {
run arrayObj.addLast(dat); // 末级元素直接加到最终的集合中,否则就继续遍历集合
} else {
run tmpArray => [ foo(#,arrayObj) ]; // 继续递归遍历,直至末级。
}
return arrayObj;
}
var au = auth(${user}.id);
// reutrn au.data();
var admin = collect.filter(au.data(),(dat)->{
return dat.roleId == 29 || dat.roleId == 19 || dat.roleId == 1
});
// return admin;
var ids = null;
if (collect.isEmpty(admin)) {
// 非管理员账号,需要获取会议ids
var ids = meetIds(${user}.id).data();
var ids = ids=>[collect.mapValues(#)];
var newList = collect.newList();
if (collect.isEmpty(ids)) {
return {
"start": dqlLimitInfo.currentPage,
"pages": dqlLimitInfo.totalPage,
"list": ids,
"length": dqlLimitInfo.pageSize,
"total": dqlLimitInfo.totalCount
}
}
var ids = foo(ids, newList).data();
}
var qlList = @@mybatis(param,ids)<%
<SELECT>
SELECT distinct t1.id, t1.meet_name, t1.address, IF(ISNULL(t1.introduction),'0','1') AS introduction,
IF(ISNULL(t1.notice),'0','1') AS notice, IF(ISNULL(t2.id),'0','1') AS agenda, IF(ISNULL(t3.id),'0','1') AS travel, IF(ISNULL(t4.id),'0','1') AS brand
FROM `meet_information` t1
LEFT JOIN meet_info_agenda t2 ON t2.meet_id = t1.id
LEFT JOIN meet_info_travel t3 ON t3.meet_id = t1.id
LEFT JOIN meet_info_brand t4 ON t4.meet_id = t1.id
WHERE
1 = 1
<if test="ids!=null">
AND t1.id in (
<foreach collection="ids" item="a" separator=",">
#{a}
</foreach>
)
</if>
<if test="param.meetName!='' and param.meetName!=null">
AND t1.meet_name LIKE CONCAT('%', #{param.meetName}, '%')
</if>
<if test="param.address!='' and param.address!=null">
AND t1.address LIKE CONCAT('%', #{param.address}, '%')
</if>
</SELECT>
%>
var dql = qlList(${param},ids)
run dql.setPageInfo({
"pageSize" : ${length},
"currentPage" : ${start}
}
);
var dqlData = dql.data()
var dqlLimitInfo = dql.pageInfo();
return {
"start": dqlLimitInfo.currentPage,
"pages": dqlLimitInfo.totalPage,
"list": dqlData,
"length": dqlLimitInfo.pageSize,
"total": dqlLimitInfo.totalCount
}
2.第一个页面按钮跳转页配置
(需带参数,否则下一个页面接收不到参数)
key-->meetId value-->${id}表示获取这个页面的id.
(1)请求链接:页面跳转的路径
(2)表单关联的字段:可以写1,不写代表跳转页表示新增
(3)链接携带的参数params:
第一个参数:key-->handlerType value-->edit 表示跳转页可修改,还有一种写法是:key-->handlerType value-->views 表示跳转页只可查看.
第二个参数:key--meetId value-->${id} 表示下一个页面的meetId关联该页面的id.
2、第二个页面的效果图
1.第二个页面及接口配置
议程安排
注:如果该页面是一个表单,并要回显上一个页面的数据,需配置回显接口及表单提交的接
口,如果该表单操作栏有按钮操作,还需要配置按钮跳转页链接及跳转携带的参数.
页面回显的接口
(需要接收上一个页面传过来的参数id)
上一个页面传的参数 key-->meetId value-->${id}
该页面接收参数 key-->meetId value-->$pageKey
注:最开始使用$pageKey,现在一般用$urlData.key。$urlData.key中的key表示从上一个按钮跳转页传过来的params参数.看1.2图.
页面回显的dataQL语法
注:sql中的param.meetId就是回显接口中“请求参数params”.
hint FRAGMENT_SQL_COLUMN_CASE = 'hump'
hint FRAGMENT_SQL_OPEN_PACKAGE = 'off'
hint FRAGMENT_SQL_QUERY_BY_PAGE = true
hint FRAGMENT_SQL_QUERY_BY_PAGE_NUMBER_OFFSET = 1
import 'net.hasor.dataql.fx.basic.CollectionUdfSource' as collect;
var qlListHead = @@mybatis(param)<%
<SELECT>
SELECT t1.id, t1.meet_name, t1.address, t1.agenda_abstract
FROM meet_information AS t1
WHERE id = #{param.meetId}
</SELECT>
%>
var qlListBody = @@mybatis(param,userId)<%
<SELECT>
SELECT s1.id, DATE_FORMAT(start_time,'%Y-%m-%d %H:%i:%s') AS start_time,
DATE_FORMAT(end_time,'%Y-%m-%d %H:%i:%s') AS end_time,
content, address, sort, image, duty_unit,video_url,video_name,yuyue_num,ifnull(num,0) as num,
case when yuyue_num is null then '未填写'
when (select s3.inserter from meet_enroll_booking s3 where s2.agenda_id = s3.agenda_id limit 1) = #{userId} then '已预约'
when yuyue_num>ifnull(s2.num,0) then '可预约'
else '已满'
end yuyue_status,
(select s3.inserter from meet_enroll_booking s3 where s2.agenda_id = s3.agenda_id limit 1) user_inserter
FROM meet_info_agenda s1
left join
(select count(1)num,agenda_id from meet_enroll_booking where meet_id = #{param.meetId} group by agenda_id)s2 on s1.id=s2.agenda_id
WHERE s1.meet_id = #{param.meetId}
ORDER BY sort
</SELECT>
%>
var dqlHead = qlListHead(${param})
var dqlBody = qlListBody(${param},${user}.id)
var dqlHeadData = dqlHead.data();
var dqlBodyData = dqlBody.data();
var newMap = collect.newMap( dqlHeadData[0]);
run newMap.put('meetInfoAgenda', {"agendaAbstract": dqlHeadData[0].agendaAbstract})
run newMap.put('meetInfoAgendaList', dqlBodyData=>[#]);
return newMap.data()
return dqlHeadData;
页面提交的接口(不需要带参数)
页面提交的dataQL语法
hint FRAGMENT_SQL_COLUMN_CASE = "hump"
hint FRAGMENT_SQL_OPEN_PACKAGE = "off"
import 'net.hasor.dataql.fx.db.TransactionUdfSource' as tran; //引入事务函数
import 'net.hasor.dataql.fx.basic.DateTimeUdfSource' as time;
import 'net.hasor.dataql.fx.basic.CollectionUdfSource' as collect; // 引入集合
import 'net.hasor.dataql.fx.basic.ConvertUdfSource' as convert;
// 判断输入是否为空
if (${meetInfoAgenda}.agendaAbstract==null) {
throw 500,'摘要不允许为空';
}
if (collect.isEmpty(${meetInfoAgendaList})) {
throw 500,'输入不允许为空';
}
var saa = (obj) -> {
if(obj.content=='' || obj.content==null) {
return false;
}
if(obj.address=='' || obj.address==null) {
return false;
}
if(obj.dutyUnit=='' || obj.dutyUnit==null) {
return false;
}
if(obj.startTime=='' || obj.startTime==null) {
return false;
}
if(obj.endTime=='' || obj.endTime==null) {
return false;
}
if(obj.sort=='' || obj.sort==null) {
return false;
}
run convert.toInt(obj.sort);
return true;
};
var sa = saa(${meetInfoAgendaList}[-1]);
if (!sa) {
throw 500,'含有必填项未填';
}
var q = (obj)->{
// 验证开始时间早于结束时间
var start = time.parser(obj.startTime, "yyyy-MM-dd HH:mm");
var end = time.parser(obj.endTime, "yyyy-MM-dd HH:mm");
if(start > end){
throw 500, '结束时间早于开始时间'
}
else if (start == end){
throw 500, '结束时间不能跟开始时间一样'
}
// 验证排序字段,暂未处理
var sort = obj.sort;
return true;
}
var qwq = ${meetInfoAgendaList}=>[q(#)];
// 先根据meetId全部删除,再循环添加
var qlDelete = @@sql(param)<%
DELETE FROM meet_info_agenda WHERE meet_id = #{param.id}
%>
var qlSave = @@mybatis(userId,meetId,params)<%
<insert>
INSERT INTO meet_info_agenda (`meet_id`, id,`start_time`,
`end_time`, `content`, `address`, `sort`, `image`, `duty_unit`, video_url,video_name,yuyue_num,
`inserter`, `insert_time`)
VALUES
<foreach collection ="params" item="param" separator =",">
( #{meetId}, IF(#{param.id}="-1",null,#{param.id}), #{param.startTime},
#{param.endTime}, #{param.content}, #{param.address},
#{param.sort}, #{param.image}, #{param.dutyUnit},#{param.videoUrl}, #{param.videoName}, #{param.yuyueNum},
#{userId}, NOW())
</foreach >
</insert>
%>
var qlUpdate = @@mybatis(userId,param,abstract)<%
<UPDATE>
UPDATE meet_information
SET
updater = #{userId}
<if test='abstract!="" and abstract!=null'>
, agenda_abstract = #{abstract}
</if>
WHERE id=#{param.id}
</UPDATE>
%>
// 添加事务
return tran.required(() -> {
run qlDelete(${param});
run qlUpdate(${user}.id,${param},${meetInfoAgenda}.agendaAbstract);
return qlSave(${user}.id,${id},${meetInfoAgendaList});
});
2. 按钮功能的配置
配置两个参数
第一个参数:key-->agendaId value-->${uiAlmp-id} 获取这个页面的id,下一个页面接收agendaId
第二个参数:key-->meetId value-->${ui9QRB-id} 获取这个页面的meet_id,下一个页面接收meetId
3、第三个页面的效果图
1.第三个页面及接口配置
预约人数
注:看1.1
页面回显的接口
需携带两个参数,接收上一个页面传过来,看2.2图
页面回显的dataQL语法
注:sql中的param.agendaId关联的是上一个页面传过来的id.看2.2.请求携带的参数 agendaId
hint FRAGMENT_SQL_COLUMN_CASE = 'hump'
hint FRAGMENT_SQL_OPEN_PACKAGE = 'off'
hint FRAGMENT_SQL_QUERY_BY_PAGE = true
hint FRAGMENT_SQL_QUERY_BY_PAGE_NUMBER_OFFSET = 1
var qlList = @@mybatis(param)<%
<SELECT>
SELECT
id,
meet_id,
agenda_id,
person_name,
phone,
id_card,
date_format( insert_time, '%Y年%c月%d日 %h时%i分' ) as insert_time
FROM
meet_enroll_booking
WHERE
agenda_id = #{param.agendaId}
</SELECT>
%>
var dql = qlList(${param})
run dql.setPageInfo({
"pageSize" : ${length},
"currentPage" : ${start}
}
);
var dqlData = dql.data()
var dqlLimitInfo = dql.pageInfo();
return {
"start": dqlLimitInfo.currentPage,
"pages": dqlLimitInfo.totalPage,
"list": dqlData,
"length": dqlLimitInfo.pageSize,
"total": dqlLimitInfo.totalCount
}
4.扩展
需先查出数据,再对查询出来的数据进行判断.
dataQL中save保存的接口添加校验.
//先验证是否有重复手机号
var dql1 =@@sql(phone,agendaId)<%
select count(1) from meet_enroll_booking where agenda_id=#{agendaId} and phone in(#{phone});
%>
var isnottest = ${isnottest};
if(isnottest == "" || isnottest == null){
var isnottest = true;
}
if(${phone}!=null){
var num1 = dql1(${phone},${agendaId});
if(num1>0 && isnottest){
throw 500,"存在已预约的手机号!"
}
}
//查询议程表中的预约人数
var dql2 = @@sql(agendaId)<%
select s2.yuyue_num,s1.agenda_id from meet_enroll_booking s1 left join meet_info_agenda s2 on s1.agenda_id = s2.id where s1.agenda_id = #{agendaId} group by s1.agenda_id
%>
var num2 = dql2(${agendaId});
var num3 = num2.yuyue_num;
if(num3 == null){
var num3 = 0;
}
if(num3 > num1 && isnottest){
throw 500,"预约人数已满,不可添加!"
}
var qlSave = @@mybatis(userId, param)<%
<insert>
INSERT INTO meet_enroll_booking (`meet_id`, `agenda_id`, `id_card`, `phone`, `person_name`,`inserter`, `insert_time`)
VALUES (#{param.meetId}, #{param.agendaId}, #{param.idCard}, #{param.phone}, #{param.personName}, #{userId}, NOW())
</insert>
%>
return qlSave(${user}.id,${param});