generated from zhaoxingchang/i-tax-management-front-lxzy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
391 lines
14 KiB
391 lines
14 KiB
10 months ago
|
const vm = new Vue({
|
||
|
el: '#merge',
|
||
|
data: {
|
||
|
shadeShow: false,
|
||
|
nextShow: false,
|
||
|
checkAllShow: false,
|
||
|
scanShow: false,
|
||
|
loadingShow: false,
|
||
|
orderNumber: 0,
|
||
|
nsrsbh: '',
|
||
|
myData: [],
|
||
|
orderInfo: [],
|
||
|
orderItemInfoList: [],
|
||
|
logo: []
|
||
|
|
||
|
},
|
||
|
computed: {
|
||
|
//共多少个订单
|
||
|
orderQuantity() {
|
||
|
let num = 0;
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
if (this.myData[i].switch) {
|
||
|
num++
|
||
|
|
||
|
}
|
||
|
}
|
||
|
return num
|
||
|
},
|
||
|
//订单总价
|
||
|
orderPrice() {
|
||
|
let num = 0;
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
if (this.myData[i].switch) {
|
||
|
num += parseFloat(this.myData[i].money)
|
||
|
}
|
||
|
}
|
||
|
return num
|
||
|
},
|
||
|
//纳税人数量
|
||
|
taxpayerLength() {
|
||
|
const array = [];
|
||
|
const temp = [];
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
if (this.myData[i].switch) {
|
||
|
array.push(this.myData[i].name);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
for (let k = 0; k < array.length; k++) {
|
||
|
if (temp.indexOf(array[k]) === -1) {
|
||
|
temp.push(array[k]);
|
||
|
}
|
||
|
}
|
||
|
return temp.length;
|
||
|
},
|
||
|
//提交多少个发票
|
||
|
invoiceNum() {
|
||
|
const array = [];
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
if (this.myData[i].switch) {
|
||
|
array.push(this.myData[i])
|
||
|
}
|
||
|
}
|
||
|
return array.length;
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
//调用微信扫码
|
||
|
onScan() {
|
||
|
const _this = this;
|
||
|
wx.scanQRCode({
|
||
|
needResult: 1,
|
||
|
scanType: ["qrCode", "barCode"],
|
||
|
success: function (res) {
|
||
|
_this.scanData(res);
|
||
|
|
||
|
}, fail: function () {
|
||
|
_this.getJSSDK();
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
//删除
|
||
|
onDel() {
|
||
|
let a = false;
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
if (this.myData[i].switch) {
|
||
|
a = true
|
||
|
}
|
||
|
}
|
||
|
if (a) {
|
||
|
this.shadeShow = true
|
||
|
} else {
|
||
|
alert_prompt_open("提示", "请选择要删除的开票", 1);
|
||
|
}
|
||
|
|
||
|
},
|
||
|
|
||
|
scanData(res) {
|
||
|
const _this = this;
|
||
|
let reqData = {"shortUrl": res.resultStr, "xhfNsrsbh": this.nsrsbh};
|
||
|
$.ajax({
|
||
|
type: 'POST',
|
||
|
url: config.projectUrl + '/scanInvoice/getMergeOrderByShortUrl?shortUrl=' + res.resultStr + '&xhfNsrsbh=' + this.nsrsbh,
|
||
|
// url: config.projectUrl +'/scanInvoice/getMergeOrderByShortUrl?shortUrl=http://sims.dxyun.com:52380/order-api-cs/api/v3/491743155269619714&xhfNsrsbh=' + this.nsrsbh,
|
||
|
async: false,
|
||
|
data: JSON.stringify(reqData),
|
||
|
contentType: "application/json;charset=utf-8",
|
||
|
success: function (res) {
|
||
|
if (res.code === "0000") {
|
||
|
const orderInfo = JSON.parse(window.sessionStorage.getItem("orderInfo"));
|
||
|
if (orderInfo) {
|
||
|
_this.nsrsbh = orderInfo.xhfNsrsbh;
|
||
|
} else {
|
||
|
_this.nsrsbh = '';
|
||
|
}
|
||
|
if (_this.nsrsbh !== '' && res.orderInfo.xhfNsrsbh !== _this.nsrsbh) {
|
||
|
alert_prompt_open("提示", "销方不一致,请重新扫描同销方订单", 1);
|
||
|
|
||
|
} else {
|
||
|
let dataOrderInfo = res.orderInfo;
|
||
|
let dataOrderItemInfoList = res.orderItemList[0];
|
||
|
_this.orderInfo = dataOrderInfo;
|
||
|
_this.orderItemInfoList = dataOrderItemInfoList;
|
||
|
window.sessionStorage.setItem("orderInfo", JSON.stringify(dataOrderInfo));
|
||
|
window.sessionStorage.setItem("orderItemInfoList", JSON.stringify(dataOrderItemInfoList));
|
||
|
let num = 0;
|
||
|
for (let i = 0; i < _this.myData.length; i++) {
|
||
|
if (_this.myData[i].id !== dataOrderInfo.id) {
|
||
|
num++
|
||
|
} else {
|
||
|
alert_prompt_open("提示", "不可重复添加", 1);
|
||
|
}
|
||
|
}
|
||
|
if (_this.myData.length === num) {
|
||
|
const time = dataOrderItemInfoList.createTime;
|
||
|
let o = {
|
||
|
id: dataOrderInfo.id,
|
||
|
addTime: time,
|
||
|
name: dataOrderInfo.xhfMc,
|
||
|
billingItem: dataOrderItemInfoList.xmmc,
|
||
|
orderInfoId: dataOrderItemInfoList.orderInfoId,
|
||
|
money: dataOrderInfo.kphjje,
|
||
|
// kpxm: dataOrderInfo.kpxm,
|
||
|
fpqqlsh: dataOrderInfo.fpqqlsh,
|
||
|
switch: false
|
||
|
}
|
||
|
_this.myData.push(o);
|
||
|
|
||
|
}
|
||
|
_this.allBtn();
|
||
|
}
|
||
|
|
||
|
} else {
|
||
|
alert_prompt_open("提示", res.msg, 1);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
//一位转两位
|
||
|
add0(m) {
|
||
|
return m < 10 ? '0' + m : m
|
||
|
},
|
||
|
//时间戳转日期
|
||
|
format(shijianchuo) {
|
||
|
//shijianchuo是整数,否则要parseInt转换
|
||
|
const time = new Date(shijianchuo);
|
||
|
const y = time.getFullYear();
|
||
|
const m = time.getMonth() + 1;
|
||
|
const d = time.getDate();
|
||
|
const h = time.getHours();
|
||
|
const mm = time.getMinutes();
|
||
|
const s = time.getSeconds();
|
||
|
return y + '-' + this.add0(m) + '-' + this.add0(d) + ' ' + this.add0(h) + ':' + this.add0(mm) + ':' + this.add0(s);
|
||
|
},
|
||
|
//获取微信扫一扫服务
|
||
|
getJSSDK() {
|
||
|
const _this = this;
|
||
|
$.ajax({
|
||
|
type: 'POST',
|
||
|
url: '/ele-myinvoice/wx/getJSSDK?url=' + window.location.href,
|
||
|
async: false,
|
||
|
// data: { url: window.location.href },
|
||
|
success: function (data) {
|
||
|
const info = data;
|
||
|
this.scanShow = true;
|
||
|
wx.config({
|
||
|
debug: false,
|
||
|
appId: info.appId,
|
||
|
beta: true,
|
||
|
timestamp: info.timestamp,
|
||
|
nonceStr: info.nonceStr,
|
||
|
signature: info.signature,
|
||
|
jsApiList: ['scanQRCode']
|
||
|
});
|
||
|
wx.error(function (res) {
|
||
|
|
||
|
setTimeout(function () {
|
||
|
if (callbackNum < 5) {
|
||
|
callbackNum++;
|
||
|
_this.getJSSDK();
|
||
|
}
|
||
|
}, 100)
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
//点击小圆点
|
||
|
onSwitch(id) {
|
||
|
let num = 0;
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
|
||
|
if (this.myData[i].id === id) {
|
||
|
this.myData[i].switch = !this.myData[i].switch
|
||
|
}
|
||
|
if (this.checkAllShow && !this.myData[i].switch) {
|
||
|
this.checkAllShow = false
|
||
|
}
|
||
|
if (!this.myData[i].switch) {
|
||
|
num++
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (num === 0) {
|
||
|
this.checkAllShow = true
|
||
|
}
|
||
|
},
|
||
|
//下一步
|
||
|
onNext() {
|
||
|
|
||
|
window.location.href = "./writing.html";
|
||
|
window.sessionStorage.setItem('page', "1")
|
||
|
|
||
|
},
|
||
|
//下一步
|
||
|
onNextBtn() {
|
||
|
|
||
|
if (this.taxpayerLength === 0) {
|
||
|
|
||
|
alert_prompt_open("提示", "请选择要合并的开票", 1);
|
||
|
} else {
|
||
|
this.loadingShow = true;
|
||
|
this.pushData()
|
||
|
|
||
|
}
|
||
|
},
|
||
|
// 下一步请求
|
||
|
pushData() {
|
||
|
const _this = this;
|
||
|
const ids = [];
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
if (this.myData[i].switch) {
|
||
|
ids.push(this.myData[i].orderInfoId)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
window.sessionStorage.setItem("myDataShow", JSON.stringify(true));
|
||
|
window.sessionStorage.setItem("myData", JSON.stringify(this.myData));
|
||
|
|
||
|
$.ajax({
|
||
|
|
||
|
type: 'POST',
|
||
|
url: config.projectUrl + '/scanInvoice/getMergeOrder',
|
||
|
async: false,
|
||
|
contentType: "application/json;charset=utf-8",
|
||
|
data: JSON.stringify({
|
||
|
ids: JSON.stringify(ids),
|
||
|
xhfNsrsbh: this.nsrsbh
|
||
|
}),
|
||
|
success: function (data) {
|
||
|
_this.loadingShow = false;
|
||
|
if (data.code === '0000') {
|
||
|
|
||
|
// window.sessionStorage.setItem("orderNumber", JSON.stringify(data.data.orderNumber));
|
||
|
// var logo = JSON.parse(window.sessionStorage.getItem("logo"));
|
||
|
// if(!logo || !_this.logo){
|
||
|
window.sessionStorage.setItem("orderInfo", JSON.stringify(data.commonOrder.orderInfo));
|
||
|
window.sessionStorage.setItem("orderItemInfoList", JSON.stringify(data.commonOrder.orderItemInfo));
|
||
|
// window.sessionStorage.setItem("logo", JSON.stringify(_this.logo));
|
||
|
// }
|
||
|
|
||
|
|
||
|
// var arr = [];
|
||
|
// _this.orderNumber = data.data.orderNumber;
|
||
|
// var orderPrice = _this.orderPrice.toFixed(2);
|
||
|
|
||
|
// window.sessionStorage.setItem("orderPrice", JSON.stringify(orderPrice));
|
||
|
window.sessionStorage.setItem("ids", JSON.stringify(ids));
|
||
|
_this.nextShow = true;
|
||
|
|
||
|
} else {
|
||
|
alert_prompt_open("提示", data.msg, 1);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
//全选
|
||
|
onCheckAll() {
|
||
|
this.checkAllShow = !this.checkAllShow
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
this.myData[i].switch = this.checkAllShow;
|
||
|
}
|
||
|
|
||
|
},
|
||
|
//点击删除
|
||
|
onDelete() {
|
||
|
this.shadeShow = false
|
||
|
let arr = [];
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
if (!this.myData[i].switch) {
|
||
|
arr.push(this.myData[i])
|
||
|
}
|
||
|
}
|
||
|
this.myData = arr;
|
||
|
this.allBtn()
|
||
|
|
||
|
// var orderInfo = JSON.parse(window.sessionStorage.getItem("orderInfo"));
|
||
|
// var orderItemInfoList = JSON.parse(window.sessionStorage.getItem("orderItemInfoList"));
|
||
|
// var enterpriseInfo = JSON.parse(window.sessionStorage.getItem("logo"));
|
||
|
// var a = 0;
|
||
|
// for (let i = 0; i < this.myData.length; i++) {
|
||
|
// if (orderInfo.id == this.myData.id) {
|
||
|
// a++;
|
||
|
// }
|
||
|
// }
|
||
|
if (this.myData.length === 0) {
|
||
|
window.sessionStorage.removeItem("orderInfo");
|
||
|
window.sessionStorage.removeItem("orderItemInfoList");
|
||
|
window.sessionStorage.removeItem("logo");
|
||
|
}
|
||
|
|
||
|
},
|
||
|
// 查看历史账单
|
||
|
billingHistory() {
|
||
|
window.location.href = config.baseUrl + "/my-invoice/html/account/login_transfer_page.html?path=http://wxkf.5ifapiao.com/my-invoice/html/public/footer.html#invoice_list";
|
||
|
},
|
||
|
//全选管理
|
||
|
allBtn() {
|
||
|
let a = 0;
|
||
|
for (let i = 0; i < this.myData.length; i++) {
|
||
|
if (this.myData[i].switch) {
|
||
|
a++
|
||
|
}
|
||
|
}
|
||
|
this.checkAllShow = a !== 0;
|
||
|
},
|
||
|
init() {
|
||
|
let myDataShow = JSON.parse(window.sessionStorage.getItem("myDataShow"));
|
||
|
if (myDataShow) {
|
||
|
this.myData = JSON.parse(window.sessionStorage.getItem("myData"))
|
||
|
this.nsrsbh = this.myData[0].xhfNsrsbh;
|
||
|
this.allBtn();
|
||
|
} else {
|
||
|
const orderInfo = JSON.parse(window.sessionStorage.getItem("orderInfo"));
|
||
|
const orderItemInfoList = JSON.parse(window.sessionStorage.getItem("orderItemInfoList"));
|
||
|
// var logo = window.localStorage.getItem("logo");
|
||
|
|
||
|
const time = orderItemInfoList[0].createTime;
|
||
|
this.nsrsbh = orderInfo.xhfNsrsbh;
|
||
|
const name = orderInfo.xhfMc;
|
||
|
let o = {
|
||
|
id: orderInfo.id,
|
||
|
addTime: time,
|
||
|
name: name,
|
||
|
billingItem: orderItemInfoList[0].xmmc,
|
||
|
money: orderInfo.kphjje,
|
||
|
xhfNsrsbh: orderInfo.xhfNsrsbh,
|
||
|
// kpxm: orderInfo.kpxm,
|
||
|
fpqqlsh: orderInfo.fpqqlsh,
|
||
|
orderInfoId: orderItemInfoList[0].orderInfoId,
|
||
|
switch: false
|
||
|
}
|
||
|
|
||
|
this.myData.push(o)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
},
|
||
|
created() {
|
||
|
this.init();
|
||
|
},
|
||
|
mounted() {
|
||
|
$('#loading').hide();
|
||
|
this.getJSSDK();
|
||
|
|
||
|
|
||
|
}
|
||
|
});
|
||
|
var callbackNum = 0;
|