billRecord.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="form-box file-form-box bill-record">
  3. <uni-forms label-position="top" :modelValue="formData">
  4. <uni-forms-item label="付款名称" name="name">
  5. <uni-easyinput type="text" v-model="formData.name" placeholder="请输入付款名称" />
  6. </uni-forms-item>
  7. <uni-forms-item label="回执单">
  8. <upload ref="upload" accept="all" type="insert"></upload>
  9. </uni-forms-item>
  10. </uni-forms>
  11. <view class="hui-button-box">
  12. <view class="hui-button" @click="submit">保存</view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import upload from '@/components/common/upload.vue'
  18. import {
  19. insertPaymentRecord,
  20. putPaymentStatus
  21. } from '@/request/api/contract.js'
  22. import {
  23. updatePayment
  24. } from '@/request/api/bill.js'
  25. export default {
  26. data() {
  27. return {
  28. formData: {
  29. name: '',
  30. paymentId: '',
  31. paymentOrdinaryId: ''
  32. },
  33. type: '',
  34. billId: ''
  35. }
  36. },
  37. onLoad(body) {
  38. this.type = body.type;
  39. this.billId = body.billId;
  40. let type = this.type == '1' ? 'paymentId' : 'paymentOrdinaryId';
  41. this.formData[type] = body.billId;
  42. },
  43. methods: {
  44. submit() {
  45. if (!this.formData.name) return this.$toast('请输入付款名称');
  46. let attachment = this.$refs.upload.getFile();
  47. if (attachment.length === 0) return this.$toast('请上传回执单');
  48. let postData = JSON.parse(JSON.stringify(this.formData));
  49. postData['attachment'] = JSON.stringify(attachment);
  50. insertPaymentRecord(postData).then(res => {
  51. if (res.code === 200) {
  52. if (this.type === '1') {
  53. putPaymentStatus(this.billId, 1);
  54. } else {
  55. updatePayment({
  56. id: this.billId,
  57. status: 1
  58. })
  59. }
  60. this.$toast('操作成功');
  61. uni.$emit('reloadBill');
  62. setTimeout(() => {
  63. this.$navigateBack();
  64. }, 400)
  65. }
  66. })
  67. }
  68. },
  69. components: {
  70. upload
  71. },
  72. }
  73. </script>
  74. <style lang="scss">
  75. .bill-record {
  76. padding: 30rpx;
  77. .file-form-box {
  78. padding-bottom: 0rpx;
  79. }
  80. }
  81. </style>