From e8cfa1d2f97ba3714a72f83b8b6b35e35d1a153c Mon Sep 17 00:00:00 2001 From: lichong <18518571399@163.com> Date: Sat, 12 Oct 2024 20:20:45 +0800 Subject: [PATCH] 10.12 --- front/src/renderer/src/views/shujufenxi.vue | 302 +++++++++++++++++++- 1 file changed, 290 insertions(+), 12 deletions(-) diff --git a/front/src/renderer/src/views/shujufenxi.vue b/front/src/renderer/src/views/shujufenxi.vue index 1eb300a..6806ac9 100644 --- a/front/src/renderer/src/views/shujufenxi.vue +++ b/front/src/renderer/src/views/shujufenxi.vue @@ -237,9 +237,20 @@ export default { return { _: _, dayjs: dayjs, - leftText: "", - placeholderLeftText: -`一单一组:684,784,876共12 + leftText: `一单一组:684,784,876共12 +单:784,961,637共6元 +组:214,315共4元 +组六:1269共10元 +组六:12069共10元 +组六:120769共10元 +组三:874共10元 +毒:6共10元 +双飞:98共10元 +定位:324共10元 +全包对子:共10元 +`, + placeholderLeftText: + `一单一组:684,784,876共12 单:784,961,637共6元 组:214,315共4元 组六:1269共10元 @@ -396,21 +407,288 @@ export default { }, // 左侧统计数据 leftTongji() { + // let lastNum = (this.leftText.match(/\d+/g) || []).pop() + let haomaList = [] // 按照换行符分割 let leftTextArr = this.leftText.split("\n") // 将分割后的每个字符串剔除含有日期的字符串和带退的行 leftTextArr = leftTextArr.filter(item => { return !(item.match(/\d{2}:\d{2}:\d{2}/g) || item.includes("退")) }) // 将剩下的字符串末尾最多两个汉字的最后一个数字取出 - leftTextArr = leftTextArr.map(item => { - let lastNum = item.match(/\d+[\u4e00-\u9fa5]{0,2}$/) - if (lastNum) { - return Number(parseFloat(lastNum[0])) + // yidanyizu: /一单一组[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yizuliu: /1组六[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yizusan: /1组三[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yidu: /1毒[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yishuangfei: /1双飞[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yidingwei: /1定位[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yibudingwei: /1不定位[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yifushi: /1复式[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yiquanbaoduizi: /1全包对子[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yidan: /1单[:|:]*([\d,.\s]+)(?=合计|共*)/, + // yizu: /1组[:|:]*([\d,.\s]+)(?=合计|共*)/, + // jine: /[合计|共]+(\d+)元*/ + for (let i = 0; i < leftTextArr.length; i++) { + let item = leftTextArr[i]; + let type = "体彩" + if (item.includes("福彩")) { + type = "福彩" } - }) - leftTextArr = _.compact(leftTextArr) - this.rightText = _.sum(leftTextArr) - this.tongjizhongjiang() - return this.rightText + let jine = item.match(this.jine) + if (jine) { + jine = Number(jine[1]) + } else { + continue + } + let haoma = [] + // 一单一组 + if (item.match(this.yidanyizu)) { + let match = item.match(this.yidanyizu) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let danxuanList = [] + let zuxuanList = [] + for (let j = 0; j < haoma.length; j++) { + let numberItem = haoma[j]; + danxuanList.push({ + type: "danxuan", + value: [`${numberItem}`], + jine: (jine / 2) / (haoma.length) + }) + zuxuanList.push({ + type: "zuxuan", + value: [`${numberItem}`], + jine: (jine / 2) / (haoma.length) + }) + } + haomaList.push({ + type: type, + name: "1单", + numbers: danxuanList, + }) + haomaList.push({ + type: type, + name: "1组", + numbers: zuxuanList, + }) + } + // 1组六 + else if (item.match(this.yizuliu)) { + let match = item.match(this.yizuliu) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let groupBy = _.groupBy(haoma, o => { return `${o}`.length }); + for (let key in groupBy) { + haomaList.push({ + type: type, + name: `1组六${key}码`, + numbers: [{ + type: `zuliu${key}`, + value: groupBy[key], + jine: (jine / haoma.length) * (groupBy[key].length) + }], + }) + } + + } + // 1组三 + else if (item.match(this.yizusan)) { + let match = item.match(this.yizusan) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let groupBy = _.groupBy(haoma, o => { return `${o}`.length }); + for (let key in groupBy) { + haomaList.push({ + type: type, + name: `1组三${key}码`, + numbers: [{ + type: `zusan${key}`, + value: groupBy[key], + jine: (jine / haoma.length) * (groupBy[key].length) + }], + }) + } + } + // 1毒 + else if (item.match(this.yidu)) { + let match = item.match(this.yidu) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let duslist = [] + for (let j = 0; j < haoma.length; j++) { + let numberItem = haoma[j]; + duslist.push({ + type: "dudan", + value: [`${numberItem}`], + jine: jine / (haoma.length) + }) + } + haomaList.push({ + type: type, + name: "1毒", + numbers: duslist, + }) + } + // 1双飞 + else if (item.match(this.yishuangfei)) { + let match = item.match(this.yishuangfei) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let shaungfeislist = [] + for (let j = 0; j < haoma.length; j++) { + let numberItem = haoma[j]; + shaungfeislist.push({ + type: "shuangfei", + value: [`${numberItem}`], + jine: jine / (haoma.length) + }) + } + haomaList.push({ + type: type, + name: "1双飞", + numbers: shaungfeislist, + }) + } + // 1定位 + else if (item.match(this.yidingwei)) { + let match = item.match(this.yidingwei) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let dingweislist = [] + for (let j = 0; j < haoma.length; j++) { + let numberItem = haoma[j]; + dingweislist.push({ + type: "dingwei", + value: [`${numberItem}`], + jine: jine / (haoma.length) + }) + } + haomaList.push({ + type: type, + name: "1定位", + numbers: dingweislist, + }) + } + // 1不定位 + else if (item.match(this.yibudingwei)) { + let match = item.match(this.yibudingwei) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let budingweislist = [] + for (let j = 0; j < haoma.length; j++) { + let numberItem = haoma[j]; + budingweislist.push({ + type: "budingwei", + value: [`${numberItem}`], + jine: jine / (haoma.length) + }) + } + haomaList.push({ + type: type, + name: "1不定位", + numbers: budingweislist, + }) + } + // 1复式 + else if (item.match(this.yifushi)) { + let match = item.match(this.yifushi) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let budingweislist = [] + for (let j = 0; j < haoma.length; j++) { + let numberItem = haoma[j]; + budingweislist.push({ + type: "fushi", + value: [`${numberItem}`], + jine: jine / (haoma.length) + }) + } + haomaList.push({ + type: type, + name: "1复式", + numbers: budingweislist, + }) + } + // 1全包对子 + else if (item.match(this.yiquanbaoduizi)) { + let quanbaoduizislist = [{ + type: "quanbaoduizi", + value: [], + jine: jine + }] + haomaList.push({ + type: type, + name: "1全包对子", + numbers: quanbaoduizislist, + }) + } + // 1单 + else if (item.match(this.yidan)) { + let match = item.match(this.yidan) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let danxuanList = [] + for (let j = 0; j < haoma.length; j++) { + let numberItem = haoma[j]; + danxuanList.push({ + type: "danxuan", + value: [`${numberItem}`], + jine: jine / (haoma.length) + }) + } + haomaList.push({ + type: type, + name: "1单", + numbers: danxuanList, + }) + } + // 1组 + else if (item.match(this.yizu)) { + let match = item.match(this.yizu) + let numbers = match[1].replace(/\s+/g, '').replace(/[,\.]+/g, ','); + haoma = _.compact(_.split(numbers, ",")) + let zuxuanList = [] + for (let j = 0; j < haoma.length; j++) { + let numberItem = haoma[j]; + zuxuanList.push({ + type: "zuxuan", + value: [`${numberItem}`], + jine: jine / (haoma.length) + }) + } + haomaList.push({ + type: type, + name: "1组", + numbers: zuxuanList, + }) + } + // 其他情况继续下一个循环 + else { + continue + } + } + let groupByName = _.groupBy(haomaList, 'name') + let rightObj = {} + for (let key in groupByName) { + let value = groupByName[key] + rightObj[key] = { + value: 0, + dataList: [] + } + for (let i = 0; i < value.length; i++) { + let element = value[i]; + for (let j = 0; j < element.numbers.length; j++) { + let numberItem = element.numbers[j]; + rightObj[key].value += Number(numberItem.jine) + rightObj[key].dataList = rightObj[key].dataList.concat(numberItem.value) + } + } + } + let text = "" + for (let key in rightObj) { + text += `${key.slice(1, 9)}:${rightObj[key].dataList.join(";")}共${rightObj[key].value}元\n` + } + this.rightText = text + // this.tongjizhongjiang() + // return this.rightText // let lastNum = (this.leftText.match(/\d+/g) || []).pop() // this.rightText = (Number(this.rightText || 0) + Number(lastNum || 0)) || 0 },