index.vue 8.01 KB
Newer Older
huhaiqing's avatar
huhaiqing committed
1 2 3
<template>
  <el-row class="shipping-ladingBill">
    <el-row class="oper-button">
huhaiqing's avatar
huhaiqing committed
4
      <el-button type="primary" @click="clickZipDownload">打包下载</el-button>
huhaiqing's avatar
huhaiqing committed
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
      <el-button type="primary">应收汇总单</el-button>
      <el-button type="primary">下载已装单</el-button>
    </el-row>

    <el-row style="margin-top:15px">
      <el-table :data="billData.list" border max-height="500px">
        <el-table-column label="序号" type="index" align="center" width="50" />
        <el-table-column label="订单号" align="center" prop="orderNo" />
        <el-table-column label="货物信息" 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>品名:{{item.prodTitleZh}}</p>
                <p>品牌:【
                  <dict-tag :type="DICT_TYPE.PRODUCT_RECORD_ATTRIBUTE" :value="item.productRecord" />

                </p>
                <p>其他:{{getTotlContent(item)}}</p>
              </div>
            </section>
          </template>
        </el-table-column>
        <el-table-column label="控货" align="center" prop="">
          <template slot-scope="scope">
            {{scope.row.isCargoControl}}
          </template>
        </el-table-column>
        <el-table-column label="计划箱数" align="center" prop="loadNum">
          <template slot-scope="scope">
            {{ scope.row.loadNum }}
          </template>
        </el-table-column>
        <el-table-column label="实装箱数" align="center" prop="num">
          <template slot-scope="scope">
            {{ scope.row.num }}
          </template>
        </el-table-column>
        <el-table-column label="提货点" align="center" prop="destWarehouse" />
        <el-table-column label="体积" align="center" prop="loadVolume">
          <template slot-scope="scope">
            {{ scope.row.loadVolume }}
          </template>
        </el-table-column>
        <el-table-column label="重量" align="center" prop="loadWeight">
          <template slot-scope="scope">
            {{ scope.row.loadWeight }}kg
          </template>
        </el-table-column>
        <el-table-column label="跟进客服" align="center" prop="" />
        <el-table-column label="制作" 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)">提单制作</el-button>
            <el-button v-if="scope.row.status === 1" type="text" size="small" @click="handleCommand('queryBill',scope.row)">审核中</el-button>
            <template v-if="scope.row.status === 2">
              <el-button type="text" size="small" @click="handleCommand('previewBill',scope.row)" style="color:green">已审核通过</el-button>
              <el-button type="text" size="small" @click="handleCommand('queryBill',scope.row)">重新制作</el-button>
              <el-button type="text" size="small" @click="handleCommand('resetBill',scope.row)" style="color:#333333">重置</el-button>
            </template>
            <template v-if="scope.row.status === 3">
              审核拒绝
            </template>
          </template>
        </el-table-column>
      </el-table>
    </el-row>

    <el-row>
      <el-col class="totle-info">
        <div>总计:{{getSumData}}</div>
        <div>容量:{{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">
      <makeLadingBill v-if="['makeBill','queryBill','resetBill'].includes(dialogCfg.type)" :currData="currData" :currRow="currRow" :dialogCfg="dialogCfg" @closeDialog="closeDialog" />
      <previewBill v-if="dialogCfg.type === 'previewBill'" :contentHtml="currData.billContent" :currRow="currRow" :type="dialogCfg.type" />
    </el-dialog>
  </el-row>
</template>

<script>
import {
  getMakeBillList,
  makeBillService,
  getBillService,
  deleteBillService,
huhaiqing's avatar
huhaiqing committed
92
  zipDownload,
huhaiqing's avatar
huhaiqing committed
93
} from "@/api/ecw/box";
huhaiqing's avatar
huhaiqing committed
94
import { getTotlContent, getCapacity } from "../shippingSea/utils";
huhaiqing's avatar
huhaiqing committed
95 96
import makeLadingBill from "./makeLadingBill.vue";
import previewBill from "./previewBill.vue";
huhaiqing's avatar
huhaiqing committed
97
import FileSaver from "file-saver";
huhaiqing's avatar
huhaiqing committed
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 126 127 128 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

export default {
  name: "ladingBill",
  components: { makeLadingBill, previewBill },
  props: {
    shipmentObj: Object,
    getCabinetName: Function,
  },
  data() {
    return {
      billData: {
        list: [],
      },
      // 提货单数据
      currData: {},
      // 当前行
      currRow: {},
      // 弹出类型
      dialogCfg: {
        title: "",
        type: "",
        width: "80%",
        // 是否显示弹出层
        visible: false,
        fullscreen: false,
      },
      // 模板内容
      billContent: "",
    };
  },
  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}`;
      this.$set(this.dialogCfg, "title", title);
    },
    closeDialog(type) {
      this.$set(this.dialogCfg, "visible", false);
      if (type === "query") {
        this.getBillList();
      }
    },
    handleCommand(type, row) {
      switch (type) {
        case "previewBill":
          this.getBill(row);
          break;
        case "makeBill":
          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;
      }
      this.currRow = row;
      this.$set(this.dialogCfg, "type", type);
      this.$set(this.dialogCfg, "visible", true);
    },
    makeBill(row) {
      makeBillService({ orderId: row.orderId }).then((res) => {
        const { data } = res;
        const { titleZh = "", contentZh = "" } = data?.ladingTemplate ?? {};
        let billContent = `${titleZh}${contentZh}`,
          orderNo = data.orderInfo?.orderNo ?? "";
        this.currData = {
          billContent,
          orderNo,
        };
      });
    },
    getBill(row) {
      getBillService({ id: row.id }).then((res) => {
        const { data } = res;
        this.currData = {
          billContent: data?.billContent ?? "",
          orderNo: this.currRow.orderNo,
        };
      });
    },
huhaiqing's avatar
huhaiqing committed
198 199
    clickZipDownload() {
      zipDownload({ shipmentId: this.shipmentObj.id }).then((res) => {
huhaiqing's avatar
huhaiqing committed
200 201
        let blob = new Blob([res], { type: "application/zip" });
        FileSaver.saveAs(blob, "打包文件.zip");
huhaiqing's avatar
huhaiqing committed
202 203
      });
    },
huhaiqing's avatar
huhaiqing committed
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
  },
  computed: {
    /* 总计 */
    getSumData() {
      return `${this.billData.totalNum ?? 0} ${
        this.billData.totalVolume ?? 0
      }m³ ${this.billData.totalVolume ?? 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>