yusheng 1 هفته پیش
والد
کامیت
75248d9f4b
4فایلهای تغییر یافته به همراه149 افزوده شده و 23 حذف شده
  1. 128 0
      src/components/upload/imageUpload.vue
  2. 11 8
      src/utils/file.js
  3. 9 14
      src/views/recordComponents/workOrderReport.vue
  4. 1 1
      vue.config.js

+ 128 - 0
src/components/upload/imageUpload.vue

@@ -0,0 +1,128 @@
+<template>
+  <div class="image-upload">
+    <div
+      class="image-preview"
+      v-for="(url, index) in imageUrls"
+      :key="index"
+    >
+      <el-image
+        style="width: 100px; height: 100px"
+        :src="url"
+        :preview-src-list="imageUrls"
+      >
+      </el-image>
+      <div class="image-actions">
+        <el-button type="text" @click="handleRemove(index)" v-if="!disabled">删除</el-button>
+      </div>
+    </div>
+    <el-upload
+      v-if="!limit || value.length < limit"
+      class="image-uploader"
+      action="#"
+      accept="image/png,image/jpeg,image/jpg"
+      :show-file-list="false"
+      :http-request="handleUpload"
+      :disabled="disabled"
+    >
+      <i class="el-icon-plus image-uploader-icon"></i>
+    </el-upload>
+  </div>
+</template>
+
+<script>
+  import { uploadFile } from '@/api/system/file/index';
+  import { getImagePath } from '@/utils/file';
+
+  export default {
+    props: {
+      value: {
+        type: Array,
+        default: () => []
+      },
+      module: {
+        type: String,
+        default: 'main'
+      },
+      disabled: {
+        type: Boolean,
+        default: false
+      },
+      limit: {
+        type: Number,
+        default: 0
+      }
+    },
+    computed: {
+      imageUrls() {
+        return (this.value || []).map((item) => {
+          const path = typeof item === 'string' ? item : item.url || '';
+          return path ? getImagePath(path) : '';
+        }).filter(Boolean);
+      }
+    },
+    methods: {
+      async handleUpload(params) {
+        const file = params.file;
+        if (!file.type.startsWith('image/')) {
+          this.$message.error('只能上传图片文件');
+          return;
+        }
+        if (file.size / 1024 / 1024 > 2) {
+          this.$message.error('图片大小不能超过 2MB');
+          return;
+        }
+        try {
+          const res = await uploadFile({
+            module: this.module,
+            multiPartFile: file
+          });
+          if (res.data && res.data.storePath) {
+            const newList = [...this.value, res.data.storePath];
+            this.$emit('input', newList);
+            this.$message.success('上传成功');
+          }
+        } catch (error) {
+          this.$message.error('上传失败');
+        }
+      },
+      handleRemove(index) {
+        const newList = [...this.value];
+        newList.splice(index, 1);
+        this.$emit('input', newList);
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .image-upload {
+    display: flex;
+    align-items: flex-start;
+    flex-wrap: wrap;
+    gap: 10px;
+  }
+  .image-preview {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+  }
+  .image-actions {
+    margin-top: 5px;
+  }
+  .image-uploader {
+    .image-uploader-icon {
+      font-size: 28px;
+      color: #8c939d;
+      width: 100px;
+      height: 100px;
+      line-height: 100px;
+      text-align: center;
+      border: 1px dashed #d9d9d9;
+      border-radius: 6px;
+      cursor: pointer;
+      &:hover {
+        border-color: #409eff;
+      }
+    }
+  }
+</style>

+ 11 - 8
src/utils/file.js

@@ -14,18 +14,21 @@ export function getImageUrl(path) {
 }
 // 从反显url上获取接口需要path
 export function getImagePath(url) {
-  if (!url) {
-    return '';
-  }
+  console.log(url,'url')
+  if(!url)return;
+  let fileNames = url.split('/');
 
-  const match = url.match(/&objectName=([\S\s]*)/);
-
-  return (match && match[1].split('&')[0]) || '';
+ 
+   return 'http://aiot.zoomwin.com.cn:51001' +
+    '/api/main/file/getFile?objectName=' +
+    url +
+    '&fullfilename=' +
+    fileNames[fileNames.length - 1];
 }
 
 // 下载方法
 
-export function download (data, name) {
+export function download(data, name) {
   const a = document.createElement('a');
   const url = window.URL.createObjectURL(data);
   const filename = name;
@@ -36,7 +39,7 @@ export function download (data, name) {
 }
 // 下载方法
 
-export function download1 (url, name) {
+export function download1(url, name) {
   const a = document.createElement('a');
   const filename = name;
   a.href = url;

+ 9 - 14
src/views/recordComponents/workOrderReport.vue

@@ -216,11 +216,10 @@
         </el-col>
         <el-col :span="9" v-if="pageName == 'QualityInspection'">
           <el-form-item label="车辆照片" prop="vehiclePhotoUrl">
-            <WithView
-              :assetName="''"
+            <image-upload
               v-model="addForm.vehiclePhotoUrl"
-              style="max-height: 370px"
-            ></WithView>
+              module="main"
+            ></image-upload>
           </el-form-item>
         </el-col>
       </el-row>
@@ -391,7 +390,7 @@
   import orderListDialog from '@/components/orderListDialog/orderListDialog.vue';
   import { getUserPage } from '@/api/system/organization';
   import { getteampage, getTeam } from '@/api/main/index.js';
-  import WithView from '@/components/upload/WithViewNew.vue';
+  import imageUpload from '@/components/upload/imageUpload.vue';
   import dayjs from 'dayjs';
   import { getTableList } from '@/api/purchasingManage/purchaseOrder';
 
@@ -401,7 +400,7 @@
       deptSelect,
       parentList,
       orderListDialog,
-      WithView
+      imageUpload
     },
     props: {
       pageName: {
@@ -437,7 +436,7 @@
         conclusion: null,
         isTempRecord: this.isTempRecord,
         unloadCheckStatus: 1,
-        vehiclePhotoUrl: '',
+        vehiclePhotoUrl: [],
         detailList: [],
         deviceId: 0,
         deviceName: '',
@@ -693,13 +692,9 @@
             this.pageName
           )
         ) {
-          let data = {
-            pageNum: 1,
-            size: 999,
-            orderStatus: 2,
-            partbId: data.id
-          };
-
+  
+          this.addForm.purchaseOrderId = ''
+          this.addForm.purchaseOrderNo = ''
           //来煤获取采购订单
           getTableList({
             pageNum: 1,

+ 1 - 1
vue.config.js

@@ -36,7 +36,7 @@ module.exports = {
     proxy: {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
-        target: 'http://192.168.1.251:18086', //开发
+        target: 'http://192.168.1.102:18086', //开发
         // target: 'http://192.168.1.251:18186', //测试
         // target: 'http://192.168.1.23:18086',//罗
         // target: 'http://192.168.1.144:18086',//付