一:表格值自定义显示
1、日期型格式化:=FORMAT($$$,"MM月dd日")
或者:
2、普通值自定义显示:if($$$='SW_1','丝网一号机',if($$$='SW_2','丝网二号机','丝网三号机'))
或者:
二:从数据集中再次筛选,如Sum运算
SUM(表格.select(QTY_SW, SHIFT_CODE_NAME = B3 && WORKGROUP_CODE_NAME = C3 && SHIFT_DAY >= $$starttime && SHIFT_DAY <= $$endtime && WORKCENTER_CODE = F1))
QTY_SW为Sum的参数,后面的条件相当于where条件
三:是否当班,是否是当天8点前
IF($shiftcode = 'DAYSHIFT',AND(G2 >= TODATE(CONCATENATE(TODAY()," 08:00:00")),G2 <= TODATE(CONCATENATE(TODAY()," 20:30:00"))),OR(G2 >= TODATE(CONCATENATE(TODAY()," 20:00:00")),G2 <= TODATE(CONCATENATE(TODAY()," 08:30:00"))))
if(RIGHT(NOW(),8) > "08:00:00", now(), DATEDELTA(TODAY(),-1) + " " + RIGHT(NOW(),8))
四:不分页,调试模式,导出重命名
URL后面增加: &__bypagesize__=false&fr_locale=zh_CN
调试:&debug=true
导出重命名:${"网版班报表"+format(now(),'yyyyMMddhhmmss')}
五:从美云平台获取底座信息
if (typeof DAF !== "undefined") {
var my_workshop_code = this.options.form.getWidgetByName("workshopcode");
var shop_code = DAFConfig.readString("Organization", "DefaultWorkshopCode");
if (typeof my_workshop_code !== "undefined") {
my_workshop_code.setValue(shop_code);
}
var my_org_id = this.options.form.getWidgetByName("LG_ORG_ID");
if (typeof my_org_id !== "undefined") {
my_org_id.setValue(DAF.orgId);
}
}
六:填报后刷新
模板Web属性 -》填报页面设置 -》事件设置 -》
setTimeout(function() {
_g().parameterCommit();
或
_g().refreshAllSheets();
}, 500)
七:获取参数面板控件的值并刷新
var my_workgroup = _g().getParameterContainer().getWidgetByName("workgroup").getValue();
if (my_workgroup == "" || my_workgroup == null) {
alert("请先选择班次,然后再添加数据");
setTimeout(function() {
_g().refreshAllSheets();
}, 50)
}
八:班别为多选框时,对应的where条件写法
${if(shiftcode = "DAYSHIFT" || shiftcode = "NIGHTSHIFT", "and T.SHIFTS in ( DECODE('" + shiftcode + "', " + "'DAYSHIFT', 'D', 'N'" + ") )", "and T.SHIFTS in ('D','N')" ) }
参考热斑结批填报报表
九:查询条件
${IF(LEN(lgorgid) = 0, "", " AND P.ORG_ID = '" + lgorgid + "' ")} ${IF(LEN(workshopcode) = 0, "", " AND P.WORKSHOP_CODE = '" + workshopcode + "' ")} ${if(len(shiftcode) == 0, "", "AND P.SHIFT_CODE IN ('" + shiftcode + "')") } ${IF(LEN(areacode) = 0, "", " AND P.AREA_CODE = '" + areacode + "' ")} ${if(len(stationcode) == 0, "", "AND P.STATION_CODE IN ('" + stationcode + "')") } ${if(len(equipmentcode) == 0, "", "AND P.EQUIPMENT_CODE IN ('" + equipmentcode + "')") } ${if(len(runstatus) == 0, "", "AND P.EQUPMENT_OPERATION_STATUS IN ('" + runstatus + "')") } ${if(len(starttime)==0,""," AND P.SHIFT_DAY >= TO_DATE('"+ starttime+"','yyyy-MM-dd hh24:mi:ss')")} ${if(len(endtime)==0,""," AND P.SHIFT_DAY <= TO_DATE('"+ endtime+"','yyyy-MM-dd hh24:mi:ss')")}
十:开始时间,结束时间显示当班
IF(HOUR(NOW())<8,CONCATENATE(DATEDELTA(TODAY(),-1)," 08:00:00"),IF(AND(HOUR(NOW())>=8,HOUR(NOW())<20),CONCATENATE(TODAY()," 08:00:00"),IF(AND(HOUR(NOW())>=20 && HOUR(NOW())<24),CONCATENATE(TODAY()," 20:00:00"),""))) IF(HOUR(NOW())<8,CONCATENATE(TODAY()," 20:00:00"),IF(AND(HOUR(NOW())>=8,HOUR(NOW())<20),CONCATENATE(TODAY()," 20:00:00"),IF(AND(HOUR(NOW())>=20 && HOUR(NOW())<24),CONCATENATE(DATEDELTA(TODAY(),1)," 08:00:00"),"")))
十一:点击查询,开始时间和结束时间相隔天数不能大于7天
var start =_g().getParameterContainer().getWidgetByName("start").getValue();
//获取start_time控件的值
var end = _g().getParameterContainer().getWidgetByName("end").getValue();
//获取end_time控件的值
if (start > end) {
alert("开始时间不能大于结束时间!");
//如果开始时间大于结束时间则提示
return false;
//阻止查询
}
var subdate = (new Date(end) - new Date(start)) / (1000 * 60 * 60 * 24);
//将开始时间和结束时间相减得出的毫秒数转化为天数
if (subdate > 8) {
alert("开始时间和结束时间相差不能大于8天!");
//如果开始时间和结束时间差了30天以上则提示
return false;
//阻止查询
}
十二:秒数转化为“HH:MI:SS”格式的输出
(MOD(N2,(24 * 60 * 60)) - MOD(MOD(N2,(24 * 60 * 60)),(60 * 60))) / (60 * 60) + "时" + (MOD(MOD(N2,(24 * 60 * 60)),(60 * 60)) - MOD(MOD(MOD(N2,(24 * 60 * 60)),(60 * 60)),60)) / 60 + "分" + MOD(MOD(MOD(N2,(24 * 60 * 60)),(60 * 60)),60) + "秒"
替换N2为秒数即可。
十三:if判断写成帆软公式
if代码
if (H2 = 'JiangSong') { if ($$$ = '1') { '手动' } if ($$$ = '2') { '待机' } if ($$$ = '3') { '自动' } if ($$$ = '4') { '暂停' } if ($$$ = '5') { '报警' } } if (H2 = 'DiEr') { if ($$$ = '1') { '停机' } if ($$$ = '2') { '自动' } if ($$$ = '3') { '待料' } if ($$$ = '4') { '暂停' } }
帆软if公式
IF(H2='JiangSong',IF($$$='1','手动',IF($$$='2','待机',IF($$$='3','自动',IF($$$='4','暂停','报警')))), IF(H2='Dier',IF($$$='1','停机',IF($$$='2','自动',IF($$$='3','待料','暂停'))), IF(H2='MaiWei',"","")))