UnfilledReportDialog.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <el-dialog
  3. v-model="dialogVisible"
  4. title="未填报详情"
  5. width="80%"
  6. top="5vh"
  7. :close-on-click-modal="false"
  8. @closed="handleClosed"
  9. >
  10. <!-- 搜索条件区域 -->
  11. <ContentWrap class="mb-15px">
  12. <el-form :model="searchParams" ref="searchFormRef" :inline="true" label-width="100px">
  13. <el-form-item label="创建时间" prop="createTime">
  14. <el-date-picker
  15. v-model="searchParams.createTime"
  16. value-format="YYYY-MM-DD HH:mm:ss"
  17. type="daterange"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期"
  20. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  21. class="!w-320px"
  22. @change="handleSearch"
  23. />
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button @click="handleSearch">
  27. <Icon icon="ep:search" class="mr-5px" /> 搜索
  28. </el-button>
  29. <el-button @click="resetSearch">
  30. <Icon icon="ep:refresh" class="mr-5px" /> 重置
  31. </el-button>
  32. </el-form-item>
  33. </el-form>
  34. </ContentWrap>
  35. <!-- 列表区域 -->
  36. <ContentWrap>
  37. <div class="table-container">
  38. <el-table
  39. v-loading="loading"
  40. :data="list"
  41. :stripe="true"
  42. style="width: 100%"
  43. :cell-style="cellStyle"
  44. empty-text="暂无未填报数据"
  45. table-layout="fixed"
  46. >
  47. <el-table-column label="日期" align="center" prop="reportDate" width="120">
  48. <template #default="scope">
  49. <span class="date-content">{{ scope.row.reportDate }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="部门名称" prop="deptNames" min-width="300">
  53. <template #default="scope">
  54. <div class="dept-names-content">
  55. {{ scope.row.deptNames || '-' }}
  56. </div>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. </div>
  61. <!-- 分页
  62. <Pagination
  63. :total="total"
  64. v-model:page="searchParams.pageNo"
  65. v-model:limit="searchParams.pageSize"
  66. @pagination="getList"
  67. /> -->
  68. </ContentWrap>
  69. </el-dialog>
  70. </template>
  71. <script setup lang="ts">
  72. import { ref, reactive, watch, nextTick } from 'vue'
  73. import { IotRyDailyReportApi } from '@/api/pms/iotrydailyreport'
  74. const { t } = useI18n()
  75. const message = useMessage()
  76. // 弹窗显示控制
  77. const dialogVisible = ref(false)
  78. // 搜索参数
  79. const searchParams = reactive({
  80. pageNo: 1,
  81. pageSize: 10,
  82. createTime: []
  83. })
  84. // 列表数据
  85. const list = ref<any[]>([])
  86. const total = ref(0)
  87. const loading = ref(false)
  88. // 接收父组件传递的查询参数
  89. const props = defineProps<{
  90. queryParams: any
  91. }>()
  92. // 搜索表单引用
  93. const searchFormRef = ref()
  94. // 打开弹窗
  95. const open = () => {
  96. // 复制父组件的查询参数
  97. if (props.queryParams.createTime && props.queryParams.createTime.length > 0) {
  98. searchParams.createTime = [...props.queryParams.createTime]
  99. }
  100. dialogVisible.value = true
  101. // 获取数据
  102. nextTick(() => {
  103. getList()
  104. })
  105. }
  106. // 获取列表数据
  107. const getList = async () => {
  108. // 检查时间范围
  109. if (!searchParams.createTime || searchParams.createTime.length === 0) {
  110. list.value = []
  111. total.value = 0
  112. return
  113. }
  114. loading.value = true
  115. try {
  116. const res = await IotRyDailyReportApi.ryUnReportDetails({
  117. createTime: searchParams.createTime,
  118. projectClassification: props.queryParams.projectClassification
  119. })
  120. // 处理返回数据
  121. if (res && Array.isArray(res)) {
  122. list.value = res
  123. total.value = res.length
  124. } else {
  125. list.value = []
  126. total.value = 0
  127. }
  128. } catch (error) {
  129. console.error('获取未填报数据失败', error)
  130. message.error('获取未填报数据失败')
  131. list.value = []
  132. total.value = 0
  133. } finally {
  134. loading.value = false
  135. }
  136. }
  137. // 搜索
  138. const handleSearch = () => {
  139. searchParams.pageNo = 1
  140. getList()
  141. }
  142. // 重置搜索
  143. const resetSearch = () => {
  144. searchFormRef.value?.resetFields()
  145. handleSearch()
  146. }
  147. // 单元格样式
  148. const cellStyle = ({ row, column, rowIndex, columnIndex }: any) => {
  149. // 为所有列设置基本样式
  150. const baseStyle = {
  151. padding: '8px 4px'
  152. }
  153. if (column.property === 'deptNames') {
  154. return {
  155. ...baseStyle,
  156. whiteSpace: 'normal',
  157. wordBreak: 'break-all',
  158. lineHeight: '1.5'
  159. }
  160. }
  161. return baseStyle
  162. }
  163. // 弹窗关闭处理
  164. const handleClosed = () => {
  165. list.value = []
  166. total.value = 0
  167. searchParams.pageNo = 1
  168. }
  169. // 暴露方法给父组件
  170. defineExpose({
  171. open
  172. })
  173. // 监听父组件查询参数变化
  174. watch(
  175. () => props.queryParams.createTime,
  176. (newVal) => {
  177. if (newVal && newVal.length > 0) {
  178. searchParams.createTime = [...newVal]
  179. }
  180. },
  181. { deep: true }
  182. )
  183. </script>
  184. <style scoped>
  185. /* 表格容器确保正确布局 */
  186. .table-container {
  187. width: 100%;
  188. overflow-x: auto;
  189. }
  190. .date-content {
  191. white-space: nowrap;
  192. }
  193. .dept-names-content {
  194. white-space: normal;
  195. word-break: break-all;
  196. line-height: 1.5;
  197. padding: 8px 4px;
  198. }
  199. /* 深度样式修改确保表格正确显示 */
  200. :deep(.el-table) {
  201. table-layout: fixed;
  202. }
  203. :deep(.el-table .el-table__cell) {
  204. box-sizing: border-box;
  205. }
  206. :deep(.el-table .cell) {
  207. white-space: normal;
  208. word-break: break-all;
  209. line-height: 1.5;
  210. padding: 8px 4px;
  211. }
  212. :deep(.el-table td.el-table__cell) {
  213. padding: 8px 4px;
  214. border-bottom: 1px solid var(--el-table-border-color);
  215. }
  216. :deep(.el-table th.el-table__cell) {
  217. padding: 8px 4px;
  218. background-color: var(--el-table-header-bg-color);
  219. }
  220. /* 确保列宽正确分配 */
  221. :deep(.el-table__body colgroup col:nth-child(1)) {
  222. width: 120px;
  223. }
  224. :deep(.el-table__body colgroup col:nth-child(2)) {
  225. width: auto;
  226. }
  227. </style>