DetailsCollection.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <!--
  2. * @Author: liuzl 461480418@qq.com
  3. * @Date: 2023-01-09 13:54:40
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-01-10 14:39:40
  6. * @Description: file content
  7. * @FilePath: \订单全流程管理系统\src\views\contract\components\DetailsCollection.vue
  8. -->
  9. <template>
  10. <div class="collection-container">
  11. <!-- 回款计划 -->
  12. <div class="collection-plan mb10">
  13. <el-row class="mb10">
  14. <el-col class="text-right" :span="24">
  15. <el-button
  16. v-permissions="['contract:detail:collectionPlan:add']"
  17. icon="el-icon-plus"
  18. size="mini"
  19. type="primary"
  20. @click="$refs.collectionPlan.init()">
  21. 新建回款计划
  22. </el-button>
  23. </el-col>
  24. </el-row>
  25. <el-table border :data="collectionPlanData" height="calc(100% - 50px)">
  26. <el-table-column
  27. v-for="(item, index) in planColumns"
  28. :key="index"
  29. align="center"
  30. :label="item.label"
  31. :min-width="item.width"
  32. :prop="item.prop"
  33. show-overflow-tooltip>
  34. <template #default="{ row }">
  35. <span v-if="item.prop == 'contractStatus'">
  36. {{ row.contractStatus == '10' ? '待回款' : row.contractStatus == '20' ? '部分回款' : '全部回款' }}
  37. </span>
  38. <span v-else-if="item.prop == 'planDatetime'">
  39. {{ parseTime(row.planDatetime, '{y}-{m}-{d}') }}
  40. </span>
  41. <span v-else-if="item.prop == 'planScale'">
  42. {{ row.planScale + '%' }}
  43. </span>
  44. <span v-else-if="item.prop == 'planAmount'">{{ formatPrice(row.planAmount) }}</span>
  45. <span v-else>{{ row[item.prop] }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column align="center" fixed="right" label="操作" width="120px">
  49. <template slot-scope="scope">
  50. <el-button
  51. v-permissions="['contract:detail:collection:add']"
  52. :disabled="scope.row.contractStatus == '30'"
  53. type="text"
  54. @click="$refs.collection.init(scope.row.id)">
  55. 回款
  56. </el-button>
  57. <el-button
  58. v-permissions="['contract:detail:collectionPlan:edit']"
  59. type="text"
  60. @click="$refs.collectionPlan.init(scope.row.id)">
  61. 编辑
  62. </el-button>
  63. <el-button
  64. v-permissions="['contract:detail:collectionPlan:delete']"
  65. type="text"
  66. @click="handleDel(scope.row, 'plan')">
  67. 删除
  68. </el-button>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. </div>
  73. <!-- 回款 -->
  74. <div class="collection">
  75. <el-row class="mb10">
  76. <el-col class="text-right" :span="24">
  77. <el-button
  78. v-permissions="['contract:detail:collection:add']"
  79. icon="el-icon-plus"
  80. size="mini"
  81. type="primary"
  82. @click="$refs.collection.init()">
  83. 新建回款
  84. </el-button>
  85. </el-col>
  86. </el-row>
  87. <el-table border :data="collectionData" height="calc(100% - 50px)">
  88. <el-table-column
  89. v-for="(item, index) in collectionColumns"
  90. :key="index"
  91. align="center"
  92. :label="item.label"
  93. :min-width="item.width"
  94. :prop="item.prop"
  95. show-overflow-tooltip>
  96. <template #default="{ row }">
  97. <span v-if="item.prop == 'collectionType'">
  98. {{ selectDictLabel(collectionTypeOption, row.collectionType) }}
  99. </span>
  100. <span v-else-if="item.prop == 'approStatus'">
  101. {{ row.approStatus == '10' ? '未回款' : '已回款' }}
  102. </span>
  103. <span v-else-if="item.prop == 'collectionDatetime'">
  104. {{ parseTime(row.collectionDatetime, '{y}-{m}-{d}') }}
  105. </span>
  106. <span v-else-if="item.prop == 'collectionAmount'">{{ formatPrice(row.collectionAmount) }}</span>
  107. <span v-else>{{ row[item.prop] }}</span>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. </div>
  112. <!-- 新增编辑回款计划 -->
  113. <edit-plan ref="collectionPlan" :details="details" @collectionPlanSave="getCollectionPlaneList()" />
  114. <!-- 新增编辑回款合同 -->
  115. <edit-collection
  116. ref="collection"
  117. :collection-type-data="collectionTypeOption"
  118. :details="details"
  119. @collectionSave="collectionSave()" />
  120. </div>
  121. </template>
  122. <script>
  123. import collectionApi from '@/api/contract/collection'
  124. import collectionPlanApi from '@/api/contract/collectionPlan'
  125. import EditPlan from '@/views/contract/components/EditPlan'
  126. import EditCollection from './EditCollection'
  127. import to from 'await-to-js'
  128. export default {
  129. name: 'DetailsCollection',
  130. components: {
  131. EditPlan,
  132. EditCollection,
  133. },
  134. props: {
  135. details: {
  136. type: Object,
  137. default: () => {},
  138. },
  139. },
  140. data() {
  141. return {
  142. collectionData: [], //回款数据
  143. collectionPlanData: [], //回款计划数据
  144. planColumns: [
  145. {
  146. label: '客户名称',
  147. width: '280px',
  148. prop: 'custName',
  149. },
  150. {
  151. label: '合同编号',
  152. width: '160px',
  153. prop: 'contractCode',
  154. },
  155. {
  156. label: '计划回款金额',
  157. width: '120px',
  158. prop: 'planAmount',
  159. },
  160. {
  161. label: '回款状态',
  162. width: '100px',
  163. prop: 'contractStatus',
  164. },
  165. {
  166. label: '计划回款日期',
  167. width: '120px',
  168. prop: 'planDatetime',
  169. },
  170. {
  171. label: '计划回款比例',
  172. width: '100px',
  173. prop: 'planScale',
  174. },
  175. {
  176. label: '回款条件',
  177. width: '120px',
  178. prop: 'planCondition',
  179. },
  180. {
  181. label: '备注',
  182. width: 'auto',
  183. prop: 'remark',
  184. },
  185. ],
  186. collectionColumns: [
  187. {
  188. label: '客户名称',
  189. width: '280px',
  190. prop: 'custName',
  191. },
  192. {
  193. label: '合同编号',
  194. width: '160px',
  195. prop: 'contractCode',
  196. },
  197. {
  198. label: '回款金额',
  199. width: '120px',
  200. prop: 'collectionAmount',
  201. },
  202. {
  203. label: '回款方式',
  204. width: '100px',
  205. prop: 'collectionType',
  206. },
  207. {
  208. label: '审核状态',
  209. width: '100px',
  210. prop: 'approStatus',
  211. },
  212. {
  213. label: '回款日期',
  214. width: '120px',
  215. prop: 'collectionDatetime',
  216. },
  217. {
  218. label: '备注',
  219. width: 'auto',
  220. prop: 'remark',
  221. },
  222. ],
  223. collectionTypeOption: [], //,回款方式
  224. }
  225. },
  226. async mounted() {
  227. await this.getOptions()
  228. this.getCollectionList()
  229. this.getCollectionPlaneList()
  230. },
  231. methods: {
  232. async getOptions() {
  233. await Promise.all([this.getDicts('collection_type')])
  234. .then(([collectionType]) => {
  235. this.collectionTypeOption = collectionType.data.values || []
  236. })
  237. .catch((err) => console.log(err))
  238. },
  239. // 获取回款和回款计划列表
  240. async getCollectionList() {
  241. let params = { contractId: this.details.id, pageNum: 0 }
  242. const [err, res] = await to(collectionApi.getList(params))
  243. if (err) return
  244. this.collectionData = res.data.list
  245. },
  246. async getCollectionPlaneList() {
  247. let params = { contractId: this.details.id, pageNum: 0 }
  248. const [err, res] = await to(collectionPlanApi.getList(params))
  249. if (err) return
  250. this.collectionPlanData = res.data.list
  251. },
  252. collectionSave() {
  253. this.getCollectionList()
  254. this.getCollectionPlaneList()
  255. },
  256. // 删除回款计划
  257. handleDel(row, type) {
  258. this.$confirm('确认删除?', '提示', {
  259. confirmButtonText: '确定',
  260. cancelButtonText: '取消',
  261. type: 'warning',
  262. })
  263. .then(async () => {
  264. // 回款计划
  265. if (type == 'plan') {
  266. const [err, res] = await to(collectionPlanApi.delCollectionPlan({ id: [row.id] }))
  267. if (err) return
  268. if (res.code == 200) {
  269. this.$message({
  270. type: 'success',
  271. message: '删除成功!',
  272. })
  273. this.getCollectionPlaneList()
  274. }
  275. } else {
  276. // 回款
  277. const [err, res] = await to(collectionPlanApi.delCollectionPlan({ id: [row.id] }))
  278. if (err) return
  279. if (res.code == 200) {
  280. this.$message({
  281. type: 'success',
  282. message: '删除成功!',
  283. })
  284. this.queryData()
  285. }
  286. }
  287. })
  288. .catch(() => {})
  289. },
  290. },
  291. }
  292. </script>
  293. <style lang="scss" scoped>
  294. .collection-container {
  295. .mb10 {
  296. margin-bottom: 10px;
  297. }
  298. height: 100%;
  299. .collection-plan,
  300. .collection {
  301. height: 50%;
  302. .el-row {
  303. height: 30px;
  304. }
  305. }
  306. .text-right {
  307. text-align: right;
  308. }
  309. }
  310. </style>