index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="content">
  3. <building-tree @buildingInformation="buildingInformation" 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="query_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. data() {
  81. return {
  82. statusOptions: [
  83. { label: '空置', val: 0 },
  84. { label: '居住', val: 1 }
  85. ],
  86. cols: [
  87. {
  88. label: '所属社区',
  89. prop: 'communityName',
  90. width: 120
  91. },
  92. {
  93. label: '楼栋名称',
  94. prop: 'buildingName'
  95. },
  96. {
  97. label: '单元',
  98. prop: 'unitName'
  99. },
  100. {
  101. label: '房屋号',
  102. prop: 'roomNumber'
  103. },
  104. {
  105. label: '建筑面积',
  106. prop: 'buildingArea',
  107. format(val) {
  108. if (!!val) {
  109. return val + '㎡';
  110. } else {
  111. return '--';
  112. }
  113. }
  114. },
  115. {
  116. label: '使用面积',
  117. prop: 'useArea',
  118. format(val) {
  119. if (!!val) {
  120. return val + '㎡';
  121. } else {
  122. return '--';
  123. }
  124. }
  125. },
  126. {
  127. label: '房屋类型',
  128. prop: 'buildingType',
  129. format(val) {
  130. if (val == 1) {
  131. return '住宅';
  132. } else if (val == 2) {
  133. return '商用';
  134. } else {
  135. return '--';
  136. }
  137. }
  138. },
  139. {
  140. label: '使用状态',
  141. slot: 'useStatus'
  142. },
  143. {
  144. label: '操作',
  145. slot: 'opt',
  146. width: 150
  147. }
  148. ],
  149. showaddDialog: '',
  150. selectRow: [],
  151. mixins_post: 'post',
  152. isAdd: true,
  153. activeData: {}
  154. };
  155. },
  156. components: {
  157. saveEdits
  158. },
  159. methods: {
  160. lookPage(row) {
  161. this.$router.push({
  162. path: '/housingManagement/details',
  163. query: {
  164. id: row.id
  165. }
  166. });
  167. },
  168. addCommand(command) {
  169. if (command === 'add') {
  170. this.addOrEdit('todo');
  171. }
  172. if (command === 'template') {
  173. this.__exportExcel('/sc-community/excel/download/template', { importType: 'HOUSE' });
  174. return;
  175. }
  176. },
  177. clerOwnerStatus() {
  178. this.showaddDialog = '';
  179. this.activeData = {};
  180. this.isAdd = true;
  181. this.mixins_search();
  182. },
  183. addOrEdit(todo, row) {
  184. if (todo == 'edit') {
  185. this.activeData = row;
  186. this.isAdd = false;
  187. }
  188. this.showaddDialog = todo;
  189. },
  190. deleteRow(row) {
  191. const { communityName, buildingName, unitName, roomNumber } = row;
  192. let title = `您确定要删除“${communityName}${buildingName}${unitName}${roomNumber}”号房间`;
  193. this.$msgBox(title)
  194. .then(() => {
  195. this.$http
  196. .post('/sc-community/assets/house/delete', [row.id])
  197. .then(({ status, msg }) => {
  198. if (0 === status) {
  199. this.$message.success(msg);
  200. this.mixins_search();
  201. } else {
  202. this.$message.error(msg);
  203. }
  204. })
  205. .catch(() => {});
  206. })
  207. .catch(() => {});
  208. },
  209. selectionChange(val) {
  210. this.selectRow = val;
  211. },
  212. deluserbyidsFn() {
  213. //获取选中列表的ids
  214. let ids = [];
  215. if (!this.selectRow.length) {
  216. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  217. return;
  218. }
  219. this.selectRow.forEach((v) => {
  220. ids.push(v.id);
  221. });
  222. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  223. .then(() => {
  224. this.$http.post('/sc-community/assets/house/delete', ids).then(({ status, data, msg }) => {
  225. if (0 === status) {
  226. this.$message({
  227. type: 'success',
  228. message: '删除成功!'
  229. });
  230. this.mixins_search();
  231. } else {
  232. this.$message.error(msg);
  233. }
  234. });
  235. })
  236. .catch(() => {});
  237. },
  238. buildingInformation(data) {
  239. if (!!data.type && data.type == 'community') {
  240. this.mixins_query.communityId = data.val;
  241. } else {
  242. this.mixins_query.communityId = data.communityId;
  243. this.mixins_query.id = data.roomId;
  244. this.mixins_query.buildingId = data.buildingId;
  245. this.mixins_query.unitName = data.unitId;
  246. }
  247. this.mixins_search();
  248. },
  249. //导出
  250. exportExcel() {
  251. this.__exportExcel('/sc-community/assets/house/export/excel', this.mixins_query);
  252. },
  253. communityNameList() {
  254. this.$http.get('/sc-community/assets/community/list', {}).then((res) => {
  255. this.$store.commit('setCommunityArray', res.data);
  256. });
  257. }
  258. },
  259. created() {
  260. this.mixins_dataUrl = '/sc-community/assets/house/page'; // 分页查询接口
  261. this.mixins_query = {
  262. buildingType: 1
  263. };
  264. this.communityNameList();
  265. this.mixins_search('search');
  266. }
  267. };
  268. </script>
  269. <style lang="scss" scoped>
  270. .content {
  271. .content-right {
  272. width: calc(100% - 280px);
  273. float: right;
  274. }
  275. }
  276. </style>