Parcourir la source

Merge remote-tracking branch 'origin/dev' into dev

Hwf il y a 4 mois
Parent
commit
1a7eef6f6e

+ 208 - 0
package-lock.json

@@ -49,6 +49,7 @@
         "luckyexcel": "^1.0.1",
         "nprogress": "0.2.0",
         "ol": "^8.0.0",
+        "pdfjs-dist": "^4.10.38",
         "pinia": "^2.1.7",
         "proj4": "^2.12.1",
         "screenfull": "6.0.2",
@@ -58,6 +59,7 @@
         "vue-cropper": "1.1.1",
         "vue-good-table": "^2.21.11",
         "vue-i18n": "9.10.2",
+        "vue-pdf-embed": "^2.1.1",
         "vue-router": "4.3.2",
         "vue-types": "5.1.1",
         "vue3-print-nb": "^0.1.4",
@@ -1532,6 +1534,188 @@
         "node": ">=10"
       }
     },
+    "node_modules/@napi-rs/canvas": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas/-/canvas-0.1.65.tgz",
+      "integrity": "sha512-YcFhXQcp+b2d38zFOJNbpyPHnIL7KAEkhJQ+UeeKI5IpE9B8Cpf/M6RiHPQXSsSqnYbrfFylnW49dyh2oeSblQ==",
+      "license": "MIT",
+      "optional": true,
+      "engines": {
+        "node": ">= 10"
+      },
+      "optionalDependencies": {
+        "@napi-rs/canvas-android-arm64": "0.1.65",
+        "@napi-rs/canvas-darwin-arm64": "0.1.65",
+        "@napi-rs/canvas-darwin-x64": "0.1.65",
+        "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.65",
+        "@napi-rs/canvas-linux-arm64-gnu": "0.1.65",
+        "@napi-rs/canvas-linux-arm64-musl": "0.1.65",
+        "@napi-rs/canvas-linux-riscv64-gnu": "0.1.65",
+        "@napi-rs/canvas-linux-x64-gnu": "0.1.65",
+        "@napi-rs/canvas-linux-x64-musl": "0.1.65",
+        "@napi-rs/canvas-win32-x64-msvc": "0.1.65"
+      }
+    },
+    "node_modules/@napi-rs/canvas-android-arm64": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-android-arm64/-/canvas-android-arm64-0.1.65.tgz",
+      "integrity": "sha512-ZYwqFYEKcT5Zr8lbiaJNJj/poLaeK2TncolY914r+gD2TJNeP7ZqvE7A2SX/1C9MB4E3DQEwm3YhL3WEf0x3MQ==",
+      "cpu": [
+        "arm64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "android"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-darwin-arm64": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-darwin-arm64/-/canvas-darwin-arm64-0.1.65.tgz",
+      "integrity": "sha512-Pg1pfiJEyDIsX+V0QaJPRWvXbw5zmWAk3bivFCvt/5pwZb37/sT6E/RqPHT9NnqpDyKW6SriwY9ypjljysUA1Q==",
+      "cpu": [
+        "arm64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "darwin"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-darwin-x64": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-darwin-x64/-/canvas-darwin-x64-0.1.65.tgz",
+      "integrity": "sha512-3Tr+/HjdJN7Z/VKIcsxV2DvDIibZCExgfYTgljCkUSFuoI7iNkOE6Dc1Q6j212EB9PeO8KmfrViBqHYT6IwWkA==",
+      "cpu": [
+        "x64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "darwin"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-linux-arm-gnueabihf": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-linux-arm-gnueabihf/-/canvas-linux-arm-gnueabihf-0.1.65.tgz",
+      "integrity": "sha512-3KP+dYObH7CVkZMZWwk1WX9jRjL+EKdQtD43H8MOI+illf+dwqLlecdQ4d9bQRIxELKJ8dyPWY4fOp/Ngufrdg==",
+      "cpu": [
+        "arm"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "linux"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-linux-arm64-gnu": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-linux-arm64-gnu/-/canvas-linux-arm64-gnu-0.1.65.tgz",
+      "integrity": "sha512-Ka3StKz7Dq7kjTF3nNJCq43UN/VlANS7qGE3dWkn1d+tQNsCRy/wRmyt1TUFzIjRqcTFMQNRbgYq84+53UBA0A==",
+      "cpu": [
+        "arm64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "linux"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-linux-arm64-musl": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-linux-arm64-musl/-/canvas-linux-arm64-musl-0.1.65.tgz",
+      "integrity": "sha512-O4xMASm2JrmqYoiDyxVWi+z5C14H+oVEag2rZ5iIA67dhWqYZB+iO7wCFpBYRj31JPBR29FOsu6X9zL+DwBFdw==",
+      "cpu": [
+        "arm64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "linux"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-linux-riscv64-gnu": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-linux-riscv64-gnu/-/canvas-linux-riscv64-gnu-0.1.65.tgz",
+      "integrity": "sha512-dblWDaA59ZU8bPbkfM+riSke7sFbNZ70LEevUdI5rgiFEUzYUQlU34gSBzemTACj5rCWt1BYeu0GfkLSjNMBSw==",
+      "cpu": [
+        "riscv64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "linux"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-linux-x64-gnu": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-linux-x64-gnu/-/canvas-linux-x64-gnu-0.1.65.tgz",
+      "integrity": "sha512-wsp+atutw13OJXGU3DDkdngtBDoEg01IuK5xMe0L6VFPV8maGkh17CXze078OD5QJOc6kFyw3DDscMLOPF8+oA==",
+      "cpu": [
+        "x64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "linux"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-linux-x64-musl": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-linux-x64-musl/-/canvas-linux-x64-musl-0.1.65.tgz",
+      "integrity": "sha512-odX+nN+IozWzhdj31INcHz3Iy9+EckNw+VqsZcaUxZOTu7/3FmktRNI6aC1qe5minZNv1m05YOS1FVf7fvmjlA==",
+      "cpu": [
+        "x64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "linux"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
+    "node_modules/@napi-rs/canvas-win32-x64-msvc": {
+      "version": "0.1.65",
+      "resolved": "https://registry.npmmirror.com/@napi-rs/canvas-win32-x64-msvc/-/canvas-win32-x64-msvc-0.1.65.tgz",
+      "integrity": "sha512-RZQX3luWnlNWgdMnLMQ1hyfQraeAn9lnxWWVCHuUM4tAWEV8UDdeb7cMwmJW7eyt8kAosmjeHt3cylQMHOxGFg==",
+      "cpu": [
+        "x64"
+      ],
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "win32"
+      ],
+      "engines": {
+        "node": ">= 10"
+      }
+    },
     "node_modules/@nodelib/fs.scandir": {
       "version": "2.1.5",
       "resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@@ -11526,6 +11710,18 @@
         "pbf": "bin/pbf"
       }
     },
+    "node_modules/pdfjs-dist": {
+      "version": "4.10.38",
+      "resolved": "https://registry.npmmirror.com/pdfjs-dist/-/pdfjs-dist-4.10.38.tgz",
+      "integrity": "sha512-/Y3fcFrXEAsMjJXeL9J8+ZG9U01LbuWaYypvDW2ycW1jL269L3js3DVBjDJ0Up9Np1uqDXsDrRihHANhZOlwdQ==",
+      "license": "Apache-2.0",
+      "engines": {
+        "node": ">=20"
+      },
+      "optionalDependencies": {
+        "@napi-rs/canvas": "^0.1.65"
+      }
+    },
     "node_modules/perfect-debounce": {
       "version": "1.0.0",
       "resolved": "https://registry.npmmirror.com/perfect-debounce/-/perfect-debounce-1.0.0.tgz",
@@ -15162,6 +15358,18 @@
         "url": "https://github.com/sponsors/kazupon"
       }
     },
+    "node_modules/vue-pdf-embed": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmmirror.com/vue-pdf-embed/-/vue-pdf-embed-2.1.1.tgz",
+      "integrity": "sha512-5cDb9j7RFISUtAo9vusfaYxiNGLafPy/kWtqairaPFPrvMoGYnUCOyYfbdbaROVNw9KE3PNoGl+7pcx89i+log==",
+      "license": "MIT",
+      "dependencies": {
+        "pdfjs-dist": "^4.7.76"
+      },
+      "peerDependencies": {
+        "vue": "^3.3.0"
+      }
+    },
     "node_modules/vue-router": {
       "version": "4.3.2",
       "resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.3.2.tgz",

+ 2 - 0
package.json

@@ -58,6 +58,7 @@
     "luckyexcel": "^1.0.1",
     "nprogress": "0.2.0",
     "ol": "^8.0.0",
+    "pdfjs-dist": "^4.10.38",
     "pinia": "^2.1.7",
     "proj4": "^2.12.1",
     "screenfull": "6.0.2",
@@ -67,6 +68,7 @@
     "vue-cropper": "1.1.1",
     "vue-good-table": "^2.21.11",
     "vue-i18n": "9.10.2",
+    "vue-pdf-embed": "^2.1.1",
     "vue-router": "4.3.2",
     "vue-types": "5.1.1",
     "vue3-print-nb": "^0.1.4",

+ 9 - 0
src/api/knowledge/HiddenStandards/index.ts

@@ -16,3 +16,12 @@ export function workDelete(data) {
     data: data
   });
 }
+
+//新增
+export function submitNewStandard(data) {
+  return request({
+    url: '/api/hazardStandards/create',
+    method: 'post',
+    data: data
+  });
+}

+ 80 - 0
src/views/knowledge/HiddenStandards/DataAdd.vue

@@ -1,6 +1,86 @@
 <template>
+  <div class="common-dialog">
+    <div class="common-dialog-content">
+      <div class="common-dialog-title-box">
+        <i class="common-dialog-title-icon" />
+        <div>新建隐患标准</div>
+      </div>
+      <div class="common-dialog-box">
+        <el-form ref="eventFormRef" :model="form" :rules="rules" label-width="80px">
+          <el-form-item label="报告名称:" prop="file_title">
+            <el-input v-model="form.file_title" placeholder="请输入标准文件名称" style="width: 468px !important" />
+          </el-form-item>
 
+          <el-form-item label="标准类型:" prop="standard_type">
+            <el-select v-model="form.standard_type">
+              <el-option
+                v-for="item in types"
+                :key="item.id"
+                :label="item.label"
+                :value="item.id"
+              />
+            </el-select>
+          </el-form-item>
+
+          <el-form-item label="报告附件:" prop="fileList">
+            <file-upload v-model="form.fileList" :limit="5" :file-type="['pdf']" />
+          </el-form-item>
+        </el-form>
+        <div class="common-dialog-footer">
+          <el-button @click="closeDialog">取消</el-button>
+          <el-button :loading="buttonLoading" type="primary" @click="submitForm(eventFormRef)">确定</el-button>
+        </div>
+      </div>
+    </div>
+  </div>
 </template>
+
 <script setup lang="ts">
+import { reactive, ref } from 'vue'
+import { submitNewStandard } from '@/api/knowledge/HiddenStandards';
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
+const eventFormRef = ref('');
+const types = ref([
+  {
+    id: '1',
+    label: '国家版',
+  },
+  {
+    id: '0',
+    label: '广东省版',
+  }
+])
+const emits = defineEmits(['close']);
+const buttonLoading = ref(false);
+// 表单数据
+const data = reactive({
+  form: {
+    standard_type: '', // 标准类型 默认选中第一个
+    file_title: '', // 报告名称
+    fileList: [],  //附件
+  },
+  rules: {
+    file_title: [{ required: true, message: '文件名称不能为空', trigger: 'blur' }],
+    standard_type: [{ required: true, message: '标准类型不能为空', trigger: 'blur' }],
+    fileList: [{ required: true, message: '附件不能为空', trigger: 'blur' }],
+  }
+});
+const { form, rules } = toRefs(data);
+const closeDialog = () => {
+  emits('close');
+};
+const submitForm = async (formEl) => {
+  if (!formEl) return;
+  await formEl.validate((valid, fields) => {
+    if (valid) {
+      submitNewStandard(form.value).then(() => {
+        proxy.$modal.msgSuccess('新增成功');
+        emits('close', true);
+      })
+    }
+  });
+};
 </script>
+
+<style lang="scss" scoped></style>

+ 119 - 0
src/views/knowledge/HiddenStandards/PdfViewer.vue

@@ -0,0 +1,119 @@
+<template>
+  <div class="yaxq-bottom-jcxx yawd">
+    <div class="page-tool">
+      <div class="page-tool-item"  @click="lastPage">上一页</div>
+      <div class="page-tool-item">{{state.pageNum}}/{{state.numPages}}</div>
+      <div class="page-tool-item"  @click="nextPage">下一页</div>
+    </div>
+    <div class="pdf-preview"  v-loading="pdfLoading" element-loading-text="正在加载中..."
+         element-loading-background="rgba(122, 122, 122, 0.0)">
+      <vue-pdf-embed v-if="show" :source="state.source" class="vue-pdf-embed" :page="state.pageNum" @loaded="handleDocument" />
+    </div>
+  </div>
+</template>
+
+<script setup lang="ts">
+import { ref, onMounted } from 'vue';
+import VuePdfEmbed from "vue-pdf-embed";
+
+const props = defineProps({
+  url: String
+})
+const pdfLoading = ref<any>(false)
+let show = ref(false)
+const state = reactive({
+  source: '', //预览pdf文件地址
+  pageNum: 1, //当前页面
+  scale: 1, // 缩放比例
+  numPages: 0, // 总页数
+});
+
+const handleDocument = (pdf:any)=>{
+  if(pdf.numPages){
+    pdfLoading.value = false
+    state.numPages = pdf.numPages;
+
+  }
+}
+const lastPage = () => {
+  if (state.pageNum > 1) {
+    state.pageNum -= 1;
+  }
+}
+const nextPage = () => {
+  if (state.pageNum < state.numPages) {
+    state.pageNum += 1;
+  }
+}
+
+onMounted(() => {
+  state.source = props.url
+  show.value = true
+})
+</script>
+
+<style scoped lang="scss">
+canvas {
+  border: 1px solid #ccc;
+}
+.yawd{
+  display: flex;
+  justify-content: center;
+  position: relative;
+  // overflow-y: auto;
+  .page-tool {
+    position: fixed;
+    bottom: 0.3vw;
+    left: 0%;
+    padding-left: 0.25vw;
+    padding-right: 0.25vw;
+    display: flex;
+    align-items: center;
+    background: rgb(66, 66, 66);
+    color: white;
+    border-radius: 0.9vw;
+    z-index: 999!important;
+    cursor: pointer;
+    margin-left: 50%;
+    transform: translateX(-50%);
+  }
+  .page-tool-item {
+    font-size: 0.6vw;
+    padding: 0.5vw 0.9vw;
+    padding-left: 0.1vw;
+    cursor: pointer;
+  }
+  .pdf-preview{
+    width: 100%;
+    height: 100%;
+    overflow-y:auto;
+    position: relative;
+    &::-webkit-scrollbar {
+      width: 1px !important;
+      /* Chrome, Safari, Edge */
+    }
+
+    &::-webkit-scrollbar-track {
+      background: transparent !important;
+      /* 滚动条轨道背景 */
+    }
+
+    &::-webkit-scrollbar-thumb {
+      background-color: #696969;
+      /* 滚动条滑块颜色 */
+      border-radius: 1px;
+      /* 滚动条滑块圆角 */
+      box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
+      /* 滚动条滑块阴影 */
+    }
+
+    .vue-pdf-embed{
+      width: 100%;
+      height: 100%;
+      z-index: 1!important;
+
+    }
+  }
+
+}
+</style>

+ 42 - 5
src/views/knowledge/HiddenStandards/index.vue

@@ -44,7 +44,11 @@
               <el-text type="primary" @click="openPatrolSubTasks(scope.row)">{{ scope.row.file_title }}</el-text>
             </template>
           </el-table-column>
-          <el-table-column label="标准类型" width="200" align="center" prop="standard_type" />
+          <el-table-column label="标准类型" width="200" align="center" prop="standard_type">
+            <template #default="scope">
+              <dict-tag :options="businessOptions" :value="scope.row.standard_type" />
+            </template>
+          </el-table-column>
           <el-table-column label="录入时间" align="center" prop="create_time" />
           <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
             <template #default="scope">
@@ -55,11 +59,20 @@
           </el-table-column>
         </el-table>
         <pagination v-show="total > 0" v-model:page="queryParams.page" v-model:limit="queryParams.pageSize" :total="total" @pagination="tableData" />
+        <el-dialog v-model="dialogTableVisible" :title="detailInfo.file_title" width="800">
+          <div style="display:flex; align-items: center;">
+            <el-icon><Download style="color: #1890ff" /></el-icon>
+            <div style="color: #1890ff" @click="downloadPdf(detailInfo)">下载</div>
+          </div>
+          <pdf-viewer v-if="dialogTableVisible" :url="baseUrl + '/file/download/' + detailInfo.file_name" />
+        </el-dialog>
       </div>
     </div>
     <!--    <PatrolSubTasks v-if="patrolSubTasksState.show" :event-id="patrolSubTasksState.eventId" @close="handleCancel" @refreshsub="fetchWorkrData" />-->
     <!--    <PatrolTaskEdit v-if="patrolTaskEditState.show" :event-id="patrolTaskEditState.eventId" @close="handleCancel" @refresh="fetchWorkrData" />-->
     <DataAdd v-if="DataAddState.show" @close="handleCancel" @refresh="fetchWorkrData" />
+
+
   </div>
 </template>
 <script setup lang="ts">
@@ -68,9 +81,11 @@ import { onMounted, reactive, ref } from 'vue';
 // import Add from './patrolTaskAdd.vue';
 import DataAdd from './DataAdd.vue';
 // import PatrolTaskEdit from './patrolTaskEdit.vue';
-import { workList, workDelete } from '@/api/knowledge/HiddenStandards/';
+import { workList, workDelete, viewStandard } from '@/api/knowledge/HiddenStandards/';
 import { to } from 'await-to-js';
 import { ElMessageBox } from 'element-plus';
+import { download2 } from '@/utils/request';
+import PdfViewer from '@/views/knowledge/HiddenStandards/PdfViewer.vue';
 const loading = ref(true);
 const showSearch = ref(true);
 const multiple = ref(true);
@@ -121,6 +136,7 @@ let DataAddState = reactive({
 
 const handleCancel = () => {
   DataAddState.show = false;
+  handleQuery();
 };
 const openPatrolSubTasks = (row) => {
   if (row) {
@@ -131,22 +147,34 @@ const openPatrolSubTasks = (row) => {
 const handleAdd = () => {
   DataAddState.show = true;
 };
+const dialogTableVisible = ref(false)
+const dialogFormVisible = ref(false)
+const formLabelWidth = '140px'
+const detailInfo = ref({
+  file_title: '',
+  file_name: '',
+});
 const handleUpdate = (row) => {
   if (row) {
     // patrolTaskEditState.eventId = row.id + ''; // 假设eventId是id字段
     // patrolTaskEditState.show = true;
+    detailInfo.value = row;
+    dialogTableVisible.value = true;
+    if (dialogFormVisible.value === false) {
+
+    }
   }
 };
 const handleDelete = async (row) => {
   let id = [];
   if (row) {
-    id = [row.id];
+    id = [row.file_id];
   } else {
     id = ids.value;
   }
   const [err] = await to(proxy?.$modal.confirm('是否确认删除选择的数据项?') as any);
   if (!err) {
-    await workDelete(id);
+    await workDelete({ file_id: id });
     proxy.$modal.msgSuccess('删除成功');
     fetchWorkrData();
   }
@@ -174,12 +202,21 @@ const resetQuery = () => {
   handleQuery();
 };
 const handleSelectionChange = (selection) => {
-  ids.value = selection.map((item) => item.id);
+  ids.value = selection.map((item) => item.file_id);
   selectedRow.value = selection.length === 1 ? selection[0] : null;
   single.value = selection.length != 1;
   multiple.value = !selection.length;
 };
 
+// const downloadPdf = (name) => {
+//
+// }
+const baseUrl = import.meta.env.VITE_APP_BASE_API;
+const downloadPdf = (file: any) => {
+  // debugger
+  download2(baseUrl + '/file/download/' + file.file_name, file.file_name_desc);
+};
+
 onMounted(() => {
   fetchWorkrData();
 });