index.vue 11.5 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
<template>
  <el-row class="shipping-ladingBill">
    <el-row class="oper-button">
      <el-button type="primary" @click="clickZipDownload">{{$t('打包下载')}}</el-button>
      <el-button type="primary" @click="handleCommand('downloadReceivableList')">{{$t('应收汇总表')}}</el-button>
      <el-button v-if="type=='sea'" type="primary" @click="handleCommand('downloadLoadGoodsList')">{{$t('下载已装单')}}</el-button>
    </el-row>

    <el-row style="margin-top:15px">
      <el-table :data="billData.list" border max-height="500px">
        <el-table-column :label="$t('序号')" align="center" width="50" prop="tidanNo" />
        <el-table-column :label="$t('订单号')" align="center" prop="orderNo">
          <template slot-scope="scope">
            <div>
              {{scope.row.orderNo}}
            </div>
            <div style="color:blue;fontWeight:bold;">
              {{ scope.row.drawee? scope.row.drawee:''}}
            </div>
            <div style="color:red;fontWeight:bold;">
              {{ scope.row.applicationInfo? scope.row.applicationInfo : ''}}
            </div>
            <div style="color:red;fontWeight:bold;">
              {{ scope.row.customsTypeName? scope.row.customsTypeName : ''}}
            </div>
          </template>
        </el-table-column>
        <el-table-column :label="$t('货物信息')" align="center" prop="">
          <template slot-scope="scope">
            <section class="table-goodList">
              <div v-for="(item, index) in scope.row.orderItemList" :key="index" class="goodList-div">
                <p>{{$t('品名')}}{{$l(item, 'prodTitle')}}</p>
                <p>{{$t('品牌')}}:【<template v-if="item.brandName">{{item.brandName}}</template>
                  <dict-tag v-else :type="DICT_TYPE.ECW_IS_BRAND" :value="item.feeType" />{{ $t('】') }}
                </p>
                <p>{{$t('其他')}}:{{getTotlContent(item)}}</p>
              </div>
            </section>
          </template>
        </el-table-column>
        <el-table-column :label="$t('控货')" align="center" prop="">
          <template slot-scope="scope">
            {{scope.row.isCargoControl ? $t('') : $t('') }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('计划箱数')" align="center" prop="num">
          <template slot-scope="scope">
            {{ scope.row.num }}{{$t('')}}
          </template>
        </el-table-column>
        <el-table-column :label="$t('实装箱数')" align="center" prop="loadNum">
          <template slot-scope="scope">
            {{ scope.row.loadNum }}{{$t('')}}
          </template>
        </el-table-column>
        <el-table-column :label="$t('提货点')" align="center" prop="destWarehouse" />
        <el-table-column :label="$t('体积')" align="center" prop="loadVolume">
          <template slot-scope="scope">
            {{ scope.row.loadVolume }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('重量')" align="center" prop="loadWeight">
          <template slot-scope="scope">
            {{ scope.row.loadWeight }}kg
          </template>
        </el-table-column>
        <el-table-column :label="$t('订单状态')" align="left" prop="orderStatusString" />
        <el-table-column :label="$t('首次入仓时间')" align="left" prop="rucangTime">
          <template slot-scope="scope">
            {{ scope.row.rucangTime }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('客户经理')" align="center" prop="salesmanId" />

        <el-table-column :label="$t('制作')" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <!-- 0 (未制作提货单)  1(审核中) 2(审核通过) 3(审核拒绝) -->
            <el-button v-if="scope.row.status === 0" type="text" size="small" @click="handleCommand('makeBill',scope.row)">{{$t('提单制作')}}</el-button>
            <el-button v-if="scope.row.status === 1" type="text" size="small" @click="handleCommand('queryBill',scope.row)">{{$t('审核中')}}</el-button>
            <template v-if="scope.row.status === 2">
              <el-button type="text" size="small" @click="handleCommand('previewBill',scope.row)" style="color:green">{{$t('已审核通过')}}</el-button>
              <el-button type="text" size="small" @click="handleCommand('queryBill',scope.row)">{{$t('重新制作')}}</el-button>
              <el-button type="text" size="small" @click="handleCommand('resetBill',scope.row)" style="color:#333333">{{$t('重置')}}</el-button>
            </template>
            <template v-if="scope.row.status === 3">
              {{$t('审核拒绝')}}
              <el-button type="text" size="small" @click="handleCommand('queryBill',scope.row)">{{$t('重新制作')}}</el-button>
              <el-button type="text" size="small" @click="handleCommand('resetBill',scope.row)" style="color:#333333">{{$t('重置')}}</el-button>
            </template>
          </template>
        </el-table-column>
      </el-table>
    </el-row>

    <el-row>
      <el-col class="totle-info">
        <div>{{$t('总计')}}:{{getSumData}}</div>
        <!--<div>{{$t('容量')}}:{{calcCapacity}}</div>-->
      </el-col>
    </el-row>

    <el-dialog :title="dialogCfg.title" :visible.sync="dialogCfg.visible" :width="dialogCfg.width" :fullscreen="dialogCfg.fullscreen" append-to-body class="shippingSea-dialog" @closed="dialogclosed">
      <makeLadingBill v-if="dialogCfg.visible && ['makeBill','queryBill','resetBill'].includes(dialogCfg.type)" :currData="currData" :currRow="currRow" :dialogCfg="dialogCfg" @closeDialog="closeDialog" :selfNo="shipmentObj.selfNo" />
      <previewBill v-if="dialogCfg.type === 'previewBill'" :contentHtml="currData.billContent" :currRow="currRow" :type="dialogCfg.type" :air="type === 'air'" />
    </el-dialog>
  </el-row>
</template>

<script>
import {
    getMakeBillList,
    makeBillService,
    getBillService,
    deleteBillService,
    zipDownload,
    downloadReceivableList,
    makeAirBillService,
    downloadAirReceivableList,
    downloadLoadGoodsList,
} from "@/api/ecw/box";
import {
  getTotlContent,
  getCapacity,
  downloadFile,
} from "../shippingSea/utils";
lanbaoming's avatar
lanbaoming committed
126
//制作提单 lanbm 2024-05-24 添加注释
lanbaoming's avatar
lanbaoming committed
127
import makeLadingBill from "./makeLadingBill.vue";
lanbaoming's avatar
lanbaoming committed
128
//预览提单 
lanbaoming's avatar
lanbaoming committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
import previewBill from "./previewBill.vue";

export default {
  name: "ladingBill",
  components: { makeLadingBill, previewBill },
  props: {
    shipmentObj: Object,
    getCabinetName: Function,
    type: {
      type: String,
      default: 'sea'
    }
  },
  data() {
    return {
      billData: {
        list: [],
      },
      // 提货单数据
      currData: {},
      // 当前行
      currRow: {},
      // 弹出类型
      dialogCfg: {
        title: "",
        type: "",
        width: "100px",
        // 是否显示弹出层
        visible: false,
        fullscreen: false,
      },
      // 模板内容
      billContent: "",
      handleType: "",
    };
  },
  created() {
    this.getBillList();
    this.buildTitle();
  },
  methods: {
    getTotlContent,
    getBillList() {
      getMakeBillList({ shipmentId: this.shipmentObj.id }).then((res) => {
        this.billData = res.data;
      });
    },
    buildTitle() {
      const cabinetLabel = this.getCabinetName(this.shipmentObj.cabinetId);
      /* const title = `查看提单 ${this.shipmentObj.selfNo ?? ""} 柜号:${
        this.shipmentObj.cubNo ?? ""
      } 柜型:${cabinetLabel}`; */
      const title = this.$t(
        "查看提单 {selfNo}",
        {
          selfNo: this.shipmentObj.selfNo,
          cubNo: this.shipmentObj.cubNo,
          cabinetLabel,
        }
      );
      this.$set(this.dialogCfg, "title", title);
    },
    closeDialog(type) {
      this.$set(this.dialogCfg, "visible", false);
      if (type === "query") {
        this.getBillList();
      }
      if (type === "close") {
        this.$emit("closeDialog");
      }
    },
    dialogclosed() {
      if (this.handleType === "resetBill") {
        this.getBillList();
      }
    },
    async handleCommand(type, row) {
      this.handleType = type;
      switch (type) {
        case "previewBill":
          this.getBill(row);
          break;
        case "makeBill":
          await this.makeBill(row);
          break;
        case "queryBill":
          this.getBill(row);
          break;
        case "resetBill":
          // 先删除,在创建
          deleteBillService(row.id).then((res) => {
            const { code } = res;
            if (code === 0) {
              this.makeBill(row);
            }
          });
          break;
        case "downloadLoadGoodsList":
          downloadLoadGoodsList({ shipmentId: this.shipmentObj.id }).then(res => {
            this.$message.success(this.$t('已加入导出队列,请稍后在下载日志中下载'))
          })
          /*downloadFile(
            type,
            { shipmentId: this.shipmentObj.id },
            this.$t("已装单") + `(${this.shipmentObj.selfNo}).xlsx`,
            "xlsx"
          );*/
          return;
        case "downloadReceivableList":
          const api = this.type == 'air' ? downloadAirReceivableList : downloadReceivableList;
          api({ shipmentId: this.shipmentObj.id }).then(res => {
            this.$message.success(this.$t('已加入导出队列,请稍后在下载日志中下载'))
          })
          return;
      }
      this.currRow = row;
      this.$set(this.dialogCfg, "type", type);
      this.$set(this.dialogCfg, "width", "1200px");
      this.$set(this.dialogCfg, "visible", true);
    },
    async makeBill(row) {
      let api = this.type != 'air' ? makeBillService : makeAirBillService;
      let loading = this.$loading()
      await api({
        orderId: row.orderId,
        shipmentId: this.shipmentObj.id,
      }).then((res) => {
        const { data } = res;
        const { titleZh = "", contentZh = "" } = data?.ladingTemplate ?? {};
        let billContent = `${titleZh}${data.orderInfo}${contentZh}`;
        this.currData = {
          billContent,
          orderNo: row.orderNo,
        };
      }).catch(() => {
        throw new Error('制作提单失败')
      }).finally(() => {
        loading.close()
      });
    },
    getBill(row) {
      getBillService({ id: row.id }).then((res) => {
        const { data } = res;
        this.currData = {
          billContent: data?.billContent ?? "",
          orderNo: this.currRow.orderNo,
          bpmProcessId: data.bpmProcessId,
        };
      });
    },
    clickZipDownload() {
      zipDownload({ shipmentId: this.shipmentObj.id }).then(res => {
        this.$message.success(this.$t('已加入导出队列,请稍后在下载日志中下载'))
      })
    },
  },
  computed: {
    /* 总计 */
    getSumData() {
      return `${this.billData.totalNum ?? 0}${this.$t("")} ${
        this.billData.totalVolume ?? 0
      }m³ ${this.billData.totalWeight ?? 0}kg`;
    },
    /* 容量 */
    calcCapacity() {
      const { cabinet } = this.billData;
      return getCapacity(cabinet);
    },
  },
};
</script>

<style lang="scss" scoped>
.shipping-ladingBill {
  .oper-button {
    text-align: right;
  }
  .table-goodList {
    p {
      margin: 0;
    }
    .goodList-div {
      border-bottom: 1px solid #e6ebf5;
      > p {
        text-align: left;
      }
      > p:last-child {
        > span {
          margin-right: 5px;
        }
      }
    }
    > div:last-child {
      border-bottom: none;
    }
  }
  .totle-info {
    font-size: 20px;
    margin-top: 15px;
  }
}
</style>