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
<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" :is-init-load="false">
    </yrt-data-list>
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :btn-read-only="btnReadOnly" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :auth-nodes="authNodes" @on-blur="onBlur" @on-add-load-after="onAddLoadAfter" @on-edit-load-after="onEditLoadAfter">
      <!--自定义按钮插槽-->
      <template slot="footer-button-region" slot-scope="{ formData, details }">
        <!--打印条码按钮-->
        <el-button :disabled="btnReadOnly.returngoods" type="primary" icon="el-icon-yrt-tuihuo" @click.native="runReturngoods()">退货</el-button>
        <el-button :disabled="btnReadOnly.cancelReturn" type="primary" icon="el-icon-yrt-tuihuochuli" @click.native="runCancelReturn()">取消退货</el-button>
      </template>
    </yrt-editor>
  </div>
</template>
 
<script>
import baseLayout from "@/components/common/base-layout.vue";
 
export default {
  name: "tms-way-bill-tracking",
  components: {
    baseLayout
  },
  mixins: [baseLayout],
  data() {
    return {
      // 自动加载
      jiazaiorder: ["plateCode"],
      // 赋值
      fuzhiorder: ["wayBillCode"]
    };
  },
  methods: {
    // 列表页面按钮点击事件
    buttonClick(authNode) {
      switch (authNode) {
        case "returnGoods":
          // 退货
          this.runReturngoods();
          return false;
        case "cancelReturn":
          // 取消退货
          this.runCancelReturn();
          return false;
      }
    },
 
    // 退货操作
    runReturngoods() {
      var editorRef = this.editor;
      var formData = editorRef.formData;
      if (!formData.wayBillCode) {
        this.$message.error("请输入运单号");
        return;
      }
      var url = "/api/tms/wayBill/billReturnGoods";
      const params = {
        ids: [formData.wayBill_Id],
        wayBillCode: formData.wayBillCode,
        abnormalReason: formData.abnormalReason,
        remark: formData.remark
      };
      this.common.ajax(url, params, res => {
        this.common.showMsg(res);
        if (res.result) {
          this.$set(this.btnReadOnly, "returngoods", true);
          // 刷新窗口
          this.dataList.reload();
          // 关闭窗口
          editorRef.cancel();
        }
      });
    },
 
    // 取消退货
    runCancelReturn() {
      var editorRef = this.editor;
      var formData = editorRef.formData;
      if (!formData.wayBillCode) {
        this.$message.error("请输入运单号");
        return;
      }
      // 获得已选中的ID
      const url = "/api/tms/wayBill/billmultiCancelReturn";
      const params = {
        wayBillCode: formData.wayBillCode,
        ids: [formData.wayBill_Id]
      };
      this.common.ajax(url, params, res => {
        this.common.showMsg(res);
        if (res.result) {
          // 刷新窗口
          this.dataList.reload();
          // 关闭窗口
          editorRef.cancel();
        }
      });
    },
    onEditLoadAfter(formData) {
      var toStatus = formData.toStatus;
      if (
        toStatus === "新建" ||
        toStatus === "审核成功" ||
        toStatus === "待录入" ||
        toStatus === "已提交" ||
        toStatus === "录入异常" ||
        toStatus === "组板异常" ||
        toStatus === "处理中" ||
        toStatus === "处理完成"
      ) {
        this.$set(this.btnReadOnly, "returngoods", false);
        this.$set(this.btnReadOnly, "cancelReturn", true);
      } else if (toStatus === "已退货") {
        this.$set(this.btnReadOnly, "returngoods", true);
        this.$set(this.btnReadOnly, "cancelReturn", false);
      } else {
        this.$set(this.btnReadOnly, "returngoods", false);
        this.$set(this.btnReadOnly, "cancelReturn", true);
      }
    },
    onAddLoadAfter(formData) {
      this.$set(this.btnReadOnly, "returngoods", true);
      this.$set(this.btnReadOnly, "cancelReturn", true);
    },
    // 失去焦点加载信息
    onBlur(ref, val, row, field) {
      if (field.label === "运单号") {
        if (!val) {
          return;
        }
        const wayBillCode = val;
        const url = "/api/tms/wayBill/getPlateCode";
        const params = {
          wayBillCode: wayBillCode
        };
        const callback = res => {
          this.common.showMsg(res);
          if (res.result) {
            if (res.data.plateCode) {
              this.jiazaiorder.forEach(field => {
                this.$set(this.editor.formData, field, res.data[field]);
              });
            }
            if (res.data.consignor_Id) {
              this.$set(this.editor.formData, "consignor_Id", res.data.consignor_Id);
              this.$set(this.editor.formData, "consignorName", res.data.consignorName);
              this.$set(this.editor.formData, "plateCode", res.data.plateCode);
              this.$set(this.editor.formData, "fromStatus", res.data.orderStatus);
              this.$set(this.editor.formData, "wayBill_Id", res.data.wayBill_Id);
              this.$set(this.editor.formData, "orderType", res.data.orderType);
              this.$set(this.editor.formData, "storage_Id", res.data.storage_Id);
              this.$set(this.editor.formData, "storageName", res.data.storageName);
              var fromdata = res.data.orderStatus;
              if (
                fromdata === "已揽收" ||
                fromdata === "审核成功" ||
                fromdata === "待录入" ||
                fromdata === "已提交" ||
                fromdata === "录入异常" ||
                fromdata === "组板异常" ||
                fromdata === "处理中" ||
                fromdata === "处理完成"
              ) {
                this.$set(this.btnReadOnly, "returngoods", false);
                this.$set(this.btnReadOnly, "cancelReturn", true);
              } else if (fromdata === "已退货") {
                this.$set(this.btnReadOnly, "returngoods", true);
                this.$set(this.btnReadOnly, "cancelReturn", false);
              } else {
                this.$set(this.btnReadOnly, "returngoods", true);
                this.$set(this.btnReadOnly, "cancelReturn", true);
              }
            }
          } else {
            this.$set(this.editor.formData, "wayBillCode", "");
          }
        };
        this.common.ajax(url, params, callback, true);
      }
    }
  }
};
</script>