|
|
@@ -34,15 +34,21 @@
|
|
|
<el-form-item label="文件" prop="file">
|
|
|
<el-upload
|
|
|
ref="uploadRef"
|
|
|
- action="#"
|
|
|
- :auto-upload="false"
|
|
|
+ :action="uploadFileUrl"
|
|
|
:file-list="fileList"
|
|
|
:limit="1"
|
|
|
- :on-change="
|
|
|
- (file) => {
|
|
|
- return setFile(file)
|
|
|
+ :show-file-list="true"
|
|
|
+ :on-remove="
|
|
|
+ (file, fileList) => {
|
|
|
+ return removeFile(file, fileList, index)
|
|
|
}
|
|
|
- ">
|
|
|
+ "
|
|
|
+ :on-success="
|
|
|
+ (response, file) => {
|
|
|
+ return setFile(response, file, index)
|
|
|
+ }
|
|
|
+ "
|
|
|
+ >
|
|
|
<el-button size="mini" type="primary">点击上传</el-button>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
@@ -58,12 +64,14 @@
|
|
|
import axios from 'axios'
|
|
|
import { getToken } from '@/utils/token'
|
|
|
import to from 'await-to-js'
|
|
|
+ import contractApi from '@/api/contract'
|
|
|
export default {
|
|
|
components: {},
|
|
|
data() {
|
|
|
return {
|
|
|
visible: false,
|
|
|
loading: false,
|
|
|
+ uploadFileUrl: process.env.VUE_APP_UPLOAD_FILE_WEED,
|
|
|
fileList: [],
|
|
|
fileSettings: {
|
|
|
// 文件配置信息
|
|
|
@@ -80,7 +88,8 @@
|
|
|
contractModel: '',
|
|
|
terms: '',
|
|
|
payTerms: '',
|
|
|
- file: null,
|
|
|
+ fileName: '',
|
|
|
+ fileUrl: '',
|
|
|
},
|
|
|
rules: {
|
|
|
contractModel: [{ required: true, trigger: 'blur', message: '请选择合同模板' }],
|
|
|
@@ -98,63 +107,87 @@
|
|
|
contractModel: '',
|
|
|
terms: '',
|
|
|
payTerms: '',
|
|
|
- file: null,
|
|
|
+ fileName: '',
|
|
|
+ fileUrl: '',
|
|
|
}
|
|
|
},
|
|
|
// 上传图片
|
|
|
- setFile(file) {
|
|
|
- this.form.file = file.raw
|
|
|
+ setFile(res, file, index) {
|
|
|
+ this.form.fileName = file.name
|
|
|
+ this.form.fileUrl = res.Data
|
|
|
return true
|
|
|
},
|
|
|
+ removeFile(file, list, index) {
|
|
|
+ this.form.fileName = ""
|
|
|
+ this.form.fileUrl = ""
|
|
|
+ },
|
|
|
async handleSubmit() {
|
|
|
const [valid] = await to(this.$refs.form.validate())
|
|
|
if (valid == false) return
|
|
|
- if (this.form.file == null) return this.$message.warning('附件不能为空')
|
|
|
+ if (!this.form.fileUrl) return this.$message.warning('附件不能为空')
|
|
|
// const [err, res] = await to(contractApi.ss(this.form))
|
|
|
// if (err) return
|
|
|
|
|
|
- let formData = new FormData()
|
|
|
- formData.append('file', this.form.file)
|
|
|
- formData.append('contractId', this.form.id)
|
|
|
- formData.append('contractModel', this.form.contractModel)
|
|
|
- formData.append('terms', this.form.terms)
|
|
|
- formData.append('payTerms', this.form.payTerms)
|
|
|
this.loading = true
|
|
|
- axios({
|
|
|
- method: 'post',
|
|
|
- url: process.env.VUE_APP_MicroSrvProxy_API + process.env.VUE_APP_ParentPath,
|
|
|
- // url: 'http://192.168.0.51:9981/dashoo.dev.opms.parent-0.0.1',
|
|
|
- data: formData,
|
|
|
- headers: {
|
|
|
- Authorization: 'Bearer ' + getToken(),
|
|
|
- 'X-RPCX-SerializeType': '1',
|
|
|
- 'X-RPCX-ServicePath': 'CtrContractHandler',
|
|
|
- 'X-RPCX-ServiceMethod': 'CommitWithFile',
|
|
|
- 'content-type': 'multipart/form-data',
|
|
|
- tenant: process.env.VUE_APP_TENANT,
|
|
|
- },
|
|
|
- })
|
|
|
+ contractApi.commitWithFileUrl(this.form)
|
|
|
.then((res) => {
|
|
|
- this.loading = false
|
|
|
- console.log(res)
|
|
|
- if (res.data.code != 0) {
|
|
|
- this.$message({
|
|
|
- type: 'error',
|
|
|
- message: res.data.msg,
|
|
|
- })
|
|
|
- } else {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$message.success('提交成功')
|
|
|
this.visible = false
|
|
|
this.$emit('refresh')
|
|
|
+ } else {
|
|
|
+ this.$message.success('系统异常')
|
|
|
+ console.error(res)
|
|
|
}
|
|
|
+ this.loading = false
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- this.loading = false
|
|
|
console.error(err)
|
|
|
- this.$message({
|
|
|
- type: 'warning',
|
|
|
- message: '系统异常',
|
|
|
- })
|
|
|
+ this.loading = false
|
|
|
})
|
|
|
+
|
|
|
+ // let formData = new FormData()
|
|
|
+ // formData.append('file', this.form.file)
|
|
|
+ // formData.append('contractId', this.form.id)
|
|
|
+ // formData.append('contractModel', this.form.contractModel)
|
|
|
+ // formData.append('terms', this.form.terms)
|
|
|
+ // formData.append('payTerms', this.form.payTerms)
|
|
|
+ // this.loading = true
|
|
|
+ // axios({
|
|
|
+ // method: 'post',
|
|
|
+ // url: process.env.VUE_APP_MicroSrvProxy_API + process.env.VUE_APP_ParentPath,
|
|
|
+ // // url: 'http://192.168.0.51:9981/dashoo.dev.opms.parent-0.0.1',
|
|
|
+ // data: formData,
|
|
|
+ // headers: {
|
|
|
+ // Authorization: 'Bearer ' + getToken(),
|
|
|
+ // 'X-RPCX-SerializeType': '1',
|
|
|
+ // 'X-RPCX-ServicePath': 'CtrContractHandler',
|
|
|
+ // 'X-RPCX-ServiceMethod': 'CommitWithFile',
|
|
|
+ // 'content-type': 'multipart/form-data',
|
|
|
+ // tenant: process.env.VUE_APP_TENANT,
|
|
|
+ // },
|
|
|
+ // })
|
|
|
+ // .then((res) => {
|
|
|
+ // this.loading = false
|
|
|
+ // console.log(res)
|
|
|
+ // if (res.data.code != 0) {
|
|
|
+ // this.$message({
|
|
|
+ // type: 'error',
|
|
|
+ // message: res.data.msg,
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // this.visible = false
|
|
|
+ // this.$emit('refresh')
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // .catch((err) => {
|
|
|
+ // this.loading = false
|
|
|
+ // console.error(err)
|
|
|
+ // this.$message({
|
|
|
+ // type: 'warning',
|
|
|
+ // message: '系统异常',
|
|
|
+ // })
|
|
|
+ // })
|
|
|
},
|
|
|
},
|
|
|
}
|