Jelajahi Sumber

栏目管理

YY 2 tahun lalu
induk
melakukan
9f5b41a875

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

@@ -44,6 +44,11 @@ export default [
     meta: { title: '栏目管理' },
     component: () => import('@/views/news/column/index.vue')
   },
+  {
+    path: '/news/column/detail',
+    meta: { title: '信息管理' },
+    component: () => import('@/views/news/column/detail.vue')
+  },
   {
     path: '/news/mess',
     meta: { title: '信息管理' },

+ 1 - 30
src/views/expo/achieve/dock/index.vue

@@ -17,15 +17,6 @@
         </el-col>
       </el-col>
     </el-row>
-    <cDialog :dialog="dialog" @handleClose="toClose">
-      <template v-slot:info>
-        <cForm v-if="dialog.type == '1'" :span="24" :fields="formFields" :form="form" :rules="{}" @save="onSubmit">
-          <template #status>
-            <el-option v-for="(i, index) in statusList" :key="index" :label="i.label" :value="i.value"></el-option>
-          </template>
-        </cForm>
-      </template>
-    </cDialog>
   </div>
 </template>
 <script lang="ts" setup>
@@ -70,10 +61,7 @@ let opera: Ref<any[]> = ref([
   { label: '修改', method: 'edit', display: (i) => i.status == '0' },
   { label: '删除', method: 'del', confirm: true, type: 'danger', display: (i) => i.status == '0' }
 ]);
-const dialog: Ref<{ type: string; show: boolean; title: string }> = ref({ type: '1', show: false, title: '信息管理' });
-let form: Ref<any> = ref({});
-// 表单
-let formFields: Ref<any[]> = ref([{ label: '状态', model: 'status', type: 'select' }]);
+
 // 查询数据
 let searchForm: Ref<any> = ref({});
 // 字典表
@@ -115,23 +103,6 @@ const toAdd = () => {
 const toEdit = async (data) => {
   router.push({ path: '/expo/achieve/dock/detail', query: { id: data._id } });
 };
-// 提交
-const onSubmit = async (data) => {
-  let res: IQueryResult;
-  if (data._id) res = await dock.update(data);
-  else res = await dock.create(data);
-  if (res.errcode == 0) {
-    ElMessage({ type: `success`, message: `审核成功` });
-    toClose();
-  }
-};
-// 弹框关闭
-const toClose = () => {
-  form.value = {};
-  searchForm.value = {};
-  dialog.value = { title: '信息管理', show: false, type: '1' };
-  search({ skip, limit });
-};
 // 删除
 const toDel = async (data) => {
   let res: IQueryResult = await dock.del(data._id);

+ 0 - 30
src/views/expo/channel/live/index.vue

@@ -20,15 +20,6 @@
         </el-col>
       </el-col>
     </el-row>
-    <cDialog :dialog="dialog" @handleClose="toClose">
-      <template v-slot:info>
-        <cForm v-if="dialog.type == '1'" :span="24" :fields="formFields" :form="form" :rules="{}" @save="onSubmit">
-          <template #status>
-            <el-option v-for="(i, index) in statusList" :key="index" :label="i.label" :value="i.value"></el-option>
-          </template>
-        </cForm>
-      </template>
-    </cDialog>
   </div>
 </template>
 <script lang="ts" setup>
@@ -72,10 +63,6 @@ let opera: Ref<any[]> = ref([
   { label: '修改', method: 'edit', display: (i) => i.status == '0' },
   { label: '删除', method: 'del', confirm: true, type: 'danger', display: (i) => i.status == '0' }
 ]);
-const dialog: Ref<{ type: string; show: boolean; title: string }> = ref({ type: '1', show: false, title: '信息管理' });
-let form: Ref<any> = ref({});
-// 表单
-let formFields: Ref<any[]> = ref([{ label: '状态', model: 'status', type: 'select' }]);
 // 查询数据
 let searchForm: Ref<any> = ref({});
 // 字典表
@@ -122,23 +109,6 @@ const toAdd = () => {
 const toEdit = async (data) => {
   router.push({ path: '/expo/channel/live/detail', query: { id: data._id } });
 };
-// 提交
-const onSubmit = async (data) => {
-  let res: IQueryResult;
-  if (data._id) res = await channel.update(data);
-  else res = await channel.create(data);
-  if (res.errcode == 0) {
-    ElMessage({ type: `success`, message: `审核成功` });
-    toClose();
-  }
-};
-// 弹框关闭
-const toClose = () => {
-  form.value = {};
-  searchForm.value = {};
-  dialog.value = { title: '信息管理', show: false, type: '1' };
-  search({ skip, limit });
-};
 // 删除
 const toDel = async (data) => {
   let res: IQueryResult = await channel.del(data._id);

+ 2 - 30
src/views/expo/train/live/index.vue

@@ -17,15 +17,6 @@
         </el-col>
       </el-col>
     </el-row>
-    <cDialog :dialog="dialog" @handleClose="toClose">
-      <template v-slot:info>
-        <cForm v-if="dialog.type == '1'" :span="24" :fields="formFields" :form="form" :rules="{}" @save="onSubmit">
-          <template #status>
-            <el-option v-for="(i, index) in statusList" :key="index" :label="i.label" :value="i.value"></el-option>
-          </template>
-        </cForm>
-      </template>
-    </cDialog>
   </div>
 </template>
 <script lang="ts" setup>
@@ -70,10 +61,7 @@ let opera: Ref<any[]> = ref([
   { label: '修改', method: 'edit', display: (i) => i.status == '0' },
   { label: '删除', method: 'del', confirm: true, type: 'danger', display: (i) => i.status == '0' }
 ]);
-const dialog: Ref<{ type: string; show: boolean; title: string }> = ref({ type: '1', show: false, title: '信息管理' });
-let form: Ref<any> = ref({});
-// 表单
-let formFields: Ref<any[]> = ref([{ label: '状态', model: 'status', type: 'select' }]);
+
 // 查询数据
 let searchForm: Ref<any> = ref({});
 // 字典表
@@ -115,23 +103,7 @@ const toAdd = () => {
 const toEdit = async (data) => {
   router.push({ path: '/expo/train/live/detail', query: { id: data._id } });
 };
-// 提交
-const onSubmit = async (data) => {
-  let res: IQueryResult;
-  if (data._id) res = await train.update(data);
-  else res = await train.create(data);
-  if (res.errcode == 0) {
-    ElMessage({ type: `success`, message: `审核成功` });
-    toClose();
-  }
-};
-// 弹框关闭
-const toClose = () => {
-  form.value = {};
-  searchForm.value = {};
-  dialog.value = { title: '信息管理', show: false, type: '1' };
-  search({ skip, limit });
-};
+
 // 删除
 const toDel = async (data) => {
   let res: IQueryResult = await train.del(data._id);

+ 96 - 0
src/views/news/column/detail.vue

@@ -0,0 +1,96 @@
+<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 #place>
+              <el-option v-for="(i, index) in placeList" :key="index" :label="i.label" :value="i.value"></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>
+          </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 { NewsColumnStore } from '@common/src/stores/allAdmin/newsColumn';
+
+import type { IQueryResult } from '@/util/types.util';
+const newsColumn = NewsColumnStore();
+const dictData = DictDataStore();
+
+// 路由
+const route = useRoute();
+
+// 加载中
+const loading = ref(false);
+let user: Ref<any> = ref({});
+// 表单
+let form: Ref<any> = ref({});
+let formFields: Ref<any[]> = ref([
+  { label: '名称', model: 'title' },
+  { label: '位置', model: 'place', type: 'select' },
+  { label: '简介', model: 'brief', type: 'textarea' },
+  { label: '是否启用', model: 'is_use', type: 'select' }
+]);
+const rules = reactive<FormRules>({});
+
+// 字典表
+let is_useList: Ref<any> = ref([]);
+let placeList: 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) {
+    formFields.value = formFields.value.filter((i) => i.model != 'password');
+    let res: IQueryResult = await newsColumn.fetch(route.query.id);
+    if (res.errcode == 0) form.value = res.data as {};
+  } else form.value = { is_use: '0' };
+};
+// 提交
+const onSubmit = async (data) => {
+  let res: IQueryResult;
+  if (data._id) res = await newsColumn.update(data);
+  else res = await newsColumn.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: 'common_use' });
+  if (res.errcode == 0) is_useList.value = res.data;
+  // 位置
+  res = await dictData.query({ type: 'news_place' });
+  if (res.errcode == 0) placeList.value = res.data;
+};
+</script>
+<style scoped lang="scss"></style>

+ 149 - 21
src/views/news/column/index.vue

@@ -2,37 +2,165 @@
   <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 #place>
+              <el-option v-for="i in placeList" :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>
+    <cDialog :dialog="dialog" @handleClose="toClose">
+      <template v-slot:info>
+        <cForm v-if="dialog.type == '1'" :span="24" :fields="formFields" :form="form" :rules="{}" @save="onSubmit">
+          <template #is_use>
+            <el-option v-for="(i, index) in is_useList" :key="index" :label="i.label" :value="i.value"></el-option>
+          </template>
+        </cForm>
+      </template>
+    </cDialog>
   </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 { NewsColumnStore } from '@common/src/stores/allAdmin/newsColumn';
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const newsColumn = NewsColumnStore();
+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: 'title', isSearch: true },
+  { label: '位置', model: 'place', format: (i) => getDict(i, 'place'), isSearch: true, type: 'select' },
+  { 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' }
+]);
+const dialog: Ref<{ type: string; show: boolean; title: string }> = ref({ type: '1', show: false, title: '信息管理' });
+let form: Ref<any> = ref({});
+// 表单
+let formFields: Ref<any[]> = ref([{ label: '状态', model: 'status', type: 'select' }]);
+// 查询数据
+let searchForm: Ref<any> = ref({});
+// 字典表
+let is_useList: Ref<any> = ref([]);
+let placeList: 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 newsColumn.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 == 'place') {
+    let data: any = placeList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  }
+};
+// 新增
+const toAdd = () => {
+  router.push({ path: '/news/column/detail' });
+};
+// 修改
+const toEdit = async (data) => {
+  router.push({ path: '/news/column/detail', query: { id: data._id } });
+};
+// 提交
+const onSubmit = async (data) => {
+  let res: IQueryResult;
+  if (data._id) res = await newsColumn.update(data);
+  else res = await newsColumn.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `审核成功` });
+    toClose();
+  }
+};
+// 弹框关闭
+const toClose = () => {
+  form.value = {};
+  searchForm.value = {};
+  dialog.value = { title: '信息管理', show: false, type: '1' };
+  search({ skip, limit });
+};
+// 删除
+const toDel = async (data) => {
+  let res: IQueryResult = await newsColumn.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) is_useList.value = res.data;
+  // 位置
+  res = await dictData.query({ type: 'news_place' });
+  if (res.errcode == 0) placeList.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>