serviceSet.vue 6.74 KB
<!-- 店面服务设置 -->
<template>
  <div class="before-sale edit-equity mall-server">
    <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 type="primary" style="width:88px;" @click="handleConfirm">确定</el-button>
    </div>
  </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: []
      }
    }
  },

  components: {
    glsxCombiForm
  },

  created() {
    this.getAllVehicleBrand()
    this.getCarChildList()
  },

  mounted() {
    this.getHotline()
    // this.getDefaultCarbrand()
  },

  methods: {
    getHotline() {
      this.$apis.beforeSale.getHotlineApi({}).then(res => {
        this.editForm.hotline = res.serviceHotline
        this.qrcodeUrl = res.qrcodeUrl
      })
    },
    getDefaultCarbrand() {
      this.$apis.beforeSale.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.beforeSale.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.beforeSale.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.beforeSale.updateHotlineApi(params), this.$apis.beforeSale.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 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%;
}
</style>