Copy of projectPostDetailList.jsp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@include file="/context/mytags.jsp"%>
  3. <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  4. <!-- 项目岗位明细表 -->
  5. <input name="postGeneralId" id="postGeneralId" type="hidden" value="${postGeneralId}" />
  6. <input name="pid" id="pid" type="hidden" value="${pid}" />
  7. <input name="rowIndex" id="rowIndex" type="hidden" value="" />
  8. <div class="easyui-layout" fit="true" >
  9. <div region="center" style="padding:0px;border:0px">
  10. <div title="新建数据" style="height:90px;" name="editPanel" id="editPanel" fit="true">
  11. <t:formvalid formid="formobj" dialog="true" layout="table" action="" tiptype="1" callback="callback">
  12. <input name="id" id="id" type="hidden" value="" />
  13. <table id="myTable" style="position:absolute;top:10px;">
  14. <tbody>
  15. <tr>
  16. <td align="right">
  17. <label class="Validform_label">
  18. <span color="red" class="requiredIcon">*</span>项目岗位名称:
  19. </label>
  20. </td>
  21. <td class="value">
  22. <input id="ptjPostName" name="ptjPostName" type="text" style="width: 240px" class="inputxt" maxlength="20" datatype="*1-20" errormsg="项目岗位名称最多20文字" placeholder="请输入项目岗位名称(1-20字符)" ignore="checked"/>
  23. <span class="Validform_checktip"></span>
  24. <label class="Validform_label" style="display: none;">项目岗位名称</label>
  25. </td>
  26. <td align="right">
  27. <label class="Validform_label">
  28. <span color="red" class="requiredIcon">*</span>岗位类型:
  29. </label>
  30. </td>
  31. <td class="value">
  32. <%--update-start--Author:jg_renjie Date:20160320 for:#942 【组件封装】所属部门弹出模式,目前是列表,得改造成树方式--%>
  33. <input id="postName" name="postName" type="text" readonly="readonly" class="inputxt" datatype="*" value="${postName}" placeholder="请选择岗位" onclick="openDepartmentSelect()">
  34. <input id="postid" name="postid" type="hidden" value="${postid}">
  35. <a href="#" class="easyui-linkbutton" plain="true" icon="icon-search" id="departSearch" onclick="openDepartmentSelect()">选择</a>
  36. <a href="#" class="easyui-linkbutton" plain="true" icon="icon-undo" id="departRedo" onclick="callbackClean()">清空</a>
  37. <%--update-end--Author:jg_renjie Date:20160320 for:#942 【组件封装】所属部门弹出模式,目前是列表,得改造成树方式--%>
  38. <span class="Validform_checktip"></span>
  39. <label class="Validform_label" style="display: none;">岗位类型</label>
  40. </td>
  41. </tr>
  42. <tr >
  43. <td align="right">
  44. <label class="Validform_label">
  45. <span color="red" class="requiredIcon">*</span>所需人数:
  46. </label>
  47. </td>
  48. <td class="value">
  49. <input id="needNumber" name="needNumber" type="text" style="width: 240px" class="inputxt" maxlength="3" datatype="/^\d{1,3}$/" errormsg="所需人数数最多3位数字" placeholder="请输入所需人数"/>
  50. <span class="Validform_checktip"></span>
  51. <label class="Validform_label" style="display: none;">所需人数</label>
  52. </td>
  53. <td align="right">
  54. <label class="Validform_label">
  55. 备注:
  56. </label>
  57. </td>
  58. <td class="value">
  59. <input id="remark" name="remark" type="text" style="width: 340px" class="inputxt" maxlength="50" datatype="*0-50" errormsg="备注最多50文字" placeholder="请输入项目岗位备注" />
  60. <span class="Validform_checktip"></span>
  61. <label class="Validform_label" style="display: none;">备注</label>
  62. </td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. <div style="display:none"><input type="submit" id ="btnsub" value=""/></div>
  67. </t:formvalid>
  68. </div>
  69. <div title="" style="height:35px" name="editPanel2" id="editPanel2" fit="true">
  70. <a href="#" style="float: right;" class="easyui-linkbutton l-btn l-btn-plain" plain="true" icon="icon-undo" onclick="clearData()">清空</a>&nbsp;&nbsp;&nbsp;
  71. <a href="#" style="float: right;" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-save" plain="true" onclick="btn_ok()">确定</a>
  72. </div>
  73. <div style="height:460px;">
  74. <t:datagrid name="projectPostDetailList" checkbox="false" fitColumns="true" title="${departname}项目岗位列表" actionUrl="projectPostDetailController.do?datagrid&ptjPostGeneralid=${postGeneralId}" idField="id" fit="true" pagination="false" queryMode="group">
  75. <t:dgCol title="主键" field="id" hidden="true" queryMode="single" width="120"></t:dgCol>
  76. <t:dgCol title="项目岗位名称" field="ptjPostName" queryMode="single" width="120"></t:dgCol>
  77. <t:dgCol title="岗位类型" field="postid" queryMode="single" dictionary="t_bus_post,id,post_name, and delete_flag = '0' and status = '0'" width="120"></t:dgCol>
  78. <t:dgCol title="项目岗位总揽表ID" field="ptjPostGeneralid" hidden="true" queryMode="single" width="120"></t:dgCol>
  79. <t:dgCol title="所需人数" field="needNumber" queryMode="single" width="120"></t:dgCol>
  80. <t:dgCol title="备注" field="remark" queryMode="single" width="120"></t:dgCol>
  81. <t:dgCol title="创建人名称" field="createName" hidden="true" queryMode="single" width="120"></t:dgCol>
  82. <t:dgCol title="创建人登录名称" field="createBy" hidden="true" queryMode="single" width="120"></t:dgCol>
  83. <t:dgCol title="创建日期" field="createDate" formatter="yyyy-MM-dd" hidden="true" queryMode="single" width="120"></t:dgCol>
  84. <t:dgCol title="更新人名称" field="updateName" hidden="true" queryMode="single" width="120"></t:dgCol>
  85. <t:dgCol title="更新人登录名称" field="updateBy" hidden="true" queryMode="single" width="120"></t:dgCol>
  86. <t:dgCol title="更新日期" field="updateDate" formatter="yyyy-MM-dd" hidden="true" queryMode="single" width="120"></t:dgCol>
  87. <t:dgCol title="所属部门" field="sysOrgCode" hidden="true" queryMode="single" width="120"></t:dgCol>
  88. <t:dgCol title="所属公司" field="sysCompanyCode" hidden="true" queryMode="single" width="120"></t:dgCol>
  89. <t:dgCol title="逻辑删除标识" field="deleteFlag" hidden="true" queryMode="single" dictionary="del_flag" width="120"></t:dgCol>
  90. <%-- <t:dgCol title="操作" field="opt"></t:dgCol>
  91. <t:dgDelOpt title="删除" url="projectPostDetailController.do?doDel&id={id}" urlclass="ace_button" urlfont="fa-trash-o"/>
  92. <t:dgToolBar title="录入" icon="icon-add" operationCode="add" url="projectPostDetailController.do?goAdd" funname="add"></t:dgToolBar>
  93. <t:dgToolBar title="修改" icon="icon-edit" operationCode="edit" url="projectPostDetailController.do?goUpdate" funname="update"></t:dgToolBar>
  94. <t:dgToolBar title="批量删除" icon="icon-remove" operationCode="remove" url="projectPostDetailController.do?doBatchDel" funname="deleteALLSelect"></t:dgToolBar>
  95. <t:dgToolBar title="查看" icon="icon-search" url="projectPostDetailController.do?goUpdate" funname="detail"></t:dgToolBar>
  96. <t:dgToolBar title="导入" icon="icon-putout" operationCode="put" funname="ImportXls"></t:dgToolBar>
  97. <t:dgToolBar title="导出" icon="icon-put" operationCode="put" funname="ExportXls"></t:dgToolBar>
  98. <t:dgToolBar title="模板下载" icon="icon-putout" operationCode="putout" funname="ExportXlsByT"></t:dgToolBar> --%>
  99. <t:dgToolBar title="删除" icon="icon-remove" operationCode="remove" funname="logicDel"></t:dgToolBar>
  100. </t:datagrid>
  101. </div>
  102. <script>
  103. $(function() {
  104. var datagrid = $("#editPanel");
  105. datagrid.next("div").next("div").after($("#tempSavePostInfo div[name='SavePostInfo1']").html());
  106. $("#tempSavePostInfo").html('');
  107. });
  108. </script>
  109. <div id="tempSavePostInfo" style="display: none;">
  110. <div name="SavePostInfo1">
  111. <div name="SavePostInfo" style="text-align: center;" class="datagrid-toolbar">
  112. <a href="#" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-save" plain="true" onclick="savePostGeneral()">保存</a>
  113. <a href="#" class="easyui-linkbutton" plain="true" icon="icon-redo" id="departRedo" onclick="callbackPostGeneralList()">取消</a>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. <script src = "webpage/cn/com/lzt/projectpostdetail/projectPostDetailList.js"></script>
  120. <script type="text/javascript">
  121. //导入
  122. function ImportXls() {
  123. openuploadwin('Excel导入', 'projectPostDetailController.do?upload', "projectPostDetailList");
  124. }
  125. //导出
  126. function ExportXls() {
  127. JeecgExcelExport("projectPostDetailController.do?exportXls","projectPostDetailList");
  128. }
  129. //模板下载
  130. function ExportXlsByT() {
  131. JeecgExcelExport("projectPostDetailController.do?exportXlsByT","projectPostDetailList");
  132. }
  133. //新增
  134. function add(title,url,id){
  135. window.location.href=url
  136. }
  137. //修改
  138. function update(title,url, id){
  139. updateNotCreateWin("修改",url, "projectPostDetailList",false);
  140. }
  141. //查看
  142. function view(title,url, id){
  143. viewNotCreateWin("查看",url, "projectPostDetailList",false)
  144. }
  145. /* $(document).ready(function(){
  146. //datagrid 隐藏行号
  147. $('#projectPostDetailList').datagrid({rownumbers:false});
  148. }); */
  149. //自定义保存按钮
  150. function btn_ok(){
  151. debugger;
  152. var flag = $("#formobj").Validform().check(true);
  153. if(flag!=true){
  154. $("#btnsub").click();
  155. return false;
  156. }
  157. var id=$('#id').val();
  158. var ptjPostName=$('#ptjPostName').val();
  159. var postid=$('#postid').val();
  160. var needNumber=$('#needNumber').val();
  161. var remark=$('#remark').val();
  162. var rowIndex="";
  163. rowIndex=$('#rowIndex').val();
  164. $('#rowIndex').val("");
  165. //判断项目岗位名称是否重复;
  166. // if(ptjPostNameCheck(rowIndex)!=true){
  167. // return false;
  168. // }
  169. if(rowIndex.length==0){
  170. //index:要插入的行索引,如果该索引值未定义,则追加新行。
  171. //row:行数据。
  172. $('#projectPostDetailList').datagrid('insertRow',{
  173. //index: rowIndex, // 索引从0开始
  174. row: {
  175. ptjPostName: ptjPostName,
  176. postid: postid,
  177. needNumber: needNumber,
  178. remark:remark
  179. }
  180. });
  181. }else{
  182. $('#projectPostDetailList').datagrid('updateRow',{
  183. index: parseInt(rowIndex), // 索引从0开始,parseInt(rowIndex)解决行号变为01,11,22;
  184. row: {
  185. ptjPostName: ptjPostName,
  186. postid: postid,
  187. needNumber: needNumber,
  188. remark:remark
  189. }
  190. });
  191. }
  192. clearData();
  193. /* $.ajax({
  194. url : "projectPostDetailController.do?saveRows",
  195. type : 'post',
  196. data : {
  197. id : id,
  198. ptjPostName : ptjPostName,
  199. postid : postid,
  200. needNumber : needNumber,
  201. remark : remark
  202. },
  203. cache : false,
  204. success : function(data) {
  205. console.log(data);
  206. var d = data; // ------ $.parseJSON(data);
  207. callback(d);
  208. }
  209. }); */
  210. }
  211. //check项目岗位名称
  212. function ptjPostNameCheck(index){
  213. //获得所有行数据
  214. var rowsAll = $("#projectPostDetailList").datagrid('getData').rows;
  215. var ptjPostName=$('#ptjPostName').val()
  216. for(var i=0;i<rowsAll.length;i++){
  217. if(index.length==0){
  218. if(ptjPostName==rowsAll[i].ptjPostName){
  219. layer.alert("项目岗位名称已存在");
  220. return false;
  221. }else{
  222. return true;
  223. }
  224. }else{
  225. if(index!=i && ptjPostName==rowsAll[i].ptjPostName){
  226. layer.alert("项目岗位名称已存在");
  227. return false;
  228. }else{
  229. return true;
  230. }
  231. }
  232. }
  233. return true;
  234. }
  235. //保存数据后刷新当前页面数据
  236. function callback(data){
  237. //debugger;
  238. if(data.success){
  239. clearData();
  240. $("#projectPostDetailList").datagrid('reload');
  241. top.tip(data.msg);
  242. }
  243. else{
  244. top.tip(data.msg);
  245. }
  246. }
  247. //清空选择
  248. function callbackClean(){
  249. $('#postid').val('');
  250. $('#postName').val('');
  251. }
  252. //清空数据
  253. function clearData(){
  254. var rowData = {};
  255. fillData(rowData);
  256. $("#projectPostDetailList").datagrid('clearChecked');
  257. $("#projectPostDetailList").datagrid('unselectAll');
  258. //清空编辑时定义的rowIndex
  259. $("#rowIndex").val("");
  260. }
  261. function fillData(rowData){
  262. //清空表单
  263. $("#formobj").form('clear');
  264. //填充数据
  265. for(var d in rowData){
  266. $("#"+d).val(rowData[d]);
  267. }
  268. }
  269. //选择按钮
  270. function openDepartmentSelect() {
  271. //$.dialog.setting.zIndex = getzIndex();
  272. var orgIds = $("#postid").val();
  273. $.dialog({content: 'url:projectPostDetailController.do?postZTree&orgIds='+orgIds,
  274. zIndex:getzIndex(), title: '岗位类型选择', lock: true, width: '400px', height: '350px', opacity: 0.4, button: [
  275. {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackDepartmentSelect, focus: true},
  276. {name: '<t:mutiLang langKey="common.cancel"/>', callback: function (){}}
  277. ]}).zindex();
  278. }
  279. function callbackDepartmentSelect() {
  280. var iframe = this.iframe.contentWindow;
  281. var treeObj = iframe.$.fn.zTree.getZTreeObj("departSelect");
  282. var nodes = treeObj.getCheckedNodes(true);
  283. if(nodes.length>0){
  284. var ids='',names='';
  285. for(i=0;i<nodes.length;i++){
  286. var node = nodes[i];
  287. ids += node.id+',';
  288. names += node.name+',';
  289. }
  290. setCookie(ids);
  291. $('#postName').val(names);
  292. $('#postName').blur();
  293. $('#postid').val(ids);
  294. }else{
  295. tip("请选择岗位类型");
  296. return false;
  297. }
  298. }
  299. function callbackClean(){
  300. $('#postName').val('');
  301. $('#postid').val('');
  302. }
  303. //编辑数据输入框复现
  304. $(function(){
  305. $("#projectPostDetailList").datagrid({
  306. onClickRow: function(rowIndex, rowData){
  307. $('#rowIndex').val(rowIndex);
  308. $('#id').val(rowData.id);
  309. $('#ptjPostName').val(rowData.ptjPostName);
  310. $('#postid').val(rowData.postid+',');
  311. $('#needNumber').val(rowData.needNumber);
  312. $('#remark').val(rowData.remark);
  313. $.ajax({
  314. url : "projectPostDetailController.do?getPName",
  315. type : 'post',
  316. data : {
  317. id : rowData.postid
  318. },
  319. cache : false,
  320. success : function(data) {
  321. var d = data; // ------ $.parseJSON(data);
  322. $('#postName').val(d.msg);
  323. }
  324. });
  325. }
  326. });
  327. })
  328. //逻辑删除
  329. function logicDel(){
  330. var rows = $("#projectPostDetailList").datagrid('getSelections');
  331. if (rows.length > 0) {
  332. $.messager.confirm("确认", "确定要删除这条数据?", function (r) {
  333. if (r) {
  334. var rowIndex="";
  335. rowIndex=$('#rowIndex').val();
  336. $('#rowIndex').val("");
  337. $('#projectPostDetailList').datagrid('deleteRow',rowIndex);
  338. clearData();
  339. /* for ( var i = 0; i < rows.length; i++) {
  340. id=rows[i].id;
  341. }
  342. $.ajax({
  343. url : "projectPostDetailController.do?logicDel",
  344. type : 'post',
  345. data : {
  346. id : id
  347. },
  348. cache : false,
  349. success : function(data) {
  350. var d = data; // ------ $.parseJSON(data);
  351. if (d.success) {
  352. var msg = d.msg;
  353. tip(msg);
  354. $("#projectPostDetailList").datagrid('reload');
  355. clearData();
  356. id='';
  357. }
  358. }
  359. }); */
  360. }
  361. });
  362. } else {
  363. tip("请选择需要删除的数据");
  364. }
  365. }
  366. //取消
  367. function callbackPostGeneralList(){
  368. window.location.href="projectPostGeneralController.do?list";
  369. }
  370. //保存
  371. function savePostGeneral(){
  372. var postGeneralId=null;
  373. if($("#postGeneralId").val()!="undefined"){
  374. postGeneralId=$("#postGeneralId").val();
  375. }
  376. var pid=$("#pid").val();
  377. var overallSituation;
  378. //获得所有行数据
  379. var rowsAll = $("#projectPostDetailList").datagrid('getData').rows;
  380. if(rowsAll.length>0){
  381. for(var i=0;i<rowsAll.length;i++){
  382. if(i==0){
  383. overallSituation=rowsAll[i].ptjPostName+"-"+rowsAll[i].needNumber;
  384. }else{
  385. overallSituation+=","+rowsAll[i].ptjPostName+"-"+rowsAll[i].needNumber;
  386. }
  387. }
  388. var result={};
  389. result["projectPostDetailList["+0+"].id"]=postGeneralId;
  390. result["projectPostDetailList["+0+"].postid"]=pid;
  391. result["projectPostDetailList["+0+"].remark"]=overallSituation;
  392. for(var i=0;i<rowsAll.length;i++){
  393. for(var d in rowsAll[i]){
  394. result["projectPostDetailList["+parseInt(i+1)+"]."+d]=rowsAll[i][d];
  395. }
  396. //result["projectPostDetailList["+i+"]."+"pkid"]=$("#busId").val();
  397. }
  398. $.ajax({
  399. url : "projectPostGeneralController.do?saveRows",
  400. type : 'post',
  401. /* data : {
  402. id : 1,
  403. pid : pid,
  404. overallSituation : overallSituation,
  405. detailList: result
  406. }, */
  407. data : result,
  408. dataType:"json",
  409. cache : false,
  410. success : function(data) {
  411. if (data.success) {
  412. window.location.href="projectPostGeneralController.do?list";
  413. tip(data.msg);
  414. }
  415. }
  416. });
  417. }else{
  418. tip("请添加项目岗位明细数据");
  419. }
  420. }
  421. </script>