index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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="aircraftNumber">
  5. <el-input v-model="queryParams.aircraftNumber" placeholder="请输入机号" clearable
  6. @keyup.enter.native="handleQuery" />
  7. </el-form-item>
  8. <el-form-item label="架次号" prop="sortieNumber">
  9. <el-input v-model="queryParams.sortieNumber" placeholder="请输入架次号" clearable @keyup.enter.native="handleQuery" />
  10. </el-form-item>
  11. <el-form-item label="开始时间" prop="startTime">
  12. <el-date-picker clearable v-model="queryParams.startTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
  13. placeholder="请选择开始时间">
  14. </el-date-picker>
  15. </el-form-item>
  16. <el-form-item label="结束时间" prop="endTime">
  17. <el-date-picker clearable v-model="queryParams.endTime" type="datetime" :picker-options="pickerOption()"
  18. value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择结束时间">
  19. </el-date-picker>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  23. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-row :gutter="10" class="mb8">
  27. <el-col :span="1.5">
  28. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  29. v-hasPermi="['manage:sortie:add']">新增</el-button>
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  33. v-hasPermi="['manage:sortie:remove']">删除</el-button>
  34. </el-col>
  35. <el-col :span="1.5">
  36. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  37. v-hasPermi="['manage:sortie:export']">导出</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button type="primary" icon="el-icon-upload2" size="mini" @click="handleImport"
  41. v-hasPermi="['manage:sortie:export']">导入</el-button>
  42. </el-col>
  43. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  44. </el-row>
  45. <el-table v-loading="loading" :data="sortieList" @selection-change="handleSelectionChange">
  46. <el-table-column type="selection" width="55" align="center" />
  47. <el-table-column label="机号" align="center" prop="aircraftNumber" />
  48. <el-table-column label="架次号" align="center" prop="sortieNumber">
  49. <template slot-scope="scope">
  50. <el-button
  51. @click.native.prevent="detail(scope.row)"
  52. type="success"
  53. plain
  54. :span="1.5"
  55. size="mini">
  56. {{ scope.row.sortieNumber }}
  57. </el-button>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="开始时间" align="center" prop="startTime" width="180">
  61. <template slot-scope="scope">
  62. <span>{{
  63. parseTime(scope.row.startTime, "{y}-{m}-{d} {h}:{i}:{s}")
  64. }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="结束时间" align="center" prop="endTime" width="180">
  68. <template slot-scope="scope">
  69. <span>{{
  70. parseTime(scope.row.endTime, "{y}-{m}-{d} {h}:{i}:{s}")
  71. }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="飞行时长" align="center" prop="duration" />
  75. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  76. <template slot-scope="scope">
  77. <el-button type="text" icon="el-icon-edit" size="mini" @click="handleUpdate(scope.row)"
  78. v-hasPermi="['manage:sortie:edit']">修改</el-button>
  79. <el-button size="mini" type="text" @click="playBack(scope.row)"
  80. v-hasPermi="['manage:sortie:edit']">数据回放</el-button>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  85. @pagination="getList" />
  86. <!-- 添加或修改架次信息对话框 -->
  87. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
  88. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  89. <el-form-item label="机号" prop="aircraftNumber">
  90. <el-input v-model="form.aircraftNumber" placeholder="请输入机号" />
  91. </el-form-item>
  92. <el-form-item label="架次号" prop="sortieNumber">
  93. <el-input v-model="form.sortieNumber" placeholder="请输入架次号" />
  94. </el-form-item>
  95. <el-form-item label="开始时间" prop="startTime">
  96. <el-date-picker clearable v-model="form.startTime" type="datetime" style="width: 100%"
  97. value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择开始时间">
  98. </el-date-picker>
  99. </el-form-item>
  100. <el-form-item label="结束时间" prop="endTime">
  101. <el-date-picker clearable v-model="form.endTime" type="datetime" style="width: 100%"
  102. value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择结束时间" :picker-options="formPickerOption()">
  103. </el-date-picker>
  104. </el-form-item>
  105. <el-form-item label="飞行时长" prop="duration">
  106. <el-input v-model="form.duration" placeholder="请输入飞行时长" />
  107. </el-form-item>
  108. </el-form>
  109. <div slot="footer" class="dialog-footer">
  110. <el-button type="primary" @click="submitForm">确 定</el-button>
  111. <el-button @click="cancel">取 消</el-button>
  112. </div>
  113. </el-dialog>
  114. <!-- 用户导入对话框 -->
  115. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  116. <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
  117. :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
  118. :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  119. <i class="el-icon-upload"></i>
  120. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  121. <div class="el-upload__tip text-center" slot="tip">
  122. <div class="el-upload__tip" slot="tip">
  123. <el-checkbox v-model="upload.updateSupport" />
  124. 是否更新已经存在的架次数据
  125. </div>
  126. <span>仅允许导入xls、xlsx格式文件。</span>
  127. <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
  128. @click="importTemplate">下载模板</el-link>
  129. </div>
  130. </el-upload>
  131. <div slot="footer" class="dialog-footer">
  132. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  133. <el-button @click="upload.open = false">取 消</el-button>
  134. </div>
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. import {
  140. listSortie,
  141. getSortie,
  142. delSortie,
  143. addSortie,
  144. updateSortie,
  145. } from '@/api/manage/sortie'
  146. import { getToken } from '@/utils/auth'
  147. import { parseTime } from '@/utils/common'
  148. export default {
  149. name: 'Sortie',
  150. data() {
  151. return {
  152. // 遮罩层
  153. loading: true,
  154. // 选中数组
  155. ids: [],
  156. //选中的架次号
  157. sortieIds: [],
  158. // 非单个禁用
  159. single: true,
  160. // 非多个禁用
  161. multiple: true,
  162. // 显示搜索条件
  163. showSearch: true,
  164. // 总条数
  165. total: 0,
  166. // 架次信息表格数据
  167. sortieList: [],
  168. // 弹出层标题
  169. title: '',
  170. // 是否显示弹出层
  171. open: false,
  172. startTime:'',
  173. endTime:'',
  174. // 查询参数
  175. queryParams: {
  176. pageNum: 1,
  177. pageSize: 10,
  178. aircraftNumber: null,
  179. sortieNumber: null,
  180. startTime: '',
  181. endTime: '',
  182. duration: null,
  183. },
  184. upload: {
  185. title: '',
  186. // 是否显示弹出层
  187. open: false,
  188. // 是否禁用上传
  189. isUploading: false,
  190. // 设置上传的请求头部
  191. headers: { Authorization: 'Bearer ' + getToken() },
  192. // 是否更新已存在数据
  193. updateSupport: 0,
  194. // 上传的地址
  195. url: process.env.VUE_APP_BASE_API + '/manage/sortie/import',
  196. },
  197. // 表单参数
  198. form: {},
  199. // 表单校验
  200. rules: {},
  201. }
  202. },
  203. created() {
  204. this.getList()
  205. },
  206. methods: {
  207. //选择结束时间的限制
  208. pickerOption() {
  209. if(this.queryParams.startTime != undefined){
  210. let date = new Date(this.queryParams.startTime)
  211. let minutes = date.getMinutes() + 1
  212. // // h和m 是将日期只取时分
  213. let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  214. let m = (minutes < 10 ? '0' + minutes : minutes);
  215. // pickerDate 判断当前选择时间是否等于上条数据时间
  216. // 若等于时,限制时间从00:00:00 - 上条数据开始时间,不等于时,24小时可选
  217. let pickerDate = new Date(this.queryParams.endTime).toDateString() === new Date(this.queryParams.startTime).toDateString()
  218. return {
  219. // 日期限制
  220. disabledDate: (time) => {
  221. let old = this.queryParams.startTime
  222. return time.getTime() < new Date(old).getTime() - 86400000
  223. },
  224. // 时间限制
  225. selectableRange: pickerDate? h + m + ':00 - 23:59:59' : '00:00:00 - 23:59:59'
  226. }
  227. }
  228. },
  229. //添加和修改时间限制
  230. formPickerOption() {
  231. if(this.form.startTime != undefined){
  232. let date = new Date(this.form.startTime)
  233. let minutes = date.getMinutes() + 1
  234. // // h和m 是将日期只取时分
  235. let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  236. let m = (minutes < 10 ? '0' + minutes : minutes);
  237. // pickerDate 判断当前选择时间是否等于上条数据时间
  238. // 若等于时,限制时间从00:00:00 - 上条数据开始时间,不等于时,24小时可选
  239. let pickerDate = new Date(this.form.endTime).toDateString() === new Date(this.form.startTime).toDateString()
  240. return {
  241. // 日期限制
  242. disabledDate: (time) => {
  243. let old = this.form.startTime
  244. return time.getTime() < new Date(old).getTime() - 86400000
  245. },
  246. // 时间限制
  247. selectableRange: pickerDate? h + m + ':00 - 23:59:59' : '00:00:00 - 23:59:59'
  248. }
  249. }
  250. },
  251. /** 查询架次信息列表 */
  252. getList() {
  253. this.loading = true
  254. listSortie(this.queryParams).then(response => {
  255. this.sortieList = response.rows
  256. this.total = response.total
  257. this.loading = false
  258. })
  259. },
  260. // 取消按钮
  261. cancel() {
  262. this.open = false
  263. this.reset()
  264. },
  265. // 表单重置
  266. reset() {
  267. this.form = {
  268. id: null,
  269. aircraftNumber: null,
  270. sortieNumber: null,
  271. startTime: null,
  272. endTime: null,
  273. duration: null,
  274. isDelete: null
  275. }
  276. this.resetForm('form')
  277. },
  278. // 跳转到选择参数
  279. playBack(row) {
  280. const sortieNumber = row.sortieNumber
  281. // this.$router.push(
  282. // '/manage/integratedDataManage/sortie/dataPlayback/' + sortieNumber
  283. // )
  284. // this.$router.push(
  285. // '/manage/integratedDataManage/sortie/selectParameters/' + sortieNumber
  286. // )
  287. this.$router.push({
  288. name: 'selectParameters',
  289. params: {
  290. sortieNumber: sortieNumber
  291. },
  292. })
  293. },
  294. // 架次详情
  295. detail(row){
  296. const sortieNumber = row.sortieNumber
  297. this.$router.push({
  298. name: 'SortieDetail',
  299. params: {
  300. sortieNumber: sortieNumber
  301. },
  302. })
  303. },
  304. /** 下载模板操作 */
  305. importTemplate() {
  306. this.download(
  307. '/manage/sortie/importTemplate',
  308. {},
  309. `sortie_template_${new Date().getTime()}.xlsx`
  310. )
  311. },
  312. /** 搜索按钮操作 */
  313. handleQuery() {
  314. this.queryParams.pageNum = 1
  315. this.getList()
  316. },
  317. /** 重置按钮操作 */
  318. resetQuery() {
  319. this.resetForm('queryForm')
  320. this.handleQuery()
  321. },
  322. // 多选框选中数据
  323. handleSelectionChange(selection) {
  324. this.ids = selection.map(item => item.id)
  325. this.sortieIds = selection.map(item => item.sortieNumber)
  326. this.single = selection.length !== 1
  327. this.multiple = !selection.length
  328. },
  329. /** 新增按钮操作 */
  330. handleAdd() {
  331. this.reset()
  332. this.open = true
  333. this.title = '添加架次信息'
  334. },
  335. /** 导入按钮操作 */
  336. handleImport() {
  337. this.upload.title = '架次导入'
  338. this.upload.open = true
  339. },
  340. /** 修改按钮操作 */
  341. handleUpdate(row) {
  342. this.reset()
  343. const id = row.id || this.ids
  344. getSortie(id).then(response => {
  345. this.form = response.data
  346. this.open = true
  347. this.title = '修改架次信息'
  348. })
  349. },
  350. submitFileForm() {
  351. // this.$refs["uploadForm"].validate(valid => {
  352. // if (!valid) {
  353. // return;
  354. // }
  355. // this.$refs.upload.submit();
  356. // })
  357. this.$refs.upload.submit()
  358. },
  359. uploadClose() {
  360. // 关闭弹窗
  361. this.upload.open = false
  362. // 重置上传状态和文件
  363. this.upload.isUploading = false
  364. this.$refs.upload.clearFiles()
  365. // 重置表单
  366. this.upload.form = {}
  367. // this.resetForm("uploadForm");
  368. },
  369. // 文件上传中处理
  370. handleFileUploadProgress(event, file, fileList) {
  371. this.upload.isUploading = true
  372. },
  373. // 文件上传成功处理
  374. handleFileSuccess(response, file, fileList) {
  375. if (response.code !== 200) {
  376. this.$modal.msgError(response.msg)
  377. return
  378. }
  379. this.upload.open = false
  380. this.upload.isUploading = false
  381. this.$refs.upload.clearFiles()
  382. this.$alert(
  383. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  384. response.msg +
  385. '</div>',
  386. '导入结果',
  387. { dangerouslyUseHTMLString: true }
  388. )
  389. this.getList()
  390. },
  391. /** 提交按钮 */
  392. submitForm() {
  393. this.$refs['form'].validate(valid => {
  394. if (valid) {
  395. if (this.form.id != null) {
  396. this.form.updateBy = this.$store.state.user.name
  397. this.form.updateTime = parseTime(new Date())
  398. updateSortie(this.form).then(response => {
  399. this.$modal.msgSuccess('修改成功')
  400. this.open = false
  401. this.getList()
  402. })
  403. } else {
  404. this.form.createBy = this.$store.state.user.name
  405. this.form.createTime = parseTime(new Date())
  406. addSortie(this.form).then(response => {
  407. this.$modal.msgSuccess('新增成功')
  408. this.open = false
  409. this.getList()
  410. })
  411. }
  412. }
  413. })
  414. },
  415. /** 删除按钮操作 */
  416. handleDelete(row) {
  417. const ids = row.id || this.ids
  418. this.$modal
  419. .confirm('是否确认删除架次号为"' + this.sortieIds + '"的数据项?')
  420. .then(function () {
  421. return delSortie(ids)
  422. })
  423. .then(() => {
  424. this.getList()
  425. this.$modal.msgSuccess('删除成功')
  426. })
  427. .catch(() => {})
  428. },
  429. /** 导出按钮操作 */
  430. handleExport() {
  431. this.download(
  432. 'manage/sortie/export',
  433. {
  434. ...this.queryParams,
  435. },
  436. `sortie_${new Date().getTime()}.xlsx`
  437. )
  438. },
  439. },
  440. }
  441. </script>