index.vue 7.9 KB

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