You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

272 lines
11 KiB

{% extends 'base.html' %}
{% block content %}
<style type="text/css">
body {
background-color: #FFF !important;
}
.myForm {
padding-top: 30px;
padding-right: 50px;
}
.layui-input {
height: 32px;
}
.layui-form-item .layui-input-inline {
float: left;
margin-right: 10px;
}
.layui-input-inline {
float: left;
width: 30%;
}
.layui-inline {
width: 45%;
float: left;
}
.layui-form-label {
/* width: 30%;margin-right: 3%; */
margin-left: 5%;
width: 100px;
}
.layui-form-item {
padding-top: 50px;
}
</style>
{% load static %}
<div class="ibox float-e-margins" style="background-color: #fff;">
<form class="form-horizontal myForm layui-form" role="form">
<input type="hidden" id="drug_id" value="{{ drug_obj.MedicamentId }}">
<div class="form-group">
<label class="layui-form-label" for="ds_host">条码编号*</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" disabled="disabled" type="text"
required="required" value="{% firstof drug_obj.BarCode '' %}" />
<input class="form-control layui-input" lay-verify="required|phone" id="RFID" name="RFID" type="hidden"
value="{% firstof drug_obj.BarCode '' %}" />
</div>
<label class="layui-form-label" for="ds_name">CAS码*</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" id="CASNumber" name="CASNumber"
required="required" type="text" value="{% firstof drug_obj.CASNumber '' %}" />
</div>
</div>
<div class="form-group">
<label class="layui-form-label" for="ds_username">药剂名称*</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" disabled="disabled" id="Name" name="Name"
required="required" type="text" value="{% firstof drug_obj.Name '' %}" />
</div>
<label class="layui-form-label" for="ds_password">英文名称*</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" id="EnglishName" name="EnglishName"
required="required" type="text" value="{% firstof drug_obj.EnglishName '' %}" />
</div>
</div>
<div class="form-group">
<label class="layui-form-label" for="ds_username">纯度*</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" disabled="disabled" id="purity" type="text"
required="required" value="{% firstof drug_obj.Purity '' %}" />
</div>
<label class="layui-form-label" for="ds_password">生产日期*</label>
<div class="layui-input-inline">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input type="text" class="form-control layui-input" lay-verify="required|phone" id="ProductionDate"
name="ProductionDate" required="required" value="{% firstof drug_obj.ProductionDate '' %}"
data-mask="9999-99-99">
</div>
</div>
</div>
<div class="form-group">
<label class="layui-form-label" for="ds_username">过期日期*</label>
<div class="layui-input-inline">
<input type="text" class="form-control layui-input" lay-verify="required|phone" id="ExpirationDate"
name="ExpirationDate" required="required" value="{% firstof drug_obj.ExpirationDate '' %}"
data-mask="9999-99-99" readonly>
</div>
<label class="layui-form-label" for="ds_password">保质期*</label>
<div class="layui-input-inline">
<div class="input-group">
<input class="form-control layui-input" lay-verify="required|phone" id="ShelfLife" name="ShelfLife"
oninput="this.value=this.value.replace(/[^0-9]+/,'');" type="number" required="required"
value="{% firstof drug_obj.ShelfLife '' %}" />
<span class="input-group-addon"></span>
</div>
</div>
</div>
<div class="form-group">
<label class="layui-form-label" for="ds_password">生产厂商</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" id="Manufacturer" name="Manufacturer"
type="text" value="{% firstof drug_obj.Manufacturer '' %}" />
</div>
<label class="layui-form-label" for="ds_username">经销商</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" id="Distributor" name="Distributor"
type="text" value="{% firstof drug_obj.Distributor '' %}" />
</div>
</div>
<div class="form-group">
<label class="layui-form-label">进价</label>
<div class="layui-input-inline">
<div class="input-group">
<input class="form-control layui-input" lay-verify="required|phone" id="Price"
oninput="this.value=this.value.replace(/[^0-9.]+/,'');" name="Price" type="number" step="0.01"
value="{% firstof drug_obj.Price '0' %}" />
<span class="input-group-addon"></span>
</div>
</div>
<label class="layui-form-label" for="ds_username">说明1</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" id="Remark1" name="Remark1" type="text"
value="{% firstof drug_obj.Remark1 '' %}" />
</div>
</div>
<div class="form-group">
<label class="layui-form-label" for="ds_password">说明2</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" id="Remark2" name="Remark2" type="text"
value="{% firstof drug_obj.Remark2 '' %}" />
</div>
<label class="layui-form-label" for="ds_username">说明3</label>
<div class="layui-input-inline">
<input class="form-control layui-input" lay-verify="required|phone" id="Remark3" name="Remark3" type="text"
value="{% firstof drug_obj.Remark3 '' %}" />
</div>
</div>
<div class="form-group">
<label class="layui-form-label" for="ds_password">是否监管</label>
<div class="layui-input-inline">
{% if drug_obj.IsSupervise == 1 %}
<input type="checkbox" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF" id="IsSuperviseSwich" checked />
{% else %}
<input type="checkbox" name="close" lay-skin="switch" lay-text="ON|OFF" id="IsSuperviseSwich" />
{% endif %}
<input type="hidden" id="IsSupervise" name="IsSupervise" value="{{ drug_obj.IsSupervise }}" />
</div>
<label class="layui-form-label" for="ds_username"></label>
</div>
<div class="hr-line-dashed"></div>
<div style="margin-left: 35%; padding-bottom: 20px;">
<button class="layui-btn" type="submit" id="saveData" style="margin-right: 50px;">保存内容</button>
<button class="layui-btn" type="button" id="closeForm" style="margin-left: 50px;">关闭</button>
</div>
</form>
</div>
<script src="{% static 'js/plugins/datapicker/bootstrap-datepicker.js' %}"></script>
<script src="{% static 'js/utils.js' %}"></script>
<script src="{% static 'js/warning.js' %}"></script>
<script type="text/javascript">
layui.use('form', function () {
var form = layui.form;
form.render(); //刷新select选择框渲染
//各种基于事件的操作,下面会有进一步介绍
});
var index = parent.layer.getFrameIndex(window.name);
$(function () {
$("#IsSuperviseSwich").change(function () {
$("#IsSupervise").val($("#IsSuperviseSwich").is(":checked") ? 1 : 0);
});
$(".myForm").submit(function () {
/* let eng = $('#EnglishName').val();
let reg = /^[a-zA-Z 0-9]+$/;
if(!reg.test(eng)){
msg('请输入英文名! ');
return false
} */
console.log("1111111111111111111111111")
var loadIndex = layer.load(2);
$.post("/drug/" + $('#drug_id').val() + "/form/", $(this).serialize(), function (obj) {
layer.close(loadIndex);
if (obj.status == 1) {
msg("保存成功", function () {
parent.layer.close(index);
});
}
else {
msg("保存失败");
}
});
return false;
});
$('#ShelfLife').blur(function () {
var ShelfLife = $('#ShelfLife').val();
var ProductionDate = $('#ProductionDate').val();
var beginDate = new Date(Date.parse(ProductionDate.replace(/-/g, '/')));
var date1 = Date.parse(ProductionDate.replace(/-/g, '/')) + Number(ShelfLife) * 24 * 60 * 60 * 1000
Date.prototype.format = function (fmt) { // author: meizz
var o = {
"M+": this.getMonth() + 1, // 月份
"d+": this.getDate(), // 日
"h+": this.getHours(), // 小时
"m+": this.getMinutes(), // 分
"s+": this.getSeconds(), // 秒
"q+": Math.floor((this.getMonth() + 3) / 3), // 季度
"S": this.getMilliseconds() // 毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
};
// 计算生产时间 和保质期的天数 得到 过期日期
commonTime = new Date(date1).format('yyyy-MM-dd');
$('#ExpirationDate').val(commonTime)
});
$('#ProductionDate').change(function () {
var ShelfLife = $('#ShelfLife').val();
var ProductionDate = $('#ProductionDate').val();
var beginDate = new Date(Date.parse(ProductionDate.replace(/-/g, '/')));
var date1 = Date.parse(ProductionDate.replace(/-/g, '/')) + Number(ShelfLife) * 24 * 60 * 60 * 1000
Date.prototype.format = function (fmt) { // author: meizz
var o = {
"M+": this.getMonth() + 1, // 月份
"d+": this.getDate(), // 日
"h+": this.getHours(), // 小时
"m+": this.getMinutes(), // 分
"s+": this.getSeconds(), // 秒
"q+": Math.floor((this.getMonth() + 3) / 3), // 季度
"S": this.getMilliseconds() // 毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
};
// 计算生产时间 和保质期的天数 得到 过期日期
commonTime = new Date(date1).format('yyyy-MM-dd');
$('#ExpirationDate').val(commonTime)
});
$("#closeForm").click(function () {
parent.layer.close(index);
});
})
</script>
{% endblock %}