新建销售子单和新建销售明细单-产品管理-添加、编辑、删除产品数据处理和保存时数据处签约实际默认设置
3个文件已修改
286 ■■■■■ 已修改文件
src/views/sales/salesDetails/AddSalesDetailsDialog.vue 162 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sales/salesDetails/index.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sales/subOrder/AddSubOrderDialog.vue 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sales/salesDetails/AddSalesDetailsDialog.vue
@@ -182,7 +182,7 @@
                    }
                  ]"
                >
                <!-- isAddQuatation || -->
                  <!-- isAddQuatation || -->
                  <div class="custom-name">
                    <el-autocomplete
                      v-model="editConfig.infomation.quotation_number"
@@ -195,14 +195,10 @@
                      @select="handleSelectClient('quotation', $event)"
                      style="width: 100%"
                      placeholder="请选择销售报价单"
                      :disabled=" isView"
                      :disabled="isView"
                    ></el-autocomplete>
                    <!-- !isAddQuatation && editConfig.infomation.sale_chance_name &&-->
                    <div
                      v-if=" !isView"
                      class="common-select-btn"
                      @click="selClientClick('quotation')"
                    >
                    <div v-if="!isView" class="common-select-btn" @click="selClientClick('quotation')">
                      <i class="el-icon-circle-plus-outline" title="选择"></i>
                    </div>
                    <!-- !isAddQuatation && -->
@@ -568,7 +564,7 @@
  },
  data() {
    return {
      dialogWidth: "50%",
      dialogWidth: "60%",
      editConfig: this.editCommonConfig,
      rules: {
        client_name: [{ required: true, message: "请选择客户名称", trigger: "change" }],
@@ -644,7 +640,7 @@
  },
  created() {
    if (this.editConfig.title !== "新建") {
      this.productTableList.tableData=[
      this.productTableList.tableData = [
        {
          productId: this.productId,
          id: 0,
@@ -721,61 +717,67 @@
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // 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 {
          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 {
            for (let i = 0; i < this.tableData.length; i++) {
              if (this.tableData[i].cost) {
                let reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
                if (!reg.test(this.tableData[i].cost)) {
                  this.$message.error("成本单价需要填写大于0的2位小数!")
                  return true
                }
            if (this.tableData[i].cost) {
              let reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
              if (!reg.test(this.tableData[i].cost)) {
                this.$message.error("成本单价需要填写大于0的2位小数!")
                return true
              }
            }
            const params = this.saveParams()
            if (this.editConfig.title === "新建") {
              getAddSalesDetails(params).then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.tableData.map((item) => {
                    this.amountTotal += parseFloat(item.total)
                  })
                  let config = {
                    amountTotal: this.amountTotal,
                    id: res.data.id
                  }
                  this.$emit("addCollectionPlanClick", config)
                }
              })
            } else {
              getUpdateSalesDetails(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
          const params = this.saveParams()
          if (this.editConfig.title === "新建") {
            getAddSalesDetails(params).then((res) => {
              console.log(res)
              this.editConfig.visible = false
              if (res.code === 200) {
                this.tableData.map((item) => {
                  this.amountTotal += parseFloat(item.total)
                })
                let config = {
                  amountTotal: this.amountTotal,
                  id: res.data.id
                }
                this.$emit("addCollectionPlanClick", config)
              }
            })
          } else {
            getUpdateSalesDetails(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
        // }
      })
    },
    saveParams() {
      let data = this.editConfig.infomation
      let products = []
      this.tableData.map((item) => {
        if (item.number.length > 0) {
          products.push(item)
        }
      })
      let commonParam = {
        address: data.address || "",
        addressee: data.addressee || "",
@@ -785,7 +787,7 @@
        memberId: data.memberId || 0,
        number: data.number || "",
        phone: data.phone || "",
        products: this.tableData,
        products: products,
        remark: data.remark || "",
        saleChanceId: this.saleChanceId || 0,
        saleType: data.saleType || 0,
@@ -828,7 +830,7 @@
        if (res.code == 200) {
          console.log(res)
          this.quotationList = res.data.list
          this.count=res.data.count;
          this.count = res.data.count
          if (value === "全部产品") {
            // this.quotationList.map((item) => {
            // if (item.id === this.editConfig.infomation.quotationId) {
@@ -854,13 +856,13 @@
        restaurants = this.clientList
        console.log(restaurants, "客户单")
      } else if (value === "chance") {
        if(this.editConfig.infomation.client_name){
        if (this.editConfig.infomation.client_name) {
          restaurants = this.saleChancelist
        }
      } else if (value === "subbill") {
        restaurants = this.subOrderList
      } else if (value === "quotation") {
        if(this.editConfig.infomation.sale_chance_name){
        if (this.editConfig.infomation.sale_chance_name) {
          restaurants = this.quotationList
        }
      }
@@ -930,7 +932,7 @@
      if (value === "client") {
        this.editSelectClientConfig.editVisible = true
      } else if (value === "chance") {
        if(this.clientId){
        if (this.clientId) {
          this.editSelectChanceConfig.clientId = this.clientId
        }
        this.editSelectChanceConfig.editVisible = true
@@ -940,15 +942,15 @@
        this.editSelCommonConfig.clientId = this.clientId
      } else if (value === "quotation") {
        this.editSelCommonConfig.title = "报价单"
        if(this.saleChanceId&&this.clientId){
        if (this.saleChanceId && this.clientId) {
          this.editSelCommonConfig.clientId = this.clientId
          // 正向选择客户 销售机会  报价单
          this.editSelCommonConfig.isRequest = false
          this.editSelCommonConfig.count=this.count
          this.editSelCommonConfig.count = this.count
          this.editSelCommonConfig.tableInfomation = [...this.quotationList]
        }else{
           // 反向选择
          this.editSelCommonConfig.isRequest = true;
        } else {
          // 反向选择
          this.editSelCommonConfig.isRequest = true
        }
        this.editSelCommonConfig.editVisible = true
      }
@@ -956,10 +958,10 @@
    selClient(row, value) {
      if (value === "client") {
        this.editConfig.infomation.sale_chance_name = ""
        this.saleChanceId=''
        this.saleChanceId = ""
        this.editConfig.infomation.subbill_name = ""
        // 清空报价单
        this.editConfig.infomation.quotation_number =''
        this.editConfig.infomation.quotation_number = ""
        this.editConfig.infomation.client_name = row.name
        this.clientId = row.id
        this.getSaleChanceList(row)
@@ -970,7 +972,7 @@
        this.clientId = row.client.id
        this.saleChanceId = row.id
        // 清空报价单
        this.editConfig.infomation.quotation_number =''
        this.editConfig.infomation.quotation_number = ""
        this.isAddQuatation = false
        this.getQuotation(row.id)
      } else if (value === "subbill") {
@@ -1052,8 +1054,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, min: 110 },
          { label: "规格", prop: "specs" },
          { label: "型号", prop: "type" },
@@ -1070,9 +1073,9 @@
    },
    // 产品列表输入
    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
        }
      })
@@ -1097,13 +1100,18 @@
      // this.showSummary.show = true
    },
    // 新增方式修改
    getSelectArray(val) {
      if (val.length > 0) {
        val.map((item, index) => {
          item.productId = this.tableData.length + index + 1
        })
    getSelectArray(val, index) {
      if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
        this.tableData = []
      }
      this.tableData = this.tableData.concat(val)
      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
    },
src/views/sales/salesDetails/index.vue
@@ -535,6 +535,7 @@
      console.log(this.addConfig)
      this.editConfig.infomation = {
        ...this.addConfig,
        signTime: new Date().toLocaleDateString(),
        currency: "人民币",
        sale_chance_name: "",
        subbill_name: "",
src/views/sales/subOrder/AddSubOrderDialog.vue
@@ -167,9 +167,11 @@
          <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"
@@ -346,53 +348,59 @@
      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 === "新建") {
            getAddSubOrder(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 === "新建") {
              getAddSubOrder(params).then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message.success("添加成功")
                  this.$parent.getData()
                }
              })
            } else {
              getUpdateSubOrder(params).then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message.success("编辑成功")
                  this.$parent.getData()
                }
              })
            }
            getUpdateSubOrder(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,
        masterOrderId: this.masterId || 0,
        memberId: data.memberId || 0,
        number: data.number || "",
        product: this.tableData,
        product: products,
        codeStandID: data.ID
      }
      return params
@@ -515,8 +523,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 },
@@ -528,27 +537,43 @@
    },
    // 产品列表输入
    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,
        unit: ""
      })
      // this.productId++
      // this.tableData.push({
      //   productId: this.productId,
      //   id: 0,
      //   amount: 0,
      //   desc: "",
      //   name: "",
      //   number: "",
      //   price: 0,
      //   total: 0,
      //   unit: ""
      // })
      // 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
    },
    //  产品清空