zuozhengqing
2024-03-20 ea2b5a4a2779a2a94c4846b110c5507a248ffeb5
src/views/sales/salesOpportunity/AddSalesOpportunityDialog.vue
@@ -316,20 +316,22 @@
          <!-- 产品管理 -->
          <div class="basic-info-title" style="display: flex">
            产品管理
            <div style="margin-left: 400px">
            <!-- <div style="margin-left: 400px">
              币种
              <el-select v-model="editConfig.infomation.currency" placeholder="请选择" size="mini" style="width: 63%">
                <el-option v-for="item in currencyOptions" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </div>
            </div> -->
          </div>
          <div class="product-view">
            <CommonFormTableView
              :show-summary="showSummary"
              :addTypeIdMultiple="true"
              :product-table-list="productTableList"
              @inputContent="inputContent"
              @addProductClick="addProductClick"
              @getSelectArray="getSelectArray"
              @emptyProductClick="emptyProductClick"
              @recalculateProductClick="recalculateProductClick"
              @clearupProduct="clearupProduct"
@@ -736,7 +738,7 @@
            let username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
            this.memberOptions.map((item) => {
              if (item.username == username) {
                this.editConfig.infomation.member_id = item.id
                this.$set(this.editConfig.infomation, "member_id", item.id)
              }
            })
          }
@@ -744,6 +746,10 @@
          this.businessTypeOptions = res.data.sale_type
          this.oldCustomerMarketOptions = res.data.regular_customers
          this.saleStageOptions = res.data.sale_stage
          if (this.editConfig.title === "新建") {
            this.editConfig.infomation.sale_stage_id=1
          }
          this.provinceOptions = res.data.province
          this.regionOptions = res.data.region
          this.possibleOptions = res.data.possibility
@@ -765,11 +771,11 @@
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const hasProduct = this.tableData.every((ele) => !!ele.name)
          if (!hasProduct) {
            this.$message.error("产品名称不能为空")
            return
          }
          // const hasProduct = this.tableData.every((ele) => !!ele.name)
          // if (!hasProduct) {
          //   this.$message.error("产品名称不能为空")
          //   return
          // }
          const params = this.saveParams()
          console.log(params)
@@ -808,6 +814,12 @@
    },
    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,
        advantages: data.advantages || "",
@@ -845,7 +857,7 @@
        detail_address: data.detail_address || "",
        codeStandID: data.ID,
        products: this.tableData
        products: products
      }
      return params
    },
@@ -979,8 +991,9 @@
      }
      this.productTableList = {
        tableData: this.tableData,
        isReturn: true,
        tableColumn: [
          { label: "#", prop: "productId", width: 40 },
          // { label: "#", prop: "productId", width: 40 },
          { label: "产品名称", prop: "name", productName: true, isRequird: true },
          { label: "产品编号", prop: "number" },
          { label: "数量", prop: "amount", inputNumber: true, isRequird: true },
@@ -991,26 +1004,42 @@
    },
    // 产品列表输入
    inputContent(val, prop, row) {
      this.productId = row.productId
      // this.productId = row.productId
      this.tableData.map((item) => {
        if (item.productId === row.productId) {
        if (item.number === row.number) {
          item[prop] = val
        }
      })
    },
    // 产品新增
    addProductClick() {
      this.productId++
      this.tableData.push({
        productId: this.productId,
        id: 0,
        amount: 0,
        desc: "",
        name: "",
        number: "",
        price: 0,
        total: 0
      })
      // this.productId++
      // this.tableData.push({
      //   productId: this.productId,
      //   id: 0,
      //   amount: 0,
      //   desc: "",
      //   name: "",
      //   number: "",
      //   price: 0,
      //   total: 0
      // })
      // this.showSummary.show = true
    },
    // 新增方式修改
    getSelectArray(val, index) {
      if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
        this.tableData = []
      }
      if (index < this.tableData.length) {
        this.tableData.splice(index, 1)
        val.map((item, ind) => {
          this.tableData.splice(index + ind, 0, item)
        })
      } else {
        this.tableData = this.tableData.concat(val)
      }
      this.productTableList.tableData = this.tableData
      this.showSummary.show = true
    },
    //  产品清空
@@ -1041,7 +1070,7 @@
      if (this.editConfig.infomation?.member_id > 0) {
        callback()
      } else {
        callback(new Error("请输入销售负责人"))
        callback(new Error("请选择销售负责人"))
      }
    }
  }