123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- {% extends "../theme.html" %}
- {% block content %}
- <div class="pannel">
- <h2>更新溯源批次</h2>
- <form class="formset" action="/origin/update" method="post" autocomplete="off" target="f1">
- {% module xsrf_form_html() %}
- <input type="hidden" name="function" id="function" value="msg"/>
- <input type="hidden" name="url" id="url" value="/origin"/>
- <iframe id="f1" name="f1" style="display:none;"></iframe>
- <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 %}" />
- <div class="form-group"><span>批次名称</span>
- <div class="formbox">
- <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="批次名称" />
- </div>
- </div>
- <div class="form-group">
- <span>选择产品</span>
- <div class="formbox">
- <select name="update_product_id" id="update_product_id">
- {% for v in data['product'] %}
- <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>
- {% end %}
- </select>
- </div>
- </div>
- <div class="form-group">
- <span>选择地块</span>
- <div class="formbox">
- <select name="update_land_id" id="update_land_id" >
- {% for v in data['land'] %}
- <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>
- {% end %}
- </select>
- </div>
- </div>
- <div class="form-group">
- <span>选择设备</span>
- <div class="formbox ">
- {%set span = True %}
- {%include '../device/alert/select.html'%}
- </div>
- </div>
- <div class="form-group" style="display:none;">
- <span>选择摄像头</span>
- <div class="formbox">
- <select name="update_device_camera_id" id="update_device_camera_id" >
- {% for v in data['camera'] %}
- <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>
- {% end %}
- </select>
- </div>
- </div>
-
- <div class="form-group"><span>生长周期</span>
- <div class="formbox">
- <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="结束时间" />
- </div>
- </div>
- <div class="form-group">
- <span>生长阶段</span>
- <div class="formbox step-cont">
- <div id="group">
- </div>
- <div class="step-group">
- <a href="javascript:;" onclick="addGroup()" class="btn">添加阶段</a>
- </div>
- </div>
- </div>
- <div class="form-group"><span>本批产量</span>
- <div class="formbox">
- <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公斤" />
- </div>
- </div>
- <div class="form-group">
- <input type="submit" name="" class="button big primary" value="确认">
- </div>
- </form>
- </div>
- <div id="grep-template" style="display:none;">
- <div class="step-group">
- <input type="hidden" class="half id" name="update_growth_id" />
- <input type="text" class="half name" name="update_growth_name" placeholder="阶段名" />
- <input type="text" class="half date" name="update_growth_date" placeholder="时间"/>
- <img src="" class="show_pic" width="66" style="display:none;"/>
- <a href="#" class="button">
- + 图像
- <input type="file" class="half pic" name="file" /><input type="hidden" class="pic_value" name="update_growth_pic" value=""/>
- </a>
- <a href="javascript:;" onclick="delGroup($(this))" class="del">删除</a>
- </div>
- </div>
- {% end %}
- {% block script %}
- <script type="text/javascript" src="{{static_url('pc/lib/laydate/laydate.js')}}"></script>
- <script type="text/javascript" src="{{static_url('pc/lib/layui/layui.js')}}"></script>
- <script type="text/javascript">
- //Farm.Upload('#pic','#master_pic');
- layui.use('laydate', function() {
- var laydate = layui.laydate;
- var dateTheme = '#247ed0';
- laydate.render({
- elem: '#update_zzdate'
- ,theme: dateTheme
- ,type: 'date'
- });
- laydate.render({
- elem: '#update_csdate'
- ,theme: dateTheme
- ,type: 'date'
- });
- });
- function addGroup(name, date, pic) {
- var e = $("#group");
- var html = $("#grep-template").html();
- var l = e.find('.date').length;
- var name_id = 'name_' + l;
- var date_id = 'date_' + l;
- var pic_id = 'pic_' + l;
- var show_pic_id = 'upload_'+pic_id+'_show';
- var pic_value_id = 'update_'+pic_id;
- e.append(html);
- e.find('.name').eq(l).attr('id', name_id);
- e.find('.date').eq(l).attr('id', date_id);
- e.find('.pic').eq(l).attr('id', pic_id);
- e.find('.show_pic').eq(l).attr('id', show_pic_id);
- e.find('.pic_value').eq(l).attr('id', pic_value_id);
- var dateTheme = '#247ed0';
- laydate.render({
- elem: '#' + date_id
- ,theme: dateTheme
- ,type: 'date'
- });
- Farm.Upload('#' + pic_id);
- if (name) {
- $("#" + name_id).val(name);
- }
- if (date) {
- $("#" + date_id).val(date);
- }
- if (pic) {
- $("#" + show_pic_id).attr('src',pic).show();
- $("#" + pic_value_id).val(pic);
- }
- }
- {% for v in data['growth'] %}
- addGroup('{{v['name']}}','{{v['date']}}','{{v['pic']}}');
- {% end %}
- function delGroup(obj) {
- var e = $("#group");
- obj.parent().remove();
- }
- </script>
- {% end %}
|