Pārlūkot izejas kodu

面料损耗报表/面料损耗表-附件上传

jbb 2 gadi atpakaļ
vecāks
revīzija
3540d40ddc

+ 18 - 2
src/views/cost-allocation-total/fabricLossesSummary.vue

@@ -101,13 +101,16 @@
       >
       <span slot="action" slot-scope="text, record">
           <a @click="handleApply(record)" v-if="apply == 1 && (record.status=='保存' ||record.status=='完成'|| record.status=='' || record.status==undefined)">发起申请</a>
-          
+          <a-divider type="vertical"  v-if="apply == 1 && (record.status=='保存' ||record.status=='完成'|| record.status=='' || record.status==undefined)"/>
+          <a @click="openAppendixList(record)" >附件</a>
+
         </span>
       </a-table>
     </a-card>
 
     <!-- 详情 大抽屉 -->
     <!-- <costDetail-drawer ref="costDetailDrawer" :fatherList="getCostList" @ok="modalFormOk"></costDetail-drawer> -->
+    <attachment   ref="attachment"></attachment>
   </div>
 </template>
 
@@ -117,13 +120,14 @@ import JEllipsis from '@/components/jeecg/JEllipsis'
 import moment from 'moment'
 
 import costDetailDrawer from '@views/cost-allocation-total/costDetailDrawer.vue'
+import attachment from '@views/cost-allocation-total/modal/attachment.vue'
 
 import { checkList } from '@api/document/fabricLossesSummary.js'
 
 export default {
   name: 'fabricLossesSummary',
   mixins: [JeecgListMixin],
-  components: { JEllipsis, moment, costDetailDrawer },
+  components: { JEllipsis, moment, costDetailDrawer,attachment },
 
   data() {
     let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
@@ -282,6 +286,18 @@ export default {
       };
       window.parent.postMessage({msg:"startApply", data:data}, "*");
     },
+    openAppendixList(record){
+      this.$refs.attachment.AttachmentModVis = true
+      var attachmentArr = record.attachs.split(',')
+      var attachList = [];
+      attachmentArr.forEach(item=>{
+        var attach = {};
+          attach.name = item;
+          attach.src=item;
+          attachList.push(attach);
+      })
+      this.$refs.attachment.attachmentData =  attachList;
+    },
   },
   computed: {},
   mounted() {}

+ 114 - 0
src/views/cost-allocation-total/modal/attachment.vue

@@ -0,0 +1,114 @@
+<template>logo
+  <a-modal
+    title="附件"
+    v-model="AttachmentModVis"
+    :confirmLoading="confirmLoading"
+    width="90%"
+    :footer="null"
+  >
+  <div>
+    
+      <ul >
+          <li v-for="(item,index) in attachmentData" :key="index">
+              <img :src="item.src" class="logo" v-if="item.status == '1'" style="width: 100%;"/>       
+              <a v-if="item.status == '0'" style="text-decoration:underline" @click="accessoryDownload(item)">
+                {{item.name}}
+              </a>       
+          </li>
+      </ul>
+  </div>
+  </a-modal>
+</template>
+
+<script>
+import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+import JEllipsis from '@/components/jeecg/JEllipsis'
+import { downFile } from '@/api/manage'
+export default {
+  name: 'AttachmentDisplay', // 明细 弹框
+  mixins: [JeecgListMixin],
+  components: { JEllipsis},
+  data() {
+    return {      
+       AttachmentModVis : false,
+       loading: false, // 表格加载
+       confirmLoading: false,
+       attachmentData:[],
+       cc:'',
+    }
+  },
+  watch:{
+      attachmentData(newValue){
+        this.attachmentData.map(item => {
+          var index= item.name.lastIndexOf('.'), // 获取指定字符串最后一次出现的位置
+              ext = item.name.substr(index+1),
+              suffix = this.isAssetTypeAnImage(ext)
+          if(suffix){
+            item.status = 1
+            item.src = `${window._CONFIG['domianURL']}/${item.src}`
+          }else{
+            item.status = 0
+          }
+        })
+      }
+  },
+ 
+  methods: {
+      backDetailTable(){
+          this.AttachmentModVis = false
+      },
+      isAssetTypeAnImage(ext) {
+        return [
+           'png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff'].
+            indexOf(ext.toLowerCase()) !== -1;
+       },
+
+      //  点击附件下载
+      accessoryDownload(item){
+       downFile(item.src).then(data => {
+        if (!data) {
+          this.$message.warning('文件下载失败')
+          return
+        }
+        if (typeof window.navigator.msSaveBlob !== 'undefined') {
+          window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
+        } else {
+          let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
+          let link = document.createElement('a')
+          link.style.display = 'none'
+          link.href = url
+          link.setAttribute('download', item.name)
+          document.body.appendChild(link)
+          link.click()
+          document.body.removeChild(link) // 下载完成移除元素
+          window.URL.revokeObjectURL(url) // 释放掉blob对象
+        }
+      })
+    },
+ },
+}
+</script>
+<style lang="less" scoped>
+@import '~@assets/less/common.less';
+@import '~@assets/less/overwriter.less';
+// /deep/ .ant-table-thead > tr > th {
+//   text-align: center;
+//   // font-weight: 700;
+// }
+
+// /deep/ .ant-table-tbody {
+//   text-align: center;
+// }
+//  /deep/ .ant-table-footer .ant-table-body {
+//     overflow: hidden !important;
+//   }
+// /deep/ th.replacecolor {
+//   background-color: #ccc;
+// }
+/deep/ .ant-modal-body {
+  height: 100% !important;
+}
+/deep/ .ant-modal-content{
+  overflow: auto;
+}
+</style>

+ 45 - 1
src/views/reportForms/fabric-loss-table.vue

@@ -102,9 +102,23 @@
             <a-col :md="6" :sm="8" class="noprint">
               <a-button type="primary" @click="openEnclosure">附件</a-button>
             </a-col>
+            <a-col :md="6" :sm="8" class="noprint">
+              <j-upload   v-model="fabricLoss.attachs"  ></j-upload>
+              <!-- <a-upload  name="file" action="https://www.mocky.io/v2/5cc8019d300000980a055e76"    :multiple="true"    :default-file-list="fileList">
+                <a-button type="primary" >附件上传</a-button>
+              </a-upload> -->
+              <!-- <a-button type="primary" @click="openEnclosure">附件</a-button> -->
+            </a-col>
           </a-form-model>
         </div>
       </a-row>
+      <a-row :gutter="24" >
+        <!-- <a-col :md="24" :sm="8" class="noprint">
+              <a-upload  name="file" action="https://www.mocky.io/v2/5cc8019d300000980a055e76"    :multiple="true"    :default-file-list="fileList">
+                <a-button type="primary" >附件上传</a-button>
+              </a-upload>
+            </a-col> -->
+      </a-row>
     </a-card>
     </div>
     <div >
@@ -455,6 +469,7 @@ import AttachmentDisplay from '@views/reportForms/fabric-loss-table/attachment-d
 import { getFabricLossDatas,saveFabricLossData } from '@api/reportForms/fabric-loss-table'
 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
 import JEllipsis from '@/components/jeecg/JEllipsis'
+import JUpload from '@/components/jeecg/JUpload'
 import moment from 'moment'
 
 export default {
@@ -474,7 +489,9 @@ export default {
     purchaseLeftModal,
     JEllipsis,
     moment,
+    JUpload,
     AttachmentDisplay,
+    accessory2:[],
     imoneyCell
   },
   data() {
@@ -487,6 +504,26 @@ export default {
       validatorRules: {
         planNum: [{ required: true, message: '请输入计划单号进行搜索', trigger: 'blur' }]
       },
+      fileList: [
+        {
+          uid: '-1',
+          name: 'xxx.png',
+          status: 'done',
+          url: 'http://www.baidu.com/xxx.png',
+        },
+        {
+          uid: '-1',
+          name: 'xxx.png',
+          status: 'done',
+          url: 'http://www.baidu.com/xxx.png',
+        },
+        {
+          uid: '-1',
+          name: 'xxx.png',
+          status: 'done',
+          url: 'http://www.baidu.com/xxx.png',
+        },
+      ],
       edit:'0',
       planNO:'',//计划单号
       isView:false,//是否查看状态
@@ -1244,7 +1281,6 @@ export default {
         return;
       }
       this.loadingBtn = true;
-      console.log(this.fabricLoss);
       saveFabricLossData(this.fabricLoss).then(res => {
         that.loadingBtn = false;
         if (res.success) {
@@ -1502,4 +1538,12 @@ export default {
 .title{
   display: none;
 }
+// /deep/.ant-upload.ant-upload-select{
+//   float: left;
+// }
+// /deep/.ant-upload-list{
+//   float: left;
+//   display: flex
+// }
+
 </style>