addBillBase.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <hc-new-dialog is-table widths="1200px" :show="isShow" title="添加分解清单" @save="modalSave" @close="modalClose">
  3. <hc-table
  4. :column="tableColumn" :datas="tableData" :loading="tableLoading"
  5. is-new is-check :check-style="{ width: 29 }" :index-style="{ width: 60 }"
  6. @selection-change="tableCheckChange"
  7. />
  8. </hc-new-dialog>
  9. </template>
  10. <script setup>
  11. import { ref, watch } from 'vue'
  12. import { arrToId, getArrValue } from 'js-fast-way'
  13. import middlepayApi from '~api/debit-pay/admin/middlepay'
  14. import mainApi from '~api/tasks/hc-data'
  15. const props = defineProps({
  16. info: {
  17. type: Object,
  18. default: () => ({}),
  19. },
  20. table: {
  21. type: Object,
  22. default: () => ({}),
  23. },
  24. ids: {
  25. type: [String, Number],
  26. default: '',
  27. },
  28. projectId: {
  29. type: [String, Number],
  30. default: '',
  31. },
  32. contractId: {
  33. type: [String, Number],
  34. default: '',
  35. },
  36. })
  37. //事件
  38. const emit = defineEmits(['finish', 'close'])
  39. const taskInfo = ref(props.info)
  40. const tableInfo = ref(props.table)
  41. const tableIds = ref(props.ids)
  42. const contractId = ref(props.contractId)
  43. const projectId = ref(props.projectId)
  44. //双向绑定
  45. // eslint-disable-next-line no-undef
  46. const isShow = defineModel('modelValue', {
  47. default: false,
  48. })
  49. //监听
  50. watch(() => [
  51. props.ids,
  52. props.projectId,
  53. props.contractId,
  54. ], ([ids, pid, cid]) => {
  55. tableIds.value = ids
  56. projectId.value = pid
  57. contractId.value = cid
  58. }, { immediate: true, deep: true })
  59. //监听数据
  60. watch(() => [
  61. props.table,
  62. props.info,
  63. ], ([table, row]) => {
  64. tableInfo.value = table
  65. taskInfo.value = row
  66. }, { deep: true })
  67. //监听
  68. watch(isShow, (val) => {
  69. if (val) {
  70. getTableData()
  71. }
  72. })
  73. //表格数据
  74. const tableLoading = ref(false)
  75. const tableColumn = [
  76. { key: 'formNumber', name: '清单编号' },
  77. { key: 'formName', name: '清单名称' },
  78. { key: 'currentPrice', name: '单价(元)' },
  79. { key: 'contractTotal', name: '合同数量' },
  80. { key: 'changeTotal', name: '合同变更后数量' },
  81. { key: 'buildChangeTotal', name: '施工图变更后数量' },
  82. { key: 'resolveResidueTotal', name: '分解剩余量' },
  83. ]
  84. const tableData = ref([])
  85. const getTableData = async () => {
  86. tableData.value = []
  87. tableLoading.value = true
  88. const { contractPeriodId, contractUnitId } = tableInfo.value
  89. const { data } = await middlepayApi.addFormList({
  90. contractPeriodId: contractPeriodId,
  91. contractId: contractId.value,
  92. ids: tableIds.value,
  93. nodeId: contractUnitId,
  94. })
  95. tableData.value = getArrValue(data)
  96. tableLoading.value = false
  97. }
  98. //表格选择
  99. const checksData = ref([])
  100. const tableCheckChange = (data) => {
  101. checksData.value = data
  102. }
  103. //确定保存
  104. const modalSave = async () => {
  105. const rows = checksData.value
  106. if (rows.length <= 0) {
  107. window.$message.warning('请先选择清单')
  108. return false
  109. }
  110. const rowIds = arrToId(rows)
  111. const { contractPeriodId, contractUnitId, id } = tableInfo.value
  112. const { data } = await mainApi.tableFormApplyTaskSave({
  113. contractPeriodId: contractPeriodId,
  114. projectId: projectId.value,
  115. contractId: contractId.value,
  116. nodeId: contractUnitId,
  117. taskId: taskInfo.value.id,
  118. dataId: id,
  119. ids: rowIds,
  120. })
  121. emit('finish', getArrValue(data))
  122. modalClose()
  123. }
  124. //取消关闭
  125. const modalClose = () => {
  126. isShow.value = false
  127. emit('close')
  128. }
  129. </script>