|
|
@ -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) |
|
|
|