zs hace 1 año
padre
commit
db190483f3

+ 2 - 2
.env.development

@@ -1,7 +1,7 @@
 VITE_BASE_URL = "/follow"
 VITE_OUT_DIR = "follow"
-VITE_REQUEST_BASE = ''
-VITE_APP_HOST="https://broadcast.waityou24.cn"
+VITE_REQUEST_BASE = '/visit/api'
+VITE_APP_HOST="http://192.168.1.113:8890"
 VITE_APP_PAGE_SIZE=15
 VITE_APP_ROUTER="follow"
 VITE_APP_ENV = 'development'

+ 2 - 2
.env.production

@@ -1,7 +1,7 @@
 VITE_BASE_URL = "/follow"
 VITE_OUT_DIR = "follow"
-VITE_REQUEST_BASE = ''
-VITE_APP_HOST="https://broadcast.waityou24.cn"
+VITE_REQUEST_BASE = '/visit/api'
+VITE_APP_HOST="http://192.168.1.113:8890"
 VITE_APP_PAGE_SIZE=15
 VITE_APP_ROUTER="follow"
 VITE_APP_ENV = 'production'

+ 1 - 1
src/router/index.ts

@@ -95,7 +95,7 @@ router.beforeEach(async (to, from, next) => {
     if (token) {
       const res = await axios.request({
         method: 'get',
-        url: '/visit/login/analysis',
+        url: '/visit/api/login/analysis',
         responseType: 'json',
         headers: {
           token: token

+ 1 - 1
src/stores/basic/config.ts

@@ -6,7 +6,7 @@ import _ from 'lodash';
 import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
 const axios = new AxiosWrapper();
 const api = {
-  url: `/visit/config`
+  url: `/config`
 };
 export const ConfigStore = defineStore('config', () => {
   const count = ref(0);

+ 1 - 1
src/stores/basic/menus.ts

@@ -6,7 +6,7 @@ import _ from 'lodash';
 import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
 const axios = new AxiosWrapper();
 const api = {
-  url: `/visit/menus`
+  url: `/menus`
 };
 export const MenusStore = defineStore('menus', () => {
   const count = ref(0);

+ 1 - 1
src/stores/basic/role.ts

@@ -6,7 +6,7 @@ import _ from 'lodash';
 import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
 const axios = new AxiosWrapper();
 const api = {
-  url: `/visit/role`
+  url: `/role`
 };
 export const RoleStore = defineStore('role', () => {
   const count = ref(0);

+ 52 - 0
src/stores/other/adv.ts

@@ -0,0 +1,52 @@
+import { ref, computed } from 'vue';
+import { defineStore } from 'pinia';
+import { AxiosWrapper } from '@/util/axios-wrapper';
+import _ from 'lodash';
+
+import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
+const axios = new AxiosWrapper();
+const api = {
+  url: `/adv`
+};
+export const AdvStore = defineStore('adv', () => {
+  const count = ref(0);
+  const doubleCount = computed(() => count.value * 2);
+  function increment() {
+    count.value++;
+  }
+  const query = async ({ skip = 0, limit = undefined, ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    let cond: IQueryType = {};
+    if (skip) cond.skip = skip;
+    if (limit) cond.limit = limit;
+    cond = { ...cond, ...info };
+    const res = await axios.$get(`${api.url}`, cond);
+    return res;
+  };
+  const fetch = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/${payload}`);
+    return res;
+  };
+  const create = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}`, payload);
+    return res;
+  };
+  const update = async (payload: any): Promise<IQueryResult> => {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  };
+  const del = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$delete(`${api.url}/${payload}`);
+    return res;
+  };
+  return {
+    count,
+    doubleCount,
+    increment,
+    query,
+    fetch,
+    create,
+    update,
+    del
+  };
+});

+ 2 - 7
src/stores/users/admin.ts

@@ -6,7 +6,7 @@ import _ from 'lodash';
 import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
 const axios = new AxiosWrapper();
 const api = {
-  url: `/visit/admin`
+  url: `/admin`
 };
 export const AdminStore = defineStore('admin', () => {
   const count = ref(0);
@@ -39,10 +39,6 @@ export const AdminStore = defineStore('admin', () => {
     const res = await axios.$delete(`${api.url}/${payload}`);
     return res;
   };
-  const login = async (payload: any): Promise<IQueryResult> => {
-    const res = await axios.$post(`${api.url}/login`, payload);
-    return res;
-  };
   return {
     count,
     doubleCount,
@@ -51,7 +47,6 @@ export const AdminStore = defineStore('admin', () => {
     fetch,
     create,
     update,
-    del,
-    login
+    del
   };
 });

+ 1 - 1
src/stores/users/doctor.ts

@@ -6,7 +6,7 @@ import _ from 'lodash';
 import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
 const axios = new AxiosWrapper();
 const api = {
-  url: `/visit/doctor`
+  url: `/doctor`
 };
 export const DoctorStore = defineStore('doctor', () => {
   const count = ref(0);

+ 1 - 1
src/stores/users/login.ts

@@ -5,7 +5,7 @@ import { AxiosWrapper } from '@/util/axios-wrapper';
 import type { IQueryResult } from '@/util/types.util';
 const axios = new AxiosWrapper();
 const api = {
-  url: `/visit/login`
+  url: `/login`
 };
 export const LoginStore = defineStore('login', () => {
   const count = ref(0);

+ 1 - 1
src/stores/users/nurse.ts

@@ -6,7 +6,7 @@ import _ from 'lodash';
 import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
 const axios = new AxiosWrapper();
 const api = {
-  url: `/visit/nurse`
+  url: `/nurse`
 };
 export const NurseStore = defineStore('nurse', () => {
   const count = ref(0);

+ 1 - 1
src/stores/users/patient.ts

@@ -6,7 +6,7 @@ import _ from 'lodash';
 import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
 const axios = new AxiosWrapper();
 const api = {
-  url: `/visit/patient`
+  url: `/patient`
 };
 export const PatientStore = defineStore('patient', () => {
   const count = ref(0);

+ 160 - 15
src/views/advert/index.vue

@@ -2,40 +2,185 @@
   <div id="index">
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
-        <el-col :span="24" class="one"> 系统首页 </el-col>
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"> </cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cButton @toAdd="toAdd()"> </cButton>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel">
+            <template #is_use="{ row }">
+              <el-switch
+                v-model="row.is_use"
+                inline-prompt
+                active-text="是"
+                inactive-text="否"
+                active-value="0"
+                inactive-value="1"
+                @click="handleChange(row)"
+              ></el-switch>
+            </template>
+          </cTable>
+        </el-col>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave" label-width="auto">
+            <template #image>
+              <cUpload
+                :model="`${'image'}`"
+                :limit="1"
+                listType="picture-card"
+                url="/visit/api/files/adv/upload"
+                accept="*"
+                :list="form.image"
+                @change="onUpload"
+              ></cUpload>
+            </template>
+            <template #is_use>
+              <el-option v-for="i in is_useList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
+import type { FormRules } from 'element-plus';
 import type { Ref } from 'vue';
-import { onMounted, ref } from 'vue';
-
+import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
 // 接口
-// import { ToolsStore } from '@/stores/tool';
-// import type { IQueryResult } from '@/util/types.util';
-// const toolsAxios = ToolsStore();
-
+import { AdvStore } from '@/stores/other/adv';
+import type { IQueryResult } from '@/util/types.util';
+const advAxios = AdvStore();
+const { proxy } = getCurrentInstance() as any;
 // 加载中
 const loading: Ref<any> = ref(false);
-
+let list: Ref<any> = ref([]);
+let total: Ref<number> = ref(0);
+let skip = 0;
+let limit: number = proxy.$limit;
+let fields: Ref<any[]> = ref([
+  { label: '标题', model: 'title', isSearch: true },
+  { label: '跳转路径', model: 'url' },
+  { label: '是否启用', model: 'is_use', custom: true }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger' }
+]);
+// 查询数据
+let searchForm: Ref<any> = ref({});
+// 弹框
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
+const form: Ref<any> = ref({ image: [] });
+const formFields: Ref<any> = ref([
+  { label: '标题', model: 'title' },
+  { label: '图片', model: 'image', custom: true },
+  { label: '跳转路径', model: 'url' },
+  { label: '是否启用', model: 'is_use', type: 'select' }
+]);
+const rules = reactive<FormRules>({
+  title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
+  image: [{ required: true, message: '请输入图片', trigger: 'blur' }],
+  url: [{ required: true, message: '请输入跳转路径', trigger: 'blur' }],
+  is_use: [{ required: true, message: '请选择是否启用', trigger: 'blur' }]
+});
+// 字典表
+const is_useList: Ref<any> = ref([
+  { label: '是', value: '0' },
+  { label: '否', value: '1' }
+]);
 // 请求
 onMounted(async () => {
   loading.value = true;
-  search();
+  await search({ skip, limit });
   loading.value = false;
 });
-const search = async () => {
-  // let res: IQueryResult = await toolsAxios.dataCount();
-  // if (res.errcode == '0') {
-  //   info.value = res.data;
-  // }
+const search = async (e: { skip: number; limit: number }) => {
+  const info = { skip: e.skip, limit: e.limit, ...searchForm.value };
+  const res: IQueryResult = await advAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query: any) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+// 提交保存
+const toSave = async (data: any) => {
+  let res: IQueryResult;
+  if (data._id) res = await advAxios.update(data);
+  else res = await advAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toClose();
+  }
+};
+// 新增
+const toAdd = () => {
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 修改
+const toEdit = async (data: any) => {
+  let res: IQueryResult = await advAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '信息管理', show: true, type: '1' };
+  }
+};
+// 删除
+const toDel = async (data: any) => {
+  let res: IQueryResult = await advAxios.del(data._id);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `刪除信息成功` });
+    search({ skip, limit });
+  }
+};
+// 关闭弹框
+const toClose = () => {
+  form.value = { image: [] };
+  dialog.value = { show: false };
+  search({ skip, limit });
+};
+// 修改是否启用
+const handleChange = (row: any) => {
+  const text = row.is_use === '0' ? '启用' : '停用';
+  ElMessageBox.confirm('确认要"' + text + '""' + row.name + '"吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  })
+    .then(async () => {
+      let res: IQueryResult;
+      if (row._id) res = await advAxios.update(row);
+      if (res.errcode == 0) {
+        ElMessage({ type: `success`, message: `修改成功` });
+      }
+    })
+    .catch(() => {
+      row.is_use = row.is_use === '0' ? '1' : '0';
+    });
 };
 </script>
 <style scoped lang="scss">
 .main {
-  padding: 2px;
+  .two {
+    margin: 0 0 10px 0;
+  }
 }
 </style>

+ 160 - 15
src/views/article/index.vue

@@ -2,40 +2,185 @@
   <div id="index">
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
-        <el-col :span="24" class="one"> 系统首页 </el-col>
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"> </cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cButton @toAdd="toAdd()"> </cButton>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel">
+            <template #is_use="{ row }">
+              <el-switch
+                v-model="row.is_use"
+                inline-prompt
+                active-text="是"
+                inactive-text="否"
+                active-value="0"
+                inactive-value="1"
+                @click="handleChange(row)"
+              ></el-switch>
+            </template>
+          </cTable>
+        </el-col>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave" label-width="auto">
+            <template #image>
+              <cUpload
+                :model="`${'image'}`"
+                :limit="1"
+                listType="picture-card"
+                url="/visit/api/files/adv/upload"
+                accept="*"
+                :list="form.image"
+                @change="onUpload"
+              ></cUpload>
+            </template>
+            <template #is_use>
+              <el-option v-for="i in is_useList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
+import type { FormRules } from 'element-plus';
 import type { Ref } from 'vue';
-import { onMounted, ref } from 'vue';
-
+import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
 // 接口
-// import { ToolsStore } from '@/stores/tool';
-// import type { IQueryResult } from '@/util/types.util';
-// const toolsAxios = ToolsStore();
-
+import { AdvStore } from '@/stores/other/adv';
+import type { IQueryResult } from '@/util/types.util';
+const advAxios = AdvStore();
+const { proxy } = getCurrentInstance() as any;
 // 加载中
 const loading: Ref<any> = ref(false);
-
+let list: Ref<any> = ref([]);
+let total: Ref<number> = ref(0);
+let skip = 0;
+let limit: number = proxy.$limit;
+let fields: Ref<any[]> = ref([
+  { label: '标题', model: 'title', isSearch: true },
+  { label: '跳转路径', model: 'url' },
+  { label: '是否启用', model: 'is_use', custom: true }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger' }
+]);
+// 查询数据
+let searchForm: Ref<any> = ref({});
+// 弹框
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
+const form: Ref<any> = ref({ image: [] });
+const formFields: Ref<any> = ref([
+  { label: '标题', model: 'title' },
+  { label: '图片', model: 'image', custom: true },
+  { label: '跳转路径', model: 'url' },
+  { label: '是否启用', model: 'is_use', type: 'select' }
+]);
+const rules = reactive<FormRules>({
+  title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
+  image: [{ required: true, message: '请输入图片', trigger: 'blur' }],
+  url: [{ required: true, message: '请输入跳转路径', trigger: 'blur' }],
+  is_use: [{ required: true, message: '请选择是否启用', trigger: 'blur' }]
+});
+// 字典表
+const is_useList: Ref<any> = ref([
+  { label: '是', value: '0' },
+  { label: '否', value: '1' }
+]);
 // 请求
 onMounted(async () => {
   loading.value = true;
-  search();
+  await search({ skip, limit });
   loading.value = false;
 });
-const search = async () => {
-  // let res: IQueryResult = await toolsAxios.dataCount();
-  // if (res.errcode == '0') {
-  //   info.value = res.data;
-  // }
+const search = async (e: { skip: number; limit: number }) => {
+  const info = { skip: e.skip, limit: e.limit, ...searchForm.value };
+  const res: IQueryResult = await advAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query: any) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+// 提交保存
+const toSave = async (data: any) => {
+  let res: IQueryResult;
+  if (data._id) res = await advAxios.update(data);
+  else res = await advAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toClose();
+  }
+};
+// 新增
+const toAdd = () => {
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 修改
+const toEdit = async (data: any) => {
+  let res: IQueryResult = await advAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '信息管理', show: true, type: '1' };
+  }
+};
+// 删除
+const toDel = async (data: any) => {
+  let res: IQueryResult = await advAxios.del(data._id);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `刪除信息成功` });
+    search({ skip, limit });
+  }
+};
+// 关闭弹框
+const toClose = () => {
+  form.value = { image: [] };
+  dialog.value = { show: false };
+  search({ skip, limit });
+};
+// 修改是否启用
+const handleChange = (row: any) => {
+  const text = row.is_use === '0' ? '启用' : '停用';
+  ElMessageBox.confirm('确认要"' + text + '""' + row.name + '"吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  })
+    .then(async () => {
+      let res: IQueryResult;
+      if (row._id) res = await advAxios.update(row);
+      if (res.errcode == 0) {
+        ElMessage({ type: `success`, message: `修改成功` });
+      }
+    })
+    .catch(() => {
+      row.is_use = row.is_use === '0' ? '1' : '0';
+    });
 };
 </script>
 <style scoped lang="scss">
 .main {
-  padding: 2px;
+  .two {
+    margin: 0 0 10px 0;
+  }
 }
 </style>

+ 1 - 1
src/views/doctor/index.vue

@@ -22,7 +22,7 @@
                 :model="`${'icon'}`"
                 :limit="1"
                 listType="picture-card"
-                url="/visit/api/files/follow/doctor/upload"
+                url="/visit/api/files/doctor/upload"
                 accept="*"
                 :list="form.icon"
                 @change="onUpload"

+ 1 - 1
src/views/group/index.vue

@@ -22,7 +22,7 @@
                 :model="`${'icon'}`"
                 :limit="1"
                 listType="picture-card"
-                url="/visit/api/files/follow/doctor/upload"
+                url="/visit/api/files/group/upload"
                 accept="*"
                 :list="form.icon"
                 @change="onUpload"

+ 1 - 1
src/views/nurse/index.vue

@@ -22,7 +22,7 @@
                 :model="`${'icon'}`"
                 :limit="1"
                 listType="picture-card"
-                url="/visit/api/files/follow/nurse/upload"
+                url="/visit/api/files/nurse/upload"
                 accept="*"
                 :list="form.icon"
                 @change="onUpload"

+ 1 - 1
src/views/patient/index.vue

@@ -22,7 +22,7 @@
                 :model="`${'icon'}`"
                 :limit="1"
                 listType="picture-card"
-                url="/visit/api/files/follow/patient/upload"
+                url="/visit/api/files/patient/upload"
                 accept="*"
                 :list="form.icon"
                 @change="onUpload"

+ 5 - 5
src/views/system/config/index.vue

@@ -11,7 +11,7 @@
               <cUpload
                 :model="item.model"
                 :limit="1"
-                url="/visit/api/files/follow/config/upload"
+                url="/visit/api/files/config/upload"
                 :list="form[item.model]"
                 listType="picture-card"
                 @change="onUpload"
@@ -21,7 +21,7 @@
               <cUpload
                 :model="item.model"
                 :limit="1"
-                url="/visit/api/files/follow/config/upload"
+                url="/visit/api/files/config/upload"
                 :list="form[item.model]"
                 listType="picture-card"
                 @change="onUpload"
@@ -31,7 +31,7 @@
               <cUpload
                 :model="item.model"
                 :limit="1"
-                url="/visit/api/files/follow/config/upload"
+                url="/visit/api/files/config/upload"
                 :list="form[item.model]"
                 listType="picture-card"
                 @change="onUpload"
@@ -41,14 +41,14 @@
               <cUpload
                 :model="item.model"
                 :limit="1"
-                url="/visit/api/files/follow/config/upload"
+                url="/visit/api/files/config/upload"
                 :list="form[item.model]"
                 listType="picture-card"
                 @change="onUpload"
               ></cUpload>
             </template>
             <template #agreement>
-              <cEditor v-model="form.agreement" url="/visit/api/files/follow/config/upload"></cEditor>
+              <cEditor v-model="form.agreement" url="/visit/api/files/config/upload"></cEditor>
             </template>
           </cForm>
         </el-col>

+ 1 - 1
vite.config.ts

@@ -18,7 +18,7 @@ export default defineConfig(({ mode }) => {
           target: 'http://192.168.1.113:8890',
           changeOrigin: true
         },
-        '/visit': {
+        '/visit/api': {
           target: 'http://192.168.1.113:8890',
           changeOrigin: true,
           ws: false