<style>
  @import "../../../assets/css/newTravelManager.css";
</style>
<template>
  <div>
    <div class="TC_Content TC-MyList">
      <div class="query-box">
        <ul>
          <li>
            <span>
              <em>所属线路</em>
              <el-select class='w150' v-model="queryMsg.LineId" filterable :placeholder="$t('pub.pleaseSel')" @change="getLineTeamList()">
                <el-option :label="$t('pub.unlimitedSel')" :value='queryCommonData.SelectDefaultValue'></el-option>
                <el-option v-for="item in queryCommonData.LineList" :label='item.LineName' :value='item.LineID' :key='item.LineID'>
                </el-option>
              </el-select>
            </span>
          </li>
          <li>
            <span>
              <em>系列名称</em>
              <el-select class='w150' v-model="queryMsg.LineteamId" filterable :placeholder="$t('pub.pleaseSel')">
                <el-option :label="$t('pub.unlimitedSel')" :value='queryCommonData.SelectDefaultValue'></el-option>
                <el-option v-for="item in queryCommonData.LineTeamList" :label='item.LtName' :value='item.LtID' :key='item.LtID'>
                </el-option>
              </el-select>
            </span>
          </li>
          <li>
            <span>
              <em>团号</em>
               <el-input maxlength="50" v-model="queryMsg.TCNUMS" class="permiss-input w150" 
                :placeholder="$t('pub.pleaseImport')"></el-input>
            </span>
          </li>
          <li>
            <span>
              <em>操作人</em>
              <el-select class='w150' v-model="queryMsg.CreateBy" filterable :placeholder="$t('pub.pleaseSel')">
                <el-option :label="$t('pub.unlimitedSel')" :value='queryCommonData.SelectDefaultValue'></el-option>
                <el-option v-for="item in queryCommonData.EmployeeList" :label='item.EmName' :value='item.EmployeeId'
                  :key='item.EmployeeId'>
                </el-option>
              </el-select>
            </span>
          </li>
          <li>
            <button class="hollowFixedBtn" @click="getControlList(),resetPageIndex()">{{$t('pub.searchBtn')}}</button>
          </li>
        </ul>
      </div>
      <div class="TravelTclList" v-loading="queryCommonData.loading" :element-loading-text="queryCommonData.loadingText">
        <ul>
          <el-pagination background @current-change="handleCurrentChange" :current-page.sync="queryMsg.currentPage"
            layout="total,prev, pager, next, jumper" :page-size='queryMsg.pageSize' :total='queryMsg.total'>
          </el-pagination>
          <li v-for="(item,index) in queryCommonData.dataList" :key="index" :class="{'TC_hasContent':item.OPInnerRemark==''&&item.OPRemark==''}">
            <div :data-id="item.ID">
              <div class="el-col" style="position:relative;width:200px">
                <div v-if="item.IsWarning===1" class="travel_warning"></div>
                <div>
                  <div class="TCL-TOPTCNUM">{{item.TCNUM}}</div>
                  <div class="d12" style="float:none;margin-top:10px">
                    <p><i class="iconfont icon-biaoti1"></i>{{item.LineName}}</p>
                    <p class="d12p">{{item.LtName}}</p>
                  </div>
                </div>
              </div>
              <div class="el-col" style="width:220px;">
                <div class="d3">
                  <p><i class="iconfont icon-tuandui"></i>团队信息</p>
                  <p><em>{{item.DayNum}}天{{item.NightNum}}晚</em></p>
                </div>
              </div>
              <div class="el-col" style="width:220px;">
                <div class="d3">
                  <p><i class="iconfont icon-tuandui"></i>团期信息</p>
                  <p class="d12p">{{item.TCNUMS}}</p>
                </div>
              </div>
              <div class="el-col" style="width:130px;">
                <div class="d5 TC-oparation" style="padding-top:10px;">
                  <p><i class="iconfont icon-yuangong"></i>设计人员</p>
                  <div class="clearfix TC-OpInfo">
                    <div class="TC-leftIMG">
                      <img v-if="item.OPPhoto" :src="item.OPPhoto" alt="">
                      <img v-else src="../../../assets/img/default_head_img.jpg" alt="">
                    </div>
                    <div class="TC-OPName">{{item.CreateUserName}}</div>
                  </div>
                </div>
              </div>
              <div class="el-col">
                <div class="d7">
                  <el-button v-if="item.CreateBy==CurrentUserId" @click="goToOpenTravel('TravelManager3',item.ID)" type="primary">行程修改</el-button>
                  <el-button @click="copyTravelInfo(item.ID)" type="primary">行程复制</el-button>
                  <el-button v-if="item.TCNUMS==''&&item.CreateBy==CurrentUserId" @click="delConfig(item.ID)" type="primary">删除</el-button>
                </div>
              </div>
            </div>
            <div class="TC_remarkContent">
              <div class="clearfix">
                <div class="TCL_remarkTitle TCL-redType">团名:</div>
                <div class="TCL_Content">{{item.Title}}</div>
              </div>
            </div>
          </li>
        </ul>
        <div class="noData" v-show="queryMsg.noData">
          {{$t('system.content_noData')}}
        </div>
        <el-pagination background @current-change="handleCurrentChange" :current-page.sync="queryMsg.currentPage"
          layout="total,prev, pager, next, jumper" :page-size='queryMsg.pageSize' :total='queryMsg.total'>
        </el-pagination>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        //查询数据列表
        queryCommonData: {
          //线路列表
          LineList: [],
          //系列列表
          LineTeamList: [],
          //下拉框默认值
          SelectDefaultValue: 0,
          //数据列表
          dataList: [],
          loading: false,
          loadingText: "",
          //员工列表
          EmployeeList: [],
        },
        //查询参数
        queryMsg: {
          pageIndex: 1,
          pageSize: 10,
          LineId: 0,
          LineteamId: 0,
          CreateBy: 0,
          TeamType: 1,
          TCNUMS:""
        },
        //当前用户id
        CurrentUserId: 0,
        remarkMsg: {
          TCID: 0,
          OPRemark: "",
          OPInnerRemark: ""
        },
        flightStatus: [{
          Id: 0,
          Name: '不限',
          Checked: false
        }, {
          Id: 1,
          Name: '已配置',
          Checked: true
        }, {
          Id: 2,
          Name: '未配置',
          Checked: false
        }],
        pickerBeginDateBefore: {
          disabledDate: time => {
            let endTime = new Date(this.queryMsg.EndGroupDate);
            return endTime.getTime() < time.getTime();
          }
        },
        pickerBeginDateAfter: {
          disabledDate: time => {
            let startTime = new Date(this.queryMsg.StartGroupDate);
            return startTime.getTime() >= time.getTime();
          }
        }
      };
    },
    methods: {
      //翻页
      handleCurrentChange(val) {
        this.queryMsg.pageIndex = val;
        this.getControlList();
      },
      //重新查询
      resetPageIndex() {
        this.queryMsg.pageIndex = 1;
        this.queryMsg.currentPage = 1;
      },
            //删除行程
      delConfig(ID) {
        var that = this;
        this.Confirm("删除过后数据不能恢复,请谨慎操作", function () {
          let msg = {
            ID: ID,
          };
          that.apipost(
            "travel_post_RemoveConfig",
            msg,
            res => {
              if (res.data.resultCode == 1) {
                that.Success("删除成功");
                that.getControlList();
              } else {
                that.Error(res.data.message);
              }
            },
            null
          );
        });
      },
      //获取线路列表
      getLineList() {
        this.apipost("line_post_GetAllList", {}, res => {
          if (res.data.resultCode == 1) {
            this.queryCommonData.LineList = res.data.data;
          }
        });
      },
      //获取系列列表
      getLineTeamList() {
        this.queryMsg.LineteamId = 0;
        let msg = {
          lineID: this.queryMsg.LineId,
          isTOOP: 1
        };
        this.apipost("team_post_GetList", msg, res => {
          if (res.data.resultCode == 1) {
            this.queryCommonData.LineTeamList = res.data.data;
          }
        });
      },
      //新获取列表数据
      getControlList() {
        var msg = JSON.parse(JSON.stringify(this.queryMsg));
        this.queryCommonData.loading = true;
        this.apipost(
          "travel_get_GetTravelV2PageList",
          msg,
          res => {
            this.queryCommonData.loading = false;
            if (res.data.resultCode == 1) {
              this.queryCommonData.dataList = res.data.data.pageData;
              this.queryMsg.total = res.data.data.count;
              this.queryMsg.noData = !this.queryMsg.total > 0;
            }
          },
          err => {}
        );
      },
      //开团或修改
      goToOpenTravel(path, configId) {
        if (configId > 0) {
          this.$store.commit("pageConditionUpdate", this.queryMsg);
          this.$router.push({
            name: path,
            query: {
              configId: configId,
              flag: true,
              openState: 1,
              blank: 'y',
              tab: '团期配置'
            }
          });
        } else {
          this.$router.push({
            name: path
          });
        }
      },
      //行程复制
      copyTravelInfo(configId) {
        var that = this;
        if (configId > 0) {
          that.Confirm("是否要复制?", function () {
            var msg = {
              targetConfigId: configId
            };
            that.queryCommonData.loading = true;
            that.queryCommonData.loadingText = "正在复制请稍后....";
            that.apipost(
              "travel_post_CopyTravelConfigInfo",
              msg,
              res => {
                that.queryCommonData.loading = false;
                that.queryCommonData.loadingText = "";
                if (res.data.resultCode == 1) {
                  that.getControlList();
                }
              },
              err => {}
            );
          });

        }
      },
      //根据当前员工所在部门获取该部门及子部门员工信息
      getEmployeeList() {
        let userInfo = this.getLocalStorage();
        let msg = {
          GroupId: userInfo.RB_Group_id,
          BranchId: "-1",
          DepartmentId: "-1",
          PostId: "-1",
          IsLeave: "0"
        };
        this.apipost(
          "admin_get_EmployeeGetList", {},
          res => {
            if (res.data.resultCode == 1) {
              this.queryCommonData.EmployeeList = res.data.data;
            }
          },
          err => {}
        );
      },
    },
    mounted() {
      let UserInfo = this.getLocalStorage();
      this.CurrentUserId = UserInfo.EmployeeId;
      this.getEmployeeList();
      this.getLineList();
    },
    created() {
      this.getControlList();
    },
  };

</script>