recodeForm.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div class="hui-flex hui-dialog">
  3. <div class="hui-flex-box hui-dialog-content">
  4. <el-form ref="form" label-position="top" :model="form">
  5. <el-form-item label="付款名称" prop="name" :rules="[{required: true, message: '请输入付款名称'}]">
  6. <el-input type="text" v-model="form.name" placeholder="请输入付款名称"></el-input>
  7. </el-form-item>
  8. <el-form-item label="回执单" class="hui-textarea">
  9. <upload ref="upload" :list="responsibility" type="insert" accept=".png, .jpg, .jpeg, .pdf"
  10. text="上传回执单">
  11. </upload>
  12. </el-form-item>
  13. </el-form>
  14. </div>
  15. <div class="hui-dialog-submit">
  16. <el-button size="medium" @click="$emit('callback')">取 消</el-button>
  17. <el-button size="medium" type="primary" @click="submit">保 存</el-button>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import upload from '@/components/common/upload'
  23. import {
  24. insertPaymentRecord,
  25. putPaymentStatus
  26. } from '@/httpApi/contract'
  27. import {
  28. updatePayment
  29. } from '@/httpApi/bill'
  30. export default {
  31. props: ['itemId', 'type'],
  32. data() {
  33. return {
  34. form: {
  35. name: '',
  36. data: '{}'
  37. },
  38. responsibility: []
  39. }
  40. },
  41. created() {
  42. this.form[this.type + 'Id'] = this.itemId;
  43. },
  44. methods: {
  45. submit() {
  46. this.$refs.form.validate((valid) => {
  47. if (valid) {
  48. if (this.$refs.upload.fileList.length === 0) return this.$message.warning('请上传回执单');
  49. let postData = JSON.parse(JSON.stringify(this.form));
  50. postData['attachment'] = JSON.stringify(this.$refs.upload.fileList);
  51. insertPaymentRecord(postData).then(res => {
  52. if (res.state) {
  53. if (this.type === 'payment') {
  54. putPaymentStatus(this.itemId, 1);
  55. } else {
  56. updatePayment({
  57. id: this.itemId,
  58. status: 1
  59. })
  60. }
  61. this.$message.success('操作成功');
  62. this.$emit('callback', 'init');
  63. }
  64. })
  65. } else {
  66. return false;
  67. }
  68. });
  69. }
  70. },
  71. components: {
  72. upload
  73. },
  74. }
  75. </script>
  76. <style>
  77. </style>