前端按条件分组查询 展示列动态变化

  • 查询条件
<#form:form id="searchForm" model="${timesheetentrydetail}" action="${ctx}/produce/timesheetreport/wageFormListDateNewAll" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div class="form-group">
				<label class="control-label">${text('汇总来源')}</label>
				<div class="control-inline width-120">
					<#form:select path="fcountsource" dictType="fcountsource" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
                <label class="control-label">${text('日期')}</label>
                <div class="control-inline">
                    <#form:input path="startTime" readOnly="true" maxlength="20" class="form-control Wdate-date"
                    dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false,onpicked:function(){endTime.click()}});"/>
                    &nbsp;--&nbsp;
                    <#form:input path="endTime" readOnly="true" maxlength="20" class="form-control Wdate-date"
                    dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
                </div>
            </div>
				<div class="form-group">
					<label class="control-label">${text('部门')}</label>
					<div class="control-inline">
							<#form:treeselect id="fdeptid"  maxlength="50"  class="form-control width-120" title="${text('机构选择')}" path="fdeptid.officeCode" labelPath="fdeptid.officeName" 
							checkbox="true" url="${ctx}/sys/office/treeData" allowClear="true" allowInput="true"/>
						</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('人员')}</label>
					<div class="control-inline">
                         <div class="input-group">
							<#form:input path="fname" maxlength="50" class="form-control width-120" style="background-color: #fff" readonly="true" onclick="empSelect()"/>
                        	<span class="input-group-btn"><a href="javascript:empSelect()" class ="btn btn-default btn-sm" ><i class="fa fa-search"></i></a></span>
                        </div>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('汇总条件')}</label>
						<#form:checkbox  path="summaryConditions" dictType="timesheetentrydetail_summary_conditions"  class="form-control" />
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
  • 展示列
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	//lazyLoad: true, //懒加载
	columnModel: [
		{header:'${text("开始时间")}', name:'startTime', index:'a.StartTime', width:120, align:"center" ,   formatter: function(val, obj, row, act){
			if(val){
				return js.formatDate(js.parseDate(val),'yyyy-MM-dd');
			}else{
				return '合计';
			}
		}},
		{header:'${text("结束时间")}', name:'endTime', index:'a.EndTime', width:120, align:"center",   formatter: function(val, obj, row, act){
				if(val){
					return js.formatDate(js.parseDate(val),'yyyy-MM-dd');
				}else{
					return '-';
				}
		}},
		{header:'${text("部门")}', name:'fdeptid.officeName', index:'a.fdeptid', width:120, align:"center"},
		{header:'${text("人员编码")}', name:'fcode', index:'a.fcode', width:130 ,hidden:true, align:"center"},
		{header:'${text("人员")}', name:'fname', index:'a.fname', width:130 ,hidden:true, align:"center"},
		{header:'${text("工资")}', name:'wage', index:'a.wage', width:120, align:"center",  formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值,金额情况下设置0.00);
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
	/* 	$('#dataGrid').dataGrid('mergeCell', 'fbillno');
		$('#dataGrid').dataGrid('mergeCell', 'fschedulingid.fbillno'); */
		  query();
	}
});
  • 控制展示哪些列
function query(){
	$("input[name='summaryConditions']:checkbox").each(function(){
            if((this).value==1) {
            	if((this).checked) {
            		$('#dataGrid').setGridParam().showCol("fname").trigger("reloadGrid");
					$('#dataGrid').setGridParam().showCol("fcode").trigger("reloadGrid");
					$('#dataGrid').setGridParam().showCol("fdeptid.officeName").trigger("reloadGrid");
            	}else {
            		$('#dataGrid').setGridParam().hideCol("fname").trigger("reloadGrid");
					$('#dataGrid').setGridParam().hideCol("fcode").trigger("reloadGrid");
					$('#dataGrid').setGridParam().hideCol("fdeptid.officeName").trigger("reloadGrid");
            	}
            }else if((this).value==2){
				if((this).checked) {
					$('#dataGrid').setGridParam().showCol("fdeptid.officeName").trigger("reloadGrid");
				}else {
					$('#dataGrid').setGridParam().hideCol("fdeptid.officeName").trigger("reloadGrid");
				}
			}
	})
}
  • 脚本写法
WITH AA AS (
		/*零活工资*/
		SELECT
			#{startTime} AS startTime,
			#{endTime} AS endTime,
			O.OFFICE_CODE AS FDEPTID,
			O.OFFICE_NAME AS OFFICENAME,
			E.fcode,
			E.fname,
			NVL(detail.fwage,0) AS wage

		FROM
			yg_pr_timesheetreport a
		LEFT JOIN YG_PR_TIMESHEETENTRYDETAIL detail ON detail.fparentid = a.id
		LEFT JOIN YG_BS_EMPLOYEE E ON detail.fempid = E.id
		left join JS_SYS_OFFICE O on O.OFFICE_CODE =e.fdepartmentid
		WHERE a.status = 3
			and a.fsrcinterid = 0
			<if test="startTime !=null">
				and trunc(a.fdate) &gt;= #{startTime}
			</if>
			<if test="endTime !=null">
				and trunc(a.fdate) &lt;= #{endTime}
			</if>
		<if test='fcountsource != null and fcountsource !="" and fcountsource =="2"'>
		/*结卡工资*/
		UNION ALL
		SELECT
			#{startTime} AS startTime,
			#{endTime} AS endTime,
			TM.FDEPTID,
			O.OFFICE_NAME AS OFFICENAME,
			PE.fcode,
			PE.FNAME,
			NVL( TE.FJKWAGE, 0 ) AS WAGE
		FROM
			YG_PR_TIMESHEET TM
		LEFT JOIN YG_PR_TIMESHEETREPORT T ON TM.ID = T.FSRCINTERID
		INNER JOIN YG_PR_TIMESHEETENTRYDETAIL TE ON T.ID = TE.FPARENTID
		LEFT JOIN JS_SYS_OFFICE O ON O.OFFICE_CODE = TM.FDEPTID
		LEFT JOIN YG_BS_EMPLOYEE PE ON PE.ID = TE.FEMPID
		/*left join JS_SYS_OFFICE O on O.OFFICE_CODE =Pe.fdepartmentid*/
		WHERE
			TM.ftimesheettype IN ( '1026', '1028' )
			AND TM.STATUS = 5
			<if test="startTime !=null">
				and TRUNC(TM.update_date) &gt;= #{startTime}
			</if>
			<if test="endTime !=null">
				and TRUNC(TM.update_date) &lt;= #{endTime}
			</if>
		</if>
		<if test='fcountsource != null and fcountsource !="" and fcountsource =="1"'>
		/*汇报工资*/
		    UNION ALL
		SELECT
			#{startTime} AS startTime,
			#{endTime} AS endTime,
			TM.FDEPTID,
			O.OFFICE_NAME AS OFFICENAME,
			PE.fcode,
			PE.FNAME,
			/*round(NVL( TE.FWORKLOAD, 0 ) * NVL( TE.FQUOTA, 0 ),2) AS WAGE*/
			round(NVL( TE.FRPWAGE, 0 ),2) AS WAGE
		FROM
			YG_PR_TIMESHEETENTRYDETAIL TE
		INNER JOIN YG_PR_TIMESHEETREPORT T ON T.ID = TE.FPARENTID
		LEFT JOIN YG_PR_TIMESHEET TM ON TM.ID = T.FSRCINTERID
		LEFT JOIN JS_SYS_OFFICE O ON O.OFFICE_CODE = TM.FDEPTID
		LEFT JOIN YG_BS_EMPLOYEE PE ON PE.ID = TE.FEMPID
		/*left join JS_SYS_OFFICE O on O.OFFICE_CODE =Pe.fdepartmentid*/
		WHERE
			1 = 1
			and t.fsrcinterid != 0
			<if test="startTime !=null">
				and TRUNC(T.fdate) &gt;= #{startTime}
			</if>
			<if test="endTime !=null">
				and TRUNC(T.fdate) &lt;= #{endTime}
			</if>
		</if>
		)

		SELECT * from (
		SELECT
		A.startTime,
		A.endTime,
		<if test='(summaryConditions != null and summaryConditions == "2") or (summaryConditions != null and summaryConditions == "1,2" ) '>
			A.FDEPTID,
			A.OFFICENAME AS "fdeptid.officeName",
		</if>
		<if test='(summaryConditions != null and summaryConditions == "1") or (summaryConditions != null and summaryConditions == "1,2" ) '>
			A.FNAME "fname",
			A.fcode "fcode",
			/*A.OFFICENAME AS "fdeptid.officeName",*/
		</if>
		SUM(A.WAGE) as "wage"
		FROM
		AA A
		where 1=1
		<if test="fname != null and fname != ''">
			AND A.FNAME like '%' || #{fname} || '%'
		</if>
		<if test="fdeptid != null and fdeptid.officeName != '' and fdeptid.officeName != null">
			AND A.OFFICENAME like '%' || #{fdeptid.officeName} || '%'
		</if>
		GROUP BY
		A.startTime,
		A.endTime
		<if test='(summaryConditions != null and summaryConditions == "2") or (summaryConditions != null and summaryConditions == "1,2" ) '>
			,A.FDEPTID
			,A.OFFICENAME
		</if>
		<if test='(summaryConditions != null and summaryConditions == "1") or (summaryConditions != null and summaryConditions == "1,2" ) '>
			,A.FNAME
			,A.fcode
			/*,A.OFFICENAME*/
		</if>
		ORDER BY A.startTime
		<if test='(summaryConditions != null and summaryConditions == "2") or (summaryConditions != null and summaryConditions == "1,2" ) '>
			,A.OFFICENAME
		</if>
		<if test='(summaryConditions != null and summaryConditions == "1") or (summaryConditions != null and summaryConditions == "1,2" ) '>
			,A.fcode
		</if>
		)
		UNION ALL
		SELECT
		NULL AS startTime,
		NULL as endTime,
		<if test='(summaryConditions != null and summaryConditions == "2") or (summaryConditions != null and summaryConditions == "1,2" ) '>
			'-' as FDEPTID,
			N'-' AS "fdeptid.officeName",
		</if>
		<if test='(summaryConditions != null and summaryConditions == "1") or (summaryConditions != null and summaryConditions == "1,2" ) '>
			'-' AS "fname",
			'-' AS "fcode",
			/*N'-' AS "fdeptid.officeName",*/
		</if>
		SUM(A.WAGE) as "wage"
		FROM
		AA A
		where 1=1
		<if test="fname != null and fname != ''">
			AND A.FNAME like '%' || #{fname} || '%'
		</if>
		<if test="fdeptid != null and fdeptid.officeName != '' and fdeptid.officeName != null">
			AND A.OFFICENAME like '%' || #{fdeptid.officeName} || '%'
		</if>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值