billInvoice.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. <lotusCalendar :calendarData="calendarData" @returnDate="calendarChange" @closeCalendar="closeCalendar">
  35. </lotusCalendar>
  36. <uv-picker ref="picker" :columns="columns" @confirm="confirm" keyName="name" :key="columns.length"></uv-picker>
  37. <view class="hui-button-box">
  38. <view class="hui-button" @click="submit">保存</view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import upload from '@/components/common/upload.vue'
  44. import lotusCalendar from "@/components/Winglau14-lotusCalendar/Winglau14-lotusCalendar.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. calendarData: {
  69. isShow: false,
  70. choseTime: ''
  71. },
  72. invoice: {}
  73. }
  74. },
  75. onShow() {
  76. this.columns = [this.$field.field.invoiceType];
  77. },
  78. onLoad(body) {
  79. this.type = body.type;
  80. this.billId = body.billId;
  81. let type = this.type == '1' ? 'paymentId' : 'paymentOrdinaryId';
  82. this.formData[type] = body.billId;
  83. this.formData['organizationId'] = this.$store.getters.organization.id;
  84. if (this.type == '1') {
  85. this.formData['cargoName'] = '房租';
  86. this.formData['type'] = 1;
  87. } else {
  88. this.formData['type'] = 2;
  89. }
  90. },
  91. methods: {
  92. openPicker() {
  93. this.$refs.picker.open();
  94. },
  95. confirm(item) {
  96. let invoice = item.value[0];
  97. this.formData.invoiceType = invoice.id;
  98. this.invoice = invoice;
  99. },
  100. openDate() {
  101. this.calendarData.isShow = true;
  102. },
  103. calendarChange(res) {
  104. if (res.time) {
  105. this.formData.date = res.time;
  106. }
  107. this.calendarData.isShow = res.isShow;
  108. },
  109. closeCalendar(res) {
  110. this.calendarData.isShow = res.isShow;
  111. },
  112. submit() {
  113. if (!this.formData.name) return this.$toast('请输入发票名称');
  114. if (!this.formData.invoiceType) return this.$toast('请选择发票类型');
  115. let attachment = this.$refs.upload.getFile();
  116. if (attachment.length === 0) return this.$toast('请上传发票附件');
  117. let postData = JSON.parse(JSON.stringify(this.formData));
  118. postData['attachment'] = JSON.stringify(attachment);
  119. insertPaymentInvoice(postData).then(res => {
  120. if (res.code === 200) {
  121. if (this.type === '1') {
  122. putPaymentStatus(this.billId, 2);
  123. } else {
  124. updatePayment({
  125. id: this.billId,
  126. status: 2
  127. })
  128. }
  129. this.$toast('操作成功');
  130. uni.$emit('reloadBill');
  131. setTimeout(() => {
  132. this.$navigateBack();
  133. }, 400)
  134. }
  135. })
  136. }
  137. },
  138. components: {
  139. upload,
  140. lotusCalendar
  141. },
  142. }
  143. </script>
  144. <style lang="scss">
  145. .bill-invoice {
  146. padding: 30rpx;
  147. padding-bottom: 130rpx;
  148. }
  149. </style>