dict.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>数据字典</title>
  6. <link href="../../component/pear/css/pear.css" rel="stylesheet" />
  7. </head>
  8. <body class="pear-container">
  9. <div class="layui-row layui-col-space10">
  10. <div class="layui-col-md12">
  11. <div class="layui-card">
  12. <div class="layui-card-body">
  13. <form class="layui-form" action="">
  14. <div class="layui-form-item">
  15. <label class="layui-form-label">字典名称</label>
  16. <div class="layui-input-inline">
  17. <input type="text" name="typeName" placeholder="" class="layui-input">
  18. </div>
  19. <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="dict-type-query">
  20. <i class="layui-icon layui-icon-search"></i>
  21. 查询
  22. </button>
  23. <button type="reset" class="pear-btn pear-btn-md">
  24. <i class="layui-icon layui-icon-refresh"></i>
  25. 重置
  26. </button>
  27. </div>
  28. </form>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="layui-col-md6">
  33. <div class="layui-card">
  34. <div class="layui-card-body">
  35. <table id="dict-type-table" lay-filter="dict-type-table"></table>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="layui-col-md6">
  40. <div class="layui-card">
  41. <div class="layui-card-body">
  42. <svg class="empty" style="margin-top: 50px;margin-left: 220px;margin-bottom: 80px;" width="184" height="152"
  43. viewBox="0 0 184 152" xmlns="http://www.w3.org/2000/svg">
  44. <g fill="none" fillRule="evenodd">
  45. <g transform="translate(24 31.67)">
  46. <ellipse fillOpacity=".8" fill="#F5F5F7" cx="67.797" cy="106.89" rx="67.797" ry="12.668"></ellipse>
  47. <path d="M122.034 69.674L98.109 40.229c-1.148-1.386-2.826-2.225-4.593-2.225h-51.44c-1.766 0-3.444.839-4.592 2.225L13.56 69.674v15.383h108.475V69.674z"
  48. fill="#AEB8C2"></path>
  49. <path d="M101.537 86.214L80.63 61.102c-1.001-1.207-2.507-1.867-4.048-1.867H31.724c-1.54 0-3.047.66-4.048 1.867L6.769 86.214v13.792h94.768V86.214z"
  50. fill="url(#linearGradient-1)" transform="translate(13.56)"></path>
  51. <path d="M33.83 0h67.933a4 4 0 0 1 4 4v93.344a4 4 0 0 1-4 4H33.83a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z" fill="#F5F5F7"></path>
  52. <path d="M42.678 9.953h50.237a2 2 0 0 1 2 2V36.91a2 2 0 0 1-2 2H42.678a2 2 0 0 1-2-2V11.953a2 2 0 0 1 2-2zM42.94 49.767h49.713a2.262 2.262 0 1 1 0 4.524H42.94a2.262 2.262 0 0 1 0-4.524zM42.94 61.53h49.713a2.262 2.262 0 1 1 0 4.525H42.94a2.262 2.262 0 0 1 0-4.525zM121.813 105.032c-.775 3.071-3.497 5.36-6.735 5.36H20.515c-3.238 0-5.96-2.29-6.734-5.36a7.309 7.309 0 0 1-.222-1.79V69.675h26.318c2.907 0 5.25 2.448 5.25 5.42v.04c0 2.971 2.37 5.37 5.277 5.37h34.785c2.907 0 5.277-2.421 5.277-5.393V75.1c0-2.972 2.343-5.426 5.25-5.426h26.318v33.569c0 .617-.077 1.216-.221 1.789z"
  53. fill="#DCE0E6"></path>
  54. </g>
  55. <path d="M149.121 33.292l-6.83 2.65a1 1 0 0 1-1.317-1.23l1.937-6.207c-2.589-2.944-4.109-6.534-4.109-10.408C138.802 8.102 148.92 0 161.402 0 173.881 0 184 8.102 184 18.097c0 9.995-10.118 18.097-22.599 18.097-4.528 0-8.744-1.066-12.28-2.902z"
  56. fill="#DCE0E6"></path>
  57. <g transform="translate(149.65 15.383)" fill="#FFF">
  58. <ellipse cx="20.654" cy="3.167" rx="2.849" ry="2.815"></ellipse>
  59. <path d="M5.698 5.63H0L2.898.704zM9.259.704h4.985V5.63H9.259z"></path>
  60. </g>
  61. </g>
  62. </svg>
  63. <table id="dict-data-table" lay-filter="dict-data-table"></table>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </body>
  69. <script type="text/html" id="dict-type-toolbar">
  70. <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
  71. <i class="layui-icon layui-icon-add-1"></i>
  72. 新增
  73. </button>
  74. <button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
  75. <i class="layui-icon layui-icon-delete"></i>
  76. 删除
  77. </button>
  78. </script>
  79. <script type="text/html" id="dict-type-bar">
  80. <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit">
  81. <i class="layui-icon layui-icon-edit"></i>
  82. </button>
  83. <button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="details">
  84. <i class="layui-icon layui-icon-transfer"></i>
  85. </button>
  86. <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove">
  87. <i class="layui-icon layui-icon-delete"></i>
  88. </button>
  89. </script>
  90. <script type="text/html" id="dict-type-enable">
  91. <input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="dict-type-enable" {{d.enable== '0' ? 'checked' : '' }}>
  92. </script>
  93. <script type="text/html" id="dict-data-toolbar">
  94. <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
  95. <i class="layui-icon layui-icon-add-1"></i>
  96. 新增
  97. </button>
  98. <button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
  99. <i class="layui-icon layui-icon-delete"></i>
  100. 删除
  101. </button>
  102. </script>
  103. <script type="text/html" id="dict-data-bar">
  104. <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>
  105. </button>
  106. <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i>
  107. </button>
  108. </script>
  109. <script type="text/html" id="dict-data-enable">
  110. <input type="checkbox" value="{{d.dataId}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="dict-data-enable" {{d.enable== '0' ? 'checked' : '' }}>
  111. </script>
  112. <script src="../../component/layui/layui.js"></script>
  113. <script src="../../component/pear/pear.js"></script>
  114. <script>
  115. layui.use(['table', 'form', 'jquery'], function() {
  116. let table = layui.table;
  117. let form = layui.form;
  118. let $ = layui.jquery;
  119. let MODULE_PATH = "operate/";
  120. let typeCode;
  121. let cols = [
  122. [{
  123. type: 'checkbox'
  124. },
  125. {
  126. title: '字典名称',
  127. field: 'typeName',
  128. align: 'center',
  129. width: 120
  130. },
  131. {
  132. title: '描述',
  133. field: 'description',
  134. align: 'center'
  135. },
  136. {
  137. title: '字典状态',
  138. field: 'enable',
  139. align: 'center',
  140. templet: '#dict-type-enable'
  141. },
  142. {
  143. title: '操作',
  144. toolbar: '#dict-type-bar',
  145. align: 'center',
  146. width: 180
  147. }
  148. ]
  149. ];
  150. let dataCols = [
  151. [{
  152. type: 'checkbox'
  153. },
  154. {
  155. title: '标签',
  156. field: 'dataLabel',
  157. align: 'center',
  158. width: 120
  159. },
  160. {
  161. title: '对应值',
  162. field: 'dataValue',
  163. align: 'center'
  164. },
  165. {
  166. title: '状态',
  167. field: 'enable',
  168. align: 'center',
  169. templet: '#dict-data-enable'
  170. },
  171. {
  172. title: '操作',
  173. toolbar: '#dict-data-bar',
  174. align: 'center',
  175. width: 180
  176. }
  177. ]
  178. ];
  179. table.render({
  180. elem: '#dict-type-table',
  181. url: "../../demos/data/dictType.json",
  182. page: true,
  183. cols: cols,
  184. skin: 'line',
  185. height: 'full-148',
  186. toolbar: '#dict-type-toolbar',
  187. defaultToolbar: [{
  188. title: '刷新',
  189. layEvent: 'refresh',
  190. icon: 'layui-icon-refresh',
  191. }, 'filter', 'print', 'exports']
  192. });
  193. window.renderData = function(code) {
  194. typeCode = code;
  195. $(".empty").hide();
  196. table.render({
  197. elem: '#dict-data-table',
  198. url: "../../demos/data/dictData.json",
  199. page: true,
  200. height: 'full-148',
  201. cols: dataCols,
  202. skin: 'line',
  203. toolbar: '#dict-data-toolbar'
  204. });
  205. }
  206. table.on('tool(dict-type-table)', function(obj) {
  207. if (obj.event === 'remove') {
  208. window.removeType(obj);
  209. } else if (obj.event === 'edit') {
  210. window.editType(obj);
  211. } else if (obj.event === 'details') {
  212. window.renderData(obj.data['typeCode'])
  213. }
  214. });
  215. table.on('toolbar(dict-type-table)', function(obj) {
  216. if (obj.event === 'add') {
  217. window.addType();
  218. } else if (obj.event === 'refresh') {
  219. window.refreshType();
  220. } else if (obj.event === 'batchRemove') {
  221. layer.msg("批量删除")
  222. }
  223. });
  224. form.on('submit(dict-type-query)', function(data) {
  225. table.reload('dict-type-table', {
  226. where: data.field
  227. })
  228. return false;
  229. });
  230. form.on('switch(dict-type-enable)', function(obj) {
  231. layer.msg("切换");
  232. });
  233. window.addType = function() {
  234. layer.open({
  235. type: 2,
  236. title: '新增',
  237. shade: 0.1,
  238. area: ['500px', '400px'],
  239. content: MODULE_PATH + 'add.html'
  240. });
  241. }
  242. window.editType = function(obj) {
  243. layer.open({
  244. type: 2,
  245. title: '修改',
  246. shade: 0.1,
  247. area: ['500px', '400px'],
  248. content: MODULE_PATH + 'edit.html'
  249. });
  250. }
  251. window.removeType = function(obj) {
  252. layer.msg("删除");
  253. }
  254. window.refreshType = function() {
  255. table.reload('dict-type-table');
  256. }
  257. window.addData = function() {
  258. layer.open({
  259. type: 2,
  260. title: '新增',
  261. shade: 0.1,
  262. area: ['500px', '450px'],
  263. content: MODULE_PATH + 'add.html'
  264. });
  265. }
  266. window.editData = function(obj) {
  267. layer.open({
  268. type: 2,
  269. title: '修改',
  270. shade: 0.1,
  271. area: ['500px', '450px'],
  272. content: MODULE_PATH + 'edit.html'
  273. });
  274. }
  275. window.removeData = function(obj) {
  276. layer.msg("删除");
  277. }
  278. table.on('tool(dict-data-table)', function(obj) {
  279. if (obj.event === 'remove') {
  280. window.removeData(obj);
  281. } else if (obj.event === 'edit') {
  282. window.editData(obj);
  283. } else if (obj.event === 'details') {
  284. window.details(obj);
  285. }
  286. });
  287. table.on('toolbar(dict-data-table)', function(obj) {
  288. if (obj.event === 'add') {
  289. window.addData();
  290. } else if (obj.event === 'refresh') {
  291. window.refreshData();
  292. } else if (obj.event === 'batchRemove') {
  293. layer.msg("批量删除")
  294. }
  295. });
  296. form.on('submit(dict-data-query)', function(data) {
  297. data.field.typeCode = typeCode;
  298. table.reload('dict-data-table', {
  299. where: data.field
  300. })
  301. return false;
  302. });
  303. form.on('switch(dict-data-enable)', function(obj) {
  304. layer.msg("切换状态");
  305. });
  306. window.refreshData = function() {
  307. table.reload('dict-data-table');
  308. }
  309. })
  310. </script>
  311. </html>