333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
  <div class="page-list-container">
    <!--数据Table-->
    <yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
    </yrt-data-list>
 
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" @on-detail-change="onDetailChange">
      <!--自定义按钮插槽-->
      <template slot="footer-button-region" slot-scope="{ formData, details }">
        <!--打印条码按钮-->
        <el-button type="success" icon="el-icon-yrt-saomiao8" @click.native="toPurchaseOrder(formData, details)">转到预到货单</el-button>
      </template>
    </yrt-editor>
 
    <!--明细选择器-->
    <yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @on-selected="onSelected"></yrt-selector>
  </div>
</template>
 
<script>
import baseLayout from "@/components/common/base-layout.vue";
import yrtSelector from "@/components/common/yrtSelector.vue";
 
export default {
  name: "tms-way-quotation",
  components: {
    yrtSelector
  },
  mixins: [baseLayout],
  data() {
    return {
      // 选择器配置参数
      selectorConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/s-product-selector"
      }
    };
  },
  methods: {
    // 明细添加
    detailAdd() {
      this.selectorConfig.visible = true;
    },
    // 将选择器选择中的数据填充到明细表中
    onSelected(rows) {
      this.editor.addDetailDataRow(rows);
      this.selectorConfig.visible = false;
    },
    // 明细按钮点击事件
    detailButtonClick(authNode) {
      switch (authNode) {
        case "add":
          // 明细添加
          this.detailAdd();
          break;
      }
    },
    // 明细字段改变
    onDetailChange(ref, val, row, field) {
      // 数量改变事件
      if (field.prop === "QuantityOrder") {
        if (val && row.SalePrice) {
          // row.RowTotal =val*row.SalePrice;
          this.$set(row, "RowTotal", val * row.SalePrice);
        }
      }
      // 单价改变事件
      if (field.prop === "SalePrice") {
        if (val && row.QuantityOrder) {
          this.$set(row, "RowTotal", val * row.QuantityOrder);
        }
      }
      // 合计数量求和
      let TotalQuantityOrder = 0;
      let GrandTotal = 0;
      var formData = this.editor.formData;
      var detailRows = formData["TMS_QuotationList"].rows;
      detailRows.forEach(item => {
        if (item.QuantityOrder) {
          TotalQuantityOrder += item.QuantityOrder;
        }
        if (item.RowTotal) {
          GrandTotal += item.RowTotal;
        }
      });
      this.editor.changeValue("TotalQuantityOrder", TotalQuantityOrder);
      this.editor.changeValue("GrandTotal", GrandTotal);
    },
    // 转到预到货单
    toPurchaseOrder(formData, details) {
      const Quotation_Id = formData.Quotation_Id;
      const url = "/api/TMS_Quotation/ChangePurchaseOrder";
      const params = {
        Quotation_Id: Quotation_Id
      };
 
      var callback = res => {
        this.common.showMsg(res);
      };
 
      this.common.ajax(url, params, callback, false);
    }
  }
};
</script>