image copy.html 23 KB

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