Parcourir la source

Merge branch 'master' of http://47.107.53.207:3000/ymy/oms

AlanWong il y a 1 an
Parent
commit
0a85caa598

+ 2 - 1
src/api/print.ts

@@ -6,6 +6,7 @@ export function print(data:any){
 		url: '/print/render',
 		method: 'POST',
     data:data,
+    responseType:'blob',
     headers:{
       'Print-User':'admin'
     }
@@ -18,7 +19,7 @@ export function preview(data:any){
 		url: '/print/preview',
 		method: 'POST',
     data:data,
-    // responseType:'blob',
+    responseType:'blob',
     headers:{
       'Print-User':'admin'
     }

+ 36 - 2
src/benyun/components/byBill/byBill.vue

@@ -1,5 +1,5 @@
 <template>
-	<div class="bill">
+	<div class="bill" v-loading="load">
 		<div class="bill-left">
 			<div class="bill-tab" :style="{width:closeTab?0:'180px'}">
 				<div class="bill-title">导航</div>
@@ -147,6 +147,7 @@
 	import { Component, Prop, Vue, Watch } from "vue-property-decorator";
 	import VueViews from '@/benyun/compVue/VueViews'
 	import billModule from "./billModule.vue";
+	import {print} from '@/api/print'
 	@Component({ components: { billModule } })
 	export default class ByBill extends VueViews {
 		showTab = "bill"
@@ -154,6 +155,7 @@
 		billValue = {};
 		activeSource = 'source0';
 		drawer = false;
+		load = false;
 		//引单
 		get sourceConfig() {
 			return this.config?.source ? this.config.source : null;
@@ -192,6 +194,33 @@
 				this.setConfig(this.propConfig)
 			}
 		}
+		//打印
+		onPrint(){
+			let param:any={};
+			let data = (this.$refs.billForm as any).getValue();
+			param.limitKey='OMS';
+			param.templateData = data;
+			param.outType = 'PDF';
+			this.$emit('printBefore',param);
+			try{
+				param.templateData = JSON.stringify(param.templateData);
+			}catch(e){
+				console.error('数据转换报错!');
+			}
+			this.load = true;
+			print(param).then((res:any)=>{
+				this.load = false;
+				const blob = new Blob([res],{
+        type: "application/pdf;chartset=UTF-8"
+      })
+				const qrUrl:any =(window as any).URL.createObjectURL(blob);
+				const myWindow =(window as any).open(qrUrl);
+				myWindow.print();
+
+			}).catch(()=>{
+				this.load = false;
+			})
+		}
 		//日志弹窗
 		showLog() {
 			this.$nextTick(() => {
@@ -252,7 +281,12 @@
 		 * @param n2 表示哪个表格的操作
 		 */
 		clickHandle(n1 : string, n2 : string) {
-			this.$emit(n1, n2)
+			if(n1 == 'onPrint' && n2 == 'bill'){
+				this.onPrint();
+			}else{
+				this.$emit(n1, n2)
+			}
+			
 		}
 		search(v : any, n : string) {
 			this.$emit('search', {

+ 1 - 0
src/benyun/components/byTool/byTool.vue

@@ -58,6 +58,7 @@ export default class GmTools extends Vue {
     { name: '取消提交', icon: 'el-icon-refresh-left', clickName: 'onReSmt', _class: 'reSmt' },
     { name: '删除', icon: 'el-icon-delete', clickName: 'onDelete', _class: 'delete' },
     { name: '导出', icon: 'el-icon-download', clickName: 'onExport', _class: 'export' },
+    { name: '打印', icon: 'el-icon-printer', clickName: 'onPrint', _class: 'print' },
   ]
   showTools:Array<any>=[]
 

+ 56 - 5
src/views/audit/outbound/index.vue

@@ -2,7 +2,7 @@
 	<div>
 		<by-bill ref="bill" :propConfig="config" @search="search" @onSmt="onSmt" @onDelete="onDelete" @onRefresh="resert"
 			@resert="resert" @detail="openEdit" @onSave="onSave" @clickTab="clickTab" @onChangeRow="onChangeRow"
-			@pagination="pagination" @onReturnSmt="onReturnSmt2" @getSupplierModal="getSupplierModal">
+			@pagination="pagination" @onReturnSmt="onReturnSmt2" @getSupplierModal="getSupplierModal" @printBefore="printBefore">
 		</by-bill>
 
 		<SettingConfig ref="setForm" type="setCForm" title="出库单" />
@@ -16,8 +16,9 @@
 	import towInOne from "../warehousing/components/towInOne.vue";
 	import stockLook from "./components/stockLook.vue";
 	import SettingConfig from "../saleOrder/components/settingConfig.vue";
+	import { add } from '@/benyun/utils/accuracy'
 	@Component({ components: { SettingConfig } })
-	export default class OrderTask extends Vue {
+	export default class Outbound extends Vue {
 		// 左边
 		tabType : any = 'all';
 		isAdd : any = false;
@@ -797,6 +798,58 @@
 				this.getDataList()
 			}, 500)
 		}
+		//打印前数据修改
+		printBefore(params:any){
+			params.templateId = 12;
+			let value = (this.$refs.bill as any).getBillFormValue();
+			if(value){
+				let data:any={};
+				data.orderNumber = value.orderNumber;
+				data.operator = value.operator;
+				data.businessType = value.businessType;
+				data.financeOrderId = value.financeOrderId;
+				data.wmsId = value.wmsId;
+				data.remark = value.remark;
+				data.receivePhone = value.receivePhone;
+				data.receiveAddress = value.receiveAddress;
+				data.outOrderNo = value.outOrderNo;
+				data.receive = value.receive;
+				data.suborderList = [];
+				if(value.suborderList){
+					data.totalNumber = 0;//总数量
+					data.totalDeliveryNumber=0; //总应出数量
+					data.totalPri = 0;//总计金额
+					data.totalOutNumber = 0; //总出库数量
+					for(const item of value.suborderList){
+						let obj:any={};
+						obj.materialName = item.materialName;
+						obj.financeSuborderId = item.financeSuborderId;
+						obj.storehouseName = item.storehouseName;
+						obj.storingLocationName = item.storingLocationName;
+						obj.number = item.number;
+						obj.deliveryNumber = item.deliveryNumber;
+						obj.outNumber = item.outNumber;
+						obj.prePrice = item.prePrice;
+						obj.unitPrice = item.unitPrice;
+						obj.totalPrice = item.totalPrice;
+						data.suborderList.push(obj);
+						if(Number(item.number)){
+							data.totalNumber = add(data.totalNumber,Number(item.number))
+						}
+						if(Number(item.deliveryNumber)){
+							data.totalDeliveryNumber = add(data.totalDeliveryNumber,Number(item.deliveryNumber))
+						}
+						if(Number(item.totalPrice)){
+							data.totalPri = add(data.totalPri,Number(item.totalPrice));
+						}
+						if(Number(item.outNumber)){
+							data.totalOutNumber = add(data.totalOutNumber,Number(item.outNumber));
+						}
+					}
+				}
+				params.templateData = data;
+			}
+		}
 		// 参数配置
 		configuration() {
 			(this as any).$refs.setForm.openSetting();
@@ -958,7 +1011,6 @@
 			api.single({ id: e.id }, 'supplyOutOrder').then((res : any) => {
 				if (res.code === 200) {
 					let parentData = res.data ? res.data : e;
-					console.log('编辑 ==>', parentData);
 					this.baseInfo = parentData;
 					if (this.tabType === 'all' || this.tabType === 'draftsBox') {
 						if (parentData.submitState === 1) {
@@ -1036,7 +1088,7 @@
 			readonly.form.attr.readonly = true; // 设置只读
 			readonly.tool.tools = {};
 			if (this.tabType != 'recycleBin') {
-				if (parentData.submitState === 1) readonly.tool.tools = { returnSmt: true };
+				if (parentData.submitState === 1) readonly.tool.tools = { returnSmt: true,print:true };
 			}
 			readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
 			api.single({ id: e.purchaseOrderId }, 'supplyPurchaseOrder').then((val : any) => {
@@ -1353,7 +1405,6 @@
 		}
 		// 工具栏删除
 		onDelete(e : any) {
-			console.log('工具栏删除 ==> ', e);
 			let selectData = (this.$refs.bill as any).getTableSelectData(e)
 			let ids = '';
 			if (selectData.length > 0) {

+ 22 - 2
src/views/audit/warehousing/index.vue

@@ -2,7 +2,7 @@
 	<div>
 		<by-bill ref="bill" :propConfig="config" @search="search" @onSmt="onSmt" @onAdd="onAdd" @onDelete="onDelete"
 			@onRefresh="resert" @resert="resert" @detail="openEdit" @onSave="onSave" @clickTab="clickTab"
-			@onChangeRow="onChangeRow" @pagination="pagination" @onReturnSmt="onReturnSmt2"
+			@onChangeRow="onChangeRow" @pagination="pagination" @onReturnSmt="onReturnSmt2" @printBefore="printBefore"
 			@getSupplierModal="getSupplierModal">
 		</by-bill>
 		<!-- 选择物料 -->
@@ -40,6 +40,7 @@
 	import Focus from "../orderTask/components/focus.vue";
 	import towInOne from "./components/towInOne.vue";
 	import BusinessType from "./components/businessType.vue";
+	import { add } from '@/benyun/utils/accuracy'
 	@Component({ components: { productModal } })
 	export default class OrderTask extends Vue {
 		// 左边
@@ -704,6 +705,25 @@
 		syncEntry() {
 			this.value = true;
 		}
+		printBefore(param:any){
+			param.templateId = 11;
+			if(param.templateData && param.templateData.suborderList){
+				param.templateData.totalNumber = 0;
+				param.templateData.totalDeliveryNumber = 0;
+				param.templateData.totalPri = 0;
+				for(const item of param.templateData.suborderList){
+					if(Number(item.number)){
+						param.templateData.totalNumber = add(param.templateData.totalNumber,Number(item.number));
+					}
+					if(Number(item.deliveryNumber)){
+						param.templateData.totalDeliveryNumber = add(param.templateData.totalDeliveryNumber,Number(item.deliveryNumber))
+					}
+					if(Number(item.totalPrice)){
+						param.templateData.totalPri = add(param.templateData.totalPri,Number(item.totalPrice))
+					}
+				}
+			}
+		}
 		// 获取时间段
 		change(v : any) {
 			if (v) {
@@ -877,7 +897,7 @@
 			readonly.form.attr.readonly = true; // 设置只读
 			readonly.tool.tools = {};
 			if (this.tabType != 'recycleBin') {
-				if (e.submitState === 1) readonly.tool.tools = { returnSmt: true };
+				if (e.submitState === 1) readonly.tool.tools = { returnSmt: true,print:true };
 			}
 			readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
 			readonly.tableConfig[0].tool.tools = {};

+ 8 - 20
src/views/print/printTemplate/index.vue

@@ -236,33 +236,21 @@ export default class PrintTemplate extends Vue {
       outType:'PDF'
     }).then((res:any) => {
       this.load=false;
-      // console.log(res);
-      if(res.code && res.code != 200){
-        this.$message({message:res.msg?res.msg:'预览出错',type:'error'});
-      }else{
-        const reader = new FileReader()
-        reader.onload = function() {
-          const content = reader.result 
-          console.log(content)
-        }
 
-        reader.readAsDataURL(res) 
-        // const blob = new Blob([res],{
-        //   type: "application/pdf;chartset=UTF-8"
-        // })
-        // const qrUrl:any =(window as any).URL.createObjectURL(blob);
-        // (window as any).open(qrUrl);
+      const blob = new Blob([res],{
+        type: "application/pdf;chartset=UTF-8"
+      })
+      const qrUrl:any =(window as any).URL.createObjectURL(blob);
+      (window as any).open(qrUrl);
 
-        // const myWindow =(window as any).open(qrUrl);
-        // myWindow.print();
-      }
-      
-     
+      // const myWindow =(window as any).open(qrUrl);
+      // myWindow.print();
 
     }).catch((err:any)=>{
       this.load=false;
     })
   }
+
   //单个删除
   singleDel(item:any){
     let data=[item.id];