zhangnuoyan 2 年之前
父节点
当前提交
f0f55e8470
共有 4 个文件被更改,包括 211 次插入6 次删除
  1. 4 0
      src/App.vue
  2. 27 0
      src/assets/document/upload.svg
  3. 3 2
      src/components/MessageInput.vue
  4. 177 4
      src/views/Document.vue

+ 4 - 0
src/App.vue

@@ -64,6 +64,10 @@ export default defineComponent({
 .arco-modal-simple .arco-modal-header {
     margin-bottom: 0;
 }
+body {
+    --primary-6: 59, 202, 168;
+    --danger-6: 255, 110, 110;
+}
 </style>
 <style scoped>
 section {

+ 27 - 0
src/assets/document/upload.svg

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="736px" height="100px" viewBox="0 0 736 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <title>待上传</title>
+    <defs>
+        <rect id="path-1" x="0" y="0" width="736" height="100" rx="4"></rect>
+        <mask id="mask-2" maskContentUnits="userSpaceOnUse" maskUnits="objectBoundingBox" x="0" y="0" width="736" height="100" fill="white">
+            <use xlink:href="#path-1"></use>
+        </mask>
+    </defs>
+    <g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
+        <g id="交互+切图" transform="translate(-77, -591)">
+            <g id="待上传" transform="translate(77, 591)">
+                <use id="矩形" stroke="#00AEA3" mask="url(#mask-2)" stroke-width="2" fill-opacity="0.05" fill="#00AEA3" stroke-dasharray="3,3" xlink:href="#path-1"></use>
+                <g id="待上传图标" transform="translate(184, 25)">
+                    <g id="编组-4" transform="translate(7, 0)">
+                        <path d="M28,0 L40,12 L40,46 C40,48.209139 38.209139,50 36,50 L4,50 C1.790861,50 -6.17636919e-16,48.209139 0,46 L0,4 C-2.705415e-16,1.790861 1.790861,1.29399067e-15 4,0 L28,0 Z" id="形状结合" fill="#A1DAFF"></path>
+                        <path d="M36,0 C38.209139,-4.05812251e-16 40,1.790861 40,4 L40,12 L28,0 L36,0 Z" id="形状结合" fill="#48B1F4" transform="translate(34, 6) scale(-1, -1) translate(-34, -6)"></path>
+                    </g>
+                    <g id="编组-3" transform="translate(0, 18)">
+                        <circle id="椭圆形" fill="#18C88A" cx="13" cy="13" r="13"></circle>
+                        <polygon id="路径" fill="#FFFFFF" points="14.4772727 13 14.4772727 18.9090909 11.5227273 18.9090909 11.5227273 13 7.09090909 13 13 7.09090909 18.9090909 13"></polygon>
+                    </g>
+                </g>
+            </g>
+        </g>
+    </g>
+</svg>

+ 3 - 2
src/components/MessageInput.vue

@@ -12,12 +12,13 @@
                 v-model="value"
                 :show-word-limit="value.length > maxLength / 2"
                 :auto-size="{ maxRows: 6 }"
-                placeholder="我想说..."
+                placeholder="输入您想了解的内容,Shift+Enter换行"
                 :style="{
                     flex: 1,
-                    borderRadius: '24px',
+                    borderRadius: '12px',
                     marginTop: '20px',
                     padding: '0px 30px 0 16px',
+                    minHeight: '90px',
                     paddingBottom: `${value.length > maxLength / 2 ? '20px' : ''}`
                 }"
             >

+ 177 - 4
src/views/Document.vue

@@ -39,6 +39,50 @@
                                 <icon-close size="large" />
                             </div>
                         </header>
+                        <div>
+                            <section>
+                                <a-upload
+                                    draggable
+                                    :multiple="true"
+                                    :limit="5"
+                                    @before-upload="onBeforeUpload"
+                                    @exceed-limit="onExceedLimit"
+                                    @before-remove="onBeforeRemove"
+                                    :custom-request="customRequest"
+                                    :show-upload-button="{ showOnExceedLimit: true }"
+                                    accept=".pdf,.doc,.docx,.txt,.csv"
+                                >
+                                    <template #upload-button>
+                                        <div class="upload-main">
+                                            <p>拖拽文档到这里,或<span>点此上传</span></p>
+                                            <span> 支持上传.pdf, .doc, .docx, .txt, .csv文档,大小不超过30M </span>
+                                        </div>
+                                    </template>
+                                </a-upload>
+                            </section>
+                            <div>
+                                <p>
+                                    <span>已解析文件列表</span>
+                                    <span>共0个</span>
+                                </p>
+                                <div>
+                                    <a-table
+                                        :pagination="false"
+                                        row-key="name"
+                                        :columns="columns"
+                                        :data="tableData"
+                                        :row-selection="rowSelection"
+                                        v-model:selectedKeys="selectedKeys"
+                                    >
+                                        <template #methods="{ record }">
+                                            <a-button @click="$modal.info({ title: 'Name', content: record.name })"
+                                                >删除</a-button
+                                            >
+                                        </template>
+                                    </a-table>
+                                </div>
+                            </div>
+                        </div>
                     </div>
                 </template>
             </a-popover>
@@ -46,12 +90,14 @@
     </main>
 </template>
 <script>
-import { defineComponent, ref, inject } from "vue";
+import { defineComponent, ref, inject, reactive } from "vue";
 export default defineComponent({
     components: {},
     setup() {
-        const showUpload = ref(false);
+        const showUpload = ref(true);
         const { helper } = inject("$global");
+        const maxSize = 30 * 1024 * 1024;
+        const fileList = [];
         const DEFAULT_DATA = [
             {
                 background: "rgba(72, 177, 244, 0.06)",
@@ -68,12 +114,121 @@ export default defineComponent({
                 content: "支持勾选多个文档,实现基于限定文档的问答"
             }
         ];
+        const onBeforeUpload = (file) => {
+            if (file.size > maxSize) {
+                helper.message("error", `上传文件大小不能超过10M`);
+                return false;
+            }
+            return true;
+        };
+        const onExceedLimit = () => {
+            helper.message("error", `最多上传5个文件`);
+        };
+        const customRequest = async (option) => {
+            const { onSuccess, fileItem } = option;
+            const { file, uid } = fileItem;
+            fileList.push({
+                id: uid,
+                file
+            });
+            onSuccess();
+        };
+        const onBeforeRemove = (data) => {
+            fileList = fileList.filter((item) => item.id !== data.uid);
+            return true;
+        };
         const data = ref(DEFAULT_DATA);
-        return { data, getAssetURL: helper.getAssetURL, showUpload };
+        const selectedKeys = ref(["Jane Doe", "Alisa Ross"]);
+
+        const rowSelection = reactive({
+            type: "checkbox",
+            showCheckedAll: true,
+            onlyCurrent: false
+        });
+
+        const columns = [
+            {
+                title: "文件名称",
+                dataIndex: "name"
+            },
+            {
+                title: "类型",
+                dataIndex: "type"
+            },
+            {
+                title: "大小",
+                dataIndex: "size"
+            },
+            {
+                title: "上传时间",
+                dataIndex: "time"
+            },
+            {
+                title: "操作",
+                slotName: "methods"
+            }
+        ];
+        const tableData = reactive([
+            {
+                key: "1",
+                name: "文件名称1",
+                type: "pdf",
+                size: "13M",
+                time: "2024.9.8"
+            },
+            {
+                key: "2",
+                name: "文件名称2",
+                type: "pdf",
+                size: "13M",
+                time: "2024.9.8"
+            },
+            {
+                key: "3",
+                name: "文件名称3",
+                type: "pdf",
+                size: "13M",
+                time: "2024.9.8"
+            }
+        ]);
+        return {
+            data,
+            selectedKeys,
+            getAssetURL: helper.getAssetURL,
+            showUpload,
+            onBeforeUpload,
+            onExceedLimit,
+            onBeforeRemove,
+            customRequest,
+            columns,
+            tableData,
+            rowSelection
+        };
     }
 });
 </script>
 <style lang="scss" scoped>
+.upload-main {
+    width: 800px;
+    height: 109px;
+    background: url("@/assets/document/upload.svg");
+    margin: 0 auto;
+    padding: 24px 0px 24px 277px;
+    background-size: 100%;
+    > p {
+        color: #000;
+        font-weight: bold;
+        margin-bottom: 5px;
+        > span {
+            color: #00aea3;
+            text-decoration: underline;
+        }
+    }
+    > span {
+        font-size: 13px;
+        color: #7f7f7f;
+    }
+}
 main {
     height: 100%;
     display: flex;
@@ -98,7 +253,8 @@ main {
             }
             > div {
                 font-size: 18px;
-                font-weight: 700;
+                font-weight: bold;
+
                 > span {
                     font-size: 15px;
                     font-weight: 400;
@@ -163,10 +319,14 @@ main {
 .upload-wrap {
     width: 800px;
     height: 300px;
+    display: flex;
+    flex-direction: column;
+    padding-bottom: 30px;
     > header {
         display: flex;
         align-items: center;
         justify-content: space-between;
+        margin-bottom: 13px;
         > p {
             font-size: 18px;
             font-weight: bold;
@@ -184,5 +344,18 @@ main {
             }
         }
     }
+    > div {
+        flex: 1;
+        overflow-y: auto;
+        > div {
+            > p {
+                margin: 20px 0;
+                color: #7f7f7f;
+                font-size: 13px;
+                display: flex;
+                justify-content: space-between;
+            }
+        }
+    }
 }
 </style>