makeLadingBill.vue 9.05 KB
Newer Older
huhaiqing's avatar
huhaiqing committed
1 2 3
<template>
  <el-row class="shipping-makeLadingBill">
    <el-row>
4
      <div class="title-orderNo">{{$t('订单号')}}{{orderNo}}</div>
huhaiqing's avatar
huhaiqing committed
5
    </el-row>
huhaiqing's avatar
huhaiqing committed
6
    <el-row class="ueditor-row">
dragondean@qq.com's avatar
dragondean@qq.com committed
7
      <vue-ueditor-wrap v-model="billContent" :config="editorConfig" editor-id="billUeditor"  />
huhaiqing's avatar
huhaiqing committed
8
    </el-row>
huhaiqing's avatar
huhaiqing committed
9 10 11 12

    <!-- 审核流程 -->
    <el-row class="process-area">
      <div class="process">
13
        <div>{{$t('审批流程')}}</div>
huhaiqing's avatar
huhaiqing committed
14 15 16
        <work-flow xmlkey="bill_lading" v-model="selectedUsers"></work-flow>
      </div>
      <div v-if="currRow.status === 1">
17
        <el-button type="primary" @click="jumpReviewDetail">{{$t('审核中')}}</el-button>
18 19
        <el-button plain type="primary" @click="canclAudit">{{$t('取消审核')}}</el-button>
        <el-button plain type="primary" @click="showLoaingTemplate">{{$t('提单预览')}}</el-button>
huhaiqing's avatar
huhaiqing committed
20 21
      </div>
      <div v-if="currRow.status !== 1">
22
        <el-button type="primary" @click="createPdf">{{$t('提交审核')}}</el-button>
23
        <el-button type="primary" @click="showLoaingTemplate">{{$t('提单预览')}}</el-button>
huhaiqing's avatar
huhaiqing committed
24 25 26
      </div>
    </el-row>

27 28 29 30 31
    <!-- htm2canvas 容器 -->
    <div style="height:0; overflow: hidden;">
      <div id="html2canvas-container" v-html="billContent"></div>
    </div>

32
    <el-dialog :title="dialogCfg.title" :visible.sync="visible" width="1000px" append-to-body class="shippingSea-dialog">
huhaiqing's avatar
huhaiqing committed
33 34 35 36 37 38 39 40 41 42 43 44 45
      <previewBill v-if="visible" :contentHtml="billContent" :currRow="currRow" :type="dialogCfg.type" />
    </el-dialog>
  </el-row>
</template>

<script>
import VueUeditorWrap from "vue-ueditor-wrap";
import WorkFlow from "@/components/WorkFlow";
import {
  createBillService,
  updateBillService,
  cancelBillService,
} from "@/api/ecw/box";
46
import { serviceMsg, toReviewDetail } from "../shippingSea/utils";
huhaiqing's avatar
huhaiqing committed
47 48
import previewBill from "./previewBill.vue";
import { getToken } from "@/utils/auth";
49 50 51
import html2canvas from 'html2canvas';
import { jsPDF } from "jspdf";
import {uploadFile} from '@/api/infra/file'
huhaiqing's avatar
huhaiqing committed
52 53 54 55 56 57 58 59 60 61 62
export default {
  name: "makeLadingBill",
  components: {
    VueUeditorWrap,
    WorkFlow,
    previewBill,
  },
  props: {
    currData: Object,
    currRow: Object,
    dialogCfg: Object,
63
    selfNo: String
huhaiqing's avatar
huhaiqing committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
  },
  data() {
    return {
      orderNo: "",
      billContent: "",
      editorConfig: {
        UEDITOR_HOME_URL: "/static/plugins/ueditor/",
        autoHeightEnabled: false,
        initialFrameHeight: 500,
        initialFrameWidth: "100%",
        zIndex: 9999,
        toolbars: [
          [
            "anchor", //锚点
            "undo", //撤销
            "redo", //重做
            "bold", //加粗
            "indent", //首行缩进
dragondean@qq.com's avatar
dragondean@qq.com committed
82
            //"snapscreen", //截图
huhaiqing's avatar
huhaiqing committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96
            "italic", //斜体
            "underline", //下划线
            "strikethrough", //删除线
            "subscript", //下标
            "fontborder", //字符边框
            "superscript", //上标
            "formatmatch", //格式刷
            "source", //源代码
            "blockquote", //引用
            "pasteplain", //纯文本粘贴模式
            "selectall", //全选
            "preview", //预览
            "horizontal", //分隔线
            "removeformat", //清除格式
dragondean@qq.com's avatar
dragondean@qq.com committed
97 98 99
            //"time", //时间
            //"date", //日期
            //"unlink", //取消链接
huhaiqing's avatar
huhaiqing committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113
            "insertrow", //前插入行
            "insertcol", //前插入列
            "mergeright", //右合并单元格
            "mergedown", //下合并单元格
            "deleterow", //删除行
            "deletecol", //删除列
            "splittorows", //拆分成行
            "splittocols", //拆分成列
            "splittocells", //完全拆分单元格
            "deletecaption", //删除表格标题
            "inserttitle", //插入标题
            "mergecells", //合并多个单元格
            "deletetable", //删除表格
            "cleardoc", //清空文档
Marcus's avatar
Marcus committed
114
            "insertparagraphbeforetable", //this.$t("表格前插入行")
dragondean@qq.com's avatar
dragondean@qq.com committed
115
            //"insertcode", //代码语言
huhaiqing's avatar
huhaiqing committed
116 117 118 119 120 121 122
            "fontfamily", //字体
            "fontsize", //字号
            "paragraph", //段落格式
            "simpleupload", //单图上传
            "insertimage", //多图上传
            "edittable", //表格属性
            "edittd", //单元格属性
dragondean@qq.com's avatar
dragondean@qq.com committed
123 124
            //"link", //超链接
            //"emotion", //表情
huhaiqing's avatar
huhaiqing committed
125
            "spechars", //特殊字符
dragondean@qq.com's avatar
dragondean@qq.com committed
126 127
            //"searchreplace", //查询替换
            //"insertvideo", //视频
huhaiqing's avatar
huhaiqing committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141
            "justifyleft", //居左对齐
            "justifyright", //居右对齐
            "justifycenter", //居中对齐
            "justifyjustify", //两端对齐
            "forecolor", //字体颜色
            "backcolor", //背景色
            "insertorderedlist", //有序列表
            "insertunorderedlist", //无序列表
            "fullscreen", //全屏
            "directionalityltr", //从左向右输入
            "directionalityrtl", //从右向左输入
            "rowspacingtop", //段前距
            "rowspacingbottom", //段后距
            "pagebreak", //分页
dragondean@qq.com's avatar
dragondean@qq.com committed
142
            //"insertframe", //插入Iframe
huhaiqing's avatar
huhaiqing committed
143 144 145
            "imagenone", //默认
            "imageleft", //左浮动
            "imageright", //右浮动
dragondean@qq.com's avatar
dragondean@qq.com committed
146
            //"attachment", //附件
huhaiqing's avatar
huhaiqing committed
147 148 149
            "imagecenter", //居中
            "wordimage", //图片转存
            "lineheight", //行间距
dragondean@qq.com's avatar
dragondean@qq.com committed
150
            //"edittip ", //编辑提示
huhaiqing's avatar
huhaiqing committed
151 152
            "customstyle", //自定义标题
            "autotypeset", //自动排版
dragondean@qq.com's avatar
dragondean@qq.com committed
153 154
            //"touppercase", //字母大写
            //"tolowercase", //字母小写
huhaiqing's avatar
huhaiqing committed
155
            "background", //背景
dragondean@qq.com's avatar
dragondean@qq.com committed
156 157
            //"scrawl", //涂鸦
            //"music", //音乐
huhaiqing's avatar
huhaiqing committed
158 159
            "inserttable", //插入表格
            "drafts", // 从草稿箱加载
dragondean@qq.com's avatar
dragondean@qq.com committed
160
            //"charts", // 图表
huhaiqing's avatar
huhaiqing committed
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
          ],
        ],
        serverUrl:
          process.env.VUE_APP_BASE_API +
          "/admin-api/infra/file/editor?api_token=" +
          getToken().replace("Bearer ", ""),
      },
      visible: false,
      selectedUsers: [],
    };
  },
  methods: {
    showLoaingTemplate() {
      this.visible = true;
    },
176 177
    createPdf(){
      let loading = this.$loading()
178
      html2canvas(document.querySelector("#html2canvas-container"), {dpi:144, useCORS: true}).then(canvas => {
179 180 181 182 183 184 185 186 187 188 189 190
        const doc = new jsPDF('p','pt','a4',true);

        const imgWidth = canvas.width
        const imgHeight = canvas.height
        let _w = 595.28;
		    let _h = 595.28/imgWidth*imgHeight;
        if(_h>841.89){
          _h = 841.89;
          _w = _h/imgHeight*imgWidth
        }
        const _left = (595.28-_w)/2;
        doc.addImage(canvas, 'PNG', _left, 0, _w,_h, '', 'FAST');
191 192
        /* doc.save("a4.pdf");
        return Promise.reject() */
193
        let form = new FormData()
194 195 196
        let file = this.selfNo + '-' + this.currRow.tidanNo + '.pdf'
        form.append('file', new File([doc.output('arraybuffer')], file, {type: 'application/pdf'}))
        form.append('path', file)
197 198 199 200 201 202 203 204
        return uploadFile(form)
      }).then(res => {
        return this.submit(res.data)
      }).finally(res => {
        loading.close()
      })
    },
    submit(imgUrl) {
huhaiqing's avatar
huhaiqing committed
205
      let params = {
206
        imgUrl,
huhaiqing's avatar
huhaiqing committed
207 208 209 210
        billContent: this.billContent,
        orderId: this.currRow.orderId,
        copyUserId: this.selectedUsers,
      };
211
      if (["makeBill", "resetBill"].includes(this.dialogCfg.type)) {
huhaiqing's avatar
huhaiqing committed
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
        createBillService({ ...params, status: 1 }).then((res) => {
          serviceMsg(res, this).then((res) => {
            this.close("query");
          });
        });
      } else {
        updateBillService({
          ...params,
          id: this.currRow.id,
          status: 1,
        }).then((res) => {
          serviceMsg(res, this).then((res) => {
            this.close("query");
          });
        });
      }
    },
    /* 取消审核 */
    canclAudit() {
      cancelBillService(this.currRow.id).then((res) => {
        serviceMsg(res, this).then(() => {
          this.close("query");
        });
      });
    },
    close(type) {
      this.$emit("closeDialog", type);
    },
240
    jumpReviewDetail() {
241
      this.close('close')
242 243 244
      const { bpmProcessId } = this.currData;
      toReviewDetail.apply(this, [bpmProcessId]);
    },
huhaiqing's avatar
huhaiqing committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258
  },
  watch: {
    currData: {
      immediate: true,
      handler(val) {
        this.billContent = val?.billContent ?? "";
        this.orderNo = val.orderNo;
      },
    },
  },
};
</script>

<style lang="scss" scoped>
259
::v-deep #html2canvas-container{
260
  padding: 3rem;
261
  word-break:initial;
262 263 264
  p{
    margin: 0;
  }
265 266 267
  td{
    word-break:initial;
  }
268
}
huhaiqing's avatar
huhaiqing committed
269 270 271
.shipping-makeLadingBill {
  .title-orderNo {
    text-align: center;
dragondean@qq.com's avatar
dragondean@qq.com committed
272
    font-size: 18px;
huhaiqing's avatar
huhaiqing committed
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
    font-weight: normal;
    margin-bottom: 10px;
  }
  .process-area {
    margin-top: 15px;
    .process {
      display: flex;
      flex-direction: column;
      > :first-child {
        color: #606266;
        font-weight: bolder;
        font-size: 16px;
      }
    }
    > :last-child {
      text-align: center;
    }
  }
huhaiqing's avatar
huhaiqing committed
291 292 293 294
  .ueditor-row {
    display: flex;
    justify-content: center;
  }
huhaiqing's avatar
huhaiqing committed
295
}
dragondean@qq.com's avatar
dragondean@qq.com committed
296 297 298 299
.shippingSea-dialog{
  ::v-deep .el-dialog__body{
    padding-top: 0;
  }
300

dragondean@qq.com's avatar
dragondean@qq.com committed
301
}
huhaiqing's avatar
huhaiqing committed
302
</style>