pay.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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">{{ selectArr.length }}</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/project/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. import { getDictionary } from '~api/other'
  86. const useAppState = useAppStore()
  87. const projectId = ref(useAppState.getProjectId)
  88. defineOptions({
  89. name: 'ProjectDebitProjectPay',
  90. })
  91. const uuid = getRandom(4)
  92. //渲染完成
  93. onMounted(() => {
  94. setSplitRef()
  95. gePayType()
  96. gePayAppType()
  97. getTableData()
  98. })
  99. //初始化设置拖动分割线
  100. const setSplitRef = () => {
  101. //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
  102. nextTick(() => {
  103. window.$split(['#hc_table_card_' + uuid, '#hc_info_card_' + uuid], {
  104. sizes: [70, 30],
  105. snapOffset: 0,
  106. minSize: [50, 300],
  107. })
  108. })
  109. }
  110. //获支付项类型
  111. const payOptions = ref([])
  112. const gePayType = async () => {
  113. const { data } = await getDictionary({
  114. code: 'meter_pay_type',
  115. })
  116. payOptions.value = getArrValue(data)
  117. payOptions.value.forEach((ele)=>{
  118. ele.dictKey = Number(ele.dictKey)
  119. })
  120. }
  121. //获支付项适用类型
  122. const payAppOptions = ref([])
  123. const gePayAppType = async () => {
  124. const { data } = await getDictionary({
  125. code: 'meter_pay_applicable_type',
  126. })
  127. payAppOptions.value = getArrValue(data)
  128. payAppOptions.value.forEach((ele)=>{
  129. ele.dictKey = Number(ele.dictKey)
  130. })
  131. }
  132. //搜索表单
  133. const searchForm = ref({ current: 1, size: 10, total: 0 })
  134. //分页
  135. const pageChange = ({ current, size }) => {
  136. searchForm.value.current = current
  137. searchForm.value.size = size
  138. }
  139. //表格数据
  140. const tableLoading = ref(false)
  141. const tableColumn = ref([
  142. { key: 'payNumber', name: '支付项编号', width: 140 },
  143. { key: 'payName', name: '支付项名称' },
  144. { key: 'payTypeName', name: '支付项类型', width: 160 },
  145. { key: 'isDeduct', name: '是否为扣款项', width: 100 },
  146. { key: 'isTotalTerms', name: '是否合计项', width: 100 },
  147. { key: 'payApplicableTypeName', name: '适用类型', width: 100 },
  148. { key: 'action', name: '操作', width: 100 },
  149. ])
  150. const tableData = ref([])
  151. const getTableData = async () => {
  152. tableLoading.value = true
  153. const { error, code, data } = await payApi.getProListPage({
  154. ...searchForm.value,
  155. projectId:projectId.value,
  156. })
  157. tableLoading.value = false
  158. if (!error && code === 200) {
  159. tableData.value = getArrValue(data['records'])
  160. searchForm.value.total = data['total']
  161. if (tableData.value.length > 0) {
  162. getDetail(tableData.value[0].id)
  163. rowViewId.value = tableData.value[0].id
  164. }
  165. } else {
  166. tableData.value = []
  167. searchForm.value.total = 0
  168. }
  169. }
  170. //引用系统支付项
  171. const systemPayShow = ref(false)
  172. const systemPaymentClick = () => {
  173. systemPayShow.value = true
  174. }
  175. const finishSystemPay = ()=>{
  176. getTableData()
  177. systemPayShow.value = false
  178. }
  179. //汇总项
  180. const tableColumn1 = ref([
  181. { key: 'payNumber', name: '支付项编号' },
  182. { key: 'payName', name: '支付项名称' },
  183. { key: 'payTypeName', name: '支付项类型' },
  184. { key: 'contractFormulaIds', name: '合同计算公式' },
  185. { key: 'updateFormulaIds', name: '变更计算公式' },
  186. { key: 'currentFormulaIds', name: '本期计算公式' },
  187. { key: 'isDeduct', name: '是否为扣款项' },
  188. { key: 'action', name: '操作', width: 50 },
  189. ])
  190. const tableData1 = ref([])
  191. //修改
  192. const rowDataId = ref('')
  193. const rowViewId = ref('')
  194. const isEditRowShow = ref(false)
  195. const editRowClick = (row) => {
  196. isEditRowShow.value = true
  197. rowDataId.value = row.id
  198. }
  199. //获取节点详情
  200. const getDetail = async (id)=>{
  201. const { error, code, data } = await payApi.getProDetail({
  202. id,
  203. })
  204. if (!error && code === 200) {
  205. tableData1.value = getObjValue(data)['summaryItemList']
  206. } else {
  207. tableData1.value = []
  208. }
  209. }
  210. const viewRowClick = ({ row })=>{
  211. rowViewId.value = row.id
  212. getDetail(row.id)
  213. }
  214. const finishEditRow = ()=>{
  215. isEditRowShow.value = false
  216. getTableData()
  217. }
  218. const delRowClick = async (row)=>{
  219. delMessageV2(async (action, instance, done) => {
  220. if (action === 'confirm') {
  221. instance.confirmButtonLoading = true
  222. removeProPay(row.id)
  223. instance.confirmButtonLoading = false
  224. done()
  225. } else {
  226. done()
  227. }
  228. })
  229. }
  230. const removeProPay = async (id) => {
  231. const { error, code } = await payApi.removeProList({
  232. id: id,
  233. })
  234. if (!error && code === 200) {
  235. window?.$message?.success('删除成功')
  236. getTableData()
  237. rowViewId.value = ''
  238. }
  239. }
  240. //添加汇总项
  241. const isCollectShow = ref(false)
  242. const collectSaveLoading = ref(false)
  243. const collectModalSave = async () => {
  244. collectSaveLoading.value = true
  245. const { error, code, msg } = await payApi.addCollect({
  246. bindIds :selectTableCollectIds.value,
  247. id:rowViewId.value,
  248. })
  249. //判断状态
  250. collectSaveLoading.value = false
  251. if (!error && code === 200) {
  252. window?.$message?.success(msg)
  253. }
  254. getDetail(rowViewId.value)
  255. isCollectShow.value = false
  256. }
  257. const addColloect = ()=>{
  258. isCollectShow.value = true
  259. getTableCollectData()
  260. selectArr.value = []
  261. }
  262. //删除汇总项
  263. const delCollectRow = (row)=>{
  264. delMessageV2(async (action, instance, done) => {
  265. if (action === 'confirm') {
  266. instance.confirmButtonLoading = true
  267. removeCollectPay(row.id)
  268. instance.confirmButtonLoading = false
  269. done()
  270. } else {
  271. done()
  272. }
  273. })
  274. }
  275. const removeCollectPay = async (id) => {
  276. const { error, code } = await payApi.removeCollect({
  277. id: rowViewId.value,
  278. bindId:id,
  279. })
  280. if (!error && code === 200) {
  281. window?.$message?.success('删除成功')
  282. getDetail(rowViewId.value)
  283. }
  284. }
  285. //添加汇总项
  286. const tableCollectColumn = ref([
  287. { key: 'payNumber', name: '支付项编号' },
  288. { key: 'payName', name: '支付项名称' },
  289. { key: 'payTypeName', name: '支付项类型' },
  290. { key: 'isDeduct', name: '是否为扣款项' },
  291. { key: 'isTotalTerms', name: '是否合计项' },
  292. { key: 'payApplicableTypeName', name: '支付项适用类型' },
  293. ])
  294. const tableCollectData = ref([])
  295. const tableCollectLoading = ref(false)
  296. const getTableCollectData = async () => {
  297. tableCollectLoading.value = true
  298. const { error, code, data } = await payApi.getProListPage({
  299. type:1,
  300. projectId:projectId.value,
  301. current: 1, size: 10000,
  302. })
  303. tableCollectLoading.value = false
  304. if (!error && code === 200) {
  305. tableCollectData.value = getArrValue(data['records'])
  306. } else {
  307. tableCollectData.value = []
  308. }
  309. }
  310. const selectTableCollectIds = ref('')
  311. const selectArr = ref([])
  312. const tableCollectCheckChange = (list) => {
  313. selectArr.value = list
  314. selectTableCollectIds.value = arrToId(list)
  315. }
  316. </script>