123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- //@ sourceURL=refund_medicine.js
- $(function () {
- init_daterangepicker();
- initChargeListByPatient();
- // initFeeTable();
- //重置查询参数
- $('#btn_clean').click(function () {
- cleanParams();
- });
- $("#btn_query").click(function (t) {
- initChargeListByPatient();
- });
- $("#btn_save").click(function (t) {
- saveRefundMedicine();
- });
- $(".selectpicker").selectpicker({
- dropuAuto: false
- });
- });
- /**
- * 查询病人缴费记录
- */
- function initChargeListByPatient() {
- $('#tb_table').bootstrapTable("destroy");
- $('#tb_table').bootstrapTable({
- url: '/thmz/getYfyjl', //请求后台的URL(*)
- method: 'post', //请求方式(*)
- toolbar: '#toolbar', //工具按钮用哪个容器
- striped: true, //是否显示行间隔色
- cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
- pagination: true, //是否显示分页(*)
- sortable: true, //是否启用排序
- sortOrder: "asc", //排序方式
- queryParams: queryParams, //传递参数(*)
- sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
- pageNumber: 1, //初始化加载第一页,默认第一页
- pageSize: 10, //每页的记录行数(*)
- pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
- search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
- strictSearch: true,
- showColumns: false, //是否显示所有的列
- showRefresh: false, //是否显示刷新按钮
- minimumCountColumns: 2, //最少允许的列数
- clickToSelect: true, //是否启用点击选中行
- uniqueId: "ID", //每一行的唯一标识,一般为主键列
- showToggle: false, //是否显示详细视图和列表视图的切换按钮
- cardView: false, //是否显示详细视图
- detailView: false,
- //rowStyle:rowStyle,//通过自定义函数设置行样式
- ajaxOptions: {
- headers: {
- 'Accept': 'application/json',
- 'Authorization': 'Bearer ' + localStorage.getItem("token")
- }
- },
- columns: [
- {
- field: 'patientId',
- title: '门诊号',
- align: "center",
- valign: 'middle',
- }, {
- field: 'name',
- title: '姓名',
- align: "center",
- valign: 'middle',
- }, {
- field: 'orderNo',
- title: '处方号',
- align: "center",
- valign: 'middle',
- }, {
- field: 'groupNoOut',
- title: '药房',
- align: "center",
- valign: 'middle',
- }, {
- field: 'chargeDate',
- title: '缴费日期',
- align: "center",
- valign: 'middle',
- formatter: function (value, row, index) {
- if (value != null && value != "") {
- return format(value, "yyyy-MM-dd HH:mm:ss");
- }
- return "";
- }
- }, {
- field: 'doctorName',
- title: '医生',
- align: "center",
- valign: 'middle',
- }, {
- field: 'confirmTime',
- title: '确认日期',
- align: "center",
- valign: 'middle',
- formatter: function (value, row, index) {
- if (value != null && value != "") {
- return format(value, "yyyy-MM-dd HH:mm:ss");
- }
- return "";
- }
- }, {
- field: 'realNo',
- title: '流水号',
- align: "center",
- valign: 'middle',
- }
- ],
- onClickRow: function (row) {
- fitfymx(row.patientId, row.times, row.receiptNo,row.orderNo,row.groupNo);
- },
- responseHandler: function (res) {
- if (res == '401' || res == 401) {
- window.location.href = '/thmz/login/view'
- return;
- }
- var ress = eval(res);
- if (ress.code == -1) {
- if (ress.message != null && ress.message != '') {
- new PNotify({
- title: '错误提示',
- text: ress.message,
- type: 'error',
- hide: true,
- styling: 'bootstrap3'
- });
- }
- return {
- "total": 0,//总页数
- "rows": {} //数据
- };
- }
- return {
- "total": ress.data.length,//总页数
- "rows": ress.data //数据
- };
- },
- });
- }
- /**
- * 构建列表查询参数
- * @param params
- * @returns {{mzChargeDetail: {patientId: string | number | string[] | undefined | jQuery, warnDept: string | number | string[] | undefined | jQuery, doctorCode: string | number | string[] | undefined | jQuery, name: string | number | string[] | undefined | jQuery, payMark: number}, beginTime: Date, endTime: Date, pageSize: *, pageIndex: number}}
- */
- function queryParams(params) {
- var rePortRangeArr = getRePortRangeArr();
- var temp = {
- beginDate: rePortRangeArr[0],
- endDate: rePortRangeArr[1],
- name: $("#name").val(),
- patientId: $("#patientId").val(),
- serialNo: $("#serialNo").val()
- };
- return temp;
- };
- /**
- * 设置病人id
- */
- function setPatientId() {
- var patientId_or_cardNo = $("#patientId_or_cardNo").val();
- $.ajax({
- type: "GET",
- url: '/thmz/getByIcCardNo?icCardNo=' + patientId_or_cardNo,
- contentType: "application/json;charset=UTF-8",
- dataType: "json",
- headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
- success: function (res) {
- if (res == '401' || res == 401) {
- window.location.href = '/thmz/login/view'
- return;
- }
- if (res.code == 0) {
- if (res.data != null) {
- $("#patientId").val(res.data.patientId);
- } else {
- $("#patientId").val(patientId_or_cardNo);
- }
- }
- }
- });
- }
- /**
- * 获取时间选择器的时间数组
- * @returns {string[]}
- */
- function getRePortRangeArr() {
- var rePortRange = $('#reportrange span').html();
- var rePortRangeArr = rePortRange.split(" - ");
- rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
- rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
- return rePortRangeArr;
- }
- /**
- * 清空查询条件
- */
- function cleanParams() {
- $('#reportrange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
- $("#name").val(null),
- $("#patientId").val(null),
- $("#serialNo").val(null),
- $("#patientId_or_cardNo").val(null)
- }
- /**
- * 设置病人药品明细
- */
- var $table;
- function fitfymx(patientId,times,receiptNo,orderNo,groupNoOut) {
- var temp = {
- patientId: patientId,
- times: times,
- receiptNo:receiptNo,
- orderNo:orderNo,
- groupNoOut:groupNoOut
- };
- $('#tb_table_right').bootstrapTable("destroy");
- $table= $('#tb_table_right').bootstrapTable({
- url: '/thmz/getYpMx', //请求后台的URL(*)
- method: 'post', //请求方式(*)
- toolbar: '#toolbar', //工具按钮用哪个容器
- striped: true, //是否显示行间隔色
- cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
- pagination: true, //是否显示分页(*)
- sortable: true, //是否启用排序
- sortOrder: "asc", //排序方式
- queryParams: temp, //传递参数(*)
- sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
- pageNumber: 1, //初始化加载第一页,默认第一页
- pageSize: 10, //每页的记录行数(*)
- pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
- search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
- strictSearch: true,
- showColumns: false, //是否显示所有的列
- showRefresh: false, //是否显示刷新按钮
- minimumCountColumns: 2, //最少允许的列数
- clickToSelect: true, //是否启用点击选中行
- uniqueId: "ID", //每一行的唯一标识,一般为主键列
- showToggle: false, //是否显示详细视图和列表视图的切换按钮
- cardView: false, //是否显示详细视图
- detailView: false,
- //rowStyle:rowStyle,//通过自定义函数设置行样式
- ajaxOptions: {
- headers: {
- 'Accept': 'application/json',
- 'Authorization': 'Bearer ' + localStorage.getItem("token")
- }
- },
- columns: [
- {
- field: 'drugname',
- title: '品名',
- align: "center",
- valign: 'middle',
- formatter: function (value, row, index) {
- if (value != null && value != "") {
- return value.replace("()","");
- }
- return "";
- }
- }, {
- field: 'specification',
- title: '规格',
- align: "center",
- valign: 'middle',
- }, {
- field: 'quantity',
- title: '数量',
- align: "center",
- valign: 'middle',
- }, {
- field: 'unit_price',
- title: '单价',
- align: "center",
- valign: 'middle',
- }, {
- field: 'dec_amount',
- title: '退药量',
- align: "center",
- valign: 'middle',
- }
- ],
- /**
- * @param {点击列的 field 名称} field
- * @param {点击列的 value 值} value
- * @param {点击列的整行数据} row
- * @param {td 元素} $element
- */
- onClickCell: function(field, value, row, $element) {
- var bill_item_code=row.bill_item_code.trim();
- if(field == 'dec_amount' && (bill_item_code =='010' || bill_item_code =='011')){
- $element.attr('contenteditable', true);
- $element.html(null);
- $element.focus();
- $element.blur(function() {
- var index = $element.parent().data('index');
- var tdValue = $element.html();
- saveData(index, field, tdValue);
- })
- }
- },
- responseHandler: function (res) {
- if (res == '401' || res == 401) {
- window.location.href = '/thmz/login/view'
- return;
- }
- var ress = eval(res);
- if (ress.code == -1) {
- if (ress.message != null && ress.message != '') {
- new PNotify({
- title: '错误提示',
- text: ress.message,
- type: 'error',
- hide: true,
- styling: 'bootstrap3'
- });
- }
- return {
- "total": 0,//总页数
- "rows": {} //数据
- };
- }
- return {
- "total": ress.data.length,//总页数
- "rows": ress.data //数据
- };
- },
- });
- function saveData(index, field, value) {
- $table.bootstrapTable('updateCell', {
- index: index, //行索引
- field: field, //列名
- value: value //cell值
- })
- }
- }
- /**
- * 保存退药信息
- */
- function saveRefundMedicine() {
- var data= $table.bootstrapTable('getData');
- var jsonData = JSON.parse('{"serialNo":"","groupNoOut":"","orderNo":"","chargeItemCodeAndDecAmounts":[]}');
- if(data!=null){
- jsonData.serialNo = data[0].serial_no;
- jsonData.groupNoOut = data[0].group_no;
- jsonData.orderNo = data[0].order_no;
- for (var i=0;i<data.length;i++){
- var dec_amount=data[i].dec_amount;
- if(dec_amount==null || dec_amount==""){
- new PNotify({
- title: '警告提示',
- text: "【"+data[i].drugname+"】"+'的退药量不能为空',
- hide: false,
- styling: 'bootstrap3'
- });
- return;
- }
- jsonData.chargeItemCodeAndDecAmounts[i] = data[i].charge_item_code+","+dec_amount;
- }
- }
- $.ajax({
- type: "POST",
- url: '/thmz/refundMedicine',
- contentType: "application/json;charset=UTF-8",
- dataType: "json",
- headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
- data: JSON.stringify(jsonData),
- success: function (res) {
- if (res == '401' || res == 401) {
- window.location.href = '/thmz/login/view'
- return;
- }
- if (res.code == 0) {
- successMesage(res);
- } else {
- errorMesage(res);
- }
- }
- });
- }
|