ReceivablePlanList.vue 5.2 KB

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