guhongwei %!s(int64=2) %!d(string=hai) anos
pai
achega
1dcc8eeb58

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

@@ -69,6 +69,11 @@ export default [
     meta: { title: '机构管理' },
     component: () => import('@/views/subscribe/organ/index.vue')
   },
+  {
+    path: '/subscribe/organ/detail',
+    meta: { title: '信息管理' },
+    component: () => import('@/views/subscribe/organ/detail.vue')
+  },
   {
     path: '/subscribe/order',
     meta: { title: '订单管理' },

+ 220 - 0
src/views/subscribe/organ/detail.vue

@@ -0,0 +1,220 @@
+<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="rules" @save="toSave">
+            <template #belong>
+              <el-option v-for="i in belongList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #image_file>
+              <cUpload
+                :model="`image_file`"
+                :limit="1"
+                url="/files/zkzx/subscribe/upload"
+                :list="form.image_file"
+                listType="picture-card"
+                @change="onUpload"
+              ></cUpload>
+            </template>
+            <template #is_use>
+              <el-option v-for="i in isuseList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #project>
+              <el-col :span="24" class="project">
+                <el-col :span="24" class="btn">
+                  <el-button type="primary" @click="toAdd('project')">添加</el-button>
+                </el-col>
+                <el-col :span="24" class="list">
+                  <cTable :fields="projectfields" :opera="otheropera" :list="form.project" :usePage="false" @edit="prEdit" @del="prDel"> </cTable>
+                </el-col>
+              </el-col>
+            </template>
+            <template #equipment>
+              <el-col :span="24" class="project">
+                <el-col :span="24" class="btn">
+                  <el-button type="primary" @click="toAdd('equipment')">添加</el-button>
+                </el-col>
+                <el-col :span="24" class="list">
+                  <cTable :fields="projectfields" :opera="otheropera" :list="form.equipment" :usePage="false" @edit="eqEdit" @del="eqDel"> </cTable>
+                </el-col>
+              </el-col>
+            </template>
+          </cForm>
+        </el-col>
+      </el-col>
+    </el-row>
+    <cDialog :dialog="dialog" @handleClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_type" v-if="dialog.type == '1'">
+          <cForm :fields="projectfields" :form="otherForm" :rules="{}" @save="otherSave"> </cForm>
+        </el-col>
+      </template>
+    </cDialog>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import moment from 'moment';
+import type { Ref } from 'vue';
+import { ref, reactive, onMounted } from 'vue';
+import { useRoute } from 'vue-router';
+import { ElMessage } from 'element-plus';
+import type { FormRules } from 'element-plus';
+// 接口
+import { SubscribeOrganStore } from '@common/src/stores/admins/subscribeOrgan';
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const orgaAxios = SubscribeOrganStore();
+const dictData = DictDataStore();
+
+// 路由
+const route = useRoute();
+
+// 加载中
+const loading: Ref<any> = ref(false);
+// 表单
+let form: Ref<any> = ref({});
+let fields: Ref<any[]> = ref([
+  { label: '名称', model: 'name' },
+  { label: '联系人', model: 'contact' },
+  { label: '手机号', model: 'phone' },
+  { label: '联系地址', model: 'address' },
+  { label: '所属', model: 'belong', type: 'select' },
+  { label: '资质', model: 'natural', type: 'textarea' },
+  { label: '成果', model: 'achieve', type: 'textarea' },
+  { label: '条件', model: 'condition', type: 'textarea' },
+  { label: '团队', model: 'team', type: 'textarea' },
+  { label: '图片', model: 'image_file', custom: true },
+  { label: '服务项目', model: 'project', custom: true },
+  { label: '设备共享', model: 'equipment', custom: true },
+  { label: '是否使用', model: 'is_use', type: 'select' }
+]);
+const rules = reactive<FormRules>({});
+// 服务项目,设备共享
+const projectfields: Ref<any> = ref([
+  { label: '名称', model: 'name' },
+  { label: '联系人', model: 'contact' },
+  { label: '手机号', model: 'phone' },
+  { label: '电子邮箱', model: 'email' },
+  { label: '邮编', model: 'post' },
+  { label: '服务内容', model: 'content', type: 'textarea' }
+]);
+const other_type: Ref<any> = ref('');
+// 字典表
+let isuseList: Ref<any> = ref([]);
+let belongList: Ref<any> = ref([]);
+// 弹框
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
+const otherForm: Ref<any> = ref({});
+const otheropera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger' }
+]);
+
+// 请求
+onMounted(async () => {
+  loading.value = true;
+  await searchOther();
+  await search();
+  loading.value = false;
+});
+const search = async () => {
+  let id = route.query.id;
+  let object: any = {};
+  if (id) {
+    let res: IQueryResult = await orgaAxios.fetch(id);
+    if (res.errcode == 0) {
+      object.value = res.data as {};
+    }
+  }
+  form.value = object;
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+// 添加
+const toAdd = (e) => {
+  other_type.value = e;
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 服务修改
+const prEdit = (data) => {
+  other_type.value = 'project';
+  otherForm.value = data;
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 服务删除
+const prDel = (data) => {
+  let list = form.value.project.filter((i) => i.id != data.id);
+  form.value.project = list;
+};
+// 设备修改
+const eqEdit = (data) => {
+  other_type.value = 'equipment';
+  otherForm.value = data;
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 设备删除
+const eqDel = (data) => {
+  let list = form.value.equipment.filter((i) => i.id != data.id);
+  form.value.equipment = list;
+};
+// 提交保存
+const otherSave = (data) => {
+  if (other_type.value == 'project') {
+    if (!data.id) {
+      data.id = moment().valueOf();
+      let project = form.value.project || [];
+      project = [...project, data];
+      form.value.project = project;
+    }
+  } else if (other_type.value == 'equipment') {
+    if (!data.id) {
+      data.id = moment().valueOf();
+      let equipment = form.value.equipment || [];
+      equipment = [...equipment, data];
+      form.value.equipment = equipment;
+    }
+  }
+  toClose();
+};
+
+// 关闭弹框
+const toClose = () => {
+  otherForm.value = {};
+  dialog.value = { title: '信息管理', show: false, type: '1' };
+};
+// 提交
+const toSave = async (data) => {
+  let res: IQueryResult;
+  if (data._id) res = await orgaAxios.update(data);
+  else res = await orgaAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toBack();
+  }
+};
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 是否使用
+  res = await dictData.query({ type: 'common_use' });
+  if (res.errcode == 0) isuseList.value = res.data;
+};
+// 返回上一页
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
+<style scoped lang="scss">
+.project {
+  .btn {
+    margin: 0 0 10px 0;
+  }
+}
+</style>

+ 110 - 21
src/views/subscribe/organ/index.vue

@@ -2,37 +2,126 @@
   <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 #is_use>
+              <el-option v-for="i in isuseList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cButton @toAdd="toAdd()"> </cButton>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel"> </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 { SubscribeOrganStore } from '@common/src/stores/admins/subscribeOrgan';
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const orgaAxios = SubscribeOrganStore();
+const dictData = 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: 'name', isSearch: true },
+  { label: '联系人', model: 'contact', isSearch: true },
+  { label: '手机号', model: 'phone', isSearch: true },
+  { label: '联系地址', model: 'address' },
+  { label: '是否使用', model: 'is_use', format: (i) => getDict(i, 'is_use'), isSearch: true, type: 'select' }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger' }
+]);
+
+// 查询数据
+let searchForm: Ref<any> = ref({});
+
+// 字典表
+let isuseList: 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, type: '7' };
+  let res: IQueryResult = await orgaAxios.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 == 'is_use') {
+    let data: any = isuseList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  }
+};
+// 新增
+const toAdd = () => {
+  router.push({ path: '/subscribe/organ/detail' });
+};
+// 修改
+const toEdit = async (data) => {
+  router.push({ path: '/subscribe/organ/detail', query: { id: data._id } });
+};
+// 删除
+const toDel = async (data) => {
+  let res: IQueryResult = await orgaAxios.del(data._id);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `刪除信息成功` });
+    search({ skip, limit });
+  }
+};
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 是否使用
+  res = await dictData.query({ type: 'common_use' });
+  if (res.errcode == 0) isuseList.value = res.data;
+};
 </script>
-<style scoped lang="scss"></style>
+<style lang="scss" scoped>
+.main {
+  .one {
+    margin: 0 0 10px 0;
+  }
+  .two {
+    margin: 0 0 10px 0;
+  }
+}
+</style>