|
|
@@ -31,36 +31,56 @@
|
|
|
show-word-limit
|
|
|
type="textarea" />
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="文件" prop="file">
|
|
|
+ <el-upload
|
|
|
+ ref="uploadRef"
|
|
|
+ action="#"
|
|
|
+ :auto-upload="false"
|
|
|
+ :file-list="fileList"
|
|
|
+ :limit="1"
|
|
|
+ :on-change="
|
|
|
+ (file) => {
|
|
|
+ return setFile(file)
|
|
|
+ }
|
|
|
+ ">
|
|
|
+ <el-button size="mini" type="primary">点击上传</el-button>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
|
<span slot="footer">
|
|
|
- <el-button size="mini" type="primary" @click="handleSubmit">确定</el-button>
|
|
|
+ <el-button :loading="loading" size="mini" type="primary" @click="handleSubmit">确定</el-button>
|
|
|
<el-button size="mini" @click="visible = false">取消</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import contractApi from '@/api/contract'
|
|
|
+ import axios from 'axios'
|
|
|
+ import { getToken } from '@/utils/token'
|
|
|
import to from 'await-to-js'
|
|
|
export default {
|
|
|
components: {},
|
|
|
data() {
|
|
|
return {
|
|
|
visible: false,
|
|
|
+ loading: false,
|
|
|
+ fileList: [],
|
|
|
+ fileSettings: {
|
|
|
+ // 文件配置信息
|
|
|
+ fileSize: 52428800,
|
|
|
+ fileTypes: '.doc,.docx,.zip,.xls,.xlsx,.rar,.jpg,.jpeg,.gif,.png,.jfif,.txt',
|
|
|
+ pictureSize: 52428800,
|
|
|
+ pictureTypes: '.jpg,.jpeg,.gif,.png,.jfif,.txt',
|
|
|
+ types: '.doc,.docx,.zip,.xls,.xlsx,.rar,.jpg,.jpeg,.gif,.png,.jfif,.mp4,.txt',
|
|
|
+ videoSize: 104857600,
|
|
|
+ videoType: '.mp4',
|
|
|
+ },
|
|
|
form: {
|
|
|
id: 0,
|
|
|
contractModel: '',
|
|
|
terms: '',
|
|
|
payTerms: '',
|
|
|
- file: [
|
|
|
- // {
|
|
|
- // spaceId: '',
|
|
|
- // fileId: '',
|
|
|
- // fileName: '',
|
|
|
- // fileSize: 0,
|
|
|
- // fileType: '',
|
|
|
- // },
|
|
|
- ],
|
|
|
+ file: null,
|
|
|
},
|
|
|
rules: {
|
|
|
contractModel: [{ required: true, trigger: 'blur', message: '请选择合同模板' }],
|
|
|
@@ -71,23 +91,70 @@
|
|
|
},
|
|
|
methods: {
|
|
|
handleClose() {
|
|
|
+ this.fileList = []
|
|
|
+ this.loading = false
|
|
|
this.form = {
|
|
|
id: 0,
|
|
|
contractModel: '',
|
|
|
terms: '',
|
|
|
payTerms: '',
|
|
|
- file: [],
|
|
|
+ file: null,
|
|
|
}
|
|
|
},
|
|
|
+ // 上传图片
|
|
|
+ setFile(file) {
|
|
|
+ this.form.file = file.raw
|
|
|
+ return true
|
|
|
+ },
|
|
|
async handleSubmit() {
|
|
|
const [valid] = await to(this.$refs.form.validate())
|
|
|
if (valid == false) return
|
|
|
- if (this.form.file.length == 0) return this.$message.warning('附件不能为空')
|
|
|
- const [err, res] = await to(contractApi.commit(this.form))
|
|
|
- if (err) return
|
|
|
- this.$message.success(res.msg)
|
|
|
- this.visible = false
|
|
|
- this.$emit('refresh')
|
|
|
+ if (this.form.file == null) 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,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .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: '系统异常',
|
|
|
+ })
|
|
|
+ })
|
|
|
},
|
|
|
},
|
|
|
}
|