index.vue 9.7 KB

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