Browse Source

意见反馈

zs 1 năm trước cách đây
mục cha
commit
b631c41e62
2 tập tin đã thay đổi với 124 bổ sung15 xóa
  1. 52 0
      src/stores/problem/opinion.ts
  2. 72 15
      src/views/problem/opinion/index.vue

+ 52 - 0
src/stores/problem/opinion.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/opinion`
+};
+export const OpinionStore = defineStore('opinion', () => {
+  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
+  };
+});

+ 72 - 15
src/views/problem/opinion/index.vue

@@ -2,40 +2,97 @@
   <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">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @view="toView"> </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="{}" :isSave="true" :disabled="true">
+            <template #file>
+              <cUpload :model="`${'file'}`" :limit="1" listType="picture-card" url="/files/travel/opinion/upload" accept="*" :list="form.file"></cUpload>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
 import type { Ref } from 'vue';
-import { onMounted, ref } from 'vue';
-
+import { ref, onMounted, getCurrentInstance } from 'vue';
 // 接口
-// import { ToolsStore } from '@/stores/tool';
-// import type { IQueryResult } from '@/util/types.util';
-// const toolsAxios = ToolsStore();
-
+import { OpinionStore } from '@/stores/problem/opinion';
+import type { IQueryResult } from '@/util/types.util';
+const opinionAxios = OpinionStore();
+const { proxy } = getCurrentInstance() as any;
 // 加载中
 const loading: Ref<any> = 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: 'user.nick_name' },
+  { label: '手机号', model: 'phone', isSearch: true },
+  { label: '内容', model: 'content' }
+]);
+// 操作
+let opera: Ref<any[]> = ref([{ label: '查看', method: 'view' }]);
+// 查询数据
+let searchForm: 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: 'phone' },
+  { label: '图片', model: 'file', custom: true },
+  { label: '内容', model: 'content', type: 'textarea' }
+]);
 // 请求
 onMounted(async () => {
   loading.value = true;
-  search();
+  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 };
+  const res: IQueryResult = await opinionAxios.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 toView = async (data: any) => {
+  let res: IQueryResult = await opinionAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '信息管理', show: true, type: '1' };
+  }
+};
+// 关闭弹框
+const toClose = () => {
+  form.value = { file: [] };
+  dialog.value = { show: false };
+  search({ skip, limit });
 };
 </script>
 <style scoped lang="scss">
 .main {
-  padding: 2px;
+  .two {
+    margin: 0 0 10px 0;
+  }
 }
 </style>