Files
income_payments_client/src/views/projectManagement/modules/WorkGroupFileUploadModal.vue
T

136 lines
3.4 KiB
Vue

<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-row>
<a-col>
<a-form-item label="文件" :labelCol="labelCol" :wrapperCol="wrapperCol">
<j-upload file-type="all"
file-type-error-message="请上传文件"
:multiple="true"
:number="10"
:return-id="true"
v-decorator="['dataId', validatorRules.dataId]"
:trigger-change="true"></j-upload>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-spin>
</j-modal>
</template>
<script>
import pick from 'lodash.pick'
import { getAction } from '@api/manage'
import JUpload from '@comp/jero/JUpload'
export default {
name: 'WorkGroupFileUploadModal',
components: { JUpload },
data() {
return {
title: '编辑',
width: 800,
visible: false,
confirmLoading: false,
form: this.$form.createForm(this),
model: {},
fileList: [],
labelCol: {
xs: { span: 24 },
sm: { span: 5 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 17 }
},
validatorRules: {
dataId: {
rules: [{ required: true, message: '请上传文件' }],
validateTrigger: 'change'
}
},
url: {
add: '', // 资料和会议的添加 post
edit: '', // 资料和会议的编辑 post
}
}
},
created(){
},
methods: {
add(data) {
this.edit({}, data)
},
edit(record, data) {
this.dataType = data // 接收数据类型
this.form.resetFields()
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'dataId' ))
})
},
close() {
this.$emit('close')
this.visible = false
},
handleOk() {
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
console.log(values)
let httpurl = ''
let params = {}
if (!this.model.keyId) {
httpurl += this.url.add
params = {
dataId: values.fileId, // 目录id
dataType: this.dataType, // 上传类型
fileIds: values.dataId // 资料id
}
} else {
httpurl += this.url.edit
params = {
dataId: values.fileId, // 目录id
dataType: this.dataType, // 上传类型
fileIds: values.dataId, // 资料id
keyId: this.record.keyId, // 主键id
oldFileId: this.record.dataId // 旧文件id
}
}
getAction(httpurl, params).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok')
that.close()
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
})
}
})
},
handleCancel() {
this.close()
}
}
}
</script>
<style scoped>
</style>