소스 검색

feat: 整体功能完成

lanjianrong 4 년 전
부모
커밋
c561bd4929
7개의 변경된 파일83개의 추가작업 그리고 81개의 파일을 삭제
  1. 6 6
      package.json
  2. 1 0
      src/layouts/default/header/index.less
  3. 4 3
      src/store/modules/user.ts
  4. 11 15
      src/views/design-directive/catalog/index.vue
  5. 3 3
      src/views/sys/login/LoginForm.vue
  6. 54 50
      src/views/sys/preview/index.vue
  7. 4 4
      yarn.lock

+ 6 - 6
package.json

@@ -42,7 +42,7 @@
     "mockjs": "^1.1.0",
     "nprogress": "^0.2.0",
     "path-to-regexp": "^6.2.0",
-    "pdfjs-dist": "^2.6.347",
+    "pdfjs-dist": "2.5.207",
     "qrcode": "^1.4.4",
     "sortablejs": "^1.13.0",
     "vue": "^3.0.7",
@@ -83,7 +83,11 @@
     "dotenv": "^8.2.0",
     "eslint": "^7.22.0",
     "eslint-config-prettier": "^8.1.0",
+    "eslint-plugin-html": "^6.1.2",
+    "eslint-plugin-javascript": "^1.3.4",
+    "eslint-plugin-jsx": "^0.1.0",
     "eslint-plugin-prettier": "^3.3.1",
+    "eslint-plugin-typescript": "^0.14.0",
     "eslint-plugin-vue": "^7.8.0",
     "esno": "^0.5.0",
     "fs-extra": "^9.1.0",
@@ -93,6 +97,7 @@
     "is-ci": "^3.0.0",
     "less": "^4.1.1",
     "lint-staged": "^10.5.4",
+    "lodash-es": "^4.17.21",
     "madge": "^4.0.2",
     "postcss": "^8.2.8",
     "prettier": "^2.2.1",
@@ -104,11 +109,6 @@
     "stylelint-config-standard": "^21.0.0",
     "stylelint-order": "^4.1.0",
     "ts-node": "^9.1.1",
-    "eslint-plugin-html": "^6.1.2",
-    "eslint-plugin-javascript": "^1.3.4",
-    "eslint-plugin-jsx": "^0.1.0",
-    "eslint-plugin-typescript": "^0.14.0",
-    "lodash-es": "^4.17.21",
     "typescript": "4.2.3",
     "vite": "2.0.5",
     "vite-plugin-compression": "^0.2.3",

+ 1 - 0
src/layouts/default/header/index.less

@@ -104,6 +104,7 @@
     display: flex;
     min-width: 180px;
     // padding-right: 12px;
+    justify-content: flex-end;
     align-items: center;
 
     &__item {

+ 4 - 3
src/store/modules/user.ts

@@ -19,6 +19,7 @@ import { useI18n } from '/@/hooks/web/useI18n'
 import { ErrorMessageMode } from '/@/utils/http/axios/types'
 import { getAuthCache, removeAuthCache, setAuthCache } from '/@/utils/auth/index'
 import { mainOutRoutes } from '/@/router/routes/mainOut'
+import { PreviewRoute } from '/@/router/routes'
 
 const NAME = 'app-user'
 hotModuleUnregisterModule(NAME)
@@ -116,10 +117,10 @@ class User extends VuexModule {
   @Action
   async logout(goLogin = false) {
     goLogin && router.push(PageEnum.BASE_LOGIN)
+    if (!goLogin && !router.hasRoute('Preview')) {
+      router.addRoute('', PreviewRoute)
+    }
     !goLogin && router.push(PageEnum.BASE_HOME)
-    // if (!goLogin && !router.hasRoute('Preview')) {
-    //   router.addRoute('', mainOutRoutes[0])
-    // }
   }
 
   /**

+ 11 - 15
src/views/design-directive/catalog/index.vue

@@ -3,18 +3,7 @@
     <div class="flex flex-nowrap w-full h-full">
       <div class="w-1/4 border-gray-400 border h-full">
         <header class="p-2 flex justify-between items-center h-12">
-          <div class="w-1/2">
-            <!-- <BasicUpload
-              v-show="showUploadBtn"
-              :max-size="20"
-              :max-number="1"
-              @change="handleChange"
-              :api="uploadApi"
-              :show-preview-number="false"
-              :empty-hide-preview="true"
-              :accept="['xlsx', 'xls', 'pdf']"
-            /> -->
-          </div>
+          <div class="w-1/2"> </div>
           <div class="flex flex-row w-1/2 justify-end">
             <span class="flex align-middle cursor-pointer" @click="handleTreeOpreate('upSerial')">
               <Icon icon="mdi:arrow-up" :size="18" />
@@ -83,7 +72,8 @@
           <!-- <AButton type="primary" class="mx-1 mr-4">下载</AButton> -->
         </header>
         <section class="h-11/12 border-gray-400 border">
-          <!-- <PreviewPdf v-show="!showExcel" :url="pdfUrl" /> -->
+          <!-- <PreviewPdf v-show="showPdf" :url="pdfUrl" type="canvas" pdfjs-dist-path="/pdfjs" /> -->
+          <!-- <PreviewPdf v-show="showPdf" :url="pdfUrl" /> -->
           <iframe v-if="showPdf" :src="pdfUrl" frameborder="0" width="100%" height="100%"></iframe>
           <div
             v-if="detail.name && !detail.pdfData.fid"
@@ -105,6 +95,8 @@
   import { uploadApi } from '/@/api/sys/upload'
   import { TreeRow } from '/#/tree'
   import { downloadByUrl } from '/@/utils/file/download'
+  // import PreviewPdf from './pdf.vue'
+  // import PreviewPdf from '/@/components/Pdf/pdf'
   import { Icon } from '/@/components/Icon'
   interface ATreeRow extends TreeRow {
     showUpload: boolean
@@ -207,11 +199,15 @@
       })
       const uploadExecl = () => {
         downloadByUrl({
-          url: 'http://sj.6jlzf.cn/static' + detail.value.excelData.filepath
+          url: 'http://sj.6jlzf.cn/api/upload/file?id=' + detail.value.excelData.fid
+          // url: 'http://localhost:7070/api/upload/file?id=' + detail.value.excelData.fid
         })
       }
 
-      const pdfUrl = computed(() => 'http://sj.6jlzf.cn/static' + detail.value.pdfData.filepath)
+      const pdfUrl = computed(
+        // () => 'http://sj.6jlzf.cn/api/upload/file?id=' + detail.value.pdfData.fid
+        () => 'http://sj.6jlzf.cn/static' + detail.value.pdfData.filepath
+      )
       return {
         treeData,
         replaceFields,

+ 3 - 3
src/views/sys/login/LoginForm.vue

@@ -7,7 +7,7 @@
     <FormItem name="password" class="enter-x">
       <InputPassword
         size="large"
-        visibilityToggle
+        visibility-toggle
         v-model:value="formData.password"
         :placeholder="t('sys.login.password')"
       />
@@ -25,9 +25,9 @@
       <ACol :span="12">
         <FormItem :style="{ 'text-align': 'right' }">
           <!-- No logic, you need to deal with it yourself -->
-          <Button type="link" size="small" @click="setLoginState(LoginStateEnum.RESET_PASSWORD)">
+          <!-- <Button type="link" size="small" @click="setLoginState(LoginStateEnum.RESET_PASSWORD)">
             {{ t('sys.login.forgetPassword') }}
-          </Button>
+          </Button> -->
         </FormItem>
       </ACol>
     </ARow>

+ 54 - 50
src/views/sys/preview/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div :class="prefixCls" class="w-full h-full">
     <div
-      class="w-full py-4 sm:max-w-540px md:max-w-720px lg:max-w-960px xl:max-w-1140px mx-auto py-4"
+      class="w-full py-4 sm:max-w-540px md:max-w-720px lg:max-w-960px xl:max-w-1140px 2xl:max-w-1600px mx-auto"
     >
       <nav class="flex justify-between items-center">
         <span
@@ -11,7 +11,7 @@
       </nav>
     </div>
     <div
-      class="container w-full py-4 sm:max-w-540px md:max-w-720px lg:max-w-960px xl:max-w-1140px mx-auto"
+      class="container w-full py-4 sm:max-w-540px md:max-w-720px lg:max-w-960px xl:max-w-1140px 2xl:max-w-1600px mx-auto"
     >
       <div class="flex flex-col h-full">
         <section class="content flex h-full">
@@ -25,44 +25,42 @@
             />
           </div>
           <div class="rounded-md bg-white h-full right-menu">
-            <header class="flex justify-between border-">
-              <span class="text-xl">{{ detail.name }}</span>
-              <a-button type="success" pre-icon="ic:outline-file-download">下载</a-button>
+            <header class="border-b">
+              <div class="flex justify-between p-4">
+                <div>
+                  <span class="text-xl">{{ detail.name }}</span>
+                  <span class="text-xl ml-3 font-medium">{{ detail.code2 }}</span>
+                </div>
+                <a-button type="success" pre-icon="ic:outline-file-download" @click="uploadExecl"
+                  >下载</a-button
+                >
+              </div>
             </header>
-            <section> </section>
+            <section class="pdf-content">
+              <iframe
+                v-if="showPdf"
+                :src="pdfUrl"
+                frameborder="0"
+                width="100%"
+                height="100%"
+                class="rounded-b-md"
+              ></iframe>
+              <div
+                v-if="detail.name && !detail.pdfData.fid"
+                class="h-full flex justify-center items-center text-2xl"
+                >暂未上传可供预览的pdf文件</div
+              >
+            </section>
           </div>
         </section>
-        <footer>
-          <p class="m-0 p-0 text-right text-light-blue-50"
+        <footer class="relative">
+          <p class="m-0 p-0 text-right text-light-blue-50 footer-content"
             >主办单位:广东省交通运输工程造价事务中心<span class="px-2">|</span
             >技术支持:珠海纵横创新软件有限公司</p
           >
         </footer>
       </div>
     </div>
-    <!-- <div class="border-b-1 border-gray-400 flex justify-between pb-2">
-      <span class="text-lg font-black">设计数量表管理平台</span>
-      <AButton size="small" @click="$router.push('/login')">登录</AButton>
-    </div>
-    <div class="flex py-5 container w-full">
-      <div class="w-1/4 border-gray-300 border-1 border overflow-y-scroll overflow-x-hidden">
-        <Tree
-          v-if="treeData && treeData.length"
-          :tree-data="treeData"
-          :replace-fields="replaceFields"
-          :default-expand-all="true"
-          @select="onSelect"
-        />
-      </div>
-      <div class="w-3/4 border-gray-300 border-1 border ml-10">
-        <iframe v-if="showPdf" :src="pdfUrl" frameborder="0" width="100%" height="100%"></iframe>
-        <div class="w-full h-full flex items-center justify-center">
-          <AButton v-show="showExcel" type="primary" size="small" class="mr-4" @click="uploadExecl"
-            >下载Excel
-          </AButton>
-        </div>
-      </div>
-    </div> -->
   </div>
 </template>
 
@@ -99,7 +97,12 @@
         createTime: '',
         showUpload: false
       })
-      const detail = ref({ name: '', content: '', filepath: '', filename: '', ext: '', fid: '' })
+      const detail = ref({
+        name: '',
+        code2: '',
+        pdfData: { content: '', filepath: '', filename: '', ext: '', fid: '' },
+        excelData: { content: '', filepath: '', filename: '', ext: '', fid: '' }
+      })
       async function initData() {
         const result = await sectionAllApi()
         treeData.value = (result && result[0].children) || []
@@ -148,32 +151,25 @@
           initSectionDetail(row.id)
         }
       })
-
-      const showExcel = computed(() => {
-        if (!detail.value.fid) {
-          return false
-        }
-        return /.(excel)|(xls)|(xlsl)$/.test(detail.value.ext)
-      })
-
+      const showExcelDownload = computed(() => detail.value.excelData.fid)
       const showPdf = computed(() => {
-        if (!detail.value.fid) {
-          return false
-        }
-        const isPdf = /.(pdf)|(PDF)$/.test(detail.value.ext)
-        if (!isPdf) {
+        if (!detail.value.pdfData.fid) {
           return false
         }
         return true
       })
-
-      const pdfUrl = computed(() => 'http://localhost:7070' + detail.value.filepath)
-
       const uploadExecl = () => {
         downloadByUrl({
-          url: 'http://localhost:7070' + detail.value.filepath
+          url: 'http://sj.6jlzf.cn/api/upload/file?id=' + detail.value.excelData.fid
+          // url: 'http://localhost:7070/api/upload/file?id=' + detail.value.excelData.fid
         })
       }
+
+      const pdfUrl = computed(
+        // () => 'http://sj.6jlzf.cn/api/upload/file?id=' + detail.value.pdfData.fid
+        () => 'http://sj.6jlzf.cn/static' + detail.value.pdfData.filepath
+      )
+
       const { prefixCls } = useDesign('preview')
       const replaceFields = { children: 'children', title: 'name', key: 'id' }
       return {
@@ -185,7 +181,7 @@
         pdfUrl,
         uploadExecl,
         title: computed(() => globSetting?.title ?? ''),
-        showExcel,
+        showExcelDownload,
         detail
       }
     }
@@ -210,8 +206,16 @@
           flex: 0 0 75%;
           max-width: 75%;
           margin-left: 15px;
+          .pdf-content {
+            height: calc(100% - 2rem - 33px);
+          }
         }
       }
+      .footer-content {
+        position: absolute;
+        right: 0;
+        bottom: -2rem;
+      }
     }
   }
 </style>

+ 4 - 4
yarn.lock

@@ -8575,10 +8575,10 @@ path-type@^4.0.0:
   resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
   integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
 
-pdfjs-dist@^2.6.347:
-  version "2.6.347"
-  resolved "https://registry.npm.taobao.org/pdfjs-dist/download/pdfjs-dist-2.6.347.tgz#f257ed66e83be900cd0fd28524a2187fb9e25cd5"
-  integrity sha1-8lftZug76QDND9KFJKIYf7niXNU=
+pdfjs-dist@2.5.207:
+  version "2.5.207"
+  resolved "https://registry.npm.taobao.org/pdfjs-dist/download/pdfjs-dist-2.5.207.tgz?cache=0&sync_timestamp=1617640231020&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fpdfjs-dist%2Fdownload%2Fpdfjs-dist-2.5.207.tgz#b5e8c19627be64269cd3fb6df3eaaf45ddffe7b6"
+  integrity sha1-tejBlie+ZCac0/tt8+qvRd3/57Y=
 
 pend@~1.2.0:
   version "1.2.0"