billInvoice.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="form-box file-form-box bill-invoice">
  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="发票类型" name="invoiceType">
  8. <view class="select-box" @click="openPicker">
  9. <text class="select-text" v-if="formData.invoiceType">{{invoice.name}}</text>
  10. <text class="select-label" v-else>请选择发票类型</text>
  11. <uni-icons class="form-icon" type="down" size="12" color="#8c8c8c"></uni-icons>
  12. </view>
  13. </uni-forms-item>
  14. <uni-forms-item label="发票代码" name="code">
  15. <uni-easyinput type="text" v-model="formData.code" placeholder="请输入发票代码" />
  16. </uni-forms-item>
  17. <uni-forms-item label="发票号码" name="name">
  18. <uni-easyinput type="text" v-model="formData.number" placeholder="请输入发票号码" />
  19. </uni-forms-item>
  20. <uni-forms-item label="货物名称" name="cargoName">
  21. <uni-easyinput type="text" v-model="formData.cargoName" placeholder="请输入货物名称" />
  22. </uni-forms-item>
  23. <uni-forms-item label="开票日期" name="date">
  24. <view class="select-box" @click="openDate">
  25. <text class="select-text" v-if="formData.date">{{formData.date}}</text>
  26. <text class="select-label" v-else>请选择日期</text>
  27. <uni-icons class="form-icon" type="down" size="12" color="#8c8c8c"></uni-icons>
  28. </view>
  29. </uni-forms-item>
  30. <uni-forms-item label="发票附件">
  31. <upload ref="upload" accept="all" type="insert"></upload>
  32. </uni-forms-item>
  33. </uni-forms>
  34. <uv-datetime-picker ref="dateTimePicker" v-model="nowTime" mode="datetime" @confirm="confirmTime"
  35. :minDate="nowTime">
  36. </uv-datetime-picker>
  37. <uv-picker ref="picker" :columns="columns" @confirm="confirm" keyName="name" :key="columns.length"></uv-picker>
  38. <view class="hui-button-box">
  39. <view class="hui-button" @click="submit">保存</view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import upload from '@/components/common/upload.vue'
  45. import {
  46. insertPaymentInvoice,
  47. putPaymentStatus
  48. } from '@/request/api/contract.js'
  49. import {
  50. updatePayment
  51. } from '@/request/api/bill.js'
  52. export default {
  53. data() {
  54. return {
  55. formData: {
  56. name: '',
  57. code: '',
  58. number: '',
  59. cargoName: '',
  60. paymentId: '',
  61. paymentOrdinaryId: '',
  62. date: '',
  63. invoiceType: ''
  64. },
  65. type: '',
  66. billId: '',
  67. columns: [],
  68. nowTime: Number(new Date()),
  69. invoice: {}
  70. }
  71. },
  72. onShow() {
  73. this.columns = [this.$field.field.invoiceType];
  74. },
  75. onLoad(body) {
  76. this.type = body.type;
  77. this.billId = body.billId;
  78. let type = this.type == '1' ? 'paymentId' : 'paymentOrdinaryId';
  79. this.formData[type] = body.billId;
  80. this.formData['organizationId'] = this.$store.getters.organization.id;
  81. if (this.type == '1') {
  82. this.formData['cargoName'] = '房租';
  83. this.formData['type'] = 1;
  84. } else {
  85. this.formData['type'] = 2;
  86. }
  87. },
  88. methods: {
  89. openPicker() {
  90. this.$refs.picker.open();
  91. },
  92. confirm(item) {
  93. let invoice = item.value[0];
  94. this.formData.invoiceType = invoice.id;
  95. this.invoice = invoice;
  96. },
  97. openDate() {
  98. this.calendarData.isShow = true;
  99. },
  100. confirm(e) {
  101. let date = this.$dayjs(e.value).format('YYYY-MM-DD HH:mm');
  102. this.formData.date = date;
  103. },
  104. submit() {
  105. if (!this.formData.name) return this.$toast('请输入发票名称');
  106. if (!this.formData.invoiceType) return this.$toast('请选择发票类型');
  107. let attachment = this.$refs.upload.getFile();
  108. if (attachment.length === 0) return this.$toast('请上传发票附件');
  109. let postData = JSON.parse(JSON.stringify(this.formData));
  110. postData['attachment'] = JSON.stringify(attachment);
  111. insertPaymentInvoice(postData).then(res => {
  112. if (res.code === 200) {
  113. if (this.type === '1') {
  114. putPaymentStatus(this.billId, 2);
  115. } else {
  116. updatePayment({
  117. id: this.billId,
  118. status: 2
  119. })
  120. }
  121. this.$toast('操作成功');
  122. uni.$emit('reloadBill');
  123. setTimeout(() => {
  124. this.$navigateBack();
  125. }, 400)
  126. }
  127. })
  128. }
  129. },
  130. components: {
  131. upload
  132. },
  133. }
  134. </script>
  135. <style lang="scss">
  136. .bill-invoice {
  137. padding: 30rpx;
  138. padding-bottom: 130rpx;
  139. }
  140. </style>