|
|
@ -28,18 +28,29 @@ |
|
|
|
<el-button type="primary" @click="addNewData">新增项目号码</el-button> |
|
|
|
</el-col> |
|
|
|
<el-col :span="2"> |
|
|
|
<el-button type="primary">保存</el-button> |
|
|
|
<el-button type="primary" @click="saveData">保存</el-button> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
<el-row> |
|
|
|
<el-col> |
|
|
|
<el-table stripe :data="addTableData" border style="width: 100%;height: calc(100vh - 72px);"> |
|
|
|
<el-table-column type="index" width="50" /> |
|
|
|
<el-table-column v-for="(headerItem, heraderIndex) in addTableHeader" :prop="headerItem.prop" |
|
|
|
:label="headerItem.label" :key="heraderIndex" /> |
|
|
|
<el-table-column label="操作" width="101"> |
|
|
|
<el-table stripe :data="addTableData" border style="width: 100%;height: calc(100vh - 72px);"> |
|
|
|
<el-table-column type="index" width="80" /> |
|
|
|
<template v-for="(headerItem, heraderIndex) in addTableHeader"> |
|
|
|
<el-table-column :label="headerItem.label" v-if="!headerItem.hidden" :key="heraderIndex"> |
|
|
|
<template #default="scope"> |
|
|
|
<div> |
|
|
|
<span :style="`color:${scope.row[headerItem.prop + '_check'] ? 'red' : '#000'}`">{{ |
|
|
|
scope.row[headerItem.prop] }}</span> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</template> |
|
|
|
<el-table-column label="操作" width="120"> |
|
|
|
<template #default="scope"> |
|
|
|
<el-button type="danger" @click="handleDelete(scope.$index, scope.row)"> |
|
|
|
<el-button type="danger" link @click="viewData(scope.row)"> |
|
|
|
查看 |
|
|
|
</el-button> |
|
|
|
<el-button type="danger" link @click="handleDelete(scope.$index)"> |
|
|
|
移除 |
|
|
|
</el-button> |
|
|
|
</template> |
|
|
@ -51,12 +62,100 @@ |
|
|
|
</div> |
|
|
|
<div v-show="type === '2'"> |
|
|
|
<div> |
|
|
|
积分数据 |
|
|
|
<el-row style="padding: 8px;"> |
|
|
|
<el-col> |
|
|
|
<span>项目:</span><span> |
|
|
|
<el-select v-model="newItem.xiangmu" placeholder="请选择项目" size="large" style="width: 240px" |
|
|
|
@change="changejifen"> |
|
|
|
<el-option v-for="(item, index) in addTableData" :key="index" :label="item.xiangmu" |
|
|
|
:value="item.xiangmu" /> |
|
|
|
</el-select> |
|
|
|
</span> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
<div v-if="!_.isEmpty(newItem)"> |
|
|
|
<el-row style="padding: 8px;"> |
|
|
|
<el-col> |
|
|
|
<el-tabs v-model="valueTag" @tab-click="handleClick"> |
|
|
|
<el-tab-pane label="所有码型" name="all"> |
|
|
|
</el-tab-pane> |
|
|
|
<el-tab-pane v-for="item in newItem.maxing" :label="`${item}码`" :key="`${item}`" |
|
|
|
:name="`${item}`"> |
|
|
|
</el-tab-pane> |
|
|
|
</el-tabs> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
<el-row style="padding: 8px;" :gutter="20" justify="center"> |
|
|
|
<el-col :span="2" class="alignCenter"></el-col> |
|
|
|
<el-col :span="2" v-for="(item1, index1) in 10" :key="index1 + 'col'" class="alignCenter"> |
|
|
|
<span>第{{ item1 }}列</span> |
|
|
|
</el-col> |
|
|
|
<el-col :span="2" class="alignCenter"></el-col> |
|
|
|
</el-row> |
|
|
|
<el-row v-for="(item, index) in 10" style="padding: 8px;" :gutter="20" justify="center" |
|
|
|
:key="index + 'row'"> |
|
|
|
<el-col :span="2" class="alignCenter">第{{ item }}行</el-col> |
|
|
|
<el-col :span="2" v-for="(item1, index1) in 10" :key="index1 + 'col'" class="alignCenter"> |
|
|
|
<span>{{ (allJifenData[`pos${item}${item1}`] - minData[`pos${item1}`]) || 0 }}</span> |
|
|
|
</el-col> |
|
|
|
<el-col :span="2" class="alignCenter"></el-col> |
|
|
|
</el-row> |
|
|
|
<el-row style="padding: 8px;" :gutter="20" justify="center"> |
|
|
|
<el-col :span="2" class="alignCenter">最小值</el-col> |
|
|
|
<el-col :span="2" v-for="(item1, index1) in 10" :key="index1 + 'col'" class="alignCenter"> |
|
|
|
<span>{{ minData[`pos${item1}`] }}</span> |
|
|
|
</el-col> |
|
|
|
<el-col :span="2" class="alignCenter"></el-col> |
|
|
|
</el-row> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
<el-dialog v-model="dialogFormData.show" :title="dialogFormData.title" width="800" :close-on-click-modal="false"> |
|
|
|
<el-form :model="dialogFormData" @submit.prevent label-width="auto"> |
|
|
|
<el-form-item label="项目"> |
|
|
|
<el-input v-model="dialogFormData.xiangmu" placeholder="请输入项目名称" /> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="码型"> |
|
|
|
<el-checkbox-group v-model="dialogFormData.maxing"> |
|
|
|
<el-checkbox v-for="item in maxing" :key="item" :label="`${item}码`" :value="item"> |
|
|
|
</el-checkbox> |
|
|
|
</el-checkbox-group> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="输入10个号码"> |
|
|
|
<el-input v-model="dialogFormData.posInput" placeholder="请输入10个号码,并用','隔开" /> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item |
|
|
|
:label="`输入的${10 - _.difference(allData, _.uniq(_.compact(_.split(dialogFormData.posInput, /[,,]/)))).length}个号码`"> |
|
|
|
<el-tag v-if="_.trim(dialogFormData.posInput)" type="primary" style="margin: 0 4px;" |
|
|
|
v-for="(item, index) in _.uniq(_.compact(_.split(dialogFormData.posInput, /[,,]/)))" :key="index"> |
|
|
|
{{ item }} |
|
|
|
</el-tag> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item |
|
|
|
:label="`缺省的${_.difference(allData, _.uniq(_.compact(_.split(dialogFormData.posInput, /[,,]/)))).length}个号码`"> |
|
|
|
<el-tag v-if="_.difference(allData, _.uniq(_.compact(_.split(dialogFormData.posInput, /[,,]/)))).length" |
|
|
|
type="danger" style="margin: 0 4px;" |
|
|
|
v-for="(item, index) in _.difference(allData, _.uniq(_.compact(_.split(dialogFormData.posInput, /[,,]/))))" |
|
|
|
:key="index"> |
|
|
|
{{ item }} |
|
|
|
</el-tag> |
|
|
|
<span v-else-if="_.trim(dialogFormData.posInput)" style="color: #529b2e;">已输入完毕</span> |
|
|
|
<span v-else style="color: #999;">请输入的10个号码,并用','隔开</span> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<template #footer> |
|
|
|
<div class="dialog-footer"> |
|
|
|
<el-button @click="closeDialog">取消</el-button> |
|
|
|
<el-button type="primary" @click="submitDialog" |
|
|
|
:disabled="!((_.difference(allData, _.uniq(_.compact(_.split(dialogFormData.posInput, /[,,]/)))).length === 0) && (_.uniq(_.compact(_.split(dialogFormData.posInput, /[,,]/))).length === 10))"> |
|
|
|
确认 |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
<div v-else class="noVip"> |
|
|
|
<h3> |
|
|
@ -68,31 +167,24 @@ |
|
|
|
<script> |
|
|
|
import _ from 'lodash' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import allDataObj from "./assets/json/orgData.json" |
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
|
export default { |
|
|
|
name: 'app', |
|
|
|
data() { |
|
|
|
return { |
|
|
|
_: _, |
|
|
|
allDataObj: allDataObj, |
|
|
|
dayjs: dayjs, |
|
|
|
isVip: false, |
|
|
|
type: "1", |
|
|
|
addTableData: [ |
|
|
|
{ |
|
|
|
xiangmu: "111", |
|
|
|
pos1: "111", |
|
|
|
pos2: "111", |
|
|
|
pos3: "111", |
|
|
|
pos4: "111", |
|
|
|
pos5: "111", |
|
|
|
pos6: "111", |
|
|
|
pos7: "111", |
|
|
|
pos8: "111", |
|
|
|
pos9: "111", |
|
|
|
pos10: "111" |
|
|
|
} |
|
|
|
], |
|
|
|
addTableData: [], |
|
|
|
addTableHeader: [ |
|
|
|
{ |
|
|
|
prop: "maxing", |
|
|
|
label: "码型", |
|
|
|
hidden: true |
|
|
|
}, |
|
|
|
{ |
|
|
|
prop: "xiangmu", |
|
|
|
label: "项目" |
|
|
@ -138,33 +230,35 @@ export default { |
|
|
|
label: "位置10" |
|
|
|
}, |
|
|
|
], |
|
|
|
dialogFormData: { |
|
|
|
show: false, |
|
|
|
title: "", |
|
|
|
xiangmu: "", |
|
|
|
maxing: [], |
|
|
|
type: 1, |
|
|
|
posInput: "", |
|
|
|
}, |
|
|
|
allData: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], |
|
|
|
newItem: {}, |
|
|
|
maxing: [2, 3, 4, 5, 6, 7, 8], |
|
|
|
valueTag: "all", |
|
|
|
allJifenData: {}, |
|
|
|
minData: {}, |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
clickLeft(type) { |
|
|
|
this.type = type |
|
|
|
}, |
|
|
|
handleDelete(index, item) { |
|
|
|
console.log(8874, index, item) |
|
|
|
}, |
|
|
|
addNewData() { |
|
|
|
this.addTableData.push({ |
|
|
|
xiangmu: "111", |
|
|
|
pos1: "111", |
|
|
|
pos2: "111", |
|
|
|
pos3: "111", |
|
|
|
pos4: "111", |
|
|
|
pos5: "111", |
|
|
|
pos6: "111", |
|
|
|
pos7: "111", |
|
|
|
pos8: "111", |
|
|
|
pos9: "111", |
|
|
|
pos10: "111" |
|
|
|
}) |
|
|
|
watch: { |
|
|
|
newItem: { |
|
|
|
handler(nel, ovl) { |
|
|
|
if (!_.isEmpty(nel)) { |
|
|
|
this.dealjifen(this.valueTag) |
|
|
|
} |
|
|
|
}, |
|
|
|
deep: true |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: {}, |
|
|
|
async mounted() { |
|
|
|
let fiveDay = dayjs('2024-08-19T00:00:00').valueOf() |
|
|
|
let fiveDay = dayjs('2024-08-29T00:00:00').valueOf() |
|
|
|
if (!this.isVip) { |
|
|
|
if (dayjs().valueOf() > fiveDay) { |
|
|
|
this.isVip = false |
|
|
@ -173,9 +267,179 @@ export default { |
|
|
|
this.isVip = true |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(666, _.groupBy(allDataObj.b.all, "pos")) |
|
|
|
this.addTableData = localStorage.getItem('addTableData') ? JSON.parse(localStorage.getItem('addTableData')) : []; |
|
|
|
}, |
|
|
|
watch: {}, |
|
|
|
computed: {} |
|
|
|
methods: { |
|
|
|
clickLeft(type) { |
|
|
|
this.type = type |
|
|
|
if (type === "1") { |
|
|
|
this.newItem = {} |
|
|
|
} |
|
|
|
}, |
|
|
|
handleDelete(index) { |
|
|
|
this.addTableData.splice(index, 1) |
|
|
|
}, |
|
|
|
viewData(row) { |
|
|
|
this.clickLeft("2") |
|
|
|
this.newItem = { ...row } |
|
|
|
}, |
|
|
|
handleClick(pane) { |
|
|
|
this.dealjifen(pane.props.name) |
|
|
|
}, |
|
|
|
dealjifen(val) { |
|
|
|
let minDataLocal = {} |
|
|
|
if (val !== "all") { |
|
|
|
this.allJifenData = this.dealOneJifen(val) |
|
|
|
} else { |
|
|
|
let alljifen = {} |
|
|
|
for (let i = 1; i < 11; i++) { |
|
|
|
for (let j = 1; j < 11; j++) { |
|
|
|
alljifen[`pos${i}${j}`] = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = 0; i < this.newItem.maxing.length; i++) { |
|
|
|
let arrItem = this.newItem.maxing[i] |
|
|
|
let jifenItem = this.dealOneJifen(`${arrItem}`) |
|
|
|
for (let key in jifenItem) { |
|
|
|
alljifen[key] += Number(jifenItem[key]) |
|
|
|
} |
|
|
|
} |
|
|
|
this.allJifenData = alljifen |
|
|
|
} |
|
|
|
for (let i = 1; i < 11; i++) { |
|
|
|
for (let key in this.allJifenData) { |
|
|
|
if (_.endsWith(key, `${i}`)) { |
|
|
|
if (minDataLocal.hasOwnProperty(`pos${i}`)) { |
|
|
|
minDataLocal[`pos${i}`].push(this.allJifenData[key]) |
|
|
|
} else { |
|
|
|
minDataLocal[`pos${i}`] = [this.allJifenData[key]] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (let key in minDataLocal) { |
|
|
|
let minItem = _.min(minDataLocal[key]) |
|
|
|
this.minData[`${key}`] = minItem |
|
|
|
} |
|
|
|
console.log(74411, minDataLocal) |
|
|
|
}, |
|
|
|
dealOneJifen(val) { |
|
|
|
let jifenData = {} |
|
|
|
let maxingItem = _.find(this.allDataObj.maxing, o => o.value === (Number(val) - 1)) |
|
|
|
let allData = { ...this.allDataObj[maxingItem.name].all } |
|
|
|
let posGroup = _.groupBy(_.cloneDeep(allData), o => o.pos) |
|
|
|
let jishu = parseInt(posGroup.p1n.length / 10) |
|
|
|
//共有10列数据先循环列 |
|
|
|
for (let i = 1; i < 11; i++) { |
|
|
|
let colObj = { |
|
|
|
[`p${i}w`]: _.cloneDeep(posGroup[`p${i}w`]), |
|
|
|
[`p${i}n`]: _.cloneDeep(posGroup[`p${i}n`]) |
|
|
|
} |
|
|
|
// 每列有10行数据后循环行 |
|
|
|
for (let j = 0; j < 10; j++) { |
|
|
|
// 最后多出来的数据放到最后一行 |
|
|
|
if (j === 9) { |
|
|
|
for (let k = jishu * j; k < posGroup.p1n.length; k++) { |
|
|
|
let itemwData = colObj[`p${i}n`][k].data |
|
|
|
let itemnData = colObj[`p${i}n`][k].data |
|
|
|
for (let l = 0; l < itemwData.length; l++) { |
|
|
|
let itemW = itemwData[l] |
|
|
|
let itemn = itemnData[l] |
|
|
|
if (Number(itemW) === Number(this.newItem[`pos${itemW}`])) { |
|
|
|
if (jifenData.hasOwnProperty(`pos${itemW}${i}`)) { |
|
|
|
jifenData[`pos${itemW}${i}`]++ |
|
|
|
} else { |
|
|
|
jifenData[`pos${itemW}${i}`] = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
if (Number(itemn) === Number(this.newItem[`pos${l + 1}`])) { |
|
|
|
if (jifenData.hasOwnProperty(`pos${j}${i}`)) { |
|
|
|
jifenData[`pos${j}${i}`]++ |
|
|
|
} else { |
|
|
|
jifenData[`pos${j}${i}`] = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 最后多出来的数据放到最后一行 |
|
|
|
for (let k = jishu * j; k < jishu * (j + 1); k++) { |
|
|
|
let itemwData = colObj[`p${i}w`][k].data |
|
|
|
let itemnData = colObj[`p${i}n`][k].data |
|
|
|
let iscontinue = false |
|
|
|
for (let l = 0; l < itemwData.length; l++) { |
|
|
|
let itemW = itemwData[l] |
|
|
|
let itemn = itemnData[l] |
|
|
|
if (Number(itemW) === Number(this.newItem[`pos${itemW}`])) { |
|
|
|
iscontinue = true |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (Number(itemn) === Number(this.newItem[`pos${l + 1}`])) { |
|
|
|
iscontinue = true |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!iscontinue) { |
|
|
|
for (let l = 0; l < itemwData.length; l++) { |
|
|
|
let itemW = itemwData[l] |
|
|
|
let itemn = itemnData[l] |
|
|
|
if (Number(itemW) !== Number(this.newItem[`pos${itemW}`])) { |
|
|
|
if (jifenData.hasOwnProperty(`pos${itemW}${i}`)) { |
|
|
|
jifenData[`pos${itemW}${i}`]++ |
|
|
|
} else { |
|
|
|
jifenData[`pos${itemW}${i}`] = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
if (Number(itemn) !== Number(this.newItem[`pos${l + 1}`])) { |
|
|
|
if (jifenData.hasOwnProperty(`pos${j}${i}`)) { |
|
|
|
jifenData[`pos${j}${i}`]++ |
|
|
|
} else { |
|
|
|
jifenData[`pos${j}${i}`] = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return jifenData |
|
|
|
}, |
|
|
|
changejifen(val) { |
|
|
|
this.newItem = { ..._.cloneDeep(_.filter(this.addTableData, (item) => item.xiangmu === val)[0]) } |
|
|
|
}, |
|
|
|
addNewData() { |
|
|
|
this.dialogFormData.show = true |
|
|
|
this.dialogFormData.title = "新增项目号码" |
|
|
|
this.dialogFormData.posInput = "" |
|
|
|
}, |
|
|
|
closeDialog() { |
|
|
|
this.dialogFormData.show = false |
|
|
|
this.dialogFormData.title = "" |
|
|
|
this.dialogFormData.posInput = "" |
|
|
|
}, |
|
|
|
submitDialog() { |
|
|
|
let posValue = _.uniq(_.compact(_.split(this.dialogFormData.posInput, /[,,]/))) |
|
|
|
let posValueObj = {} |
|
|
|
for (let i = 0; i < posValue.length; i++) { |
|
|
|
let ele = posValue[i]; |
|
|
|
posValueObj[`pos${i + 1}`] = ele |
|
|
|
} |
|
|
|
this.addTableData.push({ |
|
|
|
xiangmu: this.dialogFormData.xiangmu, |
|
|
|
maxing: _.sortBy(this.dialogFormData.maxing), |
|
|
|
...posValueObj |
|
|
|
}) |
|
|
|
this.closeDialog() |
|
|
|
}, |
|
|
|
saveData() { |
|
|
|
localStorage.setItem('addTableData', JSON.stringify(this.addTableData)) |
|
|
|
ElMessage.success('保存成功') |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
</script> |
|
|
|
<style scoped> |
|
|
@ -191,7 +455,9 @@ export default { |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.alignCenter { |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.leftThird { |
|
|
|