<el-col :span="1.5">
  <el-button
    type="primary"
    plain
    icon="el-icon-plus"
    size="mini"
    @click="handleAdd"
    v-hasPermi="['pay:configBank:add']"
  >新增推广码
  </el-button>
</el-col>
<el-col :span="1.5">
  <el-button
    type="danger"
    plain
    icon="el-icon-delete"
    size="mini"
    @click="handleDelete"
    v-hasPermi="['pay:configBank:remove']"
  >删除推广码
  </el-button>
</el-col>

 

 

<!-- 新增推广码弹框 -->
<el-dialog
  v-dialogDrag
  :close-on-click-modal="false"
  title="新增推广码"
  :visible.sync="addPromotionCode"
  width="500px"
  append-to-body
>
  <el-form ref="formaddPromotionCode" :model="formaddPromotionCode" :rules="rules" label-width="70px">
    <el-form-item label="推广码" prop="code">
      <el-input placeholder="请输入推广码" v-model="formaddPromotionCode.code"
      />
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="submitaddPromotionCode">立即提交</el-button>
  </div>
</el-dialog>

<!-- 删除推广码弹框 -->
<el-dialog
  v-dialogDrag
  :close-on-click-modal="false"
  title="删除推广码"
  :visible.sync="delPromotionCode"
  width="500px"
  append-to-body
>
  <el-form ref="formdelPromotionCode" :model="formdelPromotionCode" :rules="rules" label-width="70px">
    <el-form-item label="推广码" prop="code">
      <el-input placeholder="请输入推广码" v-model="formdelPromotionCode.code"
      />
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="submitdelPromotionCode">立即提交</el-button>
  </div>
</el-dialog>

 

 

//新增推广码弹框
addPromotionCode: false,
//删除推广码弹框
delPromotionCode: false,
//新增推广码参数
formaddPromotionCode: {},
//删除推广码参数
formdelPromotionCode: {},

 

 

// 表单校验
rules: {
  code: [
    {required: true, message: "推广码不能为空", trigger: "blur"}
  ]
}

 

 

//新增推广码
handleAdd() {
  this.resetformaddPromotionCode()
  this.addPromotionCode = true
},
//删除推广码
handleDelete() {
  this.resetformdelPromotionCode()
  this.delPromotionCode = true
},
// 新增推广码表单重置
resetformaddPromotionCode() {
  this.formaddPromotionCode = {
    code: null
  };
  this.resetForm("formaddPromotionCode");
},
// 删除推广码表单重置
resetformdelPromotionCode() {
  this.formdelPromotionCode = {
    code: null
  };
  this.resetForm("formdelPromotionCode");
},

 

 

/** 新增推广码提交按钮 */
submitaddPromotionCode() {
  this.$refs["formaddPromotionCode"].validate(valid => {
    if ((/^[0-9]+$/).test(this.formaddPromotionCode.code)) {
      addPromotionCode(this.formaddPromotionCode).then(response => {
        if (response.code == 0) {
          this.$message.error(response.msg);
        } else {
          this.msgSuccess("新增成功");
          this.addPromotionCode = false;
          this.getList();
        }
      });
    } else {
      this.$message.error("推广码只能为纯数字");
    }
  });
},
/** 删除推广码提交按钮 */
submitdelPromotionCode() {
  this.$refs["formdelPromotionCode"].validate(valid => {
    if ((/^[0-9]+$/).test(this.formdelPromotionCode.code)) {
      delPromotionCode(this.formdelPromotionCode).then(response => {
        if (response.code == 0) {
          this.$message.error(response.msg);
        } else {
          this.msgSuccess("删除成功");
          this.delPromotionCode = false;
          this.getList();
        }
      });
    } else {
      this.$message.error("推广码只能为纯数字");
    }
  });
},

 

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐