report.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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. height: 100%;
  8. }
  9. .lay-main {
  10. background-color: #EEEEEE;
  11. width: 100%;
  12. height: 100%;
  13. }
  14. .lay-leftBox {
  15. height: 100%;
  16. }
  17. .lay-leftBox form {
  18. height: 100%
  19. }
  20. .flex {
  21. display: flex;
  22. }
  23. .lay-rightBox {
  24. background-color: #fff;
  25. margin: 10px;
  26. box-sizing: border-box;
  27. padding: 10px;
  28. overflow-y: auto;
  29. height: 96%;
  30. }
  31. .lay-rightTips {
  32. width: 100%;
  33. height: 20px;
  34. display: flex;
  35. align-items: center;
  36. }
  37. .labelIcon {
  38. width: 5px;
  39. height: 18px;
  40. border-radius: 2px;
  41. background-color: #249EFB;
  42. }
  43. .valid {
  44. color: #249EFB;
  45. font-weight: 700;
  46. }
  47. .ml6 {
  48. margin-left: 6px;
  49. }
  50. .layui-border-blue,
  51. .layui-border-blue:hover {
  52. color: #249EFB;
  53. border-color: #249EFB;
  54. }
  55. .visitlistBox {
  56. width: 100%;
  57. padding: 10px;
  58. display: flex;
  59. flex-wrap: wrap;
  60. }
  61. .visitItemBox {
  62. flex: 1;
  63. }
  64. .layui-border-black {
  65. margin: 0px 5px 6px !important;
  66. position: relative;
  67. }
  68. .lay-close {
  69. position: absolute;
  70. top: -15px;
  71. right: -10px;
  72. z-index: 99 !important;
  73. }
  74. .fieldBox {
  75. width: 100%;
  76. display: flex;
  77. box-sizing: border-box;
  78. padding: 10px 0px;
  79. height: 90%;
  80. }
  81. .fieldLeftBox {
  82. width: 60%;
  83. box-sizing: border-box;
  84. }
  85. .fieldRightBox {
  86. margin-left: 10px;
  87. box-sizing: border-box;
  88. flex:1;
  89. }
  90. .fieldTitle {
  91. font-size: 13px;
  92. color: #333333;
  93. font-weight: 600;
  94. line-height: 25px;
  95. }
  96. .fieldViewBox {
  97. border: 1px solid #EEEEEE;
  98. padding: 5px;
  99. border-radius: 4px;
  100. box-sizing: border-box;
  101. height: 92%;
  102. overflow: auto;
  103. }
  104. /*里面的代码可以根据自己需求去进行更改*/
  105. /* 设置滚动条的样式 */
  106. .fieldViewBox::-webkit-scrollbar {
  107. width: 4px;
  108. }
  109. /* 滚动槽 */
  110. .fieldViewBox::-webkit-scrollbar-track {
  111. -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.3);
  112. border-radius: 0px;
  113. }
  114. /* 滚动条滑块 */
  115. .fieldViewBox::-webkit-scrollbar-thumb {
  116. border-radius: 10px;
  117. background: #cccccc;
  118. -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.5);
  119. }
  120. .searchBox {
  121. width: 100%;
  122. height: 40px;
  123. border: 1px solid #EEEEEE;
  124. border-radius: 4px;
  125. box-sizing: border-box;
  126. padding: 0px 10px;
  127. display: flex;
  128. align-items: center;
  129. }
  130. .searchBox>input {
  131. flex: 1;
  132. height: 100%;
  133. margin-left: 10px;
  134. outline: none;
  135. border: none;
  136. }
  137. .selectFieldBox {
  138. width: 100%;
  139. height: auto;
  140. overflow: hidden;
  141. box-sizing: border-box;
  142. padding: 10px 0px 10px;
  143. display: flex;
  144. flex-wrap: wrap;
  145. }
  146. .layui-icon-ok:before {
  147. font-size: 12px !important;
  148. }
  149. .layui-form-checkbox {
  150. margin-bottom: 5px;
  151. }
  152. .sortItemBox {
  153. width: 100%;
  154. height: 40px;
  155. display: flex;
  156. align-items: center;
  157. justify-content: space-between;
  158. background-color: #fff;
  159. }
  160. .sortLeft>img {
  161. width: 16px;
  162. }
  163. .sortRight>img {
  164. width: 16px;
  165. }
  166. .moveElement {
  167. cursor: move;
  168. }
  169. .fixed-btn {
  170. width: 100%;
  171. box-sizing: border-box;
  172. padding: 10px 10px;
  173. display: flex;
  174. justify-content: flex-end;
  175. border-top: 1px solid #cccccc;
  176. margin-top: 120px;
  177. }
  178. .fieldItem {
  179. width: 50%;
  180. }
  181. .checkedDel {
  182. cursor: pointer;
  183. }
  184. .layui-icon-search {
  185. cursor: pointer;
  186. }
  187. .allCheckedField {
  188. padding-top: 10px;
  189. }
  190. .layinputtext {
  191. width: 100%;
  192. height: 40px;
  193. border-bottom: 1px solid #DEEAF1;
  194. display: flex;
  195. }
  196. .textlabel {
  197. width: 120px;
  198. height: 100%;
  199. line-height: 40px;
  200. white-space: nowrap;
  201. text-overflow: ellipsis;
  202. overflow: hidden;
  203. font-size: 13px;
  204. }
  205. .textinput {
  206. width: calc(100% - 120px);
  207. height: 100%;
  208. line-height: 40px;
  209. font-size: 13px;
  210. }
  211. .radiocontent {
  212. width: calc(100% - 150px);
  213. height: 100%;
  214. display: flex;
  215. font-size: 13px;
  216. }
  217. .radiocontent>div {
  218. flex: 1;
  219. display: flex;
  220. justify-content: flex-start;
  221. align-items: center;
  222. font-size: 13px;
  223. white-space: nowrap;
  224. }
  225. .gradecontent {
  226. width: calc(100% - 150px);
  227. height: 100%;
  228. display: flex;
  229. align-items: center;
  230. font-size: 13px;
  231. }
  232. .gradecontent>span {
  233. flex: none;
  234. display: inline-block;
  235. padding: 2px 8px;
  236. height: 18px;
  237. border: 1px solid #9DB6CF;
  238. font-size: 13px;
  239. margin-right: 5px;
  240. font-size: 13px;
  241. }
  242. .selectContent {
  243. width: calc(100% - 150px);
  244. height: 100%;
  245. display: flex;
  246. align-items: center;
  247. justify-content: space-between;
  248. font-size: 13px;
  249. }
  250. .selectContent>img {
  251. width: 8px;
  252. }
  253. .dateContent {
  254. width: calc(100% - 150px);
  255. height: 100%;
  256. display: flex;
  257. align-items: center;
  258. justify-content: space-between;
  259. font-size: 13px;
  260. }
  261. .dateContent>img {
  262. width: 14px;
  263. }
  264. .lay-default {
  265. width: 100%;
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-between;
  269. }
  270. .layui-form-checked[lay-skin=primary] i {
  271. border-color: #249EFB;
  272. background-color: #249EFB;
  273. }
  274. </style>
  275. <body>
  276. <div class="lay-main flex">
  277. <div class="lay-leftBox">
  278. <div class="lay-rightBox">
  279. <form class="layui-form">
  280. <div class="lay-rightTips">
  281. <div class="labelIcon"></div>
  282. <span class="ml6">PC报备字段设置</span>
  283. </div>
  284. <div class="fieldBox">
  285. <div class="fieldLeftBox">
  286. <div class="fieldTitle" id="visitAllField"></div>
  287. <div class="fieldViewBox">
  288. <!-- <div class="searchBox">
  289. <i class="layui-icon layui-icon-search"></i>
  290. <input type="text" id="allFieldInput" autocomplete="off">
  291. </div> -->
  292. <div class="allCheckedField">
  293. <input lay-filter="checkedAll" name="all" title="全选" type="checkbox"
  294. lay-skin="primary">
  295. </div>
  296. <div class="selectFieldBox">
  297. </div>
  298. </div>
  299. </div>
  300. <div class="fieldRightBox">
  301. <div class="fieldTitle" id="checkedFieldEl"></div>
  302. <div class="fieldViewBox" id="scrollTargetEl">
  303. <!-- <div class="searchBox">
  304. <i class="layui-icon layui-icon-search"></i>
  305. <input type="text" id="checkedSearchEl" autocomplete="off">
  306. </div> -->
  307. <div class="checkedFieldBox">
  308. </div>
  309. </div>
  310. </div>
  311. </div>
  312. <div class="lay-default">
  313. <div class="layui-btn layui-btn-primary" id="recoveryDefault">恢复默认</div>
  314. <div>
  315. <div class="layui-btn layui-btn-primary">取消</div>
  316. <div class="layui-btn layui-btn-normal" lay-submit
  317. lay-filter="layuiadmin-report-form-submit">确认</div>
  318. </div>
  319. </div>
  320. </form>
  321. </div>
  322. </div>
  323. </body>
  324. {/block} {block name="js"}
  325. <script type="text/javascript" src="__STATIC__/js/Sortable.js"></script>
  326. <script>
  327. layui.config({
  328. base: '__LAYUI__/' //静态资源所在路径
  329. ,
  330. urlbase: '/sys'
  331. }).extend({
  332. index: 'lib/index' //主入口模块
  333. }).use(['index', 'table', 'layedit', 'element', 'upload'], function () {
  334. var $ = layui.$,
  335. table = layui.table,
  336. element = layui.element,
  337. upload = layui.upload,
  338. form = layui.form,
  339. visitFieldAll = [],
  340. checkedArr = [],
  341. defaultArr = [];
  342. form.render();
  343. getVisitFiled();
  344. function getVisitFiled() {
  345. $.ajax({
  346. type: "get",
  347. url: "{:url('customerSetting/report')}",
  348. data: {},
  349. dataType: 'json',
  350. success: function (res) {
  351. if (res.code == 0) {
  352. visitFieldAll = res.all;
  353. checkedArr = res.checked;
  354. defaultArr = res.default;
  355. renderVisitFieldHtmls(visitFieldAll);
  356. renderCheckedFieldHtmls(checkedArr);
  357. }
  358. }
  359. })
  360. }
  361. function renderVisitFieldHtmls(fields) {
  362. $('#visitAllField').text(`可选择字段(共${fields.length}个)`);
  363. let htmls = fields.map((item, index) => {
  364. return `<div class="fieldItem"><input lay-filter="checkboxs" data-keyname="${item.keyname}" data-type="${item.type}" ${item.keyname == 'phone' ? 'disabled' : ''} class="visitFieldElement${item.id}" type="checkbox" ${(returnCheckedStatus(item.id)) ? 'checked' : ''} name="visit" value="${item.id}" title="${item.name}" lay-skin="primary"></div>`;
  365. }).join('');
  366. $('.selectFieldBox').html(htmls);
  367. setTimeout(() => {
  368. form.render();
  369. form.on('checkbox(checkboxs)', function (data) {
  370. if (data.elem.checked) {
  371. let OneValue = [];
  372. $(`input:checkbox[name='visit']:checked`).each(function (i) {
  373. let key = $(this).prop('dataset').keyname;
  374. let type = $(this).prop('dataset').type;
  375. OneValue.push({ id: $(this).val(), name: $(this).prop('title'), keyname: key, type: type });
  376. });
  377. let name = data.elem.title;
  378. if (data.elem.dataset.keyname == 'name') {
  379. checkedArr.unshift({ name: name, id: data.value, keyname: data.elem.dataset.keyname, type: data.elem.dataset.type });
  380. renderCheckedFieldHtmls(checkedArr);
  381. } else {
  382. let itemArr = [];
  383. OneValue.forEach(k => {
  384. let item = checkedArr.filter(o => o.id == k.id);
  385. if (!item.length) {
  386. itemArr.push(k)
  387. }
  388. })
  389. checkedArr.push(...itemArr);
  390. renderCheckedFieldHtmls(checkedArr);
  391. }
  392. } else {
  393. checkedArr.forEach((y, i) => {
  394. if (data.value == y.id) {
  395. checkedArr.splice(i, 1);
  396. renderCheckedFieldHtmls(checkedArr);
  397. return;
  398. }
  399. })
  400. }
  401. })
  402. form.on('checkbox(checkedAll)', function (data) {
  403. if (data.elem.checked) {
  404. $(`input:checkbox[name='visit']`).each(function (i) {
  405. if ($(this).prop('dataset').keyname != 'phone') {
  406. $(this).prop('checked', true);
  407. }
  408. });
  409. checkedArr = visitFieldAll;
  410. renderCheckedFieldHtmls(checkedArr);
  411. form.render();
  412. } else {
  413. checkedArr = visitFieldAll.filter(v => v.keyname == 'phone');
  414. renderCheckedFieldHtmls(checkedArr);
  415. $(`input:checkbox[name='visit']:checked`).each(function (i) {
  416. if ($(this).prop('dataset').keyname != 'phone') {
  417. $(this).prop('checked', false);
  418. }
  419. });
  420. form.render();
  421. }
  422. })
  423. }, 600);
  424. }
  425. function renderCheckedFieldHtmls(checkedFields) {
  426. $('#checkedFieldEl').text(`已选择字段(共${checkedFields.length}个)`);
  427. let firstArr = checkedFields.filter(v => v.keyname == 'name' || v.keyname == 'phone');
  428. let htmls1 = '';
  429. if (firstArr.length == 1) {
  430. htmls1 = firstArr.map((item, index) => {
  431. return `<div data-id="${item.id}" data-type="${item.type}" data-keyname="${item.keyname}" data-name="${item.name}" class="sortItemBox">
  432. <div data-id="${item.id}" class="sortLeft">
  433. ${item.keyname != 'phone' && item.keyname != 'name' ? `<img data-id="${item.id}" class="moveElement" src="/static/img/move.png" alt="">` : ''}
  434. <span data-id="${item.id}" class="getSortName">${item.name}</span>
  435. </div>
  436. <div data-id="${item.id}" class="sortRight">
  437. <img data-id="${item.id}" src="/static/img/sTop.png" alt="">
  438. ${item.keyname != 'phone' ? `<img data-id="${item.id}" src="/static/img/sDel.png" class="checkedDel" alt="">` : ''}
  439. </div>
  440. </div>`;
  441. }).join('');
  442. }
  443. if (firstArr.length == 2) {
  444. htmls1 = firstArr.map((item, index) => {
  445. return `<div data-id="${item.id}" data-type="${item.type}" data-keyname="${item.keyname}" data-name="${item.name}" class="sortItemBox">
  446. <div data-id="${item.id}" class="sortLeft">
  447. ${item.keyname != 'phone' && item.keyname != 'name' ? `<img data-id="${item.id}" class="moveElement" src="/static/img/move.png" alt="">` : ''}
  448. <span data-id="${item.id}" class="getSortName">${item.name}</span>
  449. </div>
  450. <div data-id="${item.id}" class="sortRight">
  451. <img data-id="${item.id}" src="/static/img/sTop.png" alt="">
  452. ${item.keyname != 'phone' ? `<img data-id="${item.id}" src="/static/img/sDel.png" class="checkedDel" alt="">` : ''}
  453. </div>
  454. </div>`;
  455. }).join('');
  456. }
  457. let htmls = checkedFields.map((item, index) => {
  458. if (item.keyname != 'name' && item.keyname != 'phone') {
  459. return `<div data-id="${item.id}" data-type="${item.type}" data-keyname="${item.keyname}" data-name="${item.name}" class="sortItemBox">
  460. <div data-id="${item.id}" class="sortLeft">
  461. ${item.keyname != 'phone' && item.keyname != 'name' ? `<img data-id="${item.id}" class="moveElement" src="/static/img/move.png" alt="">` : ''}
  462. <span data-id="${item.id}" class="getSortName">${item.name}</span>
  463. </div>
  464. <div data-id="${item.id}" class="sortRight">
  465. <img data-id="${item.id}" class="topping" src="/static/img/sTop.png" alt="">
  466. ${item.keyname != 'phone' ? `<img data-id="${item.id}" src="/static/img/sDel.png" class="checkedDel" alt="">` : ''}
  467. </div>
  468. </div>`;
  469. } else {
  470. return null;
  471. }
  472. }).join('');
  473. let aHtmls = `${htmls1}<div class="draggleableBox" id="draggleableBox">${htmls}</div>`
  474. $('.checkedFieldBox').html(aHtmls);
  475. setTimeout(() => {
  476. new Sortable($('.draggleableBox')[0], {
  477. handle: '.moveElement', // handle's class
  478. filter: ".ignore-elements",
  479. animation: 150
  480. });
  481. $('.checkedDel').click(function () {
  482. let id = $(this).prop('dataset').id;
  483. $(this).parent().parent().remove();
  484. checkedArr.forEach((item, index) => {
  485. if (item.id == id) {
  486. $(`.visitFieldElement${id}`).removeAttr('checked');
  487. checkedArr.splice(index, 1);
  488. form.render();
  489. return;
  490. }
  491. })
  492. })
  493. $('.sortRight').click(function () {
  494. var ops1 = {
  495. draggable: ".sortItemBox",
  496. onChoose: function (evt) {
  497. var index = evt.oldIndex;
  498. $("#draggleableBox .sortItemBox").eq(index).insertBefore($("#draggleableBox .sortItemBox").eq(0));
  499. }
  500. };
  501. var sortable1 = Sortable.create($('#draggleableBox')[0], ops1);
  502. })
  503. }, 600);
  504. }
  505. function returnCheckedStatus(vid) {
  506. let ids = checkedArr.map(v => parseInt(v.id));
  507. return ids.includes(parseInt(vid));
  508. }
  509. $('#checkedSearchEl').on('keyup', function (e) {
  510. let val = $(this).val();
  511. if (e.keyCode == 13 && val) {
  512. let eleArr = $('.getSortName');
  513. eleArr.each(function (index) {
  514. let name = $(this).text();
  515. if (name === val || name.indexOf(val) > -1) {
  516. $('#scrollTargetEl').scrollTop((parseInt(index) + 1) * 40);
  517. return;
  518. }
  519. })
  520. }
  521. });
  522. $('#allFieldInput').on('keyup', function (e) {
  523. let val = $(this).val();
  524. if (e.keyCode == 13) {
  525. if (val) {
  526. let itemArr = visitFieldAll.filter(item => {
  527. if (val == item.name || item.name.search(val) > -1) {
  528. return item;
  529. }
  530. })
  531. renderVisitFieldHtmls(itemArr);
  532. } else {
  533. renderVisitFieldHtmls(visitFieldAll);
  534. }
  535. }
  536. })
  537. $('#recoveryDefault').click(function () {
  538. layer.confirm('确定要恢复默认设置吗?', { title: '提示' }, function (index) {
  539. checkedArr = defaultArr;
  540. renderVisitFieldHtmls(visitFieldAll);
  541. renderCheckedFieldHtmls(checkedArr);
  542. layer.close(index);
  543. });
  544. })
  545. /* 监听提交 */
  546. form.on('submit(layuiadmin-report-form-submit)', function (obj) {
  547. let getCheckedField = $('.sortItemBox');
  548. let itemArr = [];
  549. getCheckedField.each(function (i) {
  550. let obj = $(this).prop('dataset');
  551. itemArr.push({ id: obj.id, name: obj.name, keyname: obj.keyname, sort: i + 1, type: obj.type });
  552. })
  553. $.ajax({
  554. url: '{:url("customerSetting/report_save")}',
  555. type: 'post',
  556. data: {
  557. content: itemArr
  558. },
  559. dataType: 'json',
  560. success: function (res) {
  561. if (res.code === 0) {
  562. layer.msg(res.msg, { anim: 0 });
  563. setTimeout(() => {
  564. window.parent.reloadFunc();
  565. }, 1000)
  566. } else {
  567. layer.msg(res.msg, { anim: 6 });
  568. }
  569. }
  570. });
  571. return false;
  572. });
  573. });
  574. </script>
  575. {/block}