index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="88px">
  4. <el-form-item label="基站名称" prop="baseStationName">
  5. <el-input
  6. v-model="queryParams.baseStationName"
  7. placeholder="请输入基站名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="无人机名称" prop="uavName">
  14. <el-input
  15. v-model="queryParams.uavName"
  16. placeholder="请输入无人机名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. plain
  32. icon="el-icon-plus"
  33. size="mini"
  34. @click="handleAdd"
  35. >新增
  36. </el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. plain
  42. icon="el-icon-edit"
  43. size="mini"
  44. :disabled="single"
  45. @click="handleUpdate"
  46. >修改
  47. </el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. plain
  53. icon="el-icon-delete"
  54. size="mini"
  55. :disabled="multiple"
  56. @click="handleDelete"
  57. >删除
  58. </el-button>
  59. </el-col>
  60. <!-- <el-col :span="1.5">-->
  61. <!-- <el-button-->
  62. <!-- type="warning"-->
  63. <!-- plain-->
  64. <!-- icon="el-icon-download"-->
  65. <!-- size="mini"-->
  66. <!-- @click="handleExport"-->
  67. <!-- >导出-->
  68. <!-- </el-button>-->
  69. <!-- </el-col>-->
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table v-loading="loading" :data="uavList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center"/>
  74. <el-table-column label="序号" align="center" type="index"/>
  75. <el-table-column label="基站名称" align="center" prop="baseStationName"/>
  76. <el-table-column label="机库ID" align="center" prop="baseStationId"/>
  77. <el-table-column label="机库SN" align="center" prop="baseStationSn"/>
  78. <el-table-column label="经度" align="center" prop="longitude"/>
  79. <el-table-column label="纬度" align="center" prop="latitude"/>
  80. <el-table-column label="海拔高度" align="center" prop="height"/>
  81. <el-table-column label="无人机名称" align="center" prop="uavName"/>
  82. <el-table-column label="无人机ID" align="center" prop="uavId"/>
  83. <el-table-column label="无人机SN" align="center" prop="uavSn"/>
  84. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width">
  85. <template slot-scope="scope">
  86. <el-button
  87. size="mini"
  88. type="text"
  89. icon="el-icon-edit"
  90. @click="handleUpdate(scope.row)"
  91. >修改
  92. </el-button>
  93. <el-button
  94. size="mini"
  95. type="text"
  96. icon="el-icon-delete"
  97. @click="handleDelete(scope.row)"
  98. >删除
  99. </el-button>
  100. <el-button
  101. size="mini"
  102. type="text"
  103. icon="el-icon-s-management"
  104. @click="handleUavDept(scope.row)"
  105. >部门管理
  106. </el-button>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <pagination
  111. v-show="total>0"
  112. :total="total"
  113. :page.sync="queryParams.pageNum"
  114. :limit.sync="queryParams.pageSize"
  115. @pagination="getList"
  116. />
  117. <!-- 添加或修改无人机对话框 -->
  118. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  119. <el-form ref="form" :inline="true" :model="form" :rules="rules" label-width="140px">
  120. <el-form-item label="基站名称" prop="baseStationName">
  121. <el-input v-model="form.baseStationName" placeholder="请输入基站名称"/>
  122. </el-form-item>
  123. <el-form-item label="机库ID" prop="baseStationId">
  124. <el-input v-model="form.baseStationId" placeholder="请输入机库ID"/>
  125. </el-form-item>
  126. <el-form-item label="机库SN" prop="baseStationSn">
  127. <el-input v-model="form.baseStationSn" placeholder="请输入机库SN"/>
  128. </el-form-item>
  129. <el-form-item label="经度" prop="longitude">
  130. <el-input v-model="form.longitude" placeholder="请输入经度"/>
  131. </el-form-item>
  132. <el-form-item label="纬度" prop="latitude">
  133. <el-input v-model="form.latitude" placeholder="请输入纬度"/>
  134. </el-form-item>
  135. <el-form-item label="海拔高度" prop="height">
  136. <el-input v-model="form.height" placeholder="请输入海拔高度"/>
  137. </el-form-item>
  138. <el-form-item label="无人机名称" prop="uavName">
  139. <el-input v-model="form.uavName" placeholder="请输入无人机名称"/>
  140. </el-form-item>
  141. <el-form-item label="无人机ID" prop="uavId">
  142. <el-input v-model="form.uavId" placeholder="请输入无人机ID"/>
  143. </el-form-item>
  144. <el-form-item label="无人机SN" prop="uavSn">
  145. <el-input v-model="form.uavSn" placeholder="请输入无人机SN"/>
  146. </el-form-item>
  147. </el-form>
  148. <div slot="footer" class="dialog-footer">
  149. <el-button type="primary" @click="submitForm">确 定</el-button>
  150. <el-button @click="cancel">取 消</el-button>
  151. </div>
  152. </el-dialog>
  153. <!-- 部门管理弹框 -->
  154. <el-dialog title="部门管理列表" :visible.sync="showUavDept" @close="closeDialog">
  155. <monitoruavdept v-if="showUavDept" ref="monitorDept" :uavId="uavIdValue" :uavName="uavNameValue"
  156. style="width: 100%;height: 100%;"
  157. ></monitoruavdept>
  158. </el-dialog>
  159. </div>
  160. </template>
  161. <script>
  162. import {listUav, getUav, delUav, addUav, updateUav} from "@/api/uav/uav";
  163. import Treeselect from "@riophae/vue-treeselect";
  164. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  165. import {treeselect} from "@/api/system/dept";
  166. import {checkLat, checkLon, checkPositiveDecimal} from '@/api/system/rules'
  167. import monitoruavdept from "@/views/uav/uavdept/monitoruavdept.vue";
  168. export default {
  169. name: "Uav",
  170. components: {monitoruavdept, Treeselect},
  171. data() {
  172. return {
  173. // 遮罩层
  174. loading: true,
  175. // 选中数组
  176. ids: [],
  177. // 非单个禁用
  178. single: true,
  179. // 非多个禁用
  180. multiple: true,
  181. // 显示搜索条件
  182. showSearch: true,
  183. // 总条数
  184. total: 0,
  185. // 无人机表格数据
  186. uavList: [],
  187. // 弹出层标题
  188. title: "",
  189. // 是否显示弹出层
  190. open: false,
  191. // 查询参数
  192. queryParams: {
  193. pageNum: 1,
  194. pageSize: 10,
  195. baseStationName: null,
  196. baseStationId: null,
  197. baseStationSn: null,
  198. longitude: null,
  199. latitude: null,
  200. height: null,
  201. uavName: null,
  202. uavId: null,
  203. uavSn: null,
  204. deptId: null
  205. },
  206. // 表单参数
  207. form: {},
  208. // 表单校验
  209. rules: {
  210. baseStationName: [
  211. {required: true, message: "基站名称不能为空", trigger: "blur"},
  212. ],
  213. baseStationId: [
  214. {required: true, message: "机库ID不能为空", trigger: "blur"},
  215. ],
  216. baseStationSn: [
  217. {required: true, message: "机库SN不能为空", trigger: "blur"},
  218. ],
  219. uavName: [
  220. {required: true, message: "无人机名称不能为空", trigger: "blur"},
  221. ],
  222. uavId: [
  223. {required: true, message: "无人机ID不能为空", trigger: "blur"},
  224. ],
  225. uavSn: [
  226. {required: true, message: "无人机SN不能为空", trigger: "change"},
  227. ],
  228. longitude: [
  229. {required: true, message: "经度不能为空", trigger: "change"},
  230. {validator: checkLon, trigger: 'blur'}
  231. ],
  232. latitude: [
  233. {required: true, message: "纬度不能为空", trigger: "change"},
  234. {validator: checkLat, trigger: 'blur'}
  235. ],
  236. height: [
  237. {required: true, message: '海拔高度不能为空', trigger: 'blur'},
  238. {validator: checkPositiveDecimal, trigger: 'blur'}
  239. ],
  240. },
  241. // 表格树数据
  242. deptList: [],
  243. // 部门树选项
  244. deptOptions: [],
  245. // 过滤掉已禁用部门树选项
  246. enabledDeptOptions: undefined,
  247. showUavDept: false,
  248. uavIdValue: null,
  249. uavNameValue: null,
  250. };
  251. },
  252. created() {
  253. this.getList();
  254. this.getDeptTree()
  255. },
  256. methods: {
  257. handleUavDept(row) {
  258. const id = row.id
  259. const uavName = row.uavName
  260. this.uavIdValue = id
  261. this.uavNameValue = uavName
  262. this.showUavDept = true
  263. this.getDeptTree()
  264. },
  265. closeDialog() {
  266. this.showUavDept = false
  267. },
  268. /** 查询无人机列表 */
  269. getList() {
  270. this.loading = true;
  271. listUav(this.queryParams).then(response => {
  272. this.uavList = response.rows;
  273. this.total = response.total;
  274. this.loading = false;
  275. });
  276. },
  277. /** 查询部门下拉树结构 */
  278. getDeptTree() {
  279. treeselect().then(response => {
  280. this.deptOptions = response.data;
  281. this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data)));
  282. });
  283. },
  284. // 过滤禁用的部门
  285. filterDisabledDept(deptList) {
  286. return deptList.filter(dept => {
  287. if (dept.disabled) {
  288. return false;
  289. }
  290. if (dept.children && dept.children.length) {
  291. dept.children = this.filterDisabledDept(dept.children);
  292. }
  293. return true;
  294. });
  295. },
  296. // 取消按钮
  297. cancel() {
  298. this.open = false;
  299. this.reset();
  300. },
  301. // 表单重置
  302. reset() {
  303. this.form = {
  304. id: null,
  305. baseStationName: null,
  306. baseStationId: null,
  307. baseStationSn: null,
  308. longitude: null,
  309. latitude: null,
  310. height: null,
  311. uavName: null,
  312. uavId: null,
  313. uavSn: null,
  314. deptId: null
  315. };
  316. this.resetForm("form");
  317. },
  318. /** 搜索按钮操作 */
  319. handleQuery() {
  320. this.queryParams.pageNum = 1;
  321. this.getList();
  322. },
  323. /** 重置按钮操作 */
  324. resetQuery() {
  325. this.resetForm("queryForm");
  326. this.handleQuery();
  327. },
  328. // 多选框选中数据
  329. handleSelectionChange(selection) {
  330. this.ids = selection.map(item => item.id)
  331. this.single = selection.length !== 1
  332. this.multiple = !selection.length
  333. },
  334. /** 新增按钮操作 */
  335. handleAdd() {
  336. this.reset();
  337. this.open = true;
  338. this.title = "添加无人机";
  339. },
  340. /** 修改按钮操作 */
  341. handleUpdate(row) {
  342. this.reset();
  343. const id = row.id || this.ids
  344. getUav(id).then(response => {
  345. this.form = response.data;
  346. this.open = true;
  347. this.title = "修改无人机";
  348. });
  349. },
  350. /** 提交按钮 */
  351. submitForm() {
  352. this.$refs["form"].validate(valid => {
  353. if (valid) {
  354. if (this.form.id != null) {
  355. updateUav(this.form).then(response => {
  356. this.$modal.msgSuccess("修改成功");
  357. this.open = false;
  358. this.getList();
  359. });
  360. } else {
  361. addUav(this.form).then(response => {
  362. this.$modal.msgSuccess("新增成功");
  363. this.open = false;
  364. this.getList();
  365. });
  366. }
  367. }
  368. });
  369. },
  370. /** 删除按钮操作 */
  371. handleDelete(row) {
  372. const ids = row.id || this.ids;
  373. this.$modal.confirm('是否确认删除无人机编号为"' + ids + '"的数据项?').then(function () {
  374. return delUav(ids);
  375. }).then(() => {
  376. this.getList();
  377. this.$modal.msgSuccess("删除成功");
  378. }).catch(() => {
  379. });
  380. },
  381. /** 导出按钮操作 */
  382. handleExport() {
  383. this.download('system/uav/export', {
  384. ...this.queryParams
  385. }, `uav_${new Date().getTime()}.xlsx`)
  386. }
  387. }
  388. };
  389. </script>