Browse Source

2244

master
lichong 7 months ago
parent
commit
c567e9c3de
  1. 2
      front/src/main/index.js
  2. 26
      front/src/renderer/src/components/tablecomponent.vue
  3. 86
      front/src/renderer/src/views/user.vue

2
front/src/main/index.js

@ -11,7 +11,7 @@ let mainWindow
function createWindow() {
mainWindow = new BrowserWindow({
minWidth: 1366,
minHeight: 684,
minHeight: 763,
show: false,
autoHideMenuBar: true,
icon: logoIcon,

26
front/src/renderer/src/components/tablecomponent.vue

@ -1,6 +1,6 @@
<template>
<div class="tableClass">
<el-table :data="tableData" height="calc(100vh - 91px)" border @select="selectChange" @select-all="selectChange" fit
<el-table :data="tableData" height="calc(100vh - 96px)" border @select="selectChange" @select-all="selectChange" fit
:row-key="getRowKeys" ref="tableRef">
<el-table-column type="selection" width="50" :reserve-selection="true" fixed="left">
</el-table-column>
@ -45,9 +45,8 @@
</el-table-column>
</el-table>
<el-pagination style="margin:8px 0 0 0;place-content:center;" v-model:current-page="currentPage"
v-model:page-size="pageSize" :total="total" @size-change="handleSizeChange"
layout="total, sizes, prev, pager, next, jumper" :page-sizes="pageSizes" @current-change="handleCurrentChange"
@prev-click="handleCurrentChange" @next-click="handleCurrentChange"></el-pagination>
v-model:page-size="pageSize" :total="total" layout="total, sizes, prev, pager, next, jumper"
:page-sizes="pageSizes"></el-pagination>
</div>
</template>
@ -75,7 +74,7 @@ export default {
pageSizes: {
type: Array,
default: () => {
return [16, 50, 100, 200]
return [12, 50, 100, 200]
}
},
total: {
@ -91,7 +90,7 @@ export default {
_: _,
dayjs: dayjs,
currentPage: 1,
pageSize: 16,
pageSize: 12,
}
},
methods: {
@ -116,7 +115,20 @@ export default {
}
},
async mounted() { },
watch: {},
watch: {
currentPage: {
handler(val) {
this.$emit("handleCurrentChange", val)
},
immediate: true
},
pageSize: {
handler(val) {
this.$emit("handleSizeChange", val)
},
immediate: true
},
},
computed: {}
}
</script>

86
front/src/renderer/src/views/user.vue

@ -7,6 +7,12 @@
</el-icon>
<span>新增</span>
</el-button>
<el-button type="primary" @click="exportData">
<el-icon>
<Download />
</el-icon>
<span>导出</span>
</el-button>
<el-button type="danger" @click="deleteData(selectionData)" :disabled="selectionData.length == 0">
<el-icon>
<Delete />
@ -48,6 +54,20 @@
</template>
</el-input>
</div>
<div class="inputClass">
<el-radio-group v-model="modelType">
<el-radio value="simple" size="large">
<el-tooltip effect="dark" content="识别速度快,但是准确率稍低,建议一次识别多张图片" placement="top">
<span>简单模型</span>
</el-tooltip>
</el-radio>
<el-radio value="complex" size="large">
<el-tooltip effect="dark" content="识别速度慢,但是准确率稍高,建议一次识别一张图片" placement="top">
<span>复杂模型</span>
</el-tooltip>
</el-radio>
</el-radio-group>
</div>
</div>
<div>
<tablecomponent :tableHeader="tableHeader" :tableData="tableData" :pageSizes="pageSizes" :total="total"
@ -71,13 +91,13 @@
<script>
import _ from 'lodash'
import * as XLSX from 'xlsx';
import tableHeaderLocal from '../assets/json/user.json'
import { myDatabase } from '../assets/js/db.js'
import dayjs from 'dayjs'
import tablecomponent from "../components/tablecomponent.vue"
import formcomponent from "../components/formcomponent.vue"
import { ElMessage, ElMessageBox } from 'element-plus'
import { set } from 'lodash'
export default {
name: 'user',
components: { tablecomponent, formcomponent },
@ -89,8 +109,8 @@ export default {
formHeader: [],
tableData: [],
currentPage: 1,
pageSize: 16,
pageSizes: [16, 50, 100, 200],
pageSize: 12,
pageSizes: [12, 50, 100, 200],
total: 0,
searchParams: {
Name: ""
@ -106,6 +126,7 @@ export default {
fileOriData: [],
displayedMessages: [],//
pngCount: 0,
modelType: "simple"
}
},
methods: {
@ -128,7 +149,7 @@ export default {
async successSubmit(opts) {
this.pngCount++
if (this.pngCount === 1) {
ElMessage.info({
ElMessage.success({
message: `识别图片中请稍后`,
duration: 0
})
@ -141,7 +162,7 @@ export default {
let base64Data = fileReader.result;
let params = {
base64Str: base64Data,
ocrType: "simple",//:complex_simple_
ocrType: that.modelType,//:complex_simple_
}
window.electron.ipcRenderer.send('ocrIdentify', params)
}
@ -154,18 +175,18 @@ export default {
initInfo() {
let that = this
window.electron.ipcRenderer.on('ocrResult', (eve, res) => {
console.log(7411, res)
ElMessage.closeAll()
if (res.hasError) {
ElMessage.info({
ElMessage.error({
message: `倒数第${that.pngCount}张图片识别失败`,
duration: 0
})
} else {
ElMessage.info({
message: `正在识别倒数第${that.pngCount - 1}张图片,请稍后`,
duration: 0
})
ElMessage.warning(
{
message: `正在识别倒数第${that.pngCount - 1}张图片,请稍后`,
duration: 0
});
let tableItem = _.get(res, ['resultsObj'], {})
myDatabase.users.add({ ...tableItem, create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss') })
}
@ -185,11 +206,15 @@ export default {
//
async updateSeach(params = {}) {
let userList = []
let totalList = 0
if (params.Name) {
userList = await myDatabase.users.where('Name').anyPass(user => user.includes(params.Name)).offset(this.currentPage - 1).limit(this.pageSize).toArray()
userList = await myDatabase.users.where('Name').anyPass(user => user.includes(params.Name)).offset((this.currentPage - 1) * this.pageSize).limit(this.pageSize).toArray()
totalList = await myDatabase.users.where('Name').anyPass(user => user.includes(params.Name)).toArray()
} else {
userList = await myDatabase.users.offset(this.currentPage - 1).limit(this.pageSize).toArray()
userList = await myDatabase.users.offset((this.currentPage - 1) * this.pageSize).limit(this.pageSize).toArray()
totalList = await myDatabase.users.toArray()
}
this.total = totalList.length
this.tableData = _.cloneDeep(userList)
},
//
@ -211,6 +236,7 @@ export default {
},
//
async handleSizeChange(pageSize) {
this.currentPage = 1
this.pageSize = pageSize
await this.searchData()
},
@ -227,7 +253,6 @@ export default {
//
async submitDialog() {
let postMethod = ["add", "put"]
console.log(7411, postMethod, this.dialogFrom.type, this.dialogFrom.formData)
if (this.dialogFrom.type === "add") {
myDatabase.users[this.dialogFrom.type]({ ...this.dialogFrom.formData, create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss') })
} else if (this.dialogFrom.type === "put") {
@ -310,7 +335,6 @@ export default {
await this.searchData()
})
.catch(() => {
console.log(333)
ElMessage({
type: 'info',
message: '取消删除',
@ -341,6 +365,38 @@ export default {
})
})
},
//
async exportData() {
let listCopy = _.cloneDeep(this.selectionData)
if (!listCopy.length) {
listCopy = await myDatabase.users.toArray()
}
let lilstLocal = []
if (listCopy.length) {
for (let i = 0; i < listCopy.length; i++) {
let item = listCopy[i];
let listItem = {}
for (let j = 0; j < tableHeaderLocal.length; j++) {
let headerItem = tableHeaderLocal[j];
listItem[headerItem.label] = item[headerItem.prop]
}
lilstLocal.push(listItem)
}
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")}.xls`);
} else {
ElMessage({
type: 'error',
message: '当前无数据,请输入数据后导出',
})
}
}
},
async mounted() {
this.tableHeader = _.filter(tableHeaderLocal, o => o.tableShow)

Loading…
Cancel
Save