cyy.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  6. <title>Title</title>
  7. <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
  8. <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
  9. <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
  10. <style>
  11. body {
  12. background-color: #ffffff;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <!--常用语开始-->
  18. <form class="layui-form" action="" lay-filter="formDemo">
  19. <div class="layui-form-item layui-inline" style="width: 100%">
  20. <label class="layui-form-label" style="width: 85px">常用语</label>
  21. <div class="layuimini-container" style="width: 850px; margin-left: 113px">
  22. <div class="layui-btn-group" style="margin-bottom: -8px">
  23. <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-filter="subAdd1"><i class="layui-icon"></i>新建</button>
  24. <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-filter="subEdit1"><i class="layui-icon"></i>编辑</button>
  25. <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-filter="subView1"><i class="layui-icon">&#xe63c;</i>查看</button>
  26. <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-filter="subDelete1"><i class="layui-icon"></i>删除</button>
  27. </div>
  28. <table class="layui-hide" id="currentTableId1" lay-filter="currentTableFilter1"></table>
  29. </div>
  30. </div>
  31. <!-- 右侧悬浮按钮 -->
  32. <div class="layui-form layuimini-form" style="padding-bottom: 100px">
  33. <div class="right-bottom-btn">
  34. <!-- <button class="layui-btn" lay-filter="selectBtn">-->
  35. <!-- <i class="layui-icon layui-icon-ok"></i>选择-->
  36. <!-- </button>-->
  37. <button class="layui-btn" lay-filter="cancleBtn">
  38. <i class="layui-icon layui-icon-close"></i>关闭
  39. </button>
  40. </div>
  41. </div>
  42. </form>
  43. <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
  44. <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
  45. <script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
  46. <script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
  47. <script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
  48. <script type="text/javascript" th:inline="javascript">
  49. AjaxUtil.ctx = /*[[@{/}]]*/'';
  50. var cyyCompany = [];//当前常用语
  51. var updateflag = 0;//更新标志
  52. var project = null;
  53. layui.use(['form', 'table'], function () {
  54. var form = layui.form,
  55. table = layui.table,
  56. layer = layui.layer,
  57. $ = layui.$;
  58. // 用于存放表格数据
  59. var tableData = new Array();
  60. $.ajax({
  61. url: AjaxUtil.ctx + 'prjProject/cyyList',
  62. type: "post",
  63. async: false,
  64. dataType: "json",
  65. success: function(result) {
  66. tableData = result.data.rows;
  67. }
  68. });
  69. var currTable1 = table.render({
  70. elem: '#currentTableId1',
  71. data: tableData,
  72. cols: [
  73. [
  74. {type: "checkbox"},
  75. {field: 'id', title: '序号', width: '8%', align: 'center'},
  76. {field: 'cyy', title: '常用语'}
  77. ]
  78. ],
  79. autoSort: true,
  80. initSort: {
  81. field: 'id', //排序字段
  82. type: 'asc' //排序方式:desc 降序,asc 升序
  83. }
  84. });
  85. // //监听行选中
  86. // table.on('row(currentTableFilter1)', function (obj) {
  87. // project = obj.data;
  88. // obj.tr.addClass('layui-bg-blue').siblings().removeClass('layui-bg-blue');
  89. //
  90. // localStorage.setItem("xmlx", project.xmlx == null ? '' : project.xmlx);
  91. // });
  92. // //双击(常用语)
  93. // table.on('rowDouble(currentTableFilter1)', function (obj) {
  94. // project = obj.data;
  95. // obj.tr.addClass('layui-bg-blue').siblings().removeClass('layui-bg-blue');
  96. // var data = obj.data;
  97. // cyyCompany = {
  98. // "id": data.id,
  99. // "cyy": data.cyy
  100. // };
  101. // localStorage.setItem("xmlx", project.xmlx == null ? '' : project.xmlx);
  102. // localStorage.setItem("updateflag", "1");
  103. // parent.layer.close(parent.layer.getFrameIndex(window.name));// 关闭子窗口
  104. // });
  105. // 监听新建按钮(常用语)
  106. $("button[lay-filter='subAdd1']").click(function(){
  107. layer.open({
  108. title: '新建常用语',
  109. type: 2,
  110. shade: 0.2,
  111. area: [layerwidth + 'px', layerheight + 'px'],
  112. content: AjaxUtil.ctx + 'prjProject/forCyyAdd',
  113. end: function (index) {
  114. if (updateflag == 1) {
  115. updateflag = 0;
  116. var oldData = table.cache["currentTableId1"];
  117. var item = {
  118. "id": cyyCompany.id,
  119. "cyy": cyyCompany.cyy
  120. };
  121. //刷新表格
  122. // oldData.push(item);
  123. // table.reload('currentTableId1',{
  124. // data : oldData
  125. // });
  126. var iframeIndex = parent.layer.getFrameIndex(window.name);
  127. parent.layer.close(iframeIndex);
  128. }
  129. }
  130. });
  131. });
  132. // 监听编辑按钮(常用语)
  133. $("button[lay-filter='subEdit1']").click(function(){
  134. var companys = table.cache["currentTableId1"];
  135. if(companys.length == 0)
  136. return;
  137. var checkStatus = table.checkStatus('currentTableId1')
  138. ,data = checkStatus.data;
  139. if (data == null || data.length === 0) {
  140. Message.warning("请选择要编辑的常用语!", 1500);
  141. } else if(data.length > 1) {
  142. Message.warning("请选择一条常用语进行编辑操作!", 1500);
  143. } else {
  144. cyyCompany = {
  145. "id": data[0].id,
  146. "cyy": data[0].cyy
  147. };
  148. layer.open({
  149. title: '编辑常用语',
  150. type: 2,
  151. // maxmin: true,
  152. shade: 0.2,
  153. area: [layerwidth + 'px', layerheight + 'px'],
  154. content: AjaxUtil.ctx + 'prjProject/forUpdate',
  155. end: function (index) {
  156. if (updateflag == 1) {
  157. updateflag = 0;
  158. var oldData = table.cache["currentTableId1"];
  159. var currCompany = {
  160. "id": cyyCompany.id,
  161. "cyy": cyyCompany.cyy
  162. };
  163. for (var i = 0; i < oldData.length; i++) {
  164. var item = oldData[i];
  165. if (item.LAY_CHECKED) {//条件:选中
  166. // oldData.splice(i, 1);//移除后后造成数组下标索引发生变化,所以下面需要i--
  167. oldData[i] = currCompany;
  168. break;
  169. }
  170. }
  171. //刷新表格
  172. var currData = oldData;
  173. // currData.push(currCompany);
  174. table.reload('currentTableId1', {
  175. data: currData
  176. });
  177. }
  178. }
  179. });
  180. }
  181. });
  182. // 监听查看按钮(常用语)
  183. $("button[lay-filter='subView1']").click(function(){
  184. var companys = table.cache["currentTableId1"];
  185. if(companys.length == 0)
  186. return;
  187. var checkStatus = table.checkStatus('currentTableId1')
  188. ,data = checkStatus.data;
  189. if (data == null || data.length === 0) {
  190. Message.warning("请选择要浏览的常用语!", 1500);
  191. } else if(data.length > 1) {
  192. Message.warning("请选择一条常用语进行浏览!", 1500);
  193. } else {
  194. cyyCompany = {
  195. "id": data[0].id,
  196. "cyy": data[0].cyy
  197. };
  198. layer.open({
  199. title: '浏览常用语',
  200. type: 2,
  201. // maxmin: true,
  202. shade: 0.2,
  203. area: [layerwidth + 'px', layerheight + 'px'],
  204. content: AjaxUtil.ctx + 'prjProject/forCyyView',
  205. end: function (index) {
  206. layer.close(index);
  207. }
  208. });
  209. }
  210. });
  211. // 监听删除按钮(常用语)
  212. $("button[lay-filter='subDelete1']").click(function(){
  213. var companys = table.cache["currentTableId1"];
  214. if(companys.length == 0)
  215. return;
  216. var checkStatus = table.checkStatus('currentTableId1')
  217. ,data = checkStatus.data;
  218. if (data == null || data.length === 0) {
  219. Message.warning("请选择要删除的常用语!", 1000);
  220. return;
  221. }else if(data.length != 0) {
  222. AjaxUtil.get({
  223. url: AjaxUtil.ctx + 'prjProject/forCyyDelete/'+data[0].id
  224. });
  225. }
  226. var oldData = table.cache["currentTableId1"];
  227. for (var i = 0; i < oldData.length; i++) {
  228. var item = oldData[i];
  229. if (item.LAY_CHECKED) {//条件:选中
  230. oldData.splice(i, 1);//移除后后造成数组下标索引发生变化,所以下面需要i--
  231. i--;
  232. }
  233. }
  234. var currData = oldData;
  235. table.reload('currentTableId1', {
  236. data: currData
  237. });
  238. });
  239. // // 监听选择按钮
  240. // $("button[lay-filter='selectBtn']").click(function(){
  241. // if(project == null)
  242. // {
  243. // Message.warning("请选择项目", 1000);
  244. // return;
  245. // }
  246. // localStorage.setItem("updateflag", "1");
  247. //
  248. // parent.layer.close(parent.layer.getFrameIndex(window.name));// 关闭子窗口
  249. // });
  250. // 监听关闭按钮
  251. $("button[lay-filter='cancleBtn']").click(function(){
  252. localStorage.setItem("updateflag", "0");
  253. var iframeIndex = parent.layer.getFrameIndex(window.name);
  254. parent.layer.close(iframeIndex);
  255. });
  256. });
  257. function getCyyCompany()
  258. {
  259. return cyyCompany;
  260. }
  261. function setCyyCompany(expense)
  262. {
  263. cyyCompany = expense;
  264. }
  265. function setUpdateFlag() {
  266. updateflag = 1;
  267. }
  268. </script>
  269. </body>
  270. </html>