serviceSet.vue 8.14 KB
<!-- 店面服务设置 -->
<template>
  <div class="before-sale edit-equity mall-server">
    <template v-if="showPage==1">
      <div class="container edit-container mall-server-box">
        <p class="edit-title">{{ title }}</p>
        <glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="144px" :isBlock="isBlock" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"></glsx-combi-form>
        <glsx-combi-form ref="editFormRefBrand" labelWidth="144px" defaultWidth="215px" formRef="editChildRefBrand" :formObj.sync="editForm" :formData="editFormDataCar">
          <template slot="vehicleBrandId">
            <el-select v-model="editForm.vehicleBrandId" placeholder="请选择品牌" filterable @change="handleChangeBrand(editForm.vehicleBrandId)" style="width:320px;" clearable>
              <el-option v-for="item in baseData.carBrandOptions" :key="item.id" :value="item.id" :label="item.name" />
            </el-select>
          </template>
          <template slot="vehicleSubBrandId">
            <el-select v-model="editForm.vehicleSubBrandId" placeholder="请选择子品牌" filterable style="width:320px;" clearable>
              <el-option v-for="item in baseData.carChildOptions" :key="item.id" :value="item.id" :label="item.name" />
            </el-select>
          </template>
        </glsx-combi-form>
        <div style="margin-left: 140px">
          <p>针对包含“车主生活权益服务”的服务套餐,提供通过扫描小程序码进行领取“车主生活权益服务”。</p>
          <img style="margin-top: 20px;" class="qrcodeImg" :src="qrcodeUrl" />
        </div>
      </div>
      <!-- <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"> -->
      <div class="footer">
        <el-button size="small" type="primary" @click="handleConfirm">确定</el-button>
      </div>
    </template>
    <template v-if="showPage==2">
      <div class="nodata_widget">
        <div :style="[{ height: nodataHeight + 'px' }]" class="wrapper">
          <img src="../../assets/nodata_icon.png" />
          <span class="nodata_tip_1">您暂未开通售前权益服务</span>
          <span class="nodata_tip_2">合作开通后,您方可在此页设置店面的服务热线和默认提单车辆品牌等。</span>
        </div>
      </div>
    </template>
  </div>
</template>

<script>
import glsxCombiForm from '@/components/glsx-combi-form'
export default {
  name: 'serviceSet',
  data() {
    return {
      size: 'small',
      isBlock: true,
      title: '店面服务设置',
      footerLeft: '0',
      footerWidth: '0',
      editChildRef: 'editChildRef',
      qrcodeUrl: '',
      editForm: {
        hotline: '',
        vehicleBrandId: '',
        vehicleSubBrandId: ''
      },
      editRule: {
        // hotline: [{ required: true, message: '请输入服务热线', trigger: 'change' }]
      },
      editFormData: [
        {
          label: '服务热线',
          name: 'hotline',
          width: '320px',
          type: 'input',
          maxlength: 20
        }
      ],
      editFormDataCar: [
        {
          label: '主营品牌',
          name: 'vehicleBrandId',
          addHtml: 'vehicleBrandId'
        },
        {
          label: '',
          // label: '子品牌',
          name: 'vehicleSubBrandId',
          addHtml: 'vehicleSubBrandId'
        }
      ],
      // 公共数据
      baseData: {
        carBrandOptions: [],
        carChildOptions: []
      },
      showPage:0,
      nodataHeight: 0,
    }
  },

  components: {
    glsxCombiForm
  },

  created() {
    let clientHeight = document.documentElement.clientHeight
    this.nodataHeight = clientHeight * 0.8
    const openStatus = localStorage.getItem('preSetStatus')
    if (openStatus == 2) {
      this.showPage = 2
      return
    }
    this.showPage = 1
    this.getAllVehicleBrand()
    this.getCarChildList()
  },

  mounted() {
    if(this.showPage==2){
      return
    }
    this.getHotline()
    // this.getDefaultCarbrand()
  },

  methods: {
    getHotline() {
      this.$apis.ghBeforeSale.getHotlineApi({}).then(res => {
        this.editForm.hotline = res.serviceHotline
        this.qrcodeUrl = res.qrcodeUrl
      })
    },
    getDefaultCarbrand() {
      this.$apis.ghBeforeSale.getDefaultCarbrandApi({}).then(res => {
        // console.log(res)
        if (res) {
          this.editForm.id = res.id
          this.editForm.vehicleBrandId = res.vehicleBrandId
          this.editForm.vehicleSubBrandId = res.vehicleSubBrandId
          this.handleChangeBrand(this.editForm.vehicleBrandId, true)
        }
      })
    },
    // 获取品牌车型
    getAllVehicleBrand(fn = () => {}) {
      const params = {}
      this.$apis.ghBeforeSale.getCarBrandListApi(params).then(res => {
        // console.log(res)
        this.baseData.carBrandOptions = res || []
      })
    },
    handleChangeBrand(brandId, isRecovery = false) {
      !isRecovery && (this.editForm.vehicleSubBrandId = '')
      this.baseData.carChildOptions = brandId ? this.allCarChildList.find(item => item.id == brandId).childs : []
    },
    // 获取子品牌
    getCarChildList(isRecovery = false) {
      this.$apis.ghBeforeSale.getCarChildListApi({}).then(res => {
        this.allCarChildList = res || []
        if (isRecovery) {
          this.baseData.carChildOptions = this.allCarChildList.find(item => item.id == this.editForm.vehicleBrandId).childs
        }
        this.getDefaultCarbrand()
      })
    },
    handleConfirm() {
      this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
        if (valid) {
          var params = this.$common.utils.deepClone(this.editForm)
          Promise.all([this.$apis.ghBeforeSale.updateHotlineApi(params), this.$apis.ghBeforeSale.updateCarBrandApi(params)]).then(([hotlineRes, carBrandRes]) => {
            this.$message({
              message: hotlineRes.code == '0' && carBrandRes.code == '0' ? '操作成功' : '操作失败',
              type: hotlineRes.code == '0' && carBrandRes.code == '0' ? 'success' : 'error'
            })
            this.getHotline()
            this.getDefaultCarbrand()
          })
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.before-sale .container {
  padding: 0 !important;
  background: #ffffff;
  box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
  padding: 20px;
}

.before-sale{
  padding-top: 17px;
}

.before-sale .edit-container {
  margin-bottom: 84px;
}

.before-sale .edit-form-container {
  margin-top: 20px;
}

.before-sale .txt-center {
  text-align: center;
}

.before-sale .footer {
  width: calc(100% + 40px);
  position: absolute;
  bottom: 0;
  height: 64px;
  left: -40px;
  text-align: center;
  line-height: 64px;
  background: #ffffff;
  z-index: 999;
}

.before-sale .flex {
  display: flex;
  justify-content: space-between;
}

.before-sale .flex-grow {
  flex: 1;
}

.before-sale .edit-title {
  padding: 0 20px;
  font-size: 16px;
  font-weight: bold;
  height: 58px;
  line-height: 58px;
  border-bottom: 1px solid #e7eaec;
  margin: 0 0;
  color: #333333;
}

.before-sale .edit-sub-title {
  position: relative;
  font-size: 13px;
  font-weight: 700;
  height: 32px;
  line-height: 32px;
  color: #333333;
  margin-bottom: 20px;
  padding-left: 8px;
  background-color: rgba(242, 242, 242, 1);
}

.before-sale .message-Z-zinde {
  z-index: 3000 !important;
}

.before-sale .txt-red {
  color: red;
}

.one-line-ellipsis {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.before-sale .qrcodeImg {
  width: 160px;
  height: 160px;
}

.mall-server{
  height: calc(100% - 94px);
}

.mall-server-box{
  height: 100%;
}
.nodata_widget {
  margin-top: 17px;
  .wrapper {
    width: 100%;
    background: #ffffff;
    box-shadow: 0px 10px 20px 0px rgba(88, 80, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    .nodata_tip_1 {
      font-size: 18px;
      font-weight: 500;
      color: #3a3a3a;
      margin-top: 48px;
    }
    .nodata_tip_2 {
      font-size: 14px;
      font-weight: 400;
      color: #3a3a3a;
      margin-top: 9px;
    }
  }
}
</style>