index.vue 16 KB

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