yangfeng
2023-09-06 29b5ffe318b8ab32865ebebedd865ea2aa3f6c7e
src/views/supplierManage/supplier/AddNewProduct.vue
@@ -14,6 +14,7 @@
        <div class="basic-info-title">产品信息</div>
        <div class="basic-info-view">
          <CommonFormTableView
            ref="productTable"
            :product-table-list="productTableList"
            :detail-enter="detailEnter"
            @inputContent="inputContent"
@@ -78,41 +79,45 @@
    },
    // 保存
    saveClick() {
      console.log(this.editConfig.infomation)
      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].name.length === 0) {
          this.isNoProduct = true
          break
        } else {
          this.isNoProduct = false
        }
      }
      if (this.isNoProduct) {
        this.$message.error("产品名称不能为空")
      } else {
        if (this.editConfig.title === "添加") {
          createProduct({
            list: this.tableData
          }).then((res) => {
            console.log(res)
            this.editConfig.visible = false
            if (res.code === 200) {
              this.$message.success("添加成功")
              this.$parent.getProductList()
      this.$refs.productTable.$refs.form.validate((valid) => {
        if (valid) {
          console.log(this.editConfig.infomation)
          for (let i = 0; i < this.tableData.length; i++) {
            if (this.tableData[i].name.length === 0) {
              this.isNoProduct = true
              break
            } else {
              this.isNoProduct = false
            }
          })
        } else {
          const params = this.saveParams()
          updateProduct(params).then((res) => {
            console.log(res)
            this.editConfig.visible = false
            if (res.code === 200) {
              this.$message.success("编辑成功")
              this.$parent.getProductList()
          }
          if (this.isNoProduct) {
            this.$message.error("产品名称不能为空")
          } else {
            if (this.editConfig.title === "添加") {
              createProduct({
                list: this.tableData
              }).then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message.success("添加成功")
                  this.$parent.getProductList()
                }
              })
            } else {
              const params = this.saveParams()
              updateProduct(params).then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message.success("编辑成功")
                  this.$parent.getProductList()
                }
              })
            }
          })
          }
        }
      }
      })
    },
    saveParams() {
      let data = this.editConfig.infomation