index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="客户" prop="customerId">
  12. <el-input
  13. v-model="queryParams.customerId"
  14. placeholder="请输入客户"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="合同" prop="contractId">
  21. <el-input
  22. v-model="queryParams.contractId"
  23. placeholder="请输入合同"
  24. clearable
  25. @keyup.enter="handleQuery"
  26. class="!w-240px"
  27. />
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  31. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  32. <el-button
  33. type="primary"
  34. plain
  35. @click="openForm('create')"
  36. v-hasPermi="['crm:receivable-plan:create']"
  37. >
  38. <Icon icon="ep:plus" class="mr-5px" /> 新增
  39. </el-button>
  40. <el-button
  41. type="success"
  42. plain
  43. @click="handleExport"
  44. :loading="exportLoading"
  45. v-hasPermi="['crm:receivable-plan:export']"
  46. >
  47. <Icon icon="ep:download" class="mr-5px" /> 导出
  48. </el-button>
  49. </el-form-item>
  50. </el-form>
  51. </ContentWrap>
  52. <!-- 列表 -->
  53. <ContentWrap>
  54. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  55. <!--<el-table-column label="ID" align="center" prop="id" />-->
  56. <el-table-column label="客户名称" align="center" prop="customerId" width="150px" />
  57. <el-table-column label="合同名称" align="center" prop="contractId" width="150px" />
  58. <el-table-column label="期数" align="center" prop="period" />
  59. <el-table-column label="计划回款" align="center" prop="price" />
  60. <el-table-column
  61. label="计划回款日期"
  62. align="center"
  63. prop="returnTime"
  64. :formatter="dateFormatter2"
  65. width="180px"
  66. />
  67. <el-table-column label="提前几天提醒" align="center" prop="remindDays" />
  68. <!--<el-table-column
  69. label="提醒日期"
  70. align="center"
  71. prop="remindTime"
  72. :formatter="dateFormatter"
  73. width="180px"
  74. />-->
  75. <!--<el-table-column label="回款ID" align="center" prop="receivableId" />-->
  76. <el-table-column label="完成状态" align="center" prop="status">
  77. <template #default="scope">
  78. <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="审批状态" align="center" prop="checkStatus" width="130px">
  82. <template #default="scope">
  83. <dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.checkStatus" />
  84. </template>
  85. </el-table-column>
  86. <!--<el-table-column label="工作流编号" align="center" prop="processInstanceId" />-->
  87. <el-table-column prop="ownerUserId" label="负责人" width="120">
  88. <template #default="scope">
  89. {{ userList.find((user) => user.id === scope.row.ownerUserId)?.nickname }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="显示顺序" align="center" prop="sort" />
  93. <el-table-column label="备注" align="center" prop="remark" />
  94. <el-table-column
  95. label="创建时间"
  96. align="center"
  97. prop="createTime"
  98. :formatter="dateFormatter"
  99. width="180px"
  100. />
  101. <el-table-column label="操作" align="center" width="130px">
  102. <template #default="scope">
  103. <el-button
  104. link
  105. type="primary"
  106. @click="openForm('update', scope.row.id)"
  107. v-hasPermi="['crm:receivable-plan:update']"
  108. >
  109. 编辑
  110. </el-button>
  111. <el-button
  112. link
  113. type="danger"
  114. @click="handleDelete(scope.row.id)"
  115. v-hasPermi="['crm:receivable-plan:delete']"
  116. >
  117. 删除
  118. </el-button>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <!-- 分页 -->
  123. <Pagination
  124. :total="total"
  125. v-model:page="queryParams.pageNo"
  126. v-model:limit="queryParams.pageSize"
  127. @pagination="getList"
  128. />
  129. </ContentWrap>
  130. <!-- 表单弹窗:添加/修改 -->
  131. <ReceivablePlanForm ref="formRef" @success="getList" />
  132. </template>
  133. <script setup lang="ts">
  134. import { DICT_TYPE } from '@/utils/dict'
  135. import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
  136. import download from '@/utils/download'
  137. import * as ReceivablePlanApi from '@/api/crm/receivable/plan'
  138. import ReceivablePlanForm from './ReceivablePlanForm.vue'
  139. import * as UserApi from '@/api/system/user'
  140. defineOptions({ name: 'ReceivablePlan' })
  141. const message = useMessage() // 消息弹窗
  142. const { t } = useI18n() // 国际化
  143. const loading = ref(true) // 列表的加载中
  144. const total = ref(0) // 列表的总页数
  145. const list = ref([]) // 列表的数据
  146. const userList = ref<UserApi.UserVO[]>([]) // 用户列表
  147. const queryParams = reactive({
  148. pageNo: 1,
  149. pageSize: 10,
  150. customerId: null,
  151. contractId: null
  152. })
  153. const queryFormRef = ref() // 搜索的表单
  154. const exportLoading = ref(false) // 导出的加载中
  155. /** 查询列表 */
  156. const getList = async () => {
  157. loading.value = true
  158. try {
  159. const data = await ReceivablePlanApi.getReceivablePlanPage(queryParams)
  160. list.value = data.list
  161. total.value = data.total
  162. } finally {
  163. loading.value = false
  164. }
  165. }
  166. /** 搜索按钮操作 */
  167. const handleQuery = () => {
  168. queryParams.pageNo = 1
  169. getList()
  170. }
  171. /** 重置按钮操作 */
  172. const resetQuery = () => {
  173. queryFormRef.value.resetFields()
  174. handleQuery()
  175. }
  176. /** 添加/修改操作 */
  177. const formRef = ref()
  178. const openForm = (type: string, id?: number) => {
  179. formRef.value.open(type, id)
  180. }
  181. /** 删除按钮操作 */
  182. const handleDelete = async (id: number) => {
  183. try {
  184. // 删除的二次确认
  185. await message.delConfirm()
  186. // 发起删除
  187. await ReceivablePlanApi.deleteReceivablePlan(id)
  188. message.success(t('common.delSuccess'))
  189. // 刷新列表
  190. await getList()
  191. } catch {}
  192. }
  193. /** 导出按钮操作 */
  194. const handleExport = async () => {
  195. try {
  196. // 导出的二次确认
  197. await message.exportConfirm()
  198. // 发起导出
  199. exportLoading.value = true
  200. const data = await ReceivablePlanApi.exportReceivablePlan(queryParams)
  201. download.excel(data, '回款计划.xls')
  202. } catch {
  203. } finally {
  204. exportLoading.value = false
  205. }
  206. }
  207. /** 初始化 **/
  208. onMounted(async () => {
  209. await getList()
  210. // 获取用户列表
  211. userList.value = await UserApi.getSimpleUserList()
  212. })
  213. </script>