middlepay.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="relative h-full flex">
  3. <div :id="`hc_tree_card_${uuid}`">
  4. <hc-new-card scrollbar>
  5. <template #header>
  6. <el-select v-model="searchForm.contractPeriodId" placeholder="选择计量期" filterable clearable block @change="searchKey1Click">
  7. <el-option v-for="item in key1Data" :key="item.id" :label="item.periodName" :value="item.id" clearable />
  8. </el-select>
  9. </template>
  10. <hc-lazy-tree :h-props="treeProps" tree-key="id" :auto-expand-keys="TreeAutoExpandKeys" @load="treeLoadNode" @nodeTap="treeNodeTap" />
  11. </hc-new-card>
  12. </div>
  13. <div :id="`hc_table_card_${uuid}`" class="flex-1">
  14. <hc-new-card>
  15. <template #header>
  16. <div class="font-400 text-orange">收方总金额:0元</div>
  17. </template>
  18. <template #extra>
  19. <el-button hc-btn type="primary" @click="addModalClick">新增</el-button>
  20. <el-button hc-btn type="warning" @click="reportClick">按期上报</el-button>
  21. <el-button hc-btn type="success" @click="detailsModalClick">清单明细</el-button>
  22. <el-button hc-btn type="success" @click="isReportDrawer = true">查看报表</el-button>
  23. <el-button hc-btn color="#626aef">按部位排序</el-button>
  24. <el-button hc-btn color="#626aef">按录入时间排序</el-button>
  25. </template>
  26. <hc-table
  27. :column="tableColumn" :datas="tableData" :loading="tableLoading"
  28. is-new is-check :check-style="{ width: 29 }" :index-style="{ width: 60 }"
  29. @selection-change="tableCheckChange"
  30. >
  31. <template #contractPeriodId="{ row }">
  32. {{ getTablePeriod(row) }}
  33. </template>
  34. <template #approveStatus="{ row }">
  35. {{ getTableStatus(row) }}
  36. </template>
  37. <template #action="{ row }">
  38. <el-link type="success" @click="rowEditClick(row)">修改</el-link>
  39. <el-link type="danger" @click="rowDelClick(row)">删除</el-link>
  40. </template>
  41. </hc-table>
  42. <template #action>
  43. <hc-pages :pages="searchForm" @change="pageChange" />
  44. </template>
  45. </hc-new-card>
  46. </div>
  47. <!-- 中间计量新增 -->
  48. <HcAddModal v-model="addModalShow" :project-id="projectId" :contract-id="contractId" :type="isAddModalType" :all-periods="key1Data" :period-id="searchForm.contractPeriodId" @finish="addModalFinish" />
  49. <!-- 清单明细 -->
  50. <HcDetailsModal v-model="detailsModalShow" />
  51. <!-- 上报弹窗 -->
  52. <hc-report-dialog v-model="isReport" />
  53. <!-- 查看报表 -->
  54. <hc-view-report v-model="isReportDrawer" />
  55. </div>
  56. </template>
  57. <script setup>
  58. import { nextTick, onMounted, ref } from 'vue'
  59. import { useAppStore } from '~src/store'
  60. import { getArrValue, getObjValue, getRandom } from 'js-fast-way'
  61. import { getStoreValue, setStoreValue } from '~src/utils/storage'
  62. import { delMessage } from '~uti/tools'
  63. import HcAddModal from './components/middlepay/addModal.vue'
  64. import HcDetailsModal from './components/middlepay/detailsModal.vue'
  65. import periodApi from '~api/debit-pay/material/periods'
  66. import unitApi from '~api/project/debit/contract/unit'
  67. import mainApi from '~api/debit-pay/admin/middlepay'
  68. const useAppState = useAppStore()
  69. const projectId = ref(useAppState.getProjectId || '')
  70. const contractId = ref(useAppState.getContractId || '')
  71. defineOptions({
  72. name: 'DebitPayAdminMiddlepay',
  73. })
  74. const uuid = getRandom(4)
  75. //渲染完成
  76. onMounted(() => {
  77. setSplitRef()
  78. getKey1Data()
  79. })
  80. //初始化设置拖动分割线
  81. const setSplitRef = () => {
  82. //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
  83. nextTick(() => {
  84. window.$split(['#hc_tree_card_' + uuid, '#hc_table_card_' + uuid], {
  85. sizes: [20, 80],
  86. snapOffset: 0,
  87. minSize: [50, 500],
  88. })
  89. })
  90. }
  91. //搜索表单
  92. const searchForm = ref({
  93. contractPeriodId: null, contractUnitId: null, contractId: contractId.value,
  94. current: 1, size: 10, total: 0,
  95. })
  96. //计量期
  97. const key1Data = ref([])
  98. const getKey1Data = async ()=>{
  99. const { error, code, data } = await periodApi.allPeriod({
  100. contractId:contractId.value,
  101. type:1,
  102. })
  103. tableLoading.value = false
  104. if (!error && code === 200) {
  105. key1Data.value = getArrValue(data)
  106. searchForm.value.contractPeriodId = key1Data.value[ key1Data.value.length - 1].id
  107. } else {
  108. key1Data.value = []
  109. }
  110. }
  111. const searchKey1Click = () => {
  112. searchForm.value.current = 1
  113. getTableData()
  114. }
  115. //数据格式
  116. const treeProps = {
  117. label: 'nodeName',
  118. children: 'children',
  119. isLeaf: 'notExsitChild',
  120. }
  121. const TreeAutoExpandKeys = ref(getStoreValue('middlepay-tree-auto-expand-keys') || [])
  122. //懒加载的数据
  123. const treeLoadNode = async ({ item, level }, resolve) => {
  124. let id = 0
  125. if (level !== 0) {
  126. const nodeData = getObjValue(item)
  127. id = nodeData?.id || ''
  128. }
  129. //获取数据
  130. const { data } = await unitApi.lazyTree({
  131. contractId: contractId.value,
  132. id:id,
  133. contractPeriodId:searchForm.value.contractPeriodId,
  134. })
  135. resolve(getArrValue(data))
  136. }
  137. const treeNodeTap = ({ data, keys }) => {
  138. searchForm.value.current = 1
  139. searchForm.value.contractUnitId = data.id
  140. TreeAutoExpandKeys.value = keys || []
  141. setStoreValue('middlepay-tree-auto-expand-keys', keys)
  142. getTableData()
  143. }
  144. //分页
  145. const pageChange = ({ current, size }) => {
  146. searchForm.value.current = current
  147. searchForm.value.size = size
  148. getTableData()
  149. }
  150. //表格数据
  151. const tableLoading = ref(false)
  152. const tableColumn = ref([
  153. { key: 'meterNumber', name: '计量单编号' },
  154. { key: 'contractPeriodId', name: '计量期' },
  155. { key: 'engineerDivide', name: '工程划分部位' },
  156. { key: 'meterMoney', name: '计量金额' },
  157. { key: 'businessDate', name: '业务日期' },
  158. { key: 'approveStatus', name: '审核状态' },
  159. { key: 'action', name: '操作', width: 130, align: 'center' },
  160. ])
  161. const tableData = ref([])
  162. const getTableData = async () => {
  163. tableData.value = []
  164. tableLoading.value = true
  165. const { data } = await mainApi.getPage({
  166. ...searchForm.value,
  167. contractId: contractId.value,
  168. })
  169. tableData.value = getArrValue(data['records'])
  170. searchForm.value.total = data.total || 0
  171. tableLoading.value = false
  172. }
  173. //获取表格计量期
  174. const getTablePeriod = ({ contractPeriodId }) => {
  175. const periods = key1Data.value
  176. const periodData = periods.find((item) => item.id === contractPeriodId)
  177. return periodData?.periodName || ''
  178. }
  179. //获取表格状态
  180. const getTableStatus = ({ approveStatus }) => {
  181. if (approveStatus === 0) {
  182. return '未上报'
  183. } else if (approveStatus === 1) {
  184. return '待审批'
  185. } else if (approveStatus === 2) {
  186. return '已审批'
  187. } else if (approveStatus === 3) {
  188. return '已废除'
  189. }
  190. }
  191. //表格选择
  192. const tableCheckChange = () => {
  193. }
  194. //中间收方新增
  195. const addModalShow = ref(false)
  196. const isAddModalType = ref('add')
  197. const addModalClick = () => {
  198. isAddModalType.value = 'add'
  199. addModalShow.value = true
  200. }
  201. //修改
  202. const rowEditClick = (row) => {
  203. }
  204. //删除
  205. const rowDelClick = (row) => {
  206. delMessage(() => {
  207. console.log('删除')
  208. })
  209. }
  210. //保存完成
  211. const addModalFinish = () => {
  212. addModalShow.value = false
  213. getTableData()
  214. }
  215. //收方清单明细
  216. const detailsModalShow = ref(false)
  217. const detailsModalClick = () => {
  218. detailsModalShow.value = true
  219. }
  220. //是否上报
  221. const isReport = ref(false)
  222. const reportClick = () => {
  223. isReport.value = true
  224. }
  225. const isReportDrawer = ref(false)
  226. </script>