Power-.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <!DOCTYPE html>
  2. <html class="x-admin-sm">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="renderer" content="webkit">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport"
  8. content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
  9. <link rel="shortcut icon" href="https://osscold.baozhida.cn/favicon.ico">
  10. <link rel="bookmark" href="https://osscold.baozhida.cn/favicon.ico">
  11. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
  12. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
  13. <link rel="stylesheet" href="https://osscold.baozhida.cn/layui/css/layui.css">
  14. <script type="text/javascript" src="https://osscold.baozhida.cn/layui/layui.js" charset="utf-8"></script>
  15. <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
  16. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  17. <!--[if lt IE 9]>
  18. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  19. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  20. <![endif]--></head>
  21. <body>
  22. <div class="layui-fluid">
  23. <div class="layui-row">
  24. <form class="layui-form layui-form-pane">
  25. <div class="layui-form-item" style="margin-top: 20px">
  26. <label for="Power_name" class="layui-form-label">
  27. <span class="x-red">*</span>权限名称</label>
  28. <div class="layui-input-inline">
  29. <input {{if gt .id 0 }}
  30. value="{{.Date.Power_name}}"
  31. {{end}} type="text" id="Power_name" name="Power_name" required="" lay-verify="required"
  32. autocomplete="off" class="layui-input"></div>
  33. </div>
  34. <div class="layui-form-item layui-form-text">
  35. <label class="layui-form-label">
  36. 拥有权限
  37. </label>
  38. <table class="layui-table layui-input-block">
  39. <tbody>
  40. <tr>
  41. <td width="50px">
  42. <span>内部人员</span>
  43. </td>
  44. <td>
  45. <div class="layui-input-block">
  46. <input type="checkbox" id="Power_Administration" name="Power_Administration" value='1'
  47. {{if gt $.id 0 }}
  48. {{if eq $.Date.Power_Administration 1 }}
  49. checked="checked"
  50. {{end}}
  51. {{end}}
  52. class='checkone' lay-skin="primary" TITLE="内部人员">
  53. </div>
  54. </td>
  55. </tr>
  56. <tr>
  57. <td>
  58. <span>管理员</span>
  59. </td>
  60. <td>
  61. <div class="layui-input-block">
  62. <input type="checkbox" id="Power_User_r" name="Power_User_r" value='1'
  63. {{if gt $.id 0 }}
  64. {{if eq $.Date.Power_User_r 1 }}
  65. checked="checked"
  66. {{end}}
  67. {{end}}
  68. class='checkone' lay-skin="primary" title="用户管理">
  69. <input type="checkbox" id="Power_User_e" name="Power_User_e" value='1'
  70. {{if gt $.id 0 }}
  71. {{if eq $.Date.Power_User_e 1 }}
  72. checked="checked"
  73. {{end}}
  74. {{end}}
  75. class='checkone' lay-skin="primary" title="创建、编辑、删除 -用户管理">
  76. <input type="checkbox" id="Power_User_entry" name="Power_User_entry" value='1'
  77. {{if gt $.id 0 }}
  78. {{if eq $.Date.Power_User_entry 1 }}
  79. checked="checked"
  80. {{end}}
  81. {{end}}
  82. class='checkone' lay-skin="primary" title="无钥匙进入 -用户管理">
  83. </div>
  84. </td>
  85. </tr>
  86. <tr>
  87. <td>
  88. <span>设备管理</span>
  89. </td>
  90. <td>
  91. <div class="layui-input-block">
  92. <input type="checkbox" id="Power_Device_r" name="Power_Device_r" value='1'
  93. {{if gt $.id 0 }}
  94. {{if eq $.Date.Power_Device_r 1 }}
  95. checked="checked"
  96. {{end}}
  97. {{end}}
  98. class='checkone' lay-skin="primary" title="设备管理">
  99. <input type="checkbox" id="Power_Device_Parameter_e" name="Power_Device_Parameter_e" value='1'
  100. {{if gt $.id 0 }}
  101. {{if eq $.Date.Power_Device_Parameter_e 1 }}
  102. checked="checked"
  103. {{end}}
  104. {{end}}
  105. class='checkone' lay-skin="primary" title="设备参数设置">
  106. <input type="checkbox" id="Power_DeviceSensor_Parameter_e" name="Power_DeviceSensor_Parameter_e" value='1'
  107. {{if gt $.id 0 }}
  108. {{if eq $.Date.Power_DeviceSensor_Parameter_e 1 }}
  109. checked="checked"
  110. {{end}}
  111. {{end}}
  112. class='checkone' lay-skin="primary" title="传感器参数设置">
  113. <input type="checkbox" id="Power_DeviceSensor_Compensate_e" name="Power_DeviceSensor_Compensate_e" value='1'
  114. {{if gt $.id 0 }}
  115. {{if eq $.Date.Power_DeviceSensor_Compensate_e 1 }}
  116. checked="checked"
  117. {{end}}
  118. {{end}}
  119. class='checkone' lay-skin="primary" title="二级报警">
  120. <input type="checkbox" id="Power_Device_a" name="Power_Device_a" value='1'
  121. {{if gt $.id 0 }}
  122. {{if eq $.Date.Power_Device_a 1 }}
  123. checked="checked"
  124. {{end}}
  125. {{end}}
  126. class='checkone' lay-skin="primary" title="设备添加 [内部]">
  127. </div>
  128. <div class="layui-input-block">
  129. <input type="checkbox" disabled="disabled" value='1' checked="checked" class='checkone' lay-skin="primary" title="设备报警">
  130. <input type="checkbox" id="Power_Device_Bind_e" name="Power_Device_Bind_e" value='1'
  131. {{if gt $.id 0 }}
  132. {{if eq $.Date.Power_Device_Bind_e 1 }}
  133. checked="checked"
  134. {{end}}
  135. {{end}}
  136. class='checkone' lay-skin="primary" title="设备绑定">
  137. <input type="checkbox" id="Power_DeviceSensor_Class" name="Power_DeviceSensor_Class" value='1'
  138. {{if gt $.id 0 }}
  139. {{if eq $.Date.Power_DeviceSensor_Class 1 }}
  140. checked="checked"
  141. {{end}}
  142. {{end}}
  143. class='checkone' lay-skin="primary" title="传感器分类">
  144. </div>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td>
  149. <span>数据展示</span>
  150. </td>
  151. <td>
  152. <input type="checkbox" disabled="disabled" value='1' checked="checked" class='checkone' lay-skin="primary" title="数据展示">
  153. <input type="checkbox" id="Power_DataScreen_r" name="Power_DataScreen_r" value='1'
  154. {{if gt $.id 0 }}
  155. {{if eq $.Date.Power_DataScreen_r 1 }}
  156. checked="checked"
  157. {{end}}
  158. {{end}}
  159. class='checkone' lay-skin="primary" title="大数据平台">
  160. </td>
  161. </tr>
  162. <tr>
  163. <td>
  164. <span>系统管理</span>
  165. </td>
  166. <td>
  167. <div class="layui-input-block">
  168. <input type="checkbox" id="Logs_Sys_r" name="Logs_Sys_r" value='1'
  169. {{if gt $.id 0 }}
  170. {{if eq $.Date.Logs_Sys_r 1 }}
  171. checked="checked"
  172. {{end}}
  173. {{end}}
  174. class='checkone' lay-skin="primary" title="系统日志 [内部]">
  175. <input type="checkbox" id="Logs_User_r" name="Logs_User_r" value='1'
  176. {{if gt $.id 0 }}
  177. {{if eq $.Date.Logs_User_r 1 }}
  178. checked="checked"
  179. {{end}}
  180. {{end}}
  181. class='checkone' lay-skin="primary" title="用户日志">
  182. </div>
  183. </td>
  184. </tr>
  185. </tbody>
  186. </table>
  187. </div>
  188. <div class="layui-form-item" style="text-align: center;margin-top: 20px">
  189. <!-- <label for="L_repass" class="layui-form-label"></label>-->
  190. <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button>
  191. </div>
  192. </form>
  193. </div>
  194. </div>
  195. <script>
  196. layui.use(['form', 'layer', "layedit"],
  197. function () {
  198. $ = layui.jquery;
  199. var form = layui.form,
  200. layer = layui.layer;
  201. var layedit = layui.layedit
  202. layedit.set({
  203. uploadImage: {
  204. url: '/UpFile' //接口url
  205. }
  206. });
  207. //构建一个默认的编辑器
  208. var index = layedit.build('T_text', {
  209. height: 580 //设置编辑器高度,
  210. });
  211. function checkone_get(tt) {
  212. if (tt == undefined) {
  213. return 0
  214. }
  215. return 1
  216. }
  217. //监听提交
  218. form.on('submit(add)',
  219. function (data) {
  220. console.log("=== submit(add) ==");
  221. console.log(data);
  222. // console.log(data.field.Power_Admin);
  223. // console.log($("#Power_Admin").attr("checked", "checked"););
  224. $.ajax({
  225. type: 'POST',
  226. url: 'Power_Post',//发送请求
  227. data: {
  228. id: "{{.id}}",
  229. Power_name: data.field.Power_name,
  230. Power_Administration: checkone_get(data.field.Power_Administration),
  231. Power_Admin_r: checkone_get(data.field.Power_Admin_r),
  232. Power_Admin_e: checkone_get(data.field.Power_Admin_e),
  233. Power_User_r: checkone_get(data.field.Power_User_r),
  234. Power_User_entry: checkone_get(data.field.Power_User_entry),
  235. Power_Power_r: checkone_get(data.field.Power_Power_r),
  236. Power_Power_e: checkone_get(data.field.Power_Power_e),
  237. Power_Device_r: checkone_get(data.field.Power_Device_r),
  238. Power_Device_a: checkone_get(data.field.Power_Device_a),
  239. Power_Device_Parameter_e: checkone_get(data.field.Power_Device_Parameter_e),
  240. Power_DeviceSensor_Parameter_e: checkone_get(data.field.Power_DeviceSensor_Parameter_e),
  241. Power_Device_Bind_e: checkone_get(data.field.Power_Device_Bind_e),
  242. Power_DeviceSensor_Compensate_e: checkone_get(data.field.Power_DeviceSensor_Compensate_e),
  243. Power_DeviceSensor_Class: checkone_get(data.field.Power_DeviceSensor_Class),
  244. Power_DataScreen_r: checkone_get(data.field.Power_DataScreen_r),
  245. Logs_Sys_r: checkone_get(data.field.Logs_Sys_r),
  246. Logs_User_r: checkone_get(data.field.Logs_User_r),
  247. },
  248. success: function (result) {
  249. console.log(result)
  250. if (result.Code == 200) {
  251. layer.msg("操作成功", {
  252. icon: 1,
  253. time: 2000
  254. });
  255. } else {
  256. layer.msg("错误:" + result.Msg, {
  257. icon: 2,
  258. time: 2000
  259. });
  260. }
  261. //
  262. //关闭当前frame
  263. parent.layer.close(parent.layer.getFrameIndex(window.name));
  264. parent.location.reload();
  265. form.render('select');
  266. // return false;
  267. }
  268. });
  269. return false;
  270. });
  271. });
  272. </script>
  273. <script>
  274. layui.use('upload', function () {
  275. var $ = layui.jquery
  276. , upload = layui.upload;
  277. //普通图片上传
  278. var uploadInst = upload.render({
  279. elem: '#test1'
  280. , url: '/UpFile' //改成您自己的上传接口
  281. , before: function (obj) {
  282. //预读本地文件示例,不支持ie8
  283. obj.preview(function (index, file, result) {
  284. $('#demo1').attr('src', result); //图片链接(base64)
  285. });
  286. }
  287. , done: function (res) {
  288. console.log(res)
  289. //如果上传失败
  290. if (res.code != 0) {
  291. return layer.msg('上传失败');
  292. }
  293. T_img = res.data.src
  294. console.log(T_img)
  295. //上传成功
  296. }
  297. , error: function () {
  298. console.log("error")
  299. //演示失败状态,并实现重传
  300. var demoText = $('#demoText');
  301. demoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
  302. demoText.find('.demo-reload').on('click', function () {
  303. uploadInst.upload();
  304. });
  305. }
  306. });
  307. //绑定原始文件域
  308. upload.render({
  309. elem: '#test20'
  310. , url: 'https://httpbin.org/post' //改成您自己的上传接口
  311. , done: function (res) {
  312. layer.msg('上传成功');
  313. console.log(res)
  314. }
  315. });
  316. });
  317. </script>
  318. </body>
  319. </html>