123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- //@ sourceURL=yf_special_mark.js
- var pharmacyGroupNo = window.localStorage["groupNo"];//药房编码
- var chargeNo;//药品表选中的行号
- var batchNo;//批次表选中的行号
- $(function () {
- $(".selectpicker").selectpicker();
- //$("#pharmacyModal").modal("show");
- if(pharmacyGroupNo == null){
- return errorMesageSimaple('药房参数未设置,请在发药参数设置中设置');
- }
- initTable();
- initBatch();
- $('#btn_search').on('click',function(e){
- loadTbTable();
- });
- $('#searchText').on('blur',function(e){
- loadTbTable();
- });
- });
- /**
- * 查询列表
- */
- 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');
- },
- ajaxCellOptions: {
- beforeSend: function (XMLHttpRequest) {
- XMLHttpRequest.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem("token"));
- }
- },
- styleUI: 'Bootstrap',
- viewrecords: true,
- autowidth: false,
- 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: 'prescriptionLimitDays', index: 'prescriptionLimitDays',width:100,align:'center',editable : true,edittype:'text'
- ,editrules: {edithidden:false,number:true,minValue: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: 'manufactoryName', index: 'manufactoryName',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',formatoptions:{decimalPlaces:0},align:'center',width:100},
- {name: 'sevenDayDosage', index: 'sevenDayDosage', formatter: 'number',formatoptions:{decimalPlaces:0},align:'center',width:100},
- {name: 'fourteenDayDosage', index: 'fourteenDayDosage', formatter: 'number',formatoptions:{decimalPlaces:0},align:'center',width:100},
- {name: 'thirtyDayDosage', index: 'thirtyDayDosage', formatter: 'number',formatoptions:{decimalPlaces:0},align:'center',width:100},
- {name: 'location', index: 'location',width:100,align:'center',editable : true,edittype:'text'
- ,editrules: {edithidden:false}},
- {name: 'className', index: 'className',width:100,align:'center'}
- ],
- jsonReader: {
- root: "data", repeatitems: false
- },
- beforeSubmitCell:function(rowid, cellname, value, iRow, iCol){
- let record = $("#tb_table").getRowData(rowid);
- let temp = eval('(' + '{ "'+cellname+'": "'+value+'"}' + ')');
- if(cellname === 'prescriptionLimitDays' && value == 0){
- if (!confirm("确定放开当前药品的处方天数限制吗?")) {
- return;
- }
- }
- if(cellname !== 'prescriptionLimitDays'){
- temp.prescriptionLimitDays = record.prescriptionLimitDays;
- }
- 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: 'json',
- mtype: 'get',
- url: '/thmz/getYpZdYpbh',
- loadBeforeSend: function (jqXHR) {
- jqXHR.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem("token"));
- jqXHR.setRequestHeader("Accept", 'application/json');
- },
- ajaxCellOptions: {
- beforeSend: function (XMLHttpRequest) {
- XMLHttpRequest.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem("token"));
- }
- },
- 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);
- }
- }
- });
- });
- }
|