index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div class="system-dic-container">
  3. <div>
  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="name">
  7. <el-input v-model="tableData.param.name" placeholder="请输入小区名称" clearable size="default" style="width: 240px" @keyup.enter="queryList" />
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button size="default" type="primary" class="ml10" @click="queryList">
  11. <el-icon>
  12. <ele-Search />
  13. </el-icon>
  14. 查询
  15. </el-button>
  16. <el-button size="default" @click="resetQuery(queryRef)">
  17. <el-icon>
  18. <ele-Refresh />
  19. </el-icon>
  20. 重置
  21. </el-button>
  22. <el-button size="default" type="success" class="ml10" @click="onOpenAddDic">
  23. <el-icon>
  24. <ele-FolderAdd />
  25. </el-icon>
  26. 新增
  27. </el-button>
  28. <!-- <el-button size="default" type="danger" class="ml10" @click="onRowDel(null)">
  29. <el-icon>
  30. <ele-Delete />
  31. </el-icon>
  32. 删除
  33. </el-button> -->
  34. </el-form-item>
  35. </el-form>
  36. </div>
  37. <el-table :data="tableData.data" v-loading="tableData.loading">
  38. <!-- <el-table-column type="selection" width="55" align="center" /> -->
  39. <el-table-column label="ID" align="center" prop="id" width="60" />
  40. <el-table-column label="小区名称" prop="name" min-width="100" />
  41. <el-table-column label="区域名称" prop="" min-width="100">
  42. <template #default="{ row }">
  43. {{ row.SysOrganization.name }}
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="更新时间" prop="createdAt" width="180" />
  47. <el-table-column prop="status" label="启用状态" width="120" align="center">
  48. <template #default="scope">
  49. <el-switch v-model="scope.row.status" inline-prompt :active-value="1" :inactive-value="0" active-text="启" inactive-text="禁" @change="handleStatusChange(scope.row)">
  50. </el-switch>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="操作" width="200" align="center" fixed="right">
  54. <template #default="scope">
  55. <el-button size="small" text type="warning" @click="onOpenEditDic(scope.row)">修改</el-button>
  56. <el-button size="small" text type="danger" @click="onRowDel(scope.row)">删除</el-button>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. <pagination v-show="tableData.total>0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="queryList" />
  61. </div>
  62. <EditDic ref="editDicRef" @queryList="handleFinish()" />
  63. <Detail ref="detailRef" />
  64. </div>
  65. </template>
  66. <script lang="ts">
  67. import { toRefs, reactive, onMounted, ref, defineComponent, watch } from 'vue';
  68. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  69. import EditDic from './component/edit.vue';
  70. import Detail from './component/detail.vue';
  71. import api from '/@/api/heatingDistrict';
  72. import systemApi from '/@/api/system';
  73. import { nextTick } from 'process';
  74. export default defineComponent({
  75. name: 'loop',
  76. components: { EditDic,Detail },
  77. props: {
  78. organizationId: {
  79. default: ''
  80. }
  81. },
  82. setup(prop, { emit }) {
  83. const addDicRef = ref();
  84. const editDicRef = ref();
  85. const detailRef=ref();
  86. const queryRef = ref();
  87. const state = reactive({
  88. ids: [],
  89. tableData: {
  90. data: [],
  91. total: 0,
  92. loading: false,
  93. param: {
  94. pageNum: 1,
  95. pageSize: 10,
  96. name: '',
  97. organizationId: '',
  98. status: -1
  99. },
  100. },
  101. });
  102. const queryList = () => {
  103. state.tableData.loading = true
  104. api.regionalManage.getList(state.tableData.param).then((res: any) => {
  105. console.log(res);
  106. state.tableData.data = res.Info || [];
  107. state.tableData.total = res.Total;
  108. state.tableData.loading = false
  109. });
  110. };
  111. const handleFinish = () => {
  112. emit('finish')
  113. queryList()
  114. }
  115. watch(() => prop.organizationId, () => {
  116. state.tableData.param.organizationId = prop.organizationId
  117. queryList()
  118. }, {
  119. deep: true,
  120. immediate: true
  121. })
  122. //查看详情
  123. const onOpenDetail=(row: any)=>{
  124. detailRef.value.openDialog(row);
  125. }
  126. // 打开新增产品弹窗
  127. const onOpenAddDic = () => {
  128. editDicRef.value.openDialog(null, prop.organizationId);
  129. };
  130. // 打开修改产品弹窗
  131. const onOpenEditDic = (row: any) => {
  132. editDicRef.value.openDialog(row);
  133. };
  134. // 状态修改
  135. const handleStatusChange = (row: any) => {
  136. let text = row.status === 1 ? '启用' : '停用';
  137. ElMessageBox.confirm('确认要"' + text + '":"' + row.name + '"小区吗?', '警告', {
  138. confirmButtonText: '确定',
  139. cancelButtonText: '取消',
  140. type: 'warning',
  141. })
  142. .then(function () {
  143. return api.regionalManage.setStatus(row.id, row.status);
  144. })
  145. .then(() => {
  146. ElMessage.success(text + '成功');
  147. })
  148. .catch(function () {
  149. row.status = row.status === 0 ? 1 : 0;
  150. });
  151. };
  152. // 删除产品
  153. const onRowDel = (row: any) => {
  154. let msg = `此操作将永久删除小区:“${row.name}”,是否继续?`;
  155. ElMessageBox.confirm(msg, '提示', {
  156. confirmButtonText: '确认',
  157. cancelButtonText: '取消',
  158. type: 'warning',
  159. })
  160. .then(() => {
  161. api.regionalManage.del(row.id).then(() => {
  162. ElMessage.success('删除成功');
  163. queryList();
  164. });
  165. })
  166. .catch(() => {});
  167. };
  168. /** 重置按钮操作 */
  169. const resetQuery = (formEl: FormInstance | undefined) => {
  170. if (!formEl) return;
  171. formEl.resetFields();
  172. queryList();
  173. };
  174. return {
  175. addDicRef,
  176. editDicRef,
  177. detailRef,
  178. queryRef,
  179. onOpenDetail,
  180. onOpenAddDic,
  181. onOpenEditDic,
  182. onRowDel,
  183. queryList,
  184. resetQuery,
  185. handleStatusChange,
  186. handleFinish,
  187. ...toRefs(state),
  188. };
  189. },
  190. });
  191. </script>