|
@@ -0,0 +1,156 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="my-title">{{ !id ? '上传':'编辑' }}</div>
|
|
|
+ <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="文件名称" prop="fileName">
|
|
|
+ <el-input v-model="dataForm.fileName" placeholder="文件名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8" style="padding-left: 20px">
|
|
|
+ <el-form-item label="文件描述" prop="fileDescribe">
|
|
|
+ <el-input v-model="dataForm.fileDescribe" placeholder="文件描述"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8" style="padding-left: 20px">
|
|
|
+ <el-form-item label="文件类别" prop="fileType">
|
|
|
+ <el-select
|
|
|
+ v-model="dataForm.fileType"
|
|
|
+ placeholder="请选择">
|
|
|
+ <el-option v-for="item in optionsType"
|
|
|
+ :key="item.code"
|
|
|
+ :label="item.value"
|
|
|
+ :value="item.code">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-form-item label="备注说明" prop="notes">
|
|
|
+ <el-input type="textarea" v-model="dataForm.notes"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <upload-component :title="'电子文件'" :accept="'*'" :file-obj-list="fileList" :limit="1" @uploadSuccess="uploadSuccess"/>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="onChose">取消</el-button>
|
|
|
+ <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import UserComponent from '../common/user-component'
|
|
|
+ import UploadComponent from '../common/upload-component'
|
|
|
+ import { getDictList } from '@/api/dict'
|
|
|
+ export default {
|
|
|
+ components: { UploadComponent, UserComponent },
|
|
|
+ computed: {
|
|
|
+ orgId: {
|
|
|
+ get () { return this.$store.state.user.orgId }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ id: 0,
|
|
|
+ dataForm: {},
|
|
|
+ dataRule: {
|
|
|
+ fileName: [{ required: true, message: '文件名称不能为空', trigger: 'blur' }],
|
|
|
+ fileDescribe: [{required: true, message: '文件描述不能为空', trigger: 'blur'}],
|
|
|
+ fileType: [{required: true, message: '请选择文件类别', trigger: 'change'}]
|
|
|
+ },
|
|
|
+ fileList: [],
|
|
|
+ optionsType: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onChose () {
|
|
|
+ this.$emit('onChose')
|
|
|
+ },
|
|
|
+ async init (id) {
|
|
|
+ this.dataForm = {}
|
|
|
+ this.id = id || 0
|
|
|
+ this.visible = true
|
|
|
+ this.fileList = []
|
|
|
+ // 获取沟通类别
|
|
|
+ await getDictList({type: 'doc_file_type'}).then(({data}) => {
|
|
|
+ if (data) {
|
|
|
+ this.optionsType = data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (this.id) {
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(`/file-service/document-ctl/info/${this.id}`),
|
|
|
+ method: 'get',
|
|
|
+ params: this.$http.adornParams()
|
|
|
+ }).then(({data}) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.dataForm = data.data
|
|
|
+ // 附件显示
|
|
|
+ if (data.data.attachList) {
|
|
|
+ data.data.attachList.forEach((item) => {
|
|
|
+ this.fileList.push({
|
|
|
+ name: item.fileName,
|
|
|
+ url: item.url,
|
|
|
+ id: item.url
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 表单提交
|
|
|
+ dataFormSubmit () {
|
|
|
+ this.$refs['dataForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ // 附件上传
|
|
|
+ let fList = this.fileList
|
|
|
+ if (fList.length > 0) {
|
|
|
+ this.dataForm.attachList = []
|
|
|
+ for (let i = 0; i < fList.length; i++) {
|
|
|
+ this.dataForm.attachList.push({
|
|
|
+ fileName: fList[i].name,
|
|
|
+ url: fList[i].url
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.error('请上传文件')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(`/file-service/document-ctl/${!this.id ? 'save' : 'update'}`),
|
|
|
+ method: 'post',
|
|
|
+ data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
|
|
|
+ }).then(({data}) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.$message({
|
|
|
+ message: '操作成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 1500,
|
|
|
+ onClose: () => {
|
|
|
+ this.onChose()
|
|
|
+ this.$emit('refreshDataList')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message.error(data.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ uploadSuccess (fileList) {
|
|
|
+ this.fileList = fileList
|
|
|
+ },
|
|
|
+ validateField (type) {
|
|
|
+ this.$refs.dataForm.validateField(type)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|