Browse Source

修改多媒体

zs 1 year ago
parent
commit
710e4bdf26

+ 0 - 5
src/router/index.ts

@@ -125,11 +125,6 @@ const router = createRouter({
           meta: { title: '信息管理' },
           component: () => import('@/views/basic/apart/detail.vue')
         },
-        {
-          path: '/basic/guide',
-          meta: { title: '导游导览管理' },
-          component: () => import('@/views/basic/guide/index.vue')
-        },
         {
           path: '/basic/place',
           meta: { title: '景区景点管理' },

+ 52 - 0
src/stores/info/media.ts

@@ -0,0 +1,52 @@
+import { ref, computed } from 'vue';
+import { defineStore } from 'pinia';
+import { AxiosWrapper } from '@/util/axios-wrapper';
+import _ from 'lodash';
+
+import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
+const axios = new AxiosWrapper();
+const api = {
+  url: `/travel/v1/api/media`
+};
+export const MediaStore = defineStore('media', () => {
+  const count = ref(0);
+  const doubleCount = computed(() => count.value * 2);
+  function increment() {
+    count.value++;
+  }
+  const query = async ({ skip = 0, limit = undefined, ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    let cond: IQueryType = {};
+    if (skip) cond.skip = skip;
+    if (limit) cond.limit = limit;
+    cond = { ...cond, ...info };
+    const res = await axios.$get(`${api.url}`, cond);
+    return res;
+  };
+  const fetch = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/${payload}`);
+    return res;
+  };
+  const create = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}`, payload);
+    return res;
+  };
+  const update = async (payload: any): Promise<IQueryResult> => {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  };
+  const del = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$delete(`${api.url}/${payload}`);
+    return res;
+  };
+  return {
+    count,
+    doubleCount,
+    increment,
+    query,
+    fetch,
+    create,
+    update,
+    del
+  };
+});

+ 0 - 24
src/views/basic/guide/index.vue

@@ -1,24 +0,0 @@
-<template>
-  <div id="index">
-    <el-row>
-      <el-col :span="24" class="main animate__animated animate__backInRight">
-        <el-col :span="24" class="one">
-          <bTable :type="type"></bTable>
-        </el-col>
-      </el-col>
-    </el-row>
-  </div>
-</template>
-
-<script setup lang="ts">
-// 基础
-import type { Ref } from 'vue';
-import { ref } from 'vue';
-//类型
-const type: Ref<string> = ref('5');
-</script>
-<style scoped lang="scss">
-.main {
-  padding: 2px;
-}
-</style>

+ 180 - 15
src/views/basic/media/audio/index.vue

@@ -2,40 +2,205 @@
   <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"> </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">
+            <template #is_use="{ row }">
+              <el-switch
+                v-model="row.is_use"
+                inline-prompt
+                active-text="是"
+                inactive-text="否"
+                active-value="0"
+                inactive-value="1"
+                @click="handleChange(row)"
+              ></el-switch>
+            </template>
+          </cTable>
+        </el-col>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave" label-width="auto">
+            <template #file>
+              <cUpload :model="`${'file'}`" :limit="1" url="/files/travel/audio/upload" accept="*" :list="form.file" @change="onUpload"></cUpload>
+            </template>
+            <template #is_use>
+              <el-radio v-for="i in is_useList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
+import store from '@/stores/counter';
+import type { FormRules } from 'element-plus';
 import type { Ref } from 'vue';
-import { onMounted, ref } from 'vue';
-
+import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
 // 接口
-// import { ToolsStore } from '@/stores/tool';
-// import type { IQueryResult } from '@/util/types.util';
-// const toolsAxios = ToolsStore();
-
+import { MediaStore } from '@/stores/info/media';
+import { RegionStore } from '@/stores/basic/region'; // 区域
+import { DictDataStore } from '@/stores/basic/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const mediaAxios = MediaStore();
+const regionAxios = RegionStore();
+const dictAxios = DictDataStore();
+const { proxy } = getCurrentInstance() as any;
 // 加载中
 const loading: Ref<any> = ref(false);
-
+let user: Ref<any> = ref(store.state.user);
+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: 'region', type: 'select', format: (i: any) => getDict(i) },
+  { label: '名称', model: 'name', isSearch: true },
+  { label: '创建时间', model: 'create_time' },
+  { label: '排序', model: 'sort', type: 'number' },
+  { label: '是否启用', model: 'is_use', custom: true }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger', display: (i: any) => i.region == user.value.region || user.value.type == '0' }
+]);
+// 查询数据
+let searchForm: Ref<any> = ref({});
+// 字典表
+let regionList: Ref<any> = ref([]);
+let is_useList: Ref<any> = ref([]);
+// 弹框
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
+const form: Ref<any> = ref({ file: [] });
+const formFields: Ref<any> = ref([
+  { label: '名称', model: 'name' },
+  { label: '创建时间', model: 'create_time', type: 'datetime' },
+  { label: '音频', model: 'file', custom: true },
+  { label: '排序', model: 'sort', type: 'number' },
+  { label: '简介', model: 'brief', type: 'textarea' },
+  { label: '是否启用', model: 'is_use', type: 'radio' }
+]);
+const rules = reactive<FormRules>({
+  name: [{ required: true, message: '名称', trigger: 'blur' }],
+  brief: [{ required: true, message: '简介', trigger: 'blur' }],
+  file: [{ required: true, message: '音频', trigger: 'blur' }],
+  create_time: [{ required: true, message: '创建时间', trigger: 'blur' }],
+  sort: [{ required: true, message: '排序', trigger: 'blur' }]
+});
 // 请求
 onMounted(async () => {
   loading.value = true;
-  search();
+  await searchOther();
+  await search({ skip, limit });
   loading.value = false;
 });
-const search = async () => {
-  // let res: IQueryResult = await toolsAxios.dataCount();
-  // if (res.errcode == '0') {
-  //   info.value = res.data;
-  // }
+const search = async (e: { skip: number; limit: number }) => {
+  const info = { skip: e.skip, limit: e.limit, ...searchForm.value, type: '0' };
+  const res: IQueryResult = await mediaAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query: any) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+const getDict = (value: any) => {
+  if (value) {
+    let data = regionList.value.find((i: any) => i._id == value);
+    if (data) return data.name;
+    else return '暂无';
+  }
+};
+// 提交保存
+const toSave = async (data: any) => {
+  let res: IQueryResult;
+  if (data._id) res = await mediaAxios.update(data);
+  else res = await mediaAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toClose();
+  }
+};
+// 新增
+const toAdd = () => {
+  form.value = { region: user.value.region || '', type: '0' };
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 修改
+const toEdit = async (data: any) => {
+  let res: IQueryResult = await mediaAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '信息管理', show: true, type: '1' };
+  }
+};
+// 删除
+const toDel = async (data: any) => {
+  let res: IQueryResult = await mediaAxios.del(data._id);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `刪除信息成功` });
+    search({ skip, limit });
+  }
+};
+
+// 关闭弹框
+const toClose = () => {
+  form.value = { file: [] };
+  dialog.value = { show: false };
+  search({ skip, limit });
+};
+
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult = await dictAxios.query({ type: 'is_use', is_use: '0' });
+  if (res.errcode == 0) is_useList.value = res.data;
+  // 区域
+  res = await regionAxios.query({ is_use: '0' });
+  if (res.errcode == '0') regionList.value = res.data;
+};
+// 修改是否启用
+const handleChange = (row: any) => {
+  const text = row.is_use === '0' ? '启用' : '停用';
+  ElMessageBox.confirm('确认要"' + text + '""' + row.name + '"吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  })
+    .then(async () => {
+      let res: IQueryResult;
+      if (row._id) res = await mediaAxios.update(row);
+      if (res.errcode == 0) {
+        ElMessage({ type: `success`, message: `修改成功` });
+      }
+    })
+    .catch(() => {
+      row.is_use = row.is_use === '0' ? '1' : '0';
+    });
 };
 </script>
 <style scoped lang="scss">
 .main {
-  padding: 2px;
+  .two {
+    margin: 0 0 10px 0;
+  }
 }
 </style>

+ 180 - 15
src/views/basic/media/url/index.vue

@@ -2,40 +2,205 @@
   <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"> </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">
+            <template #is_use="{ row }">
+              <el-switch
+                v-model="row.is_use"
+                inline-prompt
+                active-text="是"
+                inactive-text="否"
+                active-value="0"
+                inactive-value="1"
+                @click="handleChange(row)"
+              ></el-switch>
+            </template>
+          </cTable>
+        </el-col>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave" label-width="auto">
+            <template #file>
+              <cUpload :model="`${'file'}`" :limit="1" url="/files/travel/audio/upload" accept="*" :list="form.file" @change="onUpload"></cUpload>
+            </template>
+            <template #is_use>
+              <el-radio v-for="i in is_useList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
+import store from '@/stores/counter';
+import type { FormRules } from 'element-plus';
 import type { Ref } from 'vue';
-import { onMounted, ref } from 'vue';
-
+import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
 // 接口
-// import { ToolsStore } from '@/stores/tool';
-// import type { IQueryResult } from '@/util/types.util';
-// const toolsAxios = ToolsStore();
-
+import { MediaStore } from '@/stores/info/media';
+import { RegionStore } from '@/stores/basic/region'; // 区域
+import { DictDataStore } from '@/stores/basic/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const mediaAxios = MediaStore();
+const regionAxios = RegionStore();
+const dictAxios = DictDataStore();
+const { proxy } = getCurrentInstance() as any;
 // 加载中
 const loading: Ref<any> = ref(false);
-
+let user: Ref<any> = ref(store.state.user);
+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: 'region', type: 'select', format: (i: any) => getDict(i) },
+  { label: '名称', model: 'name', isSearch: true },
+  { label: '创建时间', model: 'create_time' },
+  { label: '排序', model: 'sort', type: 'number' },
+  { label: '是否启用', model: 'is_use', custom: true }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger', display: (i: any) => i.region == user.value.region || user.value.type == '0' }
+]);
+// 查询数据
+let searchForm: Ref<any> = ref({});
+// 字典表
+let regionList: Ref<any> = ref([]);
+let is_useList: Ref<any> = ref([]);
+// 弹框
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
+const form: Ref<any> = ref({ file: [] });
+const formFields: Ref<any> = ref([
+  { label: '名称', model: 'name' },
+  { label: '创建时间', model: 'create_time', type: 'datetime' },
+  { label: '图片', model: 'file', custom: true },
+  { label: '排序', model: 'sort', type: 'number' },
+  { label: '简介', model: 'brief', type: 'textarea' },
+  { label: '是否启用', model: 'is_use', type: 'radio' }
+]);
+const rules = reactive<FormRules>({
+  name: [{ required: true, message: '名称', trigger: 'blur' }],
+  brief: [{ required: true, message: '简介', trigger: 'blur' }],
+  file: [{ required: true, message: '图片', trigger: 'blur' }],
+  create_time: [{ required: true, message: '创建时间', trigger: 'blur' }],
+  sort: [{ required: true, message: '排序', trigger: 'blur' }]
+});
 // 请求
 onMounted(async () => {
   loading.value = true;
-  search();
+  await searchOther();
+  await search({ skip, limit });
   loading.value = false;
 });
-const search = async () => {
-  // let res: IQueryResult = await toolsAxios.dataCount();
-  // if (res.errcode == '0') {
-  //   info.value = res.data;
-  // }
+const search = async (e: { skip: number; limit: number }) => {
+  const info = { skip: e.skip, limit: e.limit, ...searchForm.value, type: '1' };
+  const res: IQueryResult = await mediaAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query: any) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+const getDict = (value: any) => {
+  if (value) {
+    let data = regionList.value.find((i: any) => i._id == value);
+    if (data) return data.name;
+    else return '暂无';
+  }
+};
+// 提交保存
+const toSave = async (data: any) => {
+  let res: IQueryResult;
+  if (data._id) res = await mediaAxios.update(data);
+  else res = await mediaAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toClose();
+  }
+};
+// 新增
+const toAdd = () => {
+  form.value = { region: user.value.region || '', type: '1' };
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 修改
+const toEdit = async (data: any) => {
+  let res: IQueryResult = await mediaAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '信息管理', show: true, type: '1' };
+  }
+};
+// 删除
+const toDel = async (data: any) => {
+  let res: IQueryResult = await mediaAxios.del(data._id);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `刪除信息成功` });
+    search({ skip, limit });
+  }
+};
+
+// 关闭弹框
+const toClose = () => {
+  form.value = { file: [] };
+  dialog.value = { show: false };
+  search({ skip, limit });
+};
+
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult = await dictAxios.query({ type: 'is_use', is_use: '0' });
+  if (res.errcode == 0) is_useList.value = res.data;
+  // 区域
+  res = await regionAxios.query({ is_use: '0' });
+  if (res.errcode == '0') regionList.value = res.data;
+};
+// 修改是否启用
+const handleChange = (row: any) => {
+  const text = row.is_use === '0' ? '启用' : '停用';
+  ElMessageBox.confirm('确认要"' + text + '""' + row.name + '"吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  })
+    .then(async () => {
+      let res: IQueryResult;
+      if (row._id) res = await mediaAxios.update(row);
+      if (res.errcode == 0) {
+        ElMessage({ type: `success`, message: `修改成功` });
+      }
+    })
+    .catch(() => {
+      row.is_use = row.is_use === '0' ? '1' : '0';
+    });
 };
 </script>
 <style scoped lang="scss">
 .main {
-  padding: 2px;
+  .two {
+    margin: 0 0 10px 0;
+  }
 }
 </style>

+ 180 - 15
src/views/basic/media/video/index.vue

@@ -2,40 +2,205 @@
   <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"> </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">
+            <template #is_use="{ row }">
+              <el-switch
+                v-model="row.is_use"
+                inline-prompt
+                active-text="是"
+                inactive-text="否"
+                active-value="0"
+                inactive-value="1"
+                @click="handleChange(row)"
+              ></el-switch>
+            </template>
+          </cTable>
+        </el-col>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave" label-width="auto">
+            <template #file>
+              <cUpload :model="`${'file'}`" :limit="1" url="/files/travel/audio/upload" accept="*" :list="form.file" @change="onUpload"></cUpload>
+            </template>
+            <template #is_use>
+              <el-radio v-for="i in is_useList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
+import store from '@/stores/counter';
+import type { FormRules } from 'element-plus';
 import type { Ref } from 'vue';
-import { onMounted, ref } from 'vue';
-
+import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
 // 接口
-// import { ToolsStore } from '@/stores/tool';
-// import type { IQueryResult } from '@/util/types.util';
-// const toolsAxios = ToolsStore();
-
+import { MediaStore } from '@/stores/info/media';
+import { RegionStore } from '@/stores/basic/region'; // 区域
+import { DictDataStore } from '@/stores/basic/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const mediaAxios = MediaStore();
+const regionAxios = RegionStore();
+const dictAxios = DictDataStore();
+const { proxy } = getCurrentInstance() as any;
 // 加载中
 const loading: Ref<any> = ref(false);
-
+let user: Ref<any> = ref(store.state.user);
+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: 'region', type: 'select', format: (i: any) => getDict(i) },
+  { label: '名称', model: 'name', isSearch: true },
+  { label: '创建时间', model: 'create_time' },
+  { label: '排序', model: 'sort', type: 'number' },
+  { label: '是否启用', model: 'is_use', custom: true }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger', display: (i: any) => i.region == user.value.region || user.value.type == '0' }
+]);
+// 查询数据
+let searchForm: Ref<any> = ref({});
+// 字典表
+let regionList: Ref<any> = ref([]);
+let is_useList: Ref<any> = ref([]);
+// 弹框
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
+const form: Ref<any> = ref({ file: [] });
+const formFields: Ref<any> = ref([
+  { label: '名称', model: 'name' },
+  { label: '创建时间', model: 'create_time', type: 'datetime' },
+  { label: '视频', model: 'file', custom: true },
+  { label: '排序', model: 'sort', type: 'number' },
+  { label: '简介', model: 'brief', type: 'textarea' },
+  { label: '是否启用', model: 'is_use', type: 'radio' }
+]);
+const rules = reactive<FormRules>({
+  name: [{ required: true, message: '名称', trigger: 'blur' }],
+  brief: [{ required: true, message: '简介', trigger: 'blur' }],
+  file: [{ required: true, message: '视频', trigger: 'blur' }],
+  create_time: [{ required: true, message: '创建时间', trigger: 'blur' }],
+  sort: [{ required: true, message: '排序', trigger: 'blur' }]
+});
 // 请求
 onMounted(async () => {
   loading.value = true;
-  search();
+  await searchOther();
+  await search({ skip, limit });
   loading.value = false;
 });
-const search = async () => {
-  // let res: IQueryResult = await toolsAxios.dataCount();
-  // if (res.errcode == '0') {
-  //   info.value = res.data;
-  // }
+const search = async (e: { skip: number; limit: number }) => {
+  const info = { skip: e.skip, limit: e.limit, ...searchForm.value, type: '2' };
+  const res: IQueryResult = await mediaAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query: any) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+const getDict = (value: any) => {
+  if (value) {
+    let data = regionList.value.find((i: any) => i._id == value);
+    if (data) return data.name;
+    else return '暂无';
+  }
+};
+// 提交保存
+const toSave = async (data: any) => {
+  let res: IQueryResult;
+  if (data._id) res = await mediaAxios.update(data);
+  else res = await mediaAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toClose();
+  }
+};
+// 新增
+const toAdd = () => {
+  form.value = { region: user.value.region || '', type: '2' };
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 修改
+const toEdit = async (data: any) => {
+  let res: IQueryResult = await mediaAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '信息管理', show: true, type: '1' };
+  }
+};
+// 删除
+const toDel = async (data: any) => {
+  let res: IQueryResult = await mediaAxios.del(data._id);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `刪除信息成功` });
+    search({ skip, limit });
+  }
+};
+
+// 关闭弹框
+const toClose = () => {
+  form.value = { file: [] };
+  dialog.value = { show: false };
+  search({ skip, limit });
+};
+
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult = await dictAxios.query({ type: 'is_use', is_use: '0' });
+  if (res.errcode == 0) is_useList.value = res.data;
+  // 区域
+  res = await regionAxios.query({ is_use: '0' });
+  if (res.errcode == '0') regionList.value = res.data;
+};
+// 修改是否启用
+const handleChange = (row: any) => {
+  const text = row.is_use === '0' ? '启用' : '停用';
+  ElMessageBox.confirm('确认要"' + text + '""' + row.name + '"吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  })
+    .then(async () => {
+      let res: IQueryResult;
+      if (row._id) res = await mediaAxios.update(row);
+      if (res.errcode == 0) {
+        ElMessage({ type: `success`, message: `修改成功` });
+      }
+    })
+    .catch(() => {
+      row.is_use = row.is_use === '0' ? '1' : '0';
+    });
 };
 </script>
 <style scoped lang="scss">
 .main {
-  padding: 2px;
+  .two {
+    margin: 0 0 10px 0;
+  }
 }
 </style>

+ 2 - 1
src/views/system/menus/index.vue

@@ -178,9 +178,10 @@ const toDelete = (data: any) => {
       let res: IQueryResult = await menusAxios.del(data._id);
       if (res.errcode == 0) {
         ElMessage({ type: `success`, message: `删除成功` });
+        search();
       }
     })
-    .catch(() => { });
+    .catch(() => {});
 };
 // 获取一维(平面)的菜单数据
 const getOneDimensionList = () => {