From f7e6014b0bad0d9f99846ac7719eac0b7274493e Mon Sep 17 00:00:00 2001 From: funjia <13429193897@163.com> Date: Fri, 9 May 2025 01:25:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E8=A7=86=E5=9B=BE=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +- src/containers/viewModel/Record.ts | 183 +++++++++++++++++++++++++ src/containers/viewModel/RecordUser.ts | 130 ++++++++++++++++++ src/views/DataDict.vue | 2 +- src/views/Notice.vue | 2 +- src/views/QA.vue | 2 +- vite.config.ts | 3 +- yarn.lock | 8 +- 8 files changed, 324 insertions(+), 10 deletions(-) create mode 100644 src/containers/viewModel/Record.ts create mode 100644 src/containers/viewModel/RecordUser.ts diff --git a/package.json b/package.json index 7a0c846..fd014f9 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "codemirror": "^6.0.1", "dayjs": "^1.10.7", "element-plus": "2.1.10", - "funjialib": "git+http://git.funjia.top/funjia/FunJiaLib_Package.git#v1.1.0", - "funjiaui": "git+http://git.funjia.top/funjia/FunjiaUI_Vue.git#v1.1.2", + "funjialib": "git+http://git.funjia.top/funjia/FunJiaLib_Package.git", + "funjiaui": "git+http://git.funjia.top/funjia/FunjiaUI_Vue.git#v1.1.3", "funjia-axios": "git+http://git.funjia.top/funjia/funjia-axios.git#v1.0.0", "html-print-element": "^0.0.5", "html2pdf.js": "^0.10.2", diff --git a/src/containers/viewModel/Record.ts b/src/containers/viewModel/Record.ts new file mode 100644 index 0000000..d7cfc73 --- /dev/null +++ b/src/containers/viewModel/Record.ts @@ -0,0 +1,183 @@ + +import 'reflect-metadata'; +import { + TableColumnPropertyDecorator as tcpd, + TableFormColumnPropertyDecorator as tfcpd, + TableColumnMethodDecorator as tcmd, TOperateType, + TableSearchFormPropertyDecorator as tsfpd +} from "@/components/UmTable"; +import * as api from "@/common/api" +import UmTableForm from '@/components/UmTable/UmTableForm.vue'; +import { ElMessage } from 'element-plus' +import { isEmpty } from 'marsLib/is'; +import { fDT } from 'marsLib/date'; +import { h } from 'vue'; +import { RECORD_URL } from "@/consts/dataDict"; +import { env } from 'process'; + +const tableName = "record"; + +const isShow = (rowData: any) => { + if (rowData?.source_add_type == "1") { + return true; + } else { + return false; + } +} + +export default class Record { + // 侵入性事件注入 + static singleListen: any = null + + static isEdit = false; + + // 操作列宽度 + static operateWidth = "140px"; + + @tfcpd({ "lang": "", "def": "id", fieldType: "primaryKey" }) + id: number = 0; + + questionId: string = "" + + @tcpd({ "lang": "", "def": "问题", minWidth: 120 }) + @tfcpd({ "lang": "", "def": "问题", fieldType: "string", rule: [{ "type": "require", message: "不能为空" }] }) + question: string = "" + + @tcpd({ "lang": "", "def": "回答", minWidth: 120 }) + @tfcpd({ "lang": "", "def": "回答", fieldType: "string", rule: [{ "type": "require", message: "不能为空" }] }) + answer: string = "" + + @tcpd({ "lang": "", "def": "提交者", minWidth: 120 }) + @tfcpd({ "lang": "", "def": "提交者", fieldType: "string", rule: [{ "type": "require", message: "不能为空" }] }) + submit: string = "" + + @tcmd({ "key": "table:searchFormMethod", "value": { "type": "getList", "es": "onAfter" } }) + getList = async (params: any) => { + return await api.getDynamicList(params, tableName); + } + + @tcmd({ + "key": "table:toolbar", "value": { + "type": "添加", "priority": 1, "es": "onAfter", "dialogContent": UmTableForm, "dialogTitle": "增加", "dialogWidth": 650 + } + }) + onAdd = async (data: any) => { + const { code, msg } = await api.addDynamic({ ...data }, tableName); + if (code != 0) { + return { code: 1, message: msg }; + } + else { + return { code: 0 }; + } + } + + /** + * 获取详情数据 + */ + @tcmd({ "value": { "type": "edit", "es": "onBefore", "dialogContent": UmTableForm, "dialogTitle": "编辑" } }) + getDetail = async (rowId: number, r, meta) => { + const { data } = await api.getDynamic({ id: rowId }, tableName); + return data; + } + + + @tcmd({ + "value": { + "type": "edit", "es": "onAfter", + sort: 2, + // isShow + } + }) + onEdit = async (params: any) => { + const { code, msg } = await api.updateDynamic({ ...params }, tableName); + if (code != 0) { + return { code: 1, message: msg }; + } + else { + return { code: 0 }; + } + } + + @tcmd({ + "value": { + "type": "del", "es": "onAfter", "dialogContent": "确定要删除该条数据吗?", + sort: 3, + // isShow + } + }) + delByIds = async (rowId: number) => { + const { code, msg } = await api.deleteDynamic({ ids: [rowId] }, tableName); + if (code != 0) { + return { code: 1, message: msg }; + } + else { + return { code: 0 }; + } + } + + @tcmd({ "key": "table:toolbar", "value": { "type": "批量删除", "priority": 5, "es": "onAfter", "dialogContent": "确定要删除选择的数据吗?" } }) + onMutilDel = async (ids: any[]) => { + const { code, msg } = await api.deleteDynamic({ ids }, tableName); + if (code != 0) { + return { code: 1, message: msg }; + } + else { + return { code: 0 }; + } + } + + exportText(filename, text) { + var element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); + element.setAttribute('download', filename); + + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } + + @tcmd({ + "key": "table:toolbar", "value": { + "type": "自定义", id: "anki", "priority": 1, "es": "onAfter", title: "导出anki脚本" + } + }) + onExport = async (params: any) => { + const { data } = await api.getQAList({ ...params, page: 1, pageSize: 10000 }); + const { data: dataDict } = await api.getDynamic({ id: RECORD_URL }, "dataDict"); + + + + const head = `#separator:tab +#html:true +#tags column:3 +` + const style = ``; + + const content = data.map(item => { + return `"${style}
" "${style}
"`; + }).join("\n") + + this.exportText("anki脚本.txt", head + content); + return true; + } + + // @tcmd({ + // "value": { + // "id": 1, "type": "customOperateEvent", "title": "详情", + // sort: 1, + // isShow: (rowData) => { + // if (rowData?.snaper_image > 0) { + // return true; + // } else { + // return false; + // } + // } + // } + // }) + // jumpEmployee = (rowId: number) => { + // return rowId; + // } +} \ No newline at end of file diff --git a/src/containers/viewModel/RecordUser.ts b/src/containers/viewModel/RecordUser.ts new file mode 100644 index 0000000..a19c932 --- /dev/null +++ b/src/containers/viewModel/RecordUser.ts @@ -0,0 +1,130 @@ + +import 'reflect-metadata'; +import { + TableColumnPropertyDecorator as tcpd, + TableFormColumnPropertyDecorator as tfcpd, + TableColumnMethodDecorator as tcmd, TOperateType, + TableSearchFormPropertyDecorator as tsfpd +} from "@/components/UmTable"; +import * as api from "@/common/api" +import UmTableForm from '@/components/UmTable/UmTableForm.vue'; +import { ElMessage } from 'element-plus' +import { isEmpty } from 'marsLib/is'; +import { fDT } from 'marsLib/date'; +import { h } from 'vue'; + +const tableName = "recordUser"; + +const isShow = (rowData: any) => { + if (rowData?.source_add_type == "1") { + return true; + } else { + return false; + } +} + +export default class RecordUser { + // 侵入性事件注入 + static singleListen: any = null + + static isEdit = false; + + // 操作列宽度 + static operateWidth = "140px"; + + @tfcpd({ "lang": "", "def": "id", fieldType: "primaryKey" }) + id: number = 0; + + @tcpd({ "lang": "", "def": "名称", minWidth: 120 }) + @tfcpd({ "lang": "", "def": "名称", fieldType: "string", rule: [{ "type": "require", message: "不能为空" }] }) + name: string = "" + + @tcpd({ "lang": "", "def": "指纹", minWidth: 120 }) + @tfcpd({ "lang": "", "def": "指纹", fieldType: "string", rule: [{ "type": "require", message: "不能为空" }] }) + fingerprint: string = "" + + @tcpd({ "lang": "", "def": "设备", minWidth: 120 }) + @tfcpd({ "lang": "", "def": "设备", fieldType: "string"}) + device: string = "" + + @tcmd({ "key": "table:searchFormMethod", "value": { "type": "getList", "es": "onAfter" } }) + getList = async (params: any) => { + return await api.getDynamicList(params, tableName); + } + + @tcmd({ + "key": "table:toolbar", "value": { + "type": "添加", "priority": 1, "es": "onAfter", "dialogContent": UmTableForm, "dialogTitle": "增加", "dialogWidth": 650 + } + }) + onAdd = async (data: any) => { + const { code, msg } = await api.addDynamic({ ...data }, tableName); + if (code != 0) { + return { code: 1, message: msg }; + } + else { + return { code: 0 }; + } + } + + /** + * 获取详情数据 + */ + @tcmd({ "value": { "type": "edit", "es": "onBefore", "dialogContent": UmTableForm, "dialogTitle": "编辑" } }) + getDetail = async (rowId: number, r, meta) => { + const { data } = await api.getDynamic({ id: rowId }, tableName); + return data; + } + + + @tcmd({ + "value": { + "type": "edit", "es": "onAfter", + sort: 2, + // isShow + } + }) + onEdit = async (params: any) => { + const { code, msg } = await api.updateDynamic({ ...params }, tableName); + if (code != 0) { + return { code: 1, message: msg }; + } + else { + return { code: 0 }; + } + } + + @tcmd({ + "value": { + "type": "del", "es": "onAfter", "dialogContent": "确定要删除该条数据吗?", + sort: 3, + // isShow + } + }) + delByIds = async (rowId: number) => { + const { code, msg } = await api.deleteDynamic({ ids: [rowId] }, tableName); + if (code != 0) { + return { code: 1, message: msg }; + } + else { + return { code: 0 }; + } + } + + // @tcmd({ + // "value": { + // "id": 1, "type": "customOperateEvent", "title": "详情", + // sort: 1, + // isShow: (rowData) => { + // if (rowData?.snaper_image > 0) { + // return true; + // } else { + // return false; + // } + // } + // } + // }) + // jumpEmployee = (rowId: number) => { + // return rowId; + // } +} \ No newline at end of file diff --git a/src/views/DataDict.vue b/src/views/DataDict.vue index 49494cb..661db01 100644 --- a/src/views/DataDict.vue +++ b/src/views/DataDict.vue @@ -13,7 +13,7 @@ import { UmByClassEnhance as UmTableClassEnhance } from "funjiaui"; import Record from "@/containers/viewModel/DataDict"; import ImgPreview from "@/components/ImgPreview.vue"; import { ref, reactive, watch } from "vue"; -import CaptureList from "@/containers/CaptureList.vue"; +// import CaptureList from "@/containers/CaptureList.vue"; import { useAppStore } from "@/store/app"; const visible = ref(false); diff --git a/src/views/Notice.vue b/src/views/Notice.vue index 49641dd..aa01ff3 100644 --- a/src/views/Notice.vue +++ b/src/views/Notice.vue @@ -16,7 +16,7 @@ import ImgPreview from "@/components/ImgPreview.vue"; import { ref, reactive, watch } from "vue"; import * as api from "@/common/api"; // import { fDT } from "marsLib/date"; -import CaptureList from "@/containers/CaptureList.vue"; +// import CaptureList from "@/containers/CaptureList.vue"; import { useAppStore } from "@/store/app"; const visible = ref(false); diff --git a/src/views/QA.vue b/src/views/QA.vue index a08a25a..bfc51dd 100644 --- a/src/views/QA.vue +++ b/src/views/QA.vue @@ -15,7 +15,7 @@ import QA from "@/containers/viewModel/QA"; import { ref, reactive, watch } from "vue"; import * as api from "@/common/api"; // import { fDT } from "marsLib/date"; -import CaptureList from "@/containers/CaptureList.vue"; +// import CaptureList from "@/containers/CaptureList.vue"; // import "funjiaui/style.css"; const visible = ref(false); diff --git a/vite.config.ts b/vite.config.ts index 06ccd2c..c5c71f0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -23,7 +23,8 @@ export default defineConfig({ host: "0.0.0.0", proxy: { "^/api": { - target: "http://localhost:4873/", + // target: "http://localhost:4873/", + target: "http://all.funjia.top/", changeOrigin: true, }, "^/static": { diff --git a/yarn.lock b/yarn.lock index f6dbd39..ec2faec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1273,9 +1273,9 @@ function-bind@^1.1.2: resolved "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== -"funjia-axios@git+http://git.funjia.top/funjia/funjia-axios.git": +"funjia-axios@git+http://git.funjia.top/funjia/funjia-axios.git#v1.0.0": version "0.0.1" - resolved "git+http://git.funjia.top/funjia/funjia-axios.git#b76323800995e88c6fcd3ede5a87ff62f0ff0a9d" + resolved "git+http://git.funjia.top/funjia/funjia-axios.git#cde7b6f0c3c83e3d13efb71f1966661c03a8bf70" dependencies: axios "^0.26.1" js-cookie "^3.0.1" @@ -1284,9 +1284,9 @@ function-bind@^1.1.2: version "1.0.0" resolved "git+http://git.funjia.top/funjia/FunJiaLib_Package.git#07908bb596bb21750d0298460df12ba963a70fa6" -"funjiaui@git+http://git.funjia.top/funjia/FunjiaUI_Vue.git#v1.1.2": +"funjiaui@git+http://git.funjia.top/funjia/FunjiaUI_Vue.git#v1.1.3": version "1.1.0" - resolved "git+http://git.funjia.top/funjia/FunjiaUI_Vue.git#503af87b2b4d35728f8a8f8aeb7029c2cbf246c5" + resolved "git+http://git.funjia.top/funjia/FunjiaUI_Vue.git#bb50f43c9c224f93d99ecfb240f08237e1fe7f58" dependencies: "@codemirror/lang-javascript" "^6.1.7" "@kousum/vue3-window" "^0.0.3"