|
|
@@ -0,0 +1,267 @@
|
|
|
+//@ sourceURL=yf_special_mark.js
|
|
|
+var pharmacyGroupNo;//药房编码
|
|
|
+var chargeNo;//药品表选中的行号
|
|
|
+var batchNo;//批次表选中的行号
|
|
|
+$(function () {
|
|
|
+ $(".selectpicker").selectpicker();
|
|
|
+ $("#pharmacyModal").modal("show");
|
|
|
+ $('#btn_search').on('click',function(e){
|
|
|
+ loadTbTable();
|
|
|
+ });
|
|
|
+ $('#searchText').on('blur',function(e){
|
|
|
+ loadTbTable();
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 初始化参数
|
|
|
+ */
|
|
|
+function init() {
|
|
|
+ pharmacyGroupNo = $("#pharmacyGroupNo").val();
|
|
|
+ $("#pharmacyModal").modal("hide");
|
|
|
+ initTable();
|
|
|
+ initBatch();
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 查询列表
|
|
|
+ */
|
|
|
+function initTable() {
|
|
|
+ $.jgrid.gridUnload("tb_table");
|
|
|
+ $("#tb_table").jqGrid({
|
|
|
+ datatype: 'local',
|
|
|
+ mtype: 'get',
|
|
|
+ url: '/thmz/getYpSpecialMark',
|
|
|
+ loadBeforeSend: function (jqXHR) {
|
|
|
+ jqXHR.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem("token"));
|
|
|
+ jqXHR.setRequestHeader("Accept", 'application/json');
|
|
|
+ },
|
|
|
+ styleUI: 'Bootstrap',
|
|
|
+ viewrecords: true,
|
|
|
+ autowidth: true,
|
|
|
+ rowNum: -1,//取消分页
|
|
|
+ height: screen.height*0.3,
|
|
|
+ caption: '药品信息',
|
|
|
+ shrinkToFit:false,
|
|
|
+ autoScroll: false,
|
|
|
+ cellEdit: true,
|
|
|
+ cellsubmit: "remote",
|
|
|
+ cellurl: '/thmz/modifYpSpecialMark',
|
|
|
+ colNames: ['门诊停用','住院停用','库存为零','编码','序号', '药品名', '库存量', '大规格(汇总)', '规格', '虚存2','启用虚存2', '3天用量', '7天用量', '14天用量','30天用量','厂家','药性分类'],
|
|
|
+ colModel: [
|
|
|
+ {name: 'visibleFlagMz', index: 'visibleFlagMz',align:'center',width:100,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
|
|
|
+ {name: 'visibleFlagZy', index: 'visibleFlagZy',align:'center',width:100,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
|
|
|
+ {name: 'visibleFlagStop', index: 'visibleFlagStop',align:'center',width:100,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
|
|
|
+ {name: 'chargeCode', index: 'chargeCode',align:'center',width:100},
|
|
|
+ {name: 'serial', index: 'serial',align:'center',width:100,hidden:true},
|
|
|
+ {name: 'name', index: 'name',width:180},
|
|
|
+ {name: 'stockAmount', index: 'stockAmount',align:'center',width:100},
|
|
|
+ {name: 'stockAmountLarge', index: 'stockAmountLarge',align:'center',width:100},
|
|
|
+ {name: 'specification', index: 'specification',align:'center',width:100},
|
|
|
+ {name: 'stockAmountVirtual2', index: 'stockAmountVirtual2',width:100,align:'center',editable : true,edittype:'text'
|
|
|
+ ,editrules: {edithidden:true,number:true,minValue:0}
|
|
|
+ },
|
|
|
+ {name: 'openVirtual2', index: 'openVirtual2',width:100,align:'center',formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
|
|
|
+ {name: 'threeDayDosage', index: 'threeDayDosage', formatter: 'number',align:'center',width:100},
|
|
|
+ {name: 'sevenDayDosage', index: 'sevenDayDosage', formatter: 'number',align:'center',width:100},
|
|
|
+ {name: 'fourteenDayDosage', index: 'fourteenDayDosage', formatter: 'number',align:'center',width:100},
|
|
|
+ {name: 'thirtyDayDosage', index: 'thirtyDayDosage', formatter: 'number',align:'center',width:100},
|
|
|
+ {name: 'manufactoryName', index: 'manufactoryName',width:180},
|
|
|
+ {name: 'className', index: 'className',width:100,align:'center'}
|
|
|
+ ],
|
|
|
+ jsonReader: {
|
|
|
+ root: "data", repeatitems: false
|
|
|
+ },
|
|
|
+ beforeSubmitCell:function(rowid, cellname, value, iRow, iCol){
|
|
|
+ let record = jQuery("#tb_table").getRowData(rowid);
|
|
|
+ let temp = eval('(' + '{ "'+cellname+'": "'+value+'"}' + ')');
|
|
|
+ temp.chargeCode = record.chargeCode;
|
|
|
+ temp.serial = record.serial;
|
|
|
+ temp.groupNo = pharmacyGroupNo;
|
|
|
+ return temp
|
|
|
+ },
|
|
|
+ onCellSelect: function(rowid,iCol,cellcontent,e){
|
|
|
+ let record = jQuery("#tb_table").getRowData(rowid);
|
|
|
+ loadBatch(record.chargeCode);
|
|
|
+ chargeNo = rowid;
|
|
|
+ },
|
|
|
+ loadComplete: function (res) { //加载完成(初始加载),回调函数
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.code == -1) {
|
|
|
+ errorMesage(res);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 加载药品批次表格数据
|
|
|
+ */
|
|
|
+function loadTbTable() {
|
|
|
+ $("#tb_table").jqGrid('setGridParam', {
|
|
|
+ datatype:'json',
|
|
|
+ postData: { searchText: $("#searchText").val(), groupNo: pharmacyGroupNo }
|
|
|
+ }).trigger('reloadGrid');
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 加载药品批次表格数据
|
|
|
+ * @param chargeCode
|
|
|
+ */
|
|
|
+function loadBatch(chargeCode) {
|
|
|
+ batchNo = null;
|
|
|
+ $("#tb_table_batch").jqGrid('setGridParam', {
|
|
|
+ datatype:'json',
|
|
|
+ postData: { chargeCode: chargeCode }
|
|
|
+ }).trigger('reloadGrid');
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 初始化药品批次表格
|
|
|
+ */
|
|
|
+function initBatch() {
|
|
|
+ $.jgrid.gridUnload("tb_table_batch");
|
|
|
+ $("#tb_table_batch").jqGrid({
|
|
|
+ datatype: 'local',
|
|
|
+ mtype: 'get',
|
|
|
+ url: '/thmz/getYpZdYpbh',
|
|
|
+ loadBeforeSend: function (jqXHR) {
|
|
|
+ jqXHR.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem("token"));
|
|
|
+ jqXHR.setRequestHeader("Accept", 'application/json');
|
|
|
+ },
|
|
|
+ toolbar : [ true, "top" ],
|
|
|
+ styleUI: 'Bootstrap',
|
|
|
+ viewrecords: true,
|
|
|
+ autowidth: true,
|
|
|
+ rowNum: -1,//取消分页
|
|
|
+ caption: '药品批次维护',
|
|
|
+ cellEdit: true,
|
|
|
+ sortable: true,
|
|
|
+ loadonce:true, //一次加载全部数据到客户端,由客户端进行排序。
|
|
|
+ sortname: 'fDate', //设置默认的排序列
|
|
|
+ sortorder: 'desc',
|
|
|
+ cellsubmit: "remote",
|
|
|
+ cellurl: '/thmz/modifYpZdYpbh',
|
|
|
+ editurl: '/thmz/addYpZdYpbh',
|
|
|
+ colNames: ['停用标记','药品编号','药品批号','入库时间'],
|
|
|
+ colModel: [
|
|
|
+ {name: 'usingFlag', index: 'usingFlag',align:'center',width:100,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
|
|
|
+ {name: 'chargeCode', index: 'chargeCode',align:'center',width:100},
|
|
|
+ {name: 'ypbh', index: 'ypbh',align:'center',width:100,editable : true,edittype:'text'},
|
|
|
+ {name: 'fDate', index: 'fDate',align:'center', formatter:"date", formatoptions: {srcformat:'Y-m-d H:i',newformat:'Y-m-d H:i'},sortable: true,width:100,
|
|
|
+ editable:true,
|
|
|
+ edittype:"text",editoptions: {
|
|
|
+ size: 10, maxlengh: 10,
|
|
|
+ dataInit: function(element) {
|
|
|
+ $(element).datetimepicker({language:'zh-CN',dateFormat: 'yyyy-mm-dd hh:ii'})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ jsonReader: {
|
|
|
+ root: "data", repeatitems: false
|
|
|
+ },
|
|
|
+ beforeSubmitCell:function(rowid, cellname, value, iRow, iCol){
|
|
|
+ let record = jQuery("#tb_table_batch").getRowData(rowid);
|
|
|
+ let temp = eval('(' + '{ "'+cellname+'": "'+value+'"}' + ')');
|
|
|
+ temp.chargeCode = record.chargeCode;
|
|
|
+ temp.ypbh = record.ypbh;
|
|
|
+ return temp
|
|
|
+ },
|
|
|
+ onCellSelect: function(rowid,iCol,cellcontent,e){
|
|
|
+ batchNo = rowid;
|
|
|
+ },
|
|
|
+ beforeEditCell: function(rowid,iCol,cellcontent,e){
|
|
|
+ batchNo = rowid;
|
|
|
+ },
|
|
|
+ loadComplete: function (res) { //加载完成(初始加载),回调函数
|
|
|
+ var ids = jQuery("#tb_table_batch").jqGrid("getDataIDs");
|
|
|
+ for (let i = 0; i < ids.length; i++) {
|
|
|
+ $("#tb_table_batch").jqGrid("setCell",ids[i],"ypbh",'','not-editable-cell');//列不可编辑
|
|
|
+ }
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.code == -1) {
|
|
|
+ errorMesage(res);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $("#t_tb_table_batch").append("<button class='registration-no-color-foot-button' title='新增一行' id='addBatch' style='color: #35D082;margin-left: 10px;'><i class='fa fa-plus'></i></button>");
|
|
|
+ $("#t_tb_table_batch").append("<button class='registration-no-color-foot-button' title='删除一行' id='removeBatch' style='color: red;margin-left: 10px;'><i class='fa fa-trash-o'></i></button>");
|
|
|
+ $("#t_tb_table_batch").append("<button class='registration-no-color-foot-button' title='保存新增行' id='saveBatch' style='color: green;margin-left: 10px;'><i class='fa fa-floppy-o'></i></button>");
|
|
|
+ $("#addBatch").on('click',function(e){
|
|
|
+ var ids = jQuery("#tb_table_batch").jqGrid("getDataIDs");//得到jqgrid当前行数
|
|
|
+ var rowid = Math.max.apply(Math,ids);//获得当前最大行号
|
|
|
+ let record = jQuery("#tb_table").getRowData(chargeNo);
|
|
|
+ let data= {chargeCode:record['chargeCode'],usingFlag:0,ypbh:"",fDate:new Date()};
|
|
|
+ $("#tb_table_batch").addRowData(rowid+1, data,'first');
|
|
|
+ jQuery("#tb_table_batch").jqGrid('editRow', rowid+1);
|
|
|
+ batchNo = rowid+1;
|
|
|
+ });
|
|
|
+ $("#removeBatch").on('click',function(e){
|
|
|
+ if(batchNo == null){
|
|
|
+ return errorMesageSimaple('请选择一行进行删除!');
|
|
|
+ }
|
|
|
+ let record = jQuery("#tb_table_batch").getRowData(batchNo);
|
|
|
+ if(!(record['ypbh'].indexOf("<input") != -1)){
|
|
|
+ let data= {chargeCode:record['chargeCode'],ypbh:record['ypbh']};
|
|
|
+ $.ajax({
|
|
|
+ type: "GET",
|
|
|
+ url: '/thmz/removeYpZdYpbh',
|
|
|
+ contentType: "application/json;charset=UTF-8",
|
|
|
+ dataType: "json",
|
|
|
+ headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
|
|
|
+ data: data,
|
|
|
+ success: function (res) {
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.code == 0) {
|
|
|
+ $("#tb_table_batch").jqGrid("delRowData", batchNo);
|
|
|
+ batchNo = null;
|
|
|
+ successMesage(res);
|
|
|
+ } else {
|
|
|
+ errorMesage(res);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ $("#tb_table_batch").jqGrid("delRowData", batchNo);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $("#saveBatch").on('click',function(e){
|
|
|
+ if(batchNo == null){
|
|
|
+ return errorMesageSimaple('没有可保存数据!');
|
|
|
+ }
|
|
|
+ let record = jQuery("#tb_table_batch").getRowData(batchNo);
|
|
|
+ let data= {usingFlag:record['usingFlag'],chargeCode:record['chargeCode'],ypbh:$('#'+batchNo+'_ypbh').val(),fDate:$('#'+batchNo+'_fDate').val()};
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ url: '/thmz/addYpZdYpbh',
|
|
|
+ contentType: "application/json;charset=UTF-8",
|
|
|
+ dataType: "json",
|
|
|
+ headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
|
|
|
+ data: JSON.stringify(data),
|
|
|
+ success: function (res) {
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.code == 0) {
|
|
|
+ let record = jQuery("#tb_table").getRowData(chargeNo);
|
|
|
+ loadBatch(record.chargeCode);
|
|
|
+ batchNo = null;
|
|
|
+ successMesage(res);
|
|
|
+ } else {
|
|
|
+ errorMesage(res);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|