pay.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <div class="relative h-full flex">
  3. <div :id="`hc_table_card_${uuid}`">
  4. <hc-new-card>
  5. <template #header>
  6. <el-button hc-btn type="primary" @click="systemPaymentClick">引用项目支付项</el-button>
  7. </template>
  8. <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" is-new :index-style="{ width: 60 }" is-current-row @row-click="viewRowClick">
  9. <template #isDeduct="{ row }">
  10. <span>{{ row?.isDeduct === 1 ? '是' : '否' }}</span>
  11. </template>
  12. <template #isTotalTerms="{ row }">
  13. <span>{{ row?.isTotalTerms === 1 ? '是' : '否' }}</span>
  14. </template>
  15. <template #action="{ row }">
  16. <el-link type="success" @click="editRowClick(row)">修改</el-link>
  17. <el-link type="danger" @click="delRowClick(row)">删除</el-link>
  18. </template>
  19. </hc-table>
  20. <template #action>
  21. <hc-pages :pages="searchForm" @change="pageChange" />
  22. </template>
  23. </hc-new-card>
  24. </div>
  25. <div :id="`hc_info_card_${uuid}`" class="flex-1">
  26. <hc-new-card scrollbar>
  27. <infoTable :ids="rowViewId" />
  28. <hc-title title="汇总项">
  29. <template #extra>
  30. <el-link type="primary" @click="addColloect">添加汇总项</el-link>
  31. </template>
  32. </hc-title>
  33. <hc-table :column="tableColumn1" :datas="tableData1" is-new :index-style="{ width: 60 }">
  34. <template #isDeduct="{ row }">
  35. <span>{{ row?.isDeduct === 1 ? '是' : '否' }}</span>
  36. </template>
  37. <template #action="{ row }">
  38. <el-link type="danger" @click="delCollectRow(row)">删除</el-link>
  39. </template>
  40. </hc-table>
  41. </hc-new-card>
  42. </div>
  43. <!-- 引用系统支付项 -->
  44. <systemPay v-model="systemPayShow" @finish="finishSystemPay" />
  45. <!-- 修改项目支付项 -->
  46. <rowDataInfo v-model="isEditRowShow" :ids="rowDataId" @finish="finishEditRow" />
  47. <!-- 添加汇总项 -->
  48. <hc-new-dialog v-model="isCollectShow" is-table widths="1200px" title="添加汇总项" @save="collectModalSave">
  49. <div class="hc-flex-column">
  50. <div class="hc-flex-shrink hc-alert-primary">
  51. <span class="mr-1">当前表格已选择</span>
  52. <span class="text-4">0</span>
  53. <span class="ml-1">项</span>
  54. </div>
  55. <div class="hc-flex-content">
  56. <hc-body padding="0px">
  57. <hc-table
  58. :column="tableCollectColumn" :datas="tableCollectData" :loading="tableCollectLoading"
  59. is-new :check-style="{ width: 29 }" :index-style="{ width: 60 }"
  60. is-check @selection-change="tableCollectCheckChange"
  61. >
  62. <template #isDeduct="{ row }">
  63. <span>{{ row?.isDeduct === 1 ? '是' : '否' }}</span>
  64. </template>
  65. <template #isTotalTerms="{ row }">
  66. <span>{{ row?.isTotalTerms === 1 ? '是' : '否' }}</span>
  67. </template>
  68. </hc-table>
  69. </hc-body>
  70. </div>
  71. </div>
  72. </hc-new-dialog>
  73. </div>
  74. </template>
  75. <script setup>
  76. import { nextTick, onMounted, ref } from 'vue'
  77. import { getRandom } from 'js-fast-way'
  78. import infoTable from './components/pay/info-table.vue'
  79. import systemPay from './components/pay/system-pay.vue'
  80. import rowDataInfo from './components/pay/row-data.vue'
  81. import payApi from '~api/project/debit/contract/pay.js'
  82. import { arrToId, getArrValue, getObjValue } from 'js-fast-way'
  83. import { useAppStore } from '~src/store'
  84. import { delMessageV2 } from '~com/message/index.js'
  85. const useAppState = useAppStore()
  86. const projectId = ref(useAppState.getProjectId)
  87. const contractId = ref(useAppState.getContractId)
  88. defineOptions({
  89. name: 'ProjectDebitProjectPay',
  90. })
  91. const uuid = getRandom(4)
  92. //渲染完成
  93. onMounted(() => {
  94. setSplitRef()
  95. getTableData()
  96. })
  97. //初始化设置拖动分割线
  98. const setSplitRef = () => {
  99. //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
  100. nextTick(() => {
  101. window.$split(['#hc_table_card_' + uuid, '#hc_info_card_' + uuid], {
  102. sizes: [70, 30],
  103. snapOffset: 0,
  104. minSize: [50, 300],
  105. })
  106. })
  107. }
  108. //搜索表单
  109. const searchForm = ref({ current: 1, size: 10, total: 0 })
  110. //分页
  111. const pageChange = ({ current, size }) => {
  112. searchForm.value.current = current
  113. searchForm.value.size = size
  114. }
  115. //表格数据
  116. const tableLoading = ref(false)
  117. const tableColumn = ref([
  118. { key: 'payNumber', name: '支付项编号', width: 140 },
  119. { key: 'payName', name: '支付项名称' },
  120. { key: 'payTypeName', name: '支付项类型', width: 160 },
  121. { key: 'isDeduct', name: '是否为扣款项', width: 100 },
  122. { key: 'isTotalTerms', name: '是否合计项', width: 100 },
  123. { key: 'payApplicableTypeName', name: '适用类型', width: 100 },
  124. { key: 'action', name: '操作', width: 100 },
  125. ])
  126. const tableData = ref([])
  127. const getTableData = async () => {
  128. tableLoading.value = true
  129. const { error, code, data } = await payApi.getProListPage({
  130. ...searchForm.value,
  131. contractId:contractId.value,
  132. })
  133. tableLoading.value = false
  134. if (!error && code === 200) {
  135. tableData.value = getArrValue(data['records'])
  136. if (tableData.value.length > 0) {
  137. getDetail(tableData.value[0].id)
  138. rowViewId.value = tableData.value[0].id
  139. }
  140. } else {
  141. tableData.value = []
  142. }
  143. }
  144. //引用系统支付项
  145. const systemPayShow = ref(false)
  146. const systemPaymentClick = () => {
  147. systemPayShow.value = true
  148. }
  149. const finishSystemPay = ()=>{
  150. getTableData()
  151. systemPayShow.value = false
  152. }
  153. //汇总项
  154. const tableColumn1 = ref([
  155. { key: 'payNumber', name: '支付项编号' },
  156. { key: 'payName', name: '支付项名称' },
  157. { key: 'payTypeName', name: '支付项类型' },
  158. { key: 'contractFormulaIds', name: '合同计算公式' },
  159. { key: 'updateFormulaIds', name: '变更计算公式' },
  160. { key: 'currentFormulaIds', name: '本期计算公式' },
  161. { key: 'isDeduct', name: '是否为扣款项' },
  162. { key: 'action', name: '操作', width: 50 },
  163. ])
  164. const tableData1 = ref([])
  165. //修改
  166. const rowDataId = ref('')
  167. const rowViewId = ref('')
  168. const isEditRowShow = ref(false)
  169. const editRowClick = (row) => {
  170. isEditRowShow.value = true
  171. rowDataId.value = row.id
  172. }
  173. //获取节点详情
  174. const getDetail = async (id)=>{
  175. const { error, code, data } = await payApi.getProDetail({
  176. id,
  177. })
  178. if (!error && code === 200) {
  179. tableData1.value = getObjValue(data)['summaryItemList']
  180. } else {
  181. tableData1.value = []
  182. }
  183. }
  184. const viewRowClick = ({ row })=>{
  185. rowViewId.value = row.id
  186. getDetail(row.id)
  187. }
  188. const finishEditRow = ()=>{
  189. isEditRowShow.value = false
  190. getTableData()
  191. }
  192. const delRowClick = async (row)=>{
  193. delMessageV2(async (action, instance, done) => {
  194. if (action === 'confirm') {
  195. instance.confirmButtonLoading = true
  196. removeProPay(row.id)
  197. instance.confirmButtonLoading = false
  198. done()
  199. } else {
  200. done()
  201. }
  202. })
  203. }
  204. const removeProPay = async (id) => {
  205. const { error, code } = await payApi.removeProList({
  206. id: id,
  207. })
  208. if (!error && code === 200) {
  209. window?.$message?.success('删除成功')
  210. getTableData()
  211. rowViewId.value = ''
  212. }
  213. }
  214. //添加汇总项
  215. const isCollectShow = ref(false)
  216. const collectSaveLoading = ref(false)
  217. const collectModalSave = async () => {
  218. collectSaveLoading.value = true
  219. const { error, code, msg } = await payApi.addCollect({
  220. bindIds :selectTableCollectIds.value,
  221. id:rowViewId.value,
  222. })
  223. //判断状态
  224. collectSaveLoading.value = false
  225. if (!error && code === 200) {
  226. window?.$message?.success(msg)
  227. }
  228. getDetail(rowViewId.value)
  229. isCollectShow.value = false
  230. }
  231. const addColloect = ()=>{
  232. isCollectShow.value = true
  233. getTableCollectData()
  234. }
  235. //删除汇总项
  236. const delCollectRow = (row)=>{
  237. delMessageV2(async (action, instance, done) => {
  238. if (action === 'confirm') {
  239. instance.confirmButtonLoading = true
  240. removeCollectPay(row.id)
  241. instance.confirmButtonLoading = false
  242. done()
  243. } else {
  244. done()
  245. }
  246. })
  247. }
  248. const removeCollectPay = async (id) => {
  249. const { error, code } = await payApi.removeCollect({
  250. id: rowViewId.value,
  251. bindId:id,
  252. })
  253. if (!error && code === 200) {
  254. window?.$message?.success('删除成功')
  255. getDetail(rowViewId.value)
  256. }
  257. }
  258. //添加汇总项
  259. const tableCollectColumn = ref([
  260. { key: 'payNumber', name: '支付项编号' },
  261. { key: 'payName', name: '支付项名称' },
  262. { key: 'payTypeName', name: '支付项类型' },
  263. { key: 'isDeduct', name: '是否为扣款项' },
  264. { key: 'isTotalTerms', name: '是否合计项' },
  265. { key: 'payApplicableTypeName', name: '支付项适用类型' },
  266. ])
  267. const tableCollectData = ref([])
  268. const tableCollectLoading = ref(false)
  269. const getTableCollectData = async () => {
  270. tableCollectLoading.value = true
  271. const { error, code, data } = await payApi.getProListPage({
  272. type:'1',
  273. contractId:contractId.value,
  274. current: 1, size: 100000,
  275. })
  276. tableCollectLoading.value = false
  277. if (!error && code === 200) {
  278. tableCollectData.value = getArrValue(data['records'])
  279. } else {
  280. tableCollectData.value = []
  281. }
  282. }
  283. const selectTableCollectIds = ref('')
  284. const tableCollectCheckChange = (list) => {
  285. selectTableCollectIds.value = arrToId(list)
  286. }
  287. </script>