TheModalTable.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <script setup>
  2. import { ref, h } from 'vue';
  3. import { NModal, NForm, NGrid, NFormItemGi, NInput, NDatePicker, NPagination, NDataTable } from 'naive-ui';
  4. import dayjs from 'dayjs';
  5. import { carbonApi } from '@/api/carbon';
  6. const modelValue = defineModel();
  7. const timeArr = ref(null);
  8. const hsTimeArr = ref(null);
  9. const formData = ref({
  10. pageNum: 1,
  11. pageSize: 10,
  12. createBy: '',
  13. })
  14. const inputThemeOverrides = {
  15. border: '1px solid #d7d9e5',
  16. borderRadius: '8px',
  17. borderHover: '1px solid #2454FF',
  18. borderFocus: '1px solid #2454FF',
  19. boxShadowFocus: '0 0 0 2px rgba(36, 84, 255, 0.2)',
  20. text: '#333'
  21. }
  22. const selectThmem = {
  23. peers: {
  24. Input: {
  25. border: '1px solid #d7d9e5',
  26. borderRadius: '8px',
  27. borderHover: '1px solid #2454FF',
  28. borderFocus: '1px solid #2454FF',
  29. boxShadowFocus: '0 0 0 2px rgba(36, 84, 255, 0.2)',
  30. text: '#333'
  31. }
  32. }
  33. }
  34. const total = ref(0);
  35. const tableData = ref([]);
  36. const columns = [
  37. { title: '核算日期', key: 'addYearMonth', align: 'center' },
  38. { title: '总碳排放量', key: 'ztTotalCo2', align: 'center' },
  39. { title: '污水处理碳排放量', key: 'wsclTotalCo2', align: 'center', width: 160 },
  40. { title: '能源、药剂碳排量', key: 'nyyjTotalCo2', align: 'center', width: 160 },
  41. { title: '污泥处理碳排量', key: 'wnclTotalCo2', align: 'center', width: 160 },
  42. { title: '替碳、碳汇替碳量', key: 'ttthTotalCo2', align: 'center', width: 160 },
  43. { title: '录入人员', key: 'createBy', align: 'center' },
  44. { title: '填报日期', key: 'remark', align: 'center' },
  45. // { title: '操作', key: 'name9', align: 'center', render: (row) => {
  46. // return h('span', {
  47. // class: 'text-[#2454FF] cursor-pointer',
  48. // onClick: () => {
  49. // console.log(row);
  50. // }
  51. // }, '下载');
  52. // }}
  53. ]
  54. const formatTime = (timestamp) => {
  55. let tempTimeList = [];
  56. if ( timestamp && timestamp.length ) {
  57. tempTimeList = timestamp.map(t => dayjs(t).format('YYYY-MM-DD'));
  58. }
  59. return tempTimeList;
  60. }
  61. const handleQueryList = async() => {
  62. const [ timeBegin, timeEnd ] = formatTime(timeArr.value);
  63. const [ hsTimeBegin, hsTimeEnd ] = formatTime(hsTimeArr.value);
  64. console.log( hsTimeArr.value );
  65. const { rows, total: allTotal } = await carbonApi.getTableList({ ...formData.value, timeBegin, timeEnd, hsTimeBegin, hsTimeEnd })
  66. tableData.value = rows;
  67. total.value = allTotal;
  68. }
  69. const handleResetList = async () => {
  70. timeArr.value = null;
  71. hsTimeArr.value = null;
  72. formData.value = {
  73. pageNum: 1,
  74. pageSize: 10,
  75. createBy: '',
  76. };
  77. handleQueryList();
  78. }
  79. const onAfterdEnter = () => {
  80. handleQueryList();
  81. }
  82. const onAfterLeave = () => {
  83. handleResetList();
  84. }
  85. </script>
  86. <template>
  87. <NModal
  88. v-model:show="modelValue"
  89. preset="card"
  90. class="custom-card"
  91. title="核算历史"
  92. header-class="card-preset_header"
  93. content-class="card-prset_content"
  94. :style="{ width: '1240px' }"
  95. :bordered="false"
  96. :close-on-esc="false"
  97. :mask-closable="false"
  98. :block-scroll="false"
  99. :on-after-enter="onAfterdEnter"
  100. :on-after-leave="onAfterLeave"
  101. >
  102. <div class="main-container space-y-[12px]">
  103. <div class="search-inner">
  104. <NForm :show-feedback="false">
  105. <NGrid :cols="14" :x-gap="24">
  106. <NFormItemGi :span="4" label="录入人员:" path="adress" label-placement="top">
  107. <NInput :theme-overrides="inputThemeOverrides" v-model:value="formData.createBy" />
  108. </NFormItemGi>
  109. <NFormItemGi :span="4" label="填报日期:" path="adress" label-placement="top">
  110. <n-date-picker v-model:value="timeArr" type="daterange" clearable :theme-overrides="selectThmem"/>
  111. </NFormItemGi>
  112. <NFormItemGi :span="4" label="核算日期:" path="adress" label-placement="top">
  113. <n-date-picker v-model:value="hsTimeArr" type="monthrange" clearable :theme-overrides="selectThmem" value-format="yyyy-mm"/>
  114. </NFormItemGi>
  115. <NFormItemGi :span="2" label="" path="adress" label-placement="top">
  116. <div class="space-x-[10px]">
  117. <button class="btn" @click="handleQueryList">查询</button>
  118. <button class="btn default" @click="handleResetList">重置</button>
  119. </div>
  120. </NFormItemGi>
  121. </NGrid>
  122. </NForm>
  123. </div>
  124. <div class="table-inner">
  125. <NDataTable :columns="columns" :data="tableData" :bordered="false" :single-line="false" :min-height="400" :max-height="400"></NDataTable>
  126. <div class="pt-[20px] flex justify-center">
  127. <NPagination v-model:page="formData.pageNum" :item-count="total"></NPagination>
  128. </div>
  129. </div>
  130. </div>
  131. </NModal>
  132. </template>
  133. <style lang="scss" scoped>
  134. .main-container {
  135. padding: 20px;
  136. border-radius: 20px;
  137. border: 1px solid #FFFFFF;
  138. background: linear-gradient(180deg, rgba(238, 253, 255, 0.5) 0%, rgba(231, 243, 252, 0.5) 100%);
  139. .search-inner, .table-inner {
  140. padding: 20px 20px;
  141. border-radius: 10px;
  142. background: #fff;
  143. .btn {
  144. border-radius: 4px;
  145. padding: 5px 16px;
  146. background: #2454FF;
  147. font-size: 14px;
  148. line-height: 22px;
  149. text-align: left;
  150. color: #fff;
  151. }
  152. .default {
  153. border: 1px solid #d7d9e5;
  154. color: #2454FF;
  155. background: #fff;
  156. }
  157. }
  158. .table-inner {
  159. }
  160. }
  161. </style>
  162. <style lang="scss">
  163. .card-preset_header {
  164. padding: 16px !important;
  165. }
  166. .card-prset_content {
  167. padding: 20px !important;
  168. background: linear-gradient(180deg, #F3F7FC 0%, #E4EAF7 100%);
  169. }
  170. </style>