xiaochan 1 år sedan
förälder
incheckning
4fa8a59778

+ 1 - 0
.env.dev

@@ -3,5 +3,6 @@ ENV = 'dev'
 VITE_BASE_URL = 'http://172.16.30.61:7201'
 VITE_SOCKET_URL = 'ws://172.16.30.61:8707/websocket/'
 VITE_EMR_CONTROL_URL = '172.16.30.61:9227'
+VITE_DATA_BASE = 'http://172.16.30.61:9205'
 
 VITE_UPLOAD_TEMPLATE_THUMB = 'http://192.168.200.3:8805/wxserver/wxApplet/updateTemplateThumb'

+ 2 - 1
.env.production

@@ -3,5 +3,6 @@ ENV = 'production'
 VITE_BASE_URL = 'http://172.16.32.160:8077'
 VITE_SOCKET_URL = 'ws://172.16.32.160:8707/websocket/'
 VITE_EMR_CONTROL_URL = '172.16.32.160:9227'
+VITE_DATA_BASE = 'http://172.16.32.160:9205'
 
-VITE_UPLOAD_TEMPLATE_THUMB = 'http://staticweb.hnthyy.cn/wxserver/wxApplet/updateTemplateThumb'
+VITE_UPLOAD_TEMPLATE_THUMB = 'http://staticweb.hnthyy.cn/wxserver/wxApplet/updateTemplateThumb'

+ 0 - 3
src/api/emr-control/request.ts

@@ -12,7 +12,6 @@ const service = axios.create({
     timeout: 0,
 })
 
-
 service.interceptors.request.use(
     // @ts-ignore
     (config) => {
@@ -72,8 +71,6 @@ service.interceptors.response.use((response) => {
             data: response.data.data
         }
     }
-
-
     return Promise.reject(response.data.message || '服务器内部错误')
 }, (error) => {
     // 超出 2xx 范围的状态码都会触发该函数。

+ 23 - 3
src/views/data-base/DataBase.vue

@@ -1,12 +1,31 @@
 <script setup lang="ts">
-import {nextTick, onActivated, onDeactivated, onMounted, ref} from "vue";
+import {
+  nextTick,
+  onActivated,
+  onDeactivated,
+  onMounted,
+  ref
+} from "vue";
 import {userInfoStore} from "@/utils/store-public";
+import DataBaseDialog from "@/views/data-base/components/DataBaseDialog.vue";
 
 const iframe = ref<HTMLIFrameElement>()
+// @ts-ignore
+const src = import.meta.env.VITE_DATA_BASE + '/magic/web/index.html'
 
+const func = {
+  'user': user
+}
+
+const dialogRef = ref({})
+
+async function user() {
+  dialogRef.value.openDialog()
+}
 
 const getMessage = e => {
-  console.log(e)
+  const data = JSON.parse(e.data)
+  func[data.name]()
 }
 
 onDeactivated(() => {
@@ -31,7 +50,8 @@ onMounted(async () => {
 </script>
 
 <template>
-  <iframe src="http://172.16.30.61:8991" width="100%" height="100%" style="border: 0"
+  <DataBaseDialog ref="dialogRef"/>
+  <iframe :src="src" width="100%" height="100%" style="border: 0"
           ref="iframe"/>
 </template>
 

+ 137 - 0
src/views/data-base/components/DataBaseDialog.vue

@@ -0,0 +1,137 @@
+<script setup lang="ts">
+import {computed, ref} from "vue";
+import {
+  apiPermissions,
+  delCompanies, getApiListByCodeName,
+  getResourceWeb,
+  getSystemToken,
+  newCompanies
+} from "@/views/data-base/src/data-base-api";
+import {copyStrFunc} from "@/utils/public";
+import {SystemTokenType} from "@/views/data-base/src/daba-base-type";
+import {windowSizeStore} from "@/utils/store-public";
+import {useCompRef} from "@/utils/useCompRef";
+import {ElTree} from "element-plus";
+import XEUtils from "xe-utils";
+
+const dialog = ref(false)
+const data = ref({})
+const tokenList = ref<SystemTokenType[]>([])
+const treeRef = useCompRef(ElTree)
+const addName = ref('')
+const currentRow = ref<SystemTokenType>()
+
+const defaultProps = {
+  children: 'children',
+  label: 'node.name',
+}
+
+const height = computed(() => {
+  return windowSizeStore.value.h / 1.6
+})
+
+function childrenToElTree(children) {
+  XEUtils.arrayEach(children, (item) => {
+    item.id = item.node.id
+    if (item.children.length > 0) {
+      childrenToElTree(item.children)
+    }
+  })
+}
+
+async function openDialog() {
+  const res = await getResourceWeb()
+  const children = res.api.children
+  childrenToElTree(children)
+  data.value = children
+  tokenList.value = await getSystemToken()
+  dialog.value = true
+}
+
+function clickCopy(value) {
+  copyStrFunc(value)
+}
+
+function treeName(node, data) {
+  return data.node.name
+}
+
+function rowClick(row: SystemTokenType) {
+  getApiListByCodeName(row.codeName).then(res => {
+    treeRef.value!.setCheckedKeys(res)
+    currentRow.value = row
+  })
+}
+
+const saveClick = async () => {
+  if (!currentRow.value.codeName) return
+  const temp = {
+    codeName: currentRow.value.codeName,
+    list: treeRef.value.getCheckedKeys()
+  }
+  console.log(temp)
+  const res = await apiPermissions(temp).catch(() => {
+    treeRef.value!.setCheckedKeys([], false)
+  })
+}
+
+async function addClick() {
+  const res = await newCompanies(addName.value)
+  addName.value = ''
+  tokenList.value.push(res)
+}
+
+async function delClick(row, $index) {
+  const res = await delCompanies(row.uuid);
+  if (res) {
+    tokenList.value.splice($index, 1);
+  }
+}
+
+defineExpose({
+  openDialog
+})
+</script>
+
+<template>
+  <el-dialog v-model="dialog" title="用户管理" width="60%">
+    <div style="display: flex">
+      <div style="width: max-content">
+        <el-input v-model="addName" style="width: 120px;" maxlength="100"/>
+        <el-button @click="addClick">新增</el-button>
+        <el-table :data="tokenList"
+                  @row-click="rowClick"
+                  :height="height"
+                  highlight-current-row>
+          <el-table-column label="名称" prop="name" width="120"/>
+          <el-table-column label="秘钥" prop="codeEncrypt" show-overflow-tooltip width="120"/>
+          <el-table-column>
+            <template #default="{row,$index}">
+              <el-button circle
+                         class="iconfont icon-fuzhi"
+                         type="info"
+                         @click="clickCopy(row.codeEncrypt)"/>
+              <el-button icon="Delete" circle type="danger" @click="delClick(row , $index)"/>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <div style="flex: 1; overflow: auto" :style="{height :height +'px'}">
+        <el-button @click="saveClick">保存</el-button>
+        <el-tree :data="data"
+                 ref="treeRef"
+                 :props="defaultProps"
+                 show-checkbox
+                 node-key="id">
+          <template #default="{ node, data }">
+            <span>{{ treeName(node, data) }}</span>
+          </template>
+        </el-tree>
+      </div>
+    </div>
+  </el-dialog>
+</template>
+
+<style scoped lang="scss">
+
+</style>

+ 27 - 0
src/views/data-base/src/daba-base-type.ts

@@ -0,0 +1,27 @@
+export declare type SystemTokenType = {
+    uuid: string;
+    name: string;
+    codeName: string;
+    codeEncrypt: string
+}
+
+
+export interface Node {
+    properties: any;
+    id: string;
+    name: string;
+    type: string;
+    parentId: string;
+    path: string;
+    createTime: number;
+    updateTime: number | null;
+    createBy: string;
+    updateBy: string | null;
+    paths: any[];
+    options: any[];
+}
+
+export interface ChildNode {
+    node: Node;
+    children: any[]; // 如果有子节点,也需要定义其类型
+}

+ 48 - 0
src/views/data-base/src/data-base-api.ts

@@ -0,0 +1,48 @@
+import request from "./data-base-axios";
+import {SystemTokenType} from "./daba-base-type";
+
+export function getResourceWeb() {
+    return request({
+        method: 'get',
+        url: "/magic/web/resource",
+    })
+}
+
+export function getSystemToken() {
+    return request<SystemTokenType[]>({
+        method: 'get',
+        url: "/permissions/getSystemToken"
+    })
+}
+
+export function newCompanies(name: string) {
+    return request<SystemTokenType>({
+        method: 'get',
+        url: '/permissions/newCompanies',
+        params: {name}
+    })
+}
+
+export function apiPermissions(data: any) {
+    return request({
+        method: 'post',
+        url: '/permissions/apiPermissions',
+        data
+    })
+}
+
+export function delCompanies(uuid: string) {
+    return request({
+        method: 'get',
+        url: '/permissions/delCompanies',
+        params: {uuid}
+    })
+}
+
+export function getApiListByCodeName(codeName) {
+    return request<string[]>({
+        method: 'get',
+        url: '/permissions/getApiListByCodeName',
+        params: {codeName}
+    })
+}

+ 40 - 0
src/views/data-base/src/data-base-axios.ts

@@ -0,0 +1,40 @@
+import axios, {AxiosRequestConfig} from "axios";
+import {userInfoStore} from "../../../utils/store-public";
+import {xcMessage} from "../../../utils/xiaochan-element-plus";
+
+const service = axios.create({
+    // @ts-ignore
+    baseURL: import.meta.env.VITE_DATA_BASE,
+    withCredentials: true,
+    timeout: 0
+})
+
+service.interceptors.request.use(
+    // @ts-ignore
+    (config) => {
+        if (userInfoStore.value.token) {
+            config.headers['token'] = userInfoStore.value.token
+            config.headers['Magic-Token'] = userInfoStore.value.token
+        }
+        return config
+    },
+    (error) => {
+        return Promise.reject(error)
+    }
+)
+
+service.interceptors.response.use((response) => {
+    if (response.data.code === -1) {
+        xcMessage.error(response.data.message)
+        return Promise.reject(response.data)
+    }
+
+    return response.data.data
+})
+
+const request = <D = any>(options: AxiosRequestConfig): Promise<D> => {
+    // @ts-ignore
+    return service(options)
+}
+
+export default request

+ 3 - 1
src/views/hospitalization/zhu-yuan-yi-sheng/shou-shu-shen-qing/src/ShouShu.vue

@@ -95,7 +95,9 @@ onMounted(async () => {
         </el-tab-pane>
 
         <el-tab-pane label="新增" name="ss-add">
-          <AddShouShu/>
+          <div :style="{height: windowSizeStore.h / 1.6 + 'px'} " style="overflow:auto;">
+            <AddShouShu/>
+          </div>
         </el-tab-pane>
 
       </el-tabs>