index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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="elevatorCode">
  5. <el-input
  6. v-model="queryParams.elevatorCode"
  7. placeholder="请输入电梯型号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="园区" prop="parkId">
  14. <el-select v-model="queryParams.parkId" placeholder="请选择" clearable size="small">
  15. <el-option
  16. v-for="item in parkList"
  17. :key="item.parkId"
  18. :label="item.parkName"
  19. :value="item.parkId"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="大楼" prop="buildingId">
  24. <template>
  25. <el-select v-model="queryParams.buildingId" filterable placeholder="请选择">
  26. <el-option
  27. v-for="item in buildingList"
  28. :key="item.buildingId"
  29. :label="item.buildingName"
  30. :value="item.buildingId">
  31. </el-option>
  32. </el-select>
  33. </template>
  34. </el-form-item>
  35. <el-form-item label="电梯状态" prop="status">
  36. <el-select v-model="queryParams.status" placeholder="请选择电梯状态" clearable size="small">
  37. <el-option
  38. v-for="dict in dict.type.elevator_info_status"
  39. :key="dict.value"
  40. :label="dict.label"
  41. :value="dict.value"
  42. />
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="电梯类型" prop="status">
  46. <el-select v-model="queryParams.type" placeholder="请选择电梯类型" clearable size="small">
  47. <el-option
  48. v-for="dict in dict.type.elevator_type"
  49. :key="dict.value"
  50. :label="dict.label"
  51. :value="dict.value"
  52. />
  53. </el-select>
  54. </el-form-item>
  55. <el-form-item label="电梯名字" prop="elevatorName">
  56. <el-input
  57. v-model="queryParams.elevatorName"
  58. placeholder="请输入电梯名字"
  59. clearable
  60. size="small"
  61. @keyup.enter.native="handleQuery"
  62. />
  63. </el-form-item>
  64. <el-form-item>
  65. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  66. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  67. </el-form-item>
  68. </el-form>
  69. <el-row :gutter="10" class="mb8">
  70. <el-col :span="1.5">
  71. <el-button
  72. type="primary"
  73. plain
  74. icon="el-icon-plus"
  75. size="mini"
  76. @click="handleAdd"
  77. v-hasPermi="['info:elevatorInfo:add']"
  78. >新增</el-button>
  79. </el-col>
  80. <el-col :span="1.5">
  81. <el-button
  82. type="success"
  83. plain
  84. icon="el-icon-edit"
  85. size="mini"
  86. :disabled="single"
  87. @click="handleUpdate"
  88. v-hasPermi="['info:elevatorInfo:edit']"
  89. >修改</el-button>
  90. </el-col>
  91. <el-col :span="1.5">
  92. <el-button
  93. type="danger"
  94. plain
  95. icon="el-icon-delete"
  96. size="mini"
  97. :disabled="multiple"
  98. @click="handleDelete"
  99. v-hasPermi="['info:elevatorInfo:remove']"
  100. >删除</el-button>
  101. </el-col>
  102. <el-col :span="1.5">
  103. <el-button
  104. type="warning"
  105. plain
  106. icon="el-icon-download"
  107. size="mini"
  108. :loading="exportLoading"
  109. @click="handleExport"
  110. v-hasPermi="['info:elevatorInfo:export']"
  111. >导出</el-button>
  112. </el-col>
  113. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  114. </el-row>
  115. <el-table v-loading="loading" :data="elevatorInfoList" @selection-change="handleSelectionChange">
  116. <el-table-column type="selection" width="55" align="center" />
  117. <el-table-column label="电梯" align="center" prop="elevatorId" />
  118. <el-table-column label="电梯型号" align="center" prop="elevatorCode" />
  119. <el-table-column label="大楼名称" align="center">
  120. <template slot-scope="scope">
  121. {{ getBuildingName(scope.row.buildingId) }}
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="电梯状态" align="center" prop="status">
  125. <template slot-scope="scope">
  126. <dict-tag :options="dict.type.elevator_info_status" :value="scope.row.status"/>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="连接状态" align="center" prop="connectStatus">
  130. <template slot-scope="scope">
  131. <dict-tag :options="dict.type.connection_status" :value="scope.row.connectStatus"/>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="电梯类型" align="center" prop="type">
  135. <template slot-scope="scope">
  136. <dict-tag :options="dict.type.elevator_type" :value="scope.row.type"/>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="电梯名字" align="center" prop="elevatorName" />
  140. <el-table-column label="保养次数" align="center" prop="upkeepNum" />
  141. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140">
  142. <template slot-scope="scope">
  143. <el-button
  144. size="mini"
  145. type="text"
  146. icon="el-icon-edit"
  147. @click="handleUpdate(scope.row)"
  148. v-hasPermi="['info:elevatorInfo:edit']"
  149. >修改</el-button>
  150. <el-button
  151. size="mini"
  152. type="text"
  153. icon="el-icon-delete"
  154. @click="handleDelete(scope.row)"
  155. v-hasPermi="['info:elevatorInfo:remove']"
  156. >删除</el-button>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. <pagination
  161. v-show="total>0"
  162. :total="total"
  163. :page.sync="queryParams.pageNum"
  164. :limit.sync="queryParams.pageSize"
  165. @pagination="getList"
  166. />
  167. <!-- 添加或修改电梯信息对话框 -->
  168. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  169. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  170. <el-form-item label="电梯型号" prop="elevatorCode">
  171. <el-input v-model="form.elevatorCode" placeholder="请输入电梯型号" />
  172. </el-form-item>
  173. <el-form-item label="园区" prop="parkId">
  174. <el-select v-model="form.parkId" placeholder="请选择" clearable size="small">
  175. <el-option
  176. v-for="item in parkList"
  177. :key="item.parkId"
  178. :label="item.parkName"
  179. :value="item.parkId"
  180. />
  181. </el-select>
  182. </el-form-item>
  183. <el-form-item label="大楼" prop="buildingId">
  184. <template>
  185. <el-select v-model="form.buildingId" filterable placeholder="请选择">
  186. <el-option
  187. v-for="item in buildingList"
  188. :key="item.buildingId"
  189. :label="item.buildingName"
  190. :value="item.buildingId">
  191. </el-option>
  192. </el-select>
  193. </template>
  194. </el-form-item>
  195. <el-form-item label="电梯状态" prop="status">
  196. <el-select v-model="form.status" placeholder="请选择电梯状态">
  197. <el-option
  198. v-for="dict in dict.type.elevator_info_status"
  199. :key="dict.value"
  200. :label="dict.label"
  201. :value="parseInt(dict.value)"
  202. ></el-option>
  203. </el-select>
  204. </el-form-item>
  205. <el-form-item label="电梯类型" prop="status">
  206. <el-select v-model="form.type" placeholder="请选择电梯类型">
  207. <el-option
  208. v-for="dict in dict.type.elevator_type"
  209. :key="dict.value"
  210. :label="dict.label"
  211. :value="parseInt(dict.value)"
  212. ></el-option>
  213. </el-select>
  214. </el-form-item>
  215. <el-form-item label="电梯连接状态" prop="status">
  216. <el-select v-model="form.connectStatus" placeholder="请选择">
  217. <el-option
  218. v-for="dict in dict.type.connection_status"
  219. :key="dict.value"
  220. :label="dict.label"
  221. :value="parseInt(dict.value)"
  222. ></el-option>
  223. </el-select>
  224. </el-form-item>
  225. <el-form-item label="电梯名字" prop="elevatorName">
  226. <el-input v-model="form.elevatorName" placeholder="请输入电梯名字" />
  227. </el-form-item>
  228. <el-form-item label="保养次数" prop="upkeepNum">
  229. <el-input-number v-model="form.upkeepNum" controls-position="right" :min="0" placeholder="请输入保养次数" />
  230. </el-form-item>
  231. <el-form-item label="运行楼层" prop="runFloor">
  232. <el-input v-model="form.runFloor" placeholder="请输入" />
  233. </el-form-item>
  234. <el-form-item label="运行时间" prop="runTime">
  235. <el-input v-model="form.runTime" placeholder="请输入" />
  236. </el-form-item>
  237. <el-form-item label="监控地址" prop="elevatorUrl">
  238. <el-input v-model="form.elevatorUrl" placeholder="请输入" />
  239. </el-form-item>
  240. </el-form>
  241. <div slot="footer" class="dialog-footer">
  242. <el-button type="primary" @click="submitForm">确 定</el-button>
  243. <el-button @click="cancel">取 消</el-button>
  244. </div>
  245. </el-dialog>
  246. </div>
  247. </template>
  248. <script>
  249. import { listElevatorInfo, getElevatorInfo, delElevatorInfo, addElevatorInfo, updateElevatorInfo, exportElevatorInfo } from "@/api/info/elevatorInfo";
  250. import { listBuildingInfo, getBuildingInfo } from "@/api/info/buildingInfo";
  251. import { listParkInfo, getParkInfo, delParkInfo, addParkInfo, updateParkInfo, exportParkInfo } from "@/api/info/parkInfo";
  252. export default {
  253. name: "ElevatorInfo",
  254. dicts: ['elevator_info_status', 'elevator_type', 'connection_status'],
  255. data() {
  256. return {
  257. parkList: [],
  258. buildingList: [],
  259. // 遮罩层
  260. loading: true,
  261. // 导出遮罩层
  262. exportLoading: false,
  263. // 选中数组
  264. ids: [],
  265. // 非单个禁用
  266. single: true,
  267. // 非多个禁用
  268. multiple: true,
  269. // 显示搜索条件
  270. showSearch: true,
  271. // 总条数
  272. total: 0,
  273. // 电梯信息表格数据
  274. elevatorInfoList: [],
  275. // 弹出层标题
  276. title: "",
  277. // 是否显示弹出层
  278. open: false,
  279. // 查询参数
  280. queryParams: {
  281. pageNum: 1,
  282. pageSize: 10,
  283. elevatorCode: null,
  284. buildingId: null,
  285. status: null,
  286. elevatorName: null,
  287. parkId: null
  288. },
  289. queryBuildingParams: {
  290. pageNum: 1,
  291. pageSize: 999999,
  292. },
  293. // 表单参数
  294. form: {},
  295. // 表单校验
  296. rules: {
  297. elevatorId: [
  298. { required: true, message: "电梯id不能为空", trigger: "blur" }
  299. ],
  300. }
  301. };
  302. },
  303. created() {
  304. this.getList();
  305. this.getBuilding();
  306. this.getParkList();
  307. },
  308. methods: {
  309. getParkList() {
  310. listParkInfo(this.queryBuildingParams).then(response => {
  311. this.parkList = response.data.list;
  312. });
  313. },
  314. getBuildingName(buildingId) {
  315. const building = this.buildingList.find(b => b.buildingId === buildingId);
  316. return building ? building.buildingName : '未知';
  317. },
  318. getBuilding() {
  319. listBuildingInfo(this.queryBuildingParams).then(response => {
  320. this.buildingList = response.data.list;
  321. });
  322. },
  323. /** 查询电梯信息列表 */
  324. getList() {
  325. this.loading = true;
  326. listElevatorInfo(this.queryParams).then(response => {
  327. this.elevatorInfoList = response.data.list;
  328. this.total = response.data.total;
  329. this.loading = false;
  330. });
  331. },
  332. // 取消按钮
  333. cancel() {
  334. this.open = false;
  335. this.reset();
  336. },
  337. // 表单重置
  338. reset() {
  339. this.form = {
  340. elevatorId: null,
  341. elevatorCode: null,
  342. buildingId: null,
  343. status: null,
  344. elevatorName: null,
  345. upkeepNum: null,
  346. type: null,
  347. runFloor: null,
  348. runTime: null,
  349. connectStatus: null,
  350. elevatorUrl: null,
  351. parkId: null
  352. };
  353. this.resetForm("form");
  354. },
  355. /** 搜索按钮操作 */
  356. handleQuery() {
  357. this.queryParams.pageNum = 1;
  358. this.getList();
  359. },
  360. /** 重置按钮操作 */
  361. resetQuery() {
  362. this.resetForm("queryForm");
  363. this.handleQuery();
  364. },
  365. // 多选框选中数据
  366. handleSelectionChange(selection) {
  367. this.ids = selection.map(item => item.elevatorId)
  368. this.single = selection.length!==1
  369. this.multiple = !selection.length
  370. },
  371. /** 新增按钮操作 */
  372. handleAdd() {
  373. this.reset();
  374. this.open = true;
  375. this.title = "添加电梯信息";
  376. },
  377. /** 修改按钮操作 */
  378. handleUpdate(row) {
  379. this.reset();
  380. const elevatorId = row.elevatorId || this.ids
  381. getElevatorInfo(elevatorId).then(response => {
  382. this.form = response.data;
  383. this.open = true;
  384. this.title = "修改电梯信息";
  385. });
  386. },
  387. /** 提交按钮 */
  388. submitForm() {
  389. this.$refs["form"].validate(valid => {
  390. if (valid) {
  391. if (this.form.elevatorId != null) {
  392. updateElevatorInfo(this.form).then(response => {
  393. this.$modal.msgSuccess("修改成功");
  394. this.open = false;
  395. this.getList();
  396. });
  397. } else {
  398. addElevatorInfo(this.form).then(response => {
  399. this.$modal.msgSuccess("新增成功");
  400. this.open = false;
  401. this.getList();
  402. });
  403. }
  404. }
  405. });
  406. },
  407. /** 删除按钮操作 */
  408. handleDelete(row) {
  409. const elevatorIds = row.elevatorId || this.ids;
  410. this.$modal.confirm('是否确认删除电梯信息编号为"' + elevatorIds + '"的数据项?').then(function() {
  411. return delElevatorInfo(elevatorIds);
  412. }).then(() => {
  413. this.getList();
  414. this.$modal.msgSuccess("删除成功");
  415. }).catch(() => {});
  416. },
  417. /** 导出按钮操作 */
  418. handleExport() {
  419. const queryParams = this.queryParams;
  420. this.$modal.confirm('是否确认导出所有电梯信息数据项?').then(() => {
  421. this.exportLoading = true;
  422. return exportElevatorInfo(queryParams);
  423. }).then(response => {
  424. this.$download.name(response.msg);
  425. this.exportLoading = false;
  426. }).catch(() => {});
  427. }
  428. }
  429. };
  430. </script>