index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <div class=" ml-2">
  5. <el-input v-model="searchForm.queryValue" clearable placeholder="请输入项目名称进行查询" size="large"/>
  6. </div>
  7. <div class="ml-4">
  8. <el-button type="primary" @click="searchClick" size="large">
  9. <HcIcon name="search-2"/>
  10. <span>搜索</span>
  11. </el-button>
  12. </div>
  13. <div class="ml-2">
  14. <el-button size="large" @click="resetClick">
  15. <HcIcon name="close-circle"/>
  16. <span>重置</span>
  17. </el-button>
  18. </div>
  19. </template>
  20. <template #extra>
  21. <el-button size="large" type="primary" hc-btn @click="addRowClick">
  22. <HcIcon name="add"/>
  23. <span>新增项目成本测算</span>
  24. </el-button>
  25. </template>
  26. <HcTable :column="tableColumn" :datas="tableData" :loading="tableLoading">
  27. <template #projectName="{row}">
  28. <span class="text-blue text-hover" @click="rowNameTap(row)">{{row.projectName}}</span>
  29. </template>
  30. <template #action="{row,index}">
  31. <el-button plain size="small" type="success" @click="approvalRowClick(row)" :disabled="row?.approveStatus!=='1'">提交审批</el-button>
  32. <el-button plain size="small" type="primary" @click="editRowClick(row)">编辑</el-button>
  33. <el-button plain size="small" type="danger" @click="delRowClick(row)">删除</el-button>
  34. </template>
  35. </HcTable>
  36. <template #action>
  37. <HcPages :pages="searchForm" @change="pageChange"/>
  38. </template>
  39. </HcCard>
  40. </template>
  41. <script setup>
  42. import {ref,onMounted,onActivated} from "vue";
  43. import {useRouter} from 'vue-router'
  44. import costApi from '~api/project/cost.js';
  45. import {getArrValue} from "js-fast-way"
  46. import {delMessage} from "~uti/tools";
  47. const router = useRouter()
  48. onActivated(()=>{
  49. getTableData()
  50. })
  51. //项目类型
  52. const projectType = ref([])
  53. const serverType=ref([])
  54. //年度数据
  55. const annuals = ref([
  56. {name: '2023年5月', key: '2023-05'},
  57. {name: '2022年4月', key: '2022-04'},
  58. {name: '2021年3月', key: '2021-03'}
  59. ])
  60. //搜索表单
  61. const searchForm = ref({
  62. projectType: null, user: null, project: null,
  63. current: 1, size: 20, total: 0
  64. })
  65. //搜索
  66. const searchClick = () => {
  67. searchForm.value.current = 1;
  68. getTableData()
  69. }
  70. //重置搜索表单
  71. const resetClick = () => {
  72. searchForm.value = {current: 1, size: 20, total: 0}
  73. }
  74. //分页被点击
  75. const pageChange = ({current, size}) => {
  76. searchForm.value.current = current
  77. searchForm.value.size = size
  78. getTableData()
  79. }
  80. //获取数据
  81. const tableLoading = ref(false)
  82. const tableColumn = [
  83. {key: 'projectName', name: '项目名称'},
  84. {key: 'projectCostTotal', name: '项目测算总金额', width: '120', align: 'center'},
  85. {key: 'devCostTotal', name: '研发部成本总金额', width: '120', align: 'center'},
  86. {key: 'businessCostTotal', name: '实施部成本总金额', width: '120', align: 'center'},
  87. {key: 'maintainCostTotal', name: '维护部成本总金额', width: '120', align: 'center'},
  88. {key: 'marketCostTotal', name: '市场部成本总金额', width: '120', align: 'center'},
  89. {key: 'manageCostTotal', name: '管理费成本总金额', width: '120', align: 'center'},
  90. {key: 'outsourceCostTotal', name: '外包劳务成本总金额', width: '120', align: 'center'},
  91. {key: 'action', name: '操作', width: '250', align: 'center', fixed: 'right'},
  92. ]
  93. const tableData = ref([
  94. {id: 1, key: '焦作至唐河高速公路方城至唐河段', key1: '810232', key2: '203200', key3: '192000', key4: '120350', key5: '63540', key6: '320000', key7: '12000'},
  95. {id: 2, key: '焦作至唐河高速公路方城至唐河段', key1: '810232', key2: '203200', key3: '192000', key4: '120350', key5: '63540', key6: '320000', key7: '12000'},
  96. {id: 3, key: '焦作至唐河高速公路方城至唐河段', key1: '810232', key2: '203200', key3: '192000', key4: '120350', key5: '63540', key6: '320000', key7: '12000'},
  97. ])
  98. const getTableData = async() => {
  99. tableLoading.value = true
  100. const {error, code, data} = await costApi.getprojectCostBudgetStats(searchForm.value)
  101. tableLoading.value = false
  102. if (!error && code === 200) {
  103. tableData.value = getArrValue(data)
  104. searchForm.value.total = data['total'] || 0
  105. } else {
  106. tableData.value = []
  107. searchForm.value.total = 0
  108. }
  109. }
  110. //新增报销记录
  111. const addRowClick = () => {
  112. router.push({name: 'project-cost-form'})
  113. }
  114. //编辑报销记录
  115. const editRowClick = (row) => {
  116. router.push({
  117. name: 'project-cost-form',
  118. query: {id: row.id}
  119. })
  120. }
  121. //删除成本预算deleteByStatsId
  122. const delRowClick = async(row) => {
  123. delMessage(async() => {
  124. const {error, code, data,msg} = await costApi.deleteByStatsId({id:row.id})
  125. if (!error && code === 200) {
  126. window.$message.success(msg)
  127. getTableData()
  128. } else {
  129. getTableData()
  130. }
  131. })
  132. }
  133. //名称被点击
  134. const rowNameTap = (row) => {
  135. router.push({
  136. name: 'project-cost-data',
  137. query: {id: row.projectId}
  138. })
  139. }
  140. //提交审批
  141. const approvalRowClick = async(row) => {
  142. const {error, code, data,msg} = await costApi.submitApprove({id:row.id})
  143. if (!error && code === 200) {
  144. window.$message.success(msg)
  145. getTableData()
  146. } else {
  147. getTableData()
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. </style>