index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="content">
  3. <building-tree @buildingInformation="buildingInformation" :buildingType="1" v-if="!showaddDialog"></building-tree>
  4. <div class="content-right" v-if="!showaddDialog">
  5. <div class="search">
  6. <el-input clearable placeholder="房屋号" class="search-input" v-trim v-model="mixins_query.roomNumber"></el-input>
  7. <el-select v-model="mixins_query.useStatus" clearable placeholder="使用状态">
  8. <el-option v-for="item in statusOptions" :label="item.label" :value="item.val" :key="item">{{ item.label }}</el-option>
  9. </el-select>
  10. <el-button
  11. class="search-btn"
  12. type="primary"
  13. @click="mixins_search"
  14. :disabled="mixins_onQuery"
  15. :loading="mixins_onQuery"
  16. icon="el-icon-search"
  17. >搜索
  18. </el-button>
  19. <div class="search-icon">
  20. <template>
  21. <el-dropdown type="primary" @command="addCommand">
  22. <span class="zoniot_font zoniot-icon-tianjia2"></span>
  23. <el-dropdown-menu slot="dropdown" hide-on-click="false" class="device-search-dropdown">
  24. <el-dropdown-item command="add">单个添加</el-dropdown-item>
  25. <el-dropdown-item command="batchAdd">
  26. <div class="upload_div">
  27. <xk-upload class="upload_class" @callback="mixins_search" :params="{ importType: 'HOUSE' }">
  28. <span class="upload_text" slot="content">批量添加</span>
  29. </xk-upload>
  30. </div>
  31. </el-dropdown-item>
  32. <el-dropdown-item command="template">下载模板</el-dropdown-item>
  33. </el-dropdown-menu>
  34. </el-dropdown>
  35. </template>
  36. <el-tooltip class="item" effect="light" placement="bottom" content="删除">
  37. <i class="zoniot_font zoniot-icon-shanchu2" @click="deluserbyidsFn"></i>
  38. </el-tooltip>
  39. <el-tooltip class="item" effect="light" placement="bottom" content="导出">
  40. <i class="zoniot_font zoniot-icon-daochu2" @click="exportExcel()"></i>
  41. </el-tooltip>
  42. </div>
  43. </div>
  44. <zz-table
  45. :settings="{ showCheckbox: true, showIndex: true, stripe: true }"
  46. :cols="cols"
  47. :loading="mixins_onQuery"
  48. :data="mixins_list"
  49. :pageset="mixins_pageset"
  50. @page-change="pageChange"
  51. @selection-change="selectionChange"
  52. >
  53. <template slot-scope="scope" slot="useStatus">
  54. <span v-if="scope.row.useStatus == 0">空置</span>
  55. <span v-if="scope.row.useStatus == 1">居住</span>
  56. </template>
  57. <template slot-scope="scope" slot="opt" class="opt">
  58. <div class="opt">
  59. <el-tooltip effect="light" placement="bottom" content="编辑">
  60. <i class="zoniot_font zoniot-icon-bianji" @click="addOrEdit('edit', scope.row)"></i>
  61. </el-tooltip>
  62. <el-tooltip effect="light" placement="bottom" content="删除">
  63. <i class="zoniot_font zoniot-icon-shanchu redText" @click="deleteRow(scope.row)"></i>
  64. </el-tooltip>
  65. <el-tooltip class="item" effect="light" placement="bottom" content="查看">
  66. <i class="zoniot_font zoniot-icon-xiangqing" @click="lookPage(scope.row)"></i>
  67. </el-tooltip>
  68. </div>
  69. </template>
  70. </zz-table>
  71. </div>
  72. <save-edits v-else :params="activeData" @clerOwnerStatus="clerOwnerStatus" :isAdd="isAdd"></save-edits>
  73. </div>
  74. </template>
  75. <script>
  76. import list from '@utils/list.js';
  77. import saveEdits from './saveEdits.vue';
  78. export default {
  79. mixins: [list],
  80. name: 'housingManagement',
  81. data() {
  82. return {
  83. statusOptions: [
  84. { label: '空置', val: 0 },
  85. { label: '居住', val: 1 }
  86. ],
  87. cols: [
  88. {
  89. label: '所属社区',
  90. prop: 'communityName',
  91. width: 120
  92. },
  93. {
  94. label: '楼栋名称',
  95. prop: 'buildingName'
  96. },
  97. {
  98. label: '单元',
  99. prop: 'unitName'
  100. },
  101. {
  102. label: '房屋号',
  103. prop: 'roomNumber'
  104. },
  105. {
  106. label: '建筑面积',
  107. prop: 'buildingArea',
  108. format(val) {
  109. if (!!val) {
  110. return val + '㎡';
  111. } else {
  112. return '--';
  113. }
  114. }
  115. },
  116. {
  117. label: '使用面积',
  118. prop: 'useArea',
  119. format(val) {
  120. if (!!val) {
  121. return val + '㎡';
  122. } else {
  123. return '--';
  124. }
  125. }
  126. },
  127. {
  128. label: '房屋类型',
  129. prop: 'buildingTypeDict',
  130. },
  131. {
  132. label: '使用状态',
  133. slot: 'useStatus'
  134. },
  135. {
  136. label: '操作',
  137. slot: 'opt',
  138. width: 150
  139. }
  140. ],
  141. showaddDialog: '',
  142. selectRow: [],
  143. mixins_post: 'post',
  144. isAdd: true,
  145. activeData: {}
  146. };
  147. },
  148. components: {
  149. saveEdits
  150. },
  151. methods: {
  152. lookPage(row) {
  153. this.$router.push({
  154. path: '/housingManagement/details',
  155. query: {
  156. id: row.id
  157. }
  158. });
  159. },
  160. addCommand(command) {
  161. if (command === 'add') {
  162. this.addOrEdit('todo');
  163. }
  164. if (command === 'template') {
  165. this.__exportExcel('/sc-community/excel/download/template', { importType: 'HOUSE' });
  166. return;
  167. }
  168. },
  169. clerOwnerStatus() {
  170. this.showaddDialog = '';
  171. this.activeData = {};
  172. this.isAdd = true;
  173. this.mixins_search();
  174. },
  175. addOrEdit(todo, row) {
  176. if (todo == 'edit') {
  177. this.activeData = row;
  178. this.isAdd = false;
  179. }
  180. this.showaddDialog = todo;
  181. },
  182. deleteRow(row) {
  183. const { communityName, buildingName, unitName, roomNumber } = row;
  184. let title = `您确定要删除“${communityName}${buildingName}${unitName}${roomNumber}”号房间`;
  185. this.$msgBox(title)
  186. .then(() => {
  187. this.$http
  188. .post('/sc-community/assets/house/delete', [row.id])
  189. .then(({ status, msg }) => {
  190. if (0 === status) {
  191. this.$message.success(msg);
  192. this.mixins_search();
  193. } else {
  194. this.$message.error(msg);
  195. }
  196. })
  197. .catch(() => {});
  198. })
  199. .catch(() => {});
  200. },
  201. selectionChange(val) {
  202. this.selectRow = val;
  203. },
  204. deluserbyidsFn() {
  205. //获取选中列表的ids
  206. let ids = [];
  207. if (!this.selectRow.length) {
  208. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  209. return;
  210. }
  211. this.selectRow.forEach((v) => {
  212. ids.push(v.id);
  213. });
  214. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  215. .then(() => {
  216. this.$http.post('/sc-community/assets/house/delete', ids).then(({ status, data, msg }) => {
  217. if (0 === status) {
  218. this.$message({
  219. type: 'success',
  220. message: '删除成功!'
  221. });
  222. this.mixins_search();
  223. } else {
  224. this.$message.error(msg);
  225. }
  226. });
  227. })
  228. .catch(() => {});
  229. },
  230. buildingInformation(data) {
  231. if (!!data.type && data.type == 'community') {
  232. this.mixins_query = { communityId: data.value, buildingType: 1 };
  233. } else {
  234. this.mixins_query.communityId = data.communityId;
  235. this.mixins_query.id = data.roomId;
  236. this.mixins_query.buildingId = data.buildingId;
  237. this.mixins_query.unitName = data.unitId;
  238. }
  239. this.mixins_search();
  240. },
  241. //导出
  242. exportExcel() {
  243. this.__exportExcel('/sc-community/assets/house/export/excel', this.mixins_query);
  244. },
  245. communityNameList() {
  246. this.$http.get('/sc-community/assets/community/list', {}).then((res) => {
  247. this.$store.commit('setCommunityArray', res.data);
  248. });
  249. }
  250. },
  251. created() {
  252. this.mixins_dataUrl = '/sc-community/assets/house/page'; // 分页查询接口
  253. this.mixins_query = {
  254. buildingType: 1
  255. };
  256. this.communityNameList();
  257. this.mixins_search('search');
  258. }
  259. };
  260. </script>
  261. <style lang="scss" scoped>
  262. .content {
  263. .content-right {
  264. width: calc(100% - 280px);
  265. float: right;
  266. }
  267. }
  268. </style>