|
@@ -0,0 +1,171 @@
|
|
|
+import { getK3ReceiptDetail } from "@/api/finance/receipt_list";
|
|
|
+
|
|
|
+import { addPrints } from '@/api/supply/pickup'
|
|
|
+import { getCompanyList } from '@/api/user'
|
|
|
+let detailArr = []
|
|
|
+let detailData = []
|
|
|
+let cids = []
|
|
|
+let company = ''
|
|
|
+// 获取详情
|
|
|
+getCompanyLists()
|
|
|
+function getDetail(ids, nickName) {
|
|
|
+
|
|
|
+ let invoicePickBeans = []
|
|
|
+ let start = 0
|
|
|
+ let end = 5
|
|
|
+ detailArr = []
|
|
|
+ const table = []
|
|
|
+ // detailData = ids
|
|
|
+ let newIds = []
|
|
|
+ newIds = ids
|
|
|
+ cids = JSON.parse(JSON.stringify(ids))
|
|
|
+ let filterId = []
|
|
|
+ if (newIds instanceof Array) {
|
|
|
+ filterId = newIds.map(k => {
|
|
|
+ return k.id
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ filterId = [newIds]
|
|
|
+ }
|
|
|
+ filterId = [...new Set(filterId)]
|
|
|
+ for (let i = 0; i < filterId.length; i++) {
|
|
|
+ getK3ReceiptDetail({ id: filterId[i] }).then(res => {
|
|
|
+ const item = res.data
|
|
|
+ console.log(item, '887899');
|
|
|
+
|
|
|
+ table.push({
|
|
|
+ billNo:item.billNo,
|
|
|
+ theTime:item.theTime,
|
|
|
+ walletName:item.walletName,
|
|
|
+ customerName:item.customerName,
|
|
|
+ remark:item.remark,
|
|
|
+ amount:item.amount,
|
|
|
+ nowDate: nowDate(),
|
|
|
+ })
|
|
|
+ detailArr.push({
|
|
|
+ company:`${company}其他收款单`,
|
|
|
+ table: [
|
|
|
+ {id: '1', name: '王小可', gender: '单据编号', count: '120', amount: '9089元'},
|
|
|
+ {id: '2', name: '梦之遥', gender: '付款单位', count: '20', amount: '89元'},
|
|
|
+ {id: '3', name: '梦之遥', gender: '钱包', count: '720', amount: '29089元'},
|
|
|
+ {id: '3', name: '梦之遥', gender: '备注', count: '720', amount: '29089元'},
|
|
|
+ ]
|
|
|
+ })
|
|
|
+
|
|
|
+ return
|
|
|
+ detailData.push(JSON.parse(JSON.stringify(item)))
|
|
|
+ invoicePickBeans = item.invoicePickBeans
|
|
|
+ let len = Math.ceil(invoicePickBeans.length / 5)
|
|
|
+ console.log(len, '长度');
|
|
|
+ for (let index = 0; index < len; index++) {
|
|
|
+ const table = []
|
|
|
+ if (invoicePickBeans.length) {
|
|
|
+ invoicePickBeans.splice(0, 5).forEach(e => {
|
|
|
+ table.push({
|
|
|
+ salesId: e.salesOrderId,
|
|
|
+ invoiceId: e.invoiceId,
|
|
|
+ id: e.id,
|
|
|
+ createTime: e.id ? dateToDayFilter(item.createTime) : '',
|
|
|
+ enginOrderType: e.enginOrderType == 'HOME' || e.enginOrderType == 'TRADE' ? e.enginOrderNo : e.mainOrderId,
|
|
|
+ materialName: e.materialName || '',
|
|
|
+ specification: e.specification || '',
|
|
|
+ refundableQty: e.refundableQty || 0,
|
|
|
+ // headerRemark:e.headerRemark,
|
|
|
+ pjxh1Text: e.pjxh1Text || ''
|
|
|
+ })
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ detailArr.push({
|
|
|
+ pageNumber: `${len}-${index + 1}`,
|
|
|
+ type: item.type,
|
|
|
+ tiTui: item.type === 2 ? `退货人` : `提货人`,
|
|
|
+ takerPhone: item.takerPhone || '',
|
|
|
+ headerRemark: item.remark,
|
|
|
+ total_num: item.total_num,
|
|
|
+ company: item.type === 2 ? `${company}销售退货单` : `${company}销售发货单`,
|
|
|
+ pickOrderWater: item.pickOrderWater,
|
|
|
+ customerNumber: item.customerNumber,
|
|
|
+ takerDa: '',
|
|
|
+ nowDate: nowDate(),
|
|
|
+ takerName: item.type === 2 ? `退货人:${item.takerName || ''}` : `提货人:${item.takerName || ''}`,
|
|
|
+ customerName: item.customerName || '',
|
|
|
+ correspondName: item.correspondName,
|
|
|
+ correspondNames: '',
|
|
|
+ pickCar: item.pickCar || '',
|
|
|
+ createBy: JSON.parse(
|
|
|
+ localStorage.getItem("supply_user")
|
|
|
+ ).nickName,
|
|
|
+ table
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function nowDate() {
|
|
|
+ var date = new Date();
|
|
|
+ var seperator1 = "-";
|
|
|
+ var year = date.getFullYear();
|
|
|
+ var month = date.getMonth() + 1;
|
|
|
+ var strDate = date.getDate();
|
|
|
+ if (month >= 1 && month <= 9) {
|
|
|
+ month = "0" + month;
|
|
|
+ }
|
|
|
+ if (strDate >= 0 && strDate <= 9) {
|
|
|
+ strDate = "0" + strDate;
|
|
|
+ }
|
|
|
+ var currentdate = year + seperator1 + month + seperator1 + strDate;
|
|
|
+ console.log(currentdate);
|
|
|
+ return currentdate;
|
|
|
+}
|
|
|
+
|
|
|
+function dateToDayFilter(date) {
|
|
|
+ if (!date) { return '' }
|
|
|
+ return date.slice(0, 10)
|
|
|
+}
|
|
|
+
|
|
|
+function getCompanyLists() {
|
|
|
+ getCompanyList().then(res => {
|
|
|
+ company = res.data ? res.data[0].companyName : ''
|
|
|
+ })
|
|
|
+ return company
|
|
|
+}
|
|
|
+
|
|
|
+// 添加次数
|
|
|
+function addPrint() {
|
|
|
+ let ids = []
|
|
|
+ detailData.map(item => {
|
|
|
+ console.log(detailData, '3223');
|
|
|
+ if (item.invoicePickBeans && item.invoicePickBeans.length) {
|
|
|
+ for (let index = 0; index < item.invoicePickBeans.length; index++) {
|
|
|
+ const element = item.invoicePickBeans[index];
|
|
|
+ console.log(element.id, 'element.id ');
|
|
|
+ // return element.id
|
|
|
+ ids.push(element.id)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // console.log(item.invoiceOrderId ,'item.invoiceOrderId ');
|
|
|
+ return item.invoiceOrderId || item.id
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ // console.log(document.execCommand('print'),'4545');
|
|
|
+ addPrints({ ids: ids.join(',') }).then(res => {
|
|
|
+ console.log('chenggong ');
|
|
|
+ // this.$successMsg('提交成功');
|
|
|
+ // this.$parent.getList()
|
|
|
+
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+export {
|
|
|
+ getDetail, getCompanyLists,
|
|
|
+ detailArr,
|
|
|
+ addPrint
|
|
|
+}
|