guhongwei 2 سال پیش
والد
کامیت
91e335f11c

+ 2 - 0
components.d.ts

@@ -17,11 +17,13 @@ declare module '@vue/runtime-core' {
     VanButton: typeof import('vant/es')['Button']
     VanCellGroup: typeof import('vant/es')['CellGroup']
     VanCol: typeof import('vant/es')['Col']
+    VanDatePicker: typeof import('vant/es')['DatePicker']
     VanField: typeof import('vant/es')['Field']
     VanForm: typeof import('vant/es')['Form']
     VanIcon: typeof import('vant/es')['Icon']
     VanImage: typeof import('vant/es')['Image']
     VanPagination: typeof import('vant/es')['Pagination']
+    VanPicker: typeof import('vant/es')['Picker']
     VanPopup: typeof import('vant/es')['Popup']
     VanRadio: typeof import('vant/es')['Radio']
     VanRadioGroup: typeof import('vant/es')['RadioGroup']

+ 1 - 0
src/router/index.ts

@@ -44,6 +44,7 @@ router.beforeEach(async (to, from, next) => {
     }
     next();
   } else {
+    next();
     window.alert('无登录信息,无法打开');
   }
 });

+ 10 - 0
src/router/module/admin.ts

@@ -19,5 +19,15 @@ export default [
     path: '/policyfile/detail',
     meta: { title: '信息管理' },
     component: () => import('@/views/policyfile/detail.vue')
+  },
+  {
+    path: '/activitys/times',
+    meta: { title: '活动时间' },
+    component: () => import('@/views/activitys/times/index.vue')
+  },
+  {
+    path: '/activitys/times/detail',
+    meta: { title: '信息管理' },
+    component: () => import('@/views/activitys/times/detail.vue')
   }
 ];

+ 181 - 0
src/views/activitys/times/detail.vue

@@ -0,0 +1,181 @@
+<template>
+  <div id="detail">
+    <van-row>
+      <van-col span="24" class="main animate__animated animate__backInRight">
+        <van-col span="24" class="one">
+          <van-form @submit="toSave" label-width="auto">
+            <van-cell-group>
+              <van-field
+                v-model="form.name"
+                name="name"
+                type="textarea"
+                rows="1"
+                autosize
+                label="标题"
+                placeholder="请输入标题"
+                :rules="[{ required: true, message: '请输入标题' }]"
+              />
+              <van-field v-model="form.year" is-link readonly name="year" label="年份" placeholder="点击选择年份" @click="toPopup({ type: 'year' })" />
+              <van-field
+                v-model="form.start_time"
+                is-link
+                readonly
+                name="start_time"
+                label="开始时间"
+                placeholder="点击选择年份"
+                @click="toPopup({ type: 'start_time' })"
+              />
+              <van-field
+                v-model="form.end_time"
+                is-link
+                readonly
+                name="end_time"
+                label="结束时间"
+                placeholder="点击选择时间"
+                @click="toPopup({ type: 'end_time' })"
+              />
+              <van-field
+                v-model="form.type"
+                is-link
+                readonly
+                name="type"
+                label="开放的实验室类型"
+                placeholder="点击选择类型"
+                @click="toPopup({ type: 'type' })"
+              />
+              <van-field v-model="form.is_use" is-link readonly name="is_use" label="是否启用" placeholder="点击选择" @click="toPopup({ type: 'is_use' })" />
+            </van-cell-group>
+            <div class="btn">
+              <van-button type="primary" size="small" native-type="submit"> 提交保存 </van-button>
+            </div>
+          </van-form>
+        </van-col>
+      </van-col>
+    </van-row>
+    <van-popup v-model:show="popup.show" position="bottom">
+      <template v-if="popup.type == 'year'">
+        <van-date-picker :min-date="minDate" :max-date="maxDate" :columns-type="['year']" @confirm="popChange" @cancel="toCancel" />
+      </template>
+      <template v-else-if="popup.type == 'start_time'">
+        <van-date-picker :min-date="minDate" :max-date="maxDate" :columns-type="['year', 'month', 'day']" @confirm="popChange" @cancel="toCancel" />
+      </template>
+      <template v-else-if="popup.type == 'end_time'">
+        <van-date-picker :min-date="minDate" :max-date="maxDate" :columns-type="['year', 'month', 'day']" @confirm="popChange" @cancel="toCancel" />
+      </template>
+      <template v-else-if="popup.type == 'type'">
+        <van-picker :columns="typeList" :columns-field-names="{ text: 'dict_label', value: 'dict_value' }" @confirm="popChange" @cancel="toCancel" />
+      </template>
+      <template v-else-if="popup.type == 'is_use'">
+        <van-picker :columns="showList" :columns-field-names="{ text: 'dict_label', value: 'dict_value' }" @confirm="popChange" @cancel="toCancel" />
+      </template>
+    </van-popup>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import type { Ref } from 'vue';
+import { onMounted, ref } from 'vue';
+import { useRoute } from 'vue-router';
+import { showToast } from 'vant';
+// 接口
+import { ActivitysStore } from '@common/src/stores/basic/activitys';
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const actAxios = ActivitysStore();
+const dictAxios = DictDataStore();
+
+// 路由
+const route = useRoute();
+
+const id: Ref<any> = ref('');
+// 表单
+const form: Ref<any> = ref({ file: [], files: [] });
+
+// 弹框
+const popup: Ref<any> = ref({ show: false, type: '' });
+// 日期
+const minDate: Ref<any> = ref(new Date(2020, 1, 1));
+const maxDate: Ref<any> = ref(new Date(2030, 1, 1));
+// 字典表
+const showList: Ref<any> = ref([]);
+const typeList: Ref<any> = ref([]);
+// 请求
+onMounted(async () => {
+  id.value = route.query.id;
+  await searchOther();
+  await search();
+});
+const search = async () => {
+  if (id.value) {
+    let res: IQueryResult = await actAxios.fetch(id.value);
+    if (res.errcode == '0') {
+      form.value = res.data;
+    }
+  }
+};
+// 选择
+const toPopup = (e) => {
+  popup.value = { show: true, type: e.type };
+};
+const popChange = (e) => {
+  let value = e.selectedValues;
+  if (popup.value.type == 'year') {
+    form.value.year = value[0];
+  } else if (popup.value.type == 'start_time') {
+    form.value.start_time = value.join('-');
+  } else if (popup.value.type == 'end_time') {
+    form.value.end_time = value.join('-');
+  } else if (popup.value.type == 'type') {
+    form.value.type = value[0];
+  } else if (popup.value.type == 'is_use') {
+    form.value.is_use = value[0];
+  }
+  toCancel();
+};
+// 关闭
+const toCancel = () => {
+  popup.value = { show: false };
+};
+
+// 保存
+const toSave = async (e) => {
+  let res: IQueryResult;
+  if (id.value) res = await actAxios.update({ ...e, _id: id.value });
+  else res = await actAxios.create(e);
+  if (res.errcode == '0') {
+    showToast({ message: '信息删除成功', type: 'success', duration: 500 });
+    toBack();
+  } else {
+    showToast({ message: `${res.errmsg}`, type: 'fail', duration: 500 });
+  }
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 是否启用
+  res = await dictAxios.query({ dict_type: 'act_time_type' });
+  if (res.errcode == '0') {
+    showList.value = res.data;
+  }
+  // 类型
+  res = await dictAxios.query({ dict_type: 'act_label_type' });
+  if (res.errcode == '0') {
+    typeList.value = res.data;
+  }
+};
+// 返回;
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
+<style scoped lang="scss">
+.main {
+  .one {
+    .btn {
+      text-align: center;
+      margin: 10px 0;
+    }
+  }
+}
+</style>

+ 203 - 0
src/views/activitys/times/index.vue

@@ -0,0 +1,203 @@
+<template>
+  <div id="index">
+    <van-row>
+      <van-col span="24" class="main animate__animated animate__backInRight">
+        <van-col span="24" class="one">
+          <van-col span="20" class="one_1">
+            <van-field v-model="searchForm.name" placeholder="请输入文件标题" @blur="toInput" />
+          </van-col>
+          <van-col span="4" class="one_2">
+            <van-button size="small" @click="toAdd" :disabled="!is_show">新增</van-button>
+          </van-col>
+        </van-col>
+        <van-col span="24" class="two">
+          <van-col span="24" class="list" v-for="i in list" :key="i._id">
+            <van-col span="24" class="name">{{ i.name }}</van-col>
+            <van-col span="24" class="other">
+              <van-col span="24" class="other_1">
+                <span>年度:</span>
+                <span>{{ i.year || '暂无' }}</span>
+              </van-col>
+              <van-col span="24" class="other_1">
+                <span>时间:</span>
+                <span>{{ i.start_time || '暂无' }}至{{ i.end_time || '暂无' }}</span>
+              </van-col>
+              <van-col span="24" class="other_1">
+                <span>开放实验室类型:</span>
+                <span>{{ getDict(i.type, 'type') }}</span>
+              </van-col>
+            </van-col>
+            <van-col span="24" class="btn">
+              <van-button type="primary" size="small" @click="toEdit(i)">信息编辑</van-button>
+              <van-button type="danger" size="small" @click="toDel(i)">信息删除</van-button>
+            </van-col>
+          </van-col>
+        </van-col>
+        <van-col span="24" class="thr">
+          <cPage :total="total" :limit="limit" @search="search"> </cPage>
+        </van-col>
+      </van-col>
+    </van-row>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import _ from 'lodash';
+import type { Ref } from 'vue';
+import { onMounted, ref, getCurrentInstance } from 'vue';
+import { useRouter } from 'vue-router';
+import { showConfirmDialog, showToast } from 'vant';
+import store from '@/stores/counter';
+// 接口
+import { ActivitysStore } from '@common/src/stores/basic/activitys';
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const actAxios = ActivitysStore();
+const dictAxios = DictDataStore();
+
+// 基本设置
+const { proxy } = getCurrentInstance() as any;
+
+// 路由
+const router = useRouter();
+
+// 是否显示
+const is_show: Ref<any> = ref(false);
+
+const list: Ref<any> = ref([]);
+const total: Ref<any> = ref(0);
+const skip = 0;
+const limit: number = proxy.$limit;
+// 查询
+const searchForm: Ref<any> = ref({});
+
+// 字典表
+// 类型
+const typeList: Ref<any> = ref([]);
+
+// 请求
+onMounted(async () => {
+  await searchOther();
+  await searchUser();
+  await search({ skip, limit });
+});
+const searchUser = () => {
+  let user = store.state.user as any;
+  if (user.role_type == '0' || user.role_type == '1') {
+    is_show.value = true;
+  }
+};
+const search = async (e: { skip: number; limit: number }) => {
+  const { skip, limit } = e;
+  const condition = _.cloneDeep(searchForm.value);
+  let info = { limit: limit, skip: skip, ...condition };
+  let res: IQueryResult = await actAxios.query(info);
+  if (res.errcode == 0) {
+    list.value = res.data as [];
+    total.value = res.total;
+  }
+};
+// 名称查询
+const toInput = () => {
+  search({ skip, limit });
+};
+// 查询
+const getDict = (e, model) => {
+  if (model == 'type') {
+    let data = typeList.value.find((i) => i.dict_value == e);
+    if (data) return data.dict_label;
+    else return '暂无';
+  }
+};
+// 新增
+const toAdd = () => {
+  router.push({ path: '/activitys/times/detail' });
+};
+// 信息修改
+const toEdit = (e) => {
+  router.push({ path: '/activitys/times/detail', query: { id: e._id } });
+};
+// 信息删除
+const toDel = async (e) => {
+  showConfirmDialog({
+    title: '提示',
+    message: '您确认删除该数据?',
+    width: '100%'
+  })
+    .then(async () => {
+      let res: IQueryResult = await actAxios.del(e._id);
+      if (res.errcode == '0') {
+        showToast({ message: '信息删除成功', type: 'success', duration: 500 });
+        search({ skip, limit });
+      } else {
+        showToast({ message: `${res.errmsg}`, type: 'fail', duration: 500 });
+      }
+    })
+    .catch(() => {});
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 类型
+  res = await dictAxios.query({ dict_type: 'act_label_type' });
+  if (res.errcode == '0') {
+    typeList.value = res.data;
+  }
+};
+</script>
+<style scoped lang="scss">
+.main {
+  height: 100vh;
+  overflow: hidden;
+  .one {
+    display: flex;
+    padding: 10px;
+    height: 9vh;
+    .one_1 {
+      .van-cell {
+        padding: 5px;
+        border: 1px solid #f1f1f1;
+      }
+    }
+    .one_2 {
+      .van-button {
+        width: 100%;
+        height: 4.8vh;
+      }
+    }
+  }
+  .two {
+    height: 85vh;
+    overflow-y: auto;
+    padding: 0 10px;
+    .list {
+      border: 1px solid #f1f1f1;
+      margin: 0 0 10px 0;
+      padding: 10px;
+      border-radius: 5px;
+      .name {
+        font-size: 16px;
+        font-weight: bold;
+        margin: 0 0 5px 0;
+      }
+      .other {
+        margin: 0 0 5px 0;
+        .other_1 {
+          font-size: 14px;
+        }
+      }
+      .btn {
+        text-align: center;
+        .van-button {
+          margin: 0 10px;
+        }
+      }
+    }
+  }
+  .thr {
+    height: 6vh;
+    overflow: hidden;
+  }
+}
+</style>

+ 3 - 2
src/views/home/index.vue

@@ -103,7 +103,7 @@ const getMenu = async () => {
       }
     }
   } else {
-    showToast({ message: `暂无用户信息,无法获取菜单信息`, type: 'error' });
+    showToast({ message: `暂无用户信息,无法获取菜单信息`, type: 'fail' });
   }
 };
 watch(
@@ -111,7 +111,7 @@ watch(
   (newVal) => {
     if (newVal && newVal._id) {
       getMenu();
-    } else showToast({ message: `暂无用户信息,无法获取菜单信息`, type: 'error' });
+    } else showToast({ message: `暂无用户信息,无法获取菜单信息`, type: 'fail' });
   },
   {
     deep: true
@@ -120,6 +120,7 @@ watch(
 </script>
 <style scoped lang="scss">
 .main {
+  height: 100vh;
   overflow: hidden;
   .one {
     background-color: #409eff;

+ 4 - 3
src/views/laboratory/info/index.vue

@@ -153,7 +153,8 @@ const searchOther = async () => {
   .one {
     display: flex;
     padding: 10px;
-    height: 9vh;
+    height: 8vh;
+    overflow: hidden;
     .one_1 {
       .van-cell {
         padding: 5px;
@@ -163,12 +164,12 @@ const searchOther = async () => {
     .one_2 {
       .van-button {
         width: 100%;
-        height: 5.4vh;
+        height: 4.8vh;
       }
     }
   }
   .two {
-    height: 85vh;
+    height: 86vh;
     overflow-y: auto;
     padding: 0 10px;
     .list {

+ 3 - 2
src/views/policyfile/index.vue

@@ -40,10 +40,11 @@ import type { Ref } from 'vue';
 import { onMounted, ref, getCurrentInstance } from 'vue';
 import { useRouter } from 'vue-router';
 import { showConfirmDialog, showToast } from 'vant';
+import store from '@/stores/counter';
+
 // 接口
 import { PolicyfileStore } from '@common/src/stores/basic/policyfile';
 import type { IQueryResult } from '@/util/types.util';
-import store from '@/stores/counter';
 const polAxios = PolicyfileStore();
 
 // 基本设置
@@ -135,7 +136,7 @@ const toDownload = (e) => {
     .one_2 {
       .van-button {
         width: 100%;
-        height: 5.4vh;
+        height: 4.8vh;
       }
     }
   }