index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" @submit.native.prevent>
  4. <el-form-item label="类型" prop="typeId">
  5. <template>
  6. <el-select v-model="queryParams.typeId" filterable placeholder="请选择">
  7. <el-option
  8. v-for="item in buildingTypeList"
  9. :key="item.typeId"
  10. :label="item.typeName"
  11. :value="item.typeId">
  12. </el-option>
  13. </el-select>
  14. </template>
  15. </el-form-item>
  16. <el-form-item label="大楼名称" prop="buildingName">
  17. <el-input
  18. v-model="queryParams.buildingName"
  19. placeholder="请输入大楼名称"
  20. clearable
  21. size="small"
  22. @keyup.enter.native="handleQuery"
  23. />
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-row :gutter="10" class="mb8">
  31. <el-col :span="1.5">
  32. <el-button
  33. type="primary"
  34. plain
  35. icon="el-icon-plus"
  36. size="mini"
  37. @click="handleAdd"
  38. v-hasPermi="['info:buildingInfo:add']"
  39. >新增</el-button>
  40. </el-col>
  41. <el-col :span="1.5">
  42. <el-button
  43. type="success"
  44. plain
  45. icon="el-icon-edit"
  46. size="mini"
  47. :disabled="single"
  48. @click="handleUpdate"
  49. v-hasPermi="['info:buildingInfo:edit']"
  50. >修改</el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="danger"
  55. plain
  56. icon="el-icon-delete"
  57. size="mini"
  58. :disabled="multiple"
  59. @click="handleDelete"
  60. v-hasPermi="['info:buildingInfo:remove']"
  61. >删除</el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button
  65. type="warning"
  66. plain
  67. icon="el-icon-download"
  68. size="mini"
  69. :loading="exportLoading"
  70. @click="handleExport"
  71. v-hasPermi="['info:buildingInfo:export']"
  72. >导出</el-button>
  73. </el-col>
  74. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  75. </el-row>
  76. <el-table v-loading="loading" :data="buildingInfoList" @selection-change="handleSelectionChange">
  77. <el-table-column type="selection" width="55" align="center" />
  78. <el-table-column label="大楼编号" align="center" prop="buildingId" />
  79. <el-table-column label="类型" align="center" prop="typeName" />
  80. <el-table-column label="大楼名称" align="center" prop="buildingName" />
  81. <el-table-column label="二维坐标" align="center" prop="lngLat" />
  82. <el-table-column label="三维坐标" align="center" prop="rasterLngLat" />
  83. <el-table-column label="户数" align="center" prop="households" />
  84. <el-table-column label="面积" align="center" prop="acreage" />
  85. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140">
  86. <template slot-scope="scope">
  87. <el-button
  88. size="mini"
  89. type="text"
  90. icon="el-icon-edit"
  91. @click="handleUpdate(scope.row)"
  92. v-hasPermi="['info:buildingInfo:edit']"
  93. >修改</el-button>
  94. <el-button
  95. size="mini"
  96. type="text"
  97. icon="el-icon-delete"
  98. @click="handleDelete(scope.row)"
  99. v-hasPermi="['info:buildingInfo:remove']"
  100. >删除</el-button>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <pagination
  105. v-show="total>0"
  106. :total="total"
  107. :page.sync="queryParams.pageNum"
  108. :limit.sync="queryParams.pageSize"
  109. @pagination="getList"
  110. />
  111. <!-- 添加或修改大楼信息对话框 -->
  112. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  113. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  114. <el-form-item label="类型" prop="typeId">
  115. <template>
  116. <el-select v-model="form.typeId" filterable placeholder="请选择">
  117. <el-option
  118. v-for="item in buildingTypeList"
  119. :key="item.typeId"
  120. :label="item.typeName"
  121. :value="item.typeId">
  122. </el-option>
  123. </el-select>
  124. </template>
  125. </el-form-item>
  126. <el-form-item label="大楼名称" prop="buildingName">
  127. <el-input v-model="form.buildingName" placeholder="请输入大楼名称" />
  128. </el-form-item>
  129. <el-form-item label="地图编码" prop="mapCode">
  130. <el-input-number v-model="form.mapCode" controls-position="right" :min="0" placeholder="请输入地图编码" />
  131. </el-form-item>
  132. <el-form-item label="英文名称" prop="enName">
  133. <el-input v-model="form.enName" placeholder="请输入英文名称" />
  134. </el-form-item>
  135. <el-form-item label="别名" prop="alias">
  136. <el-input v-model="form.alias" placeholder="请输入别名" />
  137. </el-form-item>
  138. <el-form-item label="排序" prop="orderId">
  139. <el-input-number v-model="form.orderId" controls-position="right" :min="0" placeholder="请输入排序" />
  140. </el-form-item>
  141. <el-form-item label="是否已同步">
  142. <el-switch v-model="form.synStatus"></el-switch>
  143. </el-form-item>
  144. <el-form-item label="简介" prop="brief">
  145. <el-input v-model="form.brief" placeholder="请输入简介" />
  146. </el-form-item>
  147. <el-form-item label="二维坐标" prop="lngLat">
  148. <el-input v-model="form.lngLat" placeholder="请输入二维坐标" />
  149. </el-form-item>
  150. <el-form-item label="备注" prop="memo">
  151. <el-input v-model="form.memo" placeholder="请输入备注" />
  152. </el-form-item>
  153. <el-form-item label="三维坐标" prop="rasterLngLat">
  154. <el-input v-model="form.rasterLngLat" placeholder="请输入三维坐标" />
  155. </el-form-item>
  156. <el-form-item label="地址" prop="address">
  157. <el-input v-model="form.address" placeholder="请输入地址" />
  158. </el-form-item>
  159. <el-form-item label="高度" prop="height">
  160. <el-input-number v-model="form.height" controls-position="right" :min="0" placeholder="请输入高度" />
  161. </el-form-item>
  162. <el-form-item label="楼层数" prop="levelNumber">
  163. <el-input-number v-model="form.levelNumber" controls-position="right" :min="0" placeholder="请输入楼层数" />
  164. </el-form-item>
  165. <el-form-item label="户数" prop="households">
  166. <el-input-number v-model="form.households" controls-position="right" :min="0" placeholder="请输入户数" />
  167. </el-form-item>
  168. <el-form-item label="面积" prop="acreage">
  169. <el-input-number v-model="form.acreage" controls-position="right" :min="0" placeholder="请输入面积" />
  170. </el-form-item>
  171. </el-form>
  172. <div slot="footer" class="dialog-footer">
  173. <el-button type="primary" @click="submitForm">确 定</el-button>
  174. <el-button @click="cancel">取 消</el-button>
  175. </div>
  176. </el-dialog>
  177. </div>
  178. </template>
  179. <script>
  180. import { listBuildingInfo, getBuildingInfo, delBuildingInfo, addBuildingInfo, updateBuildingInfo, exportBuildingInfo } from "@/api/info/buildingInfo";
  181. import { listBuildingType, getBuildingType } from "@/api/type/buildingType";
  182. export default {
  183. name: "BuildingInfo",
  184. data() {
  185. return {
  186. buildingTypeList: [],
  187. // 遮罩层
  188. loading: true,
  189. // 导出遮罩层
  190. exportLoading: false,
  191. // 选中数组
  192. ids: [],
  193. // 非单个禁用
  194. single: true,
  195. // 非多个禁用
  196. multiple: true,
  197. // 显示搜索条件
  198. showSearch: true,
  199. // 总条数
  200. total: 0,
  201. // 大楼信息表格数据
  202. buildingInfoList: [],
  203. // 弹出层标题
  204. title: "",
  205. // 是否显示弹出层
  206. open: false,
  207. // 查询参数
  208. queryParams: {
  209. pageNum: 1,
  210. pageSize: 10,
  211. typeId: null,
  212. buildingName: null,
  213. },
  214. queryBuildingTypeParams: {
  215. pageNum: 1,
  216. pageSize: 9999,
  217. },
  218. // 表单参数
  219. form: {},
  220. // 表单校验
  221. rules: {
  222. buildingId: [
  223. { required: true, message: "大楼编号不能为空", trigger: "blur" }
  224. ],
  225. }
  226. };
  227. },
  228. created() {
  229. this.getList();
  230. this.getBuildingTypeList();
  231. },
  232. methods: {
  233. getBuildingTypeList() {
  234. listBuildingType(this.queryBuildingTypeParams).then(response => {
  235. this.buildingTypeList = response.data.list;
  236. });
  237. },
  238. /** 查询大楼信息列表 */
  239. getList() {
  240. this.loading = true;
  241. listBuildingInfo(this.queryParams).then(response => {
  242. this.buildingInfoList = response.data.list;
  243. this.total = response.data.total;
  244. this.loading = false;
  245. });
  246. },
  247. // 取消按钮
  248. cancel() {
  249. this.open = false;
  250. this.reset();
  251. },
  252. // 表单重置
  253. reset() {
  254. this.form = {
  255. buildingId: null,
  256. typeId: null,
  257. buildingName: null,
  258. mapCode: null,
  259. enName: null,
  260. alias: null,
  261. orderId: null,
  262. synStatus: true,
  263. delete: true,
  264. brief: null,
  265. lngLat: null,
  266. memo: null,
  267. rasterLngLat: null,
  268. address: null,
  269. height: null,
  270. levelNumber: null,
  271. households: null,
  272. acreage: null
  273. };
  274. this.resetForm("form");
  275. },
  276. /** 搜索按钮操作 */
  277. handleQuery() {
  278. this.queryParams.pageNum = 1;
  279. this.getList();
  280. },
  281. /** 重置按钮操作 */
  282. resetQuery() {
  283. this.resetForm("queryForm");
  284. this.handleQuery();
  285. },
  286. // 多选框选中数据
  287. handleSelectionChange(selection) {
  288. this.ids = selection.map(item => item.buildingId)
  289. this.single = selection.length!==1
  290. this.multiple = !selection.length
  291. },
  292. /** 新增按钮操作 */
  293. handleAdd() {
  294. this.reset();
  295. this.open = true;
  296. this.title = "添加大楼信息";
  297. },
  298. /** 修改按钮操作 */
  299. handleUpdate(row) {
  300. this.reset();
  301. const buildingId = row.buildingId || this.ids
  302. getBuildingInfo(buildingId).then(response => {
  303. this.form = response.data;
  304. this.open = true;
  305. this.title = "修改大楼信息";
  306. });
  307. },
  308. /** 提交按钮 */
  309. submitForm() {
  310. this.$refs["form"].validate(valid => {
  311. if (valid) {
  312. if (this.form.buildingId != null) {
  313. updateBuildingInfo(this.form).then(response => {
  314. this.$modal.msgSuccess("修改成功");
  315. this.open = false;
  316. this.getList();
  317. });
  318. } else {
  319. addBuildingInfo(this.form).then(response => {
  320. this.$modal.msgSuccess("新增成功");
  321. this.open = false;
  322. this.getList();
  323. });
  324. }
  325. }
  326. });
  327. },
  328. /** 删除按钮操作 */
  329. handleDelete(row) {
  330. const buildingIds = row.buildingId || this.ids;
  331. this.$modal.confirm('是否确认删除大楼信息编号为"' + buildingIds + '"的数据项?').then(function() {
  332. return delBuildingInfo(buildingIds);
  333. }).then(() => {
  334. this.getList();
  335. this.$modal.msgSuccess("删除成功");
  336. }).catch(() => {});
  337. },
  338. /** 导出按钮操作 */
  339. handleExport() {
  340. const queryParams = this.queryParams;
  341. this.$modal.confirm('是否确认导出所有大楼信息数据项?').then(() => {
  342. this.exportLoading = true;
  343. return exportBuildingInfo(queryParams);
  344. }).then(response => {
  345. this.$download.name(response.msg);
  346. this.exportLoading = false;
  347. }).catch(() => {});
  348. }
  349. }
  350. };
  351. </script>