index.vue 18 KB

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