Browse Source

预约服务

guhongwei 2 years ago
parent
commit
cbedb97acf
3 changed files with 236 additions and 21 deletions
  1. 5 0
      src/router/module/admin.ts
  2. 109 0
      src/views/subscribe/order/detail.vue
  3. 122 21
      src/views/subscribe/order/index.vue

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

@@ -78,5 +78,10 @@ export default [
     path: '/subscribe/order',
     meta: { title: '订单管理' },
     component: () => import('@/views/subscribe/order/index.vue')
+  },
+  {
+    path: '/subscribe/order/detail',
+    meta: { title: '信息管理' },
+    component: () => import('@/views/subscribe/order/detail.vue')
   }
 ];

+ 109 - 0
src/views/subscribe/order/detail.vue

@@ -0,0 +1,109 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_back="true" @toBack="toBack"></cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cForm :fields="fields" :form="form" :rules="{}" :isSave="false" :disabled="true">
+            <template #type>
+              <el-option v-for="i in typeList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #organ_id>
+              <el-option v-for="i in organList" :key="i._id" :label="i.name" :value="i._id"></el-option>
+            </template>
+            <template #is_money>
+              <el-option v-for="i in isnoList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </cForm>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import type { Ref } from 'vue';
+import { onMounted, ref } from 'vue';
+import { useRoute } from 'vue-router';
+// 接口
+import { SubscribeOrderStore } from '@common/src/stores/admins/subscribeOrder';
+import { SubscribeOrganStore } from '@common/src/stores/admins/subscribeOrgan';
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const orderAxios = SubscribeOrderStore();
+const orgaAxios = SubscribeOrganStore();
+const dictAxios = DictDataStore();
+
+// 路由
+const route = useRoute();
+
+// 加载中
+const loading: Ref<any> = ref(false);
+// 表单
+const form: Ref<any> = ref({ project: {} });
+const fields: Ref<any[]> = ref([
+  { label: '服务类型', model: 'type', type: 'select' },
+  { label: '选取机构', model: 'organ_id', type: 'select' },
+  { label: '名称', model: 'project_name' },
+  { label: '联系人', model: 'contact' },
+  { label: '手机号', model: 'phone' },
+  { label: '电子邮箱', model: 'email' },
+  { label: '服务时间', model: 'service_date', type: 'date' },
+  { label: '预约备注', model: 'remerk', type: 'textarea' },
+  { label: '是否开具发票', model: 'is_money', type: 'select' },
+  { label: '单位名称', model: 'company' },
+  { label: '机构代码', model: 'company_code' },
+  { label: '服务状态', model: 'status', type: 'select' }
+]);
+
+// 字典表
+const typeList: Ref<any> = ref([]);
+const organList: Ref<any> = ref([]);
+const statusList: Ref<any> = ref([]);
+const isnoList: Ref<any> = ref([]);
+
+// 请求
+onMounted(async () => {
+  loading.value = true;
+  await searchOther();
+  await search();
+  loading.value = false;
+});
+const search = async () => {
+  let id = route.query.id;
+  if (id) {
+    let res: IQueryResult = await orderAxios.fetch(id);
+    if (res.errcode == '0') {
+      let data = res.data as any;
+      if (data && data.project) data.project_name = data.project.name;
+      form.value = data;
+    }
+  }
+};
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 服务类型
+  res = await dictAxios.query({ type: 'subscribe_type' });
+  if (res.errcode == '0') typeList.value = res.data;
+  // 机构
+  res = await orgaAxios.query({ is_use: '0' });
+  if (res.errcode == '0') organList.value = res.data;
+  // 状态
+  res = await dictAxios.query({ type: 'subscribe_status' });
+  if (res.errcode == '0') statusList.value = res.data;
+  // 是否
+  res = await dictAxios.query({ type: 'common_isno' });
+  if (res.errcode == '0') isnoList.value = res.data;
+};
+// 返回上一页
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
+<style scoped lang="scss"></style>

+ 122 - 21
src/views/subscribe/order/index.vue

@@ -2,37 +2,138 @@
   <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">
+            <template #type>
+              <el-option v-for="i in typeList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #organ_id>
+              <el-option v-for="i in organList" :key="i._id" :label="i.name" :value="i._id"></el-option>
+            </template>
+          </cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @view="toView" @succ="toSucc"></cTable>
+        </el-col>
       </el-col>
     </el-row>
   </div>
 </template>
-
-<script setup lang="ts">
-// 基础
+<script lang="ts" setup>
+import _ from 'lodash';
 import type { Ref } from 'vue';
-// reactive,
-import { onMounted, ref, getCurrentInstance } from 'vue';
+import { ref, onMounted, getCurrentInstance } from 'vue';
+import { useRouter } from 'vue-router';
+import { ElMessage } from 'element-plus';
+
 // 接口
-//import { TestStore } from '@common/src/stores/test';
-//import type { IQueryResult } from '@/util/types.util';
-//const testAxios = TestStore();
+import { SubscribeOrderStore } from '@common/src/stores/admins/subscribeOrder';
+import { SubscribeOrganStore } from '@common/src/stores/admins/subscribeOrgan';
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const orderAxios = SubscribeOrderStore();
+const orgaAxios = SubscribeOrganStore();
+const dictAxios = DictDataStore();
+
 const { proxy } = getCurrentInstance() as any;
+
+// 路由
+const router = useRouter();
+
 // 加载中
-const loading: Ref<any> = ref(false);
-// 分页数据
-//  const skip = 0;
-//  const limit = proxy.limit;;
-// 请求
+const loading = 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: 'type', format: (i) => getDict(i, 'type'), isSearch: true, type: 'select' },
+  { label: '机构', model: 'organ_id', format: (i) => getDict(i, 'organ_id'), isSearch: true, type: 'select' },
+  { label: '服务名称', model: 'project.name', isSearch: true },
+  { label: '联系人', model: 'contact', isSearch: true },
+  { label: '手机号', model: 'phone' },
+  { label: '电子邮箱', model: 'email' },
+  { label: '服务时间', model: 'service_date' },
+  { label: '状态', model: 'status', format: (i) => getDict(i, 'status') }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '查看', method: 'view' },
+  { label: '完成', method: 'succ', type: 'success', confirm: true, display: (i) => i.status == '0' }
+]);
+
+// 查询数据
+let searchForm: Ref<any> = ref({});
+
+// 字典表
+const typeList: Ref<any> = ref([]);
+const organList: Ref<any> = ref([]);
+const statusList: Ref<any> = ref([]);
+
 onMounted(async () => {
   loading.value = true;
-  //  await search({ skip, limit });
+  await searchOther();
+  await search({ skip, limit });
   loading.value = false;
 });
-//const search = async (e: { skip: number; limit: number }) => {
-//  const info = { skip: e.skip, limit: e.limit, ...searchInfo.value  };
-//  const res: IQueryResult = await testAxios.query(info);
-//  console.log(res);
-//};
+// 查询
+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 orderAxios.query(info);
+  if (res.errcode == 0) {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+const getDict = (e, model) => {
+  if (model == 'type') {
+    let data: any = typeList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  } else if (model == 'organ_id') {
+    let data: any = organList.value.find((i: any) => i._id == e);
+    if (data) return data.name;
+    else return '暂无';
+  } else if (model == 'status') {
+    let data: any = statusList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  }
+};
+
+// 修改
+const toView = async (data) => {
+  router.push({ path: '/subscribe/order/detail', query: { id: data._id } });
+};
+const toSucc = async (data) => {
+  data.status = '1';
+  let res: IQueryResult = await orderAxios.update(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `服务完成` });
+    search({ skip, limit });
+  } else {
+    ElMessage({ type: `error`, message: `${res.errmsg}` });
+  }
+};
+
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 服务类型
+  res = await dictAxios.query({ type: 'subscribe_type' });
+  if (res.errcode == '0') typeList.value = res.data;
+  // 机构
+  res = await orgaAxios.query({ is_use: '0' });
+  if (res.errcode == '0') organList.value = res.data;
+  // 状态
+  res = await dictAxios.query({ type: 'subscribe_status' });
+  if (res.errcode == '0') statusList.value = res.data;
+};
 </script>
-<style scoped lang="scss"></style>
+<style lang="scss" scoped></style>