1. 程式人生 > >WabaCus實現列表操作列的多按鈕執行操作(專案實戰)

WabaCus實現列表操作列的多按鈕執行操作(專案實戰)

寫這篇博文的初衷:

官方提供的操作列按鈕操作只有一個,即使放上多個按鈕也只執行同一方法,往往不能滿足實際工作中的需求,例如:

<col column="{editablelist-edit}" label="操作列" width="100px">
	<![CDATA[<input type="button" class='cls-button' value="修改時間"/>]]>
	<![CDATA[<input type="button" class='cls-button' value="傳送面試通知"/>]]>
</col>

此時,可藉助<a></a>來完成,再設定成按鈕的style即可,例項如下:

<report id="report2" title="面試溝通中資訊" parenttitle="溝通中request{c1}" rowselect="checkbox" type="editablelist">
	<!-- getReportColData()是page引入的js中的方法,選擇時進行攔截處理 -->
	<buttons>
		<button name="button1" position="title" label="放棄溝通">
			getReportColData('interview','report2',{c01:true},{name:'SELECTEDROW',value:true},'GiveUpCommunication');
		</button>
	</buttons>
	<display>
		<col column="c1" label="個數" displaytype="hidden" />
		<col column="c01" label="co1" displaytype="hidden" clickorderby="true" valuestyleproperty="style='mso-number-format:\@' width='10%'">
			<inputbox jsvalidate="isNotEmpty(${invalid.isnotempty})"/>
		</col>
		<col column="c02" label="姓名"></col>
		<col column="c03" label="應聘職位"></col>
		<col column="c12" label="邀約面試官"></col>
		<col column="c13" label="確認面試官" clickorderby="true" width="15%"></col>
		<col column="c14" label="確認面試時間" width="160px"></col>
		<col column="c15" label="面試通知"></col>
		<col column="{non-fromdb}" label="操作" property="look" width="170px"></col>
	</display>
	<sql>
		<select>
			<value>
				<![CDATA[select (SELECT COUNT(*) c FROM A05 a WHERE c10='溝通中') c1,c01,c02,c03,c12,c13,c14,c15 from A05 where  {#condition#} and c10='溝通中']]>
			</value>
			<condition name="txtgonghao" label="姓名|職位">
				<value>
				<![CDATA[(c02 like '%#data#%' or c03 like '%#data#%')]]>
				</value>
				<inputbox>
					<typeprompt count="30">
						<promptcol label="c02" title="姓名" matchmode="anywhere"></promptcol>
						<promptcol label="c03" title="應聘職位" matchmode="anywhere"></promptcol>
						<datasource>
							<option dataset="@{select c02,c03 from A05 where {#matchcondition#}}"></option>
						</datasource>
					</typeprompt>
				</inputbox>
			</condition>
			<condition name="txtchosemsg" label="確認面試官">
				<value>
					<![CDATA[(c13 =#data#)]]>
				</value>
				<inputbox type="selectbox">
					<option value="" label="確認面試官"></option>
					<option value="待反饋" label="待反饋"></option>
					<option value="已同意" label="已同意"></option>
					<option value="已拒絕" label="已拒絕"></option>
				</inputbox>
			</condition>
		</select>
	</sql>
	<format>
		<imports>
			<import>com.wabacus.util.*</import>
			<import>com.java.util.*</import>
		</imports>
		<value>
			rrequest.getRequest().setAttribute("c1",c1);	<!-- 存放request,以便顯示標題時能取到 -->
			<![CDATA[
				look = c13.indexOf("拒絕")==-1&&c13!="已拒絕"?(c13!="已拒絕"&&c14.indexOf("同意")!=-1?"<a style='line-height:21px;padding: 0 10px;background:#00B38A;border-radius:3px;display:inline-block;font-size:12px;text-decoration:none;color:white;' href='javascript:void(0)' onclick=\"wx_winpage('http://localhost:8080/OA/ShowReport.wx?PAGEID=CancelPlan&id="+c01+"',{width:'35%',height:'35%',title:'取消面試安排'})\">取消安排</a>&nbsp;<a style='line-height:21px;padding: 0 10px;background:#00B38A;border-radius:3px;display:inline-block;font-size:12px;text-decoration:none;color:white;' href='javascript:void(0)' onclick=\"wx_winpage('http://localhost:8080/OA/ShowReport.wx?PAGEID=ReachConfirm&id="+c01+"',{width:'50%',height:'50%',title:'確認應聘者已到達'})\">確認到達</a>":"<a style='line-height:21px;padding: 0 10px;background:#00B38A;border-radius:3px;display:inline-block;font-size:12px;text-decoration:none;color:white;' href='javascript:void(0)' onclick=\"wx_winpage('http://localhost:8080/OA/ShowReport.wx?PAGEID=UpdteInvitationsTime&id="+c01+"',{width:'35%',height:'35%',title:'面試溝通中'})\">修改時間</a>&nbsp;<a style='line-height:21px;padding: 0 10px;background:#00B38A;border-radius:3px;display:inline-block;font-size:12px;text-decoration:none;color:white;' href='javascript:void(0)' onclick=\"wx_winpage('http://localhost:8080/OA/ShowReport.wx?PAGEID=SendEmail&id="+c01+"',{width:'50%',height:'50%',title:'面試溝通中'})\">傳送面試通知</a>"):"<a style='width:145px;line-height:21px;padding: 0 10px;background:#00B38A;border-radius:3px;display:inline-block;font-size:12px;text-decoration:none;color:white;' href='javascript:void(0)' onclick=\"wx_winpage('http://localhost:8080/OA/ShowReport.wx?PAGEID=TwoInvitations&id="+c01+"',{width:'35%',height:'35%',title:'重新發起邀約'})\">重新發起邀約</a>";
				c02 = "<a style='color:#3F00FF' href='ShowReport.wx?PAGEID=ViewWerPDF&c01="+c01+"'>"+c02+"</a>";
			]]>
	  </value>
	</format>
</report>

亮點:

1、發揮三目運算子的優勢,完成了對按鈕的設定

2、點選姓名可實現線上檔案預覽(下期會有一篇博文專門來講述,盡請期待。。。)

效果圖: