yangfeng
2023-08-21 46ed69e3b72658140a40127f4bae16bef9a02d56
src/views/sales/subOrder/AddSubOrderDialog.vue
@@ -126,70 +126,14 @@
          </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-view">
            <el-row>
              <el-col :span="7" :offset="17">
                <el-form-item prop="discount">
                  <template slot="label">
                    <span>整单折扣</span>
                    <el-select
                      v-model="discount"
                      placeholder="请选择"
                      size="mini"
                      style="width: 104px; margin-left: 3px"
                      disabled
                    >
                      <el-option
                        v-for="item in discountOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </template>
                  <el-input v-model="editConfig.infomation.discount" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="7" :offset="17">
                <el-form-item prop="discount">
                  <template slot="label">
                    <span>调整</span>
                    <el-select
                      v-model="adjust"
                      placeholder="请选择"
                      size="mini"
                      style="width: 74px; margin-left: 3px"
                      disabled
                    >
                      <el-option
                        v-for="item in adjustOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </template>
                  <el-input v-model="editConfig.infomation.discount" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="7" :offset="17">
                <el-form-item label="合计" prop="total">
                  <el-button type="text" v-model="editConfig.infomation.total" style="color: #555; font-size: 13px">{{
                    editConfig.infomation.total ? editConfig.infomation.total : "0.00"
                  }}</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </div>
      </el-form>
@@ -266,9 +210,9 @@
      productTableList: {},
      showSummary: {
        show: true,
        total: false,
        sumProp: ["other1", "other7"],
        mergeNumber: 7
        total: true,
        sumProp: ["Amount", "total"],
        mergeNumber: 2
      },
      editSelectClientConfig: {
        editVisible: false,
@@ -319,26 +263,38 @@
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(this.editConfig.infomation)
          const params = this.saveParams()
          console.log(params)
          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()
              }
            })
          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 {
            getUpdateSubOrder(params).then((res) => {
              console.log(res)
              this.editConfig.visible = false
              if (res.code === 200) {
                this.$message.success("编辑成功")
                this.$parent.getData()
              }
            })
            const params = this.saveParams()
            console.log(params)
            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()
                }
              })
            }
          }
        } else {
          console.log("error submit")
@@ -369,11 +325,6 @@
      } else if (value === "master") {
        restaurants = this.masterOrderList
      }
      // else if (value === "chance") {
      //   restaurants = this.saleChancelist
      // } else {
      //   restaurants = this.saleLeadlist
      // }
      var results = queryString ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants
      cb(results)
    },
@@ -430,86 +381,84 @@
    // 设置允许上传文件格式
    setFormatClick() {},
    setTableForm() {
      if (this.editConfig.title === "新建") {
      if (this.editConfig.title === "新建" || this.editConfig.infomation.products.length === 0) {
        this.tableData = [
          {
            id: 1,
            Amount: 0,
            IsSale: true,
            MaterialMode: "",
            MinInventory: 0,
            Name: "",
            Number: "",
            PurchaseType: "",
            SalePrice: 0,
            Unit: ""
            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: "id", width: 40 },
          { label: "产品名称", prop: "Name", input: true, isRequird: true },
          { label: "产品编号", prop: "Number" },
          { label: "数量", prop: "Amount", input: true, isRequird: true },
          { label: "销售单价", prop: "Unit", input: true },
          { label: "价税合计", prop: "total", input: true },
          { label: "描述", prop: "other8" }
          { 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) {
      console.log("aaaaaaaa")
      console.log(val, prop)
      this.productId = row.id
      this.productId = row.productId
      this.tableData.map((item) => {
        if (item.id === row.id) {
        if (item.productId === row.productId) {
          item[prop] = val
        }
      })
      console.log(this.tableData)
    },
    // 产品新增
    addProductClick() {
      this.productId++
      this.tableData.push({
        id: this.productId,
        Amount: 0,
        IsSale: true,
        MaterialMode: "",
        MinInventory: 0,
        Name: "",
        Number: "",
        PurchaseType: "",
        SalePrice: 0,
        Unit: ""
        productId: this.productId,
        id: 0,
        amount: 0,
        desc: "",
        name: "",
        number: "",
        price: 0,
        total: 0
      })
      this.showSummary.show = true
    },
    //  产品清空
    emptyProductClick() {
      this.productId = 1
      this.tableData = [
        {
          id: 1,
          Amount: 0,
          IsSale: true,
          MaterialMode: "",
          MinInventory: 0,
          Name: "",
          Number: "",
          PurchaseType: "",
          SalePrice: 0,
          Unit: ""
          productId: this.productId,
          id: 0,
          amount: 0,
          desc: "",
          name: "",
          number: "",
          price: 0,
          total: 0
        }
      ]
      this.productTableList.tableData = this.tableData
    },
    // 产品重算
    recalculateProductClick() {}
    recalculateProductClick() {},
    clearupProduct(data) {
      this.tableData = data
      this.productTableList.tableData = this.tableData
    }
  }
}
</script>