yangfeng
2024-02-28 504e00da9a9898ac419e97f93fc66cc7c7c6f620
服务合同-去掉产品为空的判断增加保存时去掉未选择产品的对象
1个文件已修改
74 ■■■■ 已修改文件
src/views/service/serviceContract/AddServiceContractDialog.vue 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/service/serviceContract/AddServiceContractDialog.vue
@@ -615,46 +615,52 @@
      this.$refs[formName].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
            }
          }
          if (this.isNoProduct) {
            this.$message.error("产品名称不能为空")
          // 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 {
          const params = this.saveParams()
          if (this.editConfig.title === "新建") {
            getAddServiceContract(params).then((res) => {
              console.log(res)
              this.editConfig.visible = false
              if (res.code === 200) {
                this.$message.success("添加成功")
                this.$parent.getData()
              }
            })
          } else {
            const params = this.saveParams()
            if (this.editConfig.title === "新建") {
              getAddServiceContract(params).then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message.success("添加成功")
                  this.$parent.getData()
                }
              })
            } else {
              getUpdateServiceContract(params).then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message.success("编辑成功")
                  this.$parent.getData()
                }
              })
            }
            getUpdateServiceContract(params).then((res) => {
              console.log(res)
              this.editConfig.visible = false
              if (res.code === 200) {
                this.$message.success("编辑成功")
                this.$parent.getData()
              }
            })
          }
        } else {
          console.log("error submit")
          return false
        }
        // } else {
        //   console.log("error submit")
        //   return false
        // }
      })
    },
    saveParams() {
      let data = this.editConfig.infomation
      let products = []
      this.tableData.map((item) => {
        if (item.number.length > 0) {
          products.push(item)
        }
      })
      let params = {
        id: this.editConfig.title === "新建" ? 0 : data.id,
        clientId: this.clientId || 0,
@@ -662,7 +668,7 @@
        endTime: data.endTime || "",
        memberId: data.memberId || 0,
        number: data.number || "",
        products: this.tableData,
        products: products,
        quotationId: this.quotationId || 0,
        remark: data.remark || "",
        saleChanceId: this.saleChanceId || 0,