文文5050
2021-08-11 08:59
采纳率: 88.9%
浏览 126
已结题

vue form表单验证出现选择输入了值,但是还是提示未选择时的问题


<el-form
        :rules="rules"
        :model="item"
        label-width="110px"
        size="small"
        ref="ruleForm"
      >
        <table
          border="1"
          width="80%"
          align="center"
          cellspacing="0"
          cellpadding="6"
          v-for="(item,index) in qualitySafetyItemVOList"
          :key='index'
        >
          <tbody>
            <tr
              align="left"
              height="70px"
            >
              <td colspan="2">
                <el-form-item
                  label="内容:"
                  prop="content"
                >
                  <!-- <span style="color:#d43030;">* </span>内容: -->
                  <el-input
                    class="search"
                    type="textarea"
                    v-model="item.content"
                    placeholder="请输入检查内容"
                    style="width:80%;"
                  />
                </el-form-item>
              </td>
            </tr>
          </tbody>
        </table>
      </el-form>


     dataForm: {
        projectId: "",
        qualityCheckType: 1,
        checkDate: "",
        checkId: "",
      },
      item: {
        content: "",
      },
      rules: {
        content: [
          { required: true, message: "请输入检查内容", trigger: "blur" },
        ],
      },



    //确定 提交
    submitbtn(draftFlag) {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          if (draftFlag == 2) {
            var checkF = this.checkInfo();
            if (checkF === "checkFalse") {
              return;
            }
          }
          let data = {};
          for (
            let index = 0;
            index < this.qualitySafetyItemVOList.length;
            index++
          ) {
            if (
              this.qualitySafetyItemVOList[index].content == "" &&
              draftFlag == 2
            )
              if (
                this.qualitySafetyItemVOList[index].checkResult === "" &&
                draftFlag == 2
              ) {
                this.$message.error("请选择检查结果");
                return;
              }
            data = Object.assign(this.dataForm, {
              ["qualitySafetyItemVOList[" + index + "].sort"]: index,
              ["qualitySafetyItemVOList[" + index + "].noticeId"]:
                this.qualitySafetyItemVOList[index].noticeId,
              ["qualitySafetyItemVOList[" + index + "].checkResult"]:
                this.qualitySafetyItemVOList[index].checkResult,
              ["qualitySafetyItemVOList[" + index + "].content"]: this
                .qualitySafetyItemVOList[index].content
                ? remarkData(this.qualitySafetyItemVOList[index].content, "add")
                : "",
              ["qualitySafetyItemVOList[" + index + "].attachmentIds"]: this
                .qualitySafetyItemVOList[index].fileList
                ? this.qualitySafetyItemVOList[index].fileList
                    .map((x) => {
                      return x.attachmentId;
                    })
                    .join(",")
                : "",
            });
          }
          data.draftFlag = draftFlag;
          data = qs.stringify(data);
          //  let data = qs.stringify(this.dataForm)
          this.btnDisabled = true;
          editQualityInfo(data)
            .then((res) => {
              this.btnDisabled = false;
              if (res.status === 200 && res.data.returncode == 0) {
                this.$message.success("质量安全修改成功");
                this.$router.push({ path: "/home/quality" });
              } else {
                this.$message.error(res.data.message);
              }
            })
            .catch(() => {
              this.btnDisabled = false;
              console.log("error", "入库单");
            });
        }
      });
    },
  • 好问题 提建议
  • 收藏

1条回答 默认 最新

  • 嘿嘿!请多指教 2021-08-11 09:10
    已采纳

    img
    item.content已经指向数组qualitySafetyItemVOList里了

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题