work-instruction-select.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  7. <title>知识库</title>
  8. <link rel="stylesheet" href="../../../assets/libs/layui/css/layui.css"/>
  9. <link rel="stylesheet" href="../../../assets/module/admin.css?v=312"/>
  10. <link rel="stylesheet" href="../../../assets/module/dtree/dtree.css"/>
  11. <link rel="stylesheet" href="../../../assets/module/dtree/font/dtreefont.css"/>
  12. <style>
  13. .layui-table-cell {
  14. height: auto;
  15. }
  16. ::-webkit-scrollbar {
  17. display: none
  18. }
  19. /*公共样式*/
  20. a,
  21. a:hover,
  22. a:link,
  23. a:visited,
  24. a:active {
  25. text-decoration: none;
  26. }
  27. /*列表展示*/
  28. .left-menu ul {
  29. border-right: 1px solid #ddd;
  30. padding-right: 20px;
  31. }
  32. .left-menu ul > li > a {
  33. display: block;
  34. padding: 10px 15px;
  35. }
  36. .menu-active > a {
  37. background: #25afe5;
  38. border-radius: 6px;
  39. color: #fff;
  40. }
  41. .time-box{
  42. overflow: hidden;
  43. padding-top: 20px;
  44. }
  45. .time1{
  46. float: left;
  47. margin-right: 50px;
  48. }
  49. .fu{
  50. display: inline-block;
  51. font-size: 22px;
  52. color: #fff;
  53. margin-bottom: 10px;
  54. margin-top: 10px;
  55. padding: 10px 20px;
  56. background: #3a98ff;
  57. }
  58. .line{
  59. margin-top: -10px;
  60. border-bottom: 2px solid #3a98ff;
  61. margin-bottom: 25px;
  62. }
  63. </style>
  64. </head>
  65. <body>
  66. <!-- 页面加载loading -->
  67. <div class="page-loading">
  68. <div class="ball-loader">
  69. <span></span><span></span><span></span><span></span>
  70. </div>
  71. </div>
  72. <!-- 正文开始 -->
  73. <div class="layui-fluid">
  74. <div class="layui-card">
  75. <div class="layui-card-body">
  76. <div class="layui-card-header">
  77. 选择指导书
  78. </div>
  79. <div class="layui-card-body">
  80. <div class="layui-tab layui-tab-brief" lay-filter="demo">
  81. <ul class="layui-tab-title">
  82. <li class="layui-this" lay-id="already">已选择的指导书</li>
  83. <li lay-id="select">选择指导书</li>
  84. </ul>
  85. <div class="layui-tab-content" style="min-height: 500px">
  86. <div class="layui-tab-item layui-show" style="overflow: hidden;">
  87. <div class="text-center" id="emptyMsg" style="min-height:220px;padding-top: 30px;">
  88. <span style="font-size: 14px">暂无数据</span>
  89. </div>
  90. <div class="layui-col-sm3 layui-col-md1 layui-col-lg3" id="dataShow">
  91. <div class="layui-card">
  92. <div class="layui-card-body mini-bar" id="menuDiv">
  93. <div class="left-menu">
  94. <ul id="menuListL" style="background-color: #fff"></ul>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="layui-col-sm9 layui-col-md1 layui-col-lg9" id="dataShow2">
  100. <div class="layui-card">
  101. <div class="layui-card-body">
  102. <div style="word-wrap: break-word;border: 0px" class="panel-body" id="postContent">
  103. </div>
  104. <div class="time-box">
  105. <h4><span class="time1" style="font-size: 12px;" id="postAuthor">发布人:</span></h4>
  106. <h4><span class="time1" style="font-size: 12px;" id="createdTime">发布时间:</span></h4>
  107. </div>
  108. <div style="margin-bottom: 30px;" id="fujianDiv">
  109. <span style="font-size: 16px;" class="fu">附件</span>
  110. <div class="line"></div>
  111. <p style="color: indianred;">
  112. 温馨提示:图片可直接点击查看大图,文件可点击下载
  113. </p>
  114. <div id="attachment">
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="layui-tab-item">
  122. <div class="layui-form toolbar">
  123. <div class="layui-form-item text-right">
  124. <div class="layui-inline pull-left">
  125. <label class="layui-form-label w-auto w-padding">搜索:</label>
  126. <div class="layui-input-inline mr0">
  127. <input name="keyword" class="layui-input" type="text" placeholder="输入关键字"/>
  128. </div>
  129. </div>
  130. <div class="layui-inline pull-left">
  131. <button class="layui-btn icon-btn" lay-filter="formSubSearch" lay-submit>
  132. <i class="layui-icon">&#xe615;</i>搜索
  133. </button>
  134. </div>
  135. <div class="layui-inline pull-right">
  136. <button type="button" class="layui-btn" id="saveBtn" >保存</button>
  137. </div>
  138. </div>
  139. </div>
  140. <table class="layui-table" id="datatable" lay-filter="datatable"></table>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. <!-- 表格照片列 -->
  149. <script type="text/html" id="imgTpl">
  150. {{# if(d.postPicUrl != null && d.postPicUrl != ''){ }}
  151. <img class="media-object" width="50px" height="50px" src="{{d.postPicUrl}}">
  152. {{# } else { }}
  153. <img class="media-object" width="50px" height="50px" src="/assets/images/error.jpg">
  154. {{# } }}
  155. </script>
  156. <!-- js部分 -->
  157. <script type="text/javascript" src="../../../assets/libs/layui/layui.js"></script>
  158. <script type="text/javascript" src="../../../assets/js/common.js?v=312"></script>
  159. <script type="text/javascript" src="../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
  160. <script type="text/javascript">
  161. var baseUrl2 = '';
  162. var riskPointId = '';
  163. layui.use(['layer','element', 'table', 'admin','form', 'uParas', 'util','element'], function () {
  164. var $ = layui.jquery;
  165. var layer = layui.layer;
  166. var table = layui.table;
  167. var admin = layui.admin;
  168. var form = layui.form;
  169. var uParas= layui.uParas;
  170. baseUrl2 = uParas.baseUrl;
  171. var element = layui.element; //Tab的切换功能,切换事件监听等,需要依赖element模块
  172. riskPointId = uParas.getUrlParam("riskPointId");
  173. //console.log("riskPointId_________________"+riskPointId);
  174. //riskPointId = "1265";
  175. var postId = '';
  176. var insTb ;
  177. //已选择的指导书初始化
  178. function initPage(){
  179. $.ajax({
  180. type: "post",
  181. url: baseUrl2 + "/ent/post/selectWorkInstruction",
  182. data: {riskPointId: riskPointId, showType:"already"},
  183. dataType: "json",
  184. success: function (resp) {
  185. if (resp.code == 0) {
  186. if (resp.count > 0 && resp.data.length > 0){
  187. $("#emptyMsg").hide();
  188. $("#dataShow").show();
  189. $("#dataShow2").show();
  190. contentMeun(resp.data);
  191. }else{
  192. $("#dataShow").hide();
  193. $("#dataShow2").hide();
  194. $("#emptyMsg").show();
  195. }
  196. } else {
  197. layer.msg(resp.msg);
  198. $("#emptyMsg").show();
  199. $("#dataShow").hide();
  200. $("#dataShow2").hide();
  201. }
  202. }
  203. });
  204. }
  205. //内容函数
  206. function contentMeun(data) {
  207. var media = '';
  208. $.each(data, function (index, item) {
  209. if (index == 0){
  210. postId = item.postId;
  211. media += '<li class="nav-item" style= "display: flex;height: 30px">';
  212. }else{
  213. media += '<li class="nav-item" style= "display: flex;height: 30px">' ;
  214. }
  215. media += ' <a href="#" style="display:block;white-space:nowrap;overflow: hidden;text-overflow:ellipsis;width: 80%;padding : 5px 5px" onclick="viewDetail(\''+item.postId+'\',\''+index+'\')" title="'+ item.postTitle +'">' + item.postTitle + '</a>' +
  216. //'<p style="margin-top: 5px;" onclick="delRelation(\''+item.postId+'\')"><i class="layui-icon layui-icon-close"></i></p>'+
  217. '<p style="margin-top: 5px;" class="delClick" data-val="'+item.postId+'"><i class="layui-icon layui-icon-close"></i></p>'+
  218. '</li>'
  219. });
  220. $("#menuListL").html('');
  221. $("#menuListL").append(media);
  222. viewDetail(postId,0);
  223. }
  224. //渲染表格
  225. function renderTable() {
  226. var url = uParas.baseUrl+'/ent/post/selectWorkInstruction';
  227. insTb = table.render({
  228. elem : '#datatable',
  229. url : url,
  230. page : true,
  231. where :{"riskPointId":riskPointId,showType:"select"},
  232. cellMinWidth: 100,
  233. method:"post",
  234. cols : [[
  235. {type : 'checkbox'} ,
  236. {field: 'postPicUrl' , sort:false , event:'view',title:'图片' , width:100,templet:'#imgTpl'},
  237. {field: 'postTitle' , sort:false , title:'标题' , width:200},
  238. {field: 'postAuthor' , sort:false , title:'作者' },
  239. {field: 'createdTime' , sort:false , title:'创建时间' },
  240. ]]
  241. });
  242. }
  243. //一些事件监听
  244. element.on('tab(demo)', function(data){
  245. if (data.index == 0){
  246. initPage();
  247. } else if(data.index == 1){
  248. renderTable();
  249. }
  250. });
  251. initPage();
  252. //保存选择
  253. $("#saveBtn").click(function () {
  254. var ids = [];
  255. var checkStatus = table.checkStatus('datatable');
  256. var checkData = checkStatus.data;
  257. if (checkData.length < 1){
  258. layer.msg("请选择指导书!");
  259. return ;
  260. }
  261. checkData.forEach(function (val, index, arr) {
  262. ids.push(val.postId);
  263. });
  264. $.ajax({
  265. type: "post",
  266. url: uParas.baseUrl+"/ent/riskPoint/saveWorkInstruction",
  267. data: {riskPointId: riskPointId, ids: ids.join(",")},
  268. dataType: "json",
  269. success: function (result) {
  270. if (result.code === 1) {
  271. layer.closeAll();
  272. element.tabChange('demo', "already");
  273. initPage();
  274. } else {
  275. layer.msg(result.msg);
  276. }
  277. }
  278. });
  279. });
  280. // 搜索
  281. form.on('submit(formSubSearch)', function(data) {
  282. insTb.reload({where: data.field}, 'data');
  283. });
  284. //绑定事件
  285. $(document).on('click', '.delClick', function(e) {
  286. //防止事件冒泡到DOM树上,也就是不触发的任何前辈元素上的事件处理函数
  287. e.stopPropagation();
  288. var postId = $(this).attr('data-val');
  289. $.ajax({
  290. type: "post",
  291. url: baseUrl2 + "/ent/riskPoint/delWorkInstruction",
  292. data: {riskPointId: riskPointId, postId: postId},
  293. dataType: "json",
  294. success: function (result) {
  295. if (result.code === 1) {
  296. initPage();
  297. } else {
  298. layer.msg(result.msg);
  299. }
  300. }
  301. });
  302. });
  303. });
  304. //展示指导书详情
  305. function viewDetail(postId,index){
  306. $('#menuListL li').removeClass('menu-active');
  307. $('#menuListL li').eq(index).addClass('menu-active');
  308. $.ajax({
  309. type: "get",
  310. url: baseUrl2 + "/ent/post/get/"+postId,
  311. dataType: "json",
  312. success: function (res) {
  313. if (res.code === 1) {
  314. var post = res.data.post;
  315. if (post != null && post != ''){
  316. var attachmentList = res.data.attachList;
  317. $("#postAuthor").html("发布人:"+post.postAuthor);
  318. $("#createdTime").html("时间:"+post.createdTime);
  319. $("#postContent").html(post.postContent);
  320. var attachDetail = '';
  321. if (attachmentList != null && attachmentList.length > 0){
  322. $.each(attachmentList, function (index, item) {
  323. attachDetail += '<p>'
  324. + '<a target="_blank" style="color: #5b9bd1" href="'+item.savePath+'" download="'+item.attName+'">'
  325. + item.attName + '</a></p>';
  326. });
  327. }
  328. $("#attachment").html(attachDetail);
  329. }
  330. }
  331. }
  332. });
  333. }
  334. </script>
  335. </body>
  336. </html>