
<style>
    .SalesHotelOrder .query-box{
        border-bottom:0;
    }
    .SalesHotelOrder .SalesHotelOrderTable{
        width: 100%;
        min-width: 1500px;
        font-size: 14px;
        color: #333;
        border-bottom: 1px solid #cccccc;
        border-right: 1px solid #cccccc;
        border-collapse: collapse;
    }
    .SalesHotelOrder .SalesHotelOrderTable th{
        background: #e6e6e6;
        height: 30px;
        font-size: 12px;
        text-align: center;
        border-top: 1px solid #cccccc;
        border-left: 1px solid #cccccc;
    }
    .SalesHotelOrder .SalesHotelOrderTable tr td{
        height: 60px;
        padding: 10px;
        background-color: #fff;
        text-align: center;
        border-top: 1px solid #cccccc;
        border-left: 1px solid #cccccc;
    }
    .SalesHotelOrder .SalesHotelOrderTable tbody tr:last-child{
        border-bottom:2px solid #333;
    }
    .SalesHotelOrder .SH_beizhu{
        float:left;
    }
    .SalesHotelOrder .SH_beizhuInner{
        float:left;
        width:85%;
    }
    .SalesHotelOrder .SH_OrderDan>div{
        display:inline-block;
    }
      .groupTourOrder_count {
    margin: 0 0 20px 0;
    width: 100%;
    height: auto;
  }

  .groupTourOrder_count_col {
    height: 80px;
  }

  .groupTourOrder_count_item {
    font-weight: 400;
    padding: 10px;
    height: 100%;
    border: 1px solid #E6E6E6;
    background-color: #FFFFFF;
    color: #333333;
  }

  .groupTourOrder_count_item>div>i {
    font-size: 12px;
    vertical-align: bottom;
  }

  .groupTourOrder_count_item>div>span:nth-child(2) {
    font-size: 14px;
    vertical-align: bottom;
  }

  .groupTourOrder_count_item>div>span:nth-child(3) {
    font-weight: bold;
    font-size: 16px;
    vertical-align: bottom;
  }

  .groupTourOrder_count_item>p {
    font-size: 12px;
    line-height: 18px;
  }

  .groupTourOrder_count_item>p>span {
    margin: 0 5px 0 0;
    white-space: nowrap;
  }
  .groupTourOrder_count_green {
    color: #1BC594;
  }

  .groupTourOrder_count_blue {
    color: #4D7AFD;
  }

  .groupTourOrder_count_yellow {
    color: #FF9C00;
  }

  .groupTourOrder_count_gray {
    color: #999999;
  }
  .HT_total span{
    display: inline-block;
    margin:5px 10px 0 0!important;
  }
  .HT_totalFinacel span{
    display: inline-block;
    margin:3px 5px 0 0!important;
  }
 .color_red_order {
    color: #e95252 !important;
  }
  .groupTourOrderByTuan_ico>i{
        display: inline-block;
        margin: 0 2px 0 0;
        width: 8px;
        height: 8px;
        border-radius: 2px;
        vertical-align: middle;
    }
  .groupTourOrder_tickets_red {
    color: #FF0000;
    text-decoration: underline;
    cursor: pointer;
  }
  .groupTourOrder_tickets_blue {
    color: #0000FF;
    text-decoration: underline;
    cursor: pointer;
  }

  .groupTourOrder_tickets_green {
    color: #008000;
    text-decoration: underline;
    cursor: pointer;
  }

  .groupTourOrder_tickets_black {
    color: #000000;
    text-decoration: underline;
    cursor: pointer;
  }

</style>

<template>
    <div class="flexOne SalesHotelOrder">
    <div class="query-box">
      <ul>
        <li>
          <span><em>{{$t('salesModule.keyWords')}}</em>
            <el-input v-model='msg.searchKey' :placeholder="$t('pub.pleaseImport')"></el-input>
          </span>
        </li>
        <li>
          <span>
            <em>{{$t('hotel.hotel_OrderStates')}}</em>
            <el-select v-model='msg.status' filterable :placeholder="$t('pub.pleaseSel')">
                <el-option v-for="item in orderStatus" :label='item.Name' :value='item.Id' :key='item.Id'>
                </el-option>
            </el-select>
            </span>
        </li>
        <li>
            <span>
                <em>{{$t('sm.company')}}</em>
                <el-select v-model="msg.rbBranchId" :placeholder="$t('pub.pleaseSel')" >
                    <el-option :value="-1" :label="$t('pub.unlimitedSel')"></el-option>
                    <el-option v-for='item in CompanyList'
                        :label='item.BName'
                        :value='item.Id'
                        :key='item.Id'>
                    </el-option>
                </el-select>
            </span>
        </li>
        <!-- -->
        <!-- <li>
            <span>
                <em>{{$t('admin.admin_Department')}}</em>
                <el-select v-model="msg.RB_Department_Id" :placeholder="$t('rule.qxzbmen')" @change="employeeMsg.DepartmentId = msg.RB_Department_Id,employeeMsg.BranchId=msg.RB_Branch_Id, getEmployee(), msg.CreateBy=0">
                <el-option :value="0" :label="$t('pub.unlimitedSel')"></el-option>
                <el-option v-for='item in DepartmentList'
                    :label='item.DepartmentName'
                    :value='item.DepartmentID'
                    :key='item.DepartmentID'>
                </el-option>
                </el-select>
            </span>
        </li>
        <li>
            <span>
                <em>{{$t('active.cl_addPp')}}</em>
                <el-select  filterable  v-model='msg.CreateBy'>
                    <el-option :value="0" :label="$t('pub.unlimitedSel')"></el-option>
                    <el-option v-for='item in EmployeeList'
                        :label='item.EmName'
                        :value='item.EmployeeId'
                        :key='item.EmployeeId'>
                    </el-option>
                </el-select>
            </span>
        </li> -->

        <li>
          <span>
            <em>{{$t('system.table_begTime')}}</em>
            <el-date-picker type="date" v-model="msg.startDate"
            :picker-options="StartTimeBefore" value-format="yyyy-MM-dd" placeholder></el-date-picker>
          </span>
        </li>
        <li>
          <span>
            <em>{{$t('MarketingActi.endTime')}}</em>
            <el-date-picker type="date" v-model="msg.endDate"
            :picker-options="EndTimeAfter" value-format="yyyy-MM-dd" placeholder></el-date-picker>
           </span>
        </li>

        <li>
          <input type="button" class="hollowFixedBtn" @click="resetPageIndex();getList()" :value="$t('pub.searchBtn')" />
        </li>
      </ul>
    </div>

    <table class="SalesHotelOrderTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
      <tr>
        <th>{{$t('hotel.order_Number')}}</th>
        <th>{{$t('restaurant.res_Number')}}</th>
        <th>{{$t('sm.zonge')}}</th>
        <th>{{$t('fnc.yishoujine')}}</th>
        <th>{{$t('fnc.tkjine')}}</th>
        <th>{{$t('Operation.Op_daishou')}}</th>
        <th>{{$t('sm.youhuijine')}}</th>
        <th>{{$t('hotel.hotel_OrderStates')}}</th>
        <th>{{$t('fnc.cjshijian')}}</th>
        <th>{{$t('scen.sc_etTime')}}</th>
        <th>{{$t('scen.sc_name')}}</th>
        <th>{{$t('fnc.khxinxi')}}</th>
        <th>{{$t('system.table_operation')}}</th>
      </tr>
      <tbody v-for="(item,index) in dataList" :key="index+500">
        <tr>
            <td style="border-bottom:2px solid #333" rowspan="2">{{item.id}}</td>
            <td>{{item.purchaseQuantity}}</td>
            <td>{{item.preferPrice}}</td>
            <td>{{item.income}}</td>
            <td>
              <span v-if="item.reFund">{{item.reFund}}</span>
              <span v-else>0</span>
            </td>
            <td>{{item.discountMoney}}</td>
            <td>{{item.duein}}</td>
            <td>
              <span v-if="item.status==1">{{$t('system.ph_zhengchang')}}</span>
              <span class="color_red_order" v-if="item.status==2">{{$t('pub.cancelBtn')}}</span>
              <span v-if="item.status==3">{{$t('sm.daifukuan')}}</span>
            </td>
            <td>{{item.createDate}}</td>
            <td>{{item.useDate}}</td>
            <td>{{item.couponsName}}</td>
            <td>
              <p>{{$t('sm.ChName')}}：{{item.contactCNName}}</p>
              <p>{{$t('sm.EnName')}}：{{item.contactENName}}</p>
              <p>{{$t('scen.sc_tel')}}：{{item.contactEmail}}</p>
              <p>{{$t('sm.email')}}：{{item.contactMobile}}</p>
            </td>
            <td>
                <el-row>
                  <el-button-group>
                    <el-tooltip class="item" effect="dark" :content="$t('fnc.fukuan')" placement="top-start" v-if="item.OrderStatus!=='已取消'">
                      <el-button type="primary" icon="iconfont icon-fukuan2" @click="getShouKuan(item)" ></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" :content="$t('sm.exitOrder')" placement="top-start" v-if="item.OrderStatus!=='已取消'">
                      <el-button type="info" v-if="item.IsCanOrder == 0" icon="iconfont icon-quxiao1" @click="Exit(item)"></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" :content="$t('pub.sureBtn')" placement="top-start" v-if="item.OrderStatus!=='已取消'">
                      <el-button  type="success" icon="iconfont icon-duigou" v-if="item.IsCanClear == 0" @click="queren(1, item.OrderID)" ></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" effect="dark" :content="$t('sm.exitsure')" placement="top-start" v-if="item.OrderStatus!=='已取消'">
                      <el-button type="info" icon=" iconfont icon-quxiao1" v-if="item.IsCanClear == 1" @click="queren(0, item.OrderID)"></el-button>
                    </el-tooltip>
                    <!-- <el-tooltip class="item" effect="dark" content="关联团" placement="top-start">
                      <el-button type="warning" icon="iconfont icon-guanlian" @click="TCID = '',GLOrderID = item.OrderID,dialogFormVisible = true"></el-button>
                    </el-tooltip> -->
                    <el-tooltip class="item" effect="dark" :content="$t('fnc.xiangqing')" placement="top-start">
                      <el-button type="success" icon="iconfont icon-sousuo" @click="goOrderDetails(item.id)"></el-button>
                    </el-tooltip>
                  </el-button-group>
                </el-row>
            </td>
        </tr>
        <tr>
            <td colspan="7" style="text-align:left;width:600px">
                <div class="clearfix">
                    <div class="SH_beizhu" style="">
                        {{$t('pub.pubRemark')}}：
                    </div>
                    <div class="SH_beizhuInner">
                        {{item.Remark}}
                    </div>
                </div>
            </td>
            <td colspan="8" style="text-align:left;width:600px">
                <div class="SH_OrderDan">
                    <div>{{$t('fnc.skdanju')}}：</div>
                    <div>
                        <span v-for="(subItem,index) in item.Revenue" :key="index+5000">
                            <span style="margin-right:6px" @click="goUrlFinacel('财务单据','FinancialDocumentsDetail',subItem.FrID)" v-if="subItem.color===1" class="groupTourOrder_tickets_blue">{{subItem.FrID}}</span>
                            <span style="margin-right:6px" @click="goUrlFinacel('财务单据','FinancialDocumentsDetail',subItem.FrID)" v-else-if="subItem.color===2" class="groupTourOrder_tickets_blue">{{subItem.FrID}}</span>
                            <span style="margin-right:6px" @click="goUrlFinacel('财务单据','FinancialDocumentsDetail',subItem.FrID)" v-else-if="subItem.color===3" class="groupTourOrder_tickets_blue">{{subItem.FrID}}</span>
                            <span style="margin-right:6px" @click="goUrlFinacel('财务单据','FinancialDocumentsDetail',subItem.FrID)" v-else-if="subItem.color===4" class="groupTourOrder_tickets_blue">{{subItem.FrID}}</span>
                        </span>
                        <span v-if="item.Revenue==0">{{$t('system.content_noData')}}</span>
                    </div>
                </div>
                <div  class="SH_OrderDan">
                    <div>{{$t('fnc.fkdanju')}}：</div>
                    <div>
                        <span v-for="(subItem,index) in item.expend" :key="index+1000">
                            <span style="margin-right:6px" @click="goUrlFinacel('财务单据','FinancialDocumentsDetail',subItem.FrID)" v-if="subItem.color===1" class="groupTourOrder_tickets_blue">{{subItem.FrID}} </span>
                            <span style="margin-right:6px" @click="goUrlFinacel('财务单据','FinancialDocumentsDetail',subItem.FrID)" v-else-if="subItem.color===2" class="groupTourOrder_tickets_green">{{subItem.FrID}} </span>
                            <span style="margin-right:6px" @click="goUrlFinacel('财务单据','FinancialDocumentsDetail',subItem.FrID)" v-else-if="subItem.color===3" class="groupTourOrder_tickets_red">{{subItem.FrID}} </span>
                            <span style="margin-right:6px" @click="goUrlFinacel('财务单据','FinancialDocumentsDetail',subItem.FrID)" v-else-if="subItem.color===4" class="groupTourOrder_tickets_black">{{subItem.FrID}} </span>
                        </span>
                        <span v-if="item.expend==0">{{$t('system.content_noData')}}</span>
                    </div>
                </div>

            </td>
        </tr>
      </tbody>
    </table>
    <div class="noDataNotice" v-if="dataList.length<1">
      <i class="iconfont icon-kong"></i>
      <p>{{$t("active.ld_noData")}}</p>
    </div>
    <el-dialog :title="$t('pub.pleaseSel')" width="400px" :visible.sync="dialogFormVisible" center :before-close="closeChangeMachie">
      <el-form label-width="110px">
          <el-form-item :label="$t('visa.v_tuanhao')">
              <el-select
                  v-model="TCID"
                  filterable
                  remote
                  reserve-keyword
                  :placeholder="$t('pub.pleaseImport')"
                  :remote-method="remoteMethodTCNum"
                  :loading="loading2">
                  <el-option
                      v-for="item in searchList"
                      :key="item.TCID"
                      :label="item.TCNUM"
                      :value="item.TCID">
                      <span style="float: left">{{ item.TCNUM }}</span>
                  </el-option>
              </el-select>
            </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
          <button class="hollowFixedBtn" @click="dialogFormVisible=false,GLOrderID = ''">{{$t('pub.cancelBtn')}}</button>
          <button class="normalBtn" type="primary" @click="querenGL">{{$t('pub.sureBtn')}}</button>
      </div>
    </el-dialog>
    <el-pagination background @current-change="handleCurrentChange" :current-page.sync="currentPage" layout="total,prev, pager, next, jumper"
      :page-size=msg.pageSize :total=total>
    </el-pagination>
    <el-dialog :title="$t('sm.exitOrder')" width="400px" :visible.sync="dialogFormVisible">
        <el-form :model="exitMsg" label-width="80px">

            <el-form-item :label="$t('sm.exitType')">
                <el-select size="small" v-model="exitMsg.cancel_type" :placeholder="$t('pub.pleaseSel')">
                    <el-option :label="$t('sm.xingchengbghqx')" value="MC001"></el-option>
                    <el-option :label="$t('sm.chongfuOrder')" value="MC002"></el-option>
                    <el-option :label="$t('sm.Priceyy')" value="MC003"></el-option>
                    <el-option :label="$t('sm.gerenys')" value="MC004"></el-option>
                    <el-option :label="$t('sm.jiaotongys')" value="MC005"></el-option>
                    <el-option :label="$t('sm.jiaotongys')" value="MC006"></el-option>
                    <el-option :label="$t('active.cl_qita')" value="MC999"></el-option>

                </el-select>
            </el-form-item>
            <el-form-item :label="$t('sm.exityy')" >
                <el-input v-model="exitMsg.cancel_desc" autocomplete="off" type="textarea" :rows="2"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button size="small" @click="dialogFormVisible = false">{{$t('pub.cancelBtn')}}</el-button>
            <el-button size="small" type="danger" @click="ExitOrder">{{$t('pub.sureBtn')}}</el-button>
        </div>
        </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dialogFormVisible:false,
      exitMsg:{
          orderId:'',
          cancel_type:"",
          cancel_desc:"",
          CancelBy:'',
      },
      msg: {
          pageIndex:1,
          pageSize:10,
          searchKey:"",
          rbBranchId:-1,
          startDate:"",
          endDate:"",
          status:0,
      },
      TCID: '',
      GLOrderID: '',
      total:0,
      currentPage: 1,
      loading:false,
      StartTimeBefore: {
        disabledDate: time => {
            if (this.msg.EndTime == null) {
                return false;
            } else {
                let endTime = new Date(this.msg.EndTime)
                return endTime.getTime() < time.getTime()
            }
        }
      },
      EndTimeAfter: {
        disabledDate: time => {
            let startTime = new Date(this.msg.StartTime)
            return startTime.getTime() >= time.getTime()
        }
      },
      CStartTimeBefore: {
        disabledDate: time => {
            if (this.msg.CEndTime == null) {
                return false;
            } else {
                let endTime = new Date(this.msg.CEndTime)
                return endTime.getTime() < time.getTime()
            }
        }
      },
      CEndTimeAfter: {
        disabledDate: time => {
            let startTime = new Date(this.msg.CStartTime)
            return startTime.getTime() >= time.getTime()
        }
      },

      orderStatus:[{
          Name:this.$t('pub.normalSel'),
          Id:0
        },{
            Name:this.$t('pub.cancelBtn'),
            Id:1
        },{
            Name:this.$t('sm.daifukuan'),
            Id:2
        }],
      dataList: [],
      getCompanyMsg:{  // 公司
        RB_Group_Id:'0',
        Status:'0',
      },
      getDepartmentMsg:{// 部门
        RB_Group_Id:'',
        RB_Branch_Id:'',
        Status:0,
        ParentId:-1,
        Tier:0,
      },
      employeeMsg:{ // 员工
        GroupId:'',
        BranchId:-1,
        DepartmentId:0,
        PostId:0,
        IsLeave:0,
      },
      CompanyList:[],
      DepartmentList:[],
      EmployeeList:[],
      searchList: [],
      loading2: false,
      dialogFormVisible: false,
    };
  },
  methods: {
    Exit(item){
      let userInfo = this.getLocalStorage();
      this.dialogFormVisible=true;
      this.exitMsg.orderId=item.OrderID;
      this.exitMsg.CancelBy=userInfo.EmployeeId;
    },
    ExitOrder(){
          if(this.exitMsg.cancel_type==""){
              this.Error(this.$t('sm.qxzqxlx'));
              return;
          }

          this.apipost(
        "dmc_post_Get_KKDayOrderCancel",
        this.exitMsg,
        res => {
          if (res.data.resultCode == 1) {
            this.Success(res.data.message);
            this.$emit('queryDays')
            this.exitMsg={
                orderId:'',
                cancel_type:"",
                cancel_desc:"",
                CancelBy:'',
            };
          } else {
            this.$message.error(res.data.message);
          }
          this.dialogFormVisible=false;
        },
        null
      );
      },
    GotoUrl(TCNUM) {
      this.$router.push({
        path: "TravelControlList",
        query: {
          tcmun: TCNUM,
          blank: 'y',
          tab: "团控查询",
        }
      });
    },
    querenGL(){
      this.apipost("dmc_post_get_RelevanceTCID",{ TCID: this.TCID, OrderID: this.GLOrderID },res => {
        if (res.data.resultCode == 1) {
          this.Success(res.data.message);
          this.getList();
          this.dialogFormVisible = false
        }
      },err => {});
    },
    closeChangeMachie(done) {  //  弹=窗口关闭
      done();
    },
    remoteMethodTCNum(query) {
      if (query !== ''||this.addShow) {
        this.loading2 = true;
        this.apipost("InvoiceApply_get_GetPriceList",{ TCNUM:query },res => {
          if (res.data.resultCode == 1) {
            this.searchList = res.data.data;
            this.loading2 = false;
          }
        },err => {});
      } else {
        this.searchList = [];
        this.loading2 = false;
      }
    },
    queren(type, OrderID){
      let text = type == 1 ? this.$t('sm.qrhOrderbhzdqx'): this.$t('sm.qxhddhzdqx')
      this.$confirm(text, this.$t('tips.tips'), {
          confirmButtonText: this.$t('pub.sureBtn'),
          cancelButtonText: this.$t('pub.cancelBtn'),
          type: 'warning'
      }).then(() => {
          this.apipost('KKDayOrder_Post_UpdateOrderCanClear',{OrderID: OrderID, IsCanClear: type},res=>{
              if(res.data.resultCode==1){
                  this.Success(res.data.message);
                  this.getList();
              }else{
                  this.Error(res.data.message);
              }
          },err=>{})
      }).catch(() => {
          this.$message({
              type: 'info',
              message: this.$t('ios.yi') + this.$t('pub.cancelBtn')
          });
      });
    },
    goOrderDetails(ID){
      this.$router.push({
        name: 'scenOrderDetails',
        query: {
          ID: ID,
          blank:'y',
        }
      })
    },
    getList() {
      //获取列表
      this.loading = true;
      this.apiJavaPost("/api/erp/ticketCoupons/getTicketCouponsOrder", this.msg, res => {
        this.loading = false;
        if (res.data.resultCode === 1) {
          this.dataList = res.data.data.pageData;
          this.total=res.data.data.count;
        } else {
          this.Error(res.data.message)
        }
      }, null);
    },
    handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
    },
    resetPageIndex() {
        this.msg.pageIndex = 1;
        this.currentPage = 1
    },
    getCompanyList: function () { //获取公司列表
      this.apipost('admin_get_BranchGetList',this.getCompanyMsg,res=>{
        if(res.data.resultCode==1){
          this.CompanyList=res.data.data;
        }else{}
      },err=>{})
    },
    getDepartment: function () {  //获取部门列表
      this.apipost('admin_get_DepartmentGetList', this.getDepartmentMsg, res => {
        if(res.data.resultCode == 1) {
          this.DepartmentList = res.data.data;
        }
      }, err => {})
    },
    getEmployee() { //员工
      this.apipost('admin_get_EmployeeGetList', this.employeeMsg, res => {
        if(res.data.resultCode == 1) {
          this.EmployeeList = res.data.data;
        }
      }, err => {})
    },
   //点击取消操作
   cancelHTorder(ThirdOrderNo){
      let userInfo = this.getLocalStorage();
      let EmployeeId = userInfo.EmployeeId;
      let msg ={
          bookingNumber:ThirdOrderNo,
          CancelBy:EmployeeId,
          CancelType:1
      }
      this.apipost(
      "dmc_post_Get_GetJAPAN_GetJAPAN_ReservationCancallation",
      msg,
      res => {
        if (res.data.resultCode == 1) {
            this.Success(this.$t('sm.quxiaocg'));
            this.getList();
        } else {
          this.Error(res.data.message);
        }
      },
      null
    );
   },
   //点击收款
   getShouKuan(obj){
     let TCIDARR = obj.TCID ? [obj.TCID] : [];
      let orderObj = {
        OrderID:obj.id,
        OrderSource: 3,
        Obj: {},
        SourceID:null,
        TCIDList: TCIDARR
      }
      this.$router.push({
        name: 'ChoiceAddFinancialDocuments',
        query:{
          "Type":1,
          "companyID":obj.RbBranchId,
          "path": "",
          'blank':'y',
          'orderObj':JSON.stringify(orderObj),
          'tradeWay':1,
          'platformAccount':0
        }
      });
   },
   //跳转财务单据
   goUrlFinacel: function(name, path, id) {
      this.$router.push({
        name: path,
        query: { id: id, blank: "y", tab: name }
      });
   }
  },
  mounted() {
    let userInfo=this.getLocalStorage();
    this.getCompanyMsg.RB_Group_Id = userInfo.RB_Group_id;    //集团
    this.getDepartmentMsg.RB_Branch_Id = userInfo.RB_Branch_id;   //公司
    this.msg.enterID = userInfo.EmployeeId;
    // this.msg.enterID = 2070;
    this.getCompanyList()
    // this.getDepartment()
    // this.getEmployee()
    this.getList();
  }
};
</script>

