Browse Source

10.22

master
lichong 5 months ago
parent
commit
c4e4e1125e
  1. 2
      package.json
  2. 2
      src/renderer/src/assets/js/db.js
  3. 8
      src/renderer/src/assets/json/chufang.json
  4. 34
      src/renderer/src/components/formcomponent.vue
  5. 2
      src/renderer/src/views/chufang.vue

2
package.json

@ -1,6 +1,6 @@
{
"name": "electron",
"version": "1.0.1",
"version": "1.0.3",
"description": "An Electron application with Vue",
"main": "./out/main/index.js",
"author": "lichong",

2
src/renderer/src/assets/js/db.js

@ -4,5 +4,5 @@ export const myDatabase = new Dexie('myDatabase');
// 定义数据库版本
myDatabase.version(1).stores({
chufang: '++id, xingming, chufang, shetai, create_at, update_at',
chufang: '++id, xingming, chufang, shetai, note, create_at, update_at',
});

8
src/renderer/src/assets/json/chufang.json

@ -23,6 +23,14 @@
"tableShow": true,
"formShow": true
},
{
"label": "备注",
"prop": "note",
"type": "textarea",
"isSort": false,
"tableShow": true,
"formShow": true
},
{
"label": "创建时间",
"prop": "create_at",

34
src/renderer/src/components/formcomponent.vue

@ -1,12 +1,12 @@
<template>
<div class="tableClass">
<el-form :model="formData" label-suffix="" :disabled="disabled" inline @submit.prevent>
<el-form :model="formData" label-suffix="" :disabled="disabled" @submit.prevent>
<el-row>
<el-col :key="formIndex" v-for="(formItem, formIndex) in formHeader"
:span="['text', 'date'].includes(formItem.type) ? 24 : 12">
:span="['text', 'date', 'textarea'].includes(formItem.type) ? 24 : 12">
<el-form-item :label="formItem.label">
<template v-if="formItem.type === 'text'">
<el-input v-model="formData[formItem.prop]" />
<template v-if="['text', 'textarea'].includes(formItem.type)">
<el-input v-model="formData[formItem.prop]" :type="formItem.type" autosize style="width: 80%;" />
</template>
<template v-else-if="formItem.type === 'date'">
<el-date-picker v-model="formData[formItem.prop]" type="date"
@ -17,7 +17,7 @@
<div v-if="!disabled">
<el-row>
<el-col :span="12">
<button @click="openVedio(formItem)">打开视频</button>
<button @click="openVedio(formItem)">打开摄像头</button>
</el-col>
<el-col :span="12">
<button @click="takePhoto(formItem)">拍照</button>
@ -85,15 +85,23 @@ export default {
},
methods: {
async openVedio(formItem) {
this.formData[formItem.prop] = ""
let stream = await navigator.mediaDevices.getUserMedia({
video: {
width: { ideal: 200 },
height: { ideal: 200 }
},
try {
this.formData[formItem.prop] = ""
let stream = await navigator.mediaDevices.getUserMedia({
video: {
width: { ideal: 200 },
height: { ideal: 200 }
},
});
this.$refs[`${formItem.prop}video`][0].srcObject = stream;
});
this.$refs[`${formItem.prop}video`][0].srcObject = stream;
} catch (e) {
ElMessage({
type: 'error',
message: '摄像头权限被禁止,请打开摄像头权限',
})
return
}
},
takePhoto(formItem) {
let video = this.$refs[`${formItem.prop}video`][0]

2
src/renderer/src/views/chufang.vue

@ -42,7 +42,7 @@
@info="info" @del="del" ref="tableComponentRef" @headerSort="headerSort">
</tablecomponent>
</div>
<el-dialog v-model="dialogFrom.visible" :title="dialogFrom.title" width="80%">
<el-dialog v-model="dialogFrom.visible" :title="dialogFrom.title" width="80%" :close-on-click-modal="false">
<formcomponent :formHeader="dialogFrom.formHeader" :formData="dialogFrom.formData"
:disabled="dialogFrom.disabled">
</formcomponent>

Loading…
Cancel
Save