From 3bf466d098b415a5473b056b1746b586279e34ec Mon Sep 17 00:00:00 2001
From: chenbo <709206448@qq.com>
Date: Fri, 15 Dec 2023 15:17:06 +0800
Subject: [PATCH] =?UTF-8?q?add=20=E4=BA=A7=E5=93=81=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?=E4=BA=A7=E5=93=81=E4=BB=8B=E7=BB=8D=E5=92=8C=E4=BA=A7=E5=93=81?=
=?UTF-8?q?=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin/src/config/index.ts | 4 +-
admin/src/main.ts | 2 +
admin/src/views/product/edit.vue | 86 ++++++++++++++++++++++--
app/adminapi/logic/land/ProductLogic.php | 4 ++
4 files changed, 91 insertions(+), 5 deletions(-)
diff --git a/admin/src/config/index.ts b/admin/src/config/index.ts
index 10bbb3da..285f76b1 100644
--- a/admin/src/config/index.ts
+++ b/admin/src/config/index.ts
@@ -2,7 +2,9 @@ const config = {
terminal: 1, //终端
title: '后台管理系统', //网站默认标题
version: '1.6.0', //版本号
- baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名
+ baseUrl: `${
+ import.meta.env.VITE_APP_BASE_URL
+ }/`, //请求接口域名
// baseUrl: 'http://127.0.0.1:30005/',
urlPrefix: 'adminapi', //请求默认前缀
timeout: 10 * 1000 //请求超时时长
diff --git a/admin/src/main.ts b/admin/src/main.ts
index ab8bc4c7..6368ff73 100644
--- a/admin/src/main.ts
+++ b/admin/src/main.ts
@@ -4,7 +4,9 @@ import install from './install'
import './permission'
import './styles/index.scss'
import 'virtual:svg-icons-register'
+import configs from './config/index'
const app = createApp(App)
app.use(install)
+app.provide('base_url', configs.baseUrl+configs.urlPrefix);
app.mount('#app')
diff --git a/admin/src/views/product/edit.vue b/admin/src/views/product/edit.vue
index f368682a..da8fa7ed 100644
--- a/admin/src/views/product/edit.vue
+++ b/admin/src/views/product/edit.vue
@@ -15,6 +15,33 @@
+
+
+
+
+
+
+
+
+
+
import { useDictOptions } from '@/hooks/useDictOptions'
-import type { FormInstance } from 'element-plus'
+import { type FormInstance,
+ type UploadProps,
+ ElMessage,
+ } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiProductAdd, apiProductEdit, apiProductDetail, getUserList, getUserInfo, apiLandLists } from '@/api/product'
import { timeFormat } from '@/utils/util'
-
+import useUserStore from "@/stores/modules/user";
import type { PropType } from 'vue'
+import {ref} from "vue";
+import config from "@/config";
defineProps({
dictData: {
type: Object as PropType>,
default: () => ({})
}
})
+
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef()
const popupRef = shallowRef>()
const mode = ref('add')
-
-
+const acceptFileTypes = ref(".png, .jpg, .jpeg, image/png, image/jpeg")
+const action = ref(`${config.baseUrl}${config.urlPrefix}/upload/image`)
+const userStore = useUserStore()
+const handleAvatarSuccessAvatar: UploadProps["onSuccess"] = (
+ response,
+ uploadFile
+) => {
+ if (response.code == 0) {
+ ElMessage.error(response.msg);
+ return;
+ }
+ formData.image = response.data.uri;
+};
// 弹窗标题
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑产品' : '新增产品'
@@ -90,6 +134,8 @@ const formData = reactive({
land_id: '',
code: '',
name: '',
+ desc: '',
+ image: '',
status: '',
})
@@ -213,3 +259,35 @@ defineExpose({
getDetail
})
+
+
+
\ No newline at end of file
diff --git a/app/adminapi/logic/land/ProductLogic.php b/app/adminapi/logic/land/ProductLogic.php
index b2930e91..71fbb75e 100644
--- a/app/adminapi/logic/land/ProductLogic.php
+++ b/app/adminapi/logic/land/ProductLogic.php
@@ -56,6 +56,8 @@ class ProductLogic extends BaseLogic
'user_id' => $userId,
'code' => $params['code'],
'name' => $params['name'],
+ 'desc' => $params['desc'],
+ 'image' => $params['image'],
'status' => $status,
]);
if (!empty($params['land_id'])) {
@@ -103,6 +105,8 @@ class ProductLogic extends BaseLogic
'user_id' => $userId,
'code' => $params['code'],
'name' => $params['name'],
+ 'desc' => $params['desc'],
+ 'image' => $params['image'],
'status' => $status,
]);
if (!empty($params['land_id'])) {