schangxiang@126.com
2025-09-19 9be9c3784b2881a3fa25e93ae2033dc2803c0ed0
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<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" :on-delete-before="onDeleteBefore">
      <template slot="common-column-slot" slot-scope="{row, col}">
        <template v-if="col.prop=='quotationStatus'">
          <el-tag :color="setStatusBgColor(row[col.prop])" :style="setStatusColor(row[col.prop])">
            {{ row[col.prop] }}
          </el-tag>
        </template>
        <!--审核字段-->
        <template v-else-if="col.prop=='auditing'">
          <template>
            <el-tag v-if="row[col.prop]==0" color="#ffff33" style="color:black;border:0">
              {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]==1" color="#ff0033" style="color:white;border:0">
              {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]==2" color="#33cc33" style="color:black;border:0;color:#fff;">
              {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <span v-else>
              {{ row[col.prop] }}
            </span>
          </template>
        </template>
        <!--连接字段-->
        <template v-else-if="col.prop==dataOptions.linkColumn">
          <el-link type="primary" @click.native="()=>{linkEditor(row[dataOptions.idField]);}">{{ row[col.prop] }}</el-link>
        </template>
        <template v-else-if="col.dropdown_Id>0">
          {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
        </template>
        <template v-else>
          <template v-if="['date', 'datetime'].indexOf(col.dataType)>=0 && col.formatter">
            {{ common.formatDate(row[col.prop], col.formatter) }}
          </template>
          <template v-else-if="['byte', 'int32', 'int64', 'decimal', 'double'].indexOf(col.dataType)>=0 && col.formatter">
            {{ common.formatNumber(row[col.prop], col.formatter) }}
          </template>
          <template v-else>
            {{ row[col.prop] }}
          </template>
        </template>
      </template>
    </yrt-data-list>
 
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :config="editorOptions.config" :data-options="dataOptions" :action.sync="editorOptions.action" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" @on-detail-change="onDetailChange" @on-edit-load-after="onEditLoadAfter" @on-add-load-after="onAddLoadAfter">
      <!--自定义按钮插槽-->
      <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>
        <!-- //:disabled="btnReadOnly.toPurchaseOrder" -->
      </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: "user-way-quotation",
  components: {
    yrtSelector
  },
  mixins: [baseLayout],
  // 自定义JSON路由地址
  custoJsonmRoute: "/user/way/quotation",
  data() {
    return {
      // 选择器配置参数
      selectorConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/s-product-selector"
      },
      authNodes: {
        add: true,
        Delete: true,
        export: true,
        save: true
      },
      // 状态值
      statusValueList: [
        {
          status: "新建",
          bgColor: "#ffff66",
          color: "#000"
        },
        {
          status: "审核失败",
          bgColor: "#ffcc66",
          color: "#fff"
        },
        {
          status: "已审核",
          bgColor: "#33cc33",
          color: "#fff"
        },
        {
          status: "完全交货",
          bgColor: "#009999",
          color: "#fff"
        },
        {
          status: "已转预到货单",
          bgColor: "#00ccff",
          color: "#fff"
        },
        {
          status: "终止",
          bgColor: "#ff6600",
          color: "#fff"
        }
      ]
    };
  },
  methods: {
    // 状态背景颜色
    setStatusBgColor(status) {
      var colorItem = this.statusValueList.find(item => {
        return item.status === status;
      });
      var bgColor = "#fffff";
      if (colorItem) bgColor = colorItem.bgColor;
 
      return bgColor;
    },
    // 状态字体颜色
    setStatusColor(status) {
      var colorItem = this.statusValueList.find(item => {
        return item.status === status;
      });
      var color = "#fffff";
      if (colorItem) color = colorItem.color;
 
      return {
        border: 0,
        color: color
      };
    },
    // 明细添加
    detailAdd() {
      this.selectorConfig.visible = true;
    },
    // 将选择器选择中的数据填充到明细表中
    onSelected(rows) {
      rows.forEach(element => {
        element.salePrice = element.ratePrice;
        //  element.ratePrice = element.salePrice;
      });
      this.editor.addDetailDataRow(rows);
      this.selectorConfig.visible = false;
    },
    // 将选择器选择中的数据填充到明细表中
    // onPositionSelected(rows) {
    //   rows.forEach(element => {
    //      element.ratePrice = element.salePrice;
    //   });
 
    //   this.editor.addDetailDataRow(rows);
    //   this.selectorPositionConfig.visible = false;
    // },
    // 明细按钮点击事件
    detailButtonClick(authNode) {
      switch (authNode) {
        case "add":
          // 明细添加
          this.detailAdd();
          return false;
      }
    },
    // 明细字段改变
    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/user/quotaion/changePurchaseOrder";
      const params = {
        quotation_Id: quotation_Id
      };
      const ref = this.dataList;
      var callback = res => {
        this.common.showMsg(res);
        // if (res.result) {
        this.editorOptions.config.visible = false;
        ref.loadData();
        // }
      };
      this.common.ajax(url, params, callback, false);
    },
    // 新建弹出后事件
    onAddLoadAfter(formData) {
      const userInfo = this.common.getUserInfo();
      this.$set(formData, "consignor_Id", userInfo.consignor_Id);
      this.$set(formData, "consignorCode", userInfo.consignorCode);
      this.$set(formData, "consignorName", userInfo.consignorName);
      this.onEditLoadAfter(formData);
    },
    // 数据加载后
    onEditLoadAfter(formData) {
      var quotationStatus = formData.quotationStatus;
      if (quotationStatus === "新建") {
        // 新建
        this.btnReadOnly.auditing = false;
        this.btnReadOnly.stop = false;
        this.btnReadOnly.open = true;
        this.btnReadOnly.save = false;
        this.btnReadOnly.toPurchaseOrder = true;
        this.editorOptions.config.disabled = false; // 整个对话框可编辑
      } else if (quotationStatus === "已审核") {
        // 审核成功
        this.btnReadOnly.auditing = true;
        this.btnReadOnly.stop = false;
        this.btnReadOnly.open = true;
        this.btnReadOnly.save = true;
        this.btnReadOnly.toPurchaseOrder = false;
        this.editorOptions.config.disabled = true; // 整个对话框可编辑
      } else if (quotationStatus === "已转预到货单") {
        // 已转预到货单
        this.btnReadOnly.auditing = true;
        this.btnReadOnly.stop = false;
        this.btnReadOnly.open = true;
        this.btnReadOnly.save = true;
        this.btnReadOnly.toPurchaseOrder = true;
        this.editorOptions.config.disabled = true; // 整个对话框可编辑
      } else if (quotationStatus === "终止") {
        // 9-终止
        this.btnReadOnly.auditing = true;
        this.btnReadOnly.stop = true;
        this.btnReadOnly.open = false;
        this.btnReadOnly.save = true;
        this.btnReadOnly.toPurchaseOrder = true;
        this.editorOptions.config.disabled = true; // 整个对话框可编辑
      } else {
        this.btnReadOnly.auditing = true;
        this.btnReadOnly.stop = true;
        this.btnReadOnly.open = true;
        this.btnReadOnly.save = true;
        this.btnReadOnly.toPurchaseOrder = true;
        this.editorOptions.config.disabled = true; // 整个对话框可编辑
      }
    },
    // 删除前事件
    onDeleteBefore(rows) {
      let quotationStatus = true;
      rows.forEach(rowData => {
        quotationStatus = rowData.quotationStatus;
        if (quotationStatus !== "新建") {
          quotationStatus = false;
        }
      });
      if (quotationStatus === false) {
        this.$message.error("仅可删除新建入库计划单!");
        return false;
      }
      return true;
    }
  }
};
</script>