浏览代码

配置文件修改

tongshangming 3 年之前
父节点
当前提交
49f9313a4b
共有 7 个文件被更改,包括 70 次插入36 次删除
  1. 6 0
      .editorconfig
  2. 4 0
      .env.development
  3. 4 0
      .env.production
  4. 1 0
      src/components/ProTable.vue
  5. 0 1
      src/components/form/DialogForm.vue
  6. 20 2
      src/components/form/FormComp.vue
  7. 35 33
      vite.config.ts

+ 6 - 0
.editorconfig

@@ -0,0 +1,6 @@
+[*]
+charset=utf-8
+end_of_line=lf
+insert_final_newline=false
+indent_style=space
+indent_size=2

+ 4 - 0
.env.development

@@ -0,0 +1,4 @@
+NODE_ENV = 'development'
+
+VITE_BASE_API = /apiSys
+VITE_BASE_PATH = http://10.0.0.39:8080

+ 4 - 0
.env.production

@@ -0,0 +1,4 @@
+NODE_ENV = 'production'
+
+VITE_BASE_API = /apiSys
+VITE_BASE_PATH = 

+ 1 - 0
src/components/ProTable.vue

@@ -182,6 +182,7 @@ defineExpose({
         <el-form-item :label="item.label" v-for="(item, index) in searchList" :key="index">
           <form-comp :item="item" v-model="query[item.name]"></form-comp>
         </el-form-item>
+        <slot name="query" :query="query"></slot>
         <el-form-item>
           <el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
           <el-button icon="Refresh" @click="handleReset">重置</el-button>

+ 0 - 1
src/components/form/DialogForm.vue

@@ -17,7 +17,6 @@ const emits = defineEmits(['update:modelValue', 'success'])
 
 const formInitData = ref({})
 watchEffect(() => {
-  console.log(props.formData)
   formInitData.value = props.formData
 })
 

+ 20 - 2
src/components/form/FormComp.vue

@@ -1,6 +1,8 @@
 <!-- eslint-disable vue/no-mutating-props -->
 <script setup lang="ts">
 import type { BasicFormItem } from '@/types/form'
+import type { UploadProps } from 'element-plus'
+import { useUserStore } from '@/stores/user'
 
 interface Props {
   modelValue: any
@@ -9,6 +11,7 @@ interface Props {
 
 const props = defineProps<Props>()
 const emits = defineEmits(['update:modelValue'])
+const baseApi = import.meta.env.VITE_BASE_API
 
 const modelValue = computed({
   get: () => props.modelValue,
@@ -16,12 +19,21 @@ const modelValue = computed({
 })
 
 const placeholder = (item: BasicFormItem) => {
-  if (['select'].includes(item.type)) {
+  if (['select', 'cascader'].includes(item.type)) {
     return '请选择' + item.label
   } else {
     return '请输入' + item.label
   }
 }
+
+const user = useUserStore()
+const headers = reactive({
+  access_token: user.token
+})
+// 图片上传
+const handleUploadSuccess: UploadProps['onSuccess'] = response => {
+  modelValue.value = import.meta.env.VITE_BASE_PATH + response.data
+}
 </script>
 
 <template>
@@ -32,7 +44,13 @@ const placeholder = (item: BasicFormItem) => {
     v-bind="item.props"
     :placeholder="item.placeholder || placeholder(item)"
   />
-  <el-upload class="avatar-uploader" v-model="modelValue" v-bind="item.props" v-else-if="item.type === 'upload'">
+  <el-upload
+    v-else-if="item.type === 'upload'"
+    :on-success="handleUploadSuccess"
+    :action="baseApi + '/file/upload'"
+    :headers="headers"
+    v-bind="item.props"
+  >
     <img v-if="modelValue" :src="modelValue" class="avatar" />
     <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
   </el-upload>

+ 35 - 33
vite.config.ts

@@ -1,7 +1,7 @@
 import { fileURLToPath, URL } from 'node:url'
 import path from 'path'
 
-import { defineConfig } from 'vite'
+import { defineConfig, loadEnv } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import vueJsx from '@vitejs/plugin-vue-jsx'
 import AutoImport from 'unplugin-auto-import/vite'
@@ -10,38 +10,40 @@ import DefineOptions from 'unplugin-vue-define-options/vite'
 import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
 import Unocss from 'unocss/vite'
 
-// https://vitejs.dev/config/
-export default defineConfig({
-  plugins: [
-    vue(),
-    vueJsx(),
-    Unocss(),
-    DefineOptions(),
-    AutoImport({
-      imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
-      dts: 'src/auto-import.d.ts'
-    }),
-    Components({
-      dirs: ['src/components'],
-      extensions: ['vue'],
-      dts: 'src/components.d.ts'
-    }),
-    createSvgIconsPlugin({
-      iconDirs: [path.resolve(process.cwd(), 'src/assets/svg')],
-      symbolId: 'icon-[dir]-[name]'
-    })
-  ],
-  resolve: {
-    alias: {
-      '@': fileURLToPath(new URL('./src', import.meta.url))
-    }
-  },
-  server: {
-    proxy: {
-      '/apiSys': {
-        // target: 'https://yunji.sxidc.com',
-        target: 'http://10.0.0.33:8080/',
-        changeOrigin: true
+export default defineConfig(({ mode }) => {
+  const env = loadEnv(mode, process.cwd(), '')
+  return {
+    plugins: [
+      vue(),
+      vueJsx(),
+      Unocss(),
+      DefineOptions(),
+      AutoImport({
+        imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
+        dts: 'src/auto-import.d.ts'
+      }),
+      Components({
+        dirs: ['src/components'],
+        extensions: ['vue'],
+        dts: 'src/components.d.ts'
+      }),
+      createSvgIconsPlugin({
+        iconDirs: [path.resolve(process.cwd(), 'src/assets/svg')],
+        symbolId: 'icon-[dir]-[name]'
+      })
+    ],
+    resolve: {
+      alias: {
+        '@': fileURLToPath(new URL('./src', import.meta.url))
+      }
+    },
+    server: {
+      proxy: {
+        [env.VITE_BASE_API]: {
+          // target: 'https://yunji.sxidc.com',
+          target: env.VITE_BASE_PATH,
+          changeOrigin: true
+        }
       }
     }
   }