index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div class="system-dic-container">
  3. <el-card shadow="hover">
  4. <div class="system-user-search mb15">
  5. <el-form :model="tableData.param" ref="queryRef" :inline="true" label-width="68px">
  6. <el-form-item label="所属组织" prop="organizationId">
  7. <el-tree-select
  8. v-model="tableData.param.organizationId"
  9. :data="orgList"
  10. :props="{
  11. label: 'name',
  12. children: 'children'
  13. }"
  14. placeholder="请选择"
  15. node-key="id"
  16. :clearable="true"
  17. check-strictly
  18. style="width: 100%;"
  19. :render-after-expand="true"
  20. size="default"
  21. />
  22. </el-form-item>
  23. <el-form-item label="小区名称" prop="plotId">
  24. <el-select v-model="tableData.param.plotId" @change="onPlotChange" placeholder="选择小区名称" filterable clearable size="default">
  25. <el-option
  26. v-for="item in plotList"
  27. :key="item.id"
  28. :label="item.name"
  29. :value="item.id">
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="楼宇名称" prop="floorId">
  34. <el-select v-model="tableData.param.floorId" @change="onFloorChange" placeholder="选择楼宇名称" filterable clearable size="default">
  35. <el-option
  36. v-for="item in floorList"
  37. :key="item.id"
  38. :label="item.name"
  39. :value="item.id">
  40. </el-option>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="单元名称" prop="unitId">
  44. <el-select v-model="tableData.param.unitId" placeholder="选择单元名称" filterable clearable size="default">
  45. <el-option
  46. v-for="item in unitList"
  47. :key="item.id"
  48. :label="item.name"
  49. :value="item.id">
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="住户名称" prop="name">
  54. <el-input v-model="tableData.param.name" placeholder="请输入住户名称" clearable size="default" style="width: 240px" @keyup.enter="queryList" />
  55. </el-form-item>
  56. <el-form-item>
  57. <el-button size="default" type="primary" class="ml10" @click="queryList">
  58. <el-icon>
  59. <ele-Search />
  60. </el-icon>
  61. 查询
  62. </el-button>
  63. <el-button size="default" @click="resetQuery(queryRef)">
  64. <el-icon>
  65. <ele-Refresh />
  66. </el-icon>
  67. 重置
  68. </el-button>
  69. <el-button size="default" type="success" class="ml10" @click="onOpenDialog()">
  70. <el-icon>
  71. <ele-FolderAdd />
  72. </el-icon>
  73. 新增
  74. </el-button>
  75. <!-- <el-button size="default" type="danger" class="ml10" @click="onRowDel(null)">
  76. <el-icon>
  77. <ele-Delete />
  78. </el-icon>
  79. 删除
  80. </el-button> -->
  81. </el-form-item>
  82. </el-form>
  83. </div>
  84. <el-table :data="tableData.data" v-loading="tableData.loading" style="width: 100%" >
  85. <!-- <el-table-column type="selection" width="55" align="center" /> -->
  86. <el-table-column label="ID" align="center" prop="id" width="60" />
  87. <el-table-column label="组织名称" prop="" min-width="100">
  88. <template #default="{ row }">
  89. {{ row.organizationInfo.name }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="小区名称" prop="" min-width="100">
  93. <template #default="{ row }">
  94. {{ row.plotInfo.name }}
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="楼宇名称" prop="" min-width="100">
  98. <template #default="{ row }">
  99. {{ row.floorInfo.name }}
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="单元名称" prop="name" min-width="100">
  103. <template #default="{ row }">
  104. {{ row.unitInfo.name }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="单元号" prop="number" min-width="100">
  108. <template #default="{ row }">
  109. {{ row.unitInfo.number }}
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="住户姓名" prop="name" min-width="100" />
  113. <el-table-column label="楼层" prop="floorLevel" min-width="100" />
  114. <el-table-column label="房间号" prop="roomNumber" min-width="100" />
  115. <el-table-column label="电话号码" prop="phone" min-width="100" />
  116. <el-table-column label="建筑面积" prop="buildingArea" min-width="100" />
  117. <el-table-column label="实供面积" prop="forRealArea" min-width="100" />
  118. <el-table-column label="更新时间" prop="createdAt" width="180"/>
  119. <el-table-column prop="status" label="启用状态" width="120" align="center">
  120. <template #default="scope">
  121. <el-switch v-model="scope.row.status" inline-prompt :active-value="1" :inactive-value="0" active-text="启" inactive-text="禁" @change="handleStatusChange(scope.row)">
  122. </el-switch>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="操作" width="200" align="center" fixed="right">
  126. <template #default="scope">
  127. <el-button size="small" text type="warning" @click="onOpenDialog(scope.row)">修改</el-button>
  128. <el-button size="small" text type="danger" @click="onRowDel(scope.row)">删除</el-button>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <pagination v-show="tableData.total>0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="queryList" />
  133. </el-card>
  134. <EditDic ref="editDicRef" @queryList="queryList" />
  135. <Detail ref="detailRef" />
  136. </div>
  137. </template>
  138. <script lang="ts">
  139. import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
  140. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  141. import EditDic from './component/edit.vue';
  142. import Detail from './component/detail.vue';
  143. import api from '/@/api/heatingDistrict';
  144. import systemApi from '/@/api/system';
  145. export default defineComponent({
  146. name: 'loop',
  147. components: { EditDic,Detail },
  148. setup() {
  149. const addDicRef = ref();
  150. const editDicRef = ref();
  151. const detailRef=ref();
  152. const queryRef = ref();
  153. const state = reactive({
  154. ids: [],
  155. tableData: {
  156. data: [],
  157. total: 0,
  158. loading: false,
  159. param: {
  160. pageNum: 1,
  161. pageSize: 10,
  162. name: '',
  163. plotId: '',
  164. floorId: '',
  165. unitId: '',
  166. organizationId: '',
  167. status: -1
  168. },
  169. },
  170. });
  171. // 组织
  172. const orgList = ref([])
  173. // 小区
  174. const plotList = ref([])
  175. // 楼宇
  176. const floorList = ref([])
  177. // 单元
  178. const unitList = ref([])
  179. // 初始化表格数据
  180. const initTableData = () => {
  181. queryList();
  182. };
  183. // 获取组织
  184. const getOrgList = () => {
  185. systemApi.org.getList({ name: '', status: -1 }).then((res: any) => {
  186. orgList.value = res;
  187. });
  188. }
  189. // 获取区域
  190. const getPlotList = () => {
  191. api.regionalManage.allList({})
  192. .then((res: any) => {
  193. plotList.value = res.Info || []
  194. })
  195. }
  196. // 获取楼宇
  197. const getFloorList = () => {
  198. api.floor.allList({})
  199. .then((res: any) => {
  200. floorList.value = res.Info || []
  201. })
  202. }
  203. // 获取单元
  204. const getUnitList = () => {
  205. api.unit.getListByFloorId({ floorId: state.tableData.param.floorId })
  206. .then((res: any) => {
  207. (unitList.value as any) = res ? [res] : []
  208. })
  209. }
  210. const queryList = () => {
  211. state.tableData.loading = true
  212. api.resident.getList(state.tableData.param).then((res: any) => {
  213. console.log(res);
  214. state.tableData.data = res.Data || [];
  215. state.tableData.total = res.Total;
  216. state.tableData.loading = false
  217. });
  218. };
  219. const onPlotChange = () => {
  220. floorList.value = []
  221. unitList.value = []
  222. state.tableData.param.floorId = ''
  223. state.tableData.param.unitId = ''
  224. if (state.tableData.param.plotId) {
  225. getFloorList()
  226. }
  227. }
  228. const onFloorChange = () => {
  229. unitList.value = []
  230. state.tableData.param.unitId = ''
  231. if (state.tableData.param.floorId) {
  232. getUnitList()
  233. }
  234. }
  235. //查看详情
  236. const onOpenDetail=(row: any)=>{
  237. detailRef.value.openDialog(row);
  238. }
  239. // 打开新增修改弹窗
  240. const onOpenDialog = (row: any) => {
  241. editDicRef.value.orgList = orgList.value
  242. editDicRef.value.plotList = plotList.value
  243. editDicRef.value.openDialog(row);
  244. };
  245. // 状态修改
  246. const handleStatusChange = (row: any) => {
  247. let text = row.status === 1 ? '启用' : '停用';
  248. ElMessageBox.confirm('确认要"' + text + '":"' + row.name + '"住户吗?', '警告', {
  249. confirmButtonText: '确定',
  250. cancelButtonText: '取消',
  251. type: 'warning',
  252. })
  253. .then(function () {
  254. return api.resident.setStatus(row.id, row.status);
  255. })
  256. .then(() => {
  257. ElMessage.success(text + '成功');
  258. })
  259. .catch(function () {
  260. row.status = row.status === 0 ? 1 : 0;
  261. });
  262. };
  263. // 删除产品
  264. const onRowDel = (row: any) => {
  265. let msg = `此操作将永久删除住户:“${row.name}”,是否继续?`;
  266. ElMessageBox.confirm(msg, '提示', {
  267. confirmButtonText: '确认',
  268. cancelButtonText: '取消',
  269. type: 'warning',
  270. })
  271. .then(() => {
  272. api.resident.del(row.id).then(() => {
  273. ElMessage.success('删除成功');
  274. queryList();
  275. });
  276. })
  277. .catch(() => {});
  278. };
  279. // 页面加载时
  280. onMounted(() => {
  281. initTableData();
  282. getOrgList();
  283. getPlotList()
  284. // getFloorList()
  285. // getUnitList()
  286. });
  287. /** 重置按钮操作 */
  288. const resetQuery = (formEl: FormInstance | undefined) => {
  289. if (!formEl) return;
  290. formEl.resetFields();
  291. queryList();
  292. };
  293. return {
  294. addDicRef,
  295. editDicRef,
  296. detailRef,
  297. queryRef,
  298. onOpenDetail,
  299. onOpenDialog,
  300. onRowDel,
  301. queryList,
  302. resetQuery,
  303. orgList,
  304. plotList,
  305. floorList,
  306. unitList,
  307. onPlotChange,
  308. onFloorChange,
  309. handleStatusChange,
  310. ...toRefs(state),
  311. };
  312. },
  313. });
  314. </script>