<style>
  .BusedHeight {
    display: block !important;
    height: 550px;
  }
  .FinaceItem span{
    display: inline-block;
    color:#3980C8;
    margin-right:10px;
    padding-right: 10px;
    border-right:1px solid #d1d1d1;
  }
  .FinaceItem span:last-child{
    border:0;
  }
  .BusApportionManagement ._bus_edit {
    overflow: auto;
    display: none;
    position: absolute;
    font-family: "PingFangSc-Fine";
    bottom: 0;
    left: 0;
    border-top: 3px solid #38425d;
    background-color: #ffffff;
    padding: 10px;
    width: 100%;
  }
  .teamNumCon{
    width:100%;
    min-height:50px;
    margin:0 110px;
  }
  .teamNumList{
    display:inline-block;
    padding:3px 8px;
    border-radius:4px;
    font-size:12px;
    background-color: #EEEEEE;
    position: relative;
    margin-right:20px;
  }
  .teamNumList i{
    color:#C5C5C5;
    position: absolute;
    right:-10px;
    top:-10px;
  }
  .teamNumList i:hover{
    color:#CD2929;
    cursor: pointer;
  }
  .exportCompany{
    width:450px;
  }
    .BusApportionManagement ._addUpload_box{
        display: block;
        margin-top: 15px;
    }
    .BusApportionManagement ._addUpload_box img{
        width: 100%;
    }
    .BusApportionManagement ._addUpload_box>div{
        float: left;
        width:138px;
        height:92px;
        border:1px dashed rgba(210,210,210,1);
        border-radius:2px;
        cursor: pointer;
        padding: 5px;
        margin-right: 10px;
        position: relative;
    }
    .BusApportionManagement ._addUpload_box>div:hover{
        background-color: #f5f5f5;
    }
    .BusApportionManagement ._addFile_name{
        padding-left: 15px;
        max-width: 450px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .BusApportionManagement ._addUpload_box .icon-guanbi1 {
        font-size: 12px;
        color: white;
        display: inline-block;
        margin-left: 15px;
        position: absolute;
        right: -6px;
        top: -9px;
        background-color: #f56c6c;
        border-radius: 50%;
        height: 20px;
        width: 20px;
        text-align: center;
        line-height: 20px;
    }
    .BusApportionManagement ._addUpload_box .icon-guanbi1:hover {
        font-size: 12px;
        color: #c94052;
    }
    .BusApportionManagement ._addUpload_box .icon-excel,._addUpload_box .icon-pdf{
        text-align: center;
        font-size: 38px;
        color: green;
        line-height: 75px;
    }
    .BusApportionManagement .el-upload-dragger{
        width:126px!important;
        height:80px!important;
    }
    .BusApportionManagement ._show_img_box{
      position: fixed;
      background: rgba(0,0,0,.6);
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      z-index: 999;
      text-align: center;
    }
</style>

<template>
  <div class="flexOne BusApportionManagement">
    <div class="query-box">
      <ul>
        <li>
          <input type="button" class="normalBtn" @click="outerVisible=true" :value="$t('ground.chezdaochu')"/>
          <input type="button" class="normalBtn" @click="getInfo()" :value="$t('pub.addBtn')"/>
        </li>
      </ul>
    </div>
    <v-table
      v-if="isReady"
      is-horizontal-resize
      column-width-drag
      style="width:100%"
      :columns="columns"
      :table-data="dataList"
      :filter-method="filterMethod"
      :total="total"
      :pageSize="msg.pageSize"
      :pageIndex="msg.pageIndex"
      :handleCurrentChange="handleCurrentChanges"
      :multiple-sort="multipleSort"
      :is-loading="loading"
      sort-always
      @sort-change="sortChange"
      @on-custom-comp='customCompFunc'
    ></v-table>
    <div class="_bus_edit _scrollbar" v-if="addShow" :class="addShow==true?'BusedHeight':''">
      <el-row>
        <el-col :span="21">
          <p class="_tit">{{$t('ground.tjiaft')}}</p>
        </el-col>
        <el-col :span="3" class="_add_saveBtn">
          <button
            type="button"
            class="normalBtn"
            @click="submitForm('addMsg',1)"
          >{{$t('pub.saveBtn')}}</button>
          <button
            class="hollowFixedBtn"
            type="button"
            @click="resetForm('addMsg'),addShow=false"
          >{{$t('pub.cancelBtn')}}</button>
        </el-col>
      </el-row>
      <el-form
        class="_info_box clearfix"
        :model="addMsg"
        ref="addMsg"
        :rules="rules"
        label-width="110px"
      >
        <el-row>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('salesModule.CostType')">
              <el-select v-model="isCked" disabled>
                <el-option :label="$t('ground.chezi')" value=1></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.djleixing')">
              <el-select v-model="isCked" disabled>
                <el-option :label="$t('ground.cantuan')" value=1></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('hotel.hotel_Supplier')">
              <el-select v-model="suppierCked" disabled>
                <el-option v-for='item in ClientTypeList'
                    :label='item.Name'
                    :value='item.ID'
                    :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.khmingcheng')">
              <el-select filterable  v-model='customId' :placeholder="$t('fnc.khmingcheng')" @change="GetClientAccountList(customId)" class="_border_b_1">
                  <el-option :value="0" :label="$t('pub.unlimitedSel')"></el-option>
                  <el-option v-for='item in ClientAccountList'
                      :label='item.Name'
                      :value='item.ID'
                      :key='item.ID'>
                  </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.fkzhanghu')">
              <el-select  filterable  v-model='addMsg.ClientID' :placeholder="$t('fnc.qxzfkzh')"  class="_border_b_1">
                  <el-option :value="0" :label="$t('pub.unlimitedSel')"></el-option>
                  <el-option v-for='item in ClientAccountListS'
                      :label='item.allName'
                      :value='item.ID'
                      :key='item.ID'>
                  </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('ground.chepeihao')">
              <el-date-picker class="w200"
                  v-model="Year"
                  type="year"
                  :placeholder="$t('pub.pleaseSel')">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item prop="CarNum">
                <el-input v-model="addMsg.CarNum" maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <button type="button" class="normalBtn" style="margin:5px 0 0 50px;" @click="getTeamInfo">{{$t('ground.sxuantd')}}</button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.jine')" prop="f_UnitPrice">
                <el-input v-model="addMsg.f_UnitPrice" :placeholder="$t('pub.pleaseImport')" @keyup.native="checkPrice(addMsg,'f_UnitPrice'),getTotalMoney(),getSingelePrice()" maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('hotel.hotel_Currency')">
              <el-select  filterable  v-model='addMsg.f_currency' :placeholder="$t('rule.qxzbzhong')" @change="getRate(addMsg.f_currency)" class=" _border_b_1">
                  <!-- <el-option :value="0" label="不限"></el-option> -->
                  <el-option v-for='item in coinGetList'
                      :label='item.Name'
                      :value='item.ID'
                      :key='item.ID'>
                  </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('hotel.hotel_CurrentRate')">
                <el-input v-model="addMsg.f_rate" :placeholder="$t('pub.pleaseImport')" @keyup.native="checkRate(addMsg,'f_rate'),getTotalMoney()" maxlength="20" class="w90"></el-input>
                <el-input  disabled class="w100" v-model="TotalMoney"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('op.TotalMoney')">
                <el-input  disabled v-model="TotalMoney"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('restaurant.res_Number')" prop="CarNumber">
                <el-input v-model="addMsg.CarNumber" :placeholder="$t('pub.pleaseImport')" @keyup.native="checkInteger(addMsg,'CarNumber'),getSingelePrice()" maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.danjia')">
                <el-input v-model="addMsg.CarUnitPrice" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('sm.jieji')">
                <el-input v-model="addMsg.JJPrice" @keyup.native="checkInteger(addMsg,'JJPrice'),getSingelePrice()" :placeholder="$t('pub.pleaseImport')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('ground.huisong')">
                <el-input v-model="addMsg.HSPrice" :placeholder="$t('pub.pleaseImport')" @keyup.native="checkInteger(addMsg,'HSPrice'),getSingelePrice()"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('sm.songji')">
                <el-input v-model="addMsg.SJPrice" :placeholder="$t('pub.pleaseImport')" @keyup.native="checkInteger(addMsg,'SJPrice'),getSingelePrice()"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('ground.zhuanji')">
                <el-input v-model="addMsg.ZJiPrice" :placeholder="$t('pub.pleaseImport')" @keyup.native="checkInteger(addMsg,'ZJiPrice'),getSingelePrice()"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('ground.zhuijia')">
                <el-input v-model="addMsg.ZJPrice" :placeholder="$t('pub.pleaseImport')" @keyup.native="checkInteger(addMsg,'ZJPrice'),getSingelePrice()"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('ground.dqjsr')" prop="PayDate">
                <el-date-picker type="date" class="w200" v-model="addMsg.PayDate" value-format="yyyy-MM-dd"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8" :gutter="35">
            <el-form-item :label="$t('ground.zdanbeizhu')">
                <el-input v-model="addMsg.Remark" type="textarea" rows="2" :placeholder="$t('pub.pleaseImport')"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
            <el-col :span="4" :gutter="35">
              <el-form-item :label="$t('scen.sc_temID')">
                  <el-input :placeholder="$t('pub.pleaseImport')" v-model="TCIDS"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4" :gutter="35">
              <button type="button" class="normalBtn" style="margin:5px 0 0 60px;" @click="checkIsUse">{{$t('ground.tjtuanhao')}}</button>
            </el-col>
            <el-col :span="12" :gutter="35">
            <el-form-item label="上传凭证">
                    <div class="_addUpload_box clearfix" >
                        <template v-for="(file,fIndex) in saveMsg">
                            <div v-if="file.Type==3">
                                <div style="width:100%;height:100%;overflow: hidden;">
                                    <img :src="file.Url?file.Url:file.Content" @click="showUpLoadFile(file)">
                                </div>
                                <span class="iconfont icon-guanbi1" @click="deleteUploadFile(fIndex)"></span>
                            </div>
                            <div v-if="file.Type==1">
                              <div class="iconfont " :class="file.Content.substring(file.Content.lastIndexOf('.')+1,file.Content.length).toUpperCase()=='PDF'? 'icon-pdf' : 'icon-excel'"  @click="showUpLoadFile(file)">

                              </div>
                              <span class="iconfont icon-guanbi1" @click="deleteUploadFile(fIndex)"></span>
                            </div>
                            <div v-if="file.Type==2">
                                <div class="iconfont icon-excel"  @click="showUpLoadFile(file)">

                                </div>
                                <span class="iconfont icon-guanbi1" @click="deleteUploadFile(fIndex)"></span>
                            </div>
                        </template>
                        <div class="_pic_upload">
                            <el-upload
                            drag
                            :http-request="uploadFileBtn"
                            :multiple="true"  :show-file-list="false"  action="">
                            <i class="el-icon-plus avatar-uploader-icon"></i>
                            <div class="el-upload__text">{{$t('active.ld_djscwj')}}</div>
                            </el-upload>
                        </div>
                    </div>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
            <el-col :span="20" :gutter="35">
              <div class="teamNumCon">
                  <span class="teamNumList" v-for="(item,index) in allTeamList">{{item.TCID}} <i @click="removeTeam(index)" class="iconfont icon-quxiao"></i></span>
              </div>
            </el-col>
        </el-row>
      </el-form>
    </div>

    <el-dialog custom-class='exportCompany' title="选择信息" :visible.sync="outerVisible" center>
      <el-form label-width="100px">
        <el-form-item :label="$t('ground.dchuyuefen')">
          <el-date-picker
            v-model="exportInfo.DCDate"
            type="month"
            value-format="yyyy-MM"
            :placeholder="$t('ground.xuanzeyue')">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('fnc.zdriqi')">
            <el-date-picker type="date" v-model="exportInfo.StartGroupDate"
                            :picker-options="pickerBeginDateBefore"
                            value-format="yyyy-MM-dd" placeholder></el-date-picker>
            <el-date-picker type="date" v-model="exportInfo.EndGroupDate"
                            :picker-options="pickerBeginDateAfter"
                            value-format="yyyy-MM-dd" placeholder></el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('hotel.hotel_Currency')" class='multiple_input countryList'>
            <el-select  filterable  v-model='exportInfo.CurrType' :placeholder="$t('rule.qxzbzhong')" class=" _border_b_1">
                <el-option v-for='item in coinGetList'
                    :label='item.Name'
                    :value='item.ID'
                    :key='item.ID'>
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item :label="$t('fnc.khmingcheng')" class='multiple_input countryList'>
            <el-select filterable  v-model='exportInfo.ClientId' :placeholder="$t('rule.qxzkhmingcheng')"  class=" _border_b_1">
                  <el-option :value="0" :label="$t('pub.unlimitedSel')"></el-option>
                  <el-option v-for='item in ClientAccountList'
                      :label='item.Name'
                      :value='item.ID'
                      :key='item.ID'>
                  </el-option>
              </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <button class="normalBtn" type="primary" @click="goToExport('BusExport')">{{$t('pub.saveBtn')}}</button> &nbsp;
        <button class="hollowFixedBtn" @click="outerVisible = false,clearDialog()">{{$t('pub.cancelBtn')}}</button>
      </div>
    </el-dialog>

    <div v-if='picIsShow' class="_show_img_box" @click="picIsShow=false,picObj=[]">
        <div style="position: absolute; width: 800px; height: 600px; left: 50%; top: 50%; margin-left: -400px; margin-top: -300px;">
            <el-carousel :initial-index=initialIndex height="600px" :interval="5000" trigger="click">
            <el-carousel-item style="height: 600px;overflow:auto;"  v-for="(item,index) in picObj" :key="index">
                <img :src="item"  style=""/>
            </el-carousel-item>
            </el-carousel>
        </div>
    </div>

  </div>
</template>
<script>
import Vue from 'vue'
export default {
    data(){
        return {
            columns: [],
            remoteLoading:false,
            total: 0,
            isReady: false,
            multipleSort: false,
            loading: true,
            outerVisible:false,
            msg: {
                pageSize:15,
                pageIndex:1,
                CarDistribution:'',
                StartTime:'',
                EndTime:''
            },
            addMsg:{
              TCIDStr:'',
              CarNum:'',
              f_UnitPrice:'',
              CarNumber:'',
              CarUnitPrice:'',
              JJPrice:'',
              HSPrice:'',
              ZJPrice:'',
              SJPrice:'',
              ZJiPrice:'',
              f_currency:1,
              f_rate:'',
              ClientID:0,
              PayDate:'',
              Remark:'',
              VorList:[]
            },
            dataList: [],
            total: 0,
            currentPage: 1,
            loading: true,
            text: "",
            dialogTitle: "",
            noData: false,
            addShow: false,
            //验证规则
            rules:{
                f_UnitPrice: [{ required: true, message:this.$t('rule.qsrjine'), trigger: "blur" }],
                CarNumber: [{ required: true, message:this.$t('rule.EnterNum'), trigger: "blur" }],
                PayDate: [{ required: true, message:this.$t('ground.qxzdqr'), trigger: "blur" }],
                CarNum: [{ required: true, message:this.$t('ground.qtxcphao'), trigger: "blur" }],
            },
            isCked:'1',
            //供应商下拉
            ClientTypeList:[],
            //账户类型
            ClientAccountList:[],
            //付款账户
            ClientAccountListS:[],
            //供应商默认选中
            suppierCked:4,
            //客户名称选中ID
            customId:0,
            //车配号 年
            Year:'',
            //币种下拉
            coinGetList:[],
            //总价
            TotalMoney:'',
            //全部团队编号
            allTeamList:[],
            //TCID
            TCIDS:'',
            //团队编号
            TCIDList:{
              TCID:'',
              TCNUM:""
            },
            //弹窗导出信息
            exportInfo:{
              DCDate:'',
              StartGroupDate:'',
              EndGroupDate:'',
              CurrType:3,
              ClientId:0
            },
            //上传数组
            saveMsg:[],
            picIsShow:false,
            picObj:[],
            imgList:[],
            pickerBeginDateBefore: {
              disabledDate: time => {
                let endTime = new Date(this.exportInfo.EndGroupDate)
                return endTime.getTime() < time.getTime()
              }
            },
            pickerBeginDateAfter: {
              disabledDate: time => {
                let startTime = new Date(this.exportInfo.StartGroupDate)
                return startTime.getTime() >= time.getTime()
              }
            }
        };
    },
    methods: {
        initColums() {
            this.isReady = false;
            let that = this;
            let License = {
                title: this.$t('ground.chepeihao'),
                field: "CarDistribution",
                width: 80,
                titleAlign: "left",
                columnAlign: "left",
                isResize: true,
                result: "",
                filterMultiple: false,
                filters: [{}],
                type: "text"
            };
            let ShareDate = {
                field: "CreateTime",
                title: this.$t('ground.fentanrq'),
                width: 40,
                titleAlign: "left",
                columnAlign: "left",
                isResize: true,
                result:{},
                filterMultiple:false,
                filters: [{}],
                type:'datetime'
            };
            let Details = {
                field: "Description",
                title: this.$t('fnc.xiangqing'),
                width: 80,
                titleAlign: "left",
                columnAlign: "left",
                isResize: true,
                // result: "",
                // filterMultiple: false,
                // filters: [{}],
                // type: "text"
            };
            let ShareTeam = {
                field: "TCIDList",
                title: this.$t('ground.fentandetuan'),
                titleAlign: "left",
                columnAlign: "left",
                isResize: true,
                width: 80,
                componentName:'table-teamList'
                // orderBy: "desc",
                // filterMultiple: false,
                // filters: [{}],
                // type: "text"
            };
            let ProductDoc = {
                field: "FinanceIdList",
                title: this.$t('ground.chanshengdj'),
                titleAlign: "left",
                columnAlign: "left",
                isResize: true,
                width: 80,
                componentName:'table-docment',
                // filterMultiple: true,
                // result: [],
                // filters: [{}],
                // type: "text"
            };
            let operaler = {
                title: this.$t('visa.v_czuser'),
                field: "CreateByName",
                titleAlign: "left",
                columnAlign: "left",
                width: 80,
                isResize: true,
            };
            let Operate = {
                title: this.$t('system.table_operation'),
                titleAlign: "left",
                columnAlign: "left",
                width: 80,
                isResize: false,
                componentName:'table-operation'
            }
            this.columns = [];
            this.columns.push(License);
            this.columns.push(ShareDate);
            this.columns.push(Details);
            this.columns.push(ShareTeam);
            this.columns.push(ProductDoc);
            this.columns.push(operaler);
            this.columns.push(Operate);
            this.isReady = true;
        },
        customCompFunc(params){
            this.financeinfoRemove(params.id,params.text)
        },
        financeinfoRemove(id, text) {
          this.$confirm(
            "是否对" + "“" + text + "”" + "进行删除操作？删除后不可恢复！",
            "提示",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }
          )
            .then(() => {
              this.apipost(
                "bus_post_DelCarfareApportion",
                { CarId: id },
                res => {
                  if (res.data.resultCode == 1) {
                    this.Success(res.data.message);
                    this.getList();
                  } else {
                    this.Error(res.data.message);
                  }
                  this.getList();
                },
                err => {}
              );
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "已取消删除"
              });
            });
        },
        sortChange(param) {
        },
        filterMethod(filters) {
          this.msg.CarDistribution = filters.CarDistribution;
          this.msg.StartTime = filters.CreateTime.beginDate;
          this.msg.EndTime = filters.CreateTime.endDate;
          if(this.msg.StartTime==null){
            this.msg.StartTime='';
          }
          if(this.msg.EndTime==null){
              this.msg.EndTime='';
          }
          this.msg.pageIndex = 1;
          this.getList();
        },
        handleCurrentChanges(val) {
          this.msg.pageIndex = val;
          this.getList();
        },
        getList() {
          this.loading = true;
          this.apipost(
            "bus_get_GetCarfareApportionPageList",
            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
          );
        },
        initAddMsg() {
          //初始化添加、修改数据
          let newMsg = {
              TCIDStr:'',
              CarNum:'',
              f_UnitPrice:'',
              CarNumber:'',
              CarUnitPrice:'',
              JJPrice:'',
              HSPrice:'',
              ZJPrice:'',
              SJPrice:'',
              ZJiPrice:'',
              f_currency:1,
              f_rate:'',
              ClientID:0,
              PayDate:'', 
              Remark:'',
              VorList:[]
          };
          this.Year = '';
          this.TCIDS ='';
          this.allTeamList = [];
          this.saveMsg = [];
          this.addMsg = newMsg;
        },

        resetForm(formName) {
          this.initAddMsg();
          this.$refs[formName].resetFields();
        },
        //获取供应商
        financeinfo_post_GetClientTypeList(){  // 获取对象类型
            this.apipost('financeinfo_post_GetClientTypeList',{}, res => {
                if(res.data.resultCode == 1) {
                    this.ClientTypeList = res.data.data;
                }
            }, err => {})
        },
        //获取客户类型
        financeinfo_post_GetClientAccountList(){  //获取付款 对象类型  新增用
            let msg = {
                ID:0,
                Type:4,
                ObjID:0,
                CardNum:''
            }
            this.apipost('financeinfo_post_GetClientAccountList',msg, res => {
                if(res.data.resultCode == 1) {
                    let data = res.data.data;
                    let ClientAccountList = [];
                    data.forEach(x=>{
                        let obj = {
                            ID:x.ID,
                            Name:x.AccountHolder + `（${x.AccountAlias}）`,
                            Nom:x.CardNum,
                            OpenBankName:x.OpenBankName,
                            ObjID:x.ObjID,
                        }
                        ClientAccountList.push(obj)
                    })
                    this.ClientAccountList = ClientAccountList;
                }
            }, err => {})
        },
        GetClientAccountList(i){    //获取客户名称并且根据费用类型和付款对象获取客户账号
            let msg = {
                ID:i,
                Type:4,
                ObjID:0,
                CardNum:''
            }
            this.addMsg.ClientID=0;
            this.apipost('financeinfo_post_GetClientAccountList',msg, res => {
                if(res.data.resultCode == 1) {
                    let data = res.data.data;
                    let ClientAccountList = [];
                    if(i){
                        data.forEach(x=>{
                            let obj = {
                                ID:x.ID,
                                Name:x.AccountHolder + + `（${x.AccountAlias}）`,
                                Nom:x.CardNum,
                                OpenBankName:x.OpenBankName,
                                allName:x.CardNum+" "+x.OpenBankName,
                                ObjID:x.ObjID,
                            }
                            ClientAccountList.push(obj)
                        })
                        this.ClientAccountListS = ClientAccountList;
                    }
                }
            }, err => {})
        },

        //获取币种
        financeinfo_post_GetList(){
            this.apipost('financeinfo_post_GetList',{Name:''}, res => {
                if(res.data.resultCode == 1) {
                    this.coinGetList = res.data.data;
                }
            }, err => {})
        },
        getRate(ID){  // 根据选择币种获取汇率
            this.coinGetList.forEach(x=>{
                if(x.ID==ID){
                    this.addMsg.f_rate=x.CurrentRate;
                }
            })
            this.getTotalMoney();
        },
        //点击新增
        getInfo(){
          this.addShow = true;
          var rate = this.addMsg.f_currency;
          this.initAddMsg();
          this.getRate(rate);
        },
        //输入金额得到总价
        getTotalMoney(){
          this.TotalMoney = this.addMsg.f_UnitPrice*this.addMsg.f_rate;
        },
        //输入数量 得到单价
        getSingelePrice(){
          if(this.addMsg.f_UnitPrice==''||this.addMsg.CarNumber==''){
            this.addMsg.CarUnitPrice=0.00
          }else{
            if(this.addMsg.JJPrice==''){
              this.addMsg.JJPrice=0;
            }
            if(this.addMsg.HSPrice==''){
              this.addMsg.HSPrice=0;
            }
            if(this.addMsg.ZJPrice==''){
              this.addMsg.ZJPrice=0;
            }
            if(this.addMsg.SJPrice==''){
              this.addMsg.SJPrice=0;
            }
            if(this.addMsg.ZJiPrice==''){
              this.addMsg.ZJiPrice=0;
            }
            var zong = parseFloat(this.addMsg.f_UnitPrice);
            var total = parseInt(this.addMsg.JJPrice)+parseInt(this.addMsg.HSPrice)+parseInt(this.addMsg.ZJPrice)+
            parseInt(this.addMsg.SJPrice)+parseInt(this.addMsg.ZJiPrice);
            this.addMsg.CarUnitPrice = ((zong-total)/this.addMsg.CarNumber).toFixed(2);
          }
        },
        //筛选团队
        getTeamInfo(){
          var Year = new Date(this.Year);
          let msg = {
            Year:Year.getFullYear(),
            CarNum:this.addMsg.CarNum
          }
          this.apipost('bus_get_ScreeningTravelForCarNum',msg, res => {
              if(res.data.resultCode == 1) {
                  this.allTeamList = res.data.data;
              }else{
                this.Error(res.data.message);
              }
          }, err => {})
        },
        //移除团队
        removeTeam(index){
            this.allTeamList.splice(index,1);
        },
        //根据团号 验证该团号是否可以
        checkIsUse(){
           let msg = {
            TCID:this.TCIDS
          }
          this.apipost('bus_get_ValidataTravelState',msg, res => {
              if(res.data.resultCode == 1) {
                  var obj = {
                    TCID:'',
                    TCNUM:""
                  }
                  obj.TCID = this.TCIDS
                  this.allTeamList.push(obj);
              }else{
                this.Error(res.data.message);
              }
            this.TCIDS = '';
          }, err => {})
        },
        //保存
        submitForm(addMsg) {
          //提交创建、修改表单
          this.$refs[addMsg].validate(valid => {
            if (valid) {
               this.saveInfo();
            } else {
              return false;
            }
          });
        },
        //保存信息
        saveInfo(){
          var newArr = [];
          this.allTeamList.forEach(x=>{
              newArr.push(x.TCID);
          })
           var str = "";
          for(var i=0;i<newArr.length;i++){
              str += newArr[i] + ",";
          }
          //去掉最后一个逗号(如果不需要去掉，就不用写)
          if (str.length > 0) {
              str = str.substr(0,str.length - 1);
          }
          this.addMsg.TCIDStr = str;
          this.addMsg.CarNumber = parseInt(this.addMsg.CarNumber);
          this.addMsg.JJPrice = parseFloat(this.addMsg.JJPrice);
          this.addMsg.HSPrice = parseFloat(this.addMsg.HSPrice);
          this.addMsg.ZJPrice = parseFloat(this.addMsg.ZJPrice);
          this.addMsg.SJPrice = parseFloat(this.addMsg.SJPrice);
          this.addMsg.ZJiPrice = parseFloat(this.addMsg.ZJiPrice);
          this.addMsg.f_rate = parseFloat(this.addMsg.f_rate);
          this.apipost('bus_post_SetCarfareApportion',this.addMsg, res => {
              if(res.data.resultCode == 1) {
                  this.addShow = false;
                  this.Success(res.data.message);
                  this.getList();
              }else{
                this.Error(res.data.message);
              }
          }, err => {})

        },
        //清空弹窗
        clearDialog(){
            this.exportInfo.DCDate='',
            this.exportInfo.StartGroupDate='',
            this.exportInfo.EndGroupDate=''
        },
        //跳转打印页面
        goToExport(path){
          
          if(this.exportInfo.DCDate==''||this.exportInfo.MakeStartDate==''){
              this.Error('请选择导出月份或制单日期');
              return;
          }
          let routeData = this.$router.resolve({
            name: path,
            query: {
              Month: this.exportInfo.DCDate,
              MakeStartDate:this.exportInfo.StartGroupDate,
              MakeEndDate:this.exportInfo.EndGroupDate,
              CurrType:this.exportInfo.CurrType,
              ClientId:this.exportInfo.ClientId
            }
          });
           window.open(routeData.href, "_blank");
        },

        showUpLoadFile(i){  // 预览上传文件
            if(i.Type==3){
              this.picObj.push(i.Url);
              this.imgList.push(i.Url);
              this.picIsShow= true;
              // this.hideFlashMan = true;
            }else{
                if(i.Content.substring(i.Content.lastIndexOf('.')+1,i.Content.length).toUpperCase()=='PDF'){ 
                    this.previewPDF(i.Url)
                }else{
                    window.open("https://view.officeapps.live.com/op/view.aspx?src="+i.Url)
                }
            }
        },
        deleteUploadFile(i){  // 删除上传文件
            this.saveMsg.splice(i,1);
            this.addMsg.VorList = this.saveMsg;
        },
        uploadFileBtn(file) { //上传
            if(file.file.size > 1024 * 1024 * 10) {
                this.Error('文件大小不能超过10M！')
                return
            }
            //  1 文档  2 数据 3 图片
            let typeArr=[
                {stringArr:'GIF|JPG|JPEG|PNG|BMP',type:3},
                {stringArr:'DOCX|DOC|XLSX|XLS|PPT|PPTX|PDF',type:1},
            ]
            let ft=file.file.name.substring(file.file.name.lastIndexOf('.')+1,file.file.name.length).toUpperCase();
            let fileTypeNumber = 2;
            let typeOk  = false;
            typeArr.forEach(x=>{
                if(x.stringArr.indexOf(ft)!='-1')
                {
                  fileTypeNumber=x.type
                  typeOk = true;
                }
            })
            if (!typeOk) return this.Error('请上传图片、word、excel类型的文件！');
            let newArr = [];
            newArr.push(file.file)
            let path = "/Upload/Temporary/"
            this.$message.info('上传中...')
            this.UploadSelfFileT(path, newArr, x => {
                let fileSize = file.file.size<1024? file.file.size:(file.file.size / 1024).toFixed(0);
                this.saveMsg.push({
                    Content: x.data.FilePath,
                    ID:0,
                    Type:fileTypeNumber,
                    Url: this.domainManager().ViittoFileUrl + x.data.FilePath,
                })
                this.addMsg.VorList = this.saveMsg;
                this.Success('上传成功');
            });
        },

    },
    mounted(){
      let num = this.$route.query.num;
      if (num) {
        this.msg.CarDistribution = num
      }
      this.getList();
      this.initColums();
      this.financeinfo_post_GetClientTypeList();
      this.financeinfo_post_GetClientAccountList();
      this.financeinfo_post_GetList();
    },
    created(){
        Vue.component('table-docment',{  //产生单据样式
          template:`<div class='FinaceItem'>
                      <span style='cursor:pointer;' @click='goDocment("FinancialDocumentsDetail",item)' v-for='item in rowData.FinanceIdList'>{{item}}</span>
                    </div>`,
            props:{
                rowData:{
                    type:Object
                },
                field:{
                    type:String
                },
                index:{
                    type:Number
                }
            },
            methods:{
              //跳转财务单据
              goDocment(path, id) {
                this.$router.push({ name: path, query: { id: id, blank: 'y', tab: '单据详情'} });
              }
            }
        })
        Vue.component('table-teamList',{  //分摊的团样式
          template:`<div class='FinaceItem'>
                      <span style='cursor:pointer;' @click='goUrlX("productQuery",item)' v-for='item in rowData.TCIDList'>{{item}}</span>
                    </div>`,
            props:{
                rowData:{
                    type:Object
                },
                field:{
                    type:String
                },
                index:{
                    type:Number
                }
            },
            methods:{
              goUrlX (path, id) {
                this.$router.push({
                  name: path,
                  query: {id: id, blank: 'y', tab: '产品查询'}
                })
              },
            }
        })

        //操作按钮
        Vue.component('table-operation',{
          template:`<div style='width:80px;height:40px;background:#fff;text-align:center;position: relative;
          left:-5px;padding-top: 6px;padding-top:6px;'></el-button><el-button type="danger" size='mini' icon="el-icon-delete" circle @click="deleteRow(rowData,index)"></el-button>
          </div>`,
          props:{
              rowData:{
                  type:Object
              },
              field:{
                  type:String
              },
              index:{
                  type:Number
              }
          },
          methods:{
            deleteRow(){
              let params = {type:'delete',id:this.rowData.ID,text:this.rowData.CarDistribution};
              this.$emit('on-custom-comp',params);
            }
          }
        })
    }
}
</script>
