commentDetail.vue 3.63 KB
<!-- 评论详情 -->
<template>
  <div class="edit-share marketing">
    <div class="container edit-container">
      <p class="edit-title">{{ title }}</p>
      <glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"></glsx-combi-form>
    </div>
    <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
      <el-button type="primary" @click="handleConfirm">确定</el-button>
      <el-button type="default" @click="handleCancel">取消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'commentDetail',
  data() {
    return {
      size: 'small',
      title: '评论详情',
      footerLeft: '0',
      footerWidth: '0',
      editChildRef: 'editChildRef',
      routeInfo: {
        // 1-新增;2-编辑;3-查看
        addOrEdit: 1,
        id: ''
      },
      editForm: {
        // 专区类型(1发现频道,2商城专区)
        zoneType: '2',
        zoneName: '',
        zoneImg: '',
        merchantList: []
      },
      editRule: {
        zoneName: [{ required: true, message: '请输入专区名称', trigger: 'change' }],
        zoneImg: [{ required: true, message: '请选择专区图片', trigger: 'change' }],
        merchantList: [{ required: true, message: '请选择门店', trigger: 'change' }]
      },
      editFormData: [
        {
          label: '专区名称',
          name: 'zoneName',
          width: '320px',
          type: 'input',
          maxlength: 20
        },
        {
          label: '专区图片',
          name: 'zoneImg',
          type: 'upload',
          width: '320px',
          limitSize: 10,
          maxPhotoNum: 1,
          handleUpload: (e, file, targetItem) => {
            const imgFile = e.target.result
            const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
            this.$apis.common.uploadImgApi({ file: base64, fileType: 'image' }).then(res => {
              this.editForm[targetItem.name] = res
              this.$refs.editFormRef.$refs[this.editChildRef].validateField(targetItem.name)
            })
          }
        }
      ]
    }
  },

  mounted() {
    this.footerLeft = document.querySelector('.base-container-right').offsetLeft
    this.footerWidth = document.documentElement.clientWidth - this.footerLeft
    this.routeInfo = this.$route.params
    this.getInfo()
  },

  methods: {
    getInfo() {
      // this.$apis.zoneList.getZoneInfoApi({ id: this.routeInfo.id }).then(res => {
      //   this.editForm.zoneName = res.zoneName
      //   this.editForm.zoneImg = res.zoneImg
      //   this.editForm.merchantList = res.merchantRefList
      //   this.editForm.merchantList.forEach(item => {
      //     item.merchantNo = item.merchantId
      //   })
      // })
    },
    handleConfirm() {
      this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
        if (valid) {
          var params = this.$common.utils.deepClone(this.editForm)
          if (this.routeInfo.addOrEdit == 2) {
            params.id = this.routeInfo.id
          }
          // this.$apis.zoneList.insertZoneApi(params).then(res => {
          //   this.$message({
          //     message: res.code == '0' ? '操作成功' : '操作失败',
          //     type: res.code == '0' ? 'success' : 'error'
          //   })
          //   if (res.code == '0') {
          //     this.handleCancel()
          //   }
          // })
        }
      })
    },
    handleCancel() {
      this.$router.push({
        path: '/orderComment/index'
      })
    }
  }
}
</script>
<style scoped></style>