index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <div class="content main">
  3. <organ-tree @organId="currentOrganId" v-if="!ownerStatus" :buildingType="1"></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 }}-{{ CheckChinese(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 addOwner from './stepPage/newAdd.vue';
  121. import Index from '../../components/mapPopup/index.vue';
  122. export default {
  123. mixins: [list],
  124. name: 'ownerManagement',
  125. components: { addOwner, Index },
  126. data() {
  127. return {
  128. ownerStatus: '',
  129. statusOptions: [],
  130. currentId: '',
  131. cols: [
  132. {
  133. label: '姓名',
  134. prop: 'name'
  135. },
  136. {
  137. label: '手机号',
  138. prop: 'phone'
  139. },
  140. {
  141. label: '身份证号',
  142. prop: 'idNumber'
  143. },
  144. {
  145. label: '住户类型',
  146. prop: 'householdType',
  147. slot: 'householdType',
  148. format(val) {
  149. if (val == 1) {
  150. return '业主';
  151. } else if (val == 2) {
  152. return '亲属';
  153. } else if (val == 3) {
  154. return '租客';
  155. }
  156. }
  157. },
  158. {
  159. label: '社区名称',
  160. prop: 'communityName',
  161. slot: 'communityName'
  162. },
  163. {
  164. label: '房屋地址',
  165. prop: 'roomNumber',
  166. slot: 'roomNumber'
  167. },
  168. {
  169. label: '状态',
  170. prop: 'residentStatus',
  171. slot: 'residentStatus',
  172. format(val) {
  173. if (val == 1) {
  174. return '在住';
  175. } else {
  176. return '已注销';
  177. }
  178. }
  179. },
  180. {
  181. label: '入住时间',
  182. prop: 'checkInDate',
  183. slot: 'checkInDate'
  184. },
  185. {
  186. label: '操作',
  187. prop: 'id',
  188. slot: 'opt',
  189. width: '200'
  190. }
  191. ],
  192. householdType: [
  193. {
  194. status: 1,
  195. label: '业主'
  196. },
  197. {
  198. status: 2,
  199. label: '亲属'
  200. },
  201. {
  202. status: 3,
  203. label: '租客'
  204. }
  205. ],
  206. residentStatus: [
  207. {
  208. status: 0,
  209. label: '已注销'
  210. },
  211. {
  212. status: 1,
  213. label: '在住'
  214. }
  215. ],
  216. activeData: {},
  217. isAdd: true,
  218. selectRow: [],
  219. thisLeftData: {}
  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;
  232. this.isAdd = false;
  233. }
  234. this.ownerStatus = todo;
  235. },
  236. deleteRow(row) {
  237. const { name } = row;
  238. let title = `您确定要删除住户“${name}”`;
  239. this.$msgBox(title)
  240. .then(() => {
  241. this.$http
  242. .postForm('/sc-community/scResident/delete', { id: row.id })
  243. .then(({ status, msg }) => {
  244. this.$delete(row, 'onDelete');
  245. if (0 === status) {
  246. this.$message.success(msg);
  247. this.mixins_search('del');
  248. } else {
  249. this.$message.error(msg);
  250. }
  251. })
  252. .catch(() => {
  253. this.$delete(row, 'onDelete');
  254. });
  255. })
  256. .catch(() => {});
  257. },
  258. lookPage(row) {
  259. this.$router.push({
  260. path: '/ownerManagement/details',
  261. query: {
  262. id: row.id
  263. }
  264. });
  265. },
  266. cancellation(row) {
  267. const { buildingName, unitName, roomNumber } = row;
  268. let status = 0;
  269. if (row.residentStatus === 0) {
  270. status = 1;
  271. }
  272. let title = `您确定要修改状态住户“${buildingName}${
  273. unitName.indexOf('单元') === -1 ? unitName + '单元' : unitName
  274. }${roomNumber}”`;
  275. this.$msgBox('是否修改住户状态', title)
  276. .then(() => {
  277. this.$http
  278. .postForm('/sc-community/scResident/operationResident', { type: status, id: row.id })
  279. .then(({ status, msg }) => {
  280. if (0 === status) {
  281. this.$message.success(msg);
  282. this.mixins_search('del');
  283. } else {
  284. this.$message.error(msg);
  285. }
  286. })
  287. .catch(() => {});
  288. })
  289. .catch(() => {});
  290. },
  291. currentOrganId(data) {
  292. this.currentId = data || '';
  293. },
  294. selectionChange(val) {
  295. this.selectRow = val;
  296. },
  297. deluserbyidsFn() {
  298. //获取选中列表的ids
  299. let ids = [];
  300. if (!this.selectRow.length) {
  301. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  302. return;
  303. }
  304. this.selectRow.forEach((v) => {
  305. ids.push(v.id);
  306. });
  307. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  308. .then(() => {
  309. this.$http.post('/sc-community/scResident/batchDelete', ids).then(({ status, data, msg }) => {
  310. if (0 === status) {
  311. this.$message({
  312. type: 'success',
  313. message: '删除成功!'
  314. });
  315. this.mixins_search();
  316. }
  317. });
  318. })
  319. .catch(() => {});
  320. },
  321. addCommand(command) {
  322. if (command === 'add') {
  323. this.addOrEdit('add');
  324. return;
  325. }
  326. if (command === 'template') {
  327. this.__exportExcel('/sc-community/scResident/downTemplate');
  328. return;
  329. }
  330. },
  331. exportExcel() {
  332. this.__exportExcel('/sc-community/scResident/getDataExcel', this.mixins_query);
  333. },
  334. getNationArray(type) {
  335. this.$http.postForm('/sc-community/scResident/option', { type: type }).then(({ status, data, msg }) => {
  336. if (status === 0 && data) {
  337. if (type == 'nation') {
  338. this.$store.commit('setNationArray', data);
  339. } else if (type == 'native') {
  340. this.$store.commit('setNativeArray', data);
  341. }
  342. }
  343. });
  344. },
  345. CheckChinese(val, name) {
  346. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  347. let newVal = val;
  348. if (!reg.test(val)) {
  349. newVal = val + name;
  350. }
  351. return newVal;
  352. }
  353. },
  354. watch: {
  355. currentId(newValue, oldValue) {
  356. this.mixins_query.communityId = '';
  357. this.mixins_query.buildingId = '';
  358. this.mixins_query.unitName = '';
  359. this.mixins_query.roomNumber = '';
  360. if (newValue.type) {
  361. let newValueIds = newValue.id.split('-');
  362. if (newValue.type === 'community') {
  363. this.mixins_query.communityId = newValueIds[0];
  364. } else if (newValue.type === 'building') {
  365. this.mixins_query.buildingId = newValueIds[1];
  366. } else if (newValue.type === 'unit') {
  367. this.mixins_query.buildingId = newValueIds[1];
  368. this.mixins_query.unitName = newValueIds[2];
  369. } else if (newValue.type === 'room') {
  370. this.mixins_query.roomNumber = newValueIds[newValueIds.length - 1];
  371. }
  372. }
  373. this.thisLeftData = newValue;
  374. this.mixins_search();
  375. }
  376. },
  377. created() {
  378. if (this.$store.getters['getNationArray'].length === 0) {
  379. this.getNationArray('nation');
  380. }
  381. if (this.$store.getters['getNativeArray'].length === 0) {
  382. this.getNationArray('native');
  383. }
  384. this.mix_path = ''; // 权限
  385. this.mixins_dataUrl = '/sc-community/scResident/page'; // 分页查询接口
  386. this.mixins_query = {
  387. questParams: ''
  388. };
  389. this.mixins_search('search');
  390. if (this.$route.query.showDialog && !this.$route.query.closeDialog) {
  391. this.addOrEdit('add');
  392. }
  393. }
  394. };
  395. </script>
  396. <style lang="scss" scoped>
  397. @import './style.scss';
  398. .table-list {
  399. padding-bottom: 16px;
  400. display: flex;
  401. justify-content: space-between;
  402. &:last-child {
  403. padding: 0;
  404. }
  405. }
  406. .statusClass {
  407. margin-right: 15px;
  408. &.open {
  409. color: $greenColor;
  410. }
  411. &.off {
  412. color: $redColor;
  413. }
  414. }
  415. </style>