work-instruction-select.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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"
  103. id="postContent">
  104. </div>
  105. <div class="time-box">
  106. <h4><span class="time1" style="font-size: 12px;" id="postAuthor">发布人:</span>
  107. </h4>
  108. <h4><span class="time1" style="font-size: 12px;"
  109. id="createdTime">发布时间:</span></h4>
  110. </div>
  111. <div style="margin-bottom: 30px;" id="fujianDiv">
  112. <span style="font-size: 16px;" class="fu">附件</span>
  113. <div class="line"></div>
  114. <p style="color: indianred;">
  115. 温馨提示:图片可直接点击查看大图,文件可点击下载
  116. </p>
  117. <div id="attachment">
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="layui-tab-item">
  125. <div class="layui-form toolbar">
  126. <div class="layui-form-item text-right">
  127. <div class="layui-inline pull-left">
  128. <label class="layui-form-label w-auto w-padding">搜索:</label>
  129. <div class="layui-input-inline mr0">
  130. <input name="keyword" class="layui-input" type="text" placeholder="输入关键字"/>
  131. </div>
  132. </div>
  133. <div class="layui-inline pull-left">
  134. <button class="layui-btn icon-btn" lay-filter="formSubSearch" lay-submit>
  135. <i class="layui-icon">&#xe615;</i>搜索
  136. </button>
  137. </div>
  138. <div class="layui-inline pull-right">
  139. <button type="button" class="layui-btn" id="saveBtn">保存</button>
  140. </div>
  141. </div>
  142. </div>
  143. <table class="layui-table" id="datatable" lay-filter="datatable"></table>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. <!-- 表格照片列 -->
  152. <script type="text/html" id="imgTpl">
  153. {{# if(d.postPicUrl != null && d.postPicUrl != ''){ }}
  154. <img class="media-object" width="50px" height="50px" src="{{d.postPicUrl}}">
  155. {{# } else { }}
  156. <img class="media-object" width="50px" height="50px" src="/assets/images/error.jpg">
  157. {{# } }}
  158. </script>
  159. <!-- js部分 -->
  160. <script type="text/javascript" src="../../../assets/libs/layui/layui.js"></script>
  161. <script type="text/javascript" src="../../../assets/js/common.js?v=312"></script>
  162. <script type="text/javascript" src="../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
  163. <script type="text/javascript">
  164. var baseUrl2 = '';
  165. var riskPointId = '';
  166. layui.use(['layer', 'element', 'table', 'admin', 'form', 'uParas', 'util', 'element'], function () {
  167. var $ = layui.jquery;
  168. var layer = layui.layer;
  169. var table = layui.table;
  170. var admin = layui.admin;
  171. var form = layui.form;
  172. var uParas = layui.uParas;
  173. baseUrl2 = uParas.baseUrl;
  174. var element = layui.element; //Tab的切换功能,切换事件监听等,需要依赖element模块
  175. riskPointId = uParas.getUrlParam("riskPointId");
  176. //console.log("riskPointId_________________"+riskPointId);
  177. //riskPointId = "1265";
  178. var postId = '';
  179. var insTb;
  180. //已选择的指导书初始化
  181. function initPage() {
  182. $.ajax({
  183. type: "post",
  184. url: baseUrl2 + "/ent/post/selectWorkInstruction",
  185. data: {riskPointId: riskPointId, showType: "already"},
  186. dataType: "json",
  187. success: function (resp) {
  188. if (resp.code == 0) {
  189. if (resp.count > 0 && resp.data.length > 0) {
  190. $("#emptyMsg").hide();
  191. $("#dataShow").show();
  192. $("#dataShow2").show();
  193. contentMeun(resp.data);
  194. } else {
  195. $("#dataShow").hide();
  196. $("#dataShow2").hide();
  197. $("#emptyMsg").show();
  198. }
  199. } else {
  200. layer.msg(resp.msg);
  201. $("#emptyMsg").show();
  202. $("#dataShow").hide();
  203. $("#dataShow2").hide();
  204. }
  205. }
  206. });
  207. }
  208. //内容函数
  209. function contentMeun(data) {
  210. var media = '';
  211. $.each(data, function (index, item) {
  212. if (index == 0) {
  213. postId = item.postId;
  214. media += '<li class="nav-item" style= "display: flex;height: 30px">';
  215. } else {
  216. media += '<li class="nav-item" style= "display: flex;height: 30px">';
  217. }
  218. 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>' +
  219. //'<p style="margin-top: 5px;" onclick="delRelation(\''+item.postId+'\')"><i class="layui-icon layui-icon-close"></i></p>'+
  220. '<p style="margin-top: 5px;" class="delClick" data-val="' + item.postId + '"><i class="layui-icon layui-icon-close"></i></p>' +
  221. '</li>'
  222. });
  223. $("#menuListL").html('');
  224. $("#menuListL").append(media);
  225. viewDetail(postId, 0);
  226. }
  227. //渲染表格
  228. function renderTable() {
  229. var url = uParas.baseUrl + '/ent/post/selectWorkInstruction';
  230. insTb = table.render({
  231. elem: '#datatable',
  232. url: url,
  233. page: true,
  234. where: {"riskPointId": riskPointId, showType: "select"},
  235. cellMinWidth: 100,
  236. method: "post",
  237. cols: [[
  238. {type: 'checkbox'},
  239. {field: 'postPicUrl', sort: false, event: 'view', title: '图片', width: 100, templet: '#imgTpl'},
  240. {field: 'postTitle', sort: false, title: '标题', width: 200},
  241. {field: 'postAuthor', sort: false, title: '作者'},
  242. {field: 'createdTime', sort: false, title: '创建时间'},
  243. ]]
  244. });
  245. }
  246. //一些事件监听
  247. element.on('tab(demo)', function (data) {
  248. if (data.index == 0) {
  249. initPage();
  250. } else if (data.index == 1) {
  251. renderTable();
  252. }
  253. });
  254. initPage();
  255. //保存选择
  256. $("#saveBtn").click(function () {
  257. var ids = [];
  258. var checkStatus = table.checkStatus('datatable');
  259. var checkData = checkStatus.data;
  260. if (checkData.length < 1) {
  261. layer.msg("请选择指导书!");
  262. return;
  263. }
  264. checkData.forEach(function (val, index, arr) {
  265. ids.push(val.postId);
  266. });
  267. $.ajax({
  268. type: "post",
  269. url: uParas.baseUrl + "/ent/riskPoint/saveWorkInstruction",
  270. data: {riskPointId: riskPointId, ids: ids.join(",")},
  271. dataType: "json",
  272. success: function (result) {
  273. if (result.code === 1) {
  274. layer.closeAll();
  275. element.tabChange('demo', "already");
  276. initPage();
  277. } else {
  278. layer.msg(result.msg);
  279. }
  280. }
  281. });
  282. });
  283. // 搜索
  284. form.on('submit(formSubSearch)', function (data) {
  285. insTb.reload({where: data.field}, 'data');
  286. });
  287. //绑定事件
  288. $(document).on('click', '.delClick', function (e) {
  289. //防止事件冒泡到DOM树上,也就是不触发的任何前辈元素上的事件处理函数
  290. e.stopPropagation();
  291. var postId = $(this).attr('data-val');
  292. $.ajax({
  293. type: "post",
  294. url: baseUrl2 + "/ent/riskPoint/delWorkInstruction",
  295. data: {riskPointId: riskPointId, postId: postId},
  296. dataType: "json",
  297. success: function (result) {
  298. if (result.code === 1) {
  299. initPage();
  300. } else {
  301. layer.msg(result.msg);
  302. }
  303. }
  304. });
  305. });
  306. });
  307. //展示指导书详情
  308. function viewDetail(postId, index) {
  309. $('#menuListL li').removeClass('menu-active');
  310. $('#menuListL li').eq(index).addClass('menu-active');
  311. $.ajax({
  312. type: "get",
  313. url: baseUrl2 + "/ent/post/get/" + postId,
  314. dataType: "json",
  315. success: function (res) {
  316. if (res.code === 1) {
  317. var post = res.data.post;
  318. if (post != null && post != '') {
  319. var attachmentList = res.data.attachList;
  320. $("#postAuthor").html("发布人:" + post.postAuthor);
  321. $("#createdTime").html("时间:" + post.createdTime);
  322. $("#postContent").html(post.postContent);
  323. var attachDetail = '';
  324. if (attachmentList != null && attachmentList.length > 0) {
  325. $.each(attachmentList, function (index, item) {
  326. attachDetail += '<p>'
  327. + '<a target="_blank" style="color: #5b9bd1" href="' + item.savePath + '" download="' + item.attName + '">'
  328. + item.attName + '</a></p>';
  329. });
  330. }
  331. $("#attachment").html(attachDetail);
  332. }
  333. }
  334. }
  335. });
  336. }
  337. </script>
  338. </body>
  339. </html>