index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="小区名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入小区名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="primary"
  21. plain
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['estate:estate:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. plain
  32. icon="el-icon-edit"
  33. size="mini"
  34. :disabled="single"
  35. @click="handleUpdate"
  36. v-hasPermi="['estate:estate:edit']"
  37. >修改</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="danger"
  42. plain
  43. icon="el-icon-delete"
  44. size="mini"
  45. :disabled="multiple"
  46. @click="handleDelete"
  47. v-hasPermi="['estate:estate:remove']"
  48. >删除</el-button>
  49. </el-col>
  50. <!-- <el-col :span="1.5">
  51. <el-button
  52. type="warning"
  53. plain
  54. icon="el-icon-download"
  55. size="mini"
  56. @click="handleExport"
  57. v-hasPermi="['estate:estate:export']"
  58. >导出</el-button>
  59. </el-col> -->
  60. <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
  61. </el-row>
  62. <el-table v-loading="loading" :data="estateList" @selection-change="handleSelectionChange">
  63. <el-table-column type="selection" width="55" align="center" />
  64. <el-table-column label="小区ID" align="center" prop="estateId" />
  65. <el-table-column label="小区名称" align="center" prop="name" />
  66. <!-- <el-table-column label="所属网格ID" align="center" prop="addressId" /> -->
  67. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  68. <template slot-scope="scope">
  69. <el-button
  70. size="mini"
  71. type="text"
  72. icon="el-icon-edit"
  73. @click="handleUpdate(scope.row)"
  74. v-hasPermi="['estate:estate:edit']"
  75. >修改</el-button>
  76. <el-button
  77. size="mini"
  78. type="text"
  79. icon="el-icon-delete"
  80. @click="handleDelete(scope.row)"
  81. v-hasPermi="['estate:estate:remove']"
  82. >删除</el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <pagination
  87. v-show="total>0"
  88. :total="total"
  89. :page.sync="queryParams.pageNum"
  90. :limit.sync="queryParams.pageSize"
  91. @pagination="getList"
  92. />
  93. <!-- 添加或修改小区管理对话框 -->
  94. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  95. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  96. <el-form-item label="小区名称" prop="name">
  97. <el-input v-model="form.name" placeholder="请输入小区名称" />
  98. </el-form-item>
  99. <!-- <el-form-item label="所属网格ID" prop="addressId">
  100. <el-input v-model="form.addressId" placeholder="请输入所属网格ID" />
  101. </el-form-item> -->
  102. </el-form>
  103. <div slot="footer" class="dialog-footer">
  104. <el-button type="primary" @click="submitForm">确 定</el-button>
  105. <el-button @click="cancel">取 消</el-button>
  106. </div>
  107. </el-dialog>
  108. </div>
  109. </template>
  110. <script>
  111. import { listestate, getestate, delestate, addestate, updateestate } from "@/api/seat/estate";
  112. export default {
  113. name: "estate",
  114. data() {
  115. return {
  116. // 遮罩层
  117. loading: true,
  118. // 选中数组
  119. ids: [],
  120. // 非单个禁用
  121. single: true,
  122. // 非多个禁用
  123. multiple: true,
  124. // 显示搜索条件
  125. showSearch: true,
  126. // 总条数
  127. total: 0,
  128. // 小区管理表格数据
  129. estateList: [],
  130. // 弹出层标题
  131. title: "",
  132. // 是否显示弹出层
  133. open: false,
  134. // 查询参数
  135. queryParams: {
  136. pageNum: 1,
  137. pageSize: 10,
  138. name: null,
  139. addressId: null
  140. },
  141. // 表单参数
  142. form: {},
  143. // 表单校验
  144. rules: {
  145. }
  146. };
  147. },
  148. created() {
  149. this.getList();
  150. },
  151. methods: {
  152. /** 查询小区管理列表 */
  153. getList() {
  154. this.loading = true;
  155. listestate(this.queryParams).then(response => {
  156. this.estateList = response.rows;
  157. this.total = response.total;
  158. this.loading = false;
  159. });
  160. },
  161. // 取消按钮
  162. cancel() {
  163. this.open = false;
  164. this.reset();
  165. },
  166. // 表单重置
  167. reset() {
  168. this.form = {
  169. estateId: null,
  170. name: null,
  171. addressId: null
  172. };
  173. this.resetForm("form");
  174. },
  175. /** 搜索按钮操作 */
  176. handleQuery() {
  177. this.queryParams.pageNum = 1;
  178. this.getList();
  179. },
  180. /** 重置按钮操作 */
  181. resetQuery() {
  182. this.resetForm("queryForm");
  183. this.handleQuery();
  184. },
  185. // 多选框选中数据
  186. handleSelectionChange(selection) {
  187. this.ids = selection.map(item => item.estateId)
  188. this.single = selection.length!==1
  189. this.multiple = !selection.length
  190. },
  191. /** 新增按钮操作 */
  192. handleAdd() {
  193. this.reset();
  194. this.open = true;
  195. this.title = "添加小区管理";
  196. },
  197. /** 修改按钮操作 */
  198. handleUpdate(row) {
  199. this.reset();
  200. const estateId = row.estateId || this.ids
  201. getestate(estateId).then(response => {
  202. this.form = response.data;
  203. this.open = true;
  204. this.title = "修改小区管理";
  205. });
  206. },
  207. /** 提交按钮 */
  208. submitForm() {
  209. this.$refs["form"].validate(valid => {
  210. if (valid) {
  211. if (this.form.estateId != null) {
  212. updateestate(this.form).then(response => {
  213. this.$modal.msgSuccess("修改成功");
  214. this.open = false;
  215. this.getList();
  216. });
  217. } else {
  218. addestate(this.form).then(response => {
  219. this.$modal.msgSuccess("新增成功");
  220. this.open = false;
  221. this.getList();
  222. });
  223. }
  224. }
  225. });
  226. },
  227. /** 删除按钮操作 */
  228. handleDelete(row) {
  229. const estateIds = row.estateId || this.ids;
  230. this.$modal.confirm('是否确认删除小区管理编号为"' + row.name + '"的数据项?').then(function() {
  231. return delestate(estateIds);
  232. }).then(() => {
  233. this.getList();
  234. this.$modal.msgSuccess("删除成功");
  235. }).catch(() => {});
  236. },
  237. /** 导出按钮操作 */
  238. handleExport() {
  239. this.download('estate/estate/export', {
  240. ...this.queryParams
  241. }, `estate_${new Date().getTime()}.xlsx`)
  242. }
  243. }
  244. };
  245. </script>