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
<template>
  <div class="page-list-container">
    <!-- 数据Table -->
    <yrt-data-list :fixed-where="fixedwhere" :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">
      <template slot="common-column-slot" slot-scope="{ row, col }">
 
        <!-- 状态 颜色 -->
        <template v-if="col.prop=='orderStatus'">
          <template>
            <el-tag v-if="row[col.prop]=='待配送'" color="#806B1A" style="color:white;border:0">
              {{ row[col.prop] }}
            </el-tag>
          </template>
        </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=='wayBillType'">
          <template>
            <el-tag v-if="row[col.prop]=='仓配单'" color="#33cc33" style="color:white;border:0">
              {{ row[col.prop] }}
            </el-tag>
          </template>
        </template>
      </template>
    </yrt-data-list>
    <!--数据编辑器Editor-->
    <yrt-editor :before-close="beforeClose" :ref="editorRef" :edit-button-click="editButtonClick" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :btn-read-only="btnReadOnly" @on-edit-load-after="onEditLoadAfter">
    </yrt-editor>
    <!--新建页面-->
    <create-dist-dialog ref="childData" :visible.sync="createDistConfig.isShowDialog" :config="createDistConfig" @generate-bills="generatebill">
    </create-dist-dialog>
  </div>
</template>
<script>
import baseLayout from "@/components/common/base-layout.vue";
import CreateDistDialog from "./components/create-dist-dialog";
 
export default {
  name: "tms-way-bill",
  components: { CreateDistDialog },
  mixins: [baseLayout],
  data() {
    return {
      fixedwhere: { orderStatus: ["待配送"] },
      createDistConfig: {
        // 显示新建页面对话框
        isShowDialog: false,
        title: "生成配送派车单"
      }
    };
  },
  methods: {
    buttonClick(authNode) {
      switch (authNode) {
        case "distributionbill":
          // 配送派车单
          this.distributionbill();
          return true;
      }
    },
    distributionbill() {
      const ids = this.dataList.dataListSelections.map(item => item.wayBill_Id);
      if (!ids.length) {
        this.$message.error("至少选择一行!");
        return;
      }
      const Total = this.dataList.dataListSelections;
      // 合计件数
      let totalQuantity = 0;
      // 合计数量
      let totalNumber = 0;
      // 合计重量
      let totalWeight = 0.0;
      // 合计体积
      let totalVolume = 0.0;
      Total.forEach(item => {
        totalQuantity += item.totalQuantity;
        totalNumber += item.totalQuantityOrder;
        totalWeight += item.totalWeight;
        totalVolume += item.totalVolume;
      });
      // 传入到子组件
      const total = { totalQuantity, totalNumber, totalWeight, totalVolume };
      this.$refs.childData.childTotal(total);
 
      // 获取司机和车辆信息
      const url = "/api/tms/wayBillDistribution/distributionbill";
      const params = {};
      const callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          // 获取司机信息集合
          const driverDataList = res.data.driverDataList;
          // 传递到子组件 driver
          this.$refs.childData.driver(driverDataList);
          // 获取车辆信息集合
          const vehicleDataList = res.data.vehicleDataList;
          // 传递到子组件 vehicle
          this.$refs.childData.vehicle(vehicleDataList);
        }
      };
      this.common.ajax(url, params, callback);
      // 打开窗体
      this.createDistConfig.isShowDialog = true;
    },
    // 生成配送单
    generatebill(formData) {
      this.$confirm("生成配送单, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // formData 获取当前输入的派车单信息
          const ids = this.dataList.dataListSelections.map(item => item.wayBill_Id);
          const url = "/api/tms/wayBillDistribution/generateBill"; // 服务地址
          const params = {
            wayBill_Ids: ids,
            formData: formData
          };
          const callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              this.createDistConfig.isShowDialog = false;
              // 触发子组件事件清空表单
              this.$refs.childData.clear();
              this.dataList.reload();
            }
          };
          this.common.ajax(url, params, callback);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    editButtonClick(authNode) {},
    beforeClose() {
      this.editorOptions.config.visible = false;
    },
    onEditLoadAfter(formData) {
      this.editorOptions.config.disabled = true; // 整个对话框不可编辑
    }
  }
};
</script>