index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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="iconfont">&#xe641;</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="iconfont" @click="deluserbyidsFn">&#xe63b;</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: 'buildingType',
  130. format(val) {
  131. if (val == 1) {
  132. return '住宅';
  133. } else if (val == 2) {
  134. return '商用';
  135. } else {
  136. return '--';
  137. }
  138. }
  139. },
  140. {
  141. label: '使用状态',
  142. slot: 'useStatus'
  143. },
  144. {
  145. label: '操作',
  146. slot: 'opt',
  147. width: 150
  148. }
  149. ],
  150. showaddDialog: '',
  151. selectRow: [],
  152. mixins_post: 'post',
  153. isAdd: true,
  154. activeData: {}
  155. };
  156. },
  157. components: {
  158. saveEdits
  159. },
  160. methods: {
  161. lookPage(row) {
  162. this.$router.push({
  163. path: '/housingManagement/details',
  164. query: {
  165. id: row.id
  166. }
  167. });
  168. },
  169. addCommand(command) {
  170. if (command === 'add') {
  171. this.addOrEdit('todo');
  172. }
  173. if (command === 'template') {
  174. this.__exportExcel('/sc-community/excel/download/template', { importType: 'HOUSE' });
  175. return;
  176. }
  177. },
  178. clerOwnerStatus() {
  179. this.showaddDialog = '';
  180. this.activeData = {};
  181. this.isAdd = true;
  182. this.mixins_search();
  183. },
  184. addOrEdit(todo, row) {
  185. if (todo == 'edit') {
  186. this.activeData = row;
  187. this.isAdd = false;
  188. }
  189. this.showaddDialog = todo;
  190. },
  191. deleteRow(row) {
  192. const { communityName, buildingName, unitName, roomNumber } = row;
  193. let title = `您确定要删除“${communityName}${buildingName}${unitName}${roomNumber}”号房间`;
  194. this.$msgBox(title)
  195. .then(() => {
  196. this.$http
  197. .post('/sc-community/assets/house/delete', [row.id])
  198. .then(({ status, msg }) => {
  199. if (0 === status) {
  200. this.$message.success(msg);
  201. this.mixins_search();
  202. } else {
  203. this.$message.error(msg);
  204. }
  205. })
  206. .catch(() => {});
  207. })
  208. .catch(() => {});
  209. },
  210. selectionChange(val) {
  211. this.selectRow = val;
  212. },
  213. deluserbyidsFn() {
  214. //获取选中列表的ids
  215. let ids = [];
  216. if (!this.selectRow.length) {
  217. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  218. return;
  219. }
  220. this.selectRow.forEach((v) => {
  221. ids.push(v.id);
  222. });
  223. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  224. .then(() => {
  225. this.$http.post('/sc-community/assets/house/delete', ids).then(({ status, data, msg }) => {
  226. if (0 === status) {
  227. this.$message({
  228. type: 'success',
  229. message: '删除成功!'
  230. });
  231. this.mixins_search();
  232. } else {
  233. this.$message.error(msg);
  234. }
  235. });
  236. })
  237. .catch(() => {});
  238. },
  239. buildingInformation(data) {
  240. if (!!data.type && data.type == 'community') {
  241. this.mixins_query = {communityId:data.value,buildingType:1};
  242. } else {
  243. this.mixins_query.communityId = data.communityId;
  244. this.mixins_query.id = data.roomId;
  245. this.mixins_query.buildingId = data.buildingId;
  246. this.mixins_query.unitName = data.unitId;
  247. }
  248. this.mixins_search();
  249. },
  250. //导出
  251. exportExcel() {
  252. this.__exportExcel('/sc-community/assets/house/export/excel', this.mixins_query);
  253. },
  254. communityNameList() {
  255. this.$http.get('/sc-community/assets/community/list', {}).then((res) => {
  256. this.$store.commit('setCommunityArray', res.data);
  257. });
  258. }
  259. },
  260. created() {
  261. this.mixins_dataUrl = '/sc-community/assets/house/page'; // 分页查询接口
  262. this.mixins_query = {
  263. buildingType: 1
  264. };
  265. this.communityNameList();
  266. this.mixins_search('search');
  267. }
  268. };
  269. </script>
  270. <style lang="scss" scoped>
  271. .content {
  272. .content-right {
  273. width: calc(100% - 280px);
  274. float: right;
  275. }
  276. }
  277. </style>