index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <script setup>
  2. import { ElMessage } from 'element-plus';
  3. import { useRouter } from 'vue-router';
  4. import SearchItemWrapper from '@/components/SearchItemWrapper';
  5. import useTableHeight from '@/composables/useTableHeight';
  6. import { noticeApi } from '@/api/voice/notice';
  7. const { tableContainer, tableMaxHeight } = useTableHeight();
  8. const router = useRouter();
  9. const loading = ref(false);
  10. const dataPickerValue = ref([]);
  11. const total = ref(0);
  12. const tableData = ref([]);
  13. const queryParams = ref({
  14. pageNum: 1,
  15. pageSize: 10,
  16. neighbourhoodName: '', // 小区名称
  17. status: '' // 停水状态
  18. })
  19. const statusEnum = {
  20. // 0: '未知',
  21. 1: '待停水',
  22. 2: '停水中',
  23. 3: '已恢复'
  24. }
  25. // 气泡弹窗 - 是否删除该项
  26. const onConfirm = async ({ id }) => {
  27. await noticeApi.delWater(id);
  28. ElMessage.success('删除停水公告成功');
  29. getList();
  30. }
  31. const getList = async () => {
  32. const [timeBegin, timeEnd] = dataPickerValue.value || [];
  33. loading.value = true;
  34. const { rows, total: t } = await noticeApi.getWaterList({...queryParams.value, timeBegin, timeEnd});
  35. tableData.value = rows.map(item => ({
  36. ...item,
  37. statusText: statusEnum[item.status]
  38. }));
  39. loading.value = false;
  40. total.value = t;
  41. };
  42. const jumpDetails = ({ id }) => {
  43. router.push({
  44. path: "notice/add",
  45. query: { id }
  46. });
  47. }
  48. // 跳转 - 添加停水公告
  49. const handleJumpWaterAdd = () => {
  50. router.push("notice/add");
  51. }
  52. // 清除检索条件
  53. const handleCleanOptions = () => {
  54. queryParams.value = {
  55. pageNum: 1,
  56. pageSize: 10,
  57. neighbourhoodName: '', // 小区名称
  58. status: '' // 停水状态
  59. };
  60. dataPickerValue.value = [];
  61. getList();
  62. }
  63. onMounted(() => {
  64. getList();
  65. })
  66. </script>
  67. <template>
  68. <div class="notice-viewprot">
  69. <div class="search-card">
  70. <el-row :gutter="24" class="mb-[24px]">
  71. <el-col :span="6">
  72. <SearchItemWrapper>
  73. <el-input class="search-input" placeholder="小区名称" v-model="queryParams.neighbourhoodName"></el-input>
  74. </SearchItemWrapper>
  75. </el-col>
  76. <el-col :span="6">
  77. <SearchItemWrapper label="停水状态">
  78. <el-select v-model="queryParams.status" placeholder="Select" size="large" :empty-values="[null, undefined]">
  79. <el-option label="全部" value="" />
  80. <el-option :label="val" :value="key" v-for="val, key in statusEnum" :key="val" />
  81. </el-select>
  82. </SearchItemWrapper>
  83. </el-col>
  84. <el-col :span="6">
  85. <SearchItemWrapper label="停水时间">
  86. <el-date-picker v-model="dataPickerValue" type="daterange" range-separator="-" start-placeholder="起始日期"
  87. end-placeholder="结束日期" style="width: 100%;" :editable="false" value-format="YYYY-MM-DD" :value-on-clear="null"/>
  88. </SearchItemWrapper>
  89. </el-col>
  90. <el-col :span="6">
  91. <div class="flex items-center justify-end space-x-[10px]">
  92. <div class="custom-btn custom-btn_primary" @click="getList">搜索</div>
  93. <div class="custom-btn custom-btn_default" @click="handleCleanOptions">重置</div>
  94. </div>
  95. </el-col>
  96. </el-row>
  97. </div>
  98. <div class="add-btn-card">
  99. <div class="btn space-x-[5px]" @click="handleJumpWaterAdd">
  100. <el-icon><CirclePlus /></el-icon>
  101. <span>添加停水公告</span>
  102. </div>
  103. </div>
  104. <div class="table-card">
  105. <div style="height: 100%;" ref="tableContainer">
  106. <el-table :data="tableData" style="width: 100%" :max-height="tableMaxHeight" v-loading="loading">
  107. <el-table-column prop="reason" label="停水原因" align="center" :width="320" :show-overflow-tooltip="{'popper-class': 'custom-tooltip-popper'}" />
  108. <el-table-column prop="timeBegin" label="停水时间" align="center" />
  109. <el-table-column prop="timeEnd" label="恢复供水时间" align="center" />
  110. <el-table-column prop="neighbourhoodName" label="停水范围(小区)" align="center" :show-overflow-tooltip="{'popper-class': 'custom-tooltip-popper'}" ></el-table-column>
  111. <el-table-column prop="statusText" label="停水状态" align="center" />
  112. <el-table-column prop="createBy" label="创建人" align="center" />
  113. <el-table-column prop="createTime" label="创建时间" align="center" />
  114. <el-table-column prop="address" label="操作" align="center" fixed="right">
  115. <template #default="scope">
  116. <div class="flex justify-center space-x-[20px]">
  117. <span class="text-[#165DFF] cursor-pointer" @click="jumpDetails(scope.row)">编辑</span>
  118. <span class="text-[#165DFF] cursor-pointer">
  119. <el-popconfirm
  120. width="220"
  121. icon-color="#626AEF"
  122. title="确认要删除本条数据吗?"
  123. @confirm="onConfirm(scope.row)"
  124. >
  125. <template #reference>
  126. <span>删除</span>
  127. </template>
  128. <template #actions="{ confirm, cancel }">
  129. <el-button size="small" @click="cancel">否</el-button>
  130. <el-button type="primary" size="small" @click="confirm">是</el-button>
  131. </template>
  132. </el-popconfirm>
  133. </span>
  134. </div>
  135. </template>
  136. </el-table-column>
  137. </el-table>
  138. <pagination
  139. v-show="total >= 0"
  140. :total="total"
  141. v-model:page="queryParams.pageNum"
  142. v-model:limit="queryParams.pageSize"
  143. @pagination="getList"
  144. />
  145. </div>
  146. </div>
  147. </div>
  148. </template>
  149. <style lang="scss" scoped>
  150. .notice-viewprot {
  151. display: flex;
  152. flex-flow: column;
  153. width: 100%;
  154. height: 100%;
  155. padding: 28px 24px 18px 24px;
  156. border-radius: 8px;
  157. background: #fff;
  158. .search-card {
  159. border-bottom: 1px dashed #E5E6EB;
  160. }
  161. .add-btn-card {
  162. display: flex;
  163. justify-content: flex-start;
  164. margin: 20px 0;
  165. .btn {
  166. display: flex;
  167. justify-content: center;
  168. align-items: center;
  169. font-size: 14px;
  170. border-radius: 8px;
  171. padding: 7px 16px;
  172. background: #165DFF;
  173. color: #fff;
  174. cursor: pointer;
  175. }
  176. }
  177. .table-card {
  178. height: 100%;
  179. }
  180. }
  181. </style>
  182. <style lang="scss">
  183. .custom-tooltip-popper {
  184. width: 500px;
  185. }
  186. </style>