index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div class="content main">
  3. <organ-tree
  4. @organId="currentOrganId"
  5. v-if="!ownerStatus"
  6. :buildingType="1"
  7. ></organ-tree>
  8. <div
  9. class="content-right"
  10. v-if="!ownerStatus"
  11. >
  12. <div class="search">
  13. <el-input
  14. clearable
  15. placeholder="输入房东姓名或手机号"
  16. class="search-input"
  17. v-trim
  18. v-model.trim="mixins_query.name"
  19. ></el-input>
  20. <el-button
  21. class="search-btn"
  22. type="primary"
  23. @click="mixins_search()"
  24. :disabled="mixins_onQuery"
  25. :loading="mixins_onQuery"
  26. icon="el-icon-search"
  27. >查询</el-button>
  28. <div class="search-icon">
  29. <template>
  30. <el-dropdown
  31. type="primary"
  32. @command="addCommand"
  33. >
  34. <span class="zoniot_font zoniot-icon-tianjia2"></span>
  35. <el-dropdown-menu
  36. slot="dropdown"
  37. hide-on-click="false"
  38. class="device-search-dropdown"
  39. >
  40. <el-dropdown-item command="add">单个添加</el-dropdown-item>
  41. <el-dropdown-item command="batchAdd">
  42. <div class="upload_div">
  43. <xk-upload
  44. class="upload_class"
  45. @callback="mixins_search"
  46. :params="{ importType: 'LANDLORD' }"
  47. >
  48. <span slot="content">批量添加</span>
  49. </xk-upload>
  50. </div>
  51. </el-dropdown-item>
  52. <el-dropdown-item command="template">下载模板</el-dropdown-item>
  53. </el-dropdown-menu>
  54. </el-dropdown>
  55. </template>
  56. <el-tooltip
  57. class="item"
  58. effect="light"
  59. placement="bottom"
  60. content="删除"
  61. >
  62. <i
  63. class="zoniot_font zoniot-icon-shanchu2"
  64. @click="deluserbyidsFn"
  65. ></i>
  66. </el-tooltip>
  67. <el-tooltip
  68. class="item"
  69. effect="light"
  70. placement="bottom"
  71. content="导出"
  72. >
  73. <i
  74. class="zoniot_font zoniot-icon-daochu2"
  75. @click="exportExcel"
  76. ></i>
  77. </el-tooltip>
  78. </div>
  79. </div>
  80. <zz-table
  81. :settings="{ showCheckbox: true, showIndex: true, stripe: true }"
  82. :cols="cols"
  83. :loading="mixins_onQuery"
  84. :data="mixins_list"
  85. :pageset="mixins_pageset"
  86. @page-change="pageChange"
  87. @selection-change="selectionChange"
  88. >
  89. <template
  90. slot-scope="scope"
  91. slot="communityName"
  92. >
  93. <!-- <span>{{scope.row.houseList}}</span> -->
  94. <div
  95. class="table-list"
  96. v-for="(item, index) in scope.row.buildingList"
  97. :key="index"
  98. >{{ item.communityName }}</div>
  99. </template>
  100. <template
  101. slot-scope="scope"
  102. slot="buildingName"
  103. >
  104. <div
  105. class="table-list"
  106. v-for="(item, index) in scope.row.buildingList"
  107. :key="index"
  108. >{{ item.buildingName }}</div>
  109. </template>
  110. <template
  111. slot-scope="scope"
  112. slot="houseName"
  113. >
  114. <div
  115. class="table-list"
  116. v-for="(item, index) in scope.row.buildingList"
  117. :key="index"
  118. >{{ item.houseName != null ? item.houseName : '-'}}</div>
  119. </template>
  120. <template
  121. slot-scope="scope"
  122. slot="area"
  123. >
  124. <div
  125. class="table-list"
  126. v-for="(item, index) in scope.row.buildingList"
  127. :key="index"
  128. >{{ item.area }}</div>
  129. </template>
  130. <template
  131. slot-scope="scope"
  132. slot="opt"
  133. >
  134. <div class="opt">
  135. <el-tooltip
  136. class="item"
  137. effect="light"
  138. placement="bottom"
  139. content="编辑"
  140. >
  141. <i
  142. class="zoniot_font zoniot-icon-bianji"
  143. @click="addOrEdit('edit', scope.row)"
  144. ></i>
  145. </el-tooltip>
  146. <el-tooltip
  147. class="item"
  148. effect="light"
  149. placement="bottom"
  150. content="删除"
  151. >
  152. <i
  153. class="zoniot_font zoniot-icon-shanchu redText"
  154. @click="deleteRow(scope.row)"
  155. ></i>
  156. </el-tooltip>
  157. </div>
  158. </template>
  159. </zz-table>
  160. </div>
  161. <add-owner
  162. v-else
  163. :params="activeData"
  164. @clerOwnerStatus="clerOwnerStatus"
  165. :isAdd="isAdd"
  166. ></add-owner>
  167. </div>
  168. </template>
  169. <script>
  170. import list from '@/js/list.js';
  171. import addOwner from './stepPage/add.vue'
  172. export default {
  173. mixins: [list],
  174. components: { addOwner },
  175. data () {
  176. return {
  177. ownerStatus: '',
  178. currentId: '',
  179. activeData: {},
  180. selectRow: [],
  181. isAdd: true,
  182. mixins_query: {
  183. name: ''
  184. },
  185. cols: [
  186. {
  187. label: '房东姓名',
  188. prop: 'name'
  189. },
  190. {
  191. label: '手机号',
  192. prop: 'phone'
  193. },
  194. {
  195. label: '社区',
  196. prop: 'communityName',
  197. slot: 'communityName'
  198. },
  199. {
  200. label: '楼栋',
  201. prop: 'buildingName',
  202. slot: 'buildingName'
  203. },
  204. {
  205. label: '房屋',
  206. prop: 'houseName',
  207. slot: 'houseName'
  208. },
  209. {
  210. label: '物业计费面积',
  211. prop: 'area',
  212. slot: 'area'
  213. }, {
  214. label: '操作',
  215. prop: 'id',
  216. slot: 'opt',
  217. width: 130
  218. }
  219. ]
  220. }
  221. },
  222. methods: {
  223. clerOwnerStatus () {
  224. this.ownerStatus = '';
  225. this.activeData = '';
  226. this.isAdd = true;
  227. this.mixins_search();
  228. },
  229. addOrEdit (todo, row) {
  230. if (todo == 'edit') {
  231. this.activeData = row.id;
  232. this.isAdd = false;
  233. }
  234. this.ownerStatus = todo;
  235. },
  236. currentOrganId (data) {
  237. this.currentId = data || '';
  238. },
  239. addCommand (command) {
  240. if (command === 'add') {
  241. this.addOrEdit('add');
  242. // alert(command)
  243. return;
  244. }
  245. if (command === 'template') {
  246. this.__exportExcel('/czc-community/landlord/downTemplate', { importType: 'LANDLORD' });
  247. return;
  248. }
  249. },
  250. getNationArray (type) {
  251. this.$http.postForm('/czc-community/scResident/option', { type: type }).then(({ status, data, msg }) => {
  252. if (status === 0 && data) {
  253. if (type == 'nation') {
  254. this.$store.commit('setNationArray', data);
  255. } else if (type == 'native') {
  256. this.$store.commit('setNativeArray', data);
  257. }
  258. }
  259. });
  260. },
  261. selectionChange (val) {
  262. this.selectRow = val;
  263. },
  264. deluserbyidsFn () {
  265. let ids = [];
  266. if (!this.selectRow.length) {
  267. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  268. return;
  269. }
  270. this.selectRow.forEach((v) => {
  271. ids.push(v.id);
  272. });
  273. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  274. .then(() => {
  275. this.$http.post('/czc-community/landlord/batchDelete', ids).then(({ status, data, msg }) => {
  276. if (0 === status) {
  277. this.$message({
  278. type: 'success',
  279. message: '删除成功!'
  280. });
  281. this.mixins_search();
  282. }
  283. });
  284. })
  285. .catch(() => { });
  286. },
  287. exportExcel () {
  288. this.__exportExcel('/czc-community/landlord/getDataExcel', this.mixins_query);
  289. },
  290. deleteRow (row) {
  291. const { name } = row;
  292. let title = `您确定要删除住户“${name}”`;
  293. this.$msgBox(title)
  294. .then(() => {
  295. this.$http
  296. .postForm('/czc-community/landlord/delete', { id: row.id })
  297. .then(({ status, msg }) => {
  298. this.$delete(row, 'onDelete');
  299. if (0 === status) {
  300. this.$message.success(msg);
  301. this.mixins_search('del');
  302. } else {
  303. this.$message.error(msg);
  304. }
  305. })
  306. .catch(() => {
  307. this.$delete(row, 'onDelete');
  308. });
  309. })
  310. .catch(() => { });
  311. },
  312. },
  313. created () {
  314. if (this.$store.getters['getNationArray'].length === 0) {
  315. this.getNationArray('nation');
  316. }
  317. if (this.$store.getters['getNativeArray'].length === 0) {
  318. this.getNationArray('native');
  319. }
  320. this.mix_path = ''; // 权限
  321. this.mixins_dataUrl = '/czc-community/landlord/page'; // 分页查询接口
  322. this.mixins_query = {
  323. questParams: ''
  324. };
  325. this.mixins_search('search');
  326. },
  327. watch: {
  328. currentId (newValue, oldValue) {
  329. this.mixins_query.communityId = '';
  330. this.mixins_query.buildingId = '';
  331. this.mixins_query.unitName = '';
  332. this.mixins_query.roomNumber = '';
  333. if (newValue.type) {
  334. let newValueIds = newValue.id.split('-');
  335. if (newValue.type === 'community') {
  336. this.mixins_query.communityId = newValueIds[0];
  337. } else if (newValue.type === 'building') {
  338. this.mixins_query.buildingId = newValueIds[1];
  339. } else if (newValue.type === 'unit') {
  340. this.mixins_query.buildingId = newValueIds[1];
  341. this.mixins_query.unitName = newValueIds[2];
  342. } else if (newValue.type === 'room') {
  343. this.mixins_query.buildingId = newValueIds[1];
  344. this.mixins_query.roomNumber = newValueIds[newValueIds.length - 1];
  345. }
  346. }
  347. this.thisLeftData = newValue;
  348. this.mixins_search();
  349. }
  350. },
  351. }
  352. </script>