serviceSet.vue 8.04 KB
<!-- 店面服务设置 -->
<template>
  <div class="edit-equity">
    <template v-if="showPage == 1">
      <div class="edit-container">
        <p class="edit-title">{{ title }}</p>
        <glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="isBlock" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"></glsx-combi-form>
        <glsx-combi-form ref="editFormRefBrand" labelWidth="140px" defaultWidth="320px" 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>
      <div
        class="fixed_bottom"
        :style="{
          left: footerLeft + 'px',
          width: footerWidth + 'px'
        }"
      >
        <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',
      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() {
    this.getHotline()
    // this.getDefaultCarbrand()
    this.footerLeft = document.querySelector('.base-container-right').offsetLeft
    this.footerWidth = document.documentElement.clientWidth - this.footerLeft
  },

  methods: {
    getHotline() {
      this.$apis.beforeSale.getHotlineApi({}).then(res => {
        this.editForm.hotline = res
      })
    },
    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 lang="scss" scoped>
.edit-equity {
  margin-top: 17px;
  width: 100%;
  height: calc(100% - 108px);
}
.edit-container {
  width: 100%;
  height: 100%;
  background: #ffffff;
  box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
}
.edit-container /deep/ .el-form--inline .el-form-item {
  margin-right: 10px;
}
/* .before-sale .edit-equity{
  height: 100vh;
}
.before-sale .container {
  background: #ffffff;
  box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
}

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

/* .before-sale .footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 64px;
  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;
} */

.edit-title {
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid #e7eaec;
  padding: 15px 20px;
  margin-bottom: 32px;
}

/* .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;
} */
.fixed_bottom {
  position: fixed;
  width: 100%;
  bottom: 0px;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  z-index: 999;
  box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
}
.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>