ybq_image.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. {% extends "base.html" %} {% block headcss %} {% load staticfiles %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8" />
  6. <link href="{% static '/lib/magnific-popup.css' %}" rel="stylesheet" type="text/css" media="all" />
  7. <style>
  8. body {
  9. overflow: hidden;
  10. }
  11. .clearfix:before,
  12. .clearfix:after {
  13. display: table;
  14. line-height: 0;
  15. content: ""
  16. }
  17. .clearfix:after {
  18. clear: both
  19. }
  20. .fl {
  21. float: left;
  22. }
  23. .fr {
  24. float: right;
  25. }
  26. .mfp-bottom-bar {
  27. color: #fff;
  28. }
  29. a {
  30. text-decoration: none !important;
  31. }
  32. .popup-gallery>div {
  33. float: left;
  34. width: 400px;
  35. overflow: hidden;
  36. text-align: center;
  37. position: relative;
  38. padding-bottom: 15px;
  39. }
  40. .imgParent:hover span {
  41. display: block;
  42. }
  43. .imgParent .delBtn {
  44. display: none;
  45. position: absolute;
  46. top: 10px;
  47. right: 58px;
  48. cursor: pointer;
  49. background: url(../static/img/delIcon.png);
  50. width: 25px;
  51. height: 25px;
  52. background-size: cover;
  53. }
  54. .content-body {
  55. margin-top: 20px;
  56. }
  57. .popupA img {
  58. width: 300px;
  59. height: 300px;
  60. }
  61. .imgParent a,
  62. .popupA p {
  63. color: #08c;
  64. padding: 10px;
  65. }
  66. /* 配置 */
  67. #lookDescribe {
  68. max-width: 700px;
  69. }
  70. .white-popup {
  71. position: relative;
  72. background: #FFF;
  73. padding: 20px;
  74. width: auto;
  75. max-width: 500px;
  76. margin: 20px auto;
  77. }
  78. .white-popup h1 {
  79. font-size: 20px;
  80. /* margin: 10px 0; */
  81. color: #006dcc;
  82. line-height: 15px;
  83. }
  84. .pupopTitle {
  85. width: 140px;
  86. text-align: right;
  87. vertical-align: middle;
  88. /* margin-top: 7px; */
  89. line-height: 30px;
  90. }
  91. .pupopBody input,
  92. .pupopBody select {
  93. height: 20px;
  94. padding: 4px 6px;
  95. margin-bottom: 10px;
  96. font-size: 14px;
  97. line-height: 20px;
  98. color: #4a4a4a;
  99. background: #fff;
  100. border: 1px solid #ccc;
  101. vertical-align: middle;
  102. width: 200px;
  103. }
  104. .pupopBody select {
  105. height: 30px;
  106. width: 215px;
  107. line-height: 30px;
  108. cursor: pointer;
  109. border: 1px solid #ccc;
  110. }
  111. .btnParent {
  112. text-align: center;
  113. }
  114. .btnParent input {
  115. color: #fff;
  116. text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  117. background-color: #006dcc;
  118. width: 80px;
  119. height: 30px;
  120. border-radius: 3px;
  121. border: none;
  122. cursor: pointer;
  123. margin: 5px 17px;
  124. }
  125. .btnParent input:hover {
  126. color: #fff;
  127. background-color: #04c;
  128. }
  129. .nullData {
  130. width: 100%;
  131. height: 500px;
  132. background: #ddd;
  133. text-align: center;
  134. line-height: 500px;
  135. font-size: 20px;
  136. border: 1px solid #ddd;
  137. }
  138. #wormDetails {
  139. width: 100%;
  140. text-align: center;
  141. line-height: 30px;
  142. }
  143. table tr {
  144. border-bottom: 1px solid #e6e6e6;
  145. line-height: 40px;
  146. }
  147. table .option,
  148. table .optionName {
  149. width: 150px;
  150. }
  151. table input {
  152. width: 80%;
  153. text-align: center;
  154. }
  155. .saveBtn {
  156. display: none;
  157. }
  158. #addwormType,
  159. #delwormType {
  160. display: none;
  161. }
  162. #delwormType .pupopBody {
  163. width: 340px;
  164. font-size: 0;
  165. }
  166. #addwormType h2,
  167. #delwormType h2 {
  168. font-size: 16px;
  169. text-indent: 30px;
  170. color: #006dcc;
  171. }
  172. .my_protocol {
  173. line-height: 30px;
  174. display: inline-block;
  175. width: 169px;
  176. overflow: hidden;
  177. white-space: nowrap;
  178. text-overflow: ellipsis;
  179. }
  180. .my_protocol .input_agreement_protocol {
  181. appearance: none;
  182. -webkit-appearance: none;
  183. outline: none;
  184. display: none;
  185. }
  186. /*未选中时*/
  187. .my_protocol .input_agreement_protocol+span {
  188. cursor: pointer;
  189. width: 16px;
  190. height: 16px;
  191. background-color: red;
  192. display: inline-block;
  193. background: url(../static/img/checkboxBj.png) no-repeat;
  194. background-position-x: 0px;
  195. background-position-y: 0px;
  196. position: relative;
  197. top: 3px;
  198. margin-right: 3px;
  199. }
  200. /*选中checkbox时,修改背景图片的位置*/
  201. .my_protocol .input_agreement_protocol:checked+span {
  202. background-position: -19px 0px
  203. }
  204. /* 图片列表批量删除复选框样式 */
  205. .imgcheckbox input[type='checkbox']+span{
  206. cursor: pointer;
  207. width: 18px;
  208. height: 18px;
  209. background-color: red;
  210. display: inline-block;
  211. background: url(/static/img/tick.png) no-repeat center;
  212. background-position: -19px 0px;
  213. position: relative;
  214. top: 3px;
  215. border: 1px solid #bbb;
  216. }
  217. .imgcheckbox input[type='checkbox']:checked+span {
  218. background-position-x: 3px;
  219. background-position-y: 3px;
  220. }
  221. .imgcheckbox input{
  222. display: none;
  223. }
  224. .imgcheckbox{
  225. display: none;
  226. position: absolute;
  227. right: 19px;
  228. top: 0px;
  229. }
  230. .searchCover {
  231. margin: 20px 0;
  232. }
  233. .delbox{
  234. text-align: right;
  235. }
  236. .canceldelimgBtn{
  237. display: none;
  238. }
  239. </style>
  240. </head>
  241. <body>
  242. <div class="content">
  243. <div id="content-header">
  244. <h1 class="tb-fpsb" style="display: inline-block;">
  245. 报表管理
  246. </h1>
  247. <span id="">
  248. > 诱捕器
  249. </span>
  250. <span>
  251. >
  252. <span class="kindName">{{equip_name}}</span>
  253. </span>
  254. <!-- 操作 -->
  255. <div class="searchCover delbox" style="float: right;">
  256. <button type="button" onclick="reload()" class="btn btn-sm btn-success">刷新</button>
  257. <button type="button" onclick="delimgAll(this)" class="btn btn-sm btn-primary batchesBtn">批量删除</button>
  258. <button type="button" onclick="canceldelimg(this)" id="canceldel" class="btn btn-sm canceldelimgBtn">取消</button>
  259. </div>
  260. </div>
  261. <!-- 图片列表 -->
  262. <div class="content-body" id="imgList">
  263. </div>
  264. <div class="fenpei-bottom">
  265. <input type="hidden" id="imei" value="{{imei}}">
  266. <input type="hidden" id="totalPage" value={{ nums }}>
  267. <div id="page" style="text-align: center;"></div>
  268. </div>
  269. <!-- 添加详情 -->
  270. <div id="test-popup" class="white-popup mfp-hide">
  271. <h1>添加详情</h1>
  272. <hr/>
  273. <form action="" id="pupopForm">
  274. <input type="hidden" value="" id="imgPath">
  275. <div class="pupopBox clearfix">
  276. <div class="fl pupopTitle">害虫名称:</div>
  277. <div class="fl pupopBody">
  278. <!-- <input type="text" value="" name="wormName"> -->
  279. <select name="wormName" id=""></select>
  280. <img src="{% static '/img/addicon.png' %}" id="addNameBtn" alt="" onclick="addNameBox()" title="添加害虫种类" width="28" style="margin-bottom: 10px;cursor: pointer;">
  281. <img src="{% static '/img/subtract.png' %}" id="delNameBtn" alt="" onclick="delNameBox()" title="删除害虫种类" width="28" style="margin-bottom: 10px;cursor: pointer;">
  282. </div>
  283. </div>
  284. <div class="pupopBox clearfix">
  285. <div class="fl pupopTitle">数量:</div>
  286. <div class="fl pupopBody">
  287. <input type="number" value="0" min="0" name="wormNum">
  288. </div>
  289. </div>
  290. <div class="pupopBox clearfix">
  291. <div class="fl pupopTitle">作物种类:</div>
  292. <div class="fl pupopBody">
  293. <input type="text" value="" placeholder="选填项" name="wormKind">
  294. </div>
  295. </div>
  296. <!-- <div class="pupopBox clearfix">
  297. <div class="fl pupopTitle">雌雄:</div>
  298. <div class="fl pupopBody">
  299. <select name="wormSex" id="">
  300. <option value="0">雌</option>
  301. <option value="1">雄</option>
  302. </select>
  303. </div>
  304. </div> -->
  305. <div class="pupopBox clearfix">
  306. <div class="fl pupopTitle">虫害阶段:</div>
  307. <div class="fl pupopBody">
  308. <input type="text" value="" placeholder="选填项" name="wormTime">
  309. </div>
  310. </div>
  311. <div class="btnParent">
  312. <input type="button" id='saveBtn' onclick="savePopWin()" value="保存">
  313. <input type="button" id='cancelBtn' onclick="closePopWin($(this))" value="取消">
  314. </div>
  315. </form>
  316. <!-- 添加害虫种类 -->
  317. <div id="addwormType">
  318. <h2>添加害虫种类</h2>
  319. <form action="" class="">
  320. <div class="pupopBox clearfix">
  321. <div class="fl pupopTitle">害虫名称:</div>
  322. <div class="fl pupopBody">
  323. <input type="text" maxlength="20" value="" name="wormTypeSelect">
  324. <!-- <img src="{% static '/img/addicon.png' %}" alt="" onclick="goBackAddDetial()" title="返回添加" width="28"> -->
  325. </div>
  326. </div>
  327. <div class="btnParent">
  328. <input type="button" id='saveBtn' onclick="saveWormType()" value="保存">
  329. <input type="button" id='cancelBtn' onclick="goBackAddDetial()" value="取消">
  330. </div>
  331. </form>
  332. </div>
  333. <!-- 删除害虫种类 -->
  334. <div id="delwormType">
  335. <h2>删除害虫种类</h2>
  336. <form action="" class="">
  337. <div class="pupopBox clearfix">
  338. <div class="fl pupopTitle">害虫名称:</div>
  339. <div class="fl pupopBody"></div>
  340. </div>
  341. <div class="btnParent">
  342. <input type="button" id='saveBtn' onclick="saveDelWormType()" value="确定">
  343. <input type="button" id='cancelBtn' onclick="goBackAddDetial()" value="取消">
  344. </div>
  345. </form>
  346. </div>
  347. </div>
  348. <!-- 查看描述 -->
  349. <div id="lookDescribe" class="white-popup mfp-hide">
  350. <h1>虫害详情</h1>
  351. <hr>
  352. <form action="">
  353. <input type="hidden" value="" id="imgPath_dteial">
  354. <table id="wormDetails">
  355. <tr>
  356. <th>害虫名称</th>
  357. <th>数量</th>
  358. <th>作物种类</th>
  359. <th>虫害阶段</th>
  360. <th>操作</th>
  361. </tr>
  362. <!-- <tr>
  363. <td class="option">大蛾子</td>
  364. <td class="option">12</td>
  365. <td class="option">花生地</td>
  366. <td class="option">大</td>
  367. <td>
  368. <button type="button" class="btn editBtn btn-primary" onclick="edit($(this))">编辑</button>
  369. <button type="button" class="btn saveBtn btn-success" onclick="save($(this))">保存</button>
  370. <button type="button" class="btn delBtn btn-danger">删除</button>
  371. </td>
  372. </tr> -->
  373. </table>
  374. </form>
  375. </div>
  376. <!-- 添加病虫种类 -->
  377. <!-- <div id="addwormType" class="white-popup mfp-hide">
  378. <h1>害虫种类</h1>
  379. <form action="" class="">
  380. <div class="pupopBox clearfix">
  381. <div class="fl pupopTitle">病虫名称:</div>
  382. <div class="fl pupopBody">
  383. <input type="text" value="" name="wormTypeSelect">
  384. </div>
  385. </div>
  386. <div class="btnParent">
  387. <input type="button" id='saveBtn' onclick="saveWormType()" value="保存">
  388. <input type="button" id='cancelBtn' onclick="closePopWin($(this))" value="取消">
  389. </div>
  390. </form>
  391. </div> -->
  392. </div>
  393. <script src="{% static '/lib/js/jquery-2.1.4.min.js' %}"></script>
  394. <script src="{% static '/lib/layui/layui.all.js' %}"></script>
  395. <script type="text/javascript">
  396. $.ajaxSetup({
  397. data: { csrfmiddlewaretoken: '{{ csrf_token }}' },
  398. });
  399. </script>
  400. <script src="{% static '/js/reportmanage/ybq_image.js' %}?versions=0.5.0"></script>
  401. <script>
  402. //点击修改名称,跳出弹框并显示所选设备的设备名称;
  403. // function addwormType(obj) {
  404. // layui.use('layer', function () { //独立版的layer无需执行这一句
  405. // var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
  406. // layer.prompt({ title: '添加病虫种类', area: 400 }, function (val, index) {
  407. // layer.close(index);
  408. // // ChangeNameSub(deviceId, oldDevicename, val);
  409. // });
  410. // });
  411. // }
  412. // 查看详情 编辑
  413. var initial = [];
  414. function edit(obj) {
  415. if ($('#wormDetails .saveBtn.current').length == 1) {
  416. layer.msg('正在编辑中');
  417. } else {
  418. initial = [];
  419. obj.hide().next().show();
  420. var parent = obj.parents('tr');
  421. var option = parent.find('.option');
  422. option.each(function () {
  423. var txt = $(this).html();
  424. initial.push(txt);
  425. var html = '<input type="text" value="' + txt + '">';
  426. $(this).html(html);
  427. })
  428. }
  429. $('#wormDetails .saveBtn').removeClass('current');
  430. obj.next().addClass('current');
  431. console.log('旧的', initial)
  432. }
  433. //查看详情 保存
  434. function save(obj) {
  435. obj.hide().prev().show();
  436. var parent = obj.parents('tr');
  437. var option = parent.find('.option');
  438. var wormName = parent.find('.optionName').html();
  439. var dataarr = [];
  440. var addr = $('#imgPath').val();
  441. option.each(function () {
  442. var txt = $(this).find('input').val();
  443. // var html = txt;
  444. dataarr[$(this).index()] = txt
  445. // $(this).html(html);
  446. })
  447. var data = {
  448. 'pest_name': wormName,
  449. 'pest_num': dataarr[1],
  450. 'crop_name': dataarr[2],
  451. 'pest_case': dataarr[3]
  452. }
  453. $('#wormDetails .saveBtn').removeClass('current');
  454. console.log(data);
  455. var addr = $('#imgPath_dteial').val();
  456. $.ajax({
  457. url: 'cbd_describe_img',
  458. type: 'post',
  459. data: { req: 'change_save', addr: addr, describe: JSON.stringify(data) },
  460. success: function (data) {
  461. if (data == 0) {
  462. //成功
  463. option.each(function () {
  464. var txt = $(this).find('input').val();
  465. var html = txt;
  466. // dataarr[$(this).index()] = txt
  467. $(this).html(html);
  468. })
  469. } else {
  470. //失败
  471. option.each(function () {
  472. var txt = $(this).find('input').val();
  473. var html = txt;
  474. // dataarr[$(this).index()] = txt
  475. $(this).html(initial[$(this).index() - 1]);
  476. })
  477. layer.msg('编辑失败');
  478. }
  479. }
  480. })
  481. }
  482. // 删除
  483. function delItemDetial(obj) {
  484. var parent = obj.parents('tr');
  485. var wormName = parent.find('.optionName').html();
  486. var data = {'pest_name': wormName};
  487. var addr = $('#imgPath_dteial').val();
  488. $.ajax({
  489. url: 'cbd_describe_img',
  490. type: 'post',
  491. data: { req:'del_desc',addr:addr,describe: JSON.stringify(data) },
  492. success: function (data) {
  493. if (data == 0) {
  494. //成功
  495. parent.remove();
  496. if($('#wormDetails tr').length < 2){
  497. var html = '<tr><td class="nullData" colspan="5">暂无数据</td></tr>'
  498. $("#wormDetails tr:not(:first)").remove();
  499. $('#wormDetails').append(html);
  500. }
  501. } else {
  502. //失败
  503. layer.msg('删除失败');
  504. }
  505. }
  506. })
  507. }
  508. function saveWormType() {
  509. var wormTypeSelect = $('#addwormType').find('input[name="wormTypeSelect"]').val();
  510. if (wormTypeSelect) {
  511. $.ajax({
  512. url: 'cbd_describe_img',
  513. type: 'get',
  514. data: { req: "add_pest", pest: wormTypeSelect },
  515. success: function (data) {
  516. if (data == 2) {
  517. layer.msg('创建名称失败');
  518. } else if (data == 1) {
  519. layer.msg('名称已存在');
  520. } else {
  521. layer.msg('创建名称成功');
  522. setTimeout(function () {
  523. //模拟数据
  524. var msg = $.parseJSON(data);
  525. // var da = [{ "pest_name": "\u641c\u7d22" }, { "pest_name": "\u5927\u86fe\u5b50" }, { "pest_name": "\u5927\u86fe\u5b50" }, { "pest_name": "\u5927\u86fe\u5b50" }, { "pest_name": "\u5927\u86fe\u5b50" }];
  526. $('#pupopForm select[name="wormName"]').empty();
  527. for (var i = 0; i < msg.length; i++) {
  528. var html = "<option value='" + msg[i].pest_name + "'>" + msg[i].pest_name + "</option>"
  529. $('#pupopForm select[name="wormName"]').append(html);
  530. }
  531. goBackAddDetial();
  532. }, 500)
  533. }
  534. }
  535. })
  536. } else {
  537. layer.msg('请填写害虫名称');
  538. }
  539. }
  540. function saveDelWormType() {
  541. var nameData = [];
  542. $("#delwormType input[type='checkbox']:checked").each(function () {
  543. nameData.push($(this).val());
  544. })
  545. if (nameData.length) {
  546. $.ajax({
  547. url: 'cbd_describe_img',
  548. type: 'get',
  549. data: { req: "del_pest", pest: JSON.stringify(nameData) },
  550. success: function (data) {
  551. var msg = $.parseJSON(data);
  552. $('#pupopForm select[name="wormName"]').empty();
  553. for (var i = 0; i < msg.length; i++) {
  554. var html = "<option value='" + msg[i].pest_name + "'>" + msg[i].pest_name + "</option>"
  555. $('#pupopForm select[name="wormName"]').append(html);
  556. };
  557. goBackAddDetial()
  558. }
  559. })
  560. } else {
  561. layer.msg('请至少选择一项');
  562. }
  563. }
  564. //添加名称显示框
  565. function addNameBox() {
  566. $('#addwormType').show();
  567. $('#addwormType').prev().hide();
  568. $('#addwormType').next().hide();
  569. }
  570. function delNameBox() {
  571. $('#addwormType').hide();
  572. $('#addwormType').prev().hide();
  573. $('#addwormType').next().show();
  574. var newPestName = [];
  575. $('#pupopForm option').each(function () {
  576. newPestName.push($(this).html());
  577. })
  578. $('#delwormType .pupopBody').empty();
  579. for (var i = 0; i < newPestName.length; i++) {
  580. var pestName = '<label class="my_protocol">' +
  581. '<input class="input_agreement_protocol" value="' + newPestName[i] + '" type="checkbox">' +
  582. '<span></span>' + newPestName[i] + '</label>';
  583. $('#delwormType .pupopBody').append(pestName);
  584. }
  585. }
  586. //返回添加详情
  587. function goBackAddDetial() {
  588. $('#addwormType').hide();
  589. $('#addwormType').next().hide();
  590. $('#addwormType').prev().show();
  591. $('#addwormType').find('form')[0].reset();
  592. $('#delwormType').find('form')[0].reset();
  593. if ($('#pupopForm option').length >= 8) {
  594. $('#addNameBtn').hide();
  595. } else {
  596. $('#addNameBtn').show();
  597. }
  598. if ($('#pupopForm option').length <= 0) {
  599. $('#delNameBtn').hide();
  600. } else {
  601. $('#delNameBtn').show();
  602. }
  603. }
  604. </script>
  605. </body>
  606. </html>
  607. {% endblock headcss %}