index.vue 35.3 KB
Newer Older
Smile's avatar
Smile 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">
Smile's avatar
Smile committed
6 7 8 9 10 11 12 13 14
      <el-form-item :label="$t('编号')">
        <el-input
          v-model.trim="noParam.value"
          :placeholder="$t('请输入快递号、包裹号、订单号')"
          clearable
          class="w-200"
          @input="replaceSpace(noParam, 'value')"
          @keyup.enter.native="handleQuery">
          <template slot="prepend">
15
            <dict-selector :type="DICT_TYPE.ORDER_QUERY_NO_FIELD" defaultable v-model="noParam.key"/>
Smile's avatar
Smile committed
16 17
          </template>
        </el-input>
Smile's avatar
Smile committed
18 19
      </el-form-item>
      <el-form-item label="发货人" prop="customerNumber">
20 21
        <el-input v-model="queryParams.customerKey" placeholder="请输入发货人手机号、客户编号" clearable
                  @keyup.enter.native="handleQuery"/>
Smile's avatar
Smile committed
22
      </el-form-item>
Smile's avatar
Smile committed
23
      <el-form-item label="发货人名称" prop="customerNumber">
24 25
        <el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable
                  @keyup.enter.native="handleQuery"/>
Smile's avatar
Smile committed
26
      </el-form-item>
27 28 29 30 31 32 33 34 35 36 37 38 39 40
      <el-form-item :label="$t('客户经理')">
        <user-selector manage v-model="queryParams.salesmanIds" multiple clearable @change="handleQuery"
                       :prepend="{ id: 0, nickname: $t('未分配客户经理') }" class="w-200"/>
      </el-form-item>
      <el-form-item :label="$t('包裹状态')" prop="statusList">
        <dict-selector :type="DICT_TYPE.CONS_STATUS" multiple v-model="queryParams.statusList" @keyup.enter.native="handleQuery"  clearable @change="handleQuery" class="w-200" />
      </el-form-item>
      <el-form-item :label="$t('在仓时间')" v-show="showSearch">
        <el-input type="number" v-model.trim="pickRatio.value" :placeholder="$t('请输入数字')" clearable @keyup.enter.native="handleQuery" class="w-200">
          <template slot="prepend">
            <dict-selector :type="DICT_TYPE.PICK_RATIO_FIELD" defaultable v-model="pickRatio.key" />
          </template>
        </el-input>
      </el-form-item>
Smile's avatar
Smile committed
41 42
      <el-form-item :label="$t('集运仓')">
        <el-select v-model="queryParams.wareId" :placeholder="$t('请选择仓库')" filterable>
43 44
          <el-option v-for="warehouse in this.warehouseList" :key="warehouse.id" :label="$l(warehouse,'title')"
                     :value="warehouse.id"></el-option>
Smile's avatar
Smile committed
45 46 47
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('运输方式')" prop="transportId">
48
        <dict-selector :type="DICT_TYPE.ECW_TRANSPORT_TYPE" v-model="queryParams.transportId" class="w-200"/>
Smile's avatar
Smile committed
49 50
      </el-form-item>
      <el-form-item :label="$t('目的国')" prop="consigneeCountryId">
51 52 53 54
        <el-select v-model="queryParams.consigneeCountryId" :label="queryParams.consigneeCountryId"
                   :placeholder="$t('请选择目的国')" clearable @change="handleQuery" class="w-200">
          <el-option v-for="item in AddressProvince" :key="item.guojia" :label="item.guojiaName"
                     :value="item.guojia"></el-option>
Smile's avatar
Smile committed
55 56 57
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('目的城市')" prop="objectiveId">
58 59
        <el-select v-model="queryParams.consigneeCityId" :placeholder="$t('请选择目的城市')" style="width: 200px"
                   clearable @change="handleQuery" class="w-200">
Smile's avatar
Smile committed
60 61 62
          <el-option v-for="item in AddressCity" :key="item.shi" :label="item.shiName" :value="item.shi"></el-option>
        </el-select>
      </el-form-item>
63 64 65 66 67 68 69 70
      <el-form-item :label="$t('出货渠道')" prop="channelIds">
        <selector clearable :options="channelList" :label-field="$l('name')" value-field="channelId" v-model="queryParams.channelIds" multiple class="w-200"></selector>
      </el-form-item>
      <el-form-item :label="$t('验货服务')" prop="needInspect" v-show="showSearch">
        <dict-selector v-model="queryParams.needInspect" :type="DICT_TYPE.YES_OR_NO" fomatter="bool" clearable @change="handleQuery" class="w-200" />
      </el-form-item>
      <el-form-item :label="$t('验货状态')" prop="inspectStatus" v-show="showSearch">
        <dict-selector v-model="queryParams.inspectStatus" :type="DICT_TYPE.CONS_INSPECT_STATUS" fomatter="bool" clearable @change="handleQuery" class="w-200" />
Smile's avatar
Smile committed
71
      </el-form-item>
Smile's avatar
Smile committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </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"
                   v-hasPermi="['ecw:cons:create']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
                   v-hasPermi="['ecw:cons:export']">导出</el-button>
      </el-col>
88 89 90 91 92 93 94 95 96 97
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleEdit">单个预报</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain icon="el-icon-plus" size="mini" @click="handleEditMore">多个预报</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleBatchSignOff">批量签收</el-button>
      </el-col>
      <el-col :span="1.5">
98 99
        <el-button type="success" plain icon="el-icon-plus" size="mini" @click="handleBatchConsEdit">批量更新货运信息
        </el-button>
100 101
      </el-col>
      <el-col :span="1.5">
102
        <el-button type="success" plain icon="el-icon-plus" size="mini" @click="handleTransfer">转运</el-button>
103 104
      </el-col>
      <el-col :span="1.5">
105
        <el-button type="success" plain icon="el-icon-plus" size="mini">批量申请费用</el-button>
106
      </el-col>
Smile's avatar
Smile committed
107 108 109 110
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
111 112
    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" fixed></el-table-column>
113 114 115 116 117 118 119 120 121 122 123 124 125
      <el-table-column label="快递单号" align="center" prop="expressNo">
        <template slot-scope="scope">
          <router-link
            :to="{
              path: '/cons/detail',
              query: { consId: scope.row.id }
            }"
            class="link-type"
          >
            <span>{{ scope.row.expressNo }}</span>
          </router-link>
        </template>
      </el-table-column>
Smile's avatar
Smile committed
126 127
      <el-table-column label="客户" align="center">
        <template slot-scope="scope">
128
          <router-link :to="`/customer/query/${scope.row.customerId}`" class="link-type">
129
          {{ scope.row.customerName }}({{ scope.row.customerNumber }})
130
          </router-link>
Smile's avatar
Smile committed
131
        </template>
132 133 134
      </el-table-column>
      >
      <el-table-column :label="$t('运输方式')" align="center">
Smile's avatar
Smile committed
135
        <template slot-scope="scope">
136
          <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="scope.row.transportId"/>
Smile's avatar
Smile committed
137 138 139 140
        </template>
      </el-table-column>
      <el-table-column :label="$t('动态')" align="center">
        <template slot-scope="scope">
141
          <dict-tag :type="DICT_TYPE.CONS_BUSINESS_NODE" :value="scope.row.businessNode"/>
Smile's avatar
Smile committed
142 143
        </template>
      </el-table-column>
Smile's avatar
Smile committed
144 145 146 147 148
      <el-table-column label="最新跟进时间" align="center">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.trackingTime) }}</span>
        </template>
      </el-table-column>
149
      <el-table-column label="箱数" align="center" prop="sumQuantity"/>
Smile's avatar
Smile committed
150 151 152 153 154 155 156
      <el-table-column label="填单商品" align="center">
        <template slot-scope="scope">
          <span v-html="getGoodsName(scope.row.consItemList)"></span>
        </template>
      </el-table-column>
      <el-table-column label="验货数据" align="center">
        <template slot-scope="scope">
157
          {{ getInspectionInfo(scope.row.consItemList, scope.row.inspectStatus) }}
Smile's avatar
Smile committed
158 159
        </template>
      </el-table-column>
160 161 162 163 164 165
      <el-table-column label="货值(RMB)" align="center" prop="worth"/>
      <!--      <el-table-column label="预计到仓时间" align="center" prop="watEtime" width="180">-->
      <!--        <template slot-scope="scope">-->
      <!--          <span>{{ parseTime(scope.row.watEtime) }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
Smile's avatar
Smile committed
166 167 168 169 170
      <el-table-column label="签收时间" align="center" prop="signedTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.signedTime) }}</span>
        </template>
      </el-table-column>
171
      <el-table-column label="签收备注" align="center" prop="signedRemarks"/>
Smile's avatar
Smile committed
172 173
      <el-table-column label="始发仓" align="center">
        <template slot-scope="scope">
174
          {{ isChinese ? scope.row.startTitleZh : scope.row.startTitleEn }}
Smile's avatar
Smile committed
175 176 177 178
        </template>
      </el-table-column>
      <el-table-column label="目的仓" align="center">
        <template slot-scope="scope">
179
          {{ isChinese ? scope.row.destTitleZh : scope.row.destTitleEn }}
Smile's avatar
Smile committed
180 181
        </template>
      </el-table-column>
182 183 184 185 186 187 188 189 190 191
      <el-table-column
        prop="tansportType"
        :label="$t('出货渠道')"
        align="center"
        width="100"
      >
        <template slot-scope="{ row }">
          <div>
            {{ channelName(row.channelId) }}
          </div>
Smile's avatar
Smile committed
192 193
        </template>
      </el-table-column>
Smile's avatar
Smile committed
194 195 196
      <el-table-column :label="$t('验货')" align="center">
        <template slot-scope="scope">
          <template v-if="scope.row.needInspect==='0'">
197
            {{ $t('未申请') }}
Smile's avatar
Smile committed
198 199
          </template>
          <template v-else>
200
            <dict-tag :type="DICT_TYPE.CONS_INSPECT_STATUS" :value="scope.row.inspectStatus"/>
Smile's avatar
Smile committed
201 202 203
          </template>
        </template>
      </el-table-column>
Smile's avatar
Smile committed
204 205
      <el-table-column :label="$t('包裹状态')" align="center">
        <template slot-scope="scope">
206
          <dict-tag :type="DICT_TYPE.CONS_STATUS" :value="scope.row.status"/>
Smile's avatar
Smile committed
207 208
        </template>
      </el-table-column>
209 210 211 212 213
      <el-table-column label="关联订单号" align="center" prop="orderNo">
        <template slot-scope="scope">
          <a href="javascript:void(0);"  @click="jumpOrderDetail(scope.row)">{{ scope.row.orderNo }}</a>
        </template>
      </el-table-column>
Smile's avatar
Smile committed
214 215
      <el-table-column :label="$t('订单状态')" align="center">
        <template slot-scope="scope">
216
          <dict-tag :type="DICT_TYPE.ORDER_STATUS" :value="scope.row.orderStatus"/>
Smile's avatar
Smile committed
217 218 219 220
        </template>
      </el-table-column>
      <el-table-column :label="$t('退仓处理状态')" align="center">
        <template slot-scope="scope">
221
          <dict-tag :type="DICT_TYPE.AUDIT_STATUS" :value="scope.row.returnStatus"/>
Smile's avatar
Smile committed
222 223
        </template>
      </el-table-column>
224 225
      <el-table-column label="包裹号" align="center" prop="consNum"/>
      <el-table-column label="包裹备注" align="center" prop="remarks"/>
Smile's avatar
Smile committed
226 227 228 229 230 231 232
      <el-table-column label="" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
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
          <el-dropdown>
            <el-button type="text">{{ $t("操作") }}</el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit" @click.native="handleUpdate(scope.row)">修改
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit" @click.native="handleSign(scope.row)">签收
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-delete" @click.native="handleDelete(scope.row)"
                         v-hasPermi="['ecw:cons:delete']">删除
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit" @click.native="transmutation(scope.row)">{{ $t('转异') }}
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit" @click.native="specialNeedsCons(scope.row)">{{ $t('特需') }}
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit" @click.native="specialNeedsConsLook(scope.row)">
                {{ $t('特需查看') }}
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit" @click.native="feeApplication(scope.row)">
                {{ $t('费用申请') }}
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit" @click.native="consFollowup(scope.row)">{{ $t('跟进') }}
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit" @click.native="exceptionHandling(scope.row)">{{$t('处理异常')}}</el-dropdown-item>
              <!-- 退仓 -->
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit"
                         @click.native="
259 260 261
                        show = true
                        consId = scope.row.id
                      "
262 263 264 265 266
                         v-hasPermi="['ecw:order:warehouse_exit']"
              >{{ $t("退仓") }}
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit"
                         @click.native="
267 268 269
                        showReturnWarehouse = true
                        consId = scope.row.id
                      "
270 271 272 273 274
                         v-hasPermi="['ecw:order:warehouse_exit']"
              >{{ $t("处理退仓") }}
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit"
                         @click.native="
275 276 277
                        showExit = true
                        consId = scope.row.id
                      "
278 279 280 281 282
                         v-hasPermi="['ecw:order:warehouse_exit']"
              >{{ $t("撤出包裹") }}
              </el-dropdown-item>
              <el-dropdown-item size="mini" type="text" icon="el-icon-edit"
                         @click.native="
283 284 285
                        showAdd = true
                        consId = scope.row.id
                      "
286 287 288 289 290
                         v-hasPermi="['ecw:order:warehouse_exit']"
              >{{ $t("追加包裹") }}
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
Smile's avatar
Smile committed
291 292 293 294
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
295
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.row"
Smile's avatar
Smile committed
296 297
                @pagination="getList"/>

298 299 300
    <el-dialog :title="inspectTitle" :visible.sync="open" width="500px" append-to-body>

    </el-dialog>
Smile's avatar
Smile committed
301 302 303 304
    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="" prop="customerId">
305
          <el-input v-model="form.customerId" placeholder="请输入"/>
Smile's avatar
Smile committed
306 307
        </el-form-item>
        <el-form-item label="客户编号" prop="customerNumber">
308
          <el-input v-model="form.customerNumber" placeholder="请输入客户编号"/>
Smile's avatar
Smile committed
309 310
        </el-form-item>
        <el-form-item label="运输方式,来自字典的值" prop="transportId">
311
          <el-input v-model="form.transportId" placeholder="请输入运输方式,来自字典的值"/>
Smile's avatar
Smile committed
312 313
        </el-form-item>
        <el-form-item label="订单ID,关联订单表" prop="orderId">
314
          <el-input v-model="form.orderId" placeholder="请输入订单ID,关联订单表"/>
Smile's avatar
Smile committed
315 316
        </el-form-item>
        <el-form-item label="平台ID,关联平台表数据,为后面系统对接预留字段" prop="platformId">
317
          <el-input v-model="form.platformId" placeholder="请输入平台ID,关联平台表数据,为后面系统对接预留字段"/>
Smile's avatar
Smile committed
318 319
        </el-form-item>
        <el-form-item label="平台订单号" prop="platformOrderSn">
320
          <el-input v-model="form.platformOrderSn" placeholder="请输入平台订单号"/>
Smile's avatar
Smile committed
321 322 323 324 325 326 327
        </el-form-item>
        <el-form-item label="包裹状态,来自字典表,cons_status" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="快递公司ID,对应快递公司表" prop="expressId">
328
          <el-input v-model="form.expressId" placeholder="请输入快递公司ID,对应快递公司表"/>
Smile's avatar
Smile committed
329 330
        </el-form-item>
        <el-form-item label="快递单号" prop="expressNo">
331
          <el-input v-model="form.expressNo" placeholder="请输入快递单号"/>
Smile's avatar
Smile committed
332 333
        </el-form-item>
        <el-form-item label="仓库ID" prop="wareId">
334
          <el-input v-model="form.wareId" placeholder="请输入仓库ID"/>
Smile's avatar
Smile committed
335 336
        </el-form-item>
        <el-form-item label="货值" prop="worth">
337
          <el-input v-model="form.worth" placeholder="请输入货值"/>
Smile's avatar
Smile committed
338 339
        </el-form-item>
        <el-form-item label="货值单位,默认为3,人民币" prop="worthCurrency">
340
          <el-input v-model="form.worthCurrency" placeholder="请输入货值单位,默认为3,人民币"/>
Smile's avatar
Smile committed
341 342
        </el-form-item>
        <el-form-item label="预计到仓时间" prop="watEtime">
343 344
          <el-date-picker clearable v-model="form.watEtime" type="date" value-format="yyyy-MM-dd"
                          placeholder="选择预计到仓时间"/>
Smile's avatar
Smile committed
345 346
        </el-form-item>
        <el-form-item label="" prop="watTime">
347
          <el-date-picker clearable v-model="form.watTime" type="date" value-format="yyyy-MM-dd" placeholder="选择"/>
Smile's avatar
Smile committed
348 349 350 351 352 353 354
        </el-form-item>
        <el-form-item label="是否被签收,0未签收,1已签收" prop="signed">
          <el-radio-group v-model="form.signed">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="签收时间" prop="signedTime">
355 356
          <el-date-picker clearable v-model="form.signedTime" type="date" value-format="yyyy-MM-dd"
                          placeholder="选择签收时间"/>
Smile's avatar
Smile committed
357 358
        </el-form-item>
        <el-form-item label="签收备注" prop="signedRemarks">
359
          <el-input v-model="form.signedRemarks" placeholder="请输入签收备注"/>
Smile's avatar
Smile committed
360 361
        </el-form-item>
        <el-form-item label="数量" prop="sumQuantity">
362
          <el-input v-model="form.sumQuantity" placeholder="请输入数量"/>
Smile's avatar
Smile committed
363
        </el-form-item>
364 365 366 367 368
        <el-form-item
          label="区分包裹是由谁创建的,关联字典表 cons_op_source,可区分为后台创建、客户web端、客户app端、客户H5端、仓库创建及其他,默认为1 客户app端"
          prop="opSource">
          <el-input v-model="form.opSource"
                    placeholder="请输入区分包裹是由谁创建的,关联字典表 cons_op_source,可区分为后台创建、客户web端、客户app端、客户H5端、仓库创建及其他,默认为1 客户app端"/>
Smile's avatar
Smile committed
369 370
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
371
          <el-input v-model="form.remarks" placeholder="请输入备注"/>
Smile's avatar
Smile committed
372 373 374 375 376 377 378
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
379
    <Transmutation :showException.sync="showException" :id="id" @determine="getList"></Transmutation>
380 381 382 383 384 385 386 387 388 389 390 391
    <SpecialNeedsCons :showSpecialNeedsCons.sync="showSpecialNeedsCons" :currency="JSON.stringify(currencyList)"
                      :consId="id" :consNum="consNum" @determine="getList"></SpecialNeedsCons>
    <SpecialNeedsConsLook :showSpecialNeedsConsLook.sync="showSpecialNeedsConsLook" :consNum="consNum"
                          :consId="id"></SpecialNeedsConsLook>
    <fee-application-cons v-if="feeApplicationBol" :consId="id" :currencys="JSON.stringify(currencyList)"
                          :dialog-visible.sync="feeApplicationBol " @refresh="getList"></fee-application-cons>
    <ConsFollowupEdit :showConsFollowupEdit.sync="showConsFollowupEdit" :consId="id"
                      @determine="getList"></ConsFollowupEdit>
    <batch-sign-off :showConsBatchSignOff.sync="showConsBatchSignOff" @determine="getList"
                    :consIds="consIds"></batch-sign-off>
    <batch-cons-edit :showConsBatchEdit.sync="showConsBatchEdit" @determine="getList"
                     :consIds="consIds"></batch-cons-edit>
392 393 394
    <cons-withdrawal v-if="show" :dialog-visible="show"  :consId="consId"></cons-withdrawal>
    <cons-withdrawal-exit v-if="showExit" :dialog-visible="showExit"  :consId="consId"></cons-withdrawal-exit>
    <cons-withdrawal-deal v-if="showReturnWarehouse" :dialog-visible="showReturnWarehouse"  :consId="consId" ></cons-withdrawal-deal>
Smile's avatar
Smile committed
395 396 397 398 399
  </div>
</template>

<script>
import {createCons, deleteCons, exportConsExcel, getCons, getConsPage, updateCons} from "@/api/ecw/cons";
400
import Transmutation from "@/views/ecw/cons/components/Transmutation.vue"
Smile's avatar
Smile committed
401
import Template from "@/views/cms/template/index.vue";
Smile's avatar
Smile committed
402
import UserSelector from "@/components/UserSelector/index.vue";
403
import {getWarehouseList} from "@/api/ecw/warehouse";
Smile's avatar
Smile committed
404
import {getRegionList} from "@/api/ecw/order";
honghy's avatar
honghy committed
405
import SpecialNeedsCons from "@/views/ecw/cons/components/SpecialNeedsCons.vue"
406 407
import SpecialNeedsConsLook from "@/views/ecw/cons/components/SpecialNeedsConsLook.vue"

408
import {getCurrencyList} from "@/api/ecw/currency"
409
import FeeApplicationCons from "@/views/ecw/cons/components/FeeApplicationCons.vue"
410
import {getChannelList} from "@/api/ecw/channel";
411
import ConsFollowupEdit from "@/views/ecw/consFollowup/components/ConsFollowupEdit.vue"
412
import BatchSignOff from "@/views/ecw/cons/batchSignOff.vue";
413
import BatchConsEdit from "@/views/ecw/cons/batchConsEdit.vue";
414 415 416
import ConsWithdrawal from "@/views/ecw/cons/consWithdrawal.vue";
import ConsWithdrawalExit from "@/views/ecw/cons/consWithdrawalExit.vue";
import ConsWithdrawalDeal from "@/views/ecw/cons/consWithdrawalDeal.vue";
417 418
import {DICT_TYPE} from "@/utils/dict";
import {arrryToKeyedObjectBy} from "@/utils";
419
import Selector from "@/components/Selector/index.vue";
Smile's avatar
Smile committed
420 421 422 423

export default {
  name: "Cons",
  components: {
424
    Selector,
425 426
    ConsWithdrawal,
    ConsWithdrawalExit,
Smile's avatar
Smile committed
427
    UserSelector,
428
    Transmutation,
honghy's avatar
honghy committed
429
    Template,
430
    FeeApplicationCons,
431
    SpecialNeedsConsLook,
432
    ConsFollowupEdit,
433
    SpecialNeedsCons,
434
    BatchSignOff,
435
    BatchConsEdit,
436
    ConsWithdrawalDeal
Smile's avatar
Smile committed
437 438 439
  },
  data() {
    return {
440 441 442 443
      pickRatio: {
        key: "eqPickRatio",
        value: ""
      },
Smile's avatar
Smile committed
444 445 446 447 448 449
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
450
      show: false,
451 452
      showExit: false,
      showAdd: false,
453
      showReturnWarehouse: false,
454
      consId: undefined,
Smile's avatar
Smile committed
455 456 457 458
      // 总条数
      total: 0,
      // 集运包裹主列表
      list: [],
459
      channelList: [],
Smile's avatar
Smile committed
460 461 462 463
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
Smile's avatar
Smile committed
464 465 466 467 468
      // 编号搜索条件
      noParam: {
        key: "numberKey",
        value: ""
      },
469
      consIds: [],
470
      inspectTitle:null,
471
      consList: [],
Smile's avatar
Smile committed
472
      dateRangeWatEtime: [],
473 474 475
      warehouseList: [],
      AddressProvince: [],
      AddressCity: [],
Smile's avatar
Smile committed
476 477 478 479 480
      dateRangeWatTime: [],
      dateRangeSignedTime: [],
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
481 482
        page: 1,
        row: 10,
Smile's avatar
Smile committed
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
        customerId: null,
        customerNumber: null,
        transportId: null,
        orderId: null,
        platformId: null,
        platformOrderSn: null,
        status: null,
        expressId: null,
        expressNo: null,
        wareId: null,
        worth: null,
        worthCurrency: null,
        signed: null,
        signedRemarks: null,
        sumQuantity: null,
        opSource: null,
        remarks: null,
      },
      // 表单参数
Smile's avatar
Smile committed
502 503 504
      form: {
        transportId: null,
      },
Smile's avatar
Smile committed
505 506
      // 表单校验
      rules: {
507
        signed: [{required: true, message: "是否被签收,0未签收,1已签收不能为空", trigger: "blur"}],
508 509
      },
      showException: false,
honghy's avatar
honghy committed
510
      showSpecialNeedsCons: false,
511
      showSpecialNeedsConsLook: false,
512
      showConsFollowupEdit: false,
513
      showConsBatchSignOff: false,
514
      showConsBatchEdit: false,
honghy's avatar
honghy committed
515 516 517
      id: null,
      currencyList: [],
      consNum: null,
518
      feeApplicationBol: false
Smile's avatar
Smile committed
519 520 521
    };
  },
  created() {
522
    this.getChannelList()
Smile's avatar
Smile committed
523
    this.getList();
524
    getChannelList().then((res) => (this.channelList = res.data))
Smile's avatar
Smile committed
525
    getWarehouseList().then((r) => {
526
      this.warehouseList = r.data.filter(map => map.isConsService === 1);
Smile's avatar
Smile committed
527 528 529
    });
    this.getAddressProvince()
    this.getAddressCity()
honghy's avatar
honghy committed
530
    getCurrencyList().then((res) => (this.currencyList = res.data))
Smile's avatar
Smile committed
531 532
  },
  computed: {
533 534 535 536
    // 渠道用id做键值
    keyedChannel(){
      return arrryToKeyedObjectBy(this.channelList, 'channelId')
    },
537 538 539
    // 根据渠道id获取渠道名
    channelName() {
      return (id) => {
540
        return id !== null && this.keyedChannel[id] ? this.keyedChannel[id].nameZh : null;
541 542
      };
    },
Smile's avatar
Smile committed
543 544 545
    isChinese() {
      return this.$i18n.locale === "zh_CN";
    },
546
    combinedQueryParams() {
Smile's avatar
Smile committed
547 548 549 550 551 552 553
      console.log(this.queryParams)
      let queryParams = {...this.queryParams}
      if (this.noParam.value) {
        queryParams[this.noParam.key] = this.noParam.value
      }
      return queryParams
    },
Smile's avatar
Smile committed
554
  },
Smile's avatar
Smile committed
555 556 557 558 559 560 561 562 563 564
  watch: {
    'queryParams.consigneeCountryId': {
      deep: true, //深度监听
      handler() {
        if (this.queryParams.consigneeCountryId != "") {
          this.findByprovinceCode()
        }
      }
    },
  },
Smile's avatar
Smile committed
565
  methods: {
566 567 568 569 570 571 572
    /* 跳转订单详情 */
    jumpOrderDetail(row) {
      this.$router.push({
        path: "/order/detail",
        query: { orderId: row.orderId },
      });
    },
573
    handleSelectionChange(val) {
574
      this.consIds = val.map((i) => i.id)
575
      this.consList = val;
576
    },
577 578 579
    getChannelList() {
      getChannelList().then((res) => (this.channelList = res.data))
    },
Smile's avatar
Smile committed
580
    getAddressProvince() {
581
      getRegionList(1, 1).then(({data}) => {
Smile's avatar
Smile committed
582 583 584 585
        this.AddressProvince = data
      })
    },
    getAddressCity() {
586
      getRegionList(4, 4).then(({data}) => {
Smile's avatar
Smile committed
587 588 589 590 591 592
        this.AddressCity = data
      })
    },
    findByprovinceCode() {
      if (this.queryParams.consigneeCountryId != null && this.queryParams.consigneeCountryId != "") {
        //获取当前省份值id,获取该省份下城市 destCountryId provinceCode
593
        getRegionList(2, this.queryParams.consigneeCountryId).then(({data}) => {
Smile's avatar
Smile committed
594 595 596 597
          this.AddressCity = data
        })
      }
    },
Smile's avatar
Smile committed
598 599 600 601
    // 自动去除空格
    replaceSpace(obj, field) {
      obj[field] = obj[field].replace(/\s+/g, "")
    },
602 603
    getGoodsName(val) {
      if (!val || val.length === 0) {
604
        return null
605
      } else {
606 607
        return val.map((item, index) => `${index + 1}.${item.prodName}*${item.quantity}`).join('<br>');
      }
Smile's avatar
Smile committed
608
    },
609 610
    getInspectionInfo(val, status) {
      if (!status && status !== 2) {
611 612
        return null
      }
Smile's avatar
Smile committed
613 614
      let inspectionNums = 0;
      let inspectionUnit;
615 616 617
      let inspectionQuantitys = 0;
      let inspectionVolumes = 0;
      let inspectionWeights = 0;
Smile's avatar
Smile committed
618 619 620 621 622 623 624
      val.forEach(item => {
        inspectionUnit = item.inspectionUnit;
        inspectionNums += item.inspectionNum;
        inspectionQuantitys += item.inspectionQuantity;
        inspectionVolumes += item.inspectionVolume;
        inspectionWeights += item.inspectionWeight;
      });
625
      return `${inspectionQuantitys}${inspectionUnit ? inspectionUnit : this.$t('')} ${inspectionVolumes}${inspectionWeights}kg ${inspectionNums}件`;
Smile's avatar
Smile committed
626 627 628 629 630
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
631
      let params = {...this.combinedQueryParams};
Smile's avatar
Smile committed
632
      console.log(params)
Smile's avatar
Smile committed
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
      this.addBeginAndEndTime(params, this.dateRangeWatEtime, 'watEtime');
      this.addBeginAndEndTime(params, this.dateRangeWatTime, 'watTime');
      this.addBeginAndEndTime(params, this.dateRangeSignedTime, 'signedTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getConsPage(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,
        customerId: undefined,
        customerNumber: undefined,
        transportId: undefined,
        orderId: undefined,
        platformId: undefined,
        platformOrderSn: undefined,
        status: undefined,
        expressId: undefined,
        expressNo: undefined,
        wareId: undefined,
        worth: undefined,
        worthCurrency: undefined,
        watEtime: undefined,
        watTime: undefined,
        signed: undefined,
668
        signer: undefined,
Smile's avatar
Smile committed
669 670 671 672 673 674 675 676 677 678
        signedTime: undefined,
        signedRemarks: undefined,
        sumQuantity: undefined,
        opSource: undefined,
        remarks: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
679
      this.queryParams.page = 1;
Smile's avatar
Smile committed
680 681 682 683 684 685 686 687
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeWatEtime = [];
      this.dateRangeWatTime = [];
      this.dateRangeSignedTime = [];
      this.dateRangeCreateTime = [];
Smile's avatar
Smile committed
688
      this.noParam.value = ""
Smile's avatar
Smile committed
689 690 691
      this.resetForm("queryForm");
      this.handleQuery();
    },
692
    handleEditMore() {
693 694
      this.$router.push("/cons/cons/create-more")
    },
695
    handleEdit() {
696 697
      this.$router.push("/cons/cons/create")
    },
698 699
    handleBatchSignOff() {
      if (!this.consIds.length) {
700 701
        return this.$message.error(this.$t('最少选择一个包裹'))
      }
702
      this.showConsBatchSignOff = true;
703 704

    },
705 706 707 708 709 710 711 712
    handleBatchConsEdit() {
      if (!this.consIds.length) {
        return this.$message.error(this.$t('最少选择一个包裹'))
      }
      this.showConsBatchEdit = true;
    },
    handleTransfer() {
      if (!this.consIds.length) {
713 714
        return this.$message.error(this.$t('最少选择一个包裹'))
      }
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
      // 2. 防御空数组
      if (!this.consList?.length) return
      // 新增客户ID非空校验(在所有校验前优先检查)
      const hasEmptyCustomer = this.consList.some(item => !item.customerId)
      if (hasEmptyCustomer) {
        return this.$message.error(this.$t('客户不能为空'))
      }
      // 3. 定义需要校验的字段及中文映射
      const VALIDATION_FIELDS = [
        'customerId',
        'transportId',
        'departureId',
        'consigneeCountryId',
        'consigneeCityId',
        'warehouseLineId',
        'channelId'
      ]
      const FIELD_NAMES = {
        customerId: this.$t('客户'),
        transportId: this.$t('运输方式'),
        departureId: this.$t('发货地'),
        consigneeCountryId: this.$t('收件国家'),
        consigneeCityId: this.$t('收件城市'),
        warehouseLineId: this.$t('仓库线路'),
        channelId: this.$t('渠道')
      }

      // 4. 动态基准值校验逻辑
      for (const field of VALIDATION_FIELDS) {
        // 4.1 动态获取第一个非空基准值
        let baseValue = null
        for (const item of this.consList) {
          if (item[field] != null) {
            baseValue = item[field]
            break
          }
        }

        // 4.2 全空字段跳过检查
        if (baseValue === null) continue

        // 4.3 检查所有非空值是否一致
        const inconsistentItem = this.consList.find(item =>
          item[field] != null && item[field] !== baseValue
        )

        if (inconsistentItem) {
          return this.$message.error(
            this.$t('所有包裹的 {field} 必须一致', { field: FIELD_NAMES[field] })
          )
        }
      }
      this.$router.push({
        path: "/order/create",
        query: {
          consIds: this.consIds.join(","),
        }
      });
773
    },
Smile's avatar
Smile committed
774 775 776 777 778 779 780 781 782
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加集运包裹主";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      const id = row.id;
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
      this.$router.push({
        path: "/cons/edit",
        query: {
          id: id,
        }
      });
    },
    /** 签收按钮操作 */
    handleSign(row) {
      debugger
      const id = row.id;
      this.$router.push({
        path: "/cons/sign",
        query: {
          id: id,
        }
Smile's avatar
Smile committed
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }
        // 修改的提交
        if (this.form.id != null) {
          updateCons(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createCons(this.form).then(response => {
          this.$modal.msgSuccess("新增成功");
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
827 828 829 830 831 832 833
      this.$modal.confirm('是否确认删除集运包裹主编号为"' + id + '"的数据项?').then(function () {
        return deleteCons(id);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
Smile's avatar
Smile committed
834 835 836 837 838
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
839 840
      params.page = undefined;
      params.row = undefined;
Smile's avatar
Smile committed
841 842 843 844 845 846
      this.addBeginAndEndTime(params, this.dateRangeWatEtime, 'watEtime');
      this.addBeginAndEndTime(params, this.dateRangeWatTime, 'watTime');
      this.addBeginAndEndTime(params, this.dateRangeSignedTime, 'signedTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行导出
      this.$modal.confirm('是否确认导出所有集运包裹主数据项?').then(() => {
847 848 849 850 851 852 853
        this.exportLoading = true;
        return exportConsExcel(params);
      }).then(response => {
        this.$download.excel(response, '${table.classComment}.xls');
        this.exportLoading = false;
      }).catch(() => {
      });
854 855 856 857 858
    },
    //转异
    transmutation(row) {
      this.id = row.id
      this.showException = true
honghy's avatar
honghy committed
859 860 861 862 863 864
    },
    //特需
    specialNeedsCons(row) {
      this.id = row.id
      this.consNum = row.consNum
      this.showSpecialNeedsCons = true
865 866 867 868 869 870
    },
    //特需查看
    specialNeedsConsLook(row) {
      this.id = row.id
      this.consNum = row.consNum
      this.showSpecialNeedsConsLook = true
871 872 873 874 875 876
    },
    //费用申请
    feeApplication(row) {
      this.id = row.id
      this.consNum = row.consNum
      this.feeApplicationBol = true
877 878 879 880 881
    },
    //跟进记录
    consFollowup(row) {
      this.id = row.id
      this.showConsFollowupEdit = true
882 883 884 885 886 887
    },
    //异常
    exceptionHandling(row) {
      this.$router.push({
        path: "./consException?id=" + row.id
      })
Smile's avatar
Smile committed
888 889 890 891
    }
  }
};
</script>