CancelAfterVerification.vue 2.66 KB
<template>
  <GLDialog
      mode="mid"
      class="muti"
      :title="cancelObj.title"
      :before-close="handleClose"
      @onOk="handleConfirm"
      @onCancel="handleClose"
      :visible.sync="cancelObj.show"
      append-to-body
  >
    <el-form :model="form" ref="form" label-width="120px">
      <!-- 基本信息 -->
      <div v-for="(section, index) in cancelObj.infoSections" :key="index" class="form-section">
        <h3 class="section-title">{{ section.title }}</h3>
        <el-row :gutter="20">
          <el-col v-for="(item, index) in section.items" :key="index" :span="12">
            <div class="info-field">
              <span class="label">{{ item.label }}:</span>
              <span class="value" :title="item.value">{{ item.value }}</span>
            </div>
          </el-col>
        </el-row>
      </div>

      <!-- 快递信息 -->
      <div class="form-section">
        <h3 class="section-title">核销信息</h3>
        <el-form-item label="核销码" prop="cancelNumber" :rules="[{ required: true, message: '核销码不能为空', trigger: 'blur' }]">
          <el-input v-model="form.cancelNumber" maxlength="50"  show-word-limit></el-input>
        </el-form-item>
      </div>
    </el-form>
  </GLDialog>
</template>

<script>
import {afterRangePickerOptions} from "../../RedEnvelopeConfig/edit";

export default {
  name: "CancelAfterVerification",
  props: {
    cancelObj: {
      type: Object,
      default: () => { }
    },
  },
  data () {
    return {
      afterRangePickerOptions,
      formItemWidth: 'width: 284px;',
      size: 'small',
      disabled: false,
      form: {
        cancelNumber: '',
      }
    }
  },
  methods:{
    handleConfirm(){
      this.validateForm().then(() => {
        this.$emit('submit', {
          ...this.form,id:this.cancelObj.id
        });
        this.handleClose();
      }).catch(error => {
        this.$message.error(error.message);
      });
    },
    validateForm() {
      return new Promise((resolve, reject) => {
        this.$refs.form.validate((valid) => {
          if (valid) {
            resolve();
          } else {
            reject(new Error('请填写核销码'));
          }
        });
      });
    },
    handleClose(){
      this.$emit('update:cancelObj', {show:false});
      this.form = {
        cancelNumber : ''
      }
    }
  }
}
</script>

<style scoped lang="scss">
.info-field {
  margin-bottom: 10px;
  line-height: 16px;
  font-size: 14px;
  padding: 10px 40px;
  border-radius: 4px;
  display: flex;
  .label {
    color: #666666;
  }
  .value {
    width: 170px;
    white-space: nowrap; /* 防止内容换行 */
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
</style>