index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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" width="120" />
  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="ownerUserName" width="120" />
  89. <el-table-column align="center" label="备注" prop="remark" />
  90. <el-table-column
  91. align="center"
  92. fixed="right"
  93. label="完成状态"
  94. prop="finishStatus"
  95. width="130px"
  96. >
  97. <template #default="scope">
  98. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.finishStatus" />
  99. </template>
  100. </el-table-column>
  101. <el-table-column align="center" fixed="right" label="操作" width="130px">
  102. <template #default="scope">
  103. <el-button
  104. v-hasPermi="['crm:receivable-plan:update']"
  105. link
  106. type="primary"
  107. @click="openForm('update', scope.row.id)"
  108. >
  109. 编辑
  110. </el-button>
  111. <el-button
  112. v-hasPermi="['crm:receivable-plan:delete']"
  113. link
  114. type="danger"
  115. @click="handleDelete(scope.row.id)"
  116. >
  117. 删除
  118. </el-button>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <!-- 分页 -->
  123. <Pagination
  124. v-model:limit="queryParams.pageSize"
  125. v-model:page="queryParams.pageNo"
  126. :total="total"
  127. @pagination="getList"
  128. />
  129. </ContentWrap>
  130. <!-- 表单弹窗:添加/修改 -->
  131. <ReceivablePlanForm ref="formRef" @success="getList" />
  132. </template>
  133. <script lang="ts" setup>
  134. import { DICT_TYPE } from '@/utils/dict'
  135. import { 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. import * as CustomerApi from '@/api/crm/customer'
  141. defineOptions({ name: 'ReceivablePlan' })
  142. const message = useMessage() // 消息弹窗
  143. const { t } = useI18n() // 国际化
  144. const loading = ref(true) // 列表的加载中
  145. const total = ref(0) // 列表的总页数
  146. const list = ref([]) // 列表的数据
  147. const userList = ref<UserApi.UserVO[]>([]) // 用户列表
  148. const queryParams = reactive({
  149. pageNo: 1,
  150. pageSize: 10,
  151. customerId: undefined,
  152. contractNo: undefined
  153. })
  154. const queryFormRef = ref() // 搜索的表单
  155. const exportLoading = ref(false) // 导出的加载中
  156. /** 查询列表 */
  157. const getList = async () => {
  158. loading.value = true
  159. try {
  160. const data = await ReceivablePlanApi.getReceivablePlanPage(queryParams)
  161. list.value = data.list
  162. total.value = data.total
  163. } finally {
  164. loading.value = false
  165. }
  166. }
  167. /** 搜索按钮操作 */
  168. const handleQuery = () => {
  169. queryParams.pageNo = 1
  170. getList()
  171. }
  172. /** 重置按钮操作 */
  173. const resetQuery = () => {
  174. queryFormRef.value.resetFields()
  175. handleQuery()
  176. }
  177. /** 添加/修改操作 */
  178. const formRef = ref()
  179. const openForm = (type: string, id?: number) => {
  180. formRef.value.open(type, id)
  181. }
  182. /** 删除按钮操作 */
  183. const handleDelete = async (id: number) => {
  184. try {
  185. // 删除的二次确认
  186. await message.delConfirm()
  187. // 发起删除
  188. await ReceivablePlanApi.deleteReceivablePlan(id)
  189. message.success(t('common.delSuccess'))
  190. // 刷新列表
  191. await getList()
  192. } catch {}
  193. }
  194. /** 导出按钮操作 */
  195. const handleExport = async () => {
  196. try {
  197. // 导出的二次确认
  198. await message.exportConfirm()
  199. // 发起导出
  200. exportLoading.value = true
  201. const data = await ReceivablePlanApi.exportReceivablePlan(queryParams)
  202. download.excel(data, '回款计划.xls')
  203. } catch {
  204. } finally {
  205. exportLoading.value = false
  206. }
  207. }
  208. const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
  209. /** 初始化 **/
  210. onMounted(async () => {
  211. await getList()
  212. // 获取用户列表
  213. userList.value = await UserApi.getSimpleUserList()
  214. // 获得客户列表
  215. customerList.value = await CustomerApi.getCustomerSimpleList()
  216. })
  217. </script>