[update] 收入合同、文件上传限制、文件预览

This commit is contained in:
zhaoxiao
2021-09-06 17:44:13 +08:00
parent 804fe3cafa
commit 575c1b7cd5
6 changed files with 97 additions and 30 deletions
+29 -5
View File
@@ -53,6 +53,7 @@ export default {
fileList: [],
newFileList: [],
uploadGoOn: true,
fileTypes: this.fileType
}
},
props: {
@@ -256,15 +257,37 @@ export default {
},
beforeUpload(file) {
this.uploadGoOn = true
let fileType = file.type
if (this.fileType === FILE_TYPE_IMG) {
if (fileType.indexOf('image') < 0) {
this.$message.warning('请上传图片')
file.uploadGoOn = true
const fileSize = file.size // 上传的文件大小
const fileType = file.type // 上传的文件类型
if (fileSize > 1024 * 1024 * 50) {
this.$message.warning('文件大小限制为50M')
this.uploadGoOn = false
file.uploadGoOn = false
return false
}
// 不等于全部类型可以上传的时候,对上传的文件进行判断
if (this.fileType !== FILE_TYPE_ALL) {
// filter(tt => fileType.indexOf(tt) > -1) 判断用户传的文件类型,和要求传的文件类型是否一致
// 当上传的图片格式为jpg时,在此组件中,会返回类型为 image/jpeg ElememntUI设计如此 所以需要把用户传下来的jpg强制改成jpeg
this.fileTypes = this.fileTypes.replace('jpg', 'jpeg')
const arr = this.fileTypes.split(',').filter(tt => fileType.indexOf(tt) > -1)
if (arr.length === 0) {
this.$message.warning(this.fileTypeErrorMessage || `请上传${this.fileTypes}文件`)
this.uploadGoOn = false
file.uploadGoOn = false
return false
}
}
//TODO 扩展功能验证文件大小
if (this.fileTypes === FILE_TYPE_IMG) {
if (fileType.indexOf('image') < 0) {
this.$message.warning('请上传图片')
this.uploadGoOn = false
file.uploadGoOn = false
return false
}
}
// TODO 扩展功能验证文件大小
return true
},
handleChange(info) {
@@ -322,6 +345,7 @@ export default {
console.log(file)
},
handlePreview(file) {
console.log(file)
if (file && file.url) {
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
@@ -167,12 +167,12 @@ export default {
}, {
title: '签订单位',
align: 'center',
dataIndex: 'signedCompany',
dataIndex: 'signedCompanyTemporaryName',
width: 250
}, {
title: '签订联系人',
align: 'center',
dataIndex: 'signedContactsName',
dataIndex: 'signedContactsTemporaryName',
width: 250
}, {
title: '合同总金额',
@@ -182,7 +182,7 @@ export default {
}, {
title: '状态',
align: 'center',
dataIndex: 'status',
dataIndex: 'status_dictText',
width: 250
}, {
title: '创建时间',
@@ -213,7 +213,7 @@ export default {
fieldName: 'amountReceived',
title: '未收金额'
}, {
fieldName: 'accountStatus',
fieldName: 'accountStatus_dictText',
title: '赊账状态'
}
],
@@ -49,7 +49,7 @@
<j-dict-select-tag v-decorator="['opening']"
:triggerChange="true"
placeholder="请选择是否开口"
dictCode="revenue_contract_open"/>
dictCode="yn"/>
</a-form-item>
</a-col>
<a-col :xxl="6" :xl="8" :sm="12">
@@ -6,15 +6,16 @@
<div class="part-title-text">工作组信息</div>
</div>
<!-- 工作组信息区域-->
<a-spin :spinning="loading">
<a-spin :spinning="spinning">
<div class="work-group-detail">
<div class="work-group-detail-item work-group-detail-item-small"
v-for="(item, index) in detailTitleList"
:key="index">
<div class="work-group-detail-item-title">{{ item.title }}:</div>
<div class="work-group-detail-item-content"
v-if="item.fieldName === 'chargeNoticeAId' || item.fieldName === 'chargeNoticeBId'">
{{ workingGroupDetail[item.fieldName] }}
<div class="work-group-detail-item-content work-group-detail-item-filename"
v-if="(item.fieldName === 'chargeNoticeA' || item.fieldName === 'chargeNoticeB') && workingGroupDetail[item.fieldName]"
@click="previewFile(workingGroupDetail[item.fieldName])">
{{ workingGroupDetail[item.fieldName].fileName }}
</div>
<div class="work-group-detail-item-content" v-else>{{ workingGroupDetail[item.fieldName] }}</div>
</div>
@@ -61,7 +62,8 @@
<!-- 操作按钮区域-->
<div class="table-operator">
<a-button type="primary" icon="plus" @click="handleAdd">添加成员</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :data="importParam" :action="importExcelUrl" @change="handleImportExcel">
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :data="importParam"
:action="importExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload>
<a-button type="primary" icon="export" @click="handleExportXls('工作组成员')">导出</a-button>
@@ -74,18 +76,18 @@
<!-- table表格区域-->
<div>
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
:columns="columns"
:scroll="{x: 1500}"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange"
class="j-table-force-nowrap">
ref="table"
size="middle"
bordered
rowKey="id"
:columns="columns"
:scroll="{x: 1500}"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange"
class="j-table-force-nowrap">
<!-- 工作组名称-->
<template slot="projectName" slot-scope="text, record">
@@ -115,7 +117,8 @@
<project-detail-modal ref="projectDetail"></project-detail-modal>
<working-group-member-unit-module ref="modalForm" @ok="modalFormOk"></working-group-member-unit-module>
<working-group-member-set-charge-notice ref="setChargeNotic" @ok="modalFormOk"></working-group-member-set-charge-notice>
<working-group-member-set-charge-notice ref="setChargeNotic"
@ok="modalFormOk"></working-group-member-set-charge-notice>
</div>
</template>
@@ -128,6 +131,10 @@ import StatusSlot from '../../components/tools/StatusSlot'
import ProjectDetailModal from '../../components/ProjectDetailModal'
import WorkingGroupMemberUnitModule from './modules/WorkingGroupMemberUnitModule'
import WorkingGroupMemberSetChargeNotice from './modules/WorkingGroupMemberSetChargeNotice'
import { getFileInfo } from '../../api/api'
import Vue from 'vue'
import { ACCESS_TOKEN } from '../../store/mutation-types'
const Base64 = require('js-base64').Base64
export default {
name: 'WorkingGroupMemberUnitMaintenance',
@@ -150,6 +157,7 @@ export default {
disableMixinCreated: true,
workingGroupProject: '',
workingGroupProjectId: '',
spinning: false,
detailTitleList: [
{
title: '工作组项目名称',
@@ -174,7 +182,7 @@ export default {
fieldName: 'chargeNoticeNoA'
}, {
title: '收费通知A',
fieldName: 'chargeNoticeAId'
fieldName: 'chargeNoticeA'
}, {
title: '本年应收款B',
fieldName: 'yearChargeB'
@@ -183,7 +191,7 @@ export default {
fieldName: 'chargeNoticeNoB'
}, {
title: '收费通知B',
fieldName: 'chargeNoticeBId'
fieldName: 'chargeNoticeB'
}
],
labelCol: {
@@ -285,6 +293,7 @@ export default {
* 初始化工作组信息
*/
initWorkGruopData() {
this.spinning = true
this.workingGroupProject = this.$route.query.workingGroupProject
this.workingGroupProjectId = this.$route.query.workingGroupProjectId
this.filters.workingGroupId = this.workingGroupProjectId
@@ -295,6 +304,21 @@ export default {
}
getWorkingGroupById(param).then(res => {
this.workingGroupDetail = res.result
// this.workingGroupDetail.chargeNoticeA = {}
// this.workingGroupDetail.chargeNoticeB = {}
this.getFile()
}).finally(() => {
this.spinning = false
})
},
async getFile() {
await getFileInfo({ id: this.workingGroupDetail.chargeNoticeAId }).then(res => {
this.workingGroupDetail.chargeNoticeA = res.result
this.$forceUpdate()
})
await getFileInfo({ id: this.workingGroupDetail.chargeNoticeBId }).then(res => {
this.workingGroupDetail.chargeNoticeB = res.result
this.$forceUpdate()
})
},
handleAdd: function () {
@@ -368,6 +392,19 @@ export default {
this.$message.warn(res.message)
}
})
},
/**
* 文件预览
* @param file
*/
previewFile(file) {
console.log(file)
if (file && file.url) {
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
// let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
window.open(url)
}
}
}
}
@@ -407,6 +444,10 @@ export default {
word-break: break-all;
color: #2F3133;
}
&-filename {
cursor: pointer;
}
}
}
@@ -96,6 +96,7 @@
:multiple="false"
:return-id="true"
bizPath="payment"
:number="1"
v-decorator="['chargeNoticeAId']"
:trigger-change="true"></j-upload>
</a-form-item>
@@ -132,6 +133,7 @@
:multiple="false"
:return-id="true"
bizPath="payment"
:number="1"
v-decorator="['chargeNoticeBId']"
:trigger-change="true"></j-upload>
</a-form-item>