فهرست منبع

增加文件代理。消息修改。

jiaxiaoqiang 7 ماه پیش
والد
کامیت
a540922955

+ 1 - 0
.env.development

@@ -6,6 +6,7 @@ VITE_APP_PORT = 3009
 
 # 代理前缀
 VITE_APP_BASE_API = '/dev-api'
+VITE_MEDIA_PREFIX = '/jgfile'
 
 # 上传文件接口地址
 VITE_APP_UPLOAD_URL = 'http://192.168.101.4:9000'

+ 1 - 1
public/version.json

@@ -1,3 +1,3 @@
 {
-  "version": "2.7"
+  "version": "2.8"
 }

+ 14 - 2
src/api/message/index.ts

@@ -17,8 +17,7 @@ export function getUserMessageList(type: string): AxiosPromise {
   });
 }
 
-
-export function getUserMessagePage(type: string): AxiosPromise {
+export function getUserMessagePage(type: string, title?: string): AxiosPromise {
   return request({
     url: "/api/v1/sys/message/user/page",
     method: "post",
@@ -27,9 +26,11 @@ export function getUserMessagePage(type: string): AxiosPromise {
       pageSize: 10,
       messageId: "10",
       type: type,
+      title: title,
     },
   });
 }
+
 // 获取消息详情
 export function getMessageDetail(id: string): AxiosPromise {
   return request({
@@ -37,3 +38,14 @@ export function getMessageDetail(id: string): AxiosPromise {
     method: "get",
   });
 }
+
+// 发送消息
+export function sendMessage(id: string): AxiosPromise {
+  return request({
+    url: "/api/v1/sys/message/send",
+    method: "post",
+    data: {
+      id: id,
+    },
+  });
+}

+ 14 - 13
src/components/Upload/FilesUpload.vue

@@ -1,28 +1,28 @@
 <template>
   <el-upload
     v-model:file-list="fileList"
-    class="upload-demo"
-    :on-change="handleChange"
-    :limit="limit"
     :auto-upload="false"
+    :limit="limit"
+    :on-change="handleChange"
     :show-file-list="false"
+    class="upload-demo"
   >
     <el-button
-      type="primary"
-      :loading="loading"
       :disabled="fileList.length >= limit"
-      >点击上传文件</el-button
-    >
+      :loading="loading"
+      type="primary"
+      >点击上传文件
+    </el-button>
     <template #tip>
-      <div class="tip" v-if="showTip">
+      <div v-if="showTip" class="tip">
         文件类型限制为.jpg,.jpeg,.png,word文档,pdf,大小不超过{{ size }}M
       </div>
     </template>
     <div>
       <el-tag
-        class="file-item"
         v-for="(file, index) in fileList"
         :key="file.name"
+        class="file-item"
         closable
         type="success"
         @close="deleteFile(index)"
@@ -34,12 +34,12 @@
   </el-upload>
   <el-drawer
     v-model="PDFVisible"
+    :append-to-body="true"
     :footer="false"
     :header="false"
     :show-close="false"
     destroy-on-close
     direction="rtl"
-    :append-to-body="true"
     size="972px"
   >
     <VuePdfEmbed :source="pdfSource" annotation-layer text-layer />
@@ -47,9 +47,8 @@
 </template>
 <script lang="ts" setup>
 import { ref } from "vue";
-import { UploadFile, UploadFiles, UploadUserFile } from "element-plus";
+import { UploadFile, UploadUserFile } from "element-plus";
 import { uploadFileApi } from "@/api/file";
-import PDFView from "@/components/PDFView/index.vue";
 import VuePdfEmbed from "vue-pdf-embed";
 
 const props = defineProps({
@@ -133,6 +132,7 @@ const deleteFile = (index: number) => {
   srcList.value.splice(index, 1);
   pdfList.value.splice(index, 1);
   fileNameList.value.splice(index, 1);
+  emit("finished");
 };
 
 const PDFVisible = ref(false);
@@ -146,12 +146,13 @@ const handlePreview = (index: number) => {
 };
 </script>
 
-<style scoped lang="scss">
+<style lang="scss" scoped>
 .tip {
   font-size: 12px;
   color: #e6a23c;
   margin-top: 5px;
 }
+
 .file-item {
   margin-left: 10px;
 }

+ 2 - 0
src/layout/components/header.vue

@@ -102,7 +102,9 @@ const handleCommand = (command: string | number | object) => {
   if (command === "b") {
     logoutApi().then(() => {
       localStorage.setItem("token", "");
+
       router.replace("/login");
+      userStore.$reset();
     });
   }
 };

+ 6 - 0
src/store/index.ts

@@ -4,6 +4,12 @@ import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
 
 const store = createPinia();
 store.use(piniaPluginPersistedstate);
+store.use(({ store }) => {
+  const initialState = JSON.parse(JSON.stringify(store.$state));
+  store.$reset = () => {
+    store.$patch(initialState);
+  };
+});
 
 // 全局注册 store
 export function setupStore(app: App<Element>) {

+ 1 - 0
src/store/modules/user.ts

@@ -13,6 +13,7 @@ export const useUserStore = defineStore("user", () => {
     sysData: [],
     canSetPermission: false,
     canSetIP: false,
+    canCreateMessage: false,
   });
 
   const isGetAuth = ref(false); //是否已经请求过auth接口活的role和menus了

+ 30 - 5
src/views/main/message.vue

@@ -1,6 +1,19 @@
 <template>
   <div class="common-box" style="margin-top: 20px">
     <TopTitle :messageType="messageType" :title="title" icon="laba" />
+    <div>
+      <el-input
+        v-model="searchText"
+        class="input-with-select"
+        clearable
+        placeholder="输入标题可以搜索..."
+        @clear="getDataList"
+      >
+        <template #append>
+          <el-button :icon="Search" @click="getDataList" />
+        </template>
+      </el-input>
+    </div>
     <div class="list-box">
       <el-scrollbar>
         <div
@@ -19,8 +32,9 @@
 </template>
 
 <script lang="ts" setup>
-import {getUserMessageList, getUserMessagePage} from "@/api/message";
+import { getUserMessagePage } from "@/api/message";
 import MessageDetail from "@/views/messages/MessageDetail.vue";
+import { Search } from "@element-plus/icons-vue";
 
 const props = defineProps({
   // 消息类型 0 系统公告 1 工位消息 2-具体某些人员消息
@@ -34,24 +48,29 @@ const props = defineProps({
   },
 });
 
+const searchText = ref("");
 const dataList = ref<any[]>();
 
 onMounted(() => {
-  getUserMessagePage(props.messageType).then((res) => {
-    dataList.value = res.data.records ?? [];
-  });
+  getDataList();
 });
 
 const messageDetailRef = ref<InstanceType<typeof MessageDetail>>();
 const showDetail = (item: any) => {
   messageDetailRef.value?.handleOpenDrawer(item.id);
 };
+
+const getDataList = () => {
+  getUserMessagePage(props.messageType, searchText.value).then((res) => {
+    dataList.value = res.data.records ?? [];
+  });
+};
 </script>
 
 <style lang="scss" scoped>
 .list-box {
   margin-top: 5px;
-  height: calc(100vh - 750px);
+  height: calc(100vh - 780px);
   padding: 0 20px;
 
   .line {
@@ -64,12 +83,18 @@ const showDetail = (item: any) => {
       font-size: 16px;
       color: #1a1a1a;
       text-align: left;
+      white-space: nowrap;
+      width: 73%;
+      overflow: hidden; /*超出宽度部分隐藏*/
+      text-overflow: ellipsis; /*超出部分以点号代替*/
     }
 
     .date {
       font-size: 14px;
       color: #888888;
       text-align: right;
+      width: 35%;
+      flex-shrink: 0;
     }
   }
 }

+ 16 - 5
src/views/messages/MessageDetail.vue

@@ -10,18 +10,29 @@
       <h3>{{ messageObj.title }}</h3>
       <p>{{ messageObj.content }}</p>
       <div class="img-container">
-        <img
+        <el-image
           v-for="(item, index) in messageObj.photoLists"
-          :key="index"
-          :src="getImgUrl(item)"
+          :initial-index="index"
+          :max-scale="7"
+          :min-scale="0.2"
+          :preview-src-list="messageObj.photoLists"
+          :src="item"
+          :zoom-rate="1.2"
           class="img-box"
-          object-fit="cover"
+          fit="cover"
         />
+        <!--        <img-->
+        <!--          v-for="(item, index) in messageObj.photoLists"-->
+        <!--          :key="index"-->
+        <!--          :src="getImgUrl(item)"-->
+        <!--          class="img-box"-->
+        <!--          object-fit="cover"-->
+        <!--        />-->
       </div>
       <div
         v-if="messageObj?.fileLists?.length > 0"
         class="message-time download-btn"
-        @click="downloadFile(messageObj.fileLists[0])"
+        @click="downloadFile(messageObj.fileLists[0].path)"
       >
         相关附件下载
       </div>

+ 38 - 9
src/views/messages/index.vue

@@ -20,16 +20,16 @@
         <MultiUpload v-model="form.photoLists" />
       </template>
       <template #fileLists-form>
-        <FilesUpload v-model:src-list="form.fileLists" :limit="1" />
+        <FilesUpload
+          v-model:file-name-list="photoNameList"
+          v-model:src-list="photoUrlList"
+          :limit="1"
+          @finished="photoChange"
+        />
       </template>
-      <template #menu-left="{ size }">
-        <el-button
-          :disabled="toDeleteIds.length < 1"
-          :size="size"
-          icon="el-icon-delete"
-          type="danger"
-          @click="multipleDelete"
-          >删除
+      <template #menu="{ row }">
+        <el-button v-if="row.state == '0'" type="primary" @click="sendMsg(row)"
+          >发送
         </el-button>
       </template>
     </avue-crud>
@@ -49,9 +49,25 @@ import { useCrud } from "@/hooks/userCrud";
 import { useDictionaryStore } from "@/store";
 import MultiUpload from "@/components/Upload/MultiUpload.vue";
 import FilesUpload from "@/components/Upload/FilesUpload.vue";
+import { sendMessage } from "@/api/message/index.ts";
 
 const userTableRef = ref(null);
 
+const photoUrlList = ref([]);
+const photoNameList = ref([]);
+const photoChange = () => {
+  if (photoUrlList.value.length > 0) {
+    form.value.fileLists = [
+      {
+        name: photoNameList.value[0],
+        path: photoUrlList.value[0],
+      },
+    ];
+  } else {
+    form.value.fileLists = [];
+  }
+};
+
 // 数据字典相关
 const { dicts } = useDictionaryStore();
 
@@ -68,6 +84,7 @@ const crudRef = ref(null); //crudRef.value 获取avue-crud对象
 
 const messageType = ref("");
 const route = useRoute();
+
 onMounted(() => {
   search.value.messageId = "10";
   search.value.type = messageType.value = route.params.type;
@@ -84,10 +101,19 @@ onMounted(() => {
   dataList();
 });
 
+const sendMsg = (row) => {
+  sendMessage(row.id).then(() => {
+    page.value.currentPage = 1;
+    dataList();
+  });
+};
+
 // 设置表格列或者其他自定义的option
 option.value = Object.assign(option.value, {
   selection: true,
   editBtn: false,
+  viewBtn: false,
+  delBtn: false,
   column: [
     {
       label: "创建人",
@@ -99,6 +125,7 @@ option.value = Object.assign(option.value, {
       label: "消息标题",
       prop: "title",
       search: true,
+      rules: [{ required: true }],
     },
     {
       label: "用户id ",
@@ -163,6 +190,8 @@ option.value = Object.assign(option.value, {
       search: true,
       type: "textarea",
       overHidden: true,
+      required: true,
+      rules: [{ required: true }],
     },
     {
       label: "消息类型",

+ 6 - 0
vite.config.ts

@@ -66,6 +66,11 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
           rewrite: (path) =>
             path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""),
         },
+        [env.VITE_MEDIA_PREFIX]: {
+          changeOrigin: true,
+          // 接口地址
+          target: env.VITE_APP_UPLOAD_URL,
+        },
       },
     },
     plugins: [
@@ -246,6 +251,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
     },
   };
 });
+
 function updateVersion() {
   return {
     name: "update-version",

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 358 - 0
vite.config.ts.timestamp-1730356995889-b75240e8081e7.mjs