songshankun
2023-10-21 5aecd21ebbdeb856629fd4a2b4e410e0f42ba587
feat: 销售机会新增和编辑弹窗加产品编辑
1个文件已修改
128 ■■■■■ 已修改文件
src/views/sales/salesOpportunity/AddSalesOpportunityDialog.vue 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sales/salesOpportunity/AddSalesOpportunityDialog.vue
@@ -299,6 +299,30 @@
              </el-col>
            </el-row>
          </div>
          <!-- 产品管理 -->
          <div class="basic-info-title" style="display: flex">
            产品管理
            <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 class="product-view">
            <CommonFormTableView
                :show-summary="showSummary"
                :product-table-list="productTableList"
                @inputContent="inputContent"
                @addProductClick="addProductClick"
                @emptyProductClick="emptyProductClick"
                @recalculateProductClick="recalculateProductClick"
                @clearupProduct="clearupProduct"
            />
          </div>
          <!-- 商机七要素 -->
          <div class="basic-info-title">商机七要素(5W2P)</div>
          <div class="basic-info-view">
@@ -579,6 +603,7 @@
import WordInput from "@/components/wordInput.vue"
import codeMixin from "@/views/client/followupRecords/mixin/codeMixin"
import { getContactList } from "@/api/client/contacts"
import CommonFormTableView from "@/components/makepager/CommonFormTableView.vue";
export default {
  name: "AddSalesOpportunityDialog",
  mixins: [codeMixin],
@@ -594,7 +619,7 @@
      }
    }
  },
  components: { WordInput, SelectClientDialog, SelectContactDialog },
  components: {CommonFormTableView, WordInput, SelectClientDialog, SelectContactDialog },
  computed: {
    searchCommonHeight() {
      return this.$refs.searchCommonView.offsetHeight
@@ -646,7 +671,16 @@
      contactId: this.editCommonConfig.infomation.contact_id,
      objCode: { name: "", page: 0, pageSize: 0, type: "销售机会编码", codeStandID: "" },
      isContact: true,
      contactNamelist: []
      contactNamelist: [],
      tableData: [],
      productTableList: {},
      showSummary: {
        show: true,
        total: true,
        sumProp: ["Amount", "total"],
        mergeNumber: 2
      },
      productId:1,
    }
  },
  created() {
@@ -654,6 +688,7 @@
    if (this.editConfig.title !== "新建" && this.editConfig.infomation.province_id !== 0) {
      this.getCityList(this.editConfig.infomation.province_id, "edit")
    }
    this.setTableForm()
    this.getCommonData()
    this.formInfo()
    if (this.editConfig.title === "编辑") {
@@ -714,7 +749,12 @@
      this.$refs[formName].validate((valid) => {
        this.validateFormNumber()
        if (valid) {
          console.log(this.editConfig.infomation)
          const hasProduct = this.tableData.every(ele=>!!ele.name)
          if (!hasProduct){
            this.$message.error("产品名称不能为空")
            return
          }
          const params = this.saveParams()
          console.log(params)
          if (this.editConfig.title === "新建") {
@@ -782,7 +822,8 @@
        detail_address: data.detail_address || "",
        codeStandID: data.ID,
        codeRule: this.codeRule
        codeRule: this.codeRule,
        products: this.tableData,
      }
      return params
    },
@@ -893,6 +934,85 @@
          }
        }
      })
    },
    setTableForm() {
      if (this.editConfig.title === "新建" || this.editConfig.infomation.products.length === 0) {
        this.tableData = [
          {
            productId: this.productId,
            id: 0,
            amount: 0,
            desc: "",
            name: "",
            number: "",
            price: 0,
            total: 0
          }
        ]
      } else {
        this.tableData = this.editConfig.infomation.products
        this.tableData.map((item, index) => {
          item.productId = index + 1
        })
      }
      this.productTableList = {
        tableData: this.tableData,
        tableColumn: [
          { label: "#", prop: "productId", width: 40 },
          { label: "产品名称", prop: "name", productName: true, isRequird: true },
          { label: "产品编号", prop: "number" },
          { label: "数量", prop: "amount", inputNumber: true, isRequird: true },
          { label: "销售单价", prop: "price", inputFloat: true },
          { label: "价税合计", prop: "total", inputFloat: true }
        ]
      }
    },
    // 产品列表输入
    inputContent(val, prop, row) {
      this.productId = row.productId
      this.tableData.map((item) => {
        if (item.productId === row.productId) {
          item[prop] = val
        }
      })
    },
    // 产品新增
    addProductClick() {
      this.productId++
      this.tableData.push({
        productId: this.productId,
        id: 0,
        amount: 0,
        desc: "",
        name: "",
        number: "",
        price: 0,
        total: 0
      })
      this.showSummary.show = true
    },
    //  产品清空
    emptyProductClick() {
      this.productId = 1
      this.tableData = [
        {
          productId: this.productId,
          id: 0,
          amount: 0,
          desc: "",
          name: "",
          number: "",
          price: 0,
          total: 0
        }
      ]
      this.productTableList.tableData = this.tableData
    },
    // 产品重算
    recalculateProductClick() {},
    clearupProduct(data) {
      this.tableData = data
      this.productTableList.tableData = this.tableData
    }
  }
}