zuozhengqing
2023-11-18 65bc5629504c5e138d8540cdf9b0eb3796842d4a
src/views/purchaseManage/purchase/components/AddPurchase.vue
@@ -31,6 +31,7 @@
                  style="width:100%;"
                >
                  <el-select
                    :disabled="editConfig.isDisabled"
                    placeholder="请选择采购类型"
                    v-model="editConfig.infomation.purchaseTypeId"
                    clearable
@@ -44,6 +45,7 @@
                    ></el-option>
                  </el-select>
                  <i
                    v-if="!editConfig.isDisabled"
                    class="el-icon-setting margin_left_10px cursor_pointer"
                    style="font-size: 20px; color: #333"
                    @click="handleShow"
@@ -55,11 +57,12 @@
                <el-form-item label="供应商名称" prop="supplierName">
                  <div class="custom-name">
                    <el-autocomplete
                      :disabled="editConfig.isDisabled"
                      style="width: calc(100% - 40px)"
                      v-model="editConfig.infomation.supplierName"
                      :fetch-suggestions="
                        (queryString, callback) => {
                          querySearchAsync(queryString, callback, 'client');
                          querySearchAsync(queryString, callback, 'supplier');
                        }
                      "
                      value-key="name"
@@ -67,6 +70,7 @@
                      @select="handleSelectClient('client', $event)"
                    ></el-autocomplete>
                    <div
                      v-if="!editConfig.isDisabled"
                      class="common-select-btn"
                      @click="selClientClick('client')"
                    >
@@ -80,7 +84,8 @@
                      class="common-select-btn"
                      @click="clearupClient('client')"
                    >
                      <i class="el-icon-remove-outline" title="清除"></i>
                      <i class="el-icon-remove-outline"
                      v-if="!editConfig.isDisabled" title="清除"></i>
                    </div>
                  </div>
                </el-form-item>
@@ -97,6 +102,7 @@
              <el-col :span="12">
                <el-form-item label="采购单名称" prop="name">
                  <el-input
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.name"
                    placeholder="请填写"
                    clearable
@@ -106,6 +112,7 @@
              <el-col :span="12">
                <el-form-item label="供应商联系人" prop="contact">
                  <el-input
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.contact"
                    placeholder="请填写"
                    clearable
@@ -115,6 +122,7 @@
              <el-col :span="12">
                <el-form-item label="联系电话" prop="phone">
                  <el-input
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.phone"
                    placeholder="请填写"
                    clearable
@@ -124,6 +132,7 @@
              <el-col :span="12">
                <el-form-item label="签约日期" prop="signingDate">
                  <el-date-picker
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.signingDate"
                    style="width: 100%"
                    type="date"
@@ -137,6 +146,7 @@
              <el-col :span="12">
                <el-form-item label="交付日期" prop="deliveryDate">
                  <el-date-picker
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.deliveryDate"
                    style="width: 100%"
                    type="date"
@@ -150,6 +160,7 @@
              <el-col :span="24">
                <el-form-item label="备注信息" prop="remark">
                  <el-input
                    :disabled="editConfig.isDisabled"
                    type="textarea"
                    :autosize="{ minRows: 3, maxRows: 4 }"
                    maxlength="500"
@@ -182,6 +193,7 @@
                  <el-select
                    v-model="editConfig.infomation.wholeDiscountType"
                    placeholder="请选择"
                    :disabled="editConfig.isDisabled"
                    filterable
                    @change="getTotal"
                  >
@@ -195,7 +207,7 @@
                  <el-input
                    v-model="editConfig.infomation.wholeDiscount"
                    size="mini"
                    :disabled="editConfig.infomation.wholeDiscountType?false:true"
                    :disabled="editConfig.isDisabled"
                    @change="getTotal"
                    placeholder="请填写"
                  ></el-input>
@@ -206,6 +218,7 @@
              <div class="table-bottom-l">
                <el-form-item label="调整" prop="member_id">
                  <el-select
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.priceAdjustmentType"
                    placeholder="请选择"
                    filterable
@@ -219,9 +232,9 @@
              <div class="table-bottom-r">
                <el-form-item label="" prop="member_id">
                  <el-input
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.priceAdjustment"
                    size="mini"
                    :disabled="editConfig.infomation.priceAdjustmentType?false:true"
                    @change="getTotal"
                    placeholder="请填写"
                  ></el-input>
@@ -265,6 +278,7 @@
<script>
import CommonFormTableView from "@/components/makepager/CommonFormTableView";
import BomDialog from "@/components/makepager/BomDialog";
import { getProductList } from "@/api/productManage/product"
import {
  addPurchase,
@@ -358,8 +372,12 @@
  },
  created() {
    this.handleGetBomKindDictList();
    this.$store.dispatch("getSupplier")
  },
  computed: {
    supplierList() {
      return this.$store.state.getSupplierName.supplierList
    }
  },
  watch:{
    'editCommonConfig.visible':{
@@ -433,8 +451,12 @@
    },
    handleConfirmSave(data) {
      console.log(data,'data')
      data.forEach(ele=>{
        delete ele.created_at
      })
      savePurchaseType(data).then((res) => {
        if (res.code == 200) {
        if (res.code === 200) {
          this.$message({
            message: "操作成功!",
            type: "success",
@@ -442,6 +464,12 @@
          this.$refs.editDialog.editDialogVisible = false;
          this.handleGetBomKindDictList(true);
        }
      },(err)=>{
        console.error(err)
        this.$message({
          message: "操作失败!",
          type: "warning",
        });
      });
    },
    validatorPhone(rule, value, callback) {
@@ -481,10 +509,8 @@
            this.$message.error("产品名称不能为空");
          } else {
            const params = this.saveParams();
            console.log(params);
            if (this.editConfig.title === "创建") {
              addPurchase(params).then((res) => {
                console.log(res);
                this.editConfig.visible = false;
                if (res.code === 200) {
                  this.$message.success("添加成功");
@@ -519,7 +545,7 @@
      let params = {
        productList:this.tableData,
        purchase:{
          supplierId:this.supplierId||0,
          supplierId:data.supplierId,
          signingDate:data.signingDate||'',
          remark:data.remark,
          orderSource:data.orderSource||'',
@@ -546,9 +572,10 @@
    },
    // 选择客户相关方法
    querySearchAsync(queryString, cb, value) {
      this.productTableList.tableProductList=[]
      var restaurants = [];
      if (value === "client") {
        restaurants = this.clientList;
      if (value === "supplier") {
        restaurants = this.supplierList;
      } 
      var results = queryString
        ? restaurants.filter(this.createStateFilter(queryString))
@@ -562,11 +589,22 @@
        );
      };
    },
    handleSelectClient(value, item) {
      console.log(value);
    async handleSelectClient(value, item) {
      this.productTableList.supplierId=item.ID
      if (value === "client") {
        this.supplierId = item.id;
        this.editConfig.infomation.supplierId=item.ID
      }
      await getProductList({
        supplierId:item.ID,
        page:1,
        pageSize:100
      }).then((res)=>{
        if(res.data.code===200){
          this.productTableList.tableProductList = res.data.data.list
          console.log(this.productTableList.tableProductList,"pop")
        }
      })
    },
    selClientClick() {
      this.editSelectSupplierConfig.editVisible = true;
@@ -579,6 +617,7 @@
    },
    // 清除已选择用户
    clearupClient(value) {
      this.emptyProductClick()
      if (value == "client") {
        this.$set(this.editConfig.infomation, "supplierName", "");
        this.supplierId = null;
@@ -609,7 +648,10 @@
        // });
      }
      this.productTableList = {
        tableProductList:[],
        supplierId:undefined,
        tableData: this.tableData,
        disabled:this.editConfig.isDisabled,
        tableColumn: [
          {
            label: "产品名称",
@@ -617,19 +659,21 @@
            min: 180,
            productName: true,
            isRequird: true,
            disabled:this.editConfig.isDisabled,
          },
          { label: "产品编号", prop: "number", min: 150,},
          { label: "计量单位", prop: "unit" },
          { label: "规格型号", prop: "specifications" },
          { label: "数量", prop: "amount", inputNumber: true, isRequird: true },
          { label: "规格型号", prop: "specifications",},
          { label: "数量", prop: "amount", inputNumber: true,disabled:this.editConfig.isDisabled, },
          {
            label: "采购单价",
            prop: "price",
            inputFloat: true,
            isRequird: true,
            disabled:this.editConfig.isDisabled,
          },
          { label: "价税合计", prop: "total", inputFloat: true,disabled:true,multiply:true, },
          { label: "描述", prop: "remark", input: true },
          { label: "价税合计", prop: "total", inputFloat: true,disabled:this.editConfig.isDisabled,multiply:true, },
          { label: "描述", prop: "remark", input: true,disabled:this.editConfig.isDisabled},
        ],
      };
      this.toal=this.editConfig.infomation.realTotalPrice