guhongwei 2 年之前
父节点
当前提交
2353b28d55
共有 3 个文件被更改,包括 318 次插入0 次删除
  1. 10 0
      src/router/module/admin.ts
  2. 122 0
      src/views/company/detail.vue
  3. 186 0
      src/views/company/index.vue

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

@@ -10,6 +10,16 @@ export default [
     meta: { title: '详细信息' },
     component: () => import('@/views/laboratory/info/detail.vue')
   },
+  {
+    path: '/company',
+    meta: { title: '参加单位' },
+    component: () => import('@/views/company/index.vue')
+  },
+  {
+    path: '/company/detail',
+    meta: { title: '信息管理' },
+    component: () => import('@/views/company/detail.vue')
+  },
   {
     path: '/policyfile',
     meta: { title: '政策文件' },

+ 122 - 0
src/views/company/detail.vue

@@ -0,0 +1,122 @@
+<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.lab_id" name="lab_id" type="textarea" rows="1" autosize label="实验室名称" placeholder="请输入实验室名称" />
+            </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>
+  </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 { BasicStore } from '@common/src/stores/basic/basic';
+import { CompanyStore } from '@common/src/stores/basic/company';
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+import store from '@/stores/counter';
+const basicAxios = BasicStore();
+const companyAxios = CompanyStore();
+const dictAxios = DictDataStore();
+
+// 路由
+const route = useRoute();
+
+// 实验室基础信息
+const lab_id: Ref<any> = ref('');
+const basicInfo: Ref<any> = ref({});
+const labList: Ref<any> = ref([]);
+
+const id: Ref<any> = ref('');
+// 表单
+const form: Ref<any> = ref({ file: [], files: [] });
+
+// 字典表
+let company_type: Ref<any[]> = ref([]); // 单位类别
+let company_subjection: Ref<any[]> = ref([]); // 隶属
+let company_nature: Ref<any[]> = ref([]); // 单位性质
+
+// 请求
+onMounted(async () => {
+  // 实验室id
+  lab_id.value = store.getters.lab_id;
+  id.value = route.query.id;
+  // 查询基础信息
+  await searchBasic();
+  // 查询其他信息
+  await searchOther();
+  await search();
+});
+// 查询基础信息
+const searchBasic = async () => {
+  let res: IQueryResult = await basicAxios.fetch(lab_id.value);
+  if (res.errcode == '0') {
+    let data = res.data as any;
+    basicInfo.value = data;
+    labList.value = [data];
+    form.value.lab_id = data._id;
+  }
+};
+const search = async () => {
+  if (id.value) {
+    let res: IQueryResult = await companyAxios.fetch(id.value);
+    if (res.errcode == '0') {
+      form.value = res.data;
+    }
+  }
+};
+// 保存
+const toSave = async (e) => {
+  let res: IQueryResult;
+  if (id.value) res = await companyAxios.update({ ...e, _id: id.value });
+  else res = await companyAxios.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: 'company_type' });
+  if (res.errcode == '0') company_type.value = res.data as [];
+  // 单位性质
+  res = await dictAxios.query({ dict_type: 'company_nature' });
+  if (res.errcode == '0') company_nature.value = res.data as [];
+  // 隶属
+  res = await dictAxios.query({ dict_type: 'company_subjection' });
+  if (res.errcode == '0') company_subjection.value = res.data as [];
+};
+
+// 返回;
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
+<style scoped lang="scss">
+.main {
+  .one {
+    .btn {
+      text-align: center;
+      margin: 10px 0;
+    }
+  }
+}
+</style>

+ 186 - 0
src/views/company/index.vue

@@ -0,0 +1,186 @@
+<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="isInAct">新增</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.contact }}</span>
+              </van-col>
+              <van-col span="24" class="other_1">
+                <span>联系人电话:</span>
+                <span>{{ i.phone }}</span>
+              </van-col>
+              <van-col span="24" class="other_1">
+                <span>单位类别:</span>
+                <span>{{ i.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 { CompanyStore } from '@common/src/stores/basic/company';
+import type { IQueryResult } from '@/util/types.util';
+const companyAxios = CompanyStore();
+
+// 基本设置
+const { proxy } = getCurrentInstance() as any;
+
+// 路由
+const router = useRouter();
+
+// 实验室id
+const lab_id: Ref<any> = ref('');
+const isInAct: Ref<any> = ref(true);
+
+const list: Ref<any> = ref([]);
+const total: Ref<any> = ref(0);
+const skip = 0;
+const limit: number = proxy.$limit;
+// 查询
+const searchForm: Ref<any> = ref({});
+
+// 请求
+onMounted(async () => {
+  // 实验室id
+  lab_id.value = store.getters.lab_id;
+  // 是否可改
+  isInAct.value = store.state.isInAct;
+  // 查询列表
+  await search({ skip, limit });
+});
+const search = async (e: { skip: number; limit: number }) => {
+  if (!lab_id.value) {
+    toPoint();
+    return;
+  }
+  const { skip, limit } = e;
+  const condition = _.cloneDeep(searchForm.value);
+  let info = { limit: limit, skip: skip, ...condition, lab_id: lab_id.value };
+  let res: IQueryResult = await companyAxios.query(info);
+  if (res.errcode == 0) {
+    list.value = res.data as [];
+    total.value = res.total;
+  }
+};
+// 名称查询
+const toInput = () => {
+  search({ skip, limit });
+};
+// 新增
+const toAdd = () => {
+  router.push({ path: '/company/detail' });
+};
+// 信息修改
+const toEdit = (e) => {
+  router.push({ path: '/company/detail', query: { id: e._id } });
+};
+// 信息删除
+const toDel = async (e) => {
+  showConfirmDialog({
+    title: '提示',
+    message: '您确认删除该数据?',
+    width: '100%'
+  })
+    .then(async () => {
+      let res: IQueryResult = await companyAxios.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 toPoint = () => {
+  showToast({ message: `当前用户未维护基础信息,不可操作`, type: 'fail' });
+};
+</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>