index.vue 6.6 KB

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