image.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  1. {% load staticfiles %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8" />
  6. <link href="{% static '/lib/bootstrap-3.3.7/css/bootstrap.css' %}" rel="stylesheet">
  7. <link rel="stylesheet" href="{% static '/lib/font-awesome/4.5.0/css/font-awesome.css' %}">
  8. <link rel="stylesheet" href="{% static '/lib/css/ace.min.css' %}" />
  9. <link rel="stylesheet" href="{% static '/lib/css/ace-skins.min.css' %}">
  10. <link rel="stylesheet" href="{% static '/lib/css/ace-rtl.min.css' %}">
  11. <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
  12. <link rel="stylesheet" href="{% static '/css/loading.css' %}?versions=0.5.0" />
  13. <!-- <link href="{% static '/lib/css/magnific-popup.css' %}" rel="stylesheet" type="text/css" media="all" /> -->
  14. <link rel="stylesheet" href="{% static '/lib/css/viewer.css' %}">
  15. <link rel="stylesheet" href="{% static '/css/loading.css' %}?versions=0.5.0" />
  16. <style>
  17. body {
  18. /* background: #fff; */
  19. background-color: #fff;
  20. overflow: hidden;
  21. }
  22. .clearfix:before,
  23. .clearfix:after {
  24. display: table;
  25. line-height: 0;
  26. content: ""
  27. }
  28. .clearfix:after {
  29. clear: both
  30. }
  31. .fl {
  32. float: left;
  33. }
  34. .fr {
  35. float: right;
  36. }
  37. .mfp-bottom-bar {
  38. color: #fff;
  39. }
  40. a {
  41. text-decoration: none !important;
  42. }
  43. /* 图片列表 */
  44. #imgList{
  45. display: flex;
  46. flex-wrap: wrap;
  47. }
  48. .imgParent{
  49. position: relative;
  50. width: 400px;
  51. text-align: center;
  52. margin-top: 20px;
  53. }
  54. .popupA{
  55. width: 300px;
  56. margin: 0 auto;
  57. }
  58. .imgParent:hover span {
  59. display: block;
  60. }
  61. .imgParent .delBtn {
  62. display: none;
  63. position: absolute;
  64. top: 10px;
  65. right: 58px;
  66. cursor: pointer;
  67. background: url(../static/img/delIcon.png);
  68. width: 25px;
  69. height: 25px;
  70. background-size: cover;
  71. }
  72. .popupA img {
  73. width: 300px;
  74. height: 300px;
  75. cursor: pointer;
  76. }
  77. .imgParent a,
  78. .popupA p {
  79. color: #08c;
  80. padding: 10px;
  81. }
  82. /* 配置 */
  83. #lookDescribe {
  84. max-width: 700px;
  85. }
  86. .white-popup {
  87. position: relative;
  88. background: #FFF;
  89. padding: 20px;
  90. width: auto;
  91. /* margin: 20px auto; */
  92. }
  93. .white-popup h1 {
  94. font-size: 20px;
  95. /* margin: 10px 0; */
  96. color: #006dcc;
  97. line-height: 15px;
  98. }
  99. .pupopTitle {
  100. width: 140px;
  101. text-align: right;
  102. vertical-align: middle;
  103. /* margin-top: 7px; */
  104. line-height: 30px;
  105. }
  106. .pupopBody input,
  107. .pupopBody select {
  108. padding: 4px 6px;
  109. margin-bottom: 10px;
  110. font-size: 14px;
  111. line-height: 20px;
  112. color: #4a4a4a;
  113. background: #fff;
  114. border: 1px solid #ccc;
  115. vertical-align: middle;
  116. width: 200px;
  117. }
  118. .pupopBody select,
  119. .pupopBody input {
  120. height: 30px;
  121. width: 215px;
  122. /* line-height: 30px; */
  123. cursor: pointer;
  124. border: 1px solid #ccc;
  125. }
  126. .btnParent {
  127. text-align: center;
  128. }
  129. .btnParent input {
  130. color: #fff;
  131. text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  132. background-color: #006dcc;
  133. width: 80px;
  134. height: 30px;
  135. border-radius: 3px;
  136. border: none;
  137. cursor: pointer;
  138. margin: 5px 17px;
  139. }
  140. .btnParent input:hover {
  141. color: #fff;
  142. background-color: #04c;
  143. }
  144. .nullData {
  145. width: 100%;
  146. height: 500px;
  147. background: #ddd;
  148. text-align: center;
  149. line-height: 500px;
  150. font-size: 20px;
  151. border: 1px solid #ddd;
  152. }
  153. #wormDetails {
  154. width: 100%;
  155. text-align: center;
  156. line-height: 30px;
  157. }
  158. #wormDetails tr {
  159. border-bottom: 1px solid #e6e6e6;
  160. /* line-height: 40px; */
  161. }
  162. #wormDetails input {
  163. width: 80%;
  164. text-align: center;
  165. }
  166. .saveBtn {
  167. display: none;
  168. }
  169. #addwormType,
  170. #delwormType {
  171. display: none;
  172. }
  173. #delwormType .pupopBody {
  174. width: 340px;
  175. font-size: 0;
  176. }
  177. #addwormType h2,
  178. #delwormType h2 {
  179. font-size: 16px;
  180. text-indent: 30px;
  181. color: #006dcc;
  182. }
  183. .my_protocol {
  184. line-height: 30px;
  185. display: inline-block;
  186. width: 169px;
  187. overflow: hidden;
  188. white-space: nowrap;
  189. text-overflow: ellipsis;
  190. }
  191. .my_protocol .input_agreement_protocol {
  192. appearance: none;
  193. -webkit-appearance: none;
  194. outline: none;
  195. display: none;
  196. }
  197. /*未选中时*/
  198. .my_protocol .input_agreement_protocol+span {
  199. cursor: pointer;
  200. width: 16px;
  201. height: 16px;
  202. background-color: red;
  203. display: inline-block;
  204. background: url(../static/img/checkboxBj.png) no-repeat;
  205. background-position-x: 0px;
  206. background-position-y: 0px;
  207. position: relative;
  208. top: 3px;
  209. margin-right: 3px;
  210. }
  211. /*选中checkbox时,修改背景图片的位置*/
  212. .my_protocol .input_agreement_protocol:checked+span {
  213. background-position: -19px 0px
  214. }
  215. /* 图片列表批量删除复选框样式 */
  216. .imgcheckbox input[type='checkbox']+span {
  217. cursor: pointer;
  218. width: 18px;
  219. height: 18px;
  220. background-color: red;
  221. display: inline-block;
  222. background: url(/static/img/tick.png) no-repeat center;
  223. background-position: -19px 0px;
  224. position: relative;
  225. top: 3px;
  226. border: 1px solid #bbb;
  227. }
  228. .imgcheckbox input[type='checkbox']:checked+span {
  229. background-position-x: 3px;
  230. background-position-y: 3px;
  231. }
  232. .imgcheckbox input {
  233. display: none;
  234. }
  235. .imgcheckbox {
  236. display: none;
  237. position: absolute;
  238. right: 19px;
  239. top: 0px;
  240. }
  241. .searchCover {
  242. margin: 20px 0;
  243. }
  244. .delbox {
  245. text-align: right;
  246. }
  247. .canceldelimgBtn {
  248. display: none;
  249. }
  250. /* 自动识别虫害 */
  251. /* .wormImg{
  252. width: 150px;
  253. float: left;
  254. margin-top: 20px;
  255. margin-right: 10px;
  256. }
  257. .wormIcon{
  258. float: left;
  259. margin-top: -5px;
  260. margin-right: 10px;
  261. font-size: 26px;
  262. color: #f1d300;
  263. /* color: #bd0606;
  264. }
  265. .wormName{
  266. text-align: center;
  267. line-height: 30px !important;
  268. }
  269. .synopsis{
  270. line-height: 23px;
  271. min-height: 100px;
  272. } */
  273. /* 自动识别2 */
  274. .wormImgTag>img {
  275. width: 100%;
  276. height: 680px;
  277. }
  278. .wormResult {
  279. /* margin-left: 140px;
  280. width: 75%;*/
  281. line-height: 28px;
  282. width: 520px;
  283. }
  284. .wormResult>span {
  285. width: 50%;
  286. display: inline-block;
  287. }
  288. .wormResult>span i {
  289. font-style: normal;
  290. color: #cf0000;
  291. font-weight: 600;
  292. }
  293. .wormResult>span i:hover {
  294. color: #006dcc;
  295. }
  296. .clear {
  297. clear: both;
  298. }
  299. .wormIcon {
  300. float: left;
  301. margin-top: -5px;
  302. margin-right: 10px;
  303. font-size: 26px;
  304. color: #f1d300;
  305. }
  306. .resultTitle {
  307. font-size: 16px;
  308. margin: 5px 0;
  309. border-left: 4px solid #006dcc;
  310. padding-left: 6px;
  311. font-weight: 600;
  312. }
  313. /* 顶部位置 */
  314. .page-header>h1,
  315. .searchCover {
  316. width: 48%;
  317. display: inline-block;
  318. }
  319. /* 模拟查看数据 */
  320. .imgParent .simulation {
  321. padding: 0;
  322. }
  323. .simulation {
  324. display: none;
  325. }
  326. .resultLookGitImg {
  327. float: right;
  328. margin-bottom: 10px;
  329. margin-left: 45px;
  330. }
  331. #bindSim{
  332. display: none;
  333. }
  334. #bindSim>div {
  335. text-align: center;
  336. }
  337. #bindSim>.hint {
  338. line-height: 100px;
  339. font-size: 16px;
  340. color: #333;
  341. }
  342. .layui-layer {
  343. border-radius: 10px;
  344. overflow: hidden;
  345. }
  346. #failure{
  347. display: none;
  348. text-align: center;
  349. }
  350. #failure >div{
  351. margin: 15px;
  352. }
  353. #wormDetails th{
  354. text-align: center;
  355. }
  356. #test-popup,#lookDescribe,#autoDiscern{
  357. display: none;
  358. }
  359. .layui-layer-skin .layui-layer-padding{
  360. padding: 50px;
  361. }
  362. .layui-layer-skin .layui-layer-content .layui-layer-ico{
  363. top: 47px;
  364. }
  365. #rainControl{
  366. display: none;
  367. }
  368. #rainControl>div {
  369. text-align: center;
  370. }
  371. #rainControl>.hint {
  372. line-height: 100px;
  373. font-size: 16px;
  374. color: #333;
  375. }
  376. #rainControl>.hint {
  377. line-height: 100px;
  378. font-size: 16px;
  379. color: #333;
  380. }
  381. #hide {
  382. display: none;
  383. }
  384. .rainControltxt {
  385. color: red;
  386. font-size: 20px;
  387. font-weight: 550;
  388. }
  389. .wormBox {
  390. display: flex;
  391. }
  392. .dataListA {
  393. margin: 0 0 0 35px;
  394. width: 395px;
  395. }
  396. .dataListB {
  397. width: 80%;
  398. }
  399. .dataNums {
  400. width: 120px !important;
  401. }
  402. .layui-layer-page .layui-layer-content {
  403. overflow: hidden;
  404. }
  405. </style>
  406. </head>
  407. <body>
  408. <div class="content">
  409. <input type="hidden" name="" value="{{disc}}" id="discern">
  410. <div class="page-header">
  411. <span class="headerPlace" onclick="goback()">
  412. <img src="{% static '/img/gobackIcon.png' %}" alt="">返回
  413. </span>
  414. <!-- 操作 -->
  415. <div class="delbox" style="float: right;">
  416. <button type="button" onclick="popupFrame('ctrl','takephoto','')" class="btn btn-sm btn-warning">拍照</button>
  417. <button type="button" onclick="reload()" class="btn btn-sm btn-success">刷新</button>
  418. {% if role == "superuser" or role == "staff" %}
  419. <button type="button" onclick="delimgAll(this)" class="btn btn-sm btn-primary batchesBtn">批量删除</button>
  420. <!-- <button type="button" onclick="delimgAll(this)" class="btn btn-sm btn-primary batchesBtn">批量删除</button> -->
  421. <button type="button" onclick="canceldelimg(this)" id="canceldel" class="btn btn-sm canceldelimgBtn">取消</button>
  422. <button type="button" onclick="akeyDeleteFun()" id="akeyDelete" class="btn btn-sm">一键删除</button>
  423. {% endif %}
  424. </div>
  425. </div>
  426. <div class="timeSelect">
  427. 时间段查询:
  428. <input type="text" value="" class="fp-user" id="timSelectBox" autocomplete="off" placeholder="时间段查询" onkeypress="if (event.keyCode == 13) img_filter();"
  429. />
  430. <input type="hidden" id="begin">
  431. <input type="hidden" id="end">
  432. <button type="button" onclick="img_filter()" class="btn btn-sm btn-primary">筛选</button>
  433. </div>
  434. <input type="hidden" value="{{simid|default_if_none:""}}" id="simid">
  435. <input type="hidden" value="{{dver}}" id="dver">
  436. <!-- 图片列表 -->
  437. <div class="content-body" id="imgList">
  438. </div>
  439. <div class="fenpei-bottom">
  440. <input type="hidden" id="imei" value="{{imei}}">
  441. <input type="hidden" id="totalPage" value={{ nums }}>
  442. <div id="page" style="text-align: center;"></div>
  443. </div>
  444. <!-- 添加详情 -->
  445. <div id="test-popup" class="white-popup mfp-hide">
  446. <!-- <h1>添加详情</h1>
  447. <hr/> -->
  448. <form action="" id="pupopForm">
  449. <input type="hidden" value="" id="imgPath">
  450. <input type="hidden" value="" id="photo_time">
  451. <div class="pupopBox clearfix">
  452. <div class="fl pupopTitle">害虫名称:</div>
  453. <div class="fl pupopBody">
  454. <!-- <input type="text" value="" name="wormName"> -->
  455. <select name="wormName" id=""></select>
  456. <img src="{% static '/img/addicon.png' %}" id="addNameBtn" alt="" onclick="addNameBox()" title="添加害虫种类" width="28" style="margin-bottom: 10px;cursor: pointer;">
  457. <img src="{% static '/img/subtract.png' %}" id="delNameBtn" alt="" onclick="delNameBox()" title="删除害虫种类" width="28" style="margin-bottom: 10px;cursor: pointer;">
  458. </div>
  459. </div>
  460. <div class="pupopBox clearfix">
  461. <div class="fl pupopTitle">数量:</div>
  462. <div class="fl pupopBody">
  463. <input type="number" value="0" min="0" name="wormNum">
  464. </div>
  465. </div>
  466. <div class="pupopBox clearfix">
  467. <div class="fl pupopTitle">作物种类:</div>
  468. <div class="fl pupopBody">
  469. <input type="text" value="" placeholder="选填项" name="wormKind">
  470. </div>
  471. </div>
  472. <!-- <div class="pupopBox clearfix">
  473. <div class="fl pupopTitle">雌雄:</div>
  474. <div class="fl pupopBody">
  475. <select name="wormSex" id="">
  476. <option value="0">雌</option>
  477. <option value="1">雄</option>
  478. </select>
  479. </div>
  480. </div> -->
  481. <div class="pupopBox clearfix">
  482. <div class="fl pupopTitle">虫害阶段:</div>
  483. <div class="fl pupopBody">
  484. <input type="text" value="" placeholder="选填项" name="wormTime">
  485. </div>
  486. </div>
  487. <div class="btnParent">
  488. <input type="button" id='saveBtn' onclick="savePopWin()" value="保存">
  489. <input type="button" id='cancelBtn' onclick="closePopWin($(this))" value="取消">
  490. </div>
  491. </form>
  492. <!-- 添加害虫种类 -->
  493. <div id="addwormType">
  494. <h2>添加害虫种类</h2>
  495. <form action="" class="">
  496. <div class="pupopBox clearfix">
  497. <div class="fl pupopTitle">害虫名称:</div>
  498. <div class="fl pupopBody">
  499. <input type="text" maxlength="20" value="" name="wormTypeSelect">
  500. <!-- <img src="{% static '/img/addicon.png' %}" alt="" onclick="goBackAddDetial()" title="返回添加" width="28"> -->
  501. </div>
  502. </div>
  503. <div class="btnParent">
  504. <input type="button" id='saveBtn' onclick="saveWormType()" value="保存">
  505. <input type="button" id='cancelBtn' onclick="goBackAddDetial()" value="取消">
  506. </div>
  507. </form>
  508. </div>
  509. <!-- 删除害虫种类 -->
  510. <div id="delwormType">
  511. <h2>删除害虫种类</h2>
  512. <form action="" class="">
  513. <div class="pupopBox clearfix">
  514. <div class="fl pupopTitle">害虫名称:</div>
  515. <div class="fr pupopBody"></div>
  516. </div>
  517. <div class="btnParent">
  518. <input type="button" id='saveBtn' onclick="saveDelWormType()" value="确定">
  519. <input type="button" id='cancelBtn' onclick="goBackAddDetial()" value="取消">
  520. </div>
  521. </form>
  522. </div>
  523. </div>
  524. <!-- 查看描述 -->
  525. <div id="lookDescribe" class="white-popup mfp-hide">
  526. <!-- <h1>虫害详情</h1>
  527. <br /> -->
  528. <form action="">
  529. <input type="hidden" value="" id="imgPath_dteial">
  530. <table id="wormDetails" class="table table-striped table-hover">
  531. <tr>
  532. <th>害虫名称</th>
  533. <th>数量</th>
  534. <th>作物种类</th>
  535. <th>虫害阶段</th>
  536. <th style="width:110px">操作</th>
  537. </tr>
  538. <!-- <tr>
  539. <td class="option">大蛾子</td>
  540. <td class="option">12</td>
  541. <td class="option">花生地</td>
  542. <td class="option">大</td>
  543. <td>
  544. <button type="button" class="btn editBtn btn-primary" onclick="edit($(this))">编辑</button>
  545. <button type="button" class="btn saveBtn btn-success" onclick="save($(this))">保存</button>
  546. <button type="button" class="btn delBtn btn-danger">删除</button>
  547. </td>
  548. </tr> -->
  549. </table>
  550. </form>
  551. </div>
  552. <!-- 添加病虫种类 -->
  553. <!-- <div id="addwormType" class="white-popup mfp-hide">
  554. <h1>害虫种类</h1>
  555. <form action="" class="">
  556. <div class="pupopBox clearfix">
  557. <div class="fl pupopTitle">病虫名称:</div>
  558. <div class="fl pupopBody">
  559. <input type="text" value="" name="wormTypeSelect">
  560. </div>
  561. </div>
  562. <div class="btnParent">
  563. <input type="button" id='saveBtn' onclick="saveWormType()" value="保存">
  564. <input type="button" id='cancelBtn' onclick="closePopWin($(this))" value="取消">
  565. </div>
  566. </form>
  567. </div> -->
  568. <!-- 自动识别 -->
  569. <div id="autoDiscern" class="white-popup mfp-hide">
  570. <!-- <h1>害虫计数</h1>
  571. <hr> -->
  572. <input type="hidden" value="" id="currImgPath">
  573. <div class="wormBox">
  574. </div>
  575. </div>
  576. <!-- 失败识别 -->
  577. <div id="failure">
  578. <div>
  579. <img src="{% static 'img/failureIcon.png'%}" alt="">
  580. </div>
  581. <p>未能识别此昆虫,努力开发中</p>
  582. </div>
  583. <!-- 版本5HK的加上SIM卡绑定提示 -->
  584. <div id="bindSim">
  585. <div class="hint">此设备还未绑定SIM卡,请先绑定SIM卡。</div>
  586. <div>
  587. <button class="layui-btn layui-btn-radius layui-btn-normal" onclick="binding()">立即绑定</button>
  588. <button class="layui-btn layui-btn-radius layui-btn-primary" onclick="closeSim()">稍后再来</button>
  589. </div>
  590. </div>
  591. <!-- loading -->
  592. <div id="loadingParent">
  593. <div id="loadCenter">
  594. <div class="skype-loader">
  595. <div class="dot">
  596. <div class="first"></div>
  597. </div>
  598. <div class="dot"></div>
  599. <div class="dot"></div>
  600. <div class="dot"></div>
  601. </div>
  602. Logging in...
  603. </div>
  604. </div>
  605. {% if rain == "1" %}
  606. <div id="rainControl">
  607. <div id="hide">111</div>
  608. <div class="hint">该设备近日触发<span class="rainControltxt">雨控</span>(雨控保护状态下设备<span class="rainControltxt">不拍照</span>)</div>
  609. <div>
  610. <button class="layui-btn layui-btn-radius layui-btn-normal" onclick="rainControl()">确定</button>
  611. </div>
  612. </div>
  613. {% else %}
  614. <div id="hide">000</div>
  615. {% endif %}
  616. <input type="hidden" name="" value="{{rain}}" id="rain">
  617. </div>
  618. <script src="{% static '/lib/js/jquery-2.1.4.min.js' %}"></script>
  619. <script src="{% static '/lib/layui/layui.all.js' %}"></script>
  620. <script src="{% static '/lib/js/viewer.js' %}"></script>
  621. <script type="text/javascript">
  622. $.ajaxSetup({
  623. data: { csrfmiddlewaretoken: '{{ csrf_token }}' },
  624. });
  625. </script>
  626. <script src="{% static '/js/reportmanage/cbd_image.js' %}?versions=0.5.0"></script>
  627. <script>
  628. console.log($('#dver').val())
  629. if ($('#dver').val().indexOf('HK') != -1) {
  630. if($('#simid').val() == ''){
  631. layui.use('layer', function () {
  632. var layer = layui.layer;
  633. layer.open({
  634. type: 1,
  635. title: '提示',
  636. area: ['400px', '200px'],
  637. content: $('#bindSim')
  638. });
  639. });
  640. }
  641. }
  642. function binding() {
  643. var sidebar = $('#sidebar', parent.document);
  644. var menuLi = sidebar.find('.nav-list.nav').children();
  645. menuLi.each(function (idx, val) {
  646. console.log($(val))
  647. $(val).removeClass('open');
  648. $(val).find('ul').removeClass('nav-show').hide();
  649. $(val).removeClass('active');
  650. $(val).children('ul').children().removeClass('active');
  651. if ($(val).children('a').find('.menu-text').html() == '设备管理') {
  652. $(val).addClass('active');
  653. $(val).addClass('open');
  654. $(val).children('ul').removeClass('nav-hide').addClass('nav-show').show();
  655. $(val).children('ul').children().each(function (index, obj) {
  656. if ($(obj).find('.menu-text').html() == '虫情测报') {
  657. $(obj).addClass('active');
  658. }
  659. })
  660. }
  661. })
  662. location.href = 'equipmanage_cbd_detail?id='+$('#imei').val()
  663. }
  664. function closeSim() {
  665. layer.closeAll();
  666. }
  667. // 查看详情 编辑
  668. var initial = [];
  669. function edit(obj) {
  670. if ($('#wormDetails .saveBtn.current').length == 1) {
  671. layer.msg('正在编辑中');
  672. } else {
  673. initial = [];
  674. obj.hide().next().show();
  675. var parent = obj.parents('tr');
  676. var option = parent.find('.option');
  677. option.each(function () {
  678. var txt = $(this).html();
  679. initial.push(txt);
  680. var html = '<input type="text" value="' + txt + '">';
  681. $(this).html(html);
  682. })
  683. }
  684. $('#wormDetails .saveBtn').removeClass('current');
  685. obj.next().addClass('current');
  686. console.log('旧的', initial)
  687. }
  688. //查看详情 保存
  689. function save(obj) {
  690. obj.hide().prev().show();
  691. var parent = obj.parents('tr');
  692. var option = parent.find('.option');
  693. var wormName = parent.find('.optionName').html();
  694. var dataarr = [];
  695. var addr = $('#imgPath').val();
  696. option.each(function () {
  697. var txt = $(this).find('input').val();
  698. // var html = txt;
  699. dataarr[$(this).index()] = txt
  700. // $(this).html(html);
  701. })
  702. var data = {
  703. 'pest_name': wormName,
  704. 'pest_num': dataarr[1],
  705. 'crop_name': dataarr[2],
  706. 'pest_case': dataarr[3]
  707. }
  708. $('#wormDetails .saveBtn').removeClass('current');
  709. console.log(data);
  710. var addr = $('#imgPath_dteial').val();
  711. $.ajax({
  712. url: 'cbd_describe_img',
  713. type: 'post',
  714. data: { req: 'change_save', addr: addr, describe: JSON.stringify(data) },
  715. success: function (data) {
  716. if (data == 0) {
  717. //成功
  718. option.each(function () {
  719. var txt = $(this).find('input').val();
  720. var html = txt;
  721. // dataarr[$(this).index()] = txt
  722. $(this).html(html);
  723. })
  724. } else {
  725. //失败
  726. option.each(function () {
  727. var txt = $(this).find('input').val();
  728. var html = txt;
  729. // dataarr[$(this).index()] = txt
  730. $(this).html(initial[$(this).index() - 1]);
  731. })
  732. layer.msg('编辑失败');
  733. }
  734. }
  735. })
  736. }
  737. // 删除
  738. function delItemDetial(obj) {
  739. var parent = obj.parents('tr');
  740. var wormName = parent.find('.optionName').html();
  741. var data = { 'pest_name': wormName };
  742. var addr = $('#imgPath_dteial').val();
  743. $.ajax({
  744. url: 'cbd_describe_img',
  745. type: 'post',
  746. data: { req: 'del_desc', addr: addr, describe: JSON.stringify(data) },
  747. success: function (data) {
  748. if (data == 0) {
  749. //成功
  750. parent.remove();
  751. if ($('#wormDetails tr').length < 2) {
  752. var html = '<tr><td class="nullData" colspan="5">暂无数据</td></tr>'
  753. $("#wormDetails tr:not(:first)").remove();
  754. $('#wormDetails').append(html);
  755. }
  756. } else {
  757. //失败
  758. layer.msg('删除失败');
  759. }
  760. }
  761. })
  762. }
  763. function saveWormType() {
  764. var wormTypeSelect = $('#addwormType').find('input[name="wormTypeSelect"]').val();
  765. if (wormTypeSelect) {
  766. $.ajax({
  767. url: 'cbd_describe_img',
  768. type: 'get',
  769. data: { req: "add_pest", pest: wormTypeSelect },
  770. success: function (data) {
  771. if (data == 2) {
  772. layer.msg('创建名称失败');
  773. } else if (data == 1) {
  774. layer.msg('名称已存在');
  775. } else {
  776. layer.msg('创建名称成功');
  777. setTimeout(function () {
  778. //模拟数据
  779. var msg = $.parseJSON(data);
  780. // 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" }];
  781. $('#pupopForm select[name="wormName"]').empty();
  782. for (var i = 0; i < msg.length; i++) {
  783. var html = "<option value='" + msg[i].pest_name + "'>" + msg[i].pest_name + "</option>"
  784. $('#pupopForm select[name="wormName"]').append(html);
  785. }
  786. goBackAddDetial();
  787. }, 500)
  788. }
  789. }
  790. })
  791. } else {
  792. layer.msg('请填写害虫名称');
  793. }
  794. }
  795. function saveDelWormType() {
  796. var nameData = [];
  797. $("#delwormType input[type='checkbox']:checked").each(function () {
  798. nameData.push($(this).val());
  799. })
  800. if (nameData.length) {
  801. $.ajax({
  802. url: 'cbd_describe_img',
  803. type: 'get',
  804. data: { req: "del_pest", pest: JSON.stringify(nameData) },
  805. success: function (data) {
  806. var msg = $.parseJSON(data);
  807. $('#pupopForm select[name="wormName"]').empty();
  808. for (var i = 0; i < msg.length; i++) {
  809. var html = "<option value='" + msg[i].pest_name + "'>" + msg[i].pest_name + "</option>"
  810. $('#pupopForm select[name="wormName"]').append(html);
  811. };
  812. goBackAddDetial()
  813. }
  814. })
  815. } else {
  816. layer.msg('请至少选择一项');
  817. }
  818. }
  819. //添加名称显示框
  820. function addNameBox() {
  821. $('#addwormType').show();
  822. $('#addwormType').prev().hide();
  823. $('#addwormType').next().hide();
  824. }
  825. function delNameBox() {
  826. $('#addwormType').hide();
  827. $('#addwormType').prev().hide();
  828. $('#addwormType').next().show();
  829. var newPestName = [];
  830. $('#pupopForm option').each(function () {
  831. newPestName.push($(this).html());
  832. })
  833. $('#delwormType .pupopBody').empty();
  834. for (var i = 0; i < newPestName.length; i++) {
  835. var pestName = '<label class="my_protocol">' +
  836. '<input class="input_agreement_protocol" value="' + newPestName[i] + '" type="checkbox">' +
  837. '<span></span>' + newPestName[i] + '</label>';
  838. $('#delwormType .pupopBody').append(pestName);
  839. }
  840. }
  841. //返回添加详情
  842. function goBackAddDetial() {
  843. $('#addwormType').hide();
  844. $('#addwormType').next().hide();
  845. $('#addwormType').prev().show();
  846. $('#addwormType').find('form')[0].reset();
  847. $('#delwormType').find('form')[0].reset();
  848. if ($('#pupopForm option').length >= 180) {
  849. $('#addNameBtn').hide();
  850. } else {
  851. $('#addNameBtn').show();
  852. }
  853. if ($('#pupopForm option').length <= 0) {
  854. $('#delNameBtn').hide();
  855. } else {
  856. $('#delNameBtn').show();
  857. }
  858. }
  859. // 一键删除
  860. function akeyDeleteFun(){
  861. //询问框
  862. layer.confirm('确定删除全部图片?', {
  863. title:'警告信息',
  864. icon: 0,
  865. skin: 'layui-layer-skin',
  866. // area:['400px','250px'],
  867. btn: ['确定', '取消'], //按钮
  868. content: '<strong style="color:red">确定删除全部图片?<span style="font-size:18px">此操作不可逆</span></strong>'
  869. }, function (index) {
  870. var id = $('#imei').val();
  871. $.ajax({
  872. type: "post",
  873. url: 'cbd_delete_img',
  874. data: {
  875. imei: id,
  876. allpic:1
  877. },
  878. success: function (data) {
  879. if (data) {
  880. reload()
  881. } else {
  882. alert('删除失败')
  883. }
  884. }
  885. })
  886. layer.close(index);
  887. }, function () {
  888. });
  889. }
  890. // 拍照
  891. function popupFrame(cmd, type, data) {
  892. //询问框
  893. layer.confirm('确定拍照?', {
  894. icon: 3,
  895. btn: ['确定', '取消'] //按钮
  896. }, function (index) {
  897. handleFun(cmd, type, data);
  898. layer.close(index);
  899. }, function () {
  900. });
  901. }
  902. function handleFun(cmd, type, data) {
  903. var id = $('#imei').val();
  904. $.ajax({
  905. type: "post",
  906. url: 'cbd_mqtt',
  907. data: {
  908. "req": "ctrl",//控制
  909. "topicid": id,
  910. "cmd": cmd,//升级 update
  911. "type": type,
  912. "data": data
  913. },
  914. dataType: "json",
  915. beforeSend: function () {
  916. $('#loadingParent').show();
  917. },
  918. complete: function () {
  919. setTimeout(function () {
  920. $('#loadingParent').hide();
  921. }, 3000)
  922. },
  923. success: function (data) {
  924. layer.close();
  925. }
  926. })
  927. }
  928. //雨控提示
  929. function bindsheb() {
  930. layer.closeAll();
  931. }
  932. </script>
  933. </body>
  934. </html>