15 changed files with 136 additions and 485 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,90 @@ |
|||
[ |
|||
{ |
|||
"label": "货号", |
|||
"prop": "货号", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "品名", |
|||
"prop": "品名", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "供应商名称", |
|||
"prop": "供应商名称", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "销售数量", |
|||
"prop": "销售数量", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "销售金额", |
|||
"prop": "销售金额", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "退货数量", |
|||
"prop": "退货数量", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "退货金额", |
|||
"prop": "退货金额", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "数量小计", |
|||
"prop": "数量小计", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "金额小计", |
|||
"prop": "金额小计", |
|||
"type": "text", |
|||
"isSort": true, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "创建时间", |
|||
"prop": "create_at", |
|||
"type": "date", |
|||
"isSort": false, |
|||
"tableShow": false, |
|||
"formShow": false |
|||
}, |
|||
{ |
|||
"label": "更新时间", |
|||
"prop": "update_at", |
|||
"type": "date", |
|||
"isSort": false, |
|||
"tableShow": false, |
|||
"formShow": false |
|||
} |
|||
] |
@ -1,42 +0,0 @@ |
|||
[ |
|||
{ |
|||
"label": "名称", |
|||
"prop": "name", |
|||
"type": "text", |
|||
"isSort": false, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "数据堆", |
|||
"prop": "data", |
|||
"type": "textarea", |
|||
"isSort": false, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "备注", |
|||
"prop": "note", |
|||
"type": "textarea", |
|||
"isSort": false, |
|||
"tableShow": true, |
|||
"formShow": true |
|||
}, |
|||
{ |
|||
"label": "创建时间", |
|||
"prop": "create_at", |
|||
"type": "date", |
|||
"isSort": false, |
|||
"tableShow": false, |
|||
"formShow": false |
|||
}, |
|||
{ |
|||
"label": "更新时间", |
|||
"prop": "update_at", |
|||
"type": "date", |
|||
"isSort": false, |
|||
"tableShow": false, |
|||
"formShow": false |
|||
} |
|||
] |
@ -1,267 +0,0 @@ |
|||
<template> |
|||
<div class="rightClass"> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="12"> |
|||
<el-input v-model="dataInput" minlength="5" maxlength="5" placeholder="请输入数字" clearable show-word-limit /> |
|||
</el-col> |
|||
<el-col :span="8"> |
|||
<el-button type="primary" @click="calNumber">计算</el-button> |
|||
<el-button type="primary" @click="clearNumber">清空</el-button> |
|||
</el-col> |
|||
<!-- <el-col :span="24" style="margin-top: 8px;"> |
|||
<el-row> |
|||
<el-col :span="4">输入随机数: </el-col> |
|||
<el-col :span="20"> |
|||
<el-input v-model="genDataStr" disabled /> |
|||
</el-col> |
|||
</el-row> |
|||
</el-col> |
|||
<el-col :span="24" style="margin-top: 8px;"> |
|||
<el-row> |
|||
<el-col :span="4">输入随机数记录:</el-col> |
|||
<el-col :span="20"> |
|||
<el-input v-model="genDataHistoryStr" disabled :autosize="{ minRows: 2, maxRows: 8 }" type="textarea" |
|||
id="textareaInput" /> |
|||
</el-col> |
|||
</el-row> |
|||
</el-col> --> |
|||
</el-row> |
|||
<el-row style="height: calc(100vh - 50px);overflow-y: auto;display: block;"> |
|||
<el-col v-for="(item, index) in calList" :key="index" style="margin: 8px 0;"> |
|||
{{ _.join(_.map(item.data, o => (o.name + "共" + o.num + "次")), "、") }}{{ item.str }} |
|||
</el-col> |
|||
</el-row> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import _ from 'lodash' |
|||
import { myDatabase } from '../assets/js/db.js' |
|||
import dayjs from 'dayjs' |
|||
import { ElMessage, ElMessageBox } from 'element-plus' |
|||
export default { |
|||
name: 'shujucal', |
|||
components: {}, |
|||
watch: {}, |
|||
computed: {}, |
|||
data() { |
|||
return { |
|||
_: _, |
|||
dayjs: dayjs, |
|||
dataInput: "", |
|||
dataInputLIst: [], |
|||
allList: [], |
|||
calList: [], |
|||
genDataStr: "", |
|||
genDataHistoryStr: "", |
|||
} |
|||
}, |
|||
methods: { |
|||
async getDataList() { |
|||
let allData = await myDatabase.shujudui.toArray() |
|||
let allList = [] |
|||
for (let i = 0; i < allData.length; i++) { |
|||
let element = allData[i]; |
|||
let elementList = element.data.split(/[,,\s+]/) |
|||
elementList = _.compact(_.uniq(elementList)) |
|||
allList.push({ |
|||
id: element.id, |
|||
name: element.name, |
|||
data: elementList, |
|||
note: element.note, |
|||
create_at: element.create_at, |
|||
update_at: element.update_at, |
|||
}) |
|||
} |
|||
this.allList = allList |
|||
}, |
|||
async calNumber() { |
|||
await this.getDataList() |
|||
if (!this.dataInput) { |
|||
ElMessage({ |
|||
type: "error", |
|||
message: "请输入数字" |
|||
}) |
|||
return |
|||
} |
|||
if (_.isEmpty(this.allList)) { |
|||
ElMessage({ |
|||
type: "error", |
|||
message: "请先设置数据" |
|||
}) |
|||
return |
|||
} |
|||
this.dataInputLIst.push(this.dataInput) |
|||
let newList = [] |
|||
let list = ["万", "千", "百", "十", "个"] |
|||
for (let s = 0; s < this.dataInputLIst.length; s++) { |
|||
let dataInputItem = this.dataInputLIst[s]; |
|||
let currentList = dataInputItem.split("") |
|||
for (let i = 0; i < currentList.length; i++) { |
|||
for (let j = i + 1; j < currentList.length; j++) { |
|||
newList.push({ |
|||
num: `${currentList[i]}${currentList[j]}`, |
|||
lable: `${list[i]}${list[j]}`, |
|||
numlable: `${list[i]}${list[j]}` |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
let newListTemp = JSON.parse(JSON.stringify(newList)) |
|||
let newListTempLocal = [] |
|||
for (let i = 0; i < newListTemp.length; i++) { |
|||
// let element = newListTemp[i]; |
|||
let element = {} |
|||
for (let s = this.allList.length - 1; s >= 0; s--) { |
|||
let item = JSON.parse(JSON.stringify(this.allList[s])) |
|||
element["numlable"] = newListTemp[i].numlable |
|||
element["num"] = newListTemp[i].num |
|||
element["id"] = item.id |
|||
element["name"] = item.name |
|||
element["data"] = [...item.data] |
|||
element["dataStr"] = item.data.join("_") |
|||
element["dataStrFirstGroup"] = `${item.data.join("_")}${newListTemp[i].numlable}` |
|||
element["note"] = item.note |
|||
element["create_at"] = item.create_at |
|||
element["update_at"] = item.update_at |
|||
if (_.includes(item.data, element.num)) { |
|||
element["has"] = true |
|||
} else { |
|||
element["has"] = false |
|||
} |
|||
newListTempLocal.push({ ...element }) |
|||
} |
|||
} |
|||
let groupName = _.groupBy(newListTempLocal, "dataStrFirstGroup") |
|||
let newLIstTemp = [] |
|||
for (let key in groupName) { |
|||
let value = groupName[key] |
|||
let filterData = _.filter(value.slice(value.length - 5), { has: true }) |
|||
if (filterData.length === 0) { |
|||
newLIstTemp = newLIstTemp.concat(value) |
|||
} |
|||
} |
|||
let allGroup = _.groupBy(newLIstTemp, "dataStr") |
|||
let allListTemp = [] |
|||
for (let key in allGroup) { |
|||
let value = allGroup[key] |
|||
let perGroup = _.groupBy(value, "numlable") |
|||
let textObj = { |
|||
data: [], |
|||
str: "" |
|||
} |
|||
for (let key1 in perGroup) { |
|||
let element = perGroup[key1]; |
|||
let has = _.get(element, [element.length - 1, "has"], false) || _.get(element, [element.length - 2, "has"], false) || _.get(element, [element.length - 3, "has"], false) || _.get(element, [element.length - 4, "has"], false) || _.get(element, [element.length - 5, "has"], false) |
|||
let hasIndex = _.findLastIndex(element, { has: true }) |
|||
textObj.data.push({ |
|||
name: key1, |
|||
has: has, |
|||
num: element.length - hasIndex - 1 |
|||
}) |
|||
} |
|||
textObj.str = value[0].data.join(" ") |
|||
allListTemp.push(textObj) |
|||
} |
|||
let allListGroup = _.groupBy(allListTemp, "str") |
|||
this.calList = [] |
|||
for (let key in allListGroup) { |
|||
let value = allListGroup[key]; |
|||
let mergedData = []; |
|||
for (let i = 0; i < value.length; i++) { |
|||
let valueItem = value[i]; |
|||
for (let j = 0; j < valueItem.data.length; j++) { |
|||
let dataItem = valueItem.data[j]; |
|||
let mergedDataTemp = _.cloneDeep(mergedData) |
|||
let findItem = _.find(mergedDataTemp, item => item.name === dataItem.name) |
|||
if (findItem) { |
|||
findItem.num++ |
|||
if (dataItem.has) { |
|||
findItem.num = 0 |
|||
} |
|||
} else { |
|||
mergedData.push(dataItem) |
|||
} |
|||
} |
|||
} |
|||
mergedData = _.filter(mergedData, o => o.num > 5) |
|||
if (mergedData.length) { |
|||
this.calList.push({ |
|||
data: mergedData, |
|||
str: key |
|||
}) |
|||
} |
|||
} |
|||
for (let i = 0; i < this.calList.length; i++) { |
|||
let element = this.calList[i]; |
|||
let eleItem = _.find(this.allList, { str: element.data }) |
|||
if (eleItem) { |
|||
element["id"] = eleItem.id |
|||
} |
|||
} |
|||
this.calList = _.sortBy(this.calList, "id").reverse() |
|||
this.genData() |
|||
// this.genDataHistory() |
|||
}, |
|||
clearNumber() { |
|||
this.dataInput = "" |
|||
this.dataInputLIst = [] |
|||
this.calList = [] |
|||
this.genData() |
|||
// this.genDataHistory() |
|||
}, |
|||
genData() { |
|||
let newList = "" |
|||
for (let i = 0; i < this.dataInput.length; i++) { |
|||
for (let j = i + 1; j < this.dataInput.length; j++) { |
|||
newList += `${this.dataInput[i]}${this.dataInput[j]} ` |
|||
} |
|||
} |
|||
this.genDataStr = newList |
|||
}, |
|||
genDataHistory() { |
|||
let that = this |
|||
let item = "" |
|||
for (let s = 0; s < this.dataInputLIst.length; s++) { |
|||
let dataInputItem = this.dataInputLIst[s]; |
|||
let currentList = dataInputItem.split("") |
|||
item += `${s + 1}: ` |
|||
for (let i = 0; i < currentList.length; i++) { |
|||
for (let j = i + 1; j < currentList.length; j++) { |
|||
item += `${currentList[i]}${currentList[j]} ` |
|||
} |
|||
} |
|||
item += `\n` |
|||
} |
|||
this.genDataHistoryStr = item |
|||
let textareaItem = document.getElementById("textareaInput"); |
|||
textareaItem.scrollTop = textareaItem.scrollHeight |
|||
} |
|||
}, |
|||
async mounted() { |
|||
|
|||
}, |
|||
} |
|||
</script> |
|||
<style scoped> |
|||
.rightClass { |
|||
padding: 8px; |
|||
} |
|||
|
|||
.uploadClass { |
|||
top: 3px; |
|||
} |
|||
|
|||
.inputClass { |
|||
display: inline-block; |
|||
margin: 0 8px; |
|||
position: relative; |
|||
} |
|||
|
|||
.tagClass { |
|||
display: inline-block; |
|||
margin: 0 8px; |
|||
width: 200px; |
|||
position: relative; |
|||
} |
|||
</style> |
Loading…
Reference in new issue