rebate.vue 5.4 KB

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