management.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2. <script type="text/javascript">
  3. layui.use(['form', 'layedit', 'laydate'], function(){
  4. var form = layui.form
  5. ,layer = layui.layer
  6. ,layedit = layui.layedit
  7. ,laydate = layui.laydate;
  8. //日期
  9. laydate.render({
  10. elem: '#beginDate1' //工程开始时间
  11. });
  12. laydate.render({
  13. elem: '#endDate1' //结束时间
  14. });
  15. laydate.render({
  16. elem: '#beginDate2' //项目开始时间
  17. });
  18. laydate.render({
  19. elem: '#endDate2' //项目结束时间
  20. });
  21. });
  22. layui.config({
  23. base: '${ctxp}/static/plugin/assets/'
  24. }).extend({
  25. treetable: 'treetable-lay/treetable'
  26. }).use(['layer', 'table', 'treetable'], function () { //生成下拉表格
  27. var $ = layui.jquery;
  28. var table = layui.table;
  29. var layer = layui.layer;
  30. var treetable = layui.treetable;
  31. var renderTable1 = function () {
  32. layer.load(2);
  33. treetable.render({
  34. treeColIndex: 0,
  35. treeSpid: -1,
  36. treeIdName: 'id',
  37. treePidName: 'pid',
  38. treeDefaultClose: true,//默认折叠
  39. treeLinkage: true,
  40. elem: '#table1',
  41. cols: [[
  42. {field: 'gcmc',width:200,title: '工程名称'},
  43. {field:'xmsl',width:180,title:"结算书数量"},
  44. {field:'cjsq',width:200,title: '创建时期'},
  45. {field:'djr',width:200,title:'登记人'},
  46. {field:'op',align:'center',title:"操作",minWidth:200,templet:function(d){
  47. ////对操作进行初始化
  48. var xml = "";
  49. if(d.status==1){ //工程按钮
  50. xml += "<a style='margin-top: 3px;' class='layui-btn layui-btn-primary layui-btn-xs' onclick=\"look( '${ctx}/project/form?id=" + d.id + "&tabId=1')\">查看</a>"
  51. +"<a style='margin-top: 3px;' class='layui-btn layui-btn-xs' onclick=\"update( '${ctx}/project/form?id=" + d.id + "&tabId=2')\">修改</a>"
  52. +"<a style='margin-top: 3px;' class='layui-btn layui-btn-normal layui-btn-xs' lay-event='add'>添加结算书</a>"
  53. +"<a style='margin-top: 3px;' class='layui-btn layui-btn-warm layui-btn-xs' lay-event=''href=\"${ctx}/project/export?id=" + d.id+"\">导出</a>"
  54. +"<a style='margin-top: 3px;' class='layui-btn layui-btn-xs layui-btn-danger' onclick=\"deleteProject('"+d.id+"')\">删除</a>";
  55. }
  56. if(d.status==2){ //项目表头操作
  57. xml +="<span class='myspan'>操作</span>";
  58. }
  59. if(d.status==3){ //项目类型
  60. xml +="<a style='margin-top: 3px;' class='layui-btn layui-btn-xs' href=\"${ctx}/jkxl/list?id="+d.id+"&type="+d.type+"\">编辑</a>"
  61. +"<a style='margin-top: 3px;' class='layui-btn layui-btn-xs layui-btn-danger' onclick=\"deleteItem('" + d.id + "')\">删除</a>";
  62. }
  63. return xml;
  64. }}
  65. ]],
  66. data: [
  67. <c:if test="${ not empty page.list}">
  68. <c:forEach items="${page.list}" var="data" varStatus="index">
  69. {
  70. "id": "${data.id}",
  71. "gcmc":"${data.projectName}",
  72. "xmsl": "${data.number}",
  73. "cjsq": "<fmt:formatDate value="${data.createDate}" pattern="yyyy/MM/dd"/>",
  74. "djr":"${data.userName}",
  75. "status":"1",
  76. "pid": -1
  77. },
  78. {
  79. "id": "2",
  80. "gcmc":"结算书名称",
  81. "xmsl": "供应商",
  82. "cjsq": "结算书划分",
  83. "djr":"创建时间",
  84. "status":"2",
  85. "pid": "${data.id}"
  86. },
  87. </c:forEach>
  88. </c:if>
  89. <c:forEach items="${page.list}" var="item" varStatus="index">
  90. <c:forEach items="${item.wbsItems}" var="items" varStatus="index">
  91. {
  92. "id": "${items.id}",
  93. "type":"${items.type}",
  94. "gcmc":"${items.itemName}",
  95. "xmsl": "${items.unit}",
  96. "cjsq":"<c:if test="${items.type eq '1'}">架空线路</c:if><c:if test="${items.type eq '2'}">电缆线路</c:if><c:if test="${items.type eq '3'}">变电站工程</c:if>",
  97. "djr":"<fmt:formatDate value="${items.createDate}" pattern="yyyy/MM/dd"/>",
  98. "status":"3",
  99. "pid": "${items.projectId}"
  100. },
  101. </c:forEach>
  102. </c:forEach>
  103. ],
  104. done: function () {
  105. $(".myspan").closest("tr").css('background-color','#f2f2f2');
  106. layer.closeAll('loading');
  107. }
  108. });
  109. };
  110. renderTable1();
  111. // treetable.foldAll('#table1');
  112. table.on('tool(table1)', function(obj,target){
  113. var data = obj.data;
  114. if(obj.event == 'add'){ //添加项目
  115. $("#addtext").val(data.id);
  116. layui.use(['table','layer'],function(){
  117. layer.open({
  118. type: 2,
  119. title: '添加结算书',
  120. offset:['7%','20%'],
  121. area: ['60%', '90%'],
  122. shade: 0.8,
  123. shadeClose: true,
  124. content: '${ctxp}/webpage/modules/sg/project/addItemForm.jsp'
  125. , btn: ['确定','关闭']
  126. ,yes: function(index, layero){
  127. // var bodyparent = layer.getChildFrame('body', index);
  128. // bodyparent.find('#newProject').click();
  129. var body = layer.getChildFrame('body', index);
  130. var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
  131. var inputForm = body.find('#inputForm');
  132. var top_iframe;
  133. if(target){
  134. top_iframe = target;//如果指定了iframe,则在改frame中跳转
  135. }else{
  136. top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
  137. }
  138. inputForm.attr("target",top_iframe);//表单提交成功后,从服务器返回的url在当前tab中展示
  139. iframeWin.contentWindow.doSubmit();
  140. // layer.close(index);//关闭对话框。
  141. }
  142. ,btn2: function(index, layero){
  143. layer.close(index);
  144. }
  145. })
  146. })
  147. }
  148. });
  149. });
  150. function refresh(){ //刷新
  151. $("#fromSumbit").submit();
  152. }
  153. function addProject(){ //添加工程
  154. layer.prompt({title: '请输入工程名称', formType: 3,offset:['35%','37%']}, function(text, index){
  155. layer.close(index);
  156. $.ajax({
  157. type: "post",
  158. url: "${ctx}/project/save",
  159. data:{projectName:text},
  160. dataType: "json",
  161. success: function(data){
  162. if(data.success){
  163. layer.msg(data.msg, {icon: 6});
  164. window.location.reload();
  165. }else{
  166. layer.msg(data.msg, {icon: 5});
  167. }
  168. }
  169. });
  170. })
  171. }
  172. function look(url) { //工程 查看
  173. layer.open({
  174. type: 2,
  175. title: '查看',
  176. area: ['70%', '90%'],
  177. offset:['7%','14%'],
  178. shade: 0.8,
  179. shadeClose: true,
  180. fixed: true, //不固定
  181. maxmin: true,
  182. content: url,//查看的路径
  183. btn: ['关闭']
  184. })
  185. }
  186. function update(url) { //修改
  187. layer.open({
  188. type: 2,
  189. title: '修改工程',
  190. area: ['70%', '90%'],
  191. offset:['6%','14%'],
  192. shade: 0.8,
  193. shadeClose: true,
  194. fixed: false, //不固定
  195. maxmin: true,
  196. content: url
  197. , btn: ['确定','关闭']
  198. ,yes: function(index, layero){
  199. var bodyparent = layer.getChildFrame('body', index); //获取子类页面body下内容
  200. bodyparent.find('#updatebtn').click(); // 点击修改页面隐藏的按钮
  201. }
  202. ,btn2: function(index, layero){
  203. layer.close(index);
  204. }
  205. })
  206. }
  207. function deleteItem(id) { //逻辑删除项目
  208. layer.msg('您确定要删除吗?', {
  209. icon: 3
  210. , time: 0 //不自动关闭
  211. ,offset:['40%','40%']
  212. , btn: ['确定', '取消']
  213. , yes: function (index) {
  214. $.ajax({
  215. type: "post",
  216. url: "${ctx}/project/tem/deleteItem",
  217. data: {'id': id},
  218. dataType: "json",
  219. success: function (data) {
  220. if (data.success) {
  221. layer.msg(data.msg, {icon: 6,offset:['40%','40%']},function () {
  222. window.location.reload();
  223. });
  224. } else {
  225. layer.msg(data.msg, {icon: 5,offset:['40%','40%']});
  226. }
  227. }
  228. })
  229. }
  230. })
  231. }
  232. function deleteProject(id) {//删除工程
  233. layer.msg('您确定要删除吗?', {
  234. icon: 3
  235. , time: 0 //不自动关闭
  236. , btn: ['确定', '取消']
  237. ,offset:['40%','40%']
  238. , yes: function (index) {
  239. $.ajax({
  240. type: "post",
  241. url: "${ctx}/project/deleteProject",
  242. data: {'id': id},
  243. dataType: "json",
  244. success: function (data) {
  245. if (data.success) {
  246. layer.msg(data.msg, {icon: 6,offset:['40%','40%']},function () {
  247. window.location.reload();
  248. })
  249. } else {
  250. layer.msg(data.msg, {icon: 5,offset:['40%','40%']});
  251. }
  252. }
  253. })
  254. }
  255. })
  256. }
  257. $(document).ready(function(e) { //触发隐藏的 搜索框
  258. $("#noneBtn").click(function(e) {
  259. $("#noneDiv").toggle();
  260. })
  261. });
  262. </script>