monitoruavdept.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10" class="mb8">
  4. <el-col :span="1.5">
  5. <el-button
  6. type="primary"
  7. plain
  8. icon="el-icon-plus"
  9. size="mini"
  10. @click="handleAdd"
  11. >新增
  12. </el-button>
  13. </el-col>
  14. <el-col :span="1.5">
  15. <el-button
  16. type="success"
  17. plain
  18. icon="el-icon-edit"
  19. size="mini"
  20. :disabled="single"
  21. @click="handleUpdate"
  22. >修改
  23. </el-button>
  24. </el-col>
  25. <el-col :span="1.5">
  26. <el-button
  27. type="danger"
  28. plain
  29. icon="el-icon-delete"
  30. size="mini"
  31. :disabled="multiple"
  32. @click="handleDelete"
  33. >删除
  34. </el-button>
  35. </el-col>
  36. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  37. </el-row>
  38. <el-table v-loading="loading" :data="uavdeptList" @selection-change="handleSelectionChange">
  39. <el-table-column type="selection" width="55" align="center"/>
  40. <el-table-column label="部门名称" align="center" prop="mapDeptName"/>
  41. <el-table-column label="部门类型" align="center" prop="deptProtype" :formatter="deptProtypeFormat" />
  42. <el-table-column label="指挥中心" align="center" prop="isCommandCenter" :formatter="isCommandCenterFormat" />
  43. <el-table-column label="添加时间" align="center" prop="createTime"/>
  44. <el-table-column label="修改时间" align="center" prop="updateTime"/>
  45. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  46. <template slot-scope="scope">
  47. <el-button
  48. size="mini"
  49. type="text"
  50. icon="el-icon-edit"
  51. @click="handleUpdate(scope.row)"
  52. >修改
  53. </el-button>
  54. <el-button
  55. size="mini"
  56. type="text"
  57. icon="el-icon-delete"
  58. @click="handleDelete(scope.row)"
  59. >删除
  60. </el-button>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <pagination
  65. v-show="total>0"
  66. :total="total"
  67. :page.sync="queryParams.pageNum"
  68. :limit.sync="queryParams.pageSize"
  69. @pagination="getList"
  70. />
  71. <!-- 添加或修改AI对应部门对话框 -->
  72. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  73. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  74. <el-form-item label="部门名称" prop="mapDeptId">
  75. <treeselect :options="deptOptions" v-model="form.mapDeptId" :show-count="true" placeholder="请选择部门名称"
  76. @select="hx"/>
  77. </el-form-item>
  78. <el-form-item label="部门类型" prop="deptProtype">
  79. <el-select v-model="form.deptProtype" placeholder="请输入部门类型">
  80. <el-option
  81. v-for="item in deptProtypeOptions"
  82. :key="item.value"
  83. :value="item.value"
  84. :label="item.label"
  85. />
  86. </el-select>
  87. </el-form-item>
  88. <el-form-item label="指挥中心" prop="isCommandCenter">
  89. <el-radio v-model='form.isCommandCenter' :label='0'>否</el-radio>
  90. <el-radio v-model='form.isCommandCenter' :label='1'>是</el-radio>
  91. </el-form-item>
  92. </el-form>
  93. <div slot="footer" class="dialog-footer">
  94. <el-button type="primary" @click="submitForm">确 定</el-button>
  95. <el-button @click="cancel">取 消</el-button>
  96. </div>
  97. </el-dialog>
  98. </div>
  99. </template>
  100. <script>
  101. import {
  102. listAidevicedept,
  103. getAidevicedept,
  104. delAidevicedept,
  105. addAidevicedept,
  106. updateAidevicedept
  107. } from "@/api/centerMonitor/aidevicedept/aidevicedept";
  108. import {treeselect} from "@/api/system/dept";
  109. import Treeselect from "@riophae/vue-treeselect";
  110. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  111. export default {
  112. name: "Uavdept",
  113. components: {
  114. Treeselect
  115. },
  116. data() {
  117. return {
  118. // 遮罩层
  119. loading: true,
  120. // 选中数组
  121. ids: [],
  122. // 非单个禁用
  123. single: true,
  124. // 非多个禁用
  125. multiple: true,
  126. // 显示搜索条件
  127. showSearch: true,
  128. // 总条数
  129. total: 0,
  130. // AI对应部门表格数据
  131. uavdeptList: [],
  132. // 部门树选项
  133. deptOptions: undefined,
  134. // 弹出层标题
  135. title: "",
  136. // 是否显示弹出层
  137. open: false,
  138. // 查询参数
  139. queryParams: {
  140. pageNum: 1,
  141. pageSize: 10,
  142. deviceId: null,
  143. deviceName: null,
  144. mapDeptId: null,
  145. mapDeptName: null,
  146. },
  147. // 表单参数
  148. form: {},
  149. // 表单校验
  150. rules: {
  151. mapDeptId: [
  152. {required: true, message: "部门名称不能为空", trigger: "blur"}
  153. ],
  154. deptProtype: [
  155. { required: true, message: "部门类型不能为空", trigger: "blur" }
  156. ],
  157. isCommandCenter: [
  158. { required: true, message: "请选择是否指挥中心", trigger: "blur" }
  159. ],
  160. },
  161. deptProtypeOptions: [
  162. {value: "1", label: '责任单位,接收推送'},
  163. {value: "2", label: '查看单位'}
  164. ],
  165. isCommandCenterOptions: [
  166. {value: "0", label: '否'},
  167. {value: "1", label: '是'}
  168. ],
  169. };
  170. },
  171. props: {
  172. uavId: null,
  173. uavName: null,
  174. uavSn: null,
  175. },
  176. created() {
  177. this.getList();
  178. this.getTreeselect();
  179. },
  180. methods: {
  181. // 部门类型字典翻译
  182. deptProtypeFormat(row, column) {
  183. var name = "";
  184. this.deptProtypeOptions.forEach(function (item, index) {
  185. if (row.deptProtype == item.value) {
  186. name = item.label;
  187. }
  188. });
  189. return name;
  190. },
  191. // 是否指挥中心字典翻译
  192. isCommandCenterFormat(row, column) {
  193. var name = "";
  194. this.isCommandCenterOptions.forEach(function (item, index) {
  195. if (row.isCommandCenter == item.value) {
  196. name = item.label;
  197. }
  198. });
  199. return name;
  200. },
  201. /** 查询AI对应部门列表 */
  202. getList() {
  203. this.loading = true;
  204. this.queryParams.deviceId = this.uavId;
  205. listAidevicedept(this.queryParams).then(response => {
  206. this.uavdeptList = response.rows;
  207. this.total = response.total;
  208. this.loading = false;
  209. });
  210. },
  211. /** 查询部门下拉树结构 */
  212. getTreeselect() {
  213. treeselect().then(response => {
  214. this.deptOptions = response.data;
  215. });
  216. },
  217. //部门ID、部门名称赋值
  218. hx(node) {
  219. this.form.mapDeptId = node.id;
  220. this.form.mapDeptName = node.label
  221. },
  222. // 取消按钮
  223. cancel() {
  224. this.open = false;
  225. this.reset();
  226. },
  227. // 表单重置
  228. reset() {
  229. this.form = {
  230. id: null,
  231. deviceId: null,
  232. mapDeptId: null,
  233. };
  234. this.resetForm("form");
  235. },
  236. /** 搜索按钮操作 */
  237. handleQuery() {
  238. this.queryParams.pageNum = 1;
  239. this.getList();
  240. },
  241. /** 重置按钮操作 */
  242. resetQuery() {
  243. this.resetForm("queryForm");
  244. this.handleQuery();
  245. },
  246. // 多选框选中数据
  247. handleSelectionChange(selection) {
  248. this.ids = selection.map(item => item.id)
  249. this.single = selection.length !== 1
  250. this.multiple = !selection.length
  251. },
  252. /** 新增按钮操作 */
  253. handleAdd() {
  254. this.reset();
  255. this.form.deviceId = this.uavId;
  256. this.form.deviceName = this.uavName;
  257. this.form.deviceCode = this.uavSn;
  258. this.open = true;
  259. this.title = "添加无人机对应部门";
  260. },
  261. /** 修改按钮操作 */
  262. handleUpdate(row) {
  263. this.reset();
  264. const id = row.id || this.ids
  265. getAidevicedept(id).then(response => {
  266. this.form = response.data;
  267. this.open = true;
  268. this.title = "修改无人机对应部门";
  269. });
  270. },
  271. /** 提交按钮 */
  272. submitForm() {
  273. this.$refs["form"].validate(valid => {
  274. if (valid) {
  275. if (this.form.id != null) {
  276. updateAidevicedept(this.form).then(response => {
  277. this.$modal.msgSuccess("修改成功");
  278. this.open = false;
  279. this.getList();
  280. });
  281. } else {
  282. addAidevicedept(this.form).then(response => {
  283. this.$modal.msgSuccess("新增成功");
  284. this.open = false;
  285. this.getList();
  286. });
  287. }
  288. }
  289. });
  290. },
  291. /** 删除按钮操作 */
  292. handleDelete(row) {
  293. const ids = row.id || this.ids;
  294. this.$modal.confirm('是否确认删除数据项?').then(function () {
  295. return delAidevicedept(ids);
  296. }).then(() => {
  297. this.getList();
  298. this.$modal.msgSuccess("删除成功");
  299. }).catch(() => {
  300. });
  301. },
  302. }
  303. };
  304. </script>