Quellcode durchsuchen

生产进度报表-附件

jbb vor 2 Jahren
Ursprung
Commit
1764987b06

+ 24 - 3
src/views/reportForms/pro-progress-report.vue

@@ -127,12 +127,19 @@
         <span slot="imageslot">
           <a>查看</a>
         </span>
+        <!--附件-->
+        <span slot="accessory" slot-scope="text, record">
+          <a-button type="primary" @click="openItemOnclosure(record)" >附件</a-button>
+        </span>
+        
       </a-table>
     </a-card>
 
     <!-- 单个订单报表 抽屉 -->
     <salesOrderDetails-drawer ref="salesOrderDetailsDrawer" @ok="modalFormOk"></salesOrderDetails-drawer>
     <imgModal ref="imgdetal"></imgModal>
+    <!-- 附件 -->
+    <attachment-display ref="attachmentDisplay"></attachment-display>
   </div>
 </template>
 
@@ -140,7 +147,7 @@
 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
 import JEllipsis from '@/components/jeecg/JEllipsis'
 import moment from 'moment'
-
+import AttachmentDisplay from '@views/reportForms/pro-progress-report/attachment-display.vue'
 import salesOrderDetailsDrawer from '@views/reportForms/pro-progress-report/salesOrderDetailsDrawer.vue'
 import imgModal from '@views/reportForms/full-rate-table/progtressImg.vue'
 import { proProgressList, getImg } from '@api/reportForms/pro-progress-report.js'
@@ -148,7 +155,7 @@ import { proProgressList, getImg } from '@api/reportForms/pro-progress-report.js
 export default {
   name: 'ProProgressReport', // 生产进度报表
   mixins: [JeecgListMixin],
-  components: { JEllipsis, moment, salesOrderDetailsDrawer,imgModal },
+  components: { JEllipsis, moment, salesOrderDetailsDrawer,imgModal,AttachmentDisplay },
 
   data() {
     let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
@@ -248,7 +255,7 @@ export default {
           className: 'replacecolor',
           scopedSlots: { customRender: 'imageslot' }
         },
-        { title: '附件', width: 70, dataIndex: 'accessory',  className: 'replacecolor' }
+        { title: '附件', width: 100, dataIndex: 'accessory',  className: 'replacecolor',scopedSlots: { customRender: 'accessory' } }
       ],
       proProgressData: [], //生产进度数据
       loading: false, // 表格加载
@@ -282,7 +289,9 @@ export default {
     // 分页查询 生产进度列表
     getproProgressList() {
       this.$nextTick(() => {
+        this.loading = true
         proProgressList(this.queryParam).then(res => {
+          this.loading = false
           if (res.success) {
             this.proProgressData = res.result.records
             console.log('生产进度列表页', this.proProgressData)
@@ -362,6 +371,18 @@ export default {
       this.cSOCode = []
       // this.getproProgressList()
     },
+    // 附件
+    openItemOnclosure(record){
+      var attachList = [];
+        record.accessorItemList.forEach(e=>{
+          var attach = {};
+          attach.name = e.filename;
+          attach.src=e.fileurl;
+          attachList.push(attach);
+        });
+      this.$refs.attachmentDisplay.AttachmentModVis = true
+      this.$refs.attachmentDisplay.attachmentData =  attachList;
+    },
 
     // 分页变化时触发
     handleTableChange(pagination, filters, sorter) {

+ 114 - 0
src/views/reportForms/pro-progress-report/attachment-display.vue

@@ -0,0 +1,114 @@
+<template>
+  <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>