index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div class="page">
  3. <div class="gva-card-box">
  4. <div class="gva-card">
  5. <div>
  6. <el-select
  7. v-model="project1"
  8. style="width: 200px;margin-bottom: 20px"
  9. clearable
  10. filterable
  11. value-on-clear=""
  12. placeholder="请选择项目"
  13. @change="changeCode"
  14. >
  15. <el-option
  16. v-for="item in projectData"
  17. :key="item.code"
  18. :label="item.name"
  19. :value="item.code"
  20. />
  21. </el-select>
  22. </div>
  23. <div
  24. id="main"
  25. style="width: 100%; height: 300px;"
  26. @click="handleChartClick"
  27. />
  28. </div>
  29. </div>
  30. <div class="gva-card-box">
  31. <div class="gva-card">
  32. <div class="gva-card-title">
  33. <el-row :gutter="10">
  34. <el-col
  35. :xs="24"
  36. :sm="2"
  37. >
  38. <span>数据统计</span>
  39. </el-col>
  40. <el-col
  41. :xs="24"
  42. :sm="4"
  43. >
  44. <el-date-picker
  45. v-model="monthData"
  46. type="month"
  47. placeholder="选择月份"
  48. value-format="YYYY-MM"
  49. value-on-clear=""
  50. @change="choiceMonth"
  51. />
  52. </el-col>
  53. <el-col
  54. :xs="24"
  55. :sm="4"
  56. >
  57. <el-date-picker
  58. v-model="yearData"
  59. type="year"
  60. placeholder="选择年份"
  61. value-format="YYYY"
  62. value-on-clear=""
  63. @change="choiceYear"
  64. />
  65. </el-col>
  66. <el-col
  67. :xs="24"
  68. :sm="4"
  69. >
  70. <el-select
  71. v-model="feeGenre"
  72. clearable
  73. filterable
  74. value-on-clear=""
  75. placeholder="请选择公司费用类型"
  76. @change="changeFeeGenre"
  77. >
  78. <el-option
  79. v-for="item in feeGenreData"
  80. :key="item.ID"
  81. :label="item.name"
  82. :value="item.ID"
  83. />
  84. </el-select>
  85. </el-col>
  86. <el-col
  87. :xs="24"
  88. :sm="6"
  89. />
  90. </el-row>
  91. </div>
  92. <div class="p-4">
  93. <el-row :gutter="10">
  94. <el-col
  95. :xs="24"
  96. :sm="11"
  97. >
  98. <el-table
  99. :data="projectMonthFee"
  100. max-height="400px"
  101. height="400px"
  102. show-summary
  103. table-layout="auto"
  104. >
  105. <el-table-column
  106. prop="projectFeeGenre.name"
  107. label="费用类型"
  108. width="200"
  109. align="center"
  110. />
  111. <el-table-column
  112. prop="totalExpenditure"
  113. label="支出金额"
  114. align="center"
  115. />
  116. <el-table-column
  117. prop="totalDeposit"
  118. label="支入金额"
  119. align="center"
  120. />
  121. </el-table>
  122. </el-col>
  123. <el-col
  124. :xs="24"
  125. :sm="2"
  126. />
  127. <el-col
  128. :xs="24"
  129. :sm="11"
  130. >
  131. <el-table
  132. :data="monthFee"
  133. max-height="400px"
  134. height="400px"
  135. table-layout="auto"
  136. show-summary
  137. >
  138. <el-table-column
  139. prop="department.name"
  140. label="部门"
  141. width="200"
  142. align="center"
  143. />
  144. <el-table-column
  145. prop="totalExpenditure"
  146. label="支出金额"
  147. align="center"
  148. />
  149. <el-table-column
  150. prop="totalDeposit"
  151. label="支入金额"
  152. align="center"
  153. />
  154. </el-table>
  155. </el-col>
  156. </el-row>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </template>
  162. <script setup>
  163. import { ref, onMounted } from 'vue'
  164. import { getAllProject, queryProjectSum } from '@/api/project'
  165. import * as echarts from 'echarts'
  166. import { queryMonthExpenses, queryProjectMonthFee } from '@/api/cost'
  167. import { queryExpensesGenre } from '@/api/finance'
  168. let myChart = null
  169. const initChart = () => {
  170. const chartDom = document.getElementById('main')
  171. if (myChart) {
  172. myChart.dispose() // 销毁图表实例
  173. }
  174. myChart = echarts.init(chartDom)
  175. myChart.setOption({
  176. title: {
  177. text: '项目总表'
  178. },
  179. xAxis: {
  180. type: 'value'
  181. },
  182. yAxis: {
  183. type: 'category',
  184. data: ['项目总营业额', '项目已收款', '项目应收款']
  185. },
  186. tooltip: {
  187. trigger: 'axis',
  188. axisPointer: {
  189. type: 'shadow'
  190. }
  191. },
  192. series: [
  193. {
  194. data: xData.value,
  195. type: 'bar'
  196. }
  197. ]
  198. })
  199. }
  200. // 筛选数据
  201. const monthData = ref('')
  202. const yearData = ref('')
  203. const project1 = ref('')
  204. const feeGenre = ref('')
  205. const projectSum = ref()
  206. const projectMonthFee = ref()
  207. const monthFee = ref()
  208. const projectData = ref()
  209. const feeGenreData = ref()
  210. const xData = ref([])
  211. const queryData = async() => {
  212. await queryProjectSum(project1.value).then(res => {
  213. projectSum.value = res.data
  214. xData.value.length = 0
  215. for (const key in projectSum.value) {
  216. xData.value.push(projectSum.value[key])
  217. }
  218. })
  219. await queryProjectMonthFee(monthData.value, yearData.value, project1.value).then(res => {
  220. projectMonthFee.value = res.data
  221. })
  222. await queryMonthExpenses(monthData.value, yearData.value, feeGenre.value).then(res => {
  223. monthFee.value = res.data
  224. })
  225. await getAllProject().then(res => {
  226. projectData.value = res.data
  227. })
  228. await queryExpensesGenre().then(res => {
  229. feeGenreData.value = res.data
  230. })
  231. initChart()
  232. }
  233. const handleChartClick = () => {
  234. console.log('详情')
  235. }
  236. // 项目费用
  237. const choiceYear = () => {
  238. monthData.value = ''
  239. queryData()
  240. }
  241. const changeCode = () => {
  242. queryData()
  243. }
  244. const changeFeeGenre = () => {
  245. queryData()
  246. }
  247. const choiceMonth = () => {
  248. yearData.value = ''
  249. queryData()
  250. }
  251. onMounted(() => {
  252. queryData()
  253. })
  254. </script>
  255. <style lang="scss" scoped>
  256. .page {
  257. @apply p-0;
  258. .gva-card-box{
  259. @apply p-4;
  260. &+.gva-card-box{
  261. @apply pt-0;
  262. }
  263. }
  264. .gva-card {
  265. @apply box-border bg-white rounded h-auto px-6 py-8 overflow-hidden shadow-sm;
  266. .gva-card-title{
  267. @apply pb-5 border-t-0 border-l-0 border-r-0 border-b border-solid border-gray-100;
  268. }
  269. }
  270. .gva-top-card {
  271. @apply h-72 flex items-center justify-between text-gray-500;
  272. &-left {
  273. @apply h-full flex flex-col w-auto;
  274. &-title {
  275. @apply text-3xl text-gray-600;
  276. }
  277. &-dot {
  278. @apply mt-4 text-gray-600 text-lg;
  279. }
  280. &-item{
  281. +.gva-top-card-left-item{
  282. margin-top: 24px;
  283. }
  284. margin-top: 14px;
  285. }
  286. }
  287. &-right {
  288. height: 600px;
  289. width: 600px;
  290. margin-top: 28px;
  291. }
  292. }
  293. ::v-deep(.el-card__header){
  294. @apply p-0 border-gray-200;
  295. }
  296. .card-header{
  297. @apply pb-5 border-b border-solid border-gray-200 border-t-0 border-l-0 border-r-0;
  298. }
  299. .quick-entrance-items {
  300. @apply flex items-center justify-center text-center text-gray-800;
  301. .quick-entrance-item {
  302. @apply px-8 py-6 flex items-center flex-col transition-all duration-100 ease-in-out rounded-lg cursor-pointer;
  303. &:hover{
  304. @apply shadow-lg;
  305. }
  306. &-icon {
  307. @apply flex items-center h-16 w-16 rounded-lg justify-center mx-0 my-auto text-2xl;
  308. }
  309. p {
  310. @apply mt-2.5;
  311. }
  312. }
  313. }
  314. }
  315. .dashboard-icon {
  316. @apply flex items-center text-xl mr-2 text-blue-400;
  317. }
  318. </style>