|
|
@ -24,10 +24,21 @@ |
|
|
|
<div v-show="type === '1'"> |
|
|
|
<div> |
|
|
|
<el-row> |
|
|
|
<el-col :span="22"> |
|
|
|
<el-col :span="20"> |
|
|
|
<el-button type="primary" @click="addNewData">新增项目号码</el-button> |
|
|
|
<el-upload :show-file-list="false" v-model="fileOriData" :before-upload="beforeAvatarUpload" |
|
|
|
:http-request="successSubmit" accept=".xls,.xlsx,.csv" class="importClass"> |
|
|
|
<el-button type="success"> |
|
|
|
<el-icon> |
|
|
|
<Upload /> |
|
|
|
</el-icon> |
|
|
|
<span>导入数据</span> |
|
|
|
</el-button> |
|
|
|
</el-upload> |
|
|
|
<el-button type="primary" @click="exportData">导出数据</el-button> |
|
|
|
</el-col> |
|
|
|
<el-col :span="2"> |
|
|
|
<el-col :span="4"> |
|
|
|
<el-button type="primary" @click="clearData">清空数据</el-button> |
|
|
|
<el-button type="primary" @click="saveData">保存</el-button> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
@ -199,6 +210,7 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import _ from 'lodash' |
|
|
|
import * as xlsx from 'xlsx' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import allDataObj from "./assets/json/orgData.json" |
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
@ -278,6 +290,7 @@ export default { |
|
|
|
allJifenData: {}, |
|
|
|
minData: {}, |
|
|
|
qishu: 1, |
|
|
|
fileOriData: [], |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: { |
|
|
@ -395,6 +408,101 @@ export default { |
|
|
|
this.minData[`${key}`] = minItem |
|
|
|
} |
|
|
|
}, |
|
|
|
dealAllJifen(newItem, addTableData) { |
|
|
|
let alljifen = {} |
|
|
|
let minData = {} |
|
|
|
let minDataLocal = {} |
|
|
|
// 先行后列 |
|
|
|
for (let i = 1; i < 11; i++) { |
|
|
|
for (let j = 1; j < 11; j++) { |
|
|
|
alljifen[`pos${i}${j}`] = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = 0; i < newItem.maxing.length; i++) { |
|
|
|
let arrItem = newItem.maxing[i] |
|
|
|
let jifenItem = this.dealOneJifenExport(`${arrItem}`, newItem.qishu, newItem, addTableData) |
|
|
|
for (let key in jifenItem) { |
|
|
|
alljifen[key] += Number(jifenItem[key]) |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = 1; i < 11; i++) { |
|
|
|
for (let key in alljifen) { |
|
|
|
if (_.endsWith(key, `${i}`)) { |
|
|
|
if (minDataLocal.hasOwnProperty(`pos${i}`)) { |
|
|
|
minDataLocal[`pos${i}`].push(alljifen[key]) |
|
|
|
} else { |
|
|
|
minDataLocal[`pos${i}`] = [alljifen[key]] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (let key in minDataLocal) { |
|
|
|
let minItem = _.min(minDataLocal[key]) |
|
|
|
minData[`${key}`] = minItem |
|
|
|
} |
|
|
|
return { alljifen, minData } |
|
|
|
}, |
|
|
|
dealOneJifenExport(val, qishu, newItem, addTableData) { |
|
|
|
let jifenData = {} |
|
|
|
let maxingItem = _.find(this.allDataObj.maxing, o => o.value === Number(val)) |
|
|
|
let maxingIndex = _.findIndex(addTableData, o => o.xiangmu === newItem.xiangmu) |
|
|
|
let allData = _.cloneDeep(this.allDataObj[maxingItem.name]) |
|
|
|
let posArrList = [] |
|
|
|
for (let i = 0; i < qishu; i++) { |
|
|
|
let item = addTableData[maxingIndex - i] |
|
|
|
posArrList.push([item.pos1, item.pos2, item.pos3, item.pos4, item.pos5, item.pos6, item.pos7, item.pos8, item.pos9, item.pos10]) |
|
|
|
} |
|
|
|
// 先把所有积分加载出来 |
|
|
|
for (let i = 1; i < 11; i++) { |
|
|
|
for (let j = 1; j < 11; j++) { |
|
|
|
jifenData[`pos${i}${j}`] = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
// 模式一按照位置积分(竖着) |
|
|
|
for (let i = 0; i < allData.length; i++) { |
|
|
|
let item = _.compact(_.split(allData[i], ",")) |
|
|
|
let moshi1Arr = [] |
|
|
|
// moshi1Arr.push(posData[Number(item[j]) - 1]) |
|
|
|
for (let j = 0; j < posArrList.length; j++) { |
|
|
|
let ele = posArrList[j]; |
|
|
|
let itemArr = [] |
|
|
|
for (let k = 0; k < item.length; k++) { |
|
|
|
itemArr.push(ele[Number(item[k]) - 1]) |
|
|
|
} |
|
|
|
moshi1Arr.push(itemArr) |
|
|
|
} |
|
|
|
let some = _.uniq(_.flatten(moshi1Arr)); |
|
|
|
for (let j = 0; j < item.length; j++) { |
|
|
|
for (let k = 1; k < 11; k++) { |
|
|
|
if (some.indexOf(`${k}`) === -1) { |
|
|
|
jifenData[`pos${k}${item[j]}`]++ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 模式二按照位置积分(横着) |
|
|
|
for (let i = 0; i < allData.length; i++) { |
|
|
|
let item = _.compact(_.split(allData[i], ",")) |
|
|
|
let moshi2Arr = [] |
|
|
|
for (let j = 0; j < posArrList.length; j++) { |
|
|
|
let ele = posArrList[j]; |
|
|
|
let itemArr = [] |
|
|
|
for (let k = 0; k < item.length; k++) { |
|
|
|
itemArr.push(ele[Number(item[k]) - 1]) |
|
|
|
} |
|
|
|
moshi2Arr.push(itemArr) |
|
|
|
} |
|
|
|
let same = _.intersection(...moshi2Arr); |
|
|
|
for (let j = 0; j < same.length; j++) { |
|
|
|
for (let k = 1; k < 11; k++) { |
|
|
|
if (item.indexOf(`${k}`) === -1) { |
|
|
|
jifenData[`pos${same[j]}${k}`]++ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return jifenData |
|
|
|
}, |
|
|
|
dealOneJifen(val) { |
|
|
|
let qishu = this.qishu |
|
|
|
let jifenData = {} |
|
|
@ -463,6 +571,7 @@ export default { |
|
|
|
}, |
|
|
|
changejifen(val) { |
|
|
|
this.newItem = { ..._.cloneDeep(_.filter(this.addTableData, (item) => item.xiangmu === val)[0]) } |
|
|
|
this.qishu = this.newItem.qishu || 1 |
|
|
|
}, |
|
|
|
addNewData() { |
|
|
|
this.dialogFormData.show = true |
|
|
@ -504,6 +613,99 @@ export default { |
|
|
|
saveData() { |
|
|
|
localStorage.setItem('addTableData', JSON.stringify(this.addTableData)) |
|
|
|
ElMessage.success('保存成功') |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 上传表格检查 |
|
|
|
*/ |
|
|
|
beforeAvatarUpload(rawFile) { |
|
|
|
let imgList = ['text/csv', 'application/vnd.ms-excel', "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] |
|
|
|
if (imgList.indexOf(rawFile.type) === -1) { |
|
|
|
this.$msgbox.alert('请上传excel,csv格式的表格文件!') |
|
|
|
return false |
|
|
|
} else if (rawFile.size / 1024 / 1024 > 50) { |
|
|
|
this.$msgbox.alert('表格文件的大小为小于50MB,数据过多时会处理过慢') |
|
|
|
return true |
|
|
|
} |
|
|
|
return true |
|
|
|
}, |
|
|
|
//表格增加数据 |
|
|
|
async successSubmit(opts) { |
|
|
|
let that = this |
|
|
|
let file = opts.file |
|
|
|
this.fileDealData = [] |
|
|
|
let fileReader = new FileReader() |
|
|
|
fileReader.onload = async function () { |
|
|
|
let data = this.result |
|
|
|
let workbook = xlsx.read(data, { type: 'binary' }) |
|
|
|
let sheetName = workbook.SheetNames[0] |
|
|
|
let sheetData = xlsx.utils.sheet_to_json(workbook.Sheets[sheetName]) |
|
|
|
let list = [] |
|
|
|
let length = that.addTableData.length |
|
|
|
for (let i = 0; i < sheetData.length; i++) { |
|
|
|
let item = sheetData[i] |
|
|
|
let posValueObj = {} |
|
|
|
let posArr = _.split(item["导入号码"], /[,,]/) |
|
|
|
for (let j = 0; j < 10; j++) { |
|
|
|
posValueObj[`pos${j + 1}`] = _.trim(posArr[j]) |
|
|
|
} |
|
|
|
that.addTableData.push({ |
|
|
|
xiangmu: _.padStart(length + i + 1, 5, "0"), |
|
|
|
maxing: [2, 3, 4, 5, 6, 7, 8], |
|
|
|
qishu: Number(item["期数"]) || 1, |
|
|
|
...posValueObj |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
fileReader.onerror = function (error) { |
|
|
|
console.error('Error reading file:', error) |
|
|
|
} |
|
|
|
fileReader.readAsArrayBuffer(file) |
|
|
|
}, |
|
|
|
exportData() { |
|
|
|
let lilstLocal = [] |
|
|
|
for (let i = 0; i < this.addTableData.length; i++) { |
|
|
|
let newItem = this.addTableData[i]; |
|
|
|
let { alljifen, minData } = this.dealAllJifen(newItem, this.addTableData) |
|
|
|
let count = 0 |
|
|
|
let minCount = 0 |
|
|
|
for (let key in alljifen) { |
|
|
|
count += (alljifen[key] || 0) |
|
|
|
} |
|
|
|
for (let key in minData) { |
|
|
|
minCount += (minData[key] || 0) |
|
|
|
} |
|
|
|
count -= (minCount * 10) |
|
|
|
let nextItem = _.get(this.addTableData, [`${i + 1}`], {}) |
|
|
|
let nextCount = 0 |
|
|
|
if (!_.isEmpty(nextItem)) { |
|
|
|
for (let i = 1; i < 11; i++) { |
|
|
|
nextCount += alljifen[`pos${nextItem["pos" + i]}${i}`] || 0 |
|
|
|
} |
|
|
|
} |
|
|
|
let xiangmuArr = [] |
|
|
|
for (let j = 1; j < 11; j++) { |
|
|
|
xiangmuArr.push(newItem["pos" + j]) |
|
|
|
} |
|
|
|
let xiangmuStr = _.join(xiangmuArr, ",") |
|
|
|
lilstLocal.push({ |
|
|
|
"导入号码": `${xiangmuStr}`, |
|
|
|
"期数": `${newItem.qishu}`, |
|
|
|
"当期下注金额": `${count}`, |
|
|
|
"比对下期号码中的金额": `${nextCount}`, |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
let jsonWorkSheet = xlsx.utils.json_to_sheet(lilstLocal); |
|
|
|
let workBook = { |
|
|
|
SheetNames: ["sheet1"], |
|
|
|
Sheets: { |
|
|
|
["sheet1"]: jsonWorkSheet, |
|
|
|
} |
|
|
|
}; |
|
|
|
xlsx.writeFile(workBook, `导出数据${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.xlsx`); |
|
|
|
}, |
|
|
|
clearData() { |
|
|
|
this.addTableData = [] |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
@ -546,6 +748,12 @@ export default { |
|
|
|
height: 100vh; |
|
|
|
} |
|
|
|
|
|
|
|
.importClass { |
|
|
|
display: inline-block; |
|
|
|
margin: 4px 8px; |
|
|
|
position: relative; |
|
|
|
top: 3px; |
|
|
|
} |
|
|
|
|
|
|
|
.noVip { |
|
|
|
text-align: center; |
|
|
|