Преглед на файлове

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

LAPTOP-16IUEB3P\Lenovo преди 2 години
родител
ревизия
870b55d003

+ 71 - 0
src/components/CommomSelect/working-procedure-select.vue

@@ -0,0 +1,71 @@
+<template>
+  <el-select
+    v-model="selectVal"
+    filterable
+    style="width: 100%"
+    v-bind="$attrs"
+    v-on="$listeners"
+    clearable
+  >
+    <el-option
+      v-for="item in dictList"
+      :key="item.id"
+      :value="item.id"
+      :label="item.name"
+    ></el-option>
+  </el-select>
+</template>
+
+<script>
+  import producetask from '@/api/technology/production';
+  export default {
+    model: {
+      prop: 'value',
+      event: 'updateVal'
+    },
+    props: {
+      value: {
+        type: [String, Number, Array],
+        default: ''
+      },
+      init: {
+        type: Boolean,
+        default: true
+      }
+    },
+    data () {
+      return {
+        dictList: []
+      };
+    },
+    computed: {
+      selectVal: {
+        set (val) {
+          this.$emit(
+            'selfChange',
+            val,
+            this.dictList.find((i) => i.id === val)
+          );
+          this.$emit('updateVal', val);
+        },
+        get () {
+          return this.value;
+        }
+      }
+    },
+    created () {
+      if (this.init) {
+        this.getList();
+      }
+    },
+    methods: {
+      async getList () {
+        const res = await producetask.list({
+          pageNum: 1,
+          size: -1
+        });
+        this.dictList = res.list;
+      }
+    }
+  };
+</script>

+ 115 - 0
src/components/upload/WithView.vue

@@ -0,0 +1,115 @@
+<template>
+  <div>
+    <div class="img-view" v-if="dialogImageUrl">
+      <img :src="dialogImageUrl" alt="" srcset="" />
+    </div>
+    <div class="placeholder-box" v-else>
+      <img src="~@/assets/upload-placeholder.svg" alt="" />
+    </div>
+    <div class="btn-box">
+      <el-upload
+        class="avatar-div"
+        action="#"
+        accept="image/png,image/jpeg"
+        :show-file-list="false"
+        ref="uploadRef"
+        :on-exceed="handleExceed"
+        :limit="1"
+        :http-request="handlSuccess"
+        :multiple="false"
+      >
+        <el-button type="text">上传{{ assetName }}图片</el-button>
+      </el-upload>
+      <el-button type="text" @click="clearImg">清除图片</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+  import { uploadFile, removeFile } from '@/api/system/file/index.js';
+  import { getImageUrl } from '@/utils/file';
+  export default {
+    props: {
+      assetName: {
+        type: String,
+        default: '设备'
+      },
+      value: {
+        type: Object,
+        default: () => []
+      },
+      // 所属模块
+      module: {
+        type: String,
+        default: 'main'
+      }
+    },
+    data () {
+      return {};
+    },
+    computed: {
+      dialogImageUrl () {
+        return this.value?.storePath && getImageUrl(this.value.storePath);
+      }
+    },
+    methods: {
+      // 清空已上传的文件列表
+      clearUploadFiles () {},
+      //图片添加
+      async handlSuccess (params) {
+        let res = await uploadFile({
+          multiPartFile: params.file,
+          module: this.module
+        });
+        if (res?.data) {
+          this.$emit('input', res.data);
+        }
+      },
+      async clearImg () {
+        await removeFile({ fileId: this.value.id });
+        this.$emit('input', {});
+        this.$refs.uploadRef.clearFiles();
+      },
+      // 限制上传的数量
+      handleExceed (files, fileList) {
+        this.$message.warning(`最多允许上传一张图片!`);
+      }
+    }
+  };
+</script>
+<style lang="scss" scoped>
+  .img-view {
+    width: 280px;
+    height: 342px;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    border-width: 1px;
+    border-style: solid;
+    border-color: rgba(215, 215, 215, 1);
+    img {
+      max-width: 100%;
+    }
+  }
+  .placeholder-box {
+    width: 280px;
+    height: 342px;
+    text-align: center;
+
+    background-color: rgba(242, 242, 242, 1);
+    box-sizing: border-box;
+    border-width: 1px;
+    border-style: solid;
+    border-color: rgba(215, 215, 215, 1);
+    padding-top: 60px;
+    img {
+      width: 158px;
+      height: 158px;
+    }
+  }
+
+  .btn-box {
+    display: flex;
+    justify-content: space-around;
+  }
+</style>

+ 2 - 1
src/components/upload/fileUpload.vue

@@ -158,6 +158,7 @@
           );
           );
         },
         },
         get () {
         get () {
+          console.log(this.value, 2);
           const arr =
           const arr =
             (this.value &&
             (this.value &&
               this.value.map((item) => ({
               this.value.map((item) => ({
@@ -227,7 +228,7 @@
         }).then((res) => {
         }).then((res) => {
           if (res.data) {
           if (res.data) {
             this.$emit('input', [
             this.$emit('input', [
-              ...this.value,
+              ...(this.value || []),
               { ...file, url: res.data.storePath, ...res.data }
               { ...file, url: res.data.storePath, ...res.data }
             ]);
             ]);
           }
           }

+ 2 - 5
src/components/upload/imgUpload.vue

@@ -5,8 +5,8 @@
     :drag="true"
     :drag="true"
     :multiple="true"
     :multiple="true"
     :upload-handler="uploadHandler"
     :upload-handler="uploadHandler"
+    :beforeUpload="beforeUpload"
     @upload="onUpload"
     @upload="onUpload"
-    :list-type="pictureStyle"
   >
   >
   </ele-image-upload>
   </ele-image-upload>
 </template>
 </template>
@@ -32,10 +32,6 @@
       value: {
       value: {
         type: Array,
         type: Array,
         default: () => []
         default: () => []
-      },
-      pictureStyle: {
-        type: Object,
-        default: () => ({})
       }
       }
     },
     },
     data () {
     data () {
@@ -66,6 +62,7 @@
       }
       }
     },
     },
     methods: {
     methods: {
+      // beforeUpload(){},
       /* 上传事件 */
       /* 上传事件 */
       uploadHandler (file) {
       uploadHandler (file) {
         const item = {
         const item = {

+ 53 - 47
src/views/ledgerAssets/equipment/edit.vue

@@ -191,7 +191,10 @@
             </el-col>
             </el-col>
             <el-col :span="8">
             <el-col :span="8">
               <el-form-item label="所属工序">
               <el-form-item label="所属工序">
-                {{ '成型工序' }}
+                <!-- {{ '成型工序' }} -->
+                <WorkingProcedureSelect
+                  v-model="zcInfo.roteId"
+                ></WorkingProcedureSelect>
               </el-form-item>
               </el-form-item>
             </el-col>
             </el-col>
             <el-col :span="8">
             <el-col :span="8">
@@ -316,16 +319,12 @@
             <span class="border-span">文档信息</span>
             <span class="border-span">文档信息</span>
           </div>
           </div>
           <div class="upload-container">
           <div class="upload-container">
-            <imgUpload
-              v-model="imageUrl"
-              :limit="1"
-              :pictureStyle="{ width: '300px', height: '300px' }"
-            />
+            <WithView v-model="imageUrl" :limit="1" />
             <div class="file-list">
             <div class="file-list">
               <div>
               <div>
                 <el-form-item prop="image" label="使用说明书">
                 <el-form-item prop="image" label="使用说明书">
                   <fileUpload
                   <fileUpload
-                    v-model="attUrl.operatingManual"
+                    v-model="attUrl.operatingManual.value"
                     module="main"
                     module="main"
                     :showLib="true"
                     :showLib="true"
                   />
                   />
@@ -334,7 +333,7 @@
               <div>
               <div>
                 <el-form-item prop="image" label="生产许可证书">
                 <el-form-item prop="image" label="生产许可证书">
                   <fileUpload
                   <fileUpload
-                    v-model="attUrl.productionLicence"
+                    v-model="attUrl.productionLicence.value"
                     module="main"
                     module="main"
                     :showLib="true"
                     :showLib="true"
                   />
                   />
@@ -343,7 +342,7 @@
               <div>
               <div>
                 <el-form-item prop="image" label="防爆合格证书">
                 <el-form-item prop="image" label="防爆合格证书">
                   <fileUpload
                   <fileUpload
-                    v-model="attUrl.explosionProofCertificate"
+                    v-model="attUrl.explosionProofCertificate.value"
                     module="main"
                     module="main"
                     :showLib="true"
                     :showLib="true"
                   />
                   />
@@ -352,7 +351,7 @@
               <div>
               <div>
                 <el-form-item prop="image" label="检验报告">
                 <el-form-item prop="image" label="检验报告">
                   <fileUpload
                   <fileUpload
-                    v-model="attUrl.surveyReport"
+                    v-model="attUrl.surveyReport.value"
                     module="main"
                     module="main"
                     :showLib="true"
                     :showLib="true"
                   />
                   />
@@ -361,7 +360,7 @@
               <div>
               <div>
                 <el-form-item prop="image" label="检验周期说明">
                 <el-form-item prop="image" label="检验周期说明">
                   <fileUpload
                   <fileUpload
-                    v-model="attUrl.inspectionCycleManual"
+                    v-model="attUrl.inspectionCycleManual.value"
                     module="main"
                     module="main"
                     :showLib="true"
                     :showLib="true"
                   />
                   />
@@ -370,7 +369,7 @@
               <div>
               <div>
                 <el-form-item prop="image" label="图纸资料">
                 <el-form-item prop="image" label="图纸资料">
                   <fileUpload
                   <fileUpload
-                    v-model="attUrl.informationDrawing"
+                    v-model="attUrl.informationDrawing.value"
                     module="main"
                     module="main"
                     :showLib="true"
                     :showLib="true"
                   />
                   />
@@ -379,7 +378,7 @@
               <div>
               <div>
                 <el-form-item prop="image" label="产品合格证">
                 <el-form-item prop="image" label="产品合格证">
                   <fileUpload
                   <fileUpload
-                    v-model="attUrl.productCertificate"
+                    v-model="attUrl.productCertificate.value"
                     module="main"
                     module="main"
                     :showLib="true"
                     :showLib="true"
                   />
                   />
@@ -476,8 +475,10 @@
   import FactoryLineSelect from '@/components/CommomSelect/factory-line-select.vue';
   import FactoryLineSelect from '@/components/CommomSelect/factory-line-select.vue';
   import WorkshopSelect from '@/components/CommomSelect/workshop-select.vue';
   import WorkshopSelect from '@/components/CommomSelect/workshop-select.vue';
   import FactoryAreaSelect from '@/components/CommomSelect/factory-area-select.vue';
   import FactoryAreaSelect from '@/components/CommomSelect/factory-area-select.vue';
+  import WorkingProcedureSelect from '@/components/CommomSelect/working-procedure-select.vue';
   import factorySelect from '@/components/CommomSelect/factory-select.vue';
   import factorySelect from '@/components/CommomSelect/factory-select.vue';
   import fileUpload from '@/components/upload/fileUpload';
   import fileUpload from '@/components/upload/fileUpload';
+  import WithView from '@/components/upload/WithView';
   import imgUpload from '@/components/upload/imgUpload';
   import imgUpload from '@/components/upload/imgUpload';
   // import selectUpload from "@/components/selectUpload";
   // import selectUpload from "@/components/selectUpload";
   // import UploadImg from "@/components/uploadImg/WithView.vue";
   // import UploadImg from "@/components/uploadImg/WithView.vue";
@@ -506,8 +507,10 @@
       //selectUpload,
       //selectUpload,
       //UploadImg,
       //UploadImg,
       FactoryLineSelect,
       FactoryLineSelect,
+      WithView,
       WorkshopSelect,
       WorkshopSelect,
       FactoryAreaSelect,
       FactoryAreaSelect,
+      WorkingProcedureSelect,
       fileUpload,
       fileUpload,
       imgUpload,
       imgUpload,
       factorySelect,
       factorySelect,
@@ -553,6 +556,8 @@
           ownershipUserId: '',
           ownershipUserId: '',
           // 设备用途
           // 设备用途
           purpose: '',
           purpose: '',
+          // 工序
+          roteId: '',
           //品牌
           //品牌
           brand: '',
           brand: '',
           // 	供应商code
           // 	供应商code
@@ -578,13 +583,34 @@
         imageUrl: null,
         imageUrl: null,
         // 文档信息
         // 文档信息
         attUrl: {
         attUrl: {
-          operatingManual: null,
-          productionLicence: null,
-          explosionProofCertificate: null,
-          surveyReport: null,
-          inspectionCycleManual: null,
-          informationDrawing: null,
-          productCertificate: null
+          operatingManual: {
+            value: [],
+            sort: 1
+          },
+          productionLicence: {
+            value: [],
+            sort: 2
+          },
+          explosionProofCertificate: {
+            value: [],
+            sort: 3
+          },
+          surveyReport: {
+            value: [],
+            sort: 4
+          },
+          inspectionCycleManual: {
+            value: [],
+            sort: 5
+          },
+          informationDrawing: {
+            value: [],
+            sort: 6
+          },
+          productCertificate: {
+            value: [],
+            sort: 7
+          }
         },
         },
         // 是否开始物联
         // 是否开始物联
         isIotEnable: true,
         isIotEnable: true,
@@ -629,14 +655,6 @@
       }
       }
     },
     },
     methods: {
     methods: {
-      setImgs (type, sort, info) {
-        if (info[0]) {
-          this.attUrl[type] = info[0];
-          this.attUrl[type].sort = sort;
-        } else {
-          this.attUrl[type] = null;
-        }
-      },
       handlwpbm () {
       handlwpbm () {
         this.$refs.DialogGoods.open();
         this.$refs.DialogGoods.open();
       },
       },
@@ -784,15 +802,10 @@
       },
       },
       // 处理文档信息
       // 处理文档信息
       setWd () {
       setWd () {
-        let attUrl = [];
-        Object.entries(this.attUrl).forEach(([key, value], index) => {
-          if (value) {
-            attUrl.push(value);
-          } else {
-            attUrl.push({ sort: index + 1 });
-          }
-        });
-        return attUrl;
+        return Object.values(this.attUrl).map((item) => ({
+          ...(item.value[0] || {}),
+          sort: item.sort
+        }));
       },
       },
       // 获取设备详情
       // 获取设备详情
       async getInfo () {
       async getInfo () {
@@ -828,7 +841,6 @@
         }
         }
         // 资产信息
         // 资产信息
         for (const key of Object.keys(this.zcInfo)) {
         for (const key of Object.keys(this.zcInfo)) {
-          console.log(key, data[key]);
           this.zcInfo[key] = data[key];
           this.zcInfo[key] = data[key];
         }
         }
         this.getwhbm();
         this.getwhbm();
@@ -836,19 +848,13 @@
         if (data.attUrl && data.attUrl.length > 0) {
         if (data.attUrl && data.attUrl.length > 0) {
           // 文档信息
           // 文档信息
           Object.keys(this.attUrl).forEach((n, index) => {
           Object.keys(this.attUrl).forEach((n, index) => {
-            if (data.attUrl[index].accessUrl) {
-              this.attUrl[n] = data.attUrl[index];
-            }
+            this.attUrl[n].value =
+              (data.attUrl[index]?.storePath && [data.attUrl[index]]) || [];
           });
           });
         }
         }
 
 
         // 设备图片
         // 设备图片
-        this.imageUrl = [];
-        if (this.imageUrl) {
-          // imageView(this.imageUrl).then((res) => {
-          //   this.$refs.UploadImg.setImg(res);
-          // });
-        }
+        this.imageUrl = data.imageUrl;
         // 物联参数
         // 物联参数
         this.isIotEnable = data.isIotEnable;
         this.isIotEnable = data.isIotEnable;
         this.iotId = data.iotId;
         this.iotId = data.iotId;