cusDeclaration.vue 24.1 KB
Newer Older
huhaiqing's avatar
huhaiqing committed
1 2
<template>
  <div>
huhaiqing's avatar
huhaiqing committed
3
    <el-form ref="cusDeclarationForm" :rules="rules" :model="cusDeclarationObj" label-width="120px">
4
      <el-form-item :label="$t('单证要求')">
huhaiqing's avatar
huhaiqing committed
5
        <template v-for="(item, index) in cusDeclarationObj.documentInfo">
6 7 8
          {{
            (index === 0 || index === cusDeclarationObj.documentInfo.length)  ? "" :"/"
          }}
huhaiqing's avatar
huhaiqing committed
9 10 11
          <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="item" :key="index" />
        </template>
        <el-button type="primary" style="margin-left:10px;" @click="downloadVGM">{{getButtonLabel(cusDeclarationObj.documentInfo)}}</el-button>
huhaiqing's avatar
huhaiqing committed
12
      </el-form-item>
13 14
      <el-form-item :label="$t('柜重')" prop="dcBoxWgt">
        <el-input v-model="cusDeclarationObj.dcBoxWgt" :placeholder="$t('请输入柜重')" clearable />
huhaiqing's avatar
huhaiqing committed
15
      </el-form-item>
16 17
      <el-form-item :label="$t('货重')" prop="dcGoodsWgt">
        <el-input v-model="cusDeclarationObj.dcGoodsWgt" :placeholder="$t('请输入货重')" clearable />
huhaiqing's avatar
huhaiqing committed
18
      </el-form-item>
huhaiqing's avatar
huhaiqing committed
19 20
      <el-form-item :label="$t('VGM重量')">
        <el-input v-model="cusDeclarationObj.dcVgmWgt" :placeholder="$t('请输入VGM重量')" clearable />
huhaiqing's avatar
huhaiqing committed
21
      </el-form-item>
22 23
      <el-form-item :label="$t('报关方式')" prop="dcCustomsType">
        <el-select v-model="cusDeclarationObj.dcCustomsType" :placeholder="$t('请选择报关方式')">
huhaiqing's avatar
huhaiqing committed
24
          <el-option v-for="type in this.getDictDatas(DICT_TYPE.BOX_SHIPPING_CUSTOMS_TYPE)" :key="type.value" :label="$l(type, 'label')" :value="type.value"></el-option>
huhaiqing's avatar
huhaiqing committed
25 26
        </el-select>
      </el-form-item>
huhaiqing's avatar
huhaiqing committed
27
      <el-form-item :label="$t('正常报关订单')" v-show="isShowNormal">
huhaiqing's avatar
huhaiqing committed
28
        <div v-for="item in normalOrderList" :key="item.orderId">
huhaiqing's avatar
huhaiqing committed
29 30
          <a href="javascript:void(0)" @click="jumpOrderDetail(item)">{{ item.orderNo }}</a>
        </div>
huhaiqing's avatar
huhaiqing committed
31
      </el-form-item>
32 33
      <el-form-item :label="$t('报关公司名称')">
        <supplierSelect v-model="cusDeclarationObj.dcCompanyId" :companyType="'2'" :placeholder="$t('请选择报关公司名称')" :allSupplier="this.$attrs.allSupplier" />
huhaiqing's avatar
huhaiqing committed
34
      </el-form-item>
35 36
      <el-form-item :label="$t('截关时间')">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cusDeclarationObj.dcCutOffTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
huhaiqing's avatar
huhaiqing committed
37
      </el-form-item>
huhaiqing's avatar
huhaiqing committed
38 39 40
      <el-form-item :label="$t('报关时间')" prop="dcDecTime">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cusDeclarationObj.dcDecTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </el-form-item>
41
      <el-form-item :label="$t('状态')" prop="dcCustomsStatus">
42
        <el-radio-group v-model="cusDeclarationObj.dcCustomsStatus" :disabled="inReview || isCheckDeal('status')">
huhaiqing's avatar
huhaiqing committed
43
          <el-radio v-for="item in this.getDictDatas(DICT_TYPE.BOX_SHIPPING_DCCUSTOMS_STATUS)" :key="item.value" :label="item.value">{{$l(item, 'label')}}</el-radio>
huhaiqing's avatar
huhaiqing committed
44 45 46 47
        </el-radio-group>
      </el-form-item>

      <!-- 查验 -->
huhaiqing's avatar
huhaiqing committed
48
      <div v-show="cusDeclarationObj.dcCustomsStatus === '3'">
49
        <el-form-item :label="$t('查验')">
50
          <el-radio-group v-model="cusDeclarationObj.dcCheckStatus" :disabled="inReview || isCheckDeal('check')">
huhaiqing's avatar
huhaiqing committed
51
            <el-radio v-for="item in this.getDictDatas(DICT_TYPE.BOX_SHIPPING_CHECK_STATUS)" :key="item.value" :label="item.value" :disabled="disabledRadio(item)">{{$l(item, 'label')}}</el-radio>
huhaiqing's avatar
huhaiqing committed
52 53 54 55 56
          </el-radio-group>
        </el-form-item>
      </div>

      <!-- 退场 -->
huhaiqing's avatar
huhaiqing committed
57
      <div v-show="['1','2','3'].includes(cusDeclarationObj.dcCheckStatus)">
58 59
        <el-form-item :label="$t('查验时间')">
          <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cusDeclarationObj.dcCheckTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
huhaiqing's avatar
huhaiqing committed
60
        </el-form-item>
61
        <el-form-item :label="$t('查验前图片')">
huhaiqing's avatar
huhaiqing committed
62
          <ImageUpload :limit="1" :isShowTip=false v-model="cusDeclarationObj.dcCheckPreImg" />
huhaiqing's avatar
huhaiqing committed
63
        </el-form-item>
64 65
        <el-form-item :label="$t('新封条')">
          <el-input v-model="cusDeclarationObj.dcStripSeal" :placeholder="$t('请输入新封条')" clearable />
huhaiqing's avatar
huhaiqing committed
66
        </el-form-item>
67
        <el-form-item :label="$t('退场状态')" v-if="cusDeclarationObj.dcCheckStatus === '1' || cusDeclarationObj.dcCheckStatus === '2'">
huhaiqing's avatar
huhaiqing committed
68 69
          {{getCheckExamineStatus}}
        </el-form-item>
huhaiqing's avatar
huhaiqing committed
70 71 72
      </div>

      <!-- 放行 -->
73 74
      <el-form-item :label="$t('放行时间')" v-show="cusDeclarationObj.dcCustomsStatus === '2' || cusDeclarationObj.dcCheckStatus === '3'">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cusDeclarationObj.dcPassTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
huhaiqing's avatar
huhaiqing committed
75 76
      </el-form-item>

77 78
      <!-- <el-form-item :label="$t('装箱单')">
        <el-button type="primary">{{$t('下载装箱单')}}</el-button>
huhaiqing's avatar
huhaiqing committed
79
      </el-form-item> -->
huhaiqing's avatar
huhaiqing committed
80
      <el-form-item :label="$t('报关单')" v-show="isDownload">
81
        <el-button type="primary" @click="downloadCusFile">{{$t('下载所有报关单')}}</el-button>
huhaiqing's avatar
huhaiqing committed
82 83 84
      </el-form-item>

    </el-form>
85
    <el-row class="operate-button" v-if="inReview">
86 87
      <el-button type="primary" @click="jumpReviewDetail">{{cusDeclarationObj.dcCheckStatus === '1' ? $t('全部退场审核中') : $t('部分退场审核中')}}</el-button>
      <el-button type="primary" plain @click="canclAudit">{{cusDeclarationObj.dcCheckStatus === '1' ? $t('取消全部退场审核') : $t('取消部分退场审核')}}</el-button>
88
    </el-row>
huhaiqing's avatar
huhaiqing committed
89
    <el-row class="operate-button">
90 91 92 93
      <el-button type="primary" @click="onSubmit(1)" :disabled="isCheckDeal('submit')">{{$t('保存')}}</el-button>
      <el-button type="success" v-if="!inReview" @click="onSubmit(2)" :disabled="isCheckDeal('submit')">{{$t('提交')}}</el-button>
      <el-button @click="cancel">{{$t('关闭')}}</el-button>
      <el-button type="primary" @click="extraCost" v-show="cusDeclarationObj.dcCustomsStatus === '2' || cusDeclarationObj.dcCustomsStatus === '3'">{{$t('额外费用')}}</el-button>
huhaiqing's avatar
huhaiqing committed
94
      <el-button type="primary" @click="exceptionReg" :disabled="!isShowError">{{$t('异常登记')}}</el-button>
huhaiqing's avatar
huhaiqing committed
95 96 97
    </el-row>

    <!-- 对话框 -->
98
    <el-dialog custom-class="shipping-dialog customsClearance" :title="dialogConfig.title" :visible.sync="dialogConfig.dialogVisible" width="700px" :modal-append-to-body=false append-to-body>
huhaiqing's avatar
huhaiqing committed
99
      <el-row>
huhaiqing's avatar
huhaiqing committed
100
        <el-row>
huhaiqing's avatar
huhaiqing committed
101
          <el-form label-width="100px">
102 103
            <el-form-item :label="$t('订单号')" class="two-element">
              <el-input v-model="orderNo" :placeholder="$t('请输入订单号')" clearable />
104
              <el-button type="primary" icon="el-icon-search" @click="searchOrder"></el-button>
huhaiqing's avatar
huhaiqing committed
105 106 107 108
            </el-form-item>
          </el-form>
        </el-row>
        <el-row>
109
          <el-table :data="costOrderList" border class="table-inputNumber">
110
            <el-table-column :label="$t('订单号')" align="center" prop="orderNo" />
111
            <el-table-column :label="$t('报关费用')" align="center" prop="fee" width="220">
huhaiqing's avatar
huhaiqing committed
112
              <template slot-scope="scope">
113
                <el-input-number v-model="scope.row.fee" controls-position="right" :min="1"></el-input-number>
huhaiqing's avatar
huhaiqing committed
114 115
              </template>
            </el-table-column>
116
            <el-table-column :label="$t('操作')" align="center">
huhaiqing's avatar
huhaiqing committed
117
              <template slot-scope="scope">
118
                <el-button type="primary" size="small" @click="createExtraCost(scope.row)">{{$t('确定')}}</el-button>
huhaiqing's avatar
huhaiqing committed
119 120 121 122 123
              </template>
            </el-table-column>
          </el-table>
        </el-row>
        <el-row class="cost-title">
124
          <div>{{$t('额外费用订单')}}</div>
huhaiqing's avatar
huhaiqing committed
125
          <div>
126
            <el-button size="small" @click="restCostList()">{{$t('重置')}}</el-button>
huhaiqing's avatar
huhaiqing committed
127 128 129
          </div>
        </el-row>
        <el-row>
130 131
          <el-table :data="costList" border height="300px" class="table-inputNumber">
            <el-table-column type="selection" width="55" align="center" />
132
            <el-table-column :label="$t('订单号')" align="center" prop="orderNo" />
133
            <el-table-column :label="$t('报关费用')" align="center" prop="fee" width="220">
huhaiqing's avatar
huhaiqing committed
134
              <template slot-scope="scope">
135
                <el-input-number v-model="scope.row.fee" controls-position="right" :min="1"></el-input-number>
huhaiqing's avatar
huhaiqing committed
136 137
              </template>
            </el-table-column>
138
            <el-table-column :label="$t('操作')" align="center">
huhaiqing's avatar
huhaiqing committed
139
              <template slot-scope="scope">
140 141
                <el-button type="primary" size="small" @click="updateExtraCost(scope.row)">{{$t('修改')}}</el-button>
                <el-button size="small" @click="restCostList(scope.row)">{{$t('重置')}}</el-button>
huhaiqing's avatar
huhaiqing committed
142 143 144 145 146 147
              </template>
            </el-table-column>
          </el-table>
        </el-row>
      </el-row>
    </el-dialog>
huhaiqing's avatar
huhaiqing committed
148 149 150 151 152

    <!-- 对话框 -->
    <el-dialog custom-class="shipping-dialog" :title="$t('票异常')" :visible.sync="regDialogVisible" width="700px" :modal-append-to-body=false append-to-body destroy-on-close>
      <regError @closeDialog="regCloseDialog" v-bind="$attrs" :shipmentObj="shipmentObj" />
    </el-dialog>
huhaiqing's avatar
huhaiqing committed
153 154 155 156
  </div>
</template>

<script>
huhaiqing's avatar
huhaiqing committed
157
import supplierSelect from "./common/supplierSelect.vue";
158 159 160 161 162 163
import {
  customsCreate,
  extraCostList,
  extraCostOrder,
  extraCostCreate,
  extraCostUpdate,
huhaiqing's avatar
huhaiqing committed
164
  approvalCancel,
165 166
  resetById,
  resetByShipmentId,
huhaiqing's avatar
huhaiqing committed
167
  customsOrderList,
168
} from "@/api/ecw/boxSea";
169 170 171 172 173
import {
  formatNumberString,
  formatDateStr,
  serviceMsg,
  toReviewDetail,
174
  downloadFileByUrl,
175
} from "../utils";
huhaiqing's avatar
huhaiqing committed
176
import ImageUpload from "@/components/ImageUpload";
177
import Decimal from "decimal.js";
huhaiqing's avatar
huhaiqing committed
178 179
import regError from "../../regError";
import dayjs from "dayjs";
huhaiqing's avatar
huhaiqing committed
180

huhaiqing's avatar
huhaiqing committed
181 182 183 184
/**
 * 报关
 */
export default {
huhaiqing's avatar
huhaiqing committed
185
  name: "cusDeclaration",
huhaiqing's avatar
huhaiqing committed
186
  inheritAttrs: false,
huhaiqing's avatar
huhaiqing committed
187
  components: { supplierSelect, ImageUpload, regError },
188 189 190
  props: {
    shipmentObj: Object,
  },
huhaiqing's avatar
huhaiqing committed
191 192 193
  data() {
    return {
      // 报关对象
huhaiqing's avatar
huhaiqing committed
194
      cusDeclarationObj: {},
huhaiqing's avatar
huhaiqing committed
195 196
      // 校验
      rules: {
197 198 199 200 201 202 203 204 205
        dcBoxWgt: [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ],
        dcGoodsWgt: [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ],
        dcCustomsType: [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ],
206
        dcCustomsStatus: [
207
          { required: true, message: this.$t("必填"), trigger: "change" },
208
        ],
huhaiqing's avatar
huhaiqing committed
209 210 211
        dcDecTime: [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ],
huhaiqing's avatar
huhaiqing committed
212 213 214 215 216 217 218 219
      },
      // 弹窗配置
      dialogConfig: {
        title: "",
        dialogVisible: false,
      },
      // 订单号
      orderNo: "",
220 221 222 223
      // 订单列表
      costOrderList: [],
      // 额外费用列表
      costList: [],
224 225
      // 是否审核中
      inReview: false,
huhaiqing's avatar
huhaiqing committed
226 227 228 229 230 231
      // 异常登记
      regDialogVisible: false,
      isShowError: false,
      inspectionTimecustoms: this.getDictDatas(
        this.DICT_TYPE.BOX_INSPECTION_TIME_CUSTOMS
      )[0].value,
huhaiqing's avatar
huhaiqing committed
232
      isDownload: false,
huhaiqing's avatar
huhaiqing committed
233
      normalOrderList: [],
huhaiqing's avatar
huhaiqing committed
234
      isShowNormal: false,
huhaiqing's avatar
huhaiqing committed
235 236
    };
  },
huhaiqing's avatar
huhaiqing committed
237
  created() {
238
    const { currNode } = this.$attrs;
huhaiqing's avatar
huhaiqing committed
239 240
    const { voName } = currNode;
    let oldData = {
241 242
      ...this.shipmentObj[voName],
      documentInfo: this.shipmentObj.documentInfo?.split(",") ?? [],
huhaiqing's avatar
huhaiqing committed
243
    };
huhaiqing's avatar
huhaiqing committed
244 245 246 247 248 249 250

    if (!this.shipmentObj[voName]) {
      oldData.dcCustomsType = oldData.dcCustomsType
        ? oldData.dcCustomsType
        : this.getDcCustomsType(oldData.documentInfo);
    }

huhaiqing's avatar
huhaiqing committed
251 252 253 254
    oldData = formatDateStr(oldData, [
      "dcCutOffTime",
      "dcCheckTime",
      "dcPassTime",
huhaiqing's avatar
huhaiqing committed
255
      "dcDecTime",
huhaiqing's avatar
huhaiqing committed
256 257 258 259 260 261
    ]);
    oldData = formatNumberString(oldData, [
      "dcCustomsType",
      "dcCustomsStatus",
      "dcCheckStatus",
    ]);
huhaiqing's avatar
huhaiqing committed
262

huhaiqing's avatar
huhaiqing committed
263
    this.cusDeclarationObj = oldData;
huhaiqing's avatar
huhaiqing committed
264 265
  },
  methods: {
huhaiqing's avatar
huhaiqing committed
266
    getCustomsOrderList(dcCustomsType) {
267
      if(!dcCustomsType) dcCustomsType = '1'
huhaiqing's avatar
huhaiqing committed
268 269
      customsOrderList({
        shipmentId: this.shipmentObj.id,
huhaiqing's avatar
huhaiqing committed
270
        customsTypes: dcCustomsType === "3" ? "2,3" : dcCustomsType,
huhaiqing's avatar
huhaiqing committed
271 272
      }).then((res) => {
        this.normalOrderList = res.data ?? [];
huhaiqing's avatar
huhaiqing committed
273 274 275 276 277
        if (dcCustomsType === "1") {
          this.isShowNormal = false;
        } else {
          this.isShowNormal = true;
        }
huhaiqing's avatar
huhaiqing committed
278 279
      });
    },
huhaiqing's avatar
huhaiqing committed
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
    regCloseDialog(type) {
      this.regDialogVisible = false;
      if (type === "error") {
        this.$emit("getBoxInfo");
      }
    },
    // 时间比较
    compareDate(dcDecTime, dcPassTime) {
      this.isShowError = false;
      let date1 = null,
        date2 = null;
      if (dcDecTime) date1 = dayjs(dcDecTime);
      if (dcPassTime) date2 = dayjs(dcPassTime);
      if (date1 && date2) {
        const delayDay = date2.diff(date1, "day");
        if (delayDay >= this.inspectionTimecustoms) this.isShowError = true;
      }
    },
    // 异常登记
    exceptionReg() {
      this.regDialogVisible = true;
    },
huhaiqing's avatar
huhaiqing committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
    /* 跳转订单详情 */
    jumpOrderDetail(row) {
      this.$router.push({
        path: "/order/detail",
        query: { orderId: row.orderId },
      });
    },
    getDcCustomsType(documentInfo = []) {
      const newList = Array.from(new Set(documentInfo));
      if (newList.length > 1) {
        return "3";
      }
      if (newList.length === 1) {
        return newList[0] === "1" ? "1" : "2";
      }
    },
huhaiqing's avatar
huhaiqing committed
318 319
    getButtonLabel(documentInfo = []) {
      const newList = Array.from(new Set(documentInfo));
huhaiqing's avatar
huhaiqing committed
320
      return newList.length >= 2 ? this.$t("混合报关") : this.$t("VGM声明");
huhaiqing's avatar
huhaiqing committed
321
    },
322 323 324 325 326 327 328 329 330 331 332
    submitCustomsCreate(operateType) {
      customsCreate({
        ...this.cusDeclarationObj,
        shipmentId: this.shipmentObj.id,
        operateType,
      }).then((res) => {
        serviceMsg(res, this).then(() => {
          this.cancel("submit");
        });
      });
    },
huhaiqing's avatar
huhaiqing committed
333
    /** 提交 */
huhaiqing's avatar
huhaiqing committed
334
    onSubmit(operateType) {
huhaiqing's avatar
huhaiqing committed
335
      this.$refs["cusDeclarationForm"].validate((valid) => {
huhaiqing's avatar
huhaiqing committed
336
        if (valid) {
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
          if (operateType === 1) {
            this.submitCustomsCreate(operateType);
            return;
            // 保存
          }
          // 提交
          const { dcCustomsStatus, dcCheckStatus } = this.cusDeclarationObj;
          // 1.状态 报关中/放行 直接提交
          if (dcCustomsStatus !== "3") {
            this.submitCustomsCreate(operateType);
            return;
          }
          // 2.查验状态,空 直接提交
          if (!dcCheckStatus) {
            this.submitCustomsCreate(operateType);
            return;
          }
          // 3.查验状态,查验后放行 直接提交
          if (dcCheckStatus === "3") {
            const { checkExamineStatus } = this.shipmentObj;
            // 没有退场审核中的状态
            if (checkExamineStatus !== 1) {
              this.submitCustomsCreate(operateType);
              return;
            }
          }
          // 4.查验状态,退场/部分退场 提示
          if (["1", "2"].includes(dcCheckStatus)) {
            const { checkExamineStatus } = this.shipmentObj;
            // 退场审核状态,1-审核中,2-审核成功,3-审核失败,4-取消
huhaiqing's avatar
huhaiqing committed
367
            if ([0, 2, 3, 4].includes(checkExamineStatus)) {
368
              this.$modal
huhaiqing's avatar
huhaiqing committed
369
                .confirm(this.$t(
370
                  `您确认提交${
Marcus's avatar
Marcus committed
371
                    dcCheckStatus === "1" ? this.$t("全部退场") : this.$t("部分退场")
huhaiqing's avatar
huhaiqing committed
372
                  }审核吗?`)
373 374 375 376 377 378 379 380
                )
                .then(() => {
                  customsCreate({
                    ...this.cusDeclarationObj,
                    shipmentId: this.shipmentObj.id,
                    operateType,
                  }).then((res) => {
                    serviceMsg(res, this).then(() => {
huhaiqing's avatar
huhaiqing committed
381 382
                      // 触发外层重新查询出货信息
                      this.$emit("getBoxInfo");
383
                    });
384
                  });
huhaiqing's avatar
huhaiqing committed
385 386 387
                });
            } else {
              this.submitCustomsCreate(operateType);
388
            }
389
          }
huhaiqing's avatar
huhaiqing committed
390 391 392
        }
      });
    },
393 394 395
    /* 查询订单号 */
    searchOrder() {
      if (!this.orderNo) {
huhaiqing's avatar
huhaiqing committed
396
        this.$message.error(this.$t("请输入订单号"));
397 398 399
        return;
      }
      extraCostOrder({
400
        shipmentId: this.shipmentObj.id,
401 402
        orderNo: this.orderNo,
      }).then((res) => {
403 404 405 406 407 408 409 410 411
        serviceMsg(res, this).then(() => {
          this.costOrderList = [
            {
              orderNo: this.orderNo,
              orderId: res.data,
            },
          ];
          this.searchCostList();
        });
412 413 414
      });
    },
    /* 查询额外费用订单 */
415
    searchCostList() {
416
      extraCostList({
417
        shipmentId: this.shipmentObj.id,
418
      }).then((res) => {
419
        this.costList = res.data;
420 421 422 423 424
      });
    },
    /* 创建额外费用 */
    createExtraCost(row) {
      if (!row.fee) {
huhaiqing's avatar
huhaiqing committed
425
        this.$message.error(this.$t("请输入费用"));
426 427 428 429 430 431
        return;
      }
      extraCostCreate({
        fee: row.fee,
        orderId: row.orderId,
        orderNo: row.orderNo,
432
        shipmentId: this.shipmentObj.id,
433 434
      }).then((res) => {
        serviceMsg(res, this).then(() => {
435
          this.searchCostList();
436 437 438 439 440 441
        });
      });
    },
    /* 修改额外费用 */
    updateExtraCost(row) {
      if (!row.fee) {
huhaiqing's avatar
huhaiqing committed
442
        this.$message.error(this.$t("请输入费用"));
443 444 445 446
        return;
      }
      extraCostUpdate(row).then((res) => {
        serviceMsg(res, this).then(() => {
447
          this.searchCostList();
448 449 450 451 452
        });
      });
    },
    /* 重置 */
    restCostList(row) {
453 454 455 456 457 458 459 460 461 462 463 464 465
      if (row) {
        resetById({ id: row.id }).then((res) => {
          serviceMsg(res, this).then(() => {
            this.searchCostList();
          });
        });
      } else {
        resetByShipmentId({ id: this.shipmentObj.id }).then((res) => {
          serviceMsg(res, this).then(() => {
            this.searchCostList();
          });
        });
      }
466
    },
huhaiqing's avatar
huhaiqing committed
467
    /** 取消 */
huhaiqing's avatar
huhaiqing committed
468 469
    cancel(type) {
      this.$emit("closeDialog", type);
huhaiqing's avatar
huhaiqing committed
470 471 472 473 474 475 476 477 478
    },
    // 下载VGM
    downloadVGM() {
      window.open(
        "http://pdatest.groupage.cn//apivue/boxTrack/vgmExport?token=930b11a41d9ca06f306d157f336a5dcb&id=1752"
      );
    },
    // 额外费用
    extraCost() {
479 480 481 482
      // 清空额外费用
      this.orderNo = "";
      this.costOrderList = [];
      this.costList = [];
483 484 485
      this.$set(
        this.dialogConfig,
        "title",
486
        `${this.shipmentObj.selfNo} ` + this.$t("报关费用")
487
      );
huhaiqing's avatar
huhaiqing committed
488
      this.$set(this.dialogConfig, "dialogVisible", true);
489
      this.searchCostList();
huhaiqing's avatar
huhaiqing committed
490
    },
huhaiqing's avatar
huhaiqing committed
491 492 493 494 495 496 497 498 499 500 501 502 503
    // 计算VGM重量
    calcVGM(dcBoxWgt, dcGoodsWgt) {
      let dcBoxWgtTmp = 0,
        dcGoodsWgtTmp = 0;
      if (!Number.isNaN(Number(dcBoxWgt))) {
        dcBoxWgtTmp = Number(dcBoxWgt);
      }
      if (!Number.isNaN(Number(dcGoodsWgt))) {
        dcGoodsWgtTmp = Number(dcGoodsWgt);
      }
      this.$set(
        this.cusDeclarationObj,
        "dcVgmWgt",
504
        Decimal.add(dcBoxWgtTmp, dcGoodsWgtTmp).toFixed(2)
huhaiqing's avatar
huhaiqing committed
505 506
      );
    },
507 508 509 510 511 512 513 514 515
    // 审核详情
    jumpReviewDetail() {
      const { customsApprovalInfo } = this.shipmentObj;
      toReviewDetail.apply(this, [customsApprovalInfo.bpmProcessId]);
      this.cancel("close");
    },
    /* 取消审核 */
    canclAudit() {
      approvalCancel({
516
        applyReason: this.$t("取消审核"),
huhaiqing's avatar
huhaiqing committed
517 518
        id: this.shipmentObj["customsApprovalInfo"].id,
        shipmentId: this.shipmentObj.id,
519 520 521
      }).then((res) => {
        serviceMsg(res, this).then(() => {
          // 触发外层重新查询出货信息
huhaiqing's avatar
huhaiqing committed
522
          this.cancel("close");
523 524 525 526
          this.$emit("getBoxInfo");
        });
      });
    },
huhaiqing's avatar
huhaiqing committed
527 528
    /* 判断查验选择是否禁用 */
    disabledRadio(item) {
huhaiqing's avatar
huhaiqing committed
529 530 531
      const { checkExamineStatus, checkDealStatus, customsInfo } =
        this.shipmentObj;
      const { dcCheckStatus } = customsInfo ?? {}; // 部分退场状态并且审核通过,退场不可选择
huhaiqing's avatar
huhaiqing committed
532 533 534
      if (
        checkExamineStatus === 2 &&
        dcCheckStatus === 2 &&
535
        checkDealStatus === 0 &&
huhaiqing's avatar
huhaiqing committed
536 537 538 539 540 541
        item.value === "1"
      ) {
        return true;
      }
      return false;
    },
huhaiqing's avatar
huhaiqing committed
542 543
    /* 下载报关单 */
    downloadCusFile() {
544 545 546
      downloadFileByUrl("downloadCustomFiles", {
        shipmentId: this.shipmentObj.id,
      });
huhaiqing's avatar
huhaiqing committed
547
    },
huhaiqing's avatar
huhaiqing committed
548 549
  },
  watch: {
huhaiqing's avatar
huhaiqing committed
550
    "cusDeclarationObj.dcCustomsType"(val) {
551
      console.log(val,'val')
huhaiqing's avatar
huhaiqing committed
552 553
      this.getCustomsOrderList(val);
    },
huhaiqing's avatar
huhaiqing committed
554 555 556 557 558 559
    "cusDeclarationObj.documentInfo"(val) {
      this.isDownload = false;
      if (val.includes("2")) {
        this.isDownload = true;
      }
    },
huhaiqing's avatar
huhaiqing committed
560 561 562 563 564 565 566 567 568
    "cusDeclarationObj.dcBoxWgt"(dcBoxWgt) {
      this.calcVGM(dcBoxWgt, this.cusDeclarationObj.dcGoodsWgt);
    },
    "cusDeclarationObj.dcGoodsWgt"(dcGoodsWgt) {
      this.calcVGM(this.cusDeclarationObj.dcBoxWgt, dcGoodsWgt);
    },
    "cusDeclarationObj.dcCustomsStatus"(val) {
      if (val !== "3") {
        this.$set(this.cusDeclarationObj, "dcCheckStatus", "");
huhaiqing's avatar
huhaiqing committed
569
        // this.$set(this.cusDeclarationObj, "dcPassTime", "");
huhaiqing's avatar
huhaiqing committed
570
      } else {
huhaiqing's avatar
huhaiqing committed
571
        const { customsInfo } = this.shipmentObj;
huhaiqing's avatar
huhaiqing committed
572 573 574
        this.$set(
          this.cusDeclarationObj,
          "dcCheckStatus",
huhaiqing's avatar
huhaiqing committed
575
          (customsInfo?.dcCheckStatus && String(customsInfo?.dcCheckStatus)) ||
huhaiqing's avatar
huhaiqing committed
576 577
            "3"
        );
huhaiqing's avatar
huhaiqing committed
578 579
      }
    },
580 581 582 583 584 585 586 587 588 589 590 591
    shipmentObj: {
      deep: true,
      immediate: true,
      handler: function (val) {
        // 监听查验状态变化
        let { checkExamineStatus } = val;
        if (checkExamineStatus === 1) {
          // 按钮变成审核中
          this.inReview = true;
        }
      },
    },
huhaiqing's avatar
huhaiqing committed
592 593 594 595 596 597 598 599 600 601
    // 报关时间
    "cusDeclarationObj.dcDecTime"(val) {
      this.compareDate(val, this.cusDeclarationObj.dcPassTime);
    },
    // 放行时间
    "cusDeclarationObj.dcPassTime"(val) {
      this.compareDate(this.cusDeclarationObj.dcDecTime, val);
    },
    // 查验状态
    "cusDeclarationObj.dcCheckStatus"(val) {
huhaiqing's avatar
huhaiqing committed
602 603
      const { customsInfo } = this.shipmentObj;
      if (val != customsInfo?.dcCheckStatus) {
huhaiqing's avatar
huhaiqing committed
604 605 606
        this.$set(this.cusDeclarationObj, "dcPassTime", "");
      }
    },
huhaiqing's avatar
huhaiqing committed
607
  },
huhaiqing's avatar
huhaiqing committed
608 609 610
  computed: {
    /* 获取报关审核退场状态文字 */
    getCheckExamineStatus() {
huhaiqing's avatar
huhaiqing committed
611 612
      const { checkExamineStatus, checkDealStatus, customsInfo } =
        this.shipmentObj;
huhaiqing's avatar
huhaiqing committed
613
      const { dcCheckStatus } = customsInfo ?? {};
huhaiqing's avatar
huhaiqing committed
614
      if (checkExamineStatus === 1) {
615 616 617
        return dcCheckStatus === 1
          ? this.$t("退场审核中")
          : this.$t("部分退场审核中");
huhaiqing's avatar
huhaiqing committed
618
      }
619
      if (checkExamineStatus === 2 && checkDealStatus === 0) {
huhaiqing's avatar
huhaiqing committed
620
        return dcCheckStatus === 1
621 622
          ? this.$t("审核通过,退场中")
          : this.$t("审核通过,部分退场中");
huhaiqing's avatar
huhaiqing committed
623
      }
huhaiqing's avatar
huhaiqing committed
624
      return this.$t("未审核");
huhaiqing's avatar
huhaiqing committed
625 626 627
    },
    /* 判断是否已处理 */
    isCheckDeal() {
628
      return (type) => {
huhaiqing's avatar
huhaiqing committed
629 630
        const { checkExamineStatus, checkDealStatus, customsInfo } =
          this.shipmentObj;
huhaiqing's avatar
huhaiqing committed
631
        const { dcCheckStatus } = customsInfo ?? {};
632 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 668 669 670 671 672 673 674 675

        // 状态
        if (type === "status") {
          // 退场/部分退场 审核通过未处理,禁用
          if (
            checkExamineStatus === 2 &&
            [1, 2].includes(dcCheckStatus) &&
            checkDealStatus === 0
          ) {
            return true;
          }
        }

        // 查验
        if (type === "check") {
          // 退场 审核通过未处理,禁用
          // 部分退场 审核通过未处理,由 disabledRadio 方法判断
          if (
            checkExamineStatus === 2 &&
            [1].includes(dcCheckStatus) &&
            checkDealStatus === 0
          ) {
            return true;
          }
        }

        // 提交/保存
        if (type === "submit") {
          const { dcCheckStatus: newCheckStatus } = this.cusDeclarationObj;
          // 退场/部分退场 审核通过未处理
          if (checkExamineStatus === 2 && checkDealStatus === 0) {
            // 退场,禁用
            if (dcCheckStatus === 1) return true;
            // 部分退场
            if (dcCheckStatus === 2) {
              // 修改为查验后放行,可用,其他禁用
              if (newCheckStatus === "3") return false;
              return true;
            }
          }
        }

        return false;
      };
huhaiqing's avatar
huhaiqing committed
676 677
    },
  },
huhaiqing's avatar
huhaiqing committed
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
};
</script>

<style lang="scss">
.customsClearance {
  .cost-title {
    display: flex;
    align-items: center;
    margin: 20px 0;
    border-left: 5px solid gray;
    > div:first-child {
      margin-left: 10px;
    }
    > div:last-child {
      flex: 1;
      text-align: right;
    }
  }
696 697 698 699 700
  .el-table.table-inputNumber {
    .cell {
      overflow: visible;
    }
  }
huhaiqing's avatar
huhaiqing committed
701 702
}
</style>