indexFutureBox.vue 17.7 KB
Newer Older
TIAN.DESHENG's avatar
TIAN.DESHENG committed
1 2 3 4 5
<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6 7
      <el-form-item :label="$t('运输方式')" prop="transportType">
        <!-- <el-select v-model="queryParams.transportType" :placeholder="$t('请选择运输方式')" clearable size="small">
TIAN.DESHENG's avatar
TIAN.DESHENG committed
8
          <el-option v-for="dict in transportTypes" :key="dict.value" :label="dict.label" :value="dict.value" />
9
        </el-select> -->
dragondean@qq.com's avatar
dragondean@qq.com committed
10
        <dict-selector :type="DICT_TYPE.TRANSPORT_TYPE" v-model="queryParams.transportType" clearable/>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
11
      </el-form-item>
12 13 14
      <el-form-item :label="$t('始发仓')" prop="startWarehouseId">
        <el-select v-model="queryParams.startWarehouseId" :placeholder="$t('请选择始发地')" clearable>
          <el-option v-for="item in exportWarehouseList" :label="$l(item, 'title')" :value="item.id" :key="item.id"></el-option>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
15 16 17
        </el-select>
      </el-form-item>

18 19 20
      <el-form-item :label="$t('目的仓')" prop="destWarehouseId">
        <el-select v-model="queryParams.destWarehouseId" :placeholder="$t('请选择目的地')" clearable>
          <el-option v-for="item in importWarehouseList" :label="$l(item, 'title')" :value="item.id" :key="item.id"></el-option>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
21 22
        </el-select>
      </el-form-item>
huhaiqing's avatar
huhaiqing committed
23

TIAN.DESHENG's avatar
TIAN.DESHENG committed
24
      <el-form-item>
25 26
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{$t('搜索')}}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{$t('重置')}}</el-button>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
27 28 29 30 31 32 33
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
34
                   v-hasPermi="['ecw:future-box:create']">{{$t('新建计划')}}</el-button>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
35
      </el-col>
dragondean@qq.com's avatar
dragondean@qq.com committed
36
      <!-- <el-col :span="1.5">
TIAN.DESHENG's avatar
TIAN.DESHENG committed
37
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
38
                   v-hasPermi="['ecw:future-box:export']">{{$t('导出')}}</el-button>
dragondean@qq.com's avatar
dragondean@qq.com committed
39
      </el-col> -->
TIAN.DESHENG's avatar
TIAN.DESHENG committed
40 41 42 43 44
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
45 46 47 48 49 50 51 52 53 54 55 56
      <el-table-column :label="$t('序号')" align="center" prop="id" />
      <el-table-column :label="$t('始发地')" align="center" prop="startWarehouse">
        <template slot-scope="{row}">
          {{getExportWarehouseName(row.startWarehouseId)}}
        </template>
      </el-table-column>
      <el-table-column :label="$t('目的地')" align="center" prop="destWarehouse" >
        <template slot-scope="{row}">
          {{getImportWarehouseName(row.destWarehouseId)}}
        </template>
      </el-table-column>
      <el-table-column :label="$t('运输方式')" align="center" prop="transportType">
TIAN.DESHENG's avatar
TIAN.DESHENG committed
57 58 59 60
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="scope.row.transportType" />
        </template>
      </el-table-column>
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
      <el-table-column :label="$t('出货渠道')" align="center" prop="shippingChannelId">
        <template slot-scope="{row}">
          {{getShipChannelName(row.shippingChannelId)}}
        </template>
      </el-table-column>
      <el-table-column :label="$t('待入仓方数')" align="center" prop="readyWarehousingNumber">
        <template slot-scope="{row}">
          {{row.readyWarehousingNumber  || 0}}
        </template>
      </el-table-column>
      <el-table-column :label="$t('已入仓方数')" align="center" prop="warehousedNumber">
        <template slot-scope="{row}">
          {{row.warehousedNumber  || 0}}
        </template>
      </el-table-column>
      <el-table-column :label="$t('在仓方数')" align="center" prop="warehousingNumber" >
        <template slot-scope="{row}">
          {{row.warehousingNumber  || 0}}
        </template>
      </el-table-column>
      <el-table-column :label="$t('已装柜方数')" align="center" prop="loadingNumber" >
        <template slot-scope="{row}">
          {{row.loadingNumber  || 0}}
        </template>
      </el-table-column>
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="180">
TIAN.DESHENG's avatar
TIAN.DESHENG committed
87 88 89 90
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
91 92
      <el-table-column :label="$t('未来天数')" align="center" prop="futureNumber" />
      <el-table-column :label="$t('计划货柜')" align="center" prop="gpNumber">
TIAN.DESHENG's avatar
TIAN.DESHENG committed
93
        <template slot-scope="{row}">
94 95
          <div>{{row.gpNumber}}个40GP</div>
          <div>{{row.hqNumber}}个40HQ</div>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
96 97
        </template>
      </el-table-column>
98 99 100 101
      <el-table-column :label="$t('未来计划方数')" align="center" prop="futurePlanNumber" />
      <el-table-column :label="$t('未来实际方数')" align="center" prop="actualNumber" />
      <el-table-column :label="$t('创建人')" align="center" prop="createName" />
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
TIAN.DESHENG's avatar
TIAN.DESHENG committed
102 103
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
104
                     v-hasPermi="['ecw:future-box:update']">{{$t('编辑')}}</el-button>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
105
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
106
                     v-hasPermi="['ecw:future-box:delete']">{{$t('删除')}}</el-button>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
107 108 109 110 111 112 113 114 115
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
huhaiqing's avatar
huhaiqing committed
116
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
117 118 119
         <el-form-item :label="$t('始发地')" prop="startWarehouseId">
          <el-select v-model="form.startWarehouseId" :placeholder="$t('请选择始发地')">
            <el-option v-for="item in exportWarehouseList" :label="$l(item, 'title')" :value="item.id" :key="item.id"></el-option>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
120 121 122
          </el-select>
        </el-form-item>

123 124 125
        <el-form-item :label="$t('目的地')" prop="destWarehouseId">
          <el-select v-model="form.destWarehouseId" :placeholder="$t('请选择目的地')">
            <el-option v-for="item in importWarehouseList" :label="$l(item, 'title')" :value="item.id" :key="item.id"></el-option>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
126 127
          </el-select>
        </el-form-item>
128
        <el-form-item :label="$t('运输方式')" prop="transportType">
129
          <dict-selector :type="DICT_TYPE.TRANSPORT_TYPE" v-model="form.transportType" form-type="radio" />
TIAN.DESHENG's avatar
TIAN.DESHENG committed
130
        </el-form-item>
131 132
        <el-form-item :label="$t('出货渠道')" prop="shippingChannelId" v-if="form.transportType == 3 || form.transportType == 4">
          <el-select v-model="form.shippingChannelId" :placeholder="$t('请选择出货渠道')">
133
            <el-option v-for="item in channelList" :label="$l(item, 'name')" :value="item.channelId" :key="item.channelId"></el-option>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
134 135
          </el-select>
        </el-form-item>
136
        <el-form-item :label="$t('待入仓方数')">
137
          {{form.readyWarehousingNumber}} m³
TIAN.DESHENG's avatar
TIAN.DESHENG committed
138
        </el-form-item>
139
        <el-form-item :label="$t('已入仓方数')">
140
          {{form.warehousedNumber}} m³
TIAN.DESHENG's avatar
TIAN.DESHENG committed
141
        </el-form-item>
142
        <el-form-item :label="$t('在仓方数')">
143
          {{form.warehousingNumber}} m³
TIAN.DESHENG's avatar
TIAN.DESHENG committed
144
        </el-form-item>
145
        <el-form-item :label="$t('已装柜仓数')">
146
          {{form.loadingNumber}} m³
TIAN.DESHENG's avatar
TIAN.DESHENG committed
147
        </el-form-item>
148 149 150
        
        <el-form-item label="">
          <div>
151
            {{$t('未来')}} <el-input v-model="form.futureNumber" class="w-100"></el-input> {{$t('天货柜数')}}
152 153 154 155 156 157
          </div>
          <div class="mt-10">
            <el-input v-model="form.gpNumber" class="w-100" /> &times; 40GP
            <el-input v-model="form.hqNumber" class="w-100 ml-10" /> &times; 40HQ
          </div>
          <div class="mt-10">
158 159 160

            {{$t('未来{futureNumber}天计划方数',{futureNumber: form.futureNumber})}}:
            <el-input v-model="form.futurePlanNumber" class="w-100"></el-input>
161 162
          </div>
          <div class="mt-10">
163 164
            {{$t('未来{futureNumber}天实际方数',{futureNumber: form.futureNumber})}}:
            <el-input v-model="form.actualNumber" class="w-100"></el-input>
165
          </div>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
166 167 168
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
169 170
        <el-button type="primary" @click="submitForm">{{$t('确定')}}</el-button>
        <el-button @click="cancel">{{$t('取消')}}</el-button>
TIAN.DESHENG's avatar
TIAN.DESHENG committed
171 172 173 174 175 176
      </div>
    </el-dialog>
  </div>
</template>

<script>
177
import { createFutureBox, updateFutureBox, deleteFutureBox, getFutureBox, getFutureBoxPage, exportFutureBoxExcel, getBoxedVolume, getToBeWareHousedVolume,getWareHousedVolume } from "@/api/ecw/futureBox";
TIAN.DESHENG's avatar
TIAN.DESHENG committed
178 179 180
import {getCabinetPage} from "@/api/ecw/cabinet";
import { getChannelList } from '@/api/ecw/channel';
import { getWarehouseList } from "@/api/ecw/warehouse"
181
import {getTradeCityList} from '@/api/ecw/region'
dragondean@qq.com's avatar
dragondean@qq.com committed
182
import Decimal from 'decimal.js'
TIAN.DESHENG's avatar
TIAN.DESHENG committed
183
export default {
huhaiqing's avatar
huhaiqing committed
184
  name: "indexFutureBox",
TIAN.DESHENG's avatar
TIAN.DESHENG committed
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
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 预定舱计划列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        startWarehouseId: null,
        destWarehouseId: null,
        transportType: null,
        readyWarehousingNumber: null,
        warehousedNumber: null,
        warehousingNumber: null,
        loadingNumber: null,
        futureNumber: null,
        gpNumber: null,
        hqNumber: null,
        futurePlanNumber: null,
        actualNumber: null,
        shippingChannelId: null,
        status: null,
      },
      // 表单参数
224 225 226
      form: {
        
      },
TIAN.DESHENG's avatar
TIAN.DESHENG committed
227 228
      // 表单校验
      rules: {
229
      },
huhaiqing's avatar
huhaiqing committed
230 231
      warehouseList: [],
      channelList: [],
232
      /* tradeCityList: [] */
TIAN.DESHENG's avatar
TIAN.DESHENG committed
233 234 235
    };
  },
  computed: {
236 237 238
    channels(){
      return this.$store.getters.channels
    },
TIAN.DESHENG's avatar
TIAN.DESHENG committed
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
    exportWarehouseList() {
      return this.warehouseList.filter(
        (item) => item.tradeType == "2" || item.type == "3"
      );
    },
    importWarehouseList() {
      return this.warehouseList.filter(
        (item) => item.tradeType == "1" || item.type == "3"
      );
    },
    getCabinetName() {
      return (cabinetId) => {
        for (let index in this.cabinetList) {
          let cabinetItem = this.cabinetList[index];
          if (cabinetItem.id == cabinetId) {
            return cabinetItem.name;
          }
        }
      };
    },
    getShipChannelName() {
        return shippingChannelId => {
          for (let index in this.channelList) {
            let channelItem = this.channelList[index];
            if (channelItem.channelId == shippingChannelId) {
264
              return this.$l(channelItem, 'name');
TIAN.DESHENG's avatar
TIAN.DESHENG committed
265 266 267 268
            }
          }
          return '/'
        }
269 270 271 272 273 274 275 276 277 278 279 280
    },
    getExportWarehouseName(){
      return id => {
        let warehouse = this.exportWarehouseList.find(item => item.id == id)
        return this.$l(warehouse, 'title')
      }
    },
    getImportWarehouseName(){
      return id => {
        let warehouse = this.importWarehouseList.find(item => item.id == id)
        return this.$l(warehouse, 'title')
      } 
TIAN.DESHENG's avatar
TIAN.DESHENG committed
281
    }
282 283 284 285 286 287
    /* importCityList(){
      return this.tradeCityList.filter(item => item.type == 1 || item.tye == 3)
    },
    exportCityList(){
      return this.tradeCityList.filter(item => item.type == 2 || item.type == 3)
    } */
TIAN.DESHENG's avatar
TIAN.DESHENG committed
288 289
  },
  created() {
290 291 292 293
    /* getTradeCityList().then(res => {
      this.tradeCityList = res.data
    }) */

huhaiqing's avatar
huhaiqing committed
294 295
    // 查询渠道
    getChannelList().then((res) => (this.channelList = res.data));
296
    /* this.transportTypes = this.getDictDatas(
TIAN.DESHENG's avatar
TIAN.DESHENG committed
297
      this.DICT_TYPE.ECW_TRANSPORT_TYPE
298 299
    ).filter((item) => item.value == "1" || item.value == "2"); */

TIAN.DESHENG's avatar
TIAN.DESHENG committed
300 301 302 303 304 305
    getWarehouseList().then((res) => (this.warehouseList = res.data));
    getCabinetPage(null).then((response) => {
      this.cabinetList = response.data.list;
    });
    this.getList();
  },
306
  watch:{
dragondean@qq.com's avatar
dragondean@qq.com committed
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
    'form.transportType'(){
      this.getVolume()
    },
    'form.startWarehouseId'(){
      this.getVolume()
    },
    'form.destWarehouseId'(){
      this.getVolume()
    },
    'form.shippingChannelId'(){
      console.log('123shippingChannelId')
      this.getVolume()
    },
    'form.warehousedNumber'(){
      //在仓 = 已入仓-已封柜
      this.$set(this.form, 'warehousingNumber', Decimal(this.form.warehousedNumber).minus(this.form.loadingNumber))
    },
    'form.loadingNumber'(){
      //在仓 = 已入仓-已封柜
      this.$set(this.form, 'warehousingNumber',  Decimal(this.form.warehousedNumber).minus(this.form.loadingNumber))
    }
  },
  methods: {
    getVolume(){
      if(!this.form.transportType || !this.form.startWarehouseId || !this.form.destWarehouseId){
        return this.setDefaultVolume()
      }
      // 空运需要选择渠道
      if((this.form.transportType == 3 || this.form.transportType == 4) && !this.form.shippingChannelId){
        return this.setDefaultVolume()
      }
      let data = {
        transportId: this.form.transportType,
        channelId: this.form.shippingChannelId,
        departureId: this.form.startWarehouseId,
        objectiveId: this.form.destWarehouseId
343 344
      }
      // 获得已封柜方数
dragondean@qq.com's avatar
dragondean@qq.com committed
345
      getBoxedVolume(data).then(res => {
346 347 348
        this.$set(this.form, 'loadingNumber', res.data || 0)
      })
      // 获得待入仓方数
dragondean@qq.com's avatar
dragondean@qq.com committed
349
      getToBeWareHousedVolume(data).then(res => {
350 351 352
        this.$set(this.form, 'readyWarehousingNumber', res.data || 0)
      })
      // 获得已入仓方数
dragondean@qq.com's avatar
dragondean@qq.com committed
353
      getWareHousedVolume(data).then(res => {
354 355 356
        this.$set(this.form, 'warehousedNumber', res.data || 0)
      })
    },
dragondean@qq.com's avatar
dragondean@qq.com committed
357 358 359 360 361
    setDefaultVolume(){
      this.$set(this.form, 'loadingNumber', 0)
      this.$set(this.form, 'readyWarehousingNumber', 0)
      this.$set(this.form, 'warehousedNumber', 0)
      this.$set(this.form, 'warehousingNumber', 0)
362
    },
TIAN.DESHENG's avatar
TIAN.DESHENG committed
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
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getFutureBoxPage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        startWarehouseId: undefined,
        destWarehouseId: undefined,
        transportType: undefined,
        readyWarehousingNumber: undefined,
        warehousedNumber: undefined,
        warehousingNumber: undefined,
        loadingNumber: undefined,
        futureNumber: undefined,
        gpNumber: undefined,
        hqNumber: undefined,
        futurePlanNumber: undefined,
        actualNumber: undefined,
        shippingChannelId: undefined,
        status: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
417
      this.title = this.$t("添加预定舱计划");
TIAN.DESHENG's avatar
TIAN.DESHENG committed
418 419 420 421 422 423 424 425
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id;
      getFutureBox(id).then(response => {
        this.form = response.data;
        this.open = true;
426
        this.title = this.$t("修改预定舱计划");
TIAN.DESHENG's avatar
TIAN.DESHENG committed
427 428 429 430 431 432 433 434 435 436 437
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }
        // 修改的提交
        if (this.form.id != null) {
          updateFutureBox(this.form).then(response => {
438
            this.$modal.msgSuccess(this.$t("修改成功"));
TIAN.DESHENG's avatar
TIAN.DESHENG committed
439 440 441 442 443 444 445
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createFutureBox(this.form).then(response => {
446
          this.$modal.msgSuccess(this.$t("新增成功"));
TIAN.DESHENG's avatar
TIAN.DESHENG committed
447 448 449 450 451 452 453 454
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
455
      this.$modal.confirm(this.$t('是否确认删除预定舱计划编号为{id}的数据项?', {id})).then(function() {
TIAN.DESHENG's avatar
TIAN.DESHENG committed
456 457 458
          return deleteFutureBox(id);
        }).then(() => {
          this.getList();
459
          this.$modal.msgSuccess(this.$t("删除成功"));
TIAN.DESHENG's avatar
TIAN.DESHENG committed
460 461 462 463 464 465 466 467 468 469
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行导出
470
      this.$modal.confirm(this.$t('是否确认导出所有预定舱计划数据项?')).then(() => {
TIAN.DESHENG's avatar
TIAN.DESHENG committed
471 472 473 474 475 476 477 478 479 480
          this.exportLoading = true;
          return exportFutureBoxExcel(params);
        }).then(response => {
          this.$download.excel(response, '${table.classComment}.xls');
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>