preinstall.vue 32.4 KB
Newer Older
huhaiiqng's avatar
huhaiiqng committed
1
<template>
huhaiqing's avatar
huhaiqing committed
2
  <div class="preinstall">
huhaiiqng's avatar
huhaiiqng committed
3
    <!-- 搜索工作栏 -->
4
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
5 6
      <el-form-item :label="$t('入仓时间')" prop="rucangtime">
        <el-date-picker v-model="queryParams.rucangtime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" start-:placeholder="$t('开始日期')" end-:placeholder="$t('结束日期')" />
huhaiiqng's avatar
huhaiiqng committed
7
      </el-form-item>
8 9 10
      <el-form-item :label="$t('始发地')" prop="startWarehouseId">
        <el-select v-model="queryParams.startWarehouseId" :placeholder="$t('请选择始发地')" clearable size="small">
          <el-option v-for="item in exportWarehouseList" :label="$l(item, 'title')" :value="item.id" :key="item.id"></el-option>
huhaiiqng's avatar
huhaiiqng committed
11 12
        </el-select>
      </el-form-item>
13 14 15
      <el-form-item :label="$t('目的地')" prop="destWarehouseIdList">
        <el-select v-model="queryParams.destWarehouseIdList" :placeholder="$t('请选择目的地')" multiple clearable>
          <el-option v-for="item in importWarehouseList" :label="$l(item, 'title')" :value="item.id" :key="item.id"></el-option>
huhaiiqng's avatar
huhaiiqng committed
16 17
        </el-select>
      </el-form-item>
18 19
      <el-form-item :label="$t('状态')" prop="orderStatus">
        <el-select v-model="queryParams.orderStatus" :placeholder="$t('请选择状态')" clearable size="small">
huhaiqing's avatar
huhaiqing committed
20
          <el-option v-for="item in stateOps" :label="$l(item, 'label')" :value="item.value" :key="item.value"></el-option>
huhaiiqng's avatar
huhaiiqng committed
21 22
        </el-select>
      </el-form-item>
23 24
      <el-form-item :label="$t('备案')" prop="productRecord">
        <el-select v-model="queryParams.productRecord" :placeholder="$t('请选择备案')" clearable size="small">
huhaiqing's avatar
huhaiqing committed
25
          <el-option v-for="item in filingOps" :label="$l(item, 'label')" :value="item.value" :key="item.value"></el-option>
huhaiiqng's avatar
huhaiiqng committed
26 27
        </el-select>
      </el-form-item>
28 29
      <el-form-item :label="$t('报关方式')" prop="customsType">
        <el-select v-model="queryParams.customsType" :placeholder="$t('请选择报关方式')" clearable size="small">
huhaiqing's avatar
huhaiqing committed
30
          <el-option v-for="item in declarationMethodOps" :label="$l(item, 'label')" :value="item.value" :key="item.value"></el-option>
huhaiiqng's avatar
huhaiiqng committed
31 32
        </el-select>
      </el-form-item>
huhaiqing's avatar
huhaiqing committed
33 34
      <el-form-item :label="$t('待预装订单')" prop="toBePreOrderNo">
        <el-input v-model="queryParams.toBePreOrderNo" :placeholder="$t('请输入待预装订单')" clearable />
huhaiiqng's avatar
huhaiiqng committed
35
      </el-form-item>
36 37
      <el-form-item :label="$t('已预装单号')" prop="preOrderNo">
        <el-input v-model="queryParams.preOrderNo" :placeholder="$t('请输入已预装单号')" clearable />
huhaiiqng's avatar
huhaiiqng committed
38
      </el-form-item>
39 40
      <el-form-item :label="$t('品名')" prop="itemName">
        <el-input v-model="queryParams.itemName" :placeholder="$t('请输入品名')" clearable />
huhaiiqng's avatar
huhaiiqng committed
41
      </el-form-item>
42
      <el-form-item :label="$t('重货比')" prop="weightRatioMax">
huhaiqing's avatar
huhaiqing committed
43
        <el-input v-model="queryParams.weightRatioMax" :placeholder="$t('请输入 大')" clearable />
huhaiiqng's avatar
huhaiiqng committed
44
      </el-form-item>
45
      <el-form-item label="" prop="weightRatioMin">
huhaiqing's avatar
huhaiqing committed
46
        <el-input v-model="queryParams.weightRatioMin" :placeholder="$t('请输入 小')" clearable />
huhaiiqng's avatar
huhaiiqng committed
47 48 49
      </el-form-item>

      <el-form-item>
50 51 52
        <el-button type="primary" icon="el-icon-search" @click="handleQuery('pre')">{{$t('搜索已预装订单')}}</el-button>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery('toBePre')">{{$t('搜索待预装订单')}}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{$t('重置')}}</el-button>
huhaiiqng's avatar
huhaiiqng committed
53 54 55 56 57
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10">
58
      <right-toolbar :showSearch.sync="showSearch" @queryTable="handleQuery('toBePre')"></right-toolbar>
huhaiiqng's avatar
huhaiiqng committed
59 60 61
    </el-row>

    <!-- 表格 -->
62
    <el-card style="margin-top: 15px" class="preinstall-card">
huhaiiqng's avatar
huhaiiqng committed
63 64
      <el-row class="preinstall-title">
        <div>
65
          <p>{{$t('自编号')}}</p>
huhaiqing's avatar
huhaiqing committed
66
          <p>{{shipmentObj.selfNo}}</p>
huhaiiqng's avatar
huhaiiqng committed
67 68
        </div>
        <div>
69
          <p>{{$t('柜号')}}</p>
huhaiqing's avatar
huhaiqing committed
70
          <p>{{shipmentObj.cubNo}}</p>
huhaiiqng's avatar
huhaiiqng committed
71 72
        </div>
        <div>
73
          <p>{{$t('容量')}}</p>
74
          <p>{{calcCapacity}}</p>
huhaiiqng's avatar
huhaiiqng committed
75 76
        </div>
        <div>
77
          <p>{{$t('始发地')}}</p>
huhaiqing's avatar
huhaiqing committed
78
          <p>{{importCityName(shipmentObj.startWarehouseId)}}</p>
huhaiiqng's avatar
huhaiiqng committed
79 80
        </div>
        <div>
81
          <p>{{$t('目的地')}}</p>
huhaiqing's avatar
huhaiqing committed
82
          <p>{{importCityName(shipmentObj.destWarehouseId)}}</p>
huhaiiqng's avatar
huhaiiqng committed
83 84 85 86 87 88
        </div>
      </el-row>
      <el-row class="preinstall-table">
        <!-- 已预装订单 -->
        <el-col :span="12">
          <el-row class="preinstall-title">
89
            <div class="table-label">{{$t('已预装订单')}}</div>
huhaiiqng's avatar
huhaiiqng committed
90
            <div>
91
              <p>{{$t('总计')}}</p>
92
              <p>{{getTotlContent(preList.loadStatistics)}}</p>
huhaiiqng's avatar
huhaiiqng committed
93 94
            </div>
            <div class="red-label">
95
              <p>{{$t('可预装方数')}}</p>
96
              <p>{{preList.remainVolume}}</p>
huhaiiqng's avatar
huhaiiqng committed
97 98
            </div>
            <div class="red-label">
99
              <p>{{$t('重量')}}</p>
100
              <p>{{preList.remainWeight}}kg</p>
huhaiiqng's avatar
huhaiiqng committed
101 102
            </div>
            <div class="table-button">
103
              <el-button type="success" size="small" @click="addPart" :disabled="isAudit">{{$t('增加')}}</el-button>
huhaiiqng's avatar
huhaiiqng committed
104 105
            </div>
          </el-row>
huhaiqing's avatar
huhaiqing committed
106
          <el-scrollbar style="height:calc(100% - 43px)">
107
            <el-row v-for="(part, index) in preList.sectionGoodList" :key="index" class="pre-part">
huhaiqing's avatar
huhaiqing committed
108 109
              <el-row class="preinstall-title">
                <div class="pre-part-info">
110
                  <p>{{$t('第{index}部分', {index: index+1})}}</p>
huhaiqing's avatar
huhaiqing committed
111
                  <p>{{getTotlContent(part.secStatistics)}}</p>
huhaiqing's avatar
huhaiqing committed
112 113
                </div>
                <div class="table-button">
114 115 116
                  <el-button type="danger" size="small" @click="deletePart(part)" :disabled="isAudit">{{$t('删除部分')}}</el-button>
                  <el-button type="danger" size="small" @click="deleteOrder('selected', part)" :disabled="isAudit">{{$t('删除订单')}}</el-button>
                  <el-button type="primary" size="small" @click="foldTable(index, part)">{{part.fold ? $t('展开') : $t('收起')}}</el-button>
huhaiqing's avatar
huhaiqing committed
117 118
                </div>
              </el-row>
huhaiqing's avatar
huhaiqing committed
119 120
              <el-collapse-transition>
                <div v-show="!part.fold">
121 122
                  <el-table v-loading="preLoading" border :data="part.sectionGoodsList" @select="(selection)=>checkboxSelect(selection, part)" @select-all="(selection)=>checkboxSelect(selection, part)">
                    <el-table-column type="selection" align="center" width="55" fixed="left" />
huhaiqing's avatar
huhaiqing committed
123
                    <el-table-column :label="$t('序号')" align="center" prop="tidanNum" width="50" />
124
                    <el-table-column :label="$t('订单号')" align="center" prop="orderNo" width="120">
huhaiqing's avatar
huhaiqing committed
125 126 127 128 129
                      <template slot-scope="scope">
                        <div>
                          {{scope.row.orderNo}}
                        </div>
                        <div style="color:blue;fontWeight:bold;">
130
                          {{ scope.row.isExternalWarehouse === 1 ? '(' +$t('外部仓')+')' : ''}}
huhaiqing's avatar
huhaiqing committed
131 132 133
                        </div>
                      </template>
                    </el-table-column>
134 135
                    <el-table-column :label="$t('目的地')" align="center" prop="destWarehouseName" width="120" />
                    <el-table-column :label="$t('入仓时间')" align="center" prop="rucangTime" width="120">
huhaiqing's avatar
huhaiqing committed
136 137 138 139
                      <template slot-scope="scope">
                        {{formatDate(scope.row.rucangTime)}}
                      </template>
                    </el-table-column>
huhaiqing's avatar
huhaiqing committed
140 141 142 143 144
                    <el-table-column :label="$t('品名')" align="center" prop="" width="120">
                      <template slot-scope="{row}">
                        {{$l(row,'prodTitle')}}
                      </template>
                    </el-table-column>
145
                    <el-table-column :label="$t('箱数')" align="center" prop="warehouseInInfoVO.cartonsNum" />
146
                    <el-table-column :label="$t('体积') + '/' + $t('重量') + '/' + $t('重货比')" align="center" width="140" prop="volumeWeight">
huhaiqing's avatar
huhaiqing committed
147
                      <template slot-scope="scope">
148 149 150
                        <p v-if="scope.row.warehouseInInfoVO.volume">{{getTotlContent(scope.row.warehouseInInfoVO,['volume'])}}</p>
                        <p v-if="scope.row.warehouseInInfoVO.weight">{{getTotlContent(scope.row.warehouseInInfoVO,['weight'])}}</p>
                        <p>{{getRatioMax(scope.row.warehouseInInfoVO)}}</p>
huhaiqing's avatar
huhaiqing committed
151 152
                      </template>
                    </el-table-column>
153
                    <el-table-column :label="$t('报关方式')" align="center" prop="customsType" width="120">
huhaiqing's avatar
huhaiqing committed
154
                      <template slot-scope="scope">
155 156 157
                        <div :class="scope.row.customsType !== 1 ? 'custom_type_red' : ''">
                          <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="scope.row.customsType" />
                        </div>
huhaiqing's avatar
huhaiqing committed
158 159
                      </template>
                    </el-table-column>
160
                    <el-table-column :label="$t('备案')" align="center" prop="productRecord" width="100">
huhaiqing's avatar
huhaiqing committed
161 162 163
                      <template slot-scope="{row}">
                        <template v-if="row.brandName">{{row.brandName}}</template>
                        <dict-tag v-else :type="DICT_TYPE.ECW_IS_BRAND" :value="row.feeType" />
huhaiqing's avatar
huhaiqing committed
164 165
                      </template>
                    </el-table-column>
166
                    <el-table-column :label="$t('操作')" align="center" width="160" class-name="small-padding fixed-width" fixed="right">
huhaiqing's avatar
huhaiqing committed
167
                      <template slot-scope="scope">
168 169
                        <el-dropdown trigger="click" @command="(command)=>handleGoods('single',scope.row,command)" :disabled="isAudit">
                          <el-button type="primary" size="small" icon="el-icon-edit-outline" circle :disabled="isAudit"></el-button>
huhaiqing's avatar
huhaiqing committed
170
                          <el-dropdown-menu slot="dropdown">
171 172 173
                            <el-dropdown-item :command="bPart" v-for="(bPart, index) in preList.sectionGoodList" :key="bPart.id" v-show="bPart.id !== part.id">
                              {{$t('第{index}部分', {index: index+1})}}
                            </el-dropdown-item>
huhaiqing's avatar
huhaiqing committed
174 175
                          </el-dropdown-menu>
                        </el-dropdown>
176
                        <el-button type="danger" size="small" icon="el-icon-minus" circle style="margin-left:10px;" @click="deleteOrder('row',scope.row)" :disabled="isAudit"></el-button>
huhaiqing's avatar
huhaiqing committed
177 178 179 180 181
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </el-collapse-transition>
huhaiqing's avatar
huhaiqing committed
182 183
            </el-row>
          </el-scrollbar>
huhaiiqng's avatar
huhaiiqng committed
184 185 186 187
        </el-col>
        <!-- 待预装订单 -->
        <el-col :span="12">
          <el-row class="preinstall-title">
188
            <div class="table-label red-label">{{$t('待预装订单')}}</div>
huhaiiqng's avatar
huhaiiqng committed
189 190
            <div class="preinstall-title preinstalled">
              <div class="red-label">
191
                <p>{{$t('筛选后待预装数量')}}</p>
huhaiqing's avatar
huhaiqing committed
192
                <p>{{getTotlContent(unloadStatistics,['num'])}}</p>
huhaiiqng's avatar
huhaiiqng committed
193 194
              </div>
              <div class="red-label">
195
                <p>{{$t('方数')}}</p>
huhaiqing's avatar
huhaiqing committed
196
                <p>{{getTotlContent(unloadStatistics,['volume'])}}</p>
huhaiiqng's avatar
huhaiiqng committed
197 198
              </div>
              <div class="red-label">
199
                <p>{{$t('重量')}}</p>
huhaiqing's avatar
huhaiqing committed
200
                <p>{{getTotlContent(unloadStatistics,['weight'])}}</p>
huhaiiqng's avatar
huhaiiqng committed
201 202 203
              </div>
            </div>
          </el-row>
huhaiqing's avatar
huhaiqing committed
204
          <el-pagination background layout="prev, pager, next" :current-page="pageParam.pageNo" :page-size="pageParam.pageSize" :total="total" @current-change="pageChange" v-show="total > 0"></el-pagination>
huhaiqing's avatar
huhaiqing committed
205
          <el-scrollbar style="height:calc(100% - 75px)">
206
            <el-row v-for="(item, index) in toBePreList" :key="index" class="tobePre-row">
huhaiqing's avatar
huhaiqing committed
207 208 209 210 211
              <el-row class="preinstall-title order-title">
                <div>
                  <p>{{item.orderNo}}</p>
                </div>
                <div>
212
                  <p>{{$t('发往')}}</p>
huhaiqing's avatar
huhaiqing committed
213 214 215
                  <p>{{item.destWarehouseName}}</p>
                </div>
                <div>
216
                  <p :class="item.customsType !== 1 ? 'custom_type_red' : ''">
217
                    <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="item.customsType" />
huhaiqing's avatar
huhaiqing committed
218
                  </p>
huhaiqing's avatar
huhaiqing committed
219 220
                </div>
                <div>
221
                  <p>{{$t('入仓时间')}}</p>
222
                  <p>{{formatDate(item.rucangTime)}}</p>
huhaiqing's avatar
huhaiqing committed
223 224
                </div>
                <div>
225
                  <p>{{$t('重货比')}}</p>
huhaiqing's avatar
huhaiqing committed
226 227
                  <p>{{item.weightRatio}}</p>
                </div>
228
                <div v-if="item.isExternalWarehouse === 1" style="color:blue;fontWeight:bold;">
229
                  <p>{{$t('外部仓')}}</p>
230
                </div>
huhaiqing's avatar
huhaiqing committed
231
                <div class="table-button">
232
                  <el-button v-if="item.relateOrderList" type="primary" size="small" style="margin-right: 20px;" @click="getRelationOrder(item)">{{$t('关联订单')}}</el-button>
233
                  <el-dropdown trigger="click" @command="(command)=>handleGoods('all',item,command)">
234
                    <el-button type="success" size="small" :disabled="isAudit">{{$t('预装全部')}}</el-button>
235
                    <el-dropdown-menu slot="dropdown" v-if="preList.sectionGoodList">
236 237 238
                      <el-dropdown-item :command="part" v-for="(part, index) in preList.sectionGoodList" :key="part.id">
                        {{$t('第{index}部分', {index: index+1})}}
                      </el-dropdown-item>
huhaiqing's avatar
huhaiqing committed
239 240 241 242
                    </el-dropdown-menu>
                  </el-dropdown>
                </div>
              </el-row>
243
              <el-table v-loading="toBePreLoading" :data="item.boxOrderItemList" border show-summary :summary-method="getSummaries">
huhaiqing's avatar
huhaiqing committed
244
                <el-table-column type="index" align="center" :label="$t('序号')" width="50" />
huhaiqing's avatar
huhaiqing committed
245 246 247 248 249
                <el-table-column :label="$t('品名')" align="center" prop="">
                  <template slot-scope="{row}">
                    {{$l(row,'prodTitle')}}
                  </template>
                </el-table-column>
huhaiqing's avatar
huhaiqing committed
250 251
                <el-table-column :label="$t('备案')" align="center" prop="feeType">
                  <template slot-scope="{row}">
252 253 254
                    <template>{{row.brandName}}</template>{{ $t('(') }}
                    <dict-tag :type="DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL" :value="row.feeType" />{{ $t('') }}
                  </template>
huhaiqing's avatar
huhaiqing committed
255
                </el-table-column>
256
                <el-table-column :label="$t('箱数')" align="center" prop="warehouseInInfoVO.cartonsNum" />
257
                <el-table-column :label="$t('体积') +'/' + $t('重量')" align="center" prop="volumeWeight">
huhaiqing's avatar
huhaiqing committed
258
                  <template slot-scope="scope">
259 260
                    <p v-if="scope.row.warehouseInInfoVO && scope.row.warehouseInInfoVO.volume">{{getTotlContent(scope.row.warehouseInInfoVO,['volume'])}}</p>
                    <p v-if="scope.row.warehouseInInfoVO && scope.row.warehouseInInfoVO.weight">{{getTotlContent(scope.row.warehouseInInfoVO,['weight'])}}</p>
huhaiqing's avatar
huhaiqing committed
261 262
                  </template>
                </el-table-column>
263
                <el-table-column :label="$t('报关方式')" align="center" prop="">
264 265 266
                  <div :class="item.customsType !== 1 ? 'custom_type_red' : ''">
                    <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="item.customsType" />
                  </div>
267
                </el-table-column>
268
                <el-table-column :label="$t('包装类型')" align="center" prop="">
269
                  <template slot-scope="scope">
270
                    <dict-tag :type="DICT_TYPE.ECW_PACKAGING_TYPE" :value="scope.row.warehouseInInfoVO && scope.row.warehouseInInfoVO.unit" />
271 272
                  </template>
                </el-table-column>
Marcus's avatar
Marcus committed
273
                <el-table-column :label="$t('材质')" align="center" prop="material">{{ $t('') }}<template slot-scope="scope">
274
                    <dict-tag :type="DICT_TYPE.ECW_PRODUCT_MATERIAL" :value="scope.row.material" />
huhaiqing's avatar
huhaiqing committed
275 276
                  </template>
                </el-table-column>
277
                <!-- <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
huhaiqing's avatar
huhaiqing committed
278
                  <template slot-scope="scope">
279
                    <el-dropdown trigger="click" @command="(command)=>handleGoods('single',scope.row,command)">
280
                      <el-button type="primary" size="small">{{$t('预装')}}</el-button>
huhaiqing's avatar
huhaiqing committed
281 282 283 284 285
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item :command="part" v-for="(part, index) in preList" :key="part.id">{{index+1}}部分</el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>
                  </template>
286
                </el-table-column> -->
huhaiqing's avatar
huhaiqing committed
287
              </el-table>
huhaiiqng's avatar
huhaiiqng committed
288
            </el-row>
huhaiqing's avatar
huhaiqing committed
289
          </el-scrollbar>
huhaiiqng's avatar
huhaiiqng committed
290 291 292 293 294
        </el-col>
      </el-row>
    </el-card>

    <!-- 操作员 -->
295
    <el-row style="margin-top: 15px" v-show="!isAudit">
huhaiiqng's avatar
huhaiiqng committed
296
      <el-row>
297
        <el-form ref="operatorForm" :model="operatorData" size="small" :inline="true" label-width="120px" :rules="rules">
298 299
          <el-form-item :label="$t('目的地操作员')" prop="noticeUser">
            <userSelect v-model="operatorData.noticeUser" :placeholder="$t('请选择目的地操作员')" :allUsers="this.$attrs.allUsers" size="small" />
huhaiiqng's avatar
huhaiiqng committed
300 301 302 303
          </el-form-item>
        </el-form>
      </el-row>
    </el-row>
huhaiqing's avatar
huhaiqing committed
304 305

    <!-- 审核流程 -->
huhaiqing's avatar
huhaiqing committed
306
    <el-row class="process-area">
huhaiqing's avatar
huhaiqing committed
307
      <div class="process">
308
        <div>{{$t('审批流程')}}</div>
309
        <work-flow xmlkey="shipment_preassemble" v-model="selectedUsers"></work-flow>
huhaiqing's avatar
huhaiqing committed
310
      </div>
huhaiqing's avatar
huhaiqing committed
311
      <div v-show="isAudit">
312 313 314
        <el-button type="primary" @click="jumpReviewDetail">{{$t('审核中')}}</el-button>
        <el-button plain type="primary" @click="canclAudit">{{$t('取消审核')}}</el-button>
        <el-button plain type="primary" @click="closeDialog">{{$t('返回')}}</el-button>
huhaiqing's avatar
huhaiqing committed
315
      </div>
huhaiqing's avatar
huhaiqing committed
316
      <div v-show="!isAudit">
317
        <el-button type="primary" @click="onSubmit">{{$t('提交申请')}}</el-button>
huhaiqing's avatar
huhaiqing committed
318
      </div>
huhaiqing's avatar
huhaiqing committed
319
    </el-row>
320 321 322 323 324 325 326 327 328
    <!-- 关联订单弹窗 -->
    <el-dialog :title="relationOrderListDialog.title" :visible.sync="relationOrderListDialog.visible" width="30%" append-to-body>
      <el-row v-for="(item,index) in relationOrderListDialog.data" :key="item.id">
        {{index+1}}. {{item.orderNo}}
      </el-row>
      <el-row style="margin-top: 10px;text-align: center;">
        <el-button type="primary" @click="relationOrderListDialog.visible = false">{{$t('关闭窗口')}}</el-button>
      </el-row>
    </el-dialog>
huhaiqing's avatar
huhaiqing committed
329

huhaiiqng's avatar
huhaiiqng committed
330 331 332 333 334
  </div>
</template>

<script>
import { DICT_TYPE } from "@/utils/dict";
huhaiqing's avatar
huhaiqing committed
335 336 337 338 339 340 341
import {
  secGoodsList,
  preloadPage,
  createSection,
  deleteSection,
  createGoods,
  deleteGoods,
342
  changeSection,
huhaiqing's avatar
huhaiqing committed
343
  approvalCreate,
huhaiqing's avatar
huhaiqing committed
344
  approvalCancel,
345
  loadRelationOrder,
huhaiqing's avatar
huhaiqing committed
346
} from "@/api/ecw/boxSea";
huhaiqing's avatar
huhaiqing committed
347
import userSelect from "./common/userSelect.vue";
348 349 350 351 352 353 354
import {
  formatDate,
  getTotlContent,
  serviceMsg,
  getCapacity,
  toReviewDetail,
} from "../utils";
huhaiqing's avatar
huhaiqing committed
355
import dayjs from "dayjs";
huhaiqing's avatar
huhaiqing committed
356
import WorkFlow from "@/components/WorkFlow";
357
import Decimal from "decimal.js";
huhaiiqng's avatar
huhaiiqng committed
358

huhaiqing's avatar
huhaiqing committed
359 360 361
/**
 * 预装
 */
huhaiiqng's avatar
huhaiiqng committed
362 363
export default {
  name: "preinstall",
huhaiqing's avatar
huhaiqing committed
364
  inheritAttrs: false,
huhaiqing's avatar
huhaiqing committed
365
  components: { userSelect, WorkFlow },
huhaiiqng's avatar
huhaiiqng committed
366 367 368 369
  data() {
    return {
      // 状态
      stateOps: [
370 371
        { value: "1", label: this.$t("拆单") },
        { value: "2", label: this.$t("关联单") },
huhaiiqng's avatar
huhaiiqng committed
372 373
      ],
      // 备案
huhaiqing's avatar
huhaiqing committed
374
      filingOps: this.getDictDatas(DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL),
huhaiiqng's avatar
huhaiiqng committed
375 376
      // 报关方式
      declarationMethodOps: this.getDictDatas(DICT_TYPE.ECW_CUSTOMS_TYPE),
huhaiqing's avatar
huhaiqing committed
377 378 379 380
      // 查询标识
      type: "",
      // 已预装 遮罩层
      preLoading: false,
381 382 383 384 385
      preList: {
        sectionGoodList: [],
        remainWeight: 0,
        remainVolume: 0,
      },
huhaiqing's avatar
huhaiqing committed
386 387 388 389 390 391 392
      // 选中行
      selectedRows: {},

      // 待预装
      toBePreLoading: false,
      toBePreList: [],
      total: 0,
393
      unloadStatistics: {},
huhaiqing's avatar
huhaiqing committed
394

huhaiiqng's avatar
huhaiiqng committed
395 396
      // 显示搜索条件
      showSearch: true,
huhaiqing's avatar
huhaiqing committed
397

huhaiiqng's avatar
huhaiiqng committed
398
      // 查询参数
huhaiqing's avatar
huhaiqing committed
399
      queryParams: {},
huhaiqing's avatar
huhaiqing committed
400
      pageParam: { pageNo: 1, pageSize: 10 },
huhaiiqng's avatar
huhaiiqng committed
401
      // 目的地操作员
huhaiqing's avatar
huhaiqing committed
402
      operatorData: {},
huhaiqing's avatar
huhaiqing committed
403
      // 校验
huhaiiqng's avatar
huhaiiqng committed
404
      rules: {
405
        noticeUser: [
406 407 408 409 410
          {
            required: true,
            message: this.$t("目的地操作员必填"),
            trigger: "change",
          },
411
        ],
huhaiiqng's avatar
huhaiiqng committed
412
      },
huhaiqing's avatar
huhaiqing committed
413 414
      // 出货信息
      shipmentObj: this.$attrs.shipmentObj,
huhaiqing's avatar
huhaiqing committed
415
      // 抄送人数组
huhaiqing's avatar
huhaiqing committed
416
      selectedUsers: [],
huhaiqing's avatar
huhaiqing committed
417 418
      // 智慧预装
      smartInstall: 1,
419 420 421 422 423 424 425
      //关联订单
      relationOrderListDialog: {
        title: '',
        visible: false,
        data: []
      },

huhaiiqng's avatar
huhaiiqng committed
426 427 428
    };
  },
  computed: {
huhaiqing's avatar
huhaiqing committed
429
    /** 始发地 */
huhaiiqng's avatar
huhaiiqng committed
430
    exportWarehouseList() {
huhaiqing's avatar
huhaiqing committed
431
      return this.$attrs.warehouseList.filter(
huhaiiqng's avatar
huhaiiqng committed
432 433 434
        (item) => item.tradeType == "2" || item.type == "3"
      );
    },
huhaiqing's avatar
huhaiqing committed
435
    /** 目的地 */
huhaiiqng's avatar
huhaiiqng committed
436
    importWarehouseList() {
huhaiqing's avatar
huhaiqing committed
437
      return this.$attrs.warehouseList.filter(
huhaiiqng's avatar
huhaiiqng committed
438 439 440
        (item) => item.tradeType == "1" || item.type == "3"
      );
    },
huhaiqing's avatar
huhaiqing committed
441 442 443 444 445
    /* 是否审核中 */
    isAudit() {
      const { currNode, shipmentObj } = this.$attrs;
      return shipmentObj[currNode.keyName] === 23;
    },
446 447 448 449 450
    /* 容量 */
    calcCapacity() {
      const { cabinetRespVO } = this.$attrs.shipmentObj;
      return getCapacity(cabinetRespVO);
    },
huhaiiqng's avatar
huhaiiqng committed
451 452
  },
  created() {
huhaiqing's avatar
huhaiqing committed
453
    // 查询待预装
huhaiqing's avatar
huhaiqing committed
454
    this.handleQuery("toBePre");
455
    this.handleQuery("pre");
huhaiqing's avatar
huhaiqing committed
456
    this.smartInstall = 0;
huhaiiqng's avatar
huhaiiqng committed
457 458
  },
  methods: {
459
    formatDate,
huhaiqing's avatar
huhaiqing committed
460
    getTotlContent,
huhaiqing's avatar
huhaiqing committed
461 462
    /* 获取城市 */
    importCityName(id) {
huhaiqing's avatar
huhaiqing committed
463
      var arr = this.$attrs.warehouseList.filter((item) => item.id == id);
464
      return arr.length > 0 ? this.$l(arr[0], "title") : this.$t("");
huhaiqing's avatar
huhaiqing committed
465 466 467 468 469 470 471 472
    },
    /* 选中行 */
    checkboxSelect(selection, part) {
      this.selectedRows[part.id] = selection;
    },
    /* 查询已预装 */
    getSecGoods() {
      this.preLoading = true;
huhaiiqng's avatar
huhaiiqng committed
473
      // 处理查询参数
474
      let params = this.getParams();
huhaiqing's avatar
huhaiqing committed
475 476 477
      // 已预装单号
      params.orderNo = params.preOrderNo;
      params.shipmentId = this.shipmentObj.id;
huhaiqing's avatar
huhaiqing committed
478
      params.smartInstall = this.smartInstall;
huhaiqing's avatar
huhaiqing committed
479
      secGoodsList(params).then((res) => {
480 481 482 483 484 485 486 487 488 489 490 491 492
        if (res.data) {
          res.data.sectionGoodList.map((data) => {
            if (data.sectionGoodsList) {
              data.sectionGoodsList.map((data1) => {
                data1.warehouseInInfoVO = data1.warehouseInInfo
                  ? JSON.parse(data1.warehouseInInfo)
                  : {};
                return data1;
              });
            }
            return data;
          });
        }
huhaiqing's avatar
huhaiqing committed
493 494 495 496 497 498 499 500
        this.preList = res.data;
        this.preLoading = false;
      });
    },
    /* 查询待预装 */
    getPreLoad() {
      this.toBePreLoading = true;
      // 处理查询参数
501
      let params = this.getParams();
huhaiqing's avatar
huhaiqing committed
502 503
      // 订单号
      params.orderNo = params.toBePreOrderNo;
huhaiqing's avatar
huhaiqing committed
504
      params.transportType = this.shipmentObj.transportType;
huhaiqing's avatar
huhaiqing committed
505
      preloadPage({ ...params, ...this.pageParam }).then((res) => {
506 507 508 509
        const { data } = res;
        this.toBePreList = data.dataList?.list ?? [];
        this.total = data.dataList?.total ?? 0;
        this.unloadStatistics = data.unloadStatistics ?? {};
huhaiqing's avatar
huhaiqing committed
510
        this.toBePreLoading = false;
511 512 513 514
        if(this.toBePreList.length == 0&&this.total!=0){
          --this.pageParam.pageNo
          this.getPreLoad()
        }
huhaiiqng's avatar
huhaiiqng committed
515 516
      });
    },
517 518 519 520 521 522 523
    /**查看关联订单 */
    getRelationOrder(item) {
      console.log(item)
      this.relationOrderListDialog.title = item.orderNo+'关联订单'
      this.relationOrderListDialog.visible = true
      this.relationOrderListDialog.data = item.relateOrderList
    },
huhaiiqng's avatar
huhaiiqng committed
524
    /** 搜索按钮操作 */
huhaiqing's avatar
huhaiqing committed
525 526 527 528 529 530 531
    handleQuery(type) {
      this.pageParam.pageNo = 1;
      if (type === "pre") {
        this.getSecGoods();
      } else {
        this.getPreLoad();
      }
huhaiiqng's avatar
huhaiiqng committed
532 533 534
    },
    /** 重置按钮操作 */
    resetQuery() {
535 536
      this.queryParams = {};
      this.$refs["queryForm"].resetFields();
huhaiiqng's avatar
huhaiiqng committed
537 538 539
    },
    /** 提交 */
    onSubmit() {
540 541 542
      this.$refs["operatorForm"].validate((valid, errors) => {
        if (!valid) {
          return this.$showFormValidateErrors(errors);
huhaiiqng's avatar
huhaiiqng committed
543
        }
544 545
        approvalCreate({
          ...this.operatorData,
546
          applyReason: this.$t("预装审核"),
547 548 549 550 551 552 553 554 555
          approvalStatus: 0,
          approvalType: 1, // 预装
          copyUserId: this.selectedUsers,
          shipmentId: this.$attrs.shipmentObj.id,
        }).then((res) => {
          serviceMsg(res, this).then(() => {
            this.$emit("closeDialog", "submit");
          });
        });
huhaiiqng's avatar
huhaiiqng committed
556 557
      });
    },
huhaiqing's avatar
huhaiqing committed
558 559 560 561 562 563
    /* 统计列 */
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (column.property === "brandType") {
564
          sums[index] = this.$t("合计");
huhaiqing's avatar
huhaiqing committed
565 566 567
          return;
        }
        if (column.property === "num") {
568 569 570
          sums[index] = new Decimal(
            this.calcSum(column.property, data)
          ).toNumber();
huhaiqing's avatar
huhaiqing committed
571 572
        }
        if (column.property === "volumeWeight") {
573 574 575 576
          let volume = this.calcSum("volume", data);
          let weight = this.calcSum("weight", data);
          volume = volume === 0 ? volume : new Decimal(volume).toFixed(2);
          weight = weight === 0 ? weight : new Decimal(weight).toFixed(2);
huhaiqing's avatar
huhaiqing committed
577 578 579 580
          sums[index] = getTotlContent({ volume, weight }, [
            "volume",
            "weight",
          ]);
581
          sums[index] = sums[index].replace(" ", "\n");
huhaiqing's avatar
huhaiqing committed
582 583 584 585 586 587
        }
      });
      return sums;
    },
    /* 计算总和 */
    calcSum(key, data) {
huhaiqing's avatar
huhaiqing committed
588
      const values = data?.map((item) => Number(item[key])) ?? [];
huhaiqing's avatar
huhaiqing committed
589 590 591 592
      if (!values.every((value) => isNaN(value))) {
        return values.reduce((prev, curr) => {
          const value = Number(curr);
          if (!isNaN(value)) {
593
            return prev + curr;
huhaiqing's avatar
huhaiqing committed
594 595 596 597 598
          } else {
            return prev;
          }
        }, 0);
      }
599
      return 0;
huhaiqing's avatar
huhaiqing committed
600 601 602
    },
    /* 待预装订单分页 */
    pageChange(page) {
huhaiqing's avatar
huhaiqing committed
603
      this.pageParam.pageNo = page;
huhaiqing's avatar
huhaiqing committed
604 605 606 607 608
      this.getPreLoad();
    },
    /* 折叠 */
    foldTable(index, part) {
      part.fold = !part.fold;
609
      this.$set(this.preList.sectionGoodList, index, part);
huhaiqing's avatar
huhaiqing committed
610 611 612
    },
    /* 增加部分 */
    addPart() {
huhaiqing's avatar
huhaiqing committed
613 614 615 616 617 618 619
      createSection({ shipmentId: this.shipmentObj.id, isCover: 0 }).then(
        (res) => {
          serviceMsg(res, this).then(() => {
            this.getSecGoods();
          });
        }
      );
huhaiqing's avatar
huhaiqing committed
620 621 622
    },
    /* 删除部分 */
    deletePart(part) {
623 624 625 626 627 628 629
      this.$confirm(
        this.$t("确认删除该部分及其已预装订单?"),
        this.$t("提示"),
        {
          type: "warning",
        }
      )
huhaiqing's avatar
huhaiqing committed
630 631 632
        .then((_) => {
          deleteSection(part.id).then((res) => {
            serviceMsg(res, this).then(() => {
633
              this.queryAllData();
huhaiqing's avatar
huhaiqing committed
634 635 636 637 638 639 640 641
            });
          });
        })
        .catch((_) => {});
    },
    /** 预装 */
    handleGoods(type, item, part) {
      if (type === "all") {
642 643 644 645 646 647 648 649 650
        let params = {
          secId: part.id,
          shipmentId: this.shipmentObj.id,
          orderId: item.orderId,
          orderItemIdList: item.boxOrderItemList.map(
            (data) => data.orderItemId
          ),
        };

651 652 653 654 655
        createGoods(params)
          .then((res) => {
            const { data } = res;
            if (data.relationMsg) {
              const msg = data.relationMsg.replaceAll(",", "");
656 657 658 659 660 661 662
              this.$confirm(msg, this.$t("提示"), {
                type: "warning",
              })
                .then((_) => {
                  loadRelationOrder(data).then((res) => {
                    serviceMsg(res, this).then(() => {
                      this.queryAllData();
663 664
                    });
                  });
665
                })
666 667 668
                .catch((_) => {
                  this.queryAllData();
                });
669 670 671 672 673 674 675 676 677
            } else {
              serviceMsg(res, this).then(() => {
                this.queryAllData();
              });
            }
          })
          .catch((res) => {
            if (res.code === 555) {
              const msg = res.msg && res.msg.replaceAll(",", "");
huhaiqing's avatar
huhaiqing committed
678
              this.$confirm(msg, this.$t("提示"), {
679 680 681
                type: "warning",
              })
                .then((_) => {
682
                  createGoods({ ...params, relationStatus: 1 }).then((res) => {
683 684
                    serviceMsg(res, this).then(() => {
                      this.queryAllData();
685 686
                    });
                  });
687
                })
688 689 690
                .catch((_) => {
                  this.queryAllData();
                });
691
            }
692
          });
huhaiqing's avatar
huhaiqing committed
693
      } else {
694 695 696 697 698 699 700 701
        let params = {
          secId: part.id,
          id: item.id,
        };
        changeSection(params).then((res) => {
          serviceMsg(res, this).then(() => {
            this.queryAllData();
          });
huhaiqing's avatar
huhaiqing committed
702
        });
703
      }
huhaiqing's avatar
huhaiqing committed
704 705 706 707 708
    },
    /* 删除订单 */
    deleteOrder(type, data) {
      let ids = [];
      if (type === "selected") {
709
        // 根据parid 构建的对象
huhaiqing's avatar
huhaiqing committed
710 711
        const rows = this.selectedRows[data.id] ?? [];
        if (!rows.length) {
712
          this.$message.error(this.$t("请选择订单"));
huhaiqing's avatar
huhaiqing committed
713 714
          return;
        }
715
        ids = rows.map((item) => item.id);
huhaiqing's avatar
huhaiqing committed
716 717 718
      }

      if (type === "row") {
719
        ids.push(data.id);
huhaiqing's avatar
huhaiqing committed
720 721 722 723 724 725 726 727 728 729
      }

      deleteGoods(ids).then((res) => {
        serviceMsg(res, this).then(() => {
          this.queryAllData();
        });
      });
    },
    /* 查询所有数据 */
    queryAllData() {
huhaiqing's avatar
huhaiqing committed
730
      this.getSecGoods();
huhaiqing's avatar
huhaiqing committed
731
      this.getPreLoad();
huhaiqing's avatar
huhaiqing committed
732
    },
huhaiqing's avatar
huhaiqing committed
733
    /* 获取参数 */
734 735 736 737
    getParams() {
      const { rucangtime = [] } = this.queryParams;
      return {
        ...this.queryParams,
738
        ...this.$attrs.params,
huhaiqing's avatar
huhaiqing committed
739 740 741 742 743 744
        rucangTimeStart: rucangtime[0]
          ? dayjs(rucangtime[0]).format("YYYY-MM-DD 00:00:00")
          : rucangtime[0],
        rucangTimeEnd: rucangtime[1]
          ? dayjs(rucangtime[1]).format("YYYY-MM-DD 23:59:59")
          : rucangtime[1],
745 746
      };
    },
huhaiqing's avatar
huhaiqing committed
747 748 749 750 751 752 753 754 755
    /* 关闭弹框 */
    closeDialog() {
      this.$emit("closeDialog");
    },
    /* 取消审核 */
    canclAudit() {
      const { currNode, shipmentObj } = this.$attrs;
      const { voName } = currNode;
      approvalCancel({
756
        applyReason: this.$t("取消审核"),
huhaiqing's avatar
huhaiqing committed
757 758 759 760 761 762 763 764
        id: shipmentObj[voName].id,
        shipmentId: shipmentObj.id,
      }).then((res) => {
        serviceMsg(res, this).then(() => {
          this.$emit("closeDialog", "submit");
        });
      });
    },
765 766 767 768 769
    jumpReviewDetail() {
      const { currNode, shipmentObj } = this.$attrs;
      toReviewDetail.apply(this, [shipmentObj[currNode.voName].bpmProcessId]);
      this.$emit("closeDialog");
    },
770 771 772
    getRatioMax(row) {
      let volume = row.volume ?? 0;
      let weight = row.weight ?? 0;
huhaiqing's avatar
huhaiqing committed
773
      return Decimal.div(weight, volume).toFixed(2);
774
    },
huhaiqing's avatar
huhaiqing committed
775
  },
huhaiiqng's avatar
huhaiiqng committed
776 777 778
};
</script>

huhaiqing's avatar
huhaiqing committed
779
<style lang="scss">
huhaiiqng's avatar
huhaiiqng committed
780
.preinstall {
huhaiqing's avatar
huhaiqing committed
781 782 783
  display: flex;
  flex-direction: column;

huhaiiqng's avatar
huhaiiqng committed
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813
  p {
    margin: 0;
  }
  .preinstall-title {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 10px;

    &.preinstalled {
      flex: 1;
      display: flex;
      justify-content: flex-end;
      > div {
        display: flex;
      }
    }

    &.order-title {
      margin-bottom: 0px;
      background-color: #e6ebf5;
      height: 45px;
    }

    > div {
      display: flex;
      margin-right: 10px;
    }

    .table-label {
huhaiqing's avatar
huhaiqing committed
814 815
      font-size: 16px;
      font-weight: bolder;
huhaiiqng's avatar
huhaiiqng committed
816 817 818 819 820 821 822 823 824 825 826 827 828
    }
    .red-label {
      color: red;
    }
    .table-button {
      flex: 1;
      margin: 0;
      display: flex;
      justify-content: flex-end;
    }
  }
  .preinstall-table {
    display: flex;
huhaiqing's avatar
huhaiqing committed
829
    height: calc(100% - 30px);
huhaiiqng's avatar
huhaiiqng committed
830 831 832 833 834 835 836 837
    > div {
      border: 1px solid #e6ebf5;
      padding: 10px 0px;
    }
    > div:first-child {
      margin-right: 10px;
    }
  }
huhaiqing's avatar
huhaiqing committed
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856

  .pre-part {
    margin-bottom: 10px;
    margin-right: 10px;
    .pre-part-info {
      font-weight: bolder;
      > p:first-child {
        color: #13ce66;
        margin-right: 10px;
      }
      > p:last-child {
        > span {
          margin-right: 5px;
        }
      }
    }
  }

  .preinstall-card {
huhaiqing's avatar
huhaiqing committed
857
    min-height: 800px;
huhaiqing's avatar
huhaiqing committed
858 859 860 861 862
    .el-card__body {
      height: 100%;

      .tobePre-row {
        margin-top: 10px;
863 864 865 866 867
        .el-table {
          .cell {
            white-space: pre-line;
          }
        }
huhaiqing's avatar
huhaiqing committed
868 869 870
      }
    }
  }
huhaiqing's avatar
huhaiqing committed
871 872 873 874 875 876 877 878 879 880 881 882 883 884

  .process-area {
    margin-top: 15px;
    padding-bottom: 30px;
    .process {
      display: flex;
      flex-direction: column;
      > :first-child {
        color: #606266;
        font-weight: bolder;
        font-size: 16px;
      }
    }
  }
huhaiiqng's avatar
huhaiiqng committed
885 886
}
</style>