<template>
  <div v-loading="loading" class="directorSetting">
    <div class="head-title">
      <span class="point">基础设置</span>
    </div>
    <div class="content">
      <el-form :model="addMsg"  ref="addMsg" label-width="160px">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>司导设置</span>
          </div>
          <div>
            <el-form-item label="订单状态">
              <div  flex="dir:left wrap:wrap">
                <div v-for="item in addMsg.OrderStateList" :key="item.Id" style="margin-right: 15px" flex="dir:left">
                  <span>{{item.Id}}：</span>
                  <el-input style="width:100px"  placeholder="请输入" size="small" v-model="item.Name" ></el-input>
                </div>
              </div>


            </el-form-item>
            <el-form-item label="是否需二次确认">
              <el-radio v-model="addMsg.IsConfirm" :label="1">是</el-radio>
              <el-radio v-model="addMsg.IsConfirm" :label="2" >否</el-radio>
            </el-form-item>
            <el-form-item label="详情页面链接">
              <el-input style="width:350px"  placeholder="请输入" size="small" v-model="addMsg.PagePath">
                <el-button slot="append"  @click="isShowLink=true">选择链接</el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="提前预定天数">
              <el-input style="width:350px"  placeholder="请输入" size="small" v-model="addMsg.AdvanceDay">
                <el-button slot="append">
                  <span>天</span>
                </el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="提前取消的时间">
              <el-input style="width:350px"  placeholder="请输入" size="small" v-model="addMsg.CancelHour">
                <el-button slot="append">
                  <span>小时</span>
                </el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="保险名称">
              <el-input style="width:350px"  placeholder="请输入" size="small" v-model="addMsg.InsuranceName"></el-input>
            </el-form-item>
            <el-form-item label="成本价格">
              <el-input style="width:350px"  type="number"  min="0"  placeholder="请输入" size="small" v-model="addMsg.CostPrice">
                <el-button slot="append">
                  <span>元</span>
                </el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="销售价格">
              <el-input style="width:350px"   type="number" min="0"  placeholder="请输入" size="small" v-model="addMsg.SalePrice">
                <el-button slot="append">
                  <span>元</span>
                </el-button>
              </el-input>
            </el-form-item>

          </div>
        </el-card>
        <el-card style="margin-top:20px" shadow="never">
          <div slot="header" class="clearfix">
            <span>保险描述</span>
          </div>
          <el-row>
            <el-col :span="242">
              <UE style="width:750px;" :defaultMsg="defaultMsg" :config="config" :IsMultiple="true" ref="ue"></UE>
            </el-col>
          </el-row>
        </el-card>
      </el-form>

    </div>
    <div style="margin-top:20px">
      <el-button size="small" type="primary" @click="Save('addMsg')">保存</el-button>
    </div>

    <el-dialog title="选择链接" :visible.sync="isShowLink" width="800px">
      <chooseMenu ref="chooseMenu">
      </chooseMenu>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="isShowLink=false">取 消</el-button>
        <el-button size="small" type="danger" @click="getMenu()" :v-loading="saveload">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
  import chooseMenu from "../common/chooseMenu.vue";
  import UE from "@/components/global/UE.vue";

  export default {
    components: {
      chooseMenu,
      UE,
    },
    data() {

      return {
        loading: false,
        isShowLink:false,
        saveload:false,
        addMsg: {
        },
        SettlementType:[],
        WithdrawWayList:[],
        dialogVisible: false,
        getGradeByTypeList:[],
        defaultMsg: "",
        config: {
          initialFrameWidth: null,
          initialFrameHeight: 350
        },
      };
    },
    created() {

      this.getData();
    },
    methods: {
      getGradeByType(num){
        this.apipost("/api/user/GetGradeByType",{GradeType:num}, res => {
          if(res.data.resultCode==1){
            this.getGradeByTypeList=res.data.data;
          }
        })
      },
      getMenu() {
        //调用子组件方法
        var obj = this.$refs.chooseMenu.getChooseMenu();
        this.addMsg.PagePath = obj.PageUrl;
        this.isShowLink = false;
      },
      Save(formName) {
        if(this.addMsg.AdvanceDay=='' || this.addMsg.AdvanceDay<1){
          this.Error('提前预定天数不能小于1')
          return false
        }
        this.$refs[formName].validate((valid) => {

          if (valid) {
            let content = this.$refs.ue.getUEContent();
            this.addMsg.InsuranceDescription = content;
            let cmd = "/api/GuideCar/SetGuideCarInfo";
            this.saveload = true
            this.apipost(cmd, this.addMsg,
              res => {
                this.saveload = false

                if (res.data.resultCode === 1) {
                  this.Success(res.data.message);
                  this.getData();
                } else {
                  this.Error(res.data.message);
                }
              },
              null
            );
          } else {
            return false;
          }
        });
      },




      getData() {
        this.loading = true;
        this.apipost("/api/GuideCar/GetGuideCarInfo", {}, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.addMsg = res.data.data;
            if (this.addMsg.InsuranceDescription && this.addMsg.InsuranceDescription != "") {
              this.defaultMsg = this.addMsg.InsuranceDescription;
            }
          }
        })
      },






    },
    mounted() {

    }
  };

</script>
<style>
  .directorSetting .app-gallery-item {
    width: 100px;
    height: 100px;
    border: 1px solid #e3e3e3;
    border-radius: 2px;
    margin-right: 10px;
    margin-bottom: 10px;
    position: relative;
  }

  .directorSetting .el-form-item .topelzk {
    top: 12px !important;
  }

  .directorSetting .el-form-item .elzk {
    position: absolute;
    left: -25px;
    top: 8px;
  }

  .directorSetting .el-checkbox-group {
    display: inline-block;
  }

  .directorSetting .nocommonLabel .el-form-item__label {
    margin-top: 0px;
    padding-right: 30px;
  }

  .directorSetting .commonLabel .el-form-item__label {
    margin-top: -4px;
  }

  .directorSetting .discount .el-form-item__label {
    padding-right: 30px;
    margin-top: -4px;
  }

  .directorSetting .blue {
    color: #409EFF;

  }

  .directorSetting .content {
    margin-top: 10px;
    box-sizing: border-box;
  }

</style>
