update.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. {% extends "../theme.html" %}
  2. {% block content %}
  3. <div class="pannel">
  4. <h2>更新溯源批次</h2>
  5. <form class="formset" action="/origin/update" method="post" autocomplete="off" target="f1">
  6. {% module xsrf_form_html() %}
  7. <input type="hidden" name="function" id="function" value="msg"/>
  8. <input type="hidden" name="url" id="url" value="/origin"/>
  9. <iframe id="f1" name="f1" style="display:none;"></iframe>
  10. <input type="hidden" name="id" id="id" value="{% if 'info' in data and data['info'] and 'id' in data['info'] and data['info']['id'] > 0 %}{{data['info']['id']}}{% end %}" />
  11. <div class="form-group"><span>批次名称</span>
  12. <div class="formbox">
  13. <input type="text" name="update_name" id="update_name" value="{% if 'info' in data and data['info'] and 'name' in data['info'] and data['info']['name'] %}{{data['info']['name']}}{% end %}" placeholder="批次名称" />
  14. </div>
  15. </div>
  16. <div class="form-group">
  17. <span>选择产品</span>
  18. <div class="formbox">
  19. <select name="update_product_id" id="update_product_id">
  20. {% for v in data['product'] %}
  21. <option value="{{v['id']}}" {% if 'info' in data and data['info'] and 'product_id' in data['info'] and data['info']['product_id'] == v['id'] %}selected{% end %}>{{v['name']}}</option>
  22. {% end %}
  23. </select>
  24. </div>
  25. </div>
  26. <div class="form-group">
  27. <span>选择地块</span>
  28. <div class="formbox">
  29. <select name="update_land_id" id="update_land_id" >
  30. {% for v in data['land'] %}
  31. <option value="{{v['id']}}" {% if 'info' in data and data['info'] and 'land_id' in data['info'] and data['info']['land_id'] == v['id'] %}selected{% end %}>{{v['name']}}</option>
  32. {% end %}
  33. </select>
  34. </div>
  35. </div>
  36. <div class="form-group">
  37. <span>选择设备</span>
  38. <div class="formbox ">
  39. {%set span = True %}
  40. {%include '../device/alert/select.html'%}
  41. </div>
  42. </div>
  43. <div class="form-group">
  44. <span>选择摄像头</span>
  45. <div class="formbox">
  46. <select name="update_device_camera_id" id="update_device_camera_id" >
  47. {% for v in data['camera'] %}
  48. <option value="{{v['id']}}" {% if 'info' in data and data['info'] and 'device_camera_id' in data['info'] and data['info']['device_camera_id'] == v['id'] %}selected{% end %}>{{v['name']}}</option>
  49. {% end %}
  50. </select>
  51. </div>
  52. </div>
  53. <div class="form-group"><span>生长周期</span>
  54. <div class="formbox">
  55. <input type="text" class="half" name="update_zzdate" id="update_zzdate" readonly value="{% if 'info' in data and data['info'] and 'zzdate' in data['info'] and data['info']['zzdate'] %}{{data['info']['zzdate']}}{% end %}" placeholder="开始时间" />~<input type="text" class="half" name="update_csdate" id="update_csdate" readonly value="{% if 'info' in data and data['info'] and 'csdate' in data['info'] and data['info']['csdate'] %}{{data['info']['csdate']}}{% end %}" placeholder="结束时间" />
  56. </div>
  57. </div>
  58. <div class="form-group">
  59. <span>生长阶段</span>
  60. <div class="formbox step-cont">
  61. <div id="group">
  62. </div>
  63. <div class="step-group">
  64. <a href="javascript:;" onclick="addGroup()" class="btn">添加阶段</a>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="form-group"><span>本批产量</span>
  69. <div class="formbox">
  70. <input type="text" name="update_amount" id="update_amount" value="{% if 'info' in data and data['info'] and 'amount' in data['info'] and data['info']['amount'] %}{{data['info']['amount']}}{% end %}" placeholder="如:6000公斤" />
  71. </div>
  72. </div>
  73. <div class="form-group">
  74. <input type="submit" name="" class="button big primary" value="确认">
  75. </div>
  76. </form>
  77. </div>
  78. <div id="grep-template" style="display:none;">
  79. <div class="step-group">
  80. <input type="hidden" class="half id" name="update_growth_id" />
  81. <input type="text" class="half name" name="update_growth_name" placeholder="阶段名" />
  82. <input type="text" class="half date" name="update_growth_date" placeholder="时间"/>
  83. <img src="" class="show_pic" width="66" style="display:none;"/>
  84. <a href="#" class="button">
  85. + 图像
  86. <input type="file" class="half pic" name="file" /><input type="hidden" class="pic_value" name="update_growth_pic" value=""/>
  87. </a>
  88. <a href="javascript:;" onclick="delGroup($(this))" class="del">删除</a>
  89. </div>
  90. </div>
  91. {% end %}
  92. {% block script %}
  93. <script type="text/javascript" src="{{static_url('pc/lib/laydate/laydate.js')}}"></script>
  94. <script type="text/javascript" src="{{static_url('pc/lib/layui/layui.js')}}"></script>
  95. <script type="text/javascript">
  96. //Farm.Upload('#pic','#master_pic');
  97. layui.use('laydate', function() {
  98. var laydate = layui.laydate;
  99. var dateTheme = '#247ed0';
  100. laydate.render({
  101. elem: '#update_zzdate'
  102. ,theme: dateTheme
  103. ,type: 'date'
  104. });
  105. laydate.render({
  106. elem: '#update_csdate'
  107. ,theme: dateTheme
  108. ,type: 'date'
  109. });
  110. });
  111. function addGroup(name, date, pic) {
  112. var e = $("#group");
  113. var html = $("#grep-template").html();
  114. var l = e.find('.date').length;
  115. var name_id = 'name_' + l;
  116. var date_id = 'date_' + l;
  117. var pic_id = 'pic_' + l;
  118. var show_pic_id = 'upload_'+pic_id+'_show';
  119. var pic_value_id = 'update_'+pic_id;
  120. e.append(html);
  121. e.find('.name').eq(l).attr('id', name_id);
  122. e.find('.date').eq(l).attr('id', date_id);
  123. e.find('.pic').eq(l).attr('id', pic_id);
  124. e.find('.show_pic').eq(l).attr('id', show_pic_id);
  125. e.find('.pic_value').eq(l).attr('id', pic_value_id);
  126. var dateTheme = '#247ed0';
  127. laydate.render({
  128. elem: '#' + date_id
  129. ,theme: dateTheme
  130. ,type: 'date'
  131. });
  132. Farm.Upload('#' + pic_id);
  133. if (name) {
  134. $("#" + name_id).val(name);
  135. }
  136. if (date) {
  137. $("#" + date_id).val(date);
  138. }
  139. if (pic) {
  140. $("#" + show_pic_id).attr('src',pic).show();
  141. $("#" + pic_value_id).val(pic);
  142. }
  143. }
  144. {% for v in data['growth'] %}
  145. addGroup('{{v['name']}}','{{v['date']}}','{{v['pic']}}');
  146. {% end %}
  147. function delGroup(obj) {
  148. var e = $("#group");
  149. obj.parent().remove();
  150. }
  151. </script>
  152. {% end %}