garageList.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div class="main">
  3. <div class="search">
  4. <el-input v-model="query.garageName" placeholder="车位号" class="search-input"></el-input>
  5. <el-select v-model="query.communityName" placeholder="请选择社区名称">
  6. <el-option v-for="(item, index) in communityList" :label="item.label" :value="item.id" :key="index"></el-option>
  7. </el-select>
  8. <el-button type="primary" @click="mixins_search" class="search-btn" icon="el-icon-search"
  9. >查询
  10. <!-- <i class="iconfont">&#xe6fc;</i> -->
  11. </el-button>
  12. <div class="search-icon">
  13. <!-- 删除 新增 -->
  14. <i class="iconfont" @click="deleteRow" v-txt-tip data-txt="删除">&#xe63b;</i>
  15. <i class="iconfont" @click="addOrEdit('add')" v-left-txt-tip data-txt="新增">&#xe641;</i>
  16. </div>
  17. </div>
  18. <div>
  19. <zz-table
  20. :cols="cols"
  21. :settings="{ showCheckbox: true, showIndex: true, stripe: true }"
  22. :loading="mixins_onQuery"
  23. :data="tableData"
  24. :pageset="mixins_pageset"
  25. @page-change="pageChange"
  26. @selection-change="selectionChange"
  27. >
  28. <template slot-scope="scope" slot="opt">
  29. <i
  30. @click="addOrEdit('edit', scope)"
  31. class="iconfont"
  32. style="color: #2787f1; margin-right: 30px"
  33. v-txt-tip
  34. data-txt="编辑"
  35. >&#xe645;</i
  36. >
  37. <i
  38. @click="deleteOne(scope.row.id)"
  39. class="iconfont"
  40. style="color: #ff7272; margin-right: 30px"
  41. v-txt-tip
  42. data-txt="删除"
  43. >&#xe63a;</i
  44. >
  45. </template>
  46. <template slot-scope="scope" slot="opt" class="opt">
  47. <div class="opt">
  48. <el-tooltip effect="light" placement="bottom" content="编辑">
  49. <i class="zoniot_font zoniot-icon-bianji" @click="addOrEdit('edit', scope)"></i>
  50. </el-tooltip>
  51. <el-tooltip effect="light" placement="bottom" content="删除">
  52. <i class="zoniot_font zoniot-icon-shanchu redText" @click="deleteOne(scope.row.id)"></i>
  53. </el-tooltip>
  54. <el-tooltip effect="light" placement="bottom" content="分区管理">
  55. <i class="zoniot_font zoniot-icon-bianji" @click="partitionManagement(scope)"></i>
  56. </el-tooltip>
  57. </div>
  58. </template>
  59. </zz-table>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import list from '@utils/list.js';
  65. export default {
  66. mixins: [list],
  67. data() {
  68. return {
  69. parkingNumber: '',
  70. communityList: [], //社区名称下拉列表
  71. communityId: '', //社区id
  72. selectName: 'parkingLot',
  73. query: {
  74. communityName: '', //社区名称
  75. garageName: '' //车库名称
  76. },
  77. cols: [
  78. {
  79. label: '所属社区',
  80. prop: 'communityName'
  81. },
  82. {
  83. label: '车库名称',
  84. prop: 'garageName'
  85. },
  86. {
  87. label: '车位数量',
  88. prop: 'parkingNumber'
  89. },
  90. {
  91. label: '备注',
  92. prop: 'remarks'
  93. },
  94. {
  95. label: '操作',
  96. prop: 'opt',
  97. slot: 'opt'
  98. }
  99. ],
  100. // tableData: []
  101. selectRow: []
  102. };
  103. },
  104. props: {
  105. tableData: {
  106. type: Array,
  107. default: ''
  108. },
  109. tableTotal: {
  110. type: Number,
  111. default: ''
  112. }
  113. },
  114. methods: {
  115. //获取社区名称下拉列表
  116. communityNameList() {
  117. this.communityList = [];
  118. let onOption = '';
  119. this.$http.get('/assets/community/list', {}).then((res) => {
  120. res.data.map((res) => {
  121. onOption = {
  122. label: res.communityName,
  123. id: res.id
  124. };
  125. this.communityList.push(onOption);
  126. });
  127. });
  128. },
  129. mixins_search() {
  130. console.log(this.query.communityName);
  131. this.communityId = this.query.communityName;
  132. this.garageLotList();
  133. },
  134. //获取列表数据
  135. garageLotList() {
  136. let submitData = {
  137. communityId: this.communityId,
  138. garageName: this.query.garageName,
  139. pageNum: 1,
  140. pageSize: 10
  141. };
  142. this.$http
  143. .post('/sc-community/assets/garage/page', submitData)
  144. .then((res) => {
  145. this.tableData = res.data.list;
  146. this.mixins_pageset = {
  147. total: parseInt(res.data.total)
  148. // pageNum: this.mixins_pageset.pageNum,
  149. // pageSize: this.mixins_pageset.pageSize
  150. };
  151. this.mixins_onQuery = false;
  152. // this.mixins_list=data.data.list;
  153. // this.mixins_onQuery=false;
  154. })
  155. .catch(function () {});
  156. },
  157. addOrEdit(todo, scope) {
  158. let self = this;
  159. new Promise((resolve) => {
  160. let row,
  161. title = '编辑车库';
  162. if ('add' == todo) {
  163. title = '新增车库';
  164. this.addEditPopUps(title, row, todo);
  165. } else {
  166. this.$http.get('/sc-community-web/assets/garage/find/' + scope.row.id, {}).then((res) => {
  167. // sessionStorage.setItem('communityInformation',JSON.stringify(data))
  168. row = res.data;
  169. this.addEditPopUps(title, row, todo);
  170. });
  171. }
  172. }).then(() => {
  173. this.mixins_search();
  174. });
  175. },
  176. addEditPopUps(title, row, todo) {
  177. this.$store.dispatch('openModal', {
  178. url: '/parkingLotAdministration/pageJump/garageSaveEdits.vue',
  179. title: title,
  180. width: '500px',
  181. height: '420px',
  182. props: {
  183. data: row,
  184. communityList:this.communityList,
  185. todo: todo,
  186. callback: this.mixins_search
  187. }
  188. });
  189. },
  190. //分区管理
  191. partitionManagement(scope) {
  192. sessionStorage.setItem('communityId', scope.row.communityId);
  193. sessionStorage.setItem('garageId', scope.row.id);
  194. this.$router.push({ name: '/parkingLotAdministration/pageJump/partitionManagement' });
  195. },
  196. //单个删除
  197. deleteOne(ids) {
  198. this.$msgBox(`刪除字典`, '删除后将无法恢复,请问是否继续?')
  199. .then(() => {
  200. this.$http.post('/dict/delete', [ids]).then(({ status, data, msg }) => {
  201. if (0 === status) {
  202. this.$message({
  203. type: 'success',
  204. message: '删除成功!'
  205. });
  206. this.mixins_search();
  207. } else {
  208. this.$message.error('删除失败!');
  209. }
  210. });
  211. })
  212. .catch(() => {
  213. this.$message({
  214. type: 'info',
  215. message: '已取消删除'
  216. });
  217. });
  218. },
  219. deleteRow() {
  220. // 获取选中列表的ids
  221. let ids = [];
  222. if (!this.selectRow.length) {
  223. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  224. return;
  225. }
  226. this.selectRow.forEach((v) => {
  227. ids.push(v.id);
  228. });
  229. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  230. .then((_) => {
  231. this.$http.post('/sc-community-web/assets/garage/delete', ids).then(({ status, data, msg }) => {
  232. if (0 === status) {
  233. this.$message({
  234. type: 'success',
  235. message: '删除成功!'
  236. });
  237. this.mixins_search();
  238. }
  239. });
  240. })
  241. .catch(() => {});
  242. },
  243. selectionChange(val) {
  244. this.selectRow = val;
  245. }
  246. },
  247. created() {
  248. this.communityNameList();
  249. this.mixins_onQuery = false;
  250. },
  251. watch: {
  252. tableTotal(item) {
  253. this.mixins_pageset = {
  254. total: item
  255. // pageNum: this.mixins_pageset.pageNum,
  256. // pageSize: this.mixins_pageset.pageSize
  257. };
  258. }
  259. }
  260. };
  261. </script>