ReceivablePlanList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <!-- 操作栏 -->
  3. <el-row justify="end">
  4. <el-button @click="openForm('create', undefined)">
  5. <Icon class="mr-5px" icon="icon-park:income" />
  6. 创建回款计划
  7. </el-button>
  8. </el-row>
  9. <!-- 列表 -->
  10. <ContentWrap class="mt-10px">
  11. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  12. <el-table-column align="center" label="客户名称" prop="customerName" width="150px" />
  13. <el-table-column align="center" label="合同编号" prop="contractNo" width="200px" />
  14. <el-table-column align="center" label="期数" prop="period" />
  15. <el-table-column
  16. align="center"
  17. label="计划回款(元)"
  18. prop="price"
  19. width="120"
  20. :formatter="erpPriceTableColumnFormatter"
  21. />
  22. <el-table-column
  23. :formatter="dateFormatter2"
  24. align="center"
  25. label="计划回款日期"
  26. prop="returnTime"
  27. width="180px"
  28. />
  29. <el-table-column align="center" label="提前几天提醒" prop="remindDays" width="150" />
  30. <el-table-column
  31. :formatter="dateFormatter2"
  32. align="center"
  33. label="提醒日期"
  34. prop="remindTime"
  35. width="180px"
  36. />
  37. <el-table-column label="负责人" prop="ownerUserName" width="120" />
  38. <el-table-column align="center" label="备注" prop="remark" />
  39. <el-table-column align="center" fixed="right" label="操作" width="200px">
  40. <template #default="scope">
  41. <el-button
  42. v-hasPermi="['crm:receivable:create']"
  43. link
  44. type="primary"
  45. @click="createReceivable(scope.row)"
  46. :disabled="scope.row.receivableId"
  47. >
  48. 创建回款
  49. </el-button>
  50. <el-button
  51. v-hasPermi="['crm:receivable-plan:update']"
  52. link
  53. type="primary"
  54. @click="openForm('update', scope.row.id)"
  55. >
  56. 编辑
  57. </el-button>
  58. <el-button
  59. v-hasPermi="['crm:receivable-plan:delete']"
  60. link
  61. type="danger"
  62. @click="handleDelete(scope.row.id)"
  63. >
  64. 删除
  65. </el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <!-- 分页 -->
  70. <Pagination
  71. v-model:limit="queryParams.pageSize"
  72. v-model:page="queryParams.pageNo"
  73. :total="total"
  74. @pagination="getList"
  75. />
  76. </ContentWrap>
  77. <!-- 表单弹窗:添加 -->
  78. <ReceivableForm ref="formRef" @success="getList" />
  79. </template>
  80. <script lang="ts" setup>
  81. import * as ReceivablePlanApi from '@/api/crm/receivable/plan'
  82. import ReceivableForm from './../ReceivablePlanForm.vue'
  83. import { dateFormatter2 } from '@/utils/formatTime'
  84. import { erpPriceTableColumnFormatter } from '@/utils'
  85. defineOptions({ name: 'CrmReceivablePlanList' })
  86. const props = defineProps<{
  87. customerId?: number // 客户编号
  88. contractId?: number // 合同编号
  89. }>()
  90. const message = useMessage() // 消息弹窗
  91. const { t } = useI18n() // 国际化
  92. const loading = ref(true) // 列表的加载中
  93. const total = ref(0) // 列表的总页数
  94. const list = ref([]) // 列表的数据
  95. const queryParams = reactive({
  96. pageNo: 1,
  97. pageSize: 10,
  98. customerId: undefined as unknown, // 允许 undefined + number
  99. contractId: undefined as unknown // 允许 undefined + number
  100. })
  101. /** 查询列表 */
  102. const getList = async () => {
  103. loading.value = true
  104. try {
  105. if (props.customerId && !props.contractId) {
  106. queryParams.customerId = props.customerId
  107. } else if (props.customerId && props.contractId) {
  108. // 如果是合同的话客户编号也需要带上因为权限基于客户
  109. queryParams.customerId = props.customerId
  110. queryParams.contractId = props.contractId
  111. }
  112. const data = await ReceivablePlanApi.getReceivablePlanPageByCustomer(queryParams)
  113. list.value = data.list
  114. total.value = data.total
  115. } finally {
  116. loading.value = false
  117. }
  118. }
  119. /** 搜索按钮操作 */
  120. const handleQuery = () => {
  121. queryParams.pageNo = 1
  122. // 置空参数
  123. queryParams.customerId = undefined
  124. queryParams.contractId = undefined
  125. getList()
  126. }
  127. /** 添加/修改操作 */
  128. const formRef = ref()
  129. const openForm = (type: string, id?: number) => {
  130. formRef.value.open(type, id, props.customerId, props.contractId)
  131. }
  132. /** 创建回款 */
  133. const emits = defineEmits<{
  134. (e: 'createReceivable', v: ReceivablePlanApi.ReceivablePlanVO)
  135. }>()
  136. const createReceivable = (row: ReceivablePlanApi.ReceivablePlanVO) => {
  137. emits('createReceivable', row)
  138. }
  139. /** 删除按钮操作 */
  140. const handleDelete = async (id: number) => {
  141. try {
  142. // 删除的二次确认
  143. await message.delConfirm()
  144. // 发起删除
  145. await ReceivablePlanApi.deleteReceivablePlan(id)
  146. message.success(t('common.delSuccess'))
  147. // 刷新列表
  148. await getList()
  149. } catch {}
  150. }
  151. /** 监听打开的 customerId + contractId,从而加载最新的列表 */
  152. watch(
  153. () => [props.customerId, props.contractId],
  154. (newVal) => {
  155. // 保证至少客户编号有值
  156. if (!newVal[0]) {
  157. return
  158. }
  159. handleQuery()
  160. },
  161. { immediate: true, deep: true }
  162. )
  163. </script>