123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- //获取团队信息
- var request = getRequest(),
- teamCode = request.id,
- isLeader = request.isLeader || true;
- //记录页面控件的值
- var startDate = '',
- endDate = '',
- state = '', //状态
- dispensaryType = '', //配送方式
- page = 1,
- jgPage = 1,
- size = 10,
- hospital = '', //服务站code
- allocationType = 0, //是否是待分配续方
- nameKey = '', //搜索的姓名
- selectItemNum = 0, //选中的数量
- selectItem = [], //选中的订单号集合
- isArrange = false, // 判断所选的订单是否是可分配的
- totalOrderCount = 0,
- totalHealthDoctorCount = 0,
- selectDoctor; //选中的医生
- $(function(){
- setTitle("续方订单");
- //非团队长隐藏操作按钮
- if(!isLeader || isLeader == 'false'){
- $("#arrange").hide();
- }
- //填充下拉框数据
- orderAPI.getFilterInfo().then(function(res){
- console.log(JSON.stringify(res));
- fillDropDown(res);
-
- // getPrescriptionList();
- });
- //获得服务站数据
- orderAPI.getHospitalList({data: {teamCode: teamCode}}).then(function(res){
- console.log(JSON.stringify(res));
- var html = template('address_tmpl', {list: res.data});
- $("#address").empty().append(html);
- });
- //获得续方订单列表
- getPrescriptionList();
- bindEvents();
- });
- //获得续方订单列表
- function getPrescriptionList( refresh){
- var params = {
- teamCode: teamCode,
- startDate: startDate,
- endDate: endDate,
- state: state,
- dispensaryType: dispensaryType,
- hospital: hospital,
- allocationType: allocationType,
- nameKey: nameKey
- };
- //先请求获得所有的数量
- orderAPI.getOrderListCount({data:params}).then(function(res){
- if(res.status == 200){
- totalOrderCount = res.data.total;
- if(refresh){
- $("#prescriptTable").bootstrapTable('refresh');
- }
- var options = $.extend(orderAPI.getOrderListTableAjaxObj, {
- queryParams: queryParams,
- queryParamsType: "limit",
- pagination: true,
- paginationLoop: true,
- sidePagination: 'server',
- pageNumber: 1,
- pageSize: 10,
- responseHandler: function (res) {
- var data = _.map(res.data, function(o){
- var result = "";
- for(var i=0; i<o.prescriptionDt.length; i++){
- if(i>0){
- result += ','+o.prescriptionDt[i].name;
- }else{
- result += o.prescriptionDt[i].name;
- }
- }
- o.result = result;
- if(o.status == '50'){
- o.statusName = '订单已支付';
- }else if(o.status == '60'){
- o.statusName = '配药完成';
- }else{
- o.statusName = getStatusName(o.status);
- }
-
- o.express = getExpressName(o.dispensaryType);
- var address = "",
- expressage = "";
- if(o.dispensaryType == 2){
- expressage = o.expressageHospitalName;
- address = o.provinceName + o.cityName + o.townName + o.address;
- }else if(o.dispensaryType == 3){
- address = o.patientHospitalName;
- expressage = o.expressageName;
- }
- o.expressage = expressage;
- o.address = address;
- o.action = '<a class="c-12b7f5" href="prescription-main.html?code='+o.code+'&patiCode='+o.patientCode+'&teamCode='+teamCode+'&tab=2&patiName='+o.name+'">查看</a>';
- o.checkbox = '<input name="orderItem" type="checkbox" class="icon-checkbox" data-status="'+o.status+'" data-type="'+o.dispensaryType+'" data-expressage="'+o.expressageCode+'" data-code="'+o.code+'">';
- return o;
- });
-
- return {
- rows: data,
- total: totalOrderCount
- }
- }
- })
- $("#prescriptTable").bootstrapTable(options);
- }
- });
-
- }
- function queryParams(params) {
- //当表格数据变化的时候,则取消全选按钮,然后之前的选中的信息将取消选中
- page = params.offset/params.limit + 1;
- selectItemNum = 0;
- $("#selectAll").prop("checked", false);
- $("#selectedCount").text(0);
- $("#arrange").addClass("disabled");
-
- return {
- teamCode: teamCode,
- page: page,
- size: params.limit,
- startDate: startDate,
- endDate: endDate,
- state: state,
- dispensaryType: dispensaryType,
- hospital: hospital,
- allocationType: allocationType,
- nameKey: nameKey
- };
- }
- //获得健管师列表
- function getHealthDoctorList(isRefresh){
- if(isRefresh){
- $("#hDoctor").bootstrapTable('refresh');
- }
- var options = $.extend(orderAPI.getHealthDoctorTableAjaxObj, {
- queryParams: queryParams2,
- queryParamsType: "limit",
- pagination: true,
- paginationLoop: true,
- sidePagination: 'server',
- pageNumber: 1,
- pageSize: 8,
- pageList: [5,8,10],
- responseHandler: function (res) {
- return {
- rows: res.data.doctors || [],
- total: res.data.total
- }
- },
- columns: [{
- field: 'photo',
- title: '',
- width: '50',
- formatter: function(val, row, index){
- var url = APIService.getImgUrl(val);
- if((url.indexOf("http")== -1) && (url.indexOf("https")== -1)){
- url = "img/d-male.png";
- }
- return '<img src="'+url+'" class="img-circle" width="40">';
- }
- }, {
- field: 'name',
- title: '',
- align: 'left'
- },{
- field: 'jobName',
- title: '职称',
- align: 'right'
- }],
- onClickRow: function(row, $el){
- $("#orderCount").text(selectItemNum);
- var jobName = '';
- if(row.jobName){
- jobName = row.jobName;
- }
- $("#docInfo").text(row.name+jobName);
- $("#confirmModal").modal('toggle');
- selectDoctor = row.code;
- }
- });
- $("#hDoctor").bootstrapTable(options);
- }
- function queryParams2(params) {
- //当表格数据变化的时候,则取消全选按钮,然后之前的选中的信息将取消选中
- jgPage = params.offset/params.limit + 1
- return {
- page: jgPage,
- size: params.limit,
- name: $.trim($("#doctorName").val())
- };
- }
- function fillDropDown(res){
- if(res.status == 200){
- var stateHtml = template('state_tmpl', {list: res.data.states});
- $("#orderStatus").append(stateHtml);
- var expressHtml = template('express_tmpl', {list: res.data.dispensaryTypes});
- $("#express").append(expressHtml);
- }else{
- }
- }
- //绑定事件
- function bindEvents(){
- $(".n-tab").on('click', function(){
- if($(this).hasClass("active")){
- return false;
- }else{
- $(this).addClass("active");
- $(this).siblings().removeClass("active");
- var seDate = getStartEndDate($(this).attr("data-val"));
- startDate = seDate.startDate;
- endDate = seDate.endDate;
- $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
- getPrescriptionList(true);
- }
- });
- $("#orderStatus").on('change', function(){
- var $this = $(this);
- state = $this.val();
- $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
- getPrescriptionList(true);
- });
- $("#express").on('change', function(){
- dispensaryType = $(this).val();
- if(dispensaryType == 3){ //健管师配送时,显示复选框
- $("#checkboxBox").removeClass("hidden");
- }else{
- $("#checkboxBox").addClass("hidden");
- $("#allocationType").prop("checked", false);
- allocationType = 0;
- }
- $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
- getPrescriptionList(true);
- });
-
- $("#address").on('change', function(){
- hospital = $(this).val();
- $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
- getPrescriptionList(true);
- });
- $("#allocationType").on('change', function(){
- var $this = $(this);
- if($this.prop('checked')){
- allocationType = 1;
- }else{
- allocationType = 0;
- }
- $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
- getPrescriptionList(true);
- });
- $("#searchBtn").on('click', function(){
- var $input = $("#searchName"),
- text = $.trim($input.val());
- nameKey = text;
- $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
- getPrescriptionList(true);
- });
- $("#selectAll").on('click', function(){
- var $this = $(this),
- $checkbox = $("input[name=orderItem]"),
- length = $checkbox.length;
- if($this.prop("checked")){
- $checkbox.prop("checked", true);
- selectItemNum = length;
- $("#selectedCount").text(selectItemNum);
- }else{
- $checkbox.prop("checked", false);
- selectItemNum = 0;
- $("#selectedCount").text(0);
- }
- checkArrangeDisable('all');
- });
- $("body").on('click', "input[name=orderItem]", function(){
- var $this = $(this),
- status = $this.data('status'),
- type = $this.data('type'),
- expressage = $this.data('expressage'),
- code = $this.data('code');
- if($this.prop("checked")){
- selectItemNum ++;
- if((type == 3) && (status >= 50) && (expressage=='' || !expressage)){
- selectItem.push(code);
- }
- }else{
- selectItemNum --;
- if(selectItem.indexOf(code) > -1){
- var index = selectItem.indexOf(code);
- selectItem.splice(index,1);
- }
- }
- $("#selectedCount").text(selectItemNum);
- checkArrangeDisable();
- });
- $("#arrange").on('click', function(){
- if($(this).hasClass("disabled")){
- return false;
- }
- $('#myModal').modal('toggle');
- getHealthDoctorList();
- });
- $("#doctorName").on('keyup', function(e){
- if (e.which === 13) {
- $('#hDoctor').bootstrapTable('refreshOptions',{pageNumber:1});
- getHealthDoctorList(true);
- }
- });
- $("#confirmBtn").on('click', function(){
- //发送请求确认的请求
- var params = {
- codes: selectItem.join(","),
- healthDoctor: selectDoctor
- }
- orderAPI.distributeHealthDoctor({data: params}).then(function(res){
- if(res.status == 200){
- $('#myModal').modal('toggle');
- $('#confirmModal').modal('toggle');
- $("#prescriptTable").bootstrapTable('refresh');
- }else{
- }
- })
- });
- }
- //判断选中的订单是否是可分配的的订单
- function checkArrangeDisable(clickType){ //type=all 为点击全选时处理
- //可以分配的条件,1是健管师配送订单,2状态为待分配
- var $checkbox = $("input[name=orderItem]:checked"),
- len = $checkbox.length;
- isArrange = false;
- if(clickType == 'all'){
- selectItem = [];
- }
- for(var i=0; i<len; i++){
- var $item = $($checkbox[i]),
- status = $item.data('status'),
- type = $item.data('type'),
- expressage = $item.data('expressage'),
- code = $item.data('code');
- if(type != 3){
- isArrange = false;
- break;
- }else{
- if((status >= 50) && (expressage=='' || !expressage)){ //支付成功后状态+配送员的名字为空为待分配状态
- isArrange = true;
- if(clickType == 'all'){
- selectItem.push(code);
- }
- }else{
- isArrange = false;
- break;
- }
- }
- }
- if(!isArrange){
- $("#arrange").addClass("disabled");
- }else{
- $("#arrange").removeClass("disabled");
- }
- }
|