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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<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" :action-field="actionField" @on-delete-after="onDeleteAfter">
      <template slot="action-column-slot" slot-scope="{row, col}">
        <template>
          <el-button type="text" size="mini" @click="actualTakeOffTime(row.voyageCode)">实飞ATD</el-button>
          <el-button type="text" size="mini" @click="actualLandingTime(row.voyageCode)">实落ATA</el-button>
        </template>
      </template>
      <!-- 字段插槽 -->
      <template slot="common-column-slot" slot-scope="{ row, col }">
        <template v-if="col.prop == 'voyageStatus'">
          <el-tag :color="setStatusBgColor(row[col.prop])" :style="setStatusColor(row[col.prop])">
            {{ row[col.prop] }}
          </el-tag>
        </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" :data-options="dataOptions" :action.sync="editorOptions.action" :visible.sync="editorOptions.config.visible" :on-save-before="onSaveBefore" :auth-nodes="authNodes" @on-add-load-after="onEditLoadAfter" @on-edit-load-after="onEditLoadAfter">
      <div slot="blank-plateCodes" class="tag-container">
        <el-tag v-for="(plateCode, index) in plateCodes" :key="index" :disable-transitions="false" closable @close="handleClose()">
          {{ plateCode }}
        </el-tag>
        <el-input v-if="inputVisible" ref="saveTagInput" v-model="inputValue" class="input-new-tag" size="small" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
        </el-input>
        <el-button v-else class="button-new-tag" size="small" @click="showInput">+ 添加托盘号</el-button>
      </div>
    </yrt-editor>
 
    <el-dialog :visible.sync="dialogFormVisible" title="" width="500px">
      <el-form :model="form" label-width="160px">
        <el-form-item label="主单号:">
          <el-input v-model="form.voyageCode" autocomplete="off" class="w-200"></el-input>
        </el-form-item>
        <el-form-item label="实际起飞时间(ATD):">
          <el-date-picker v-model="value1" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" class="w-200">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="editSave">确 定</el-button>
      </div>
    </el-dialog>
 
    <el-dialog :visible.sync="dialogLandingTime" width="500px">
      <el-form :model="form" label-width="160px">
        <el-form-item label="主单号:">
          <el-input v-model="form.voyageCode" autocomplete="off" class="w-200"></el-input>
        </el-form-item>
        <el-form-item label="实际落地时间(ATA):">
          <el-date-picker v-model="landingTime" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" class="w-200">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogLandingTime = false">取 消</el-button>
        <el-button type="primary" @click="EditlogLandingTimesave">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import baseLayout from "@/components/common/base-layout.vue";
 
export default {
  name: "tms-way-voyage",
  components: {},
  mixins: [baseLayout],
  data() {
    return {
      plateCodes: [],
      inputVisible: false,
      inputValue: "",
      dialogFormVisible: false,
      dialogLandingTime: false,
      value1: "",
      landingTime: "",
      form: {
        voyageCode: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: ""
      },
      // 状态值
      statusValueList: [
        {
          status: "已发运",
          bgColor: "#0099cc",
          color: "#fff"
        },
        {
          status: "清关中",
          bgColor: "#cc99ff",
          color: "#fff"
        },
        {
          status: "新建",
          bgColor: "#ffcc66",
          color: "#fff"
        }
      ],
      actionField: {
        prop: "_action",
        label: "操作",
        width: 130,
        headerAlign: "center",
        align: "center",
        hidden: false
      }
    };
  },
  methods: {
    // 状态背景颜色
    setStatusBgColor(status) {
      var colorItem = this.statusValueList.find(item => {
        return item.status === status;
      });
      var bgColor = "#ffffff";
      if (colorItem) bgColor = colorItem.bgColor;
 
      return bgColor;
    },
    // 状态字体颜色
    setStatusColor(status) {
      var colorItem = this.statusValueList.find(item => {
        return item.status === status;
      });
      var color = "#888";
      if (colorItem) color = colorItem.color;
 
      return {
        border: 0,
        color: color
      };
    },
    // 列表页面按钮点击事件
    buttonClick(authNode) {
      switch (authNode) {
        case "send":
          // 航班发运
          this.send();
          return false;
        case "clearance":
          // 清关
          this.clearance();
          return false;
      }
    },
    // 保存前事件
    onSaveBefore(formData) {
      var editorRef = this.editor;
      editorRef.changeValue("plateCodes", this.plateCodes.join(","));
      if (formData.voyageCode) {
        if (formData.voyageCode.length !== 12) {
          this.$message.error("主单号格式不正确");
          return false;
        }
        // 前7位减第8位后除7余数为0就是正确的主单号
        var voyayestr = formData.voyageCode.split("-")[1];
        var voyage = parseInt(voyayestr.substr(0, 7)); // 截取从第0个开始往后数7位之间的字符
        var last = parseInt(voyayestr.substr(7, 1));
        if ((voyage - last) % 7) {
          this.$message.error("主单号不正确");
          return false;
        }
      }
    },
    // 编辑加载数据后事件
    onEditLoadAfter(formData) {
      if (formData.plateCodes) {
        this.plateCodes = formData.plateCodes.split(",");
      } else {
        this.plateCodes = [];
      }
    },
    handleClose(tag) {
      this.plateCodes.splice(this.plateCodes.indexOf(tag), 1);
    },
 
    showInput() {
      this.inputVisible = true;
      this.$nextTick(_ => {
        this.$refs.saveTagInput.$refs.input.focus();
      });
    },
 
    handleInputConfirm() {
      const inputValue = this.inputValue;
      var url = "/api/tms/voyage/checkPlateCode";
      var params = {
        voyageCode: inputValue
      };
      this.common.ajax(url, params, res => {
        if (res.result) {
          if (inputValue) {
            this.plateCodes.push(inputValue);
          }
        } else {
          this.$message.error(res.msg);
        }
        this.inputVisible = false;
        this.inputValue = "";
        var editorRef = this.editor;
        editorRef.changeValue("plateCodes", this.plateCodes.join(","));
      });
    },
    // 实际起飞
    actualTakeOffTime(voyageCode) {
      this.$set(this.form, "voyageCode", voyageCode);
      this.dialogFormVisible = true;
    },
    editSave() {
      var voyageCode = this.form.voyageCode;
      const actualTakeOffTime = this.value1;
      const params = {
        voyageCode: voyageCode,
        actualTakeOffTime: actualTakeOffTime
      };
      const url = "/api/tms/voyage/upActualTakeOffTime";
      const ref = this.dataList;
      var callback = res => {
        this.common.showMsg(res);
        if (!res.result) {
          this.$message.success(res.msg);
        }
      };
      this.common.ajax(url, params, callback, ref);
      this.dialogFormVisible = false;
      ref.loadData();
    },
    // 实际落地
    actualLandingTime(voyageCode) {
      this.$set(this.form, "voyageCode", voyageCode);
      this.dialogLandingTime = true;
    },
    // 实际落地保存
    EditlogLandingTimesave() {
      var voyageCode = this.form.voyageCode;
      const actualLandingTime = this.landingTime;
      const params = {
        voyageCode: voyageCode,
        actualLandingTime: actualLandingTime
      };
      const url = "/api/tms/voyage/upActualLandingTime";
      const ref = this.dataList;
      var callback = res => {
        this.common.showMsg(res);
        if (!res.result) {
          this.$message.success(res.msg);
        }
      };
      this.common.ajax(url, params, callback, ref);
      this.dialogLandingTime = false;
      ref.loadData();
    },
    // 航班发运
    send() {
      const selectIDs = this.dataListSelections.map((item, index, Array) => {
        return item.voyage_Id;
      });
      if (!selectIDs.length) {
        this.$message.error("至少选择一项");
        return;
      }
 
      this.$confirm("此操作将确认为航班已发运, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const url = "/api/tms/voyage/send";
          const params = {
            ids: selectIDs
          };
          this.common.ajax(
            url,
            params,
            res => {
              this.common.showMsg(res);
              if (res.result) {
                this.dataList.reload();
              }
            },
            true
          );
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 清关中
    clearance() {
      const selectIDs = this.dataListSelections.map((item, index, Array) => {
        return item.voyage_Id;
      });
      if (!selectIDs.length) {
        this.$message.error("至少选择一项");
        return;
      }
 
      this.$confirm("此操作将确认为清关中, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const url = "/api/tms/voyage/Clearance";
          const params = {
            ids: selectIDs
          };
          this.common.ajax(
            url,
            params,
            res => {
              this.common.showMsg(res);
              if (res.result) {
                this.dataList.reload();
              }
            },
            true
          );
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 删除数据后将运单中的航空主单号清空
    onDeleteAfter(rows) {
      const voyageCodes = [];
      if (rows) {
        rows.map(item => {
          voyageCodes.push(item.voyageCode);
        });
      }
      alert(voyageCodes);
      const url = "/api/tms/voyage/deleteVoyageCode";
      const ref = this.dataList;
      const params = {
        voyageCode: voyageCodes
      };
      var callback = res => {
        this.common.showMsg(res);
        if (!res.result) {
          this.$message.success(res.msg);
        }
      };
      this.common.ajax(url, params, callback, ref);
    }
  }
};
</script>
 
<style lang="scss" scoped>
.page-list-container {
  min-height: calc(100vh - 110px);
  overflow: hidden;
  position: relative;
}
 
.tag-container {
  .el-tag + .el-tag {
    margin-left: 10px;
  }
  .button-new-tag {
    margin-left: 10px;
    width: 130px;
    height: 32px;
    line-height: 30px;
    padding-top: 0;
    padding-bottom: 0;
  }
  .input-new-tag {
    width: 130px;
    margin-left: 10px;
    vertical-align: bottom;
  }
}
 
@media screen and (max-height: 900px) {
  .page-list-container {
    min-height: 600px;
  }
}
</style>