YY hace 2 años
padre
commit
f8088d7181

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

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

+ 0 - 1
src/views/expo/achieve/dock/detail.vue

@@ -73,7 +73,6 @@ onMounted(async () => {
 });
 const search = async () => {
   if (route.query.id) {
-    formFields.value = formFields.value.filter((i) => i.model != 'password');
     let res: IQueryResult = await dock.fetch(route.query.id);
     if (res.errcode == 0) form.value = res.data as {};
   } else form.value = { type: '7', status: '0', user_id: user.value._id };

+ 0 - 1
src/views/expo/channel/live/detail.vue

@@ -64,7 +64,6 @@ onMounted(async () => {
 });
 const search = async () => {
   if (route.query.id) {
-    formFields.value = formFields.value.filter((i) => i.model != 'password');
     let res: IQueryResult = await channel.fetch(route.query.id);
     if (res.errcode == 0) form.value = res.data as {};
   } else form.value = { type: '8', status: '0' };

+ 0 - 1
src/views/expo/train/live/detail.vue

@@ -72,7 +72,6 @@ onMounted(async () => {
 });
 const search = async () => {
   if (route.query.id) {
-    formFields.value = formFields.value.filter((i) => i.model != 'password');
     let res: IQueryResult = await train.fetch(route.query.id);
     if (res.errcode == 0) form.value = res.data as {};
   } else form.value = { type: '9', status: '0' };

+ 1 - 1
src/views/news/column/index.vue

@@ -89,7 +89,7 @@ onMounted(async () => {
 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 info = { limit: limit, skip: skip, ...condition };
   let res: IQueryResult = await newsColumn.query(info);
   if (res.errcode == 0) {
     list.value = res.data;

+ 142 - 0
src/views/news/mess/detail.vue

@@ -0,0 +1,142 @@
+<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_back="true" @toBack="toBack"></cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cForm :span="12" :fields="formFields" :form="form" :rules="rules" @save="onSubmit">
+            <template #column_id>
+              <el-option v-for="(i, index) in columnList" :key="index" :label="i.title" :value="i._id"></el-option>
+            </template>
+            <template #is_use>
+              <el-option v-for="(i, index) in is_useList" :key="index" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #is_money>
+              <el-option v-for="(i, index) in moneyList" :key="index" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #type>
+              <el-option v-for="(i, index) in typeList" :key="index" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #expo_id>
+              <el-option v-for="(i, index) in dockList" :key="index" :label="i.title" :value="i._id"></el-option>
+            </template>
+            <template #image_file="{ item }">
+              <cUpload :model="item.model" :limit="1" url="/files/news/upload" :list="form[item.model]" listType="picture" @change="onUpload"></cUpload>
+            </template>
+            <template #video_file="{ item }">
+              <cUpload :model="item.model" :limit="1" url="/files/news/upload" :list="form[item.model]" listType="picture" @change="onUpload"></cUpload>
+            </template>
+            <template #annex_file="{ item }">
+              <cUpload :model="item.model" :limit="1" url="/files/news/upload" :list="form[item.model]" listType="picture" @change="onUpload"></cUpload>
+            </template>
+            <template #money_file="{ item }">
+              <cUpload :model="item.model" :limit="1" url="/files/news/upload" :list="form[item.model]" listType="picture" @change="onUpload"></cUpload>
+            </template>
+          </cForm>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script setup lang="ts">
+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 store from '@/stores/counter';
+// 接口
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import { NewsMessStore } from '@common/src/stores/allAdmin/newsMess';
+import { NewsColumnStore } from '@common/src/stores/allAdmin/newsColumn';
+import { DockStore } from '@common/src/stores/allAdmin/dock';
+import type { IQueryResult } from '@/util/types.util';
+const newsMess = NewsMessStore();
+const dictData = DictDataStore();
+const newsColumn = NewsColumnStore();
+const dock = DockStore();
+// 路由
+const route = useRoute();
+
+// 加载中
+const loading = ref(false);
+let user: Ref<any> = ref({});
+// 表单
+let form: Ref<any> = ref({});
+let formFields: Ref<any[]> = ref([
+  { label: '所属栏目', model: 'column_id', type: 'select' },
+  { label: '标题', model: 'title' },
+  { label: '信息类型', model: 'type', type: 'select' },
+  { label: '发布时间', model: 'create_date', type: 'date' },
+  { label: '信息来源', model: 'origin' },
+  { label: '信息简介', model: 'brief', type: 'textarea' },
+  { label: '图片文件', model: 'image_file', custom: true },
+  { label: '视频文件', model: 'video_file', custom: true },
+  { label: '附件文件', model: 'annex_file', custom: true },
+  { label: '是否收费', model: 'is_money', type: 'select' },
+  { label: '收费图片', model: 'money_file', custom: true },
+  { label: '关联展会', model: 'expo_id', type: 'select' },
+  { label: '信息内容', model: 'content', type: 'textarea' },
+  { label: '是否启用', model: 'is_use', type: 'select' }
+]);
+const rules = reactive<FormRules>({});
+
+// 字典表
+let typeList: Ref<any> = ref([]);
+let moneyList: Ref<any> = ref([]);
+let is_useList: Ref<any> = ref([]);
+let columnList: Ref<any> = ref([]);
+let dockList: Ref<any> = ref([]);
+onMounted(async () => {
+  loading.value = true;
+  user.value = store.state.user;
+  await searchOther();
+  await search();
+  loading.value = false;
+});
+const search = async () => {
+  if (route.query.id) {
+    let res: IQueryResult = await newsMess.fetch(route.query.id);
+    if (res.errcode == 0) form.value = res.data as {};
+  } else form.value = { is_use: '0' };
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+// 提交
+const onSubmit = async (data) => {
+  let res: IQueryResult;
+  if (data._id) res = await newsMess.update(data);
+  else res = await newsMess.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toBack();
+  }
+};
+
+// 返回上一页
+const toBack = () => {
+  window.history.go(-1);
+};
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 信息类型
+  res = await dictData.query({ type: 'news_type' });
+  if (res.errcode == 0) typeList.value = res.data;
+  // 是否收费
+  res = await dictData.query({ type: 'common_isno' });
+  if (res.errcode == 0) moneyList.value = res.data;
+  // 是否使用
+  res = await dictData.query({ type: 'common_use' });
+  if (res.errcode == 0) is_useList.value = res.data;
+  res = await newsColumn.query();
+  if (res.errcode == 0) columnList.value = res.data;
+  res = await dock.query();
+  if (res.errcode == 0) dockList.value = res.data;
+};
+</script>
+<style scoped lang="scss"></style>

+ 148 - 21
src/views/news/mess/index.vue

@@ -2,37 +2,164 @@
   <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 is_useList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #type>
+              <el-option v-for="i in typeList" :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 { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import { NewsMessStore } from '@common/src/stores/allAdmin/newsMess';
+import { NewsColumnStore } from '@common/src/stores/allAdmin/newsColumn';
+import { DockStore } from '@common/src/stores/allAdmin/dock';
+import type { IQueryResult } from '@/util/types.util';
+const newsMess = NewsMessStore();
+const dictData = DictDataStore();
+const newsColumn = NewsColumnStore();
+const dock = DockStore();
+
 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: 'column_id', format: (i) => getDict(i, 'column_id') },
+  { label: '标题', model: 'title', isSearch: true },
+  { label: '信息类型', model: 'type', format: (i) => getDict(i, 'type'), isSearch: true, type: 'select' },
+  { label: '关联展会', model: 'expo_id', format: (i) => getDict(i, 'expo_id') },
+  { label: '信息来源', model: 'origin' },
+  { label: '是否收费', model: 'is_money', format: (i) => getDict(i, 'is_money') },
+  { 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 is_useList: Ref<any> = ref([]);
+let typeList: Ref<any> = ref([]);
+let dockList: Ref<any> = ref([]);
+let columnList: Ref<any> = ref([]);
+let moneyList: 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 newsMess.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 = is_useList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  } else if (model == 'type') {
+    let data: any = typeList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  } else if (model == 'is_money') {
+    let data: any = moneyList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  } else if (model == 'expo_id') {
+    let data: any = dockList.value.find((i: any) => i._id == e);
+    if (data) return data.title;
+    else return '暂无';
+  } else if (model == 'column_id') {
+    let data: any = columnList.value.find((i: any) => i._id == e);
+    if (data) return data.title;
+    else return '暂无';
+  }
+};
+// 新增
+const toAdd = () => {
+  router.push({ path: '/news/mess/detail' });
+};
+// 修改
+const toEdit = async (data) => {
+  router.push({ path: '/news/mess/detail', query: { id: data._id } });
+};
+// 删除
+const toDel = async (data) => {
+  let res: IQueryResult = await newsMess.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: 'news_type' });
+  if (res.errcode == 0) typeList.value = res.data;
+  // 是否收费
+  res = await dictData.query({ type: 'common_isno' });
+  if (res.errcode == 0) moneyList.value = res.data;
+  // 是否使用
+  res = await dictData.query({ type: 'common_use' });
+  if (res.errcode == 0) is_useList.value = res.data;
+  res = await newsColumn.query();
+  if (res.errcode == 0) columnList.value = res.data;
+  res = await dock.query();
+  if (res.errcode == 0) dockList.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>