动态删减表单

<template>
  <div class="ele-body">
    <el-card shadow="never">
      <el-tabs v-model="form.type" @tab-click="handleClick">
        <el-tab-pane label="用户" name="0">
          <el-form v-model="aaa">
            <el-form-item style="margin:10px">
              <div v-for="item in aaa" :key="item.id">
                <el-input
                  style="width: 40%;"
                  placeholder="请输入原因"
                  v-model="item.cause"
                  clearable
                />
                <el-button
                  v-if="item.id"
                  type="primary"
                  style="margin:10px"
                  @click="sc(item.id)"
                  >删除</el-button
                >
              </div>
            </el-form-item>
            <el-form-item>
              <el-button
                style="width: 40%;"
                plain
                type="primary"
                @click="xz"
                :disabled="this.jy"
                icon="el-icon-plus"
                >增加原因</el-button
              >
            </el-form-item>
            <el-button style="width: 40%;" type="primary" @click="submit">
              提交
            </el-button>
          </el-form>
        </el-tab-pane>
        <!-- ............................. -->
        <el-tab-pane label="回收员" name="1">
          <el-form v-model="aaa">
            <el-form-item style="margin:10px">
              <div v-for="item in aaa" :key="item.id">
                <el-input
                  style="width: 40%;"
                  placeholder="请输入原因"
                  v-model="item.cause"
                  clearable
                />
                <el-button
                  v-if="item.id"
                  type="primary"
                  style="margin:10px"
                  @click="sc(item.id)"
                  >删除</el-button
                >
              </div>
            </el-form-item>
            <el-form-item>
              <el-button
                style="width: 40%;"
                plain
                type="primary"
                @click="xz"
                :disabled="this.jy"
                icon="el-icon-plus"
                >增加原因</el-button
              >
            </el-form-item>
            <el-button style="width: 40%;" type="primary" @click="submit">
              提交
            </el-button>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        type: "0"
      },
      aaa: [],
      jy: false
    };
  },
  methods: {
    handleClick(tab, event) {
      // console.log(tab, event);
      // console.log(this.form.type);
      this.queryinfo();
    },
    // 查询信息
    queryinfo() {
      this.$http
        .get("?s=Manage.Setting_Complaint.All", {
          params: { type: this.form.type }
        })
        .then(res => {
          console.log(res.data.data.data, "投诉原因");
          if (res.data.code === 200) {
            this.aaa = res.data.data.data;
          }
        });
    },
    //删除
    sc(e) {
      this.$http
        .post("?s=Manage.Setting_Complaint.Del", { id: e })
        .then(res => {
          if (res.data.code == 200) {
            this.$message({ type: "success", message: "成功" });
            this.queryinfo();
          } else {
            this.$message.error(res.data.msg);
          }
        });
    },
    // 新增
    xz() {
      this.aaa.push({
        cause: ""
      });
      this.jy = true;
    },
    // 提交
    submit() {
      this.$http
        .post("?s=Manage.Setting_Complaint.Add", {
          type: this.form.type,
          cause: this.aaa[this.aaa.length - 1]
        })
        .then(res => {
          console.log(res, "增加");
          if (res.data.code == 200) {
            this.$message({ type: "success", message: "成功" });
            this.queryinfo();
            this.jy = false;
          } else {
            this.$message.error(res.data.msg);
          }
        });
    }
  },
  created() {
    this.queryinfo();
  }
};
</script>

<style scoped></style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值