diff --git a/backend/defConfig/configTemp.yaml b/backend/defConfig/configTemp.yaml index a366bef..e4a00f2 100644 --- a/backend/defConfig/configTemp.yaml +++ b/backend/defConfig/configTemp.yaml @@ -8,7 +8,7 @@ web: certPublicPath: "" database: - type: "sqlite" # mysql or sqlite + type: "sqlite" # mysql pg or sqlite path: "data/database.db" # sqlite path host: "" # mysql host port: "" diff --git a/backend/go.mod b/backend/go.mod index 0f811f3..8829787 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -22,6 +22,10 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/goccy/go-yaml v1.18.0 // indirect github.com/google/uuid v1.3.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect + github.com/jackc/pgx/v5 v5.6.0 // indirect + github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -48,6 +52,7 @@ require ( golang.org/x/tools v0.34.0 // indirect google.golang.org/protobuf v1.36.9 // indirect gorm.io/driver/mysql v1.6.0 // indirect + gorm.io/driver/postgres v1.6.0 // indirect gorm.io/gorm v1.31.0 // indirect modernc.org/libc v1.22.5 // indirect modernc.org/mathutil v1.5.0 // indirect diff --git a/backend/go.sum b/backend/go.sum index 06c3242..ea8c2d0 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -35,6 +35,14 @@ github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7Lk github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= +github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= +github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= @@ -67,6 +75,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -100,6 +109,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg= gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo= +gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4= +gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo= gorm.io/gorm v1.31.0 h1:0VlycGreVhK7RF/Bwt51Fk8v0xLiiiFdbGDPIZQ7mJY= gorm.io/gorm v1.31.0/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs= modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE= diff --git a/backend/models/sql.go b/backend/models/sql.go index 06a29cc..4b3e41e 100644 --- a/backend/models/sql.go +++ b/backend/models/sql.go @@ -6,6 +6,7 @@ import ( "github.com/glebarez/sqlite" "gorm.io/driver/mysql" + "gorm.io/driver/postgres" "gorm.io/gorm" ) @@ -102,7 +103,13 @@ func DatabaseInit() error { fmt.Println("mysql") dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", DatabaseConfigs["user"].(string), DatabaseConfigs["pass"].(string), DatabaseConfigs["host"].(string), DatabaseConfigs["port"].(string), DatabaseConfigs["name"].(string)) DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{}) + } else if DatabaseConfigs["type"].(string) == "pg" { + //postgresql init + fmt.Println("postgresql") + dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Shanghai", DatabaseConfigs["host"].(string), DatabaseConfigs["user"].(string), DatabaseConfigs["pass"].(string), DatabaseConfigs["name"].(string), DatabaseConfigs["port"].(string)) + DB, err = gorm.Open(postgres.Open(dsn), &gorm.Config{}) } + if err != nil { fmt.Println(err) panic("数据库连接失败") diff --git a/frontent/ops_vue_js/src/components/HeardMain.vue b/frontent/ops_vue_js/src/components/HeardMain.vue index c9370a7..c39b319 100644 --- a/frontent/ops_vue_js/src/components/HeardMain.vue +++ b/frontent/ops_vue_js/src/components/HeardMain.vue @@ -292,6 +292,15 @@ onMounted(() => { {{ t("appname.schedule") }} + + + {{ t("appname.purchase") }} + +
diff --git a/frontent/ops_vue_js/src/i18n/en.json b/frontent/ops_vue_js/src/i18n/en.json index e12ed9b..8b409cd 100644 --- a/frontent/ops_vue_js/src/i18n/en.json +++ b/frontent/ops_vue_js/src/i18n/en.json @@ -4,7 +4,27 @@ "login": "Login", "forgot_password": "Forgot Password", "register": "Register", - "schedule":"Schedule" + "schedule":"Schedule", + "purchase":"Purchase" + }, + "schedule": { + "my_schedule":"My Schedule", + "add_event":"Add Event", + "event_title":"Event Title", + "event_date":"Event Date", + "event_time":"Event Time", + "event_description":"Event Description", + "save_event":"Save Event", + "no_events":"No events found", + "delete_event":"Delete Event", + "edit_event":"Edit Event", + "tody":"Today", + "week":"This Week", + "month":"This Month", + "previous_month":"Prev Month", + "next_month":"Next Month", + "previous_year":"Prev Year", + "next_year":"Next Year" }, "message": { "functionality_not_yet_developed":"Functionality not yet developed", diff --git a/frontent/ops_vue_js/src/i18n/zh-CN.json b/frontent/ops_vue_js/src/i18n/zh-CN.json index ef8901a..9650513 100644 --- a/frontent/ops_vue_js/src/i18n/zh-CN.json +++ b/frontent/ops_vue_js/src/i18n/zh-CN.json @@ -4,7 +4,27 @@ "login": "登录", "forgot_password": "忘记密码", "register": "注册", - "schedule":"日程" + "schedule":"日程", + "purchase":"采购" + }, + "schedule": { + "my_schedule":"我的日程", + "add_event":"添加事件", + "event_title":"事件标题", + "event_date":"事件日期", + "event_time":"事件时间", + "event_description":"事件描述", + "save_event":"保存事件", + "no_events":"没有找到事件", + "delete_event":"删除事件", + "edit_event":"编辑事件", + "tody":"今天", + "week":"本周", + "month":"本月", + "previous_month":"上月", + "next_month":"下月", + "previous_year":"上年", + "next_year":"下年" }, "message": { "functionality_not_yet_developed":"功能未开发", diff --git a/frontent/ops_vue_js/src/router/index.js b/frontent/ops_vue_js/src/router/index.js index 4254213..503c659 100644 --- a/frontent/ops_vue_js/src/router/index.js +++ b/frontent/ops_vue_js/src/router/index.js @@ -56,6 +56,11 @@ const router = createRouter({ name: "schedule", component: () => import("../views/scheduleView.vue"), }, + { + path: "/purchase", + name: "purchase", + component: () => import("../views/purchaseView.vue"), + } ], }); diff --git a/frontent/ops_vue_js/src/views/purchaseView.vue b/frontent/ops_vue_js/src/views/purchaseView.vue new file mode 100644 index 0000000..f60370f --- /dev/null +++ b/frontent/ops_vue_js/src/views/purchaseView.vue @@ -0,0 +1,164 @@ + diff --git a/frontent/ops_vue_js/src/views/scheduleView.vue b/frontent/ops_vue_js/src/views/scheduleView.vue index f42aa60..87204cd 100644 --- a/frontent/ops_vue_js/src/views/scheduleView.vue +++ b/frontent/ops_vue_js/src/views/scheduleView.vue @@ -3,13 +3,16 @@ import FullCalendar from "@fullcalendar/vue3"; import dayGridPlugin from "@fullcalendar/daygrid"; import timeGridPlugin from "@fullcalendar/timegrid"; import interactionPlugin from "@fullcalendar/interaction"; //拖动插件 需要用npm安装 -import listPlugin from '@fullcalendar/list'; +import listPlugin from "@fullcalendar/list"; import { onMounted, watch, ref } from "vue"; import { useI18n } from "vue-i18n"; const { t, locale } = useI18n(); +const calendar = ref(null); + + const calendarOptions = ref({ height: "auto", locale: locale.value, @@ -25,7 +28,7 @@ const calendarOptions = ref({ editable: true, selectable: true, firstDay: 1, - + dayCellDidMount(info) { switch (info.dow) { case 0: @@ -42,12 +45,54 @@ const calendarOptions = ref({ info.el.style.border = "1px solid #4b4b4b"; // 浅蓝色边框 }, + headerToolbar: { + left: "prevYearCustom,prevMonthCustom,todayCustom,nextMonthCustom,nextYearCustom", + center: "title", + right: "", //,timeGridWeek,timeGridDay' + }, + + // 自定义按钮 + customButtons: { + prevYearCustom: { + text: t('schedule.previous_year'), + click: function () { + calendar.value.getApi().prevYear(); + }, + }, + nextYearCustom: { + text: t('schedule.next_year'), + click: function () { + calendar.value.getApi().nextYear(); + }, + }, + prevMonthCustom: { + text: t('schedule.previous_month'), + click: function () { + calendar.value.getApi().prev(); + }, + }, + nextMonthCustom: { + text: t('schedule.next_month'), + click: function () { + calendar.value.getApi().next(); + }, + }, + todayCustom: { + text: t('schedule.month'), + click: function () { + calendar.value.getApi().today(); + }, + }, + }, events: [ { title: "事件 1", start: "2025-11-10" }, { title: "事件 2", start: "2025-11-15", end: "2024-06-17" }, - { title: "事件 3", start: "2025-11-20T10:30:00", end: "2024-06-20T12:30:00" }, - + { + title: "事件 3", + start: "2025-11-20T10:30:00", + end: "2024-06-20T12:30:00", + }, ], }); @@ -59,6 +104,13 @@ function functionupdataTitle() { watch(locale, () => { functionupdataTitle(); calendarOptions.value.locale = locale.value; + + // 更新自定义按钮文本 + calendarOptions.value.customButtons.prevYearCustom.text = t('schedule.previous_year'); + calendarOptions.value.customButtons.nextYearCustom.text = t('schedule.next_year'); + calendarOptions.value.customButtons.prevMonthCustom.text = t('schedule.previous_month'); + calendarOptions.value.customButtons.nextMonthCustom.text = t('schedule.next_month'); + calendarOptions.value.customButtons.todayCustom.text = t('schedule.month'); }); onMounted(() => { @@ -66,5 +118,17 @@ onMounted(() => { }); + + +