index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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" fixed="left" label="客户名称" prop="customerName" width="150">
  70. <template #default="scope">
  71. <el-link
  72. :underline="false"
  73. type="primary"
  74. @click="openCustomerDetail(scope.row.customerId)"
  75. >
  76. {{ scope.row.customerName }}
  77. </el-link>
  78. </template>
  79. </el-table-column>
  80. <el-table-column align="center" label="合同编号" prop="contractNo" width="200px" />
  81. <el-table-column align="center" label="期数" prop="period">
  82. <template #default="scope">
  83. <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
  84. {{ scope.row.period }}
  85. </el-link>
  86. </template>
  87. </el-table-column>
  88. <el-table-column
  89. align="center"
  90. label="计划回款金额(元)"
  91. prop="price"
  92. width="160"
  93. :formatter="erpPriceTableColumnFormatter"
  94. />
  95. <el-table-column
  96. :formatter="dateFormatter2"
  97. align="center"
  98. label="计划回款日期"
  99. prop="returnTime"
  100. width="180px"
  101. />
  102. <el-table-column align="center" label="提前几天提醒" prop="remindDays" width="150" />
  103. <el-table-column
  104. align="center"
  105. label="提醒日期"
  106. prop="remindTime"
  107. width="180px"
  108. :formatter="dateFormatter2"
  109. />
  110. <el-table-column align="center" label="回款方式" prop="returnType" width="130px">
  111. <template #default="scope">
  112. <dict-tag :type="DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE" :value="scope.row.returnType" />
  113. </template>
  114. </el-table-column>
  115. <el-table-column align="center" label="备注" prop="remark" />
  116. <el-table-column label="负责人" prop="ownerUserName" width="120" />
  117. <el-table-column
  118. align="center"
  119. label="实际回款金额(元)"
  120. prop="receivable.price"
  121. width="160"
  122. >
  123. <template #default="scope">
  124. <el-text v-if="scope.row.receivable">
  125. {{ erpPriceInputFormatter(scope.row.receivable.price) }}
  126. </el-text>
  127. <el-text v-else>{{ erpPriceInputFormatter(0) }}</el-text>
  128. </template>
  129. </el-table-column>
  130. <el-table-column
  131. align="center"
  132. label="实际回款日期"
  133. prop="receivable.returnTime"
  134. width="180px"
  135. :formatter="dateFormatter2"
  136. />
  137. <el-table-column
  138. align="center"
  139. label="实际回款金额(元)"
  140. prop="receivable.price"
  141. width="160"
  142. >
  143. <template #default="scope">
  144. <el-text v-if="scope.row.receivable">
  145. {{ erpPriceInputFormatter(scope.row.price - scope.row.receivable.price) }}
  146. </el-text>
  147. <el-text v-else>{{ erpPriceInputFormatter(scope.row.price) }}</el-text>
  148. </template>
  149. </el-table-column>
  150. <el-table-column
  151. align="center"
  152. fixed="right"
  153. label="完成状态"
  154. prop="finishStatus"
  155. width="130px"
  156. >
  157. <template #default="scope">
  158. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.finishStatus" />
  159. </template>
  160. </el-table-column>
  161. <el-table-column
  162. :formatter="dateFormatter"
  163. align="center"
  164. label="更新时间"
  165. prop="updateTime"
  166. width="180px"
  167. />
  168. <el-table-column
  169. :formatter="dateFormatter"
  170. align="center"
  171. label="创建时间"
  172. prop="createTime"
  173. width="180px"
  174. />
  175. <el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
  176. <el-table-column align="center" fixed="right" label="操作" width="130px">
  177. <!-- TODO @puhui999:新建回款 -->
  178. <template #default="scope">
  179. <el-button
  180. v-hasPermi="['crm:receivable-plan:update']"
  181. link
  182. type="primary"
  183. @click="openForm('update', scope.row.id)"
  184. >
  185. 编辑
  186. </el-button>
  187. <el-button
  188. v-hasPermi="['crm:receivable-plan:delete']"
  189. link
  190. type="danger"
  191. @click="handleDelete(scope.row.id)"
  192. >
  193. 删除
  194. </el-button>
  195. </template>
  196. </el-table-column>
  197. </el-table>
  198. <!-- 分页 -->
  199. <Pagination
  200. v-model:limit="queryParams.pageSize"
  201. v-model:page="queryParams.pageNo"
  202. :total="total"
  203. @pagination="getList"
  204. />
  205. </ContentWrap>
  206. <!-- 表单弹窗:添加/修改 -->
  207. <ReceivablePlanForm ref="formRef" @success="getList" />
  208. </template>
  209. <script lang="ts" setup>
  210. import { DICT_TYPE } from '@/utils/dict'
  211. import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
  212. import download from '@/utils/download'
  213. import * as ReceivablePlanApi from '@/api/crm/receivable/plan'
  214. import ReceivablePlanForm from './ReceivablePlanForm.vue'
  215. import * as CustomerApi from '@/api/crm/customer'
  216. import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils'
  217. defineOptions({ name: 'ReceivablePlan' })
  218. const message = useMessage() // 消息弹窗
  219. const { t } = useI18n() // 国际化
  220. const loading = ref(true) // 列表的加载中
  221. const total = ref(0) // 列表的总页数
  222. const list = ref([]) // 列表的数据
  223. const queryParams = reactive({
  224. pageNo: 1,
  225. pageSize: 10,
  226. customerId: undefined,
  227. contractNo: undefined
  228. })
  229. const queryFormRef = ref() // 搜索的表单
  230. const exportLoading = ref(false) // 导出的加载中
  231. const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
  232. /** 查询列表 */
  233. const getList = async () => {
  234. loading.value = true
  235. try {
  236. const data = await ReceivablePlanApi.getReceivablePlanPage(queryParams)
  237. list.value = data.list
  238. total.value = data.total
  239. } finally {
  240. loading.value = false
  241. }
  242. }
  243. /** 搜索按钮操作 */
  244. const handleQuery = () => {
  245. queryParams.pageNo = 1
  246. getList()
  247. }
  248. /** 重置按钮操作 */
  249. const resetQuery = () => {
  250. queryFormRef.value.resetFields()
  251. handleQuery()
  252. }
  253. /** 添加/修改操作 */
  254. const formRef = ref()
  255. const openForm = (type: string, id?: number) => {
  256. formRef.value.open(type, id)
  257. }
  258. /** 删除按钮操作 */
  259. const handleDelete = async (id: number) => {
  260. try {
  261. // 删除的二次确认
  262. await message.delConfirm()
  263. // 发起删除
  264. await ReceivablePlanApi.deleteReceivablePlan(id)
  265. message.success(t('common.delSuccess'))
  266. // 刷新列表
  267. await getList()
  268. } catch {}
  269. }
  270. /** 导出按钮操作 */
  271. const handleExport = async () => {
  272. try {
  273. // 导出的二次确认
  274. await message.exportConfirm()
  275. // 发起导出
  276. exportLoading.value = true
  277. const data = await ReceivablePlanApi.exportReceivablePlan(queryParams)
  278. download.excel(data, '回款计划.xls')
  279. } catch {
  280. } finally {
  281. exportLoading.value = false
  282. }
  283. }
  284. /** 打开详情 */
  285. const { push } = useRouter()
  286. const openDetail = (id: number) => {
  287. push({ name: 'CrmReceivablePlanDetail', params: { id } })
  288. }
  289. /** 打开客户详情 */
  290. const openCustomerDetail = (id: number) => {
  291. push({ name: 'CrmCustomerDetail', params: { id } })
  292. }
  293. /** 初始化 **/
  294. onMounted(async () => {
  295. await getList()
  296. // 获得客户列表
  297. customerList.value = await CustomerApi.getCustomerSimpleList()
  298. })
  299. </script>