Browse Source

学术委员会

guhongwei 2 years ago
parent
commit
7262d4988a

+ 3 - 0
components.d.ts

@@ -16,6 +16,8 @@ declare module '@vue/runtime-core' {
     RouterView: typeof import('vue-router')['RouterView']
     VanButton: typeof import('vant/es')['Button']
     VanCellGroup: typeof import('vant/es')['CellGroup']
+    VanCheckbox: typeof import('vant/es')['Checkbox']
+    VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup']
     VanCol: typeof import('vant/es')['Col']
     VanDatePicker: typeof import('vant/es')['DatePicker']
     VanField: typeof import('vant/es')['Field']
@@ -24,6 +26,7 @@ declare module '@vue/runtime-core' {
     VanImage: typeof import('vant/es')['Image']
     VanPagination: typeof import('vant/es')['Pagination']
     VanPicker: typeof import('vant/es')['Picker']
+    VanPickerGroup: typeof import('vant/es')['PickerGroup']
     VanPopup: typeof import('vant/es')['Popup']
     VanRadio: typeof import('vant/es')['Radio']
     VanRadioGroup: typeof import('vant/es')['RadioGroup']

+ 3 - 3
src/views/activitys/times/detail.vue

@@ -54,13 +54,13 @@
     </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" />
+        <van-date-picker :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" />
+        <van-date-picker :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" />
+        <van-date-picker :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" />

+ 222 - 15
src/views/person/committee/detail.vue

@@ -2,32 +2,239 @@
   <div id="detail">
     <van-row>
       <van-col span="24" class="main animate__animated animate__backInRight">
-        <van-col span="24" class="one">系统首页</van-col>
+        <van-col span="24" class="one">
+          <van-form @submit="toSave" label-width="auto">
+            <van-cell-group>
+              <van-field
+                v-model="form.act_time"
+                is-link
+                readonly
+                name="act_time"
+                label="活动时间"
+                placeholder="点击选择"
+                @click="toPopup({ type: 'act_time' })"
+              />
+              <van-field v-model="form.lab_id" name="lab_id" style="display: none" />
+              <van-field v-model="form.lab_name" name="lab_name" label="实验室名称" placeholder="请输入实验室名称" readonly />
+              <van-field v-model="form.name" name="name" type="textarea" rows="1" autosize label="姓名" placeholder="请输入姓名" />
+              <van-field v-model="form.age" name="age" type="textarea" rows="1" autosize label="年龄" placeholder="请输入年龄" />
+              <van-field v-model="form.unit" name="unit" type="textarea" rows="1" autosize label="单位" placeholder="请输入单位" />
+              <van-field v-model="form.zwzc" name="zwzc" type="textarea" rows="1" autosize label="职务职称" placeholder="请输入职务职称" />
+              <van-field v-model="form.title" name="title" type="textarea" rows="1" autosize label="称号" placeholder="请输入称号" />
+              <van-field v-model="form.major" name="major" type="textarea" rows="1" autosize label="专业" placeholder="请输入专业" />
+              <!-- 期间 -->
+              <van-field v-model="form.term_of" is-link readonly name="term_of" label="任职期间" placeholder="点击选择" @click="toPopup({ type: 'term_of' })" />
+              <van-field name="type" label="本实验室职务">
+                <template #input>
+                  <van-checkbox-group v-model="form.type" direction="horizontal">
+                    <van-checkbox v-for="i in typeList" :key="i.dict_value" :name="i.dict_value" shape="square">{{ i.dict_label }}</van-checkbox>
+                  </van-checkbox-group>
+                </template>
+              </van-field>
+              <van-field v-model="form.is_show" is-link readonly name="is_show" label="是否公开" placeholder="点击选择" @click="toPopup({ type: 'is_show' })" />
+            </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 == 'act_time'">
+        <van-picker :columns="actList" :columns-field-names="{ text: 'name', value: '_id' }" @confirm="popChange" @cancel="toCancel" />
+      </template>
+      <template v-else-if="popup.type == 'is_show'">
+        <van-picker :columns="showList" :columns-field-names="{ text: 'dict_label', value: 'dict_value' }" @confirm="popChange" @cancel="toCancel" />
+      </template>
+      <template v-else-if="popup.type == 'term_of'">
+        <van-picker-group title="任职期间" :tabs="['开始日期', '结束日期']" @confirm="popChange" @cancel="toCancel">
+          <van-date-picker v-model="startDate" :columns-type="['year', 'month', 'day']" />
+          <van-date-picker v-model="endDate" :columns-type="['year', 'month', 'day']" />
+        </van-picker-group>
+      </template>
+    </van-popup>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
-// import type { Ref } from 'vue';
-// reactive, ref, onMounted
-import { onMounted } from 'vue';
+// import _ from 'lodash';
+import type { Ref } from 'vue';
+import { onMounted, ref } from 'vue';
+import { useRoute } from 'vue-router';
+import { showToast } from 'vant';
 // 接口
-import { TestStore } from '@common/src/stores/test';
+import { BasicStore } from '@common/src/stores/basic/basic';
+import { ActivitysStore } from '@common/src/stores/basic/activitys';
+import { CommitteeStore } from '@common/src/stores/basic/committee';
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
 import type { IQueryResult } from '@/util/types.util';
-const testAxios = TestStore();
-// 分页数据
-const skip = 0;
-const limit = 10;
+import store from '@/stores/counter';
+const basicAxios = BasicStore();
+const actAxios = ActivitysStore();
+const coomperAxios = CommitteeStore();
+const dictAxios = DictDataStore();
+
+// 路由
+const route = useRoute();
+
+// 实验室基础信息
+const lab_id: Ref<any> = ref('');
+const basicInfo: Ref<any> = ref({});
+const labList: Ref<any> = ref([]);
+// 活动时间
+const actList: Ref<any> = ref([]);
+
+const id: Ref<any> = ref('');
+// 表单
+const form: Ref<any> = ref({ term_of: [] });
+// 时间区间
+const startDate: Ref<any> = ref([]);
+const endDate: Ref<any> = ref([]);
+
+// 弹框
+const popup: Ref<any> = ref({ show: false, type: '' });
+
+const typeList: Ref<any> = ref([]);
+const showList: Ref<any> = ref([]);
+
 // 请求
 onMounted(async () => {
-  await search({ skip, limit });
+  // 实验室id
+  lab_id.value = store.getters.lab_id;
+  id.value = route.query.id;
+  // 查询基础信息
+  await searchBasic();
+  // 查询其他信息
+  await searchOther();
+  await search();
 });
-const search = async (e: { skip: number; limit: number }) => {
-  const info = { skip: e.skip, limit: e.limit };
-  const res: IQueryResult = await testAxios.query(info);
-  console.log(res);
+// 查询基础信息
+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;
+    form.value.lab_name = data.name;
+    // 查询活动时间
+    const isInAct = store.state.isInAct;
+    if (!isInAct) searchAct(data);
+  }
+};
+// 查询活动时间
+const searchAct = async (e) => {
+  const query = { is_use: '0', type: '' };
+  if (e.status == '1') query.type = '-1';
+  else if (e.status == '2') query.type = '2';
+  else query.type = '1';
+  let res: IQueryResult = await actAxios.query(query);
+  if (res.errcode == '0') {
+    actList.value = res.data;
+  }
+};
+const search = async () => {
+  if (id.value) {
+    let res: IQueryResult = await coomperAxios.fetch(id.value);
+    if (res.errcode == '0') {
+      let data = res.data as any;
+      form.value = data;
+      form.value.lab_name = basicInfo.value.name;
+      form.value.act_time = data.act_time._id;
+    }
+  }
+};
+// 选择
+const toPopup = (e) => {
+  popup.value = { show: true, type: e.type };
+};
+const popChange = (e) => {
+  let value = e.selectedValues;
+  if (popup.value.type == 'act_time') {
+    form.value.act_time = value[0];
+  } else if (popup.value.type == 'is_show') {
+    form.value.is_show = value[0];
+  } else if (popup.value.type == 'term_of') {
+    // 时间区间
+    let start = e[0].selectedValues;
+    let end = e[1].selectedValues;
+    let start_value = start.join('-');
+    let end_value = end.join('-');
+    form.value.term_of = [start_value, end_value];
+  }
+  toCancel();
+};
+// 关闭
+const toCancel = () => {
+  popup.value = { show: false };
+};
+// 保存
+const toSave = async (e) => {
+  let res: IQueryResult;
+  delete e.lab_name;
+  e.term_of = e.term_of.split(',');
+  if (id.value) {
+    // if (_.isObject(e.act_time)) e.act_time = e.act_time._id;
+    res = await coomperAxios.update({ ...e, _id: id.value });
+  } else res = await coomperAxios.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: 'xueshu_type' });
+  if (res.errcode == '0') {
+    typeList.value = res.data;
+  }
+  // 是否公开
+  res = await dictAxios.query({ dict_type: 'info_show' });
+  if (res.errcode == '0') {
+    showList.value = res.data;
+  }
+};
+
+// 返回;
+const toBack = () => {
+  window.history.go(-1);
 };
 </script>
-<style scoped lang="scss"></style>
+<style scoped lang="scss">
+.main {
+  .one {
+    .btn {
+      text-align: center;
+      margin: 10px 0;
+    }
+  }
+}
+.logs {
+  display: flex;
+  flex-direction: column;
+  .logs_1 {
+    margin: 0 0 5px 0;
+  }
+  .logs_2 {
+    .list {
+      border: 1px solid #858585;
+      border-radius: 5px;
+      margin: 0 0 5px 0;
+      padding: 5px;
+      .list_1 {
+        display: flex;
+        flex-direction: row;
+        .list_1_btn {
+          text-align: right;
+        }
+      }
+    }
+  }
+}
+</style>

+ 240 - 12
src/views/person/committee/index.vue

@@ -2,32 +2,260 @@
   <div id="index">
     <van-row>
       <van-col span="24" class="main animate__animated animate__backInRight">
-        <van-col span="24" class="one">系统首页</van-col>
+        <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>{{ getDict(i.type, 'type') }}</span>
+              </van-col>
+              <van-col span="24" class="other_1">
+                <span>年龄:</span>
+                <span>{{ i.age }}</span>
+              </van-col>
+              <van-col span="24" class="other_1">
+                <span>单位:</span>
+                <span>{{ i.unit }}</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-button type="warning" size="small" @click="toFile(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>
+    <cPopup :popupInfo="popupInfo">
+      <template v-slot:info>
+        <van-col span="24" class="popup_one" v-if="popupInfo.type == '1'">
+          <van-form @submit="toSave" label-width="auto">
+            <van-cell-group>
+              <van-field name="file" label="佐证资料">
+                <template #input>
+                  <vUpload :file="form.file" :count="2"></vUpload>
+                </template>
+              </van-field>
+            </van-cell-group>
+            <div class="btn">
+              <van-button type="primary" size="small" native-type="submit"> 提交保存 </van-button>
+            </div>
+          </van-form>
+        </van-col>
+      </template>
+    </cPopup>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
-// import type { Ref } from 'vue';
-// reactive, ref, onMounted
-import { onMounted } from 'vue';
+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 { TestStore } from '@common/src/stores/test';
+import { CommitteeStore } from '@common/src/stores/basic/committee';
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
 import type { IQueryResult } from '@/util/types.util';
-const testAxios = TestStore();
-// 分页数据
+const coomperAxios = CommitteeStore();
+const dictAxios = DictDataStore();
+
+// 基本设置
+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 = 10;
+const limit: number = proxy.$limit;
+// 查询
+const searchForm: Ref<any> = ref({});
+
+// 字典表
+const typeList: Ref<any> = ref([]);
+
+// 弹出层
+const popupInfo: Ref<any> = ref({ show: false, type: '1', title: '佐证资料' });
+const form: Ref<any> = ref({});
 // 请求
 onMounted(async () => {
+  // 实验室id
+  lab_id.value = store.getters.lab_id;
+  // 是否可改
+  isInAct.value = store.state.isInAct;
+  // 查询其他信息
+  await searchOther();
+  // 查询列表
   await search({ skip, limit });
 });
 const search = async (e: { skip: number; limit: number }) => {
-  const info = { skip: e.skip, limit: e.limit };
-  const res: IQueryResult = await testAxios.query(info);
-  console.log(res);
+  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 coomperAxios.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 list = [];
+    for (const val of e) {
+      const data = typeList.value.find((i) => i.dict_value == val);
+      if (data) list.push(data.dict_label);
+    }
+    return list.join(',');
+  }
+};
+// 新增
+const toAdd = () => {
+  router.push({ path: '/person/committee/detail' });
+};
+// 信息修改
+const toEdit = (e) => {
+  router.push({ path: '/person/committee/detail', query: { id: e._id } });
+};
+// 信息删除
+const toDel = async (e) => {
+  showConfirmDialog({
+    title: '提示',
+    message: '您确认删除该数据?',
+    width: '100%'
+  })
+    .then(async () => {
+      let res: IQueryResult = await coomperAxios.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 toFile = (e) => {
+  form.value = e;
+  popupInfo.value = { show: true, type: '1', title: '佐证资料' };
+};
+// 提交保存
+const toSave = async (e) => {
+  const obj = { _id: form.value._id, file: e.file };
+  const res: IQueryResult = await coomperAxios.update(obj);
+  if (res.errcode == '0') {
+    showToast({ message: '附件维护成功', type: 'success' });
+    toClose();
+    search({ skip, limit });
+  } else {
+    showToast({ message: `${res.errmsg}`, type: 'fail' });
+  }
+};
+// 关闭弹框
+const toClose = () => {
+  popupInfo.value = { show: false, type: '1', title: '佐证资料' };
+};
+const toPoint = () => {
+  showToast({ message: `当前用户未维护基础信息,不可操作`, type: 'fail' });
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 职务
+  res = await dictAxios.query({ dict_type: 'xueshu_type' });
+  if (res.errcode == '0') {
+    typeList.value = res.data;
+  }
 };
 </script>
-<style scoped lang="scss"></style>
+<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;
+  }
+}
+.popup_one {
+  .btn {
+    text-align: center;
+    margin: 10px 0;
+  }
+}
+</style>