community.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. {extend name="public/layout" /} {block name="title"}案例分类管理{/block} {block name="body"}
  2. <style type="text/css">
  3. html,
  4. body {
  5. display: block;
  6. width: 100%;
  7. }
  8. .layui-table thead tr,
  9. .layui-table-header {
  10. background-color: #D8E6F1 !important;
  11. }
  12. .layui-fluid {
  13. display: block;
  14. box-shadow: 0 0 4px 0 #B6CADE;
  15. border-radius: 5px;
  16. margin: 15px;
  17. background-color: #ffffff;
  18. }
  19. .layui-tab {
  20. padding: 15px;
  21. height: 100%;
  22. }
  23. .layui-form-item {
  24. width: 100%;
  25. }
  26. .layui-form-item .layui-inline {
  27. display: block;
  28. float: left;
  29. width: 145px;
  30. height: 38px;
  31. line-height: 38px;
  32. background: #FFFFFF;
  33. margin-right: 16px;
  34. }
  35. .layui-form-item .layui-input-inline {
  36. width: 145px;
  37. height: 38px;
  38. line-height: 38px;
  39. margin-bottom: 0;
  40. }
  41. .layui-icon {
  42. font-size: 20px !important;
  43. }
  44. .layui-form-item .layui-input-inline .layui-input {
  45. border: 1px solid #9DB6CF;
  46. border-radius: 5px;
  47. }
  48. .layui-form-select dl dd.layui-this {
  49. background-color: #249EFB;
  50. }
  51. .layui-form-item div.searchBox {
  52. width: 320px;
  53. background: #FFFFFF;
  54. border: 1px solid #B6CADE;
  55. border-radius: 24px;
  56. height: 38px;
  57. overflow: hidden;
  58. padding-left: 18px;
  59. position: relative;
  60. margin-bottom: 0px;
  61. float: right;
  62. }
  63. .searchBox .inputBox {
  64. width: 240px;
  65. float: left;
  66. height: 36px;
  67. line-height: 36px;
  68. border-width: 0;
  69. }
  70. .searchBtn {
  71. position: absolute;
  72. top: 0;
  73. right: 0;
  74. width: 51px;
  75. height: 38px;
  76. background-color: #fff;
  77. }
  78. .searchBtn img {
  79. position: absolute;
  80. width: 26px;
  81. top: 6px;
  82. left: 0;
  83. }
  84. .layui-card .layui-tab {
  85. margin: 0;
  86. height: 31%;
  87. width: 100%;
  88. padding: 1px;
  89. }
  90. .layui-btn-primary {
  91. color: #249EFB;
  92. border: 1px solid #249EFB;
  93. }
  94. .layui-btn-primary:hover {
  95. background-color: #E3F7FF;
  96. color: #249EFB;
  97. }
  98. .layui-card .layui-tab-brief .layui-tab-title li.layui-this {
  99. background-color: #249EFB;
  100. color: #fff;
  101. }
  102. .layui-tab-brief>.layui-tab-more li.layui-this:after,
  103. .layui-tab-brief>.layui-tab-title .layui-this:after {
  104. border-bottom: none;
  105. }
  106. .layui-card .layui-tab-brief .layui-tab-title li {
  107. background-color: #F2F2F2;
  108. margin: 0px 5px;
  109. }
  110. .layuiadmin-card-header-auto {
  111. display: flex;
  112. justify-content: space-between;
  113. align-items: center;
  114. }
  115. .layui-btn-xs,
  116. .layui-btn-xs:hover {
  117. border: 1px solid #249EFB;
  118. background-color: #fff;
  119. color: #249EFB;
  120. padding: 0px 10px;
  121. }
  122. .layui-btn-danger,
  123. .layui-btn-danger:hover {
  124. border: 1px solid #FF5722;
  125. background-color: #fff;
  126. color: #FF5722;
  127. padding: 0px 10px;
  128. }
  129. .layui-card-body {
  130. padding: 0px;
  131. }
  132. .layui-card-header {
  133. padding: 0px 0px 15px !important;
  134. }
  135. .flex-end {
  136. display: flex;
  137. justify-content: flex-end;
  138. align-items: center;
  139. }
  140. .flex {
  141. display: flex;
  142. }
  143. .flex-sub {
  144. flex: 1;
  145. }
  146. .ml10 {
  147. margin-left: 10px;
  148. }
  149. .search .layui-input-inline{
  150. margin-left: 10px;
  151. }
  152. </style>
  153. <body>
  154. <div class="layui-fluid">
  155. <div class="layui-card">
  156. <div class="layui-card-header layuiadmin-card-header-auto">
  157. <div class="layui-tab layui-tab-brief flex" lay-filter="docDemoTabBrief">
  158. <a href="#" type="button" class="layui-btn layui-btn-primary" id="cate_add">添加小区</a>
  159. <a href="#" type="button" class="layui-btn layui-btn-primary" id="import">导入小区</a>
  160. <a href="#" type="button" class="layui-btn layui-btn-primary" id="export">导出小区</a>
  161. <div class="flex-sub flex-end layui-form">
  162. <div class="layui-inline">
  163. <div class="layui-input-inline">
  164. <select name="employee_id" id="">
  165. <option value="">请选择上传人</option>
  166. {volist name="employee" id="vo"}
  167. <option value="{$vo.id}">{$vo.opt_name}</option>
  168. {/volist}
  169. </select>
  170. </div>
  171. </div>
  172. <div class="layui-inline">
  173. <div class="layui-input-inline">
  174. <input type="text" id="lay-date" name="addtime" placeholder="请选择上传时间" autocomplete="off"
  175. class="layui-input">
  176. </div>
  177. </div>
  178. <div class="layui-inline">
  179. <div class="layui-input-inline">
  180. <input type="text" name="keyword" id="elName" placeholder="请输入小区名称" autocomplete="off"
  181. class="layui-input">
  182. </div>
  183. </div>
  184. <div class="layui-inline ml10">
  185. <button class="layui-btn layuiadmin-btn-list" lay-submit
  186. lay-filter="LAY-app-contlist-search">
  187. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
  188. </button>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. <div class="layui-card-body">
  194. <table id="evidence-table" lay-filter="evidence-table"></table>
  195. </div>
  196. </div>
  197. </div>
  198. </body>
  199. {/block} {block name="js"}
  200. <script type="text/html" id="show">
  201. <input type="checkbox" name="show" value="{{d.id}}" lay-skin="switch" lay-text="上架|下架" lay-filter="show" {{ d.publish == 1 ? 'checked' : '' }}>
  202. </script>
  203. <script type="text/html" id="table-evidence-action">
  204. {{# if(d.show == 0){ }}
  205. <a class="layui-btn layui-btn-xs" lay-event="evi-details">编辑</a>
  206. <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="evidence-delete">删除</a>
  207. {{# }else{ }}
  208. <a class="layui-btn layui-btn-xs layui-btn-disabled" style="border: 1px solid #ccc;color: #ccc;">编辑</a>
  209. <a class="layui-btn layui-btn-xs layui-btn-disabled" style="border: 1px solid #ccc;color: #ccc;">删除</a>
  210. {{# } }}
  211. </script>
  212. <script type="text/html" id="duetime">
  213. {{# if(d.duetime){ }}
  214. <span>{{d.duetime}}</span>
  215. {{# }else{ }}
  216. {{# } }}
  217. </script>
  218. <script type="text/html" id="location">
  219. {{# if(d.location){ }}
  220. <span>{{d.location}}</span>
  221. {{# }else{ }}
  222. {{# } }}
  223. </script>
  224. <script type="text/html" id="opt_employee">
  225. {{# if(d.employee){ }}
  226. {{d.employee.opt_name}}
  227. {{# } }}
  228. </script>
  229. <script>
  230. layui.config({
  231. base: '__LAYUI__/',
  232. urlbase: '/sys'
  233. }).extend({
  234. index: 'lib/index' //主入口模块
  235. }).use(['index', 'table', 'element', 'laydate'], function () {
  236. var $ = layui.$,
  237. form = layui.form,
  238. element = layui.element,
  239. laydate = layui.laydate,
  240. table = layui.table;
  241. laydate.render({
  242. elem: '#lay-date',
  243. range: true
  244. });
  245. //添加分类
  246. $('#cate_add').click(function () {
  247. layer.open({
  248. type: 2,
  249. title: ['添加小区', 'color:#333333;background-color:#D8E6F1;'],
  250. content: "{:url('material/communityadding')}",
  251. area: ['500px', '450px'],
  252. btn: ['确定', '取消'],
  253. yes: function (index, layero) {
  254. var submit = layero.find('iframe').contents().find(
  255. "#layuiadmin-community-submit");
  256. submit.click();
  257. //执行重载
  258. },
  259. end: function() {
  260. table.reload('evidence-table', {});
  261. }
  262. });
  263. return false;
  264. layer.prompt({ title: ['添加', 'color:#333333;background-color:#D8E6F1;'], value: '' }, function (value, index) {
  265. var reg = /^\s+$/g
  266. if (reg.test(value)) {
  267. layer.msg('分类名称不能为空', {
  268. anim: 6, time: 800
  269. });
  270. return false;
  271. }
  272. if (value == '') {
  273. layer.msg('请输入分类名称', {
  274. anim: 6, time: 400
  275. });
  276. return false;
  277. }
  278. if (value.length > 15) {
  279. layer.msg('分类名称超长', {
  280. anim: 6
  281. , time: 400
  282. });
  283. return false;
  284. }
  285. $.ajax({
  286. url: '{:url("material/cate_administration_add")}',
  287. type: 'post',
  288. data: { name: value, type: types },
  289. dataType: 'json',
  290. success: function (res) {
  291. console.log(res)
  292. if (res.code === 0) {
  293. layer.msg(res.msg, {
  294. anim: 0
  295. , time: 400
  296. });
  297. //执行重载
  298. table.reload('evidence-table', {
  299. });
  300. } else {
  301. layer.msg(res.msg, {
  302. anim: 6
  303. , time: 400
  304. });
  305. }
  306. }
  307. });
  308. layer.close(index);
  309. });
  310. });
  311. $('#import').click(function() {
  312. layer.open({
  313. type: 2,
  314. title: ['小区数据导入', 'color:#333333;background-color:#D8E6F1;'],
  315. content: '{:url("material/importingCommunity")}',
  316. resize: false,
  317. area: ['80%', '80%'],
  318. end: function (index, layero) {
  319. //执行重载
  320. table.reload('evidence-table', {});
  321. }
  322. });
  323. })
  324. function openUrl(url) {
  325. var a = document.createElement('a')
  326. a.setAttribute('href', url)
  327. a.setAttribute('target', '_blank')
  328. a.setAttribute('id', 'd2admin-link-temp')
  329. document.body.appendChild(a)
  330. a.click()
  331. document.body.removeChild(document.getElementById('d2admin-link-temp'))
  332. }
  333. $('#export').click(function() {
  334. let url = '{:url("material/export_community")}';
  335. openUrl(url);
  336. })
  337. //选项卡
  338. var types = 0;
  339. function sa(type) {
  340. //执行重载
  341. var w = [];
  342. w.type = type;
  343. table.reload('evidence-table', {
  344. where: w
  345. , page: { curr: 1 }
  346. });
  347. }
  348. ///default entery
  349. //客户见证列表
  350. table.render({
  351. elem: '#evidence-table',
  352. autoSort: false,
  353. url: '{:url("material/cate_administration_list")}',
  354. cols: [
  355. [{
  356. type: 'numbers',
  357. field: 'id',
  358. width: 80,
  359. title: '序号',
  360. sort: true
  361. }, {
  362. field: 'name',
  363. title: '名称'
  364. }, {
  365. field: 'households',
  366. title: '小区户数'
  367. }, {
  368. field: 'location',
  369. title: '地址',
  370. templet: '#location'
  371. }, {
  372. field: 'duetime',
  373. title: '交房时间',
  374. templet: '#duetime',
  375. align:'center'
  376. }, {
  377. field: 'users',
  378. title: '活跃用户',
  379. align:'center'
  380. },{
  381. title: '上传人',
  382. templet: '#opt_employee',
  383. align:'center'
  384. },{
  385. field: 'addtime',
  386. title: '上传时间',
  387. align:'center'
  388. }, {
  389. title: '操作',
  390. width: 240,
  391. align: 'center',
  392. fixed: 'right',
  393. toolbar: '#table-evidence-action'
  394. }]
  395. ],
  396. page: true,
  397. limit: 30,
  398. height: 'full-120',
  399. text: '对不起,加载出现异常!'
  400. });
  401. //监听搜索
  402. form.on('submit(LAY-app-contlist-search)', function (data) {
  403. var field = data.field;
  404. field.type = 0;
  405. field.keyword = $('#elName').val();
  406. //执行重载
  407. table.reload('evidence-table', {
  408. where: field
  409. , page: { curr: 1 }
  410. });
  411. });
  412. //监听列表
  413. table.on('tool(evidence-table)', function (obj) {
  414. var data = obj.data;
  415. if (obj.event === 'evidence-delete') {
  416. //监听关联的数量
  417. $.ajax({
  418. url: '{:url("material/with_cate_administration_count")}',
  419. type: 'post',
  420. data: { id: data.id, type: types },
  421. dataType: 'json',
  422. success: function (res) {
  423. layer.confirm(res, { title: ['信息', 'color:#333333;background-color:#D8E6F1;'] }, function () {
  424. $.get("{:url('material/cate_administration_delete')}?id=" + data.id + '&type=' + types, function (res) {
  425. if (res.code === 0) {
  426. layer.msg(res.msg, { anim: 0, time: 400 }, function () {
  427. table.reload('evidence-table');
  428. });
  429. } else {
  430. layer.msg(res.msg, { anim: 6, time: 400 });
  431. }
  432. });
  433. });
  434. }
  435. });
  436. } else if (obj.event === 'evi-details') {
  437. layer.open({
  438. type: 2,
  439. title: ['编辑小区信息', 'color:#333333;background-color:#D8E6F1;'],
  440. content: "{:url('material/communityadding')}?id=" + data.id,
  441. area: ['500px', '450px'],
  442. btn: ['确定', '取消'],
  443. yes: function (index, layero) {
  444. var submit = layero.find('iframe').contents().find(
  445. "#layuiadmin-community-submit");
  446. submit.click();
  447. //执行重载
  448. },
  449. end: function() {
  450. table.reload('evidence-table', {});
  451. }
  452. });
  453. return false;
  454. layer.prompt({ title: ['编辑', 'color:#333333;background-color:#D8E6F1;'], value: data.name }, function (value, index) {
  455. var reg = /^\s+$/g
  456. if (reg.test(value)) {
  457. layer.msg('请分类名称不能为空', {
  458. anim: 6, time: 800
  459. });
  460. return false;
  461. }
  462. if (value == data.name || value == '') {
  463. layer.msg('请修改名称', {
  464. anim: 6
  465. , time: 400
  466. });
  467. return false;
  468. }
  469. if (value.length > 15) {
  470. layer.msg('分类名称超长', {
  471. anim: 6, time: 400
  472. });
  473. return false;
  474. }
  475. $.ajax({
  476. url: '{:url("material/cate_administration_edit")}',
  477. type: 'post',
  478. data: { id: data.id, name: value, type: types },
  479. dataType: 'json',
  480. success: function (res) {
  481. // console.log(res)
  482. if (res.code === 0) {
  483. layer.msg(res.msg, {
  484. anim: 0
  485. , time: 400
  486. });
  487. //执行重载
  488. table.reload('evidence-table', {
  489. });
  490. // parent.location.reload(); // 父页面刷新
  491. } else {
  492. layer.msg(res.msg, {
  493. anim: 6
  494. , time: 400
  495. });
  496. }
  497. }
  498. });
  499. layer.close(index);
  500. });
  501. }
  502. });
  503. //备注
  504. $('body').on('mouseover', '.remarksInfo', function () {
  505. var type = $(this).data('type');
  506. layer.tips(type, this, {
  507. tips: [1, '#3595CC'],
  508. time: 400
  509. });
  510. });
  511. form.on('switch(show)', function (obj) {
  512. var id = obj.value;
  513. $.ajax({
  514. type: "post",
  515. url: '{:url("material/apipublish")}',
  516. data: {
  517. id: id,
  518. cate: 'evidence'
  519. },
  520. success: function (res) {
  521. layer.msg(res.msg);
  522. }
  523. });
  524. });
  525. });
  526. </script>
  527. {/block}