rebate.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="operationRecord pl-4 pr-4 pt-3 pb-3 h-full flex flex-col">
  3. <div class="flex justify-between">
  4. <div class="title">回款</div>
  5. <div class="flex" v-permission="['orderEdit']">
  6. <el-button type="primary" @click="editRebate(false)">新增回款</el-button>
  7. </div>
  8. </div>
  9. <div class="flex-1 overflow-auto pt-5">
  10. <el-table :data="operationRecordtable" border style="width: 100%;height: 278px;">
  11. <el-table-column prop="createTime" label="回款时间" width="170" />
  12. <el-table-column prop="creatorName" label="操作人" width="120" />
  13. <el-table-column prop="money" label="回款金额" width="120" />
  14. <el-table-column prop="unReceivedPayment" label="未回款金额" width="120" />
  15. <el-table-column :label="'操作'" :width="'120px'" fixed="right">
  16. <template #default="scope">
  17. <el-button link type="primary" size="large" @click="editRebate(scope.row)">编辑</el-button>
  18. <el-button link type="danger" size="large" @click="deteItem(scope.row)">删除</el-button>
  19. </template>
  20. </el-table-column>
  21. </el-table>
  22. </div>
  23. <!-- 弹窗 -->
  24. <el-dialog v-model="allVisible.rebateVisible" width="680" :show-close="false" top="10vh">
  25. <template #header="{ close, titleId, titleClass }">
  26. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  27. <h4 :id="titleId">{{ allText.rebateText }}</h4>
  28. <div class="flex">
  29. <el-button @click="allVisible.rebateVisible = false">取消</el-button>
  30. <el-button type="primary" @click="saveRebate" :loading="allLoading.rebateLoading">保存</el-button>
  31. </div>
  32. </div>
  33. </template>
  34. <div class="p-8">
  35. <div class="flex flex-row items-center">
  36. <div>回款金额:</div>
  37. <div class="flex-1">
  38. <el-input v-model.trim="mony" v-enterNumber placeholder="请输入" clearable class="w-full"></el-input>
  39. </div>
  40. <div class="ml-4">元</div>
  41. </div>
  42. </div>
  43. </el-dialog>
  44. </div>
  45. </template>
  46. <script lang="ts" setup>
  47. import { post } from '@/utils/request';
  48. import { ref, reactive, onMounted, onUnmounted, defineExpose, inject, watchEffect } from 'vue'
  49. import { URL_ADDREBATE, URL_DETELEITEMS, URL_EDITEBATE } from '../api';
  50. import { confirmAction } from '@/utils/tools';
  51. import { ITEM_RENDER_EVT } from 'element-plus/es/components/virtual-list/src/defaults';
  52. const globalPopup = inject<GlobalPopup>('globalPopup')
  53. const emits = defineEmits(['refreshData']);
  54. const props = defineProps<{
  55. data: any,
  56. information: any
  57. }>()
  58. const allVisible = reactive({
  59. rebateVisible: false,
  60. })
  61. const allLoading = reactive({
  62. rebateLoading: false
  63. })
  64. const allText = reactive({
  65. rebateText: '新增回款'
  66. })
  67. const operationRecordtable = ref([])
  68. const mony = ref('')
  69. const monyItem = ref<any>({})
  70. const info = ref<any>({})
  71. function deteItem(item: any) {
  72. confirmAction(`确定删除该回款记录吗?`).then(() => {
  73. post(URL_DETELEITEMS, { paymentId: item.id }).then((_res) => {
  74. globalPopup?.showSuccess('删除成功')
  75. emits('refreshData', 'getPaymentCollectionList')
  76. }).catch((err) => {
  77. globalPopup?.showError(err.msg || '')
  78. })
  79. })
  80. }
  81. function editRebate(item: any) {
  82. if (!item) {
  83. allText.rebateText = '新增回款'
  84. mony.value = ''
  85. monyItem.value = {}
  86. } else {
  87. monyItem.value = item
  88. mony.value = item.money
  89. allText.rebateText = '编辑回款'
  90. }
  91. allVisible.rebateVisible = true
  92. }
  93. function saveRebate() {
  94. if (!mony.value || mony.value == '.' || Number(mony.value as string) < 0) {
  95. globalPopup?.showWarning(Number(mony.value as string) < 0 ? '请不要输入负数' : '请输入金额')
  96. return
  97. }
  98. if(Number(mony.value as string) > info.value.unReceivedPayment) {
  99. globalPopup?.showWarning('回款金额超过了未回款金额')
  100. return
  101. }
  102. allLoading.rebateLoading = true
  103. const { url, formVal } = Object.keys(monyItem.value).length === 0
  104. ? { url: URL_ADDREBATE, formVal: { orderId: info.value.id, money: mony.value } }
  105. : { url: URL_EDITEBATE, formVal: { paymentId: monyItem.value.id, money: mony.value } };
  106. post(url, { ...formVal }).then(() => {
  107. globalPopup?.showSuccess('操作成功')
  108. allVisible.rebateVisible = false
  109. emits('refreshData', 'getPaymentCollectionList')
  110. }).finally(() => {
  111. allLoading.rebateLoading = false
  112. })
  113. }
  114. watchEffect(() => {
  115. const { data, information } = props
  116. operationRecordtable.value = data || []
  117. info.value = information
  118. });
  119. // 生命周期钩子
  120. onMounted(() => {
  121. });
  122. </script>
  123. <style scoped lang="scss">
  124. .operationRecord {
  125. .title {
  126. font-size: 18px;
  127. color: #000
  128. }
  129. }
  130. </style>