lrf 7 mēneši atpakaļ
vecāks
revīzija
65400dbd71

+ 1 - 1
.env.development

@@ -8,7 +8,7 @@ VITE_APP_PORT = 3000
 
 # 代理前缀
 VITE_APP_BASE_API = '/cxyy/api'
-
+VITE_APP_ES_API = '/cxyy/es'
 VITE_APP_HOST = ""
 VITE_BASE_URL = "/cxyyAdmin"
 VITE_OUT_DIR = "cxyyAdmin"

+ 1 - 1
.env.production

@@ -7,7 +7,7 @@ VITE_APP_PORT = 3000
 VITE_USE_CRYPTO = false
 # 代理前缀
 VITE_APP_BASE_API = '/cxyy/api'
-
+VITE_APP_ES_API = '/cxyy/es'
 VITE_APP_HOST = ""
 
 VITE_BASE_URL = "/cxyyAdmin"

+ 1 - 1
src/components/custom/custom-table.vue

@@ -1,7 +1,7 @@
 <template>
   <el-row>
     <el-col>
-      <el-table :data="data" border :height="height" @selection-change="toSelect">
+      <el-table :data="data" border :height="height" @selection-change="toSelect" stripe>
         <el-table-column type="selection" width="55" v-if="select"> </el-table-column>
         <template v-for="f in fields" :key="f.model">
           <el-table-column v-if="f.custom" :label="f.label" :prop="f.model" align="center" v-bind="f.options">

+ 15 - 0
src/store/api/esDict.js

@@ -0,0 +1,15 @@
+import { defineStore } from 'pinia'
+import { AxiosWrapper } from '@/utils/axios-wrapper'
+const url = '/dict'
+const axios = new AxiosWrapper({ baseUrl: import.meta.env.VITE_APP_ES_API })
+export const EsDictStore = defineStore('esDict', () => {
+  const getDict = async (payload) => {
+    const res = await axios.$get(`${url}`)
+    return res
+  }
+  const updateDict = async (payload) => {
+    const res = await axios.$post(`${url}`, { data: payload })
+    return res
+  }
+  return { getDict, updateDict }
+})

+ 1 - 0
src/views/platform/index.vue

@@ -25,6 +25,7 @@ const componentList = ref({
   tags: defineAsyncComponent(() => import('./parts/tags.vue')),
   sector: defineAsyncComponent(() => import('./parts/sector.vue')),
   friend: defineAsyncComponent(() => import('./parts/friend.vue')),
+  'es-dict': defineAsyncComponent(() => import('./parts/es-dict.vue')),
   import: defineAsyncComponent(() => import('./parts/import.vue'))
 })
 const value = ref()

+ 65 - 0
src/views/platform/parts/es-dict.vue

@@ -0,0 +1,65 @@
+<template>
+  <div id="es-dict">
+    <el-row justify="space-between" style="margin-bottom:10px">
+      <el-col :span="6" style="text-align: left">
+        <el-button type="success" @click="toSave">保存</el-button>
+      </el-col>
+      <el-col :span="6" style="text-align: right">
+        <el-button type="primary" @click="toAdd">添加字典</el-button>
+      </el-col>
+    </el-row>
+    <el-row>
+      <el-col :span="24">
+        <el-table :data="data" height="70vh" border stripe>
+          <el-table-column align="center" label="字典项">
+            <template #default="{ row }">{{ row }}</template>
+          </el-table-column>
+          <el-table-column align="center" label="操作" width="150px">
+            <template #default="{ $index }">
+              <el-button text type="danger" @click="toDelete($index)">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script setup>
+const $checkRes = inject('$checkRes')
+import { get, cloneDeep } from 'lodash-es'
+import { EsDictStore } from '@/store/api/esDict'
+const store = EsDictStore()
+const data = ref([])
+const search = async () => {
+  const result = await store.getDict()
+  if ($checkRes(result)) {
+    data.value = get(result, 'data', [])
+  }
+}
+const toAdd = () =>{
+  ElMessageBox.prompt('请填写字典项', '添加字典项', {
+    confirmButtonText: '确认',
+    cancelButtonText: '取消',
+  })
+    .then(({ value }) => {
+      data.value.push(value)
+    })
+    .catch(() => {
+    })
+}
+const toDelete = (index) => {
+  data.value.splice(index, 1)
+}
+const toSave = async () => {
+  const updateData = cloneDeep(data.value)
+  const result = store.updateDict(updateData)
+  if ($checkRes(result, true, result.errmsg)) {
+    search()
+  }
+}
+onMounted(() => {
+  search()
+})
+</script>
+<style scoped></style>

+ 4 - 0
vite.config.js

@@ -42,6 +42,10 @@ export default defineConfig(({ mode }) => {
         [env.VITE_APP_BASE_API]: {
           changeOrigin: true,
           target: 'http://127.0.0.1:19700'
+        },
+        [env.VITE_APP_ES_API]: {
+          changeOrigin: true,
+          target: 'http://127.0.0.1:19700'
         }
       }
     },