<style>
  .busUsePrice .busList {
    width: 230px;
    height: 270px;
    float: left;
    margin: 0 10px 10px 0;
    background-color: #fff;
    border-radius: 4px;
    font-size: 12px;
    overflow: hidden;
  }

  .busUsePrice .busListTable {
    width: 98%;
    margin: 0px 2px 0px 2px;
  }

  .busUsePrice .busListTable tr td {
    height: 20px;
    line-height: 20px;
  }

  .busUsePrice .busListTop {
    width: 100%;
    position: relative;
    text-align: center;
  }

  .busUsePrice .usePricediv {
    margin: 7px 0 0 20px;
  }

  .busUsePrice .btmAddStore {
    border-top: 1px solid #d1d1d1;
    width: 100%;
    display: none;
    overflow-x: auto;
    overflow-y: auto;
    position: fixed;
    background: #f9f9f9;
    bottom: 0;
  }

  .busUsePrice .changeMsg {
    width: 80%;
  }

  .busUsePrice .changeMsg li {
    float: left;
  }

  .busUsePrice .changeMsg li:first-child {
    margin-left: 20px;
  }

  .busUsePrice .btmTitle {
    padding: 0 10px;
    margin: 20px 0 20px 25px;
    border-left: 3px solid #e95252;
    font-size: 14px;
    color: #000000;
  }

  .busUsePrice .busUsePeople .el-input__inner {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  .busUsePrice .busType {
    margin: 10px 0 0 31px;
    font-size: 14px;
    display: inline-block;
  }

  .busUsePrice .cityBtnList {
    margin: 10px 0 20px 20px;
  }

  .busUsePrice .busUserBtnList {
    width: 100%;
    text-align: center;
    margin-top: 10px;
  }

  .busUsePrice .busListTop img {
    width: 100%;
  }

  .busUsePrice .BusTypeStr {
    position: absolute;
    top: 15px;
    color: #fff;
    font-size: 25px;
    left: 63px;
  }

  .busUsePrice .UPBtn {
    width: 70px;
    height: 23px;
  }

  .busUsePrice .topNotice {
    width: 100%;
    height: 20px;
    font-size: 12px;
    text-align: left;
    margin: 20px 0;
  }

  .busUsePrice .delScien {
    position: absolute;
    right: 10px;
    top: 10px;
    display: none;
  }

  .busUsePrice .delScien:hover {
    color: #f76f6f;
    cursor: pointer;
  }

  .busUsePrice .busList:hover .delScien {
    display: block;
  }

  .busUsePrice .busDiv {
    margin-top: 20px;
  }

  .busUsePrice .busList:hover {
    box-shadow: 0px 0px 20px rgba(191, 191, 191, 1);
    transition: all linear 0.5s;
  }

  .Bus_BtnList {
    text-align: right;
    margin-bottom: 10px;
  }

  .Bus_Spacing {
    margin-left: 24px;
  }

  .busUsePrice .combottomDiv .el-select {
    width: 100%;
  }

</style>
<template>
  <div class="flexOne busUsePrice">
    <div class="query-box" style="border-bottom:0;">
      <ul>
        <li>
          <input type="button" class="normalBtn" @click="addPanel" :value="$t('pub.addBtn')" />
        </li>
      </ul>
    </div>
    <div class="busDiv clearfix" v-loading="loading">
      <table class="singeRowTable">
        <thead>
          <tr>
            <th>
              地区/车辆类型
            </th>
            <th>
              时间
            </th>
            <th>
              接送价格
            </th>
            <th>
              全天价格
            </th>
            <th>
              半天价格
            </th>
            <th>
              每公里价格
            </th>
            <th>
              全天高速
            </th>
            <th>
              接送高速
            </th>
            <th>
              全天茶代
            </th>
            <th>
              接送茶代
            </th>
            <th>
              操作
            </th>
          </tr>
        </thead>
        <tbody v-for="item in dataList" :key="item.subCode">
          <tr>
            <td>
              {{getArea(item.AreaType)}}- {{getBusTypeStr(item.BusType)}}
            </td>
            <td>
              {{item.MonthStr}}
            </td>
            <td>
              {{item.S_ReceivePrice}}
            </td>
            <td>
              {{item.S_AllDayPrice}}
            </td>
            <td>
              {{item.S_HalfDayPrice}}
            </td>
            <td>
              {{item.S_KMPrice}}
            </td>
            <td>
              {{item.S_AllDayHighSpeedFee}}
            </td>
            <td>
              {{item.S_PickUpHighSpeedFee}}
            </td>
            <td>{{item.S_AllDayChaDaiFee}}</td>
            <td>{{item.S_PickUpChaDaiFee}}</td>
            <td>
              <el-row>
                <el-tooltip class="item" effect="dark" content="管理报价" placement="top-start">
                  <el-button type="primary" class="iconfont icon-bianji-smal" circle @click="managePrice(item.Id)">
                  </el-button>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" :content="$t('system.table_delete')" placement="top-start">
                  <el-button type="danger" class="iconfont icon-img_delete_small" circle @click="isdelete(item.Id)">
                  </el-button>
                </el-tooltip>
              </el-row>
            </td>
          </tr>
        </tbody>
        <tfoot>
          <tr>
            <td colspan="11">
              <el-pagination background @current-change="handleCurrentChange" :current-page.sync="msg.currentPage"
                layout="total,prev, pager, next, jumper" :page-size="msg.pageSize" :total="msg.total">
              </el-pagination>
            </td>
          </tr>
        </tfoot>
      </table>
    </div>
    <div class="combottomDiv" v-if="isShow">
      <el-row>
        <el-col :span="18">
          <div class="combottomTitle">报价管理</div>
        </el-col>
        <el-col :span="4" class="Bus_BtnList">
          <input type="button" class="hollowFixedBtn" @click="cancelPanel" :value="$t('pub.cancelBtn')" />
          <input type="button" class="normalBtn" @click="submitForm('addMsg')" :value="$t('pub.saveBtn')" />
        </el-col>
      </el-row>
      <el-form :model="addMsg" :rules="rules" ref="addMsg" label-width="100px">
        <el-row>
          <template v-if="addMsg.Id==0">
            <el-col :span="5">
              <el-form-item label="开始月份" prop="StartDateStr">
                <el-date-picker v-model="addMsg.StartDateStr" type="month" value-format="yyyy-MM">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="结束月份" prop="EndDateStr">
                <el-date-picker v-model="addMsg.EndDateStr" type="month" value-format="yyyy-MM">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </template>
          <el-col :span="5">
            <el-form-item label="接送报价">
              <el-input v-model="addMsg.S_ReceivePrice" @keyup.native="checkPrice(addMsg,'S_ReceivePrice')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="送机报价" style="display:none;">
              <el-input v-model="addMsg.S_SendPrice" @keyup.native="checkPrice(addMsg,'S_SendPrice')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="全天报价">
              <el-input v-model="addMsg.S_AllDayPrice" @keyup.native="checkPrice(addMsg,'S_AllDayPrice')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="半天报价">
              <el-input v-model="addMsg.S_HalfDayPrice" @keyup.native="checkPrice(addMsg,'S_HalfDayPrice')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5" style="display:none;">
            <el-form-item label="小时报价">
              <el-input v-model="addMsg.S_HourPrice" @keyup.native="checkPrice(addMsg,'S_HourPrice')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="每公里价格">
              <el-input v-model="addMsg.S_KMPrice" @keyup.native="checkPrice(addMsg,'S_KMPrice')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="全天高速">
              <el-input v-model="addMsg.S_AllDayHighSpeedFee" @keyup.native="checkPrice(addMsg,'S_AllDayHighSpeedFee')">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="接送高速">
              <el-input v-model="addMsg.S_PickUpHighSpeedFee" @keyup.native="checkPrice(addMsg,'S_PickUpHighSpeedFee')">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="全天茶代">
              <el-input v-model="addMsg.S_AllDayChaDaiFee" @keyup.native="checkPrice(addMsg,'S_AllDayChaDaiFee')">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="接送茶代">
              <el-input v-model="addMsg.S_PickUpChaDaiFee" @keyup.native="checkPrice(addMsg,'S_PickUpChaDaiFee')">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        dataList: "",
        loading: false,
        isShow: false,
        msg: {
          pageIndex: 1,
          pageSize: 10,
          BusPriceId: 0,
          total: 0,
          currentPage: 1,
        },
        AreaList: [],
        BusTypeList: [],
        addMsg: {
          Id: 0, //主键编号
          StartDateStr: "", //开始月份
          EndDateStr: "", //结束月份
          MonthStr: "", //月份
          BusPriceId: 0, //车辆报价主表编号
          S_ReceivePrice: 0, //接机价格
          S_SendPrice: 0, //送机价格
          S_AllDayPrice: 0, //全天价格
          S_HalfDayPrice: 0, //半天价格
          S_HourPrice: 0, //小时价格
          S_AllDayHighSpeedFee: 0, //全天高速费
          S_PickUpHighSpeedFee: 0, //接送高速费
          S_AllDayChaDaiFee: 0, //全天茶代费
          S_PickUpChaDaiFee: 0, //接送茶代费
          S_KMPrice: 0, //每公里价格
        },
        rules: {
          StartDateStr: [{
            required: true,
            message: "请选择开始月份",
            trigger: "change"
          }],
          EndDateStr: [{
            required: true,
            message: "请选择结束月份",
            trigger: "change"
          }],
        }
      };
    },
    methods: {
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.initData();
      },
      resetPageIndex() {
        this.msg.pageIndex = 1;
        this.msg.currentPage = 1;
      },
      initData() {
        this.loading = true;
        this.apipost(
          "buspricedetails_get_GetPageList",
          this.msg,
          res => {
            this.loading = false;
            if (res.data.resultCode == 1) {
              this.dataList = res.data.data.pageData;
              this.msg.total = res.data.data.count;
            }
          },
          null
        );
      },
      saveInfo() {
        this.apipost(
          "buspricedetails_post_SetPriceDetails",
          this.addMsg,
          res => {
            if (res.data.resultCode == 1) {
              this.initData();
              this.Success(this.$t('tips.saveYes'));
              this.isShow = false;
              this.resetForm("addMsg");
            } else {
              this.Error(res.data.message);
            }
          },
          null
        );
      },
      //修改管理报价
      managePrice(ID) {
        this.addMsg.Id = ID;
        this.isShow = true;
        let msg = {
          ID: ID
        };
        this.apipost(
          "buspricedetails_get_GetPriceDetails",
          msg,
          res => {
            this.addMsg = res.data.data;
          },
          null
        );
      },
      //取消
      cancelPanel() {
        this.isShow = false;
        this.resetForm("addMsg");
      },
      //添加
      addPanel() {
        this.isShow = true;
        this.addMsg.Id = 0;
        this.clearInfo();
      },
      clearInfo() {
        this.addMsg.Id = 0;
        this.addMsg.StartDateStr = "";
        this.addMsg.EndDateStr = "";
        this.addMsg.MonthStr = "";
        this.addMsg.S_ReceivePrice = 0;
        this.addMsg.S_SendPrice = 0;
        this.addMsg.S_AllDayPrice = 0;
        this.addMsg.S_HalfDayPrice = 0;
        this.addMsg.S_HourPrice = 0;
        this.addMsg.S_AllDayHighSpeedFee = 0;
        this.addMsg.S_PickUpHighSpeedFee = 0;
        this.addMsg.S_AllDayChaDaiFee = 0;
        this.addMsg.S_PickUpChaDaiFee = 0;
        this.addMsg.S_KMPrice = 0;
      },
      submitForm(addMsg) {
        //提交创建、修改表单
        let that = this;
        that.$refs[addMsg].validate(valid => {
          if (valid) {
            that.saveInfo();
          } else {
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      //删除
      isdelete(ID) {
        var that = this;
        this.Confirm(this.$t('tips.shifoushanchu'), function () {
          var msg = {
            ID: ID
          };
          that.apipost(
            "buspricedetails_post_RemovePriceDetails",
            msg,
            res => {
              if (res.data.resultCode == 1) {
                that.initData();
              }
            },
            null
          );
        });
      },
      //获取地区下拉
      getAreaList() {
        this.apipost(
          "busprice_get_GetBusAreaType", {},
          res => {
            if (res.data.resultCode == 1) {
              this.AreaList = res.data.data;
            }
          },
          null
        );
      },
      //根据ID获取地区
      getArea(AreaType) {
        var AreaName = '';
        this.AreaList.forEach(item => {
          if (item.Id == AreaType) {
            AreaName = item.Name
          }
        })
        return AreaName;
      },
      getBusTypeStr(busType) {
        var AreaName = '';
        this.BusTypeList.forEach(item => {
          if (item.Id == busType) {
            AreaName = item.Name
          }
        })
        return AreaName;
      },
      /*获取车辆类型列表*/
      getBusTypeList() {
        this.apipost(
          "bus_get_GetBusTypeList",
          null,
          res => {
            if (res.data.resultCode == 1) {
              this.BusTypeList = res.data.data;
            }
          },
          null
        );
      },
    },
    mounted() {
      this.getAreaList();
      this.getBusTypeList();
      this.msg.BusPriceId = this.$route.query.id;
      this.addMsg.BusPriceId = this.$route.query.id;
      this.initData();
    }
  };

</script>