浏览代码

实现用户绑定

songxy 1 月之前
父节点
当前提交
8e4fa2bb47

+ 1 - 0
ais_search_jx/public/config.js

@@ -44,6 +44,7 @@
       '1': 10,
       '2': 15,
     },
+    baseApi: '/baseApi',
     // server: 'https://zdzy.zrzyt.zj.gov.cn/aisKnowledge',
     server: '/server',
     authServer: '/auth',

+ 2 - 90
ais_search_jx/src/App.vue

@@ -32,104 +32,16 @@ const route = useRoute();
 const router = useRouter();
 const foundHandle = () => {
   router.push({
-    name: '404'
+    name: 'AdminLogin'
   })
 }
-const ticketStr = ref()
 const getUrlParamByToken = () => {
-  if (!window?.AppGlobalConfig?.authorization?.enabled) return;
   const routePath = route.path
   if (routePath.indexOf('404') !== -1) { return }
   const isLogin = getLocalStorageWithExpiry("_isLogin")
   if(isLogin === '1') return
-  var urlStr = window.location.href
-  var arr = urlStr.split('?')
-  if (arr.length === 1) {
-    foundHandle()
-    return
-  }
-
-  var paramStr = arr[1]
-  var paramArr = paramStr.split('&')
-  var paramMap = {}
-  paramArr.forEach(item => {
-    var arr = item.split('=')
-    paramMap[arr[0]] = arr[1]
-  })
-  if (paramMap["debugger"] == "1") {
-      return;
-  }
-  if (!paramMap.hasOwnProperty('sykjzlptv2_ticket')) {
-    foundHandle()
-    return
-  }
-  ticketStr.value = paramMap['sykjzlptv2_ticket']
-  const storeTicketStr = localStorage.getItem('_sykjzlptv2_ticket')
-  if (storeTicketStr) {
-    if (storeTicketStr === paramMap['sykjzlptv2_ticket']) {
-      return
-    }
-  }
-  localStorage.removeItem('sykjzlptv2_ticket')
-  getCommonToken()
-}
-const getCommonToken = async () => {
-  if (!ticketStr.value) { return }
-  const urlApi = `/auth/ticket`
-  var p = { ticket: ticketStr.value };
-  http.get(urlApi, p, this, false).then(async (resultData) => {
-    if (!resultData || resultData['error_code']) {
-      message.error('用户不合法,请核实用户信息!')
-      foundHandle()
-      return
-    }
-    if (resultData['error']) {
-      message.error(resultData['error'])
-      foundHandle()
-      return
-    }
-    if(resultData['syUser']){
-      const syUserObj = resultData["syUser"];
-      store.updateUser({
-        syUser: syUserObj
-      })
-      getByUser(syUserObj['UserName'], syUserObj['Id'])
-      setLocalStorageWithExpiry("_isLogin", "1", 3600000 * window?.AppGlobalConfig?.authorization?.time);
-      localStorage.setItem("_sykjzlptv2_ticket", ticketStr.value);
-    }
-  });
-}
-const getByUser = (userName='zjszrzyhghj-sxy', userId = '31fdcf79-ea83-4888-bbb2-06f2b7ba8b0b') => {
-  const urlStr = `/ai/knowledge/vector/get-by-user`
-  http.get(urlStr, {
-    userId: userId
-  }).then((result) => {
-    const resultData = result.data;
-    if (!resultData) {
-      vectorCreate(userName, userId);
-    } else {
-      store.updateVectorId(resultData)
-      localStorage.setItem('_vectorId', resultData)
-    }
-  })
-}
-const vectorCreate = (userName, userId) => {
-  return;
-  const urlStr = `/ai/knowledge/vector/create`
-  http.post(urlStr, {
-    id: userName,
-    userId: userId
-  }).then((result) => {
-    const resultData = result.data;
-    console.log("resultData--------------------")
-    console.log(resultData)
-    if (resultData) {
-      store.updateVectorId(resultData)
-      localStorage.setItem('_vectorId', resultData)
-    }
-  })
+  foundHandle()
 }
-getByUser();
 getUrlParamByToken()
 </script>
 

+ 12 - 0
ais_search_jx/src/router/routes.js

@@ -25,6 +25,18 @@ export default [
           },
         ]
       },
+      {
+        path: 'adminLogin',
+        name: 'AdminLogin',
+        meta: { title: '后台管理系统登录' },
+        component: () => import('@/views/admin/login.vue'),
+      },
+      {
+        path: 'usemanagement',
+        name: 'UseManagement',
+        meta: { title: '用户管理' },
+        component: () => import('@/views/admin/usemanagement.vue'),
+      },
       {
         path: 'ai-search',
         name: 'AiSearch',

+ 98 - 0
ais_search_jx/src/views/admin/login.vue

@@ -0,0 +1,98 @@
+<template>
+  <div class="adminLogin_box">
+    <div class="container">
+      <div class="top">欢迎登录</div>
+      <div class="form_box">
+        <div class="form_input">
+          <input type="text" v-model="formData.username" placeholder="请输入用户名"/>
+        </div>
+        <div class="form_input">
+          <input type="password" v-model="formData.password" placeholder="请输入密码" />
+        </div>
+        <div class="btn">
+          <a-button type="primary" block :loading="loading" @click="onLoginSubmit">登录</a-button>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script setup>
+import axios from "axios";
+import { message } from "ant-design-vue";
+import { useUserStore } from '@/stores';
+import { setLocalStorageWithExpiry } from '@/utils/store.js'
+
+const store = useUserStore();
+const router = useRouter();
+const formData = ref({
+  username: '',
+  password: ''
+})
+const loading = ref(false)
+const onLoginSubmit = () => {
+  const urlStr = "/baseApi/auth/login"
+  const sendData = {
+    ...formData.value
+  }
+  loading.value = true
+  axios.post(urlStr, sendData).then((result) => {
+    const resultData = result.data
+    loading.value = false
+    if (resultData['data']) {
+      store.updateUser({
+        syUser: {
+          Id: resultData['data']['userId']
+        }
+      })
+      setLocalStorageWithExpiry("_isLogin", "1", 3600000 * window?.AppGlobalConfig?.authorization?.time);
+      router.push({
+        name: 'Index'
+      })
+    } else {
+      message.error("登录失败,请稍后重试!");
+    }
+  });
+}
+</script>
+
+<style lang="scss" scoped>
+.adminLogin_box {
+  width: 100%;
+  height: 100%;
+  background: #f0f9ff;
+  position: relative;
+  >.container {
+    width: 480px;
+    border: 1px solid #eee;
+    background: #fff;
+    border-radius: 5px;
+    position: absolute;
+    left: 0px;
+    right: 0px;
+    margin: auto;
+    top: 40%;
+    transform: translateY(-50%);
+    padding: 20px;
+    >.top {
+      font-size: 28px;
+    }
+    >.form_box {
+      margin-top: 30px;
+      >.form_input {
+        border: 1px solid #dcdfe6;
+        padding: 8px 10px;
+        margin-bottom: 20px;
+        border-radius: 4px;
+        >input {
+          width: 100%;
+          border: 0px;
+          outline: none;
+          padding: 0px;
+          color: #666;
+        }
+      }
+    }
+  }
+}
+</style>

+ 240 - 0
ais_search_jx/src/views/admin/usemanagement.vue

@@ -0,0 +1,240 @@
+<template>
+  <div class="adminLogin_box">
+    <div class="top_box">
+      <a-button type="primary" @click="onEditorHandle('add')">新增</a-button>
+    </div>
+    <div class="table_box">
+      <a-table :dataSource="dataSource" :columns="columns" bordered :pagination="false">
+        <template #bodyCell="{ column, text, index, record }">
+          <template v-if="column.dataIndex === 'index'">
+            <div>{{ index + 1 }}</div>
+          </template>
+          <template v-if="column.dataIndex === 'operation'">
+            <div>
+              <span style="margin-right: 10px;">
+                <a-button type="primary" size="small" @click="onEditorHandle('edit', record)">编辑</a-button>
+              </span>
+              <span style="margin-right: 10px;">
+                <a-button size="small" @click="onEditorHandle('edit-pwd', record)">重置密码</a-button>
+              </span>
+              <span>
+                <a-popconfirm title="确定删除该用户?" @confirm="onDeleteHandle(record)">
+                  <a-button type="primary" danger size="small">删除</a-button>
+                </a-popconfirm>
+              </span>
+            </div>
+          </template>
+        </template>
+      </a-table>
+      <div class="pagination">
+        <a-pagination v-model:current="PageParam['pageNo']" :pageSize="PageParam['pageSize']" :total="PageParam['total']" show-quick-jumper @change="onPaginationHandle" />
+      </div>
+    </div>
+    <a-modal v-model:open="open" :title="modalType === 'add' ? '新增账户' : '编辑账户'" @ok="onSubmitHandle" >
+      <a-form
+        ref="formRef"
+        :model="formData"
+        :rules="rules"
+        :label-col="{ span: 4 }"
+        :wrapper-col="{ span: 20 }"
+        autocomplete="off"
+      >
+       <a-form-item
+          label="昵称"
+          v-if="['add', 'edit'].includes(modalType)"
+          name="nickname"
+        >
+          <a-input v-model:value="formData.nickname" />
+        </a-form-item>
+
+       <a-form-item
+          label="账号"
+          v-if="['add', 'edit'].includes(modalType)"
+          name="username"
+        >
+          <a-input v-model:value="formData.username" />
+        </a-form-item>
+
+        <a-form-item
+          label="密码"
+          v-if="['add', 'edit-pwd'].includes(modalType)"
+          name="password"
+        >
+          <a-input-password v-model:value="formData.password" />
+        </a-form-item>
+      </a-form>
+    </a-modal>
+  </div>
+</template>
+
+<script setup>
+import axios from "axios";
+import { message } from "ant-design-vue";
+
+defineOptions({
+  name: 'UserManagement'
+})
+const columns = ref([
+  {
+    title: '序号',
+    dataIndex: 'index',
+    key: 'index',
+    width: 100,
+    align: 'center'
+  },
+  {
+    title: '账号',
+    dataIndex: 'username',
+    key: 'username',
+  },
+  {
+    title: '用户昵称',
+    dataIndex: 'nickname',
+    key: 'nickname',
+  },
+  {
+    title: '操作',
+    dataIndex: 'operation',
+    width: '280px'
+  },
+])
+
+const dataSource = ref([]);
+const PageParam = ref({
+  pageNo: 1,
+  pageSize: 10,
+  total: 0
+})
+
+const queryTableByPage = () => {
+  const urlStr = "/baseApi/system/user/page"
+  const sendData = {
+    ...PageParam.value
+  }
+  axios.get(urlStr, sendData).then((result) => {
+    const resultData = result.data.data;
+    if (resultData) {
+      dataSource.value = resultData.list
+      PageParam.value.pageNo = resultData.total
+    }
+  });
+}
+queryTableByPage()
+
+const onPaginationHandle = (page) => {
+  PageParam.value.pageNo = page
+  queryTableByPage()
+}
+/**
+ * 新增、编辑、删除
+ * */
+const formRef = ref(null)
+const modalType = ref('add');
+const open = ref(false)
+const onEditorHandle = (type, item)=>{
+  modalType.value = type
+  open.value = true
+  formData.value = {
+    id: '',
+    nickname: '',
+    username: '',
+    password: ''
+  }
+  if(item){
+    formData.value = {
+      id: item['id'],
+      nickname: item['nickname'],
+      username: item['username'],
+      password: item['password']
+    };
+  }
+}
+const rules = {
+  nickname: [{ required: true, message: '昵称不能为空!' }],
+  username: [{ required: true, message: '账号不能为空!' }],
+  password: [{ required: true, message: '密码不能为空!' }]
+}
+const formData = ref({
+  id: '',
+  nickname: '',
+  username: '',
+  password: ''
+})
+const onSubmitHandle = ()=>{
+  formRef.value
+  .validate()
+  .then(() => {
+    if(modalType.value === 'edit-pwd'){
+      onUpdatePwdHandle();
+      return;
+    }
+    const sendData = {
+      ...formData.value
+    }
+    const urlStr = modalType.value === 'add' ? '/baseApi/system/user/create' : '/baseApi/system/user/update'
+    axios.post(urlStr, sendData).then((result) => {
+      const resultData = result.data;
+      if(resultData.data){
+        message.success("提交成功")
+        open.value = false
+        onPaginationHandle()
+      }
+    });
+  })
+  .catch(error => {
+    console.log('error', error);
+  });
+}
+const onUpdatePwdHandle = ()=>{
+  formRef.value
+  .validate()
+  .then(() => {
+    const sendData = {
+      ...formData.value
+    }
+    const urlStr =  '/baseApi/system/user/update-password'
+    axios.post(urlStr, sendData).then((result) => {
+      const resultData = result.data;
+      if(resultData.data){
+        message.success("密码重置成功")
+        onPaginationHandle(1)
+      }
+    });
+  })
+  .catch(error => {
+    console.log('error', error);
+  });
+}
+const onDeleteHandle = (item) => {
+  const urlStr = `/baseApi/system/user/delete?id=${item['id']}`
+  axios.get(urlStr).then((result) => {
+    const resultData = result.data;
+    if(resultData.data){
+      message.success("删除成功")
+      onPaginationHandle(1)
+    }
+  });
+}
+</script>
+
+<style lang="scss" scoped>
+.adminLogin_box {
+  width: 100%;
+  height: 100%;
+  background: #fff;
+  position: relative;
+  padding: 20px;
+  >.top_box {
+    margin-bottom: 10px;
+  }
+  >.table_box {
+    height: calc(100% - 60px);
+    display: flex;
+    flex-direction: column;
+    >.pagination {
+      margin-top: 20px;
+      text-align: right;
+    }
+  }
+}
+</style>

+ 2 - 2
ais_search_jx/src/views/home/components/HomeHeader.vue

@@ -6,8 +6,8 @@
         <div class="title">{{ subTitle }}</div>
       </div>
     </div>
-    <div class="right user-panel" v-if="syUser['Name']">
-      {{syUser['Name']}}
+    <div class="right user-panel" v-if="syUser['nickname']">
+      {{syUser['nickname']}}
     </div>
   </div>
 </template>

+ 7 - 0
ais_search_jx/vite.config.js

@@ -40,6 +40,13 @@ export default defineConfig({
   server: {
     cors: true,
     proxy: {
+      '/baseApi': {
+        target: 'http://10.10.8.117:9999/',
+          // target: 'https://ai.zrzyt.zj.gov.cn:10086/aisChat',
+          // target: 'https://zdzy.zrzyt.zj.gov.cn/aisKnowledge',
+          changeOrigin: true,
+          rewrite: function (path) { return path.replace(/^\/baseApi/, ''); }
+      },
       '/server': {
         // target: 'http://10.10.8.238:9999/',
           target: 'https://ai.zrzyt.zj.gov.cn:10086/aisKnowledge',

+ 0 - 1
ais_search_zj/web/components.d.ts

@@ -14,7 +14,6 @@ declare module 'vue' {
     BasicCurdPage: typeof import('./src/components/curd/BasicCurdPage.vue')['default']
     BasicCurdPageFrame: typeof import('./src/components/curd/frame/BasicCurdPageFrame.vue')['default']
     BasicQueryForm: typeof import('./src/components/query/BasicQueryForm.vue')['default']
-    copy: typeof import('./src/components/pdf/PDFViewerSearch copy.vue')['default']
     HomeCard: typeof import('./src/components/home-card/HomeCard.vue')['default']
     IframePage: typeof import('./src/components/iframe-page/IframePage.vue')['default']
     MarkdownToc: typeof import('./src/components/markdown-toc/MarkdownToc.vue')['default']

+ 7 - 7
ais_search_zj/web/src/views/home/index.vue

@@ -8,7 +8,7 @@
         <div class="tool">
           <ul>
             <template v-for="(menu,index) in menuRoutes" :key="index">
-              <li  v-if="index < 4" :class="{active: cMenuRoute['title'] === menu['title']}" @click="toSwitchPage(menu)">
+              <li  v-if="index < 3" :class="{active: cMenuRoute['title'] === menu['title']}" @click="toSwitchPage(menu)">
                 <span :class="`iconfont ${menu['icon']}`"></span>
                 <span class="title">{{menu['title']}}</span>
               </li>
@@ -39,12 +39,12 @@ const menuRoutes = [
     name: 'Znxz',
     iframe: true
   },
-  {
-    title: '找图找数',
-    icon: 'icon-zhengcefagui',
-    name: 'Ztzs',
-    iframe: true
-  },
+  // {
+  //   title: '找图找数',
+  //   icon: 'icon-zhengcefagui',
+  //   name: 'Ztzs',
+  //   iframe: true
+  // },
   {
     title: '智能找图',
     icon: 'icon-map',