|
@@ -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>
|