index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="140px">
  4. <el-form-item label="故障记录批次名称" prop="batchName">
  5. <el-input
  6. v-model="queryParams.batchName"
  7. placeholder="请输入故障记录批次名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport"
  20. v-hasPermi="['system:failure:import']">导入
  21. </el-button>
  22. </el-col>
  23. <el-col :span="1.5">
  24. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleGenerateReport"
  25. v-hasPermi="['system:failure:export']">报告生成</el-button>
  26. </el-col>
  27. <el-col :span="1.5">
  28. <el-button
  29. type="danger"
  30. plain
  31. icon="el-icon-delete"
  32. size="mini"
  33. :disabled="multiple"
  34. @click="handleDelete"
  35. v-hasPermi="['system:failureRecord:remove']"
  36. >删除
  37. </el-button>
  38. </el-col>
  39. <!--<el-col :span="1.5">-->
  40. <!-- <el-button-->
  41. <!-- type="warning"-->
  42. <!-- plain-->
  43. <!-- icon="el-icon-download"-->
  44. <!-- size="mini"-->
  45. <!-- @click="handleExport"-->
  46. <!-- v-hasPermi="['system:failureRecord:export']"-->
  47. <!-- >导出</el-button>-->
  48. <!--</el-col>-->
  49. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  50. </el-row>
  51. <el-table v-loading="loading" :data="failureRecordList" @selection-change="handleSelectionChange">
  52. <el-table-column type="selection" width="55" align="center"/>
  53. <el-table-column label="故障记录批次名称" align="center" prop="batchName"/>
  54. <el-table-column label="数据数量" align="center" prop="quantity"/>
  55. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  56. <template slot-scope="scope">
  57. <el-button
  58. size="mini"
  59. type="text"
  60. icon="el-icon-view"
  61. @click="handleView(scope.row)"
  62. v-hasPermi="['system:failureRecord:view']"
  63. >查看
  64. </el-button>
  65. <el-button
  66. size="mini"
  67. type="text"
  68. icon="el-icon-delete"
  69. @click="handleDelete(scope.row)"
  70. v-hasPermi="['system:failureRecord:remove']"
  71. >删除
  72. </el-button>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <pagination
  77. v-show="total>0"
  78. :total="total"
  79. :page.sync="queryParams.pageNum"
  80. :limit.sync="queryParams.pageSize"
  81. @pagination="getList"
  82. />
  83. <!-- 导入对话框 -->
  84. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  85. <el-input v-model="upload.batchName" placeholder="请输入批次名称"></el-input>
  86. <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
  87. :action="upload.url + '?batchName=' + upload.batchName + '&updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
  88. :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  89. <i class="el-icon-upload"></i>
  90. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  91. <div class="el-upload__tip text-center" slot="tip">
  92. <div class="el-upload__tip" slot="tip">
  93. <el-checkbox v-model="upload.updateSupport"/>
  94. 是否更新已经存在的故障数据
  95. </div>
  96. <span>仅允许导入xls、xlsx格式文件。</span>
  97. <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
  98. @click="importTemplate">下载模板
  99. </el-link>
  100. </div>
  101. </el-upload>
  102. <div slot="footer" class="dialog-footer">
  103. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  104. <el-button @click="closeFile">取 消</el-button>
  105. </div>
  106. </el-dialog>
  107. <!-- 查看故障记录对话框 -->
  108. <el-dialog :title="title" :visible.sync="open" width="1500px" append-to-body>
  109. <el-table v-loading="loading" :data="failureList">
  110. <el-table-column type="selection" width="55" align="center"/>
  111. <!--<el-table-column label="序号" align="center" prop="id" />-->
  112. <el-table-column label="ZQ" align="center" prop="zq"/>
  113. <el-table-column label="J/JD/XY" align="center" prop="jjdJxy"/>
  114. <el-table-column label="S" align="center" prop="s"/>
  115. <el-table-column label="LT" align="center" prop="bdlt"/>
  116. <el-table-column label="故障日期" align="center" prop="failureDate" width="180">
  117. <template slot-scope="scope">
  118. <span>{{ parseTime(scope.row.failureDate, "{y}-{m}-{d}") }}</span>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="机型" align="center" prop="aircraftType"/>
  122. <el-table-column label="发现时机" align="center" prop="discoveryTime"/>
  123. <el-table-column label="专业" align="center" prop="major"/>
  124. <el-table-column label="故障描述" align="center" prop="failureDescription"/>
  125. <el-table-column label="故障原因" align="center" prop="failureCause"/>
  126. <el-table-column label="故障名称" align="center" prop="failureName"/>
  127. <el-table-column label="故障件名称" align="center" prop="unserviceableCompName"/>
  128. <el-table-column label="故障件型别" align="center" prop="unserviceableCompType"/>
  129. <el-table-column label="故障件号码" align="center" prop="unserviceableCompNum"/>
  130. <el-table-column label="故障件所属系统" align="center" prop="unserviceableCompSystem"/>
  131. <el-table-column label="故障后果" align="center" prop="failureConsequence"/>
  132. <el-table-column label="故障责任" align="center" prop="failureDuty"/>
  133. <el-table-column label="故换件名称" align="center" prop="replacementCompName"/>
  134. <el-table-column label="故换件型别" align="center" prop="replacementCompType"/>
  135. <el-table-column label="故换件号码" align="center" prop="replacementCompNum"/>
  136. <el-table-column label="排除方法" align="center" prop="eliminationMethods"/>
  137. <!--<el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
  138. <!-- <template slot-scope="scope">-->
  139. <!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"-->
  140. <!-- v-hasPermi="['system:failure:edit']">修改</el-button>-->
  141. <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"-->
  142. <!-- v-hasPermi="['system:failure:remove']">删除</el-button>-->
  143. <!-- </template>-->
  144. <!--</el-table-column>-->
  145. </el-table>
  146. <pagination :total="failureTotal" :page.sync="failureQueryParams.pageNum"
  147. :limit.sync="failureQueryParams.pageSize"
  148. @pagination="getFailureList"/>
  149. <div slot="footer" class="dialog-footer">
  150. <el-button @click="cancel">取 消</el-button>
  151. </div>
  152. </el-dialog>
  153. <!-- 报告对话框 -->
  154. <el-dialog :title="report.title" :visible.sync="report.open" width="400px" append-to-body>
  155. <div style="margin: 5px">
  156. <el-row>
  157. <el-col>
  158. <span style="">故障月份</span>
  159. </el-col>
  160. <el-col>
  161. <el-date-picker v-model="report.reportDate" type="month" placeholder="选择故障月份" value-format="yyyy-MM">
  162. </el-date-picker>
  163. </el-col>
  164. </el-row>
  165. </div>
  166. <div style="margin: 5px">
  167. <el-row>
  168. <el-col><span style="">专业</span></el-col>
  169. <el-col>
  170. <el-select v-model="report.major" placeholder="请选择专业">
  171. <el-option v-for="item in report.majorOption" :key="item.major" :label="item.major" :value="item.major">
  172. </el-option>
  173. </el-select>
  174. </el-col>
  175. </el-row>
  176. </div>
  177. <div style="margin: 5px">
  178. <el-row>
  179. <el-col><span style="">机型系列</span></el-col>
  180. <el-col>
  181. <el-select v-model="selectedBrandIds" placeholder="请选择机型系列" multiple @change="handleBrandChange">
  182. <el-option v-for="option in brandOptions" :key="option.brandId" :label="option.brandName"
  183. :value="option.brandId"></el-option>
  184. </el-select>
  185. </el-col>
  186. </el-row>
  187. </div>
  188. <div slot="footer" class="dialog-footer">
  189. <el-button type="primary" @click="submitGenerateReport">确 定</el-button>
  190. <el-button @click="report.open = false">取 消</el-button>
  191. </div>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import {
  197. listFailureRecord,
  198. getFailureRecord,
  199. delFailureRecord,
  200. addFailureRecord,
  201. updateFailureRecord
  202. } from "@/api/system/failureRecord";
  203. import {
  204. generateReport,
  205. getMajorOption,
  206. listFailure,
  207. } from "@/api/system/failure";
  208. import {getToken} from "@/utils/auth";
  209. import {getListBrand} from "@/api/system/brand";
  210. export default {
  211. name: "FailureRecord",
  212. data() {
  213. return {
  214. // 导入参数
  215. upload: {
  216. batchName: null,
  217. // 是否显示弹出层(用户导入)
  218. open: false,
  219. // 弹出层标题(用户导入)
  220. title: "",
  221. // 是否禁用上传
  222. isUploading: false,
  223. // 是否更新已经存在的用户数据
  224. updateSupport: 0,
  225. // 设置上传的请求头部
  226. headers: {Authorization: "Bearer " + getToken()},
  227. // 上传的地址
  228. url: process.env.VUE_APP_BASE_API + "/system/failureRecord/importData",
  229. },
  230. // 报告参数
  231. report: {
  232. // 是否显示弹出层
  233. open: false,
  234. // 弹出层标题
  235. title: "生成报告",
  236. // 报告日期
  237. reportDate: null,
  238. // 专业
  239. major: null,
  240. brandIds: null,
  241. majorOption: [],
  242. },
  243. selectedBrandIds: [],
  244. brandOptions: [], // 机型系列选项列表
  245. // 遮罩层
  246. loading: true,
  247. // 选中数组
  248. ids: [],
  249. // 非单个禁用
  250. single: true,
  251. // 非多个禁用
  252. multiple: true,
  253. // 显示搜索条件
  254. showSearch: true,
  255. // 总条数
  256. total: 0,
  257. failureTotal: 0,
  258. // failureTotal
  259. failureRecordList: [],
  260. // 弹出层标题
  261. title: "",
  262. // 是否显示弹出层
  263. open: false,
  264. // 查询参数
  265. queryParams: {
  266. pageNum: 1,
  267. pageSize: 10,
  268. batchName: null,
  269. },
  270. failureQueryParams: {
  271. pageNum: 1,
  272. pageSize: 10,
  273. failureRecordId: null,
  274. },
  275. // 故障记录表格数据
  276. failureList: [],
  277. // 表单参数
  278. form: {},
  279. // 表单校验
  280. rules: {}
  281. };
  282. },
  283. created() {
  284. this.getList();
  285. },
  286. methods: {
  287. // 生成报告
  288. submitGenerateReport() {
  289. if (!this.report.reportDate && !this.report.major && !this.report.brandIds) {
  290. this.$message({
  291. showClose: true,
  292. message: "需要选择故障月份和专业和机型系列",
  293. type: "error",
  294. });
  295. return;
  296. }
  297. if (!this.report.reportDate) {
  298. this.$message({
  299. showClose: true,
  300. message: "需要选择故障月份",
  301. type: "error",
  302. });
  303. return;
  304. }
  305. if (!this.report.major) {
  306. this.$message({
  307. showClose: true,
  308. message: "需要选择专业",
  309. type: "error",
  310. });
  311. return;
  312. }
  313. if (!this.report.brandIds) {
  314. this.$message({
  315. showClose: true,
  316. message: "需要选择机型系列",
  317. type: "error",
  318. });
  319. return;
  320. }
  321. generateReport(this.report.reportDate, this.report.major, this.report.brandIds).then(
  322. (response) => {
  323. console.info("报告返回结果" + response);
  324. this.$message({
  325. showClose: true,
  326. message: response.msg,
  327. type: "success",
  328. });
  329. }
  330. );
  331. this.report.open = false;
  332. },
  333. handleBrandChange() {
  334. this.report.brandIds = this.selectedBrandIds.join(',');
  335. },
  336. /** 生成报告按钮操作 */
  337. handleGenerateReport() {
  338. this.report.title = "生成报告";
  339. this.report.open = true;
  340. this.report.reportDate = null;
  341. this.report.major = null;
  342. this.report.brandIds = null;
  343. this.selectedBrandIds = []; // 清空已选择的机型系列ID
  344. this.getBrandOptions(); // 在打开弹框时获取机型系列选项
  345. this.report.majorOption = getMajorOption();
  346. getMajorOption().then((response) => {
  347. this.report.majorOption = response.data;
  348. });
  349. },
  350. /** 获取机型系列选项 */
  351. getBrandOptions() {
  352. // 假设接口名称是 `listBrandOptions`
  353. getListBrand().then(response => {
  354. this.brandOptions = response.data; // 假设返回的数据结构为 {data: [{brandId: 1, brandName: '系列1'}, ...]}
  355. });
  356. },
  357. getFailureList() {
  358. /** 查询故障记录列表 */
  359. this.loading = true;
  360. listFailure(this.failureQueryParams).then((response) => {
  361. this.failureList = response.rows;
  362. this.failureTotal = response.total;
  363. this.loading = false;
  364. });
  365. },
  366. // 提交上传文件
  367. submitFileForm() {
  368. if (!this.upload.batchName) {
  369. this.$message.error('批次名称不能为空');
  370. return;
  371. }
  372. this.$refs.upload.submit();
  373. },
  374. closeFile() {
  375. this.upload.open = false;
  376. this.upload.batchName = null;
  377. },
  378. /** 导入按钮操作 */
  379. handleImport() {
  380. this.upload.title = "导入";
  381. this.upload.open = true;
  382. },
  383. // 文件上传中处理
  384. handleFileUploadProgress(event, file, fileList) {
  385. this.upload.isUploading = true;
  386. },
  387. // 文件上传成功处理
  388. handleFileSuccess(response, file, fileList) {
  389. this.upload.open = false;
  390. this.upload.isUploading = false;
  391. this.$refs.upload.clearFiles();
  392. this.$alert(
  393. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  394. response.msg +
  395. "</div>",
  396. "导入结果",
  397. {dangerouslyUseHTMLString: true}
  398. );
  399. this.getList();
  400. },
  401. /** 下载模板操作 */
  402. importTemplate() {
  403. this.download(
  404. "system/failure/importTemplate",
  405. {},
  406. `failure_template_${new Date().getTime()}.xlsx`
  407. );
  408. },
  409. /** 查询故障记录总列表 */
  410. getList() {
  411. this.loading = true;
  412. listFailureRecord(this.queryParams).then(response => {
  413. this.failureRecordList = response.rows;
  414. this.total = response.total;
  415. this.loading = false;
  416. });
  417. },
  418. // 取消按钮
  419. cancel() {
  420. this.open = false;
  421. this.reset();
  422. },
  423. // 表单重置
  424. reset() {
  425. this.form = {
  426. id: null,
  427. batchName: null,
  428. quantity: null,
  429. createBy: null,
  430. createTime: null,
  431. updateBy: null,
  432. updateTime: null
  433. };
  434. this.resetForm("form");
  435. },
  436. /** 搜索按钮操作 */
  437. handleQuery() {
  438. this.queryParams.pageNum = 1;
  439. this.getList();
  440. },
  441. /** 重置按钮操作 */
  442. resetQuery() {
  443. this.resetForm("queryForm");
  444. this.handleQuery();
  445. },
  446. // 多选框选中数据
  447. handleSelectionChange(selection) {
  448. this.ids = selection.map(item => item.id)
  449. this.single = selection.length !== 1
  450. this.multiple = !selection.length
  451. },
  452. /** 新增按钮操作 */
  453. handleAdd() {
  454. this.reset();
  455. this.open = true;
  456. this.title = "添加故障记录总";
  457. },
  458. /** 查看按钮操作 */
  459. handleView(row) {
  460. this.reset();
  461. const id = row.id || this.ids
  462. this.title = "故障记录";
  463. this.failureQueryParams.failureRecordId = id
  464. this.getFailureList()
  465. this.open = true;
  466. this.title = "故障记录";
  467. // getFailureRecord(id).then(response => {
  468. //
  469. // });
  470. },
  471. /** 提交按钮 */
  472. submitForm() {
  473. this.$refs["form"].validate(valid => {
  474. if (valid) {
  475. if (this.form.id != null) {
  476. updateFailureRecord(this.form).then(response => {
  477. this.$modal.msgSuccess("修改成功");
  478. this.open = false;
  479. this.getList();
  480. });
  481. } else {
  482. addFailureRecord(this.form).then(response => {
  483. this.$modal.msgSuccess("新增成功");
  484. this.open = false;
  485. this.getList();
  486. });
  487. }
  488. }
  489. });
  490. },
  491. /** 删除按钮操作 */
  492. handleDelete(row) {
  493. const ids = row.id || this.ids;
  494. this.$modal.confirm('是否确认删除故障记录总编号为"' + ids + '"的数据项?').then(function () {
  495. return delFailureRecord(ids);
  496. }).then(() => {
  497. this.getList();
  498. this.$modal.msgSuccess("删除成功");
  499. }).catch(() => {
  500. });
  501. },
  502. /** 导出按钮操作 */
  503. handleExport() {
  504. this.download('system/failureRecord/export', {
  505. ...this.queryParams
  506. }, `failureRecord_${new Date().getTime()}.xlsx`)
  507. }
  508. }
  509. };
  510. </script>