index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. v-show="showSearch"
  5. ref="queryForm"
  6. :model="queryParams"
  7. size="small"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="机型" prop="aircraftTypeId">
  12. <el-select
  13. v-model="queryParams.aircraftTypeId"
  14. placeholder="请选择"
  15. @change="handleaircraftChange"
  16. >
  17. <el-option
  18. v-for="item in typeOption"
  19. :key="item.id"
  20. :label="item.name"
  21. :value="item.id"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="系统" prop="aircraftSystemId">
  26. <el-select
  27. v-model="queryParams.aircraftSystemId"
  28. placeholder="请选择"
  29. @change="handlesystemChange"
  30. >
  31. <el-option
  32. v-for="item in systemOption"
  33. :key="item.id"
  34. :label="item.aircraftSystemName"
  35. :value="item.id"
  36. />
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="分系统" prop="aircraftSubsystemId">
  40. <el-select
  41. v-model="queryParams.aircraftSubsystemId"
  42. placeholder="请选择"
  43. >
  44. <el-option
  45. v-for="item in subSystemOption"
  46. :key="item.id"
  47. :label="item.aircraftSubsystemName"
  48. :value="item.id"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="故障现象" prop="faultPhenomenon">
  53. <el-input
  54. v-model="queryParams.faultPhenomenon"
  55. placeholder="请输入故障现象"
  56. clearable
  57. @keyup.enter.native="handleQuery"
  58. />
  59. </el-form-item>
  60. <el-form-item label="故障原因" prop="faultCause">
  61. <el-input
  62. v-model="queryParams.faultCause"
  63. placeholder="请输入故障原因"
  64. clearable
  65. @keyup.enter.native="handleQuery"
  66. />
  67. </el-form-item>
  68. <!-- <el-form-item label="故障树" prop="faultTreePath">
  69. <el-input
  70. v-model="queryParams.faultTreePath"
  71. placeholder="请输入故障树"
  72. clearable
  73. @keyup.enter.native="handleQuery"
  74. />
  75. </el-form-item> -->
  76. <!-- <el-form-item label="故障图" prop="faultPicturePath">
  77. <el-input
  78. v-model="queryParams.faultPicturePath"
  79. placeholder="请输入故障图"
  80. clearable
  81. @keyup.enter.native="handleQuery"
  82. />
  83. </el-form-item>
  84. <el-form-item label="排故方法" prop="troubleshootingMethodPath">
  85. <el-input
  86. v-model="queryParams.troubleshootingMethodPath"
  87. placeholder="请输入排故方法"
  88. clearable
  89. @keyup.enter.native="handleQuery"
  90. />
  91. </el-form-item>
  92. <el-form-item label="浏览次数" prop="viewCount">
  93. <el-input
  94. v-model="queryParams.viewCount"
  95. placeholder="请输入浏览次数"
  96. clearable
  97. @keyup.enter.native="handleQuery"
  98. />
  99. </el-form-item> -->
  100. <el-form-item>
  101. <el-button
  102. type="primary"
  103. icon="el-icon-search"
  104. size="mini"
  105. @click="handleQuery"
  106. >搜索</el-button
  107. >
  108. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  109. >重置</el-button
  110. >
  111. </el-form-item>
  112. </el-form>
  113. <el-row :gutter="10" class="mb8">
  114. <el-col :span="1.5">
  115. <el-button
  116. v-hasPermi="['system:case:add']"
  117. type="primary"
  118. plain
  119. icon="el-icon-plus"
  120. size="mini"
  121. @click="handleAdd"
  122. >新增</el-button
  123. >
  124. </el-col>
  125. <el-col :span="1.5">
  126. <el-button
  127. v-hasPermi="['system:case:edit']"
  128. type="success"
  129. plain
  130. icon="el-icon-edit"
  131. size="mini"
  132. :disabled="single"
  133. @click="handleUpdate"
  134. >修改</el-button
  135. >
  136. </el-col>
  137. <el-col :span="1.5">
  138. <el-button
  139. v-hasPermi="['system:case:remove']"
  140. type="danger"
  141. plain
  142. icon="el-icon-delete"
  143. size="mini"
  144. :disabled="multiple"
  145. @click="handleDelete"
  146. >删除</el-button
  147. >
  148. </el-col>
  149. <el-col :span="1.5">
  150. <el-button
  151. v-hasPermi="['system:case:export']"
  152. type="warning"
  153. plain
  154. icon="el-icon-download"
  155. size="mini"
  156. @click="handleExport"
  157. >导出</el-button
  158. >
  159. </el-col>
  160. <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
  161. </el-row>
  162. <el-table
  163. v-loading="loading"
  164. :data="caseList"
  165. @selection-change="handleSelectionChange"
  166. >
  167. <el-table-column type="selection" width="55" align="center" />
  168. <el-table-column label="编号" align="center" prop="id" />
  169. <el-table-column label="机型" align="center" prop="aircraftTypeName" />
  170. <el-table-column label="系统" align="center" prop="aircraftSystemName" />
  171. <el-table-column
  172. label="分系统"
  173. align="center"
  174. prop="aircraftSubsystemName"
  175. />
  176. <el-table-column label="故障现象" align="center" prop="faultPhenomenon" />
  177. <el-table-column label="故障原因" align="center" prop="faultCause" />
  178. <!-- <el-table-column label="故障树" align="center" prop="faultTreePath" />
  179. <el-table-column label="故障图" align="center" prop="faultPicturePath" />
  180. <el-table-column label="排故方法" align="center" prop="troubleshootingMethodPath" /> -->
  181. <el-table-column label="浏览次数" align="center" prop="viewCount" />
  182. <el-table-column label="作者" align="center" prop="author" />
  183. <el-table-column
  184. label="创建时间"
  185. align="center"
  186. prop="createTime"
  187. width="180"
  188. >
  189. <template slot-scope="scope">
  190. <span>{{ parseTime(scope.row.createTime) }}</span>
  191. </template>
  192. </el-table-column>
  193. <!-- <el-table-column label="最后修改人" align="center" prop="updateBy" />
  194. <el-table-column label="最后修改时间" align="center" prop="updateTime" width="180">
  195. <template slot-scope="scope">
  196. <span>{{ parseTime(scope.row.updateTime) }}</span>
  197. </template>
  198. </el-table-column> -->
  199. <el-table-column
  200. label="操作"
  201. align="center"
  202. class-name="small-padding fixed-width"
  203. >
  204. <template slot-scope="scope">
  205. <el-button
  206. v-hasPermi="['system:case:edit']"
  207. size="mini"
  208. type="text"
  209. icon="el-icon-edit"
  210. @click="handleUpdate(scope.row)"
  211. >修改</el-button
  212. >
  213. <el-button
  214. v-hasPermi="['system:case:remove']"
  215. size="mini"
  216. type="text"
  217. icon="el-icon-delete"
  218. @click="handleDelete(scope.row)"
  219. >删除</el-button
  220. >
  221. </template>
  222. </el-table-column>
  223. </el-table>
  224. <pagination
  225. v-show="total > 0"
  226. :total="total"
  227. :page.sync="queryParams.pageNum"
  228. :limit.sync="queryParams.pageSize"
  229. @pagination="getList"
  230. />
  231. <!-- 添加或修改故障案例管理对话框 -->
  232. <el-dialog
  233. :title="title"
  234. :visible.sync="open"
  235. width="80%"
  236. append-to-body
  237. :close-on-click-modal="false"
  238. :close-on-press-escape="false"
  239. >
  240. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  241. <el-row>
  242. <el-col :span="6"
  243. ><div class="grid-content bg-purple">
  244. <el-form-item label="机型" prop="faultPhenomenon">
  245. <el-select
  246. v-model="form.aircraftTypeId"
  247. placeholder="请选择"
  248. @change="handleaircraftChange1"
  249. >
  250. <el-option
  251. v-for="item in typeOption1"
  252. :key="item.id"
  253. :label="item.name"
  254. :value="item.id"
  255. />
  256. </el-select>
  257. </el-form-item></div
  258. ></el-col>
  259. <el-col :span="6"
  260. ><div class="grid-content bg-purple">
  261. <el-form-item label="系统" prop="aircraftSystemId">
  262. <el-select
  263. v-model="form.aircraftSystemId"
  264. placeholder="请选择"
  265. @change="handlesystemChange1"
  266. >
  267. <el-option
  268. v-for="item in systemOption1"
  269. :key="item.id"
  270. :label="item.aircraftSystemName"
  271. :value="item.id"
  272. />
  273. </el-select>
  274. </el-form-item></div
  275. ></el-col>
  276. <el-col :span="6"
  277. ><div class="grid-content bg-purple">
  278. <el-form-item label="分系统" prop="aircraftSubsystemId">
  279. <el-select
  280. v-model="form.aircraftSubsystemId"
  281. placeholder="请选择"
  282. >
  283. <el-option
  284. v-for="item in subSystemOption1"
  285. :key="item.id"
  286. :label="item.aircraftSubsystemName"
  287. :value="item.id"
  288. />
  289. </el-select>
  290. </el-form-item>
  291. </div>
  292. </el-col>
  293. <el-col :span="6">
  294. <div class="grid-content bg-purple">
  295. <el-form-item label="作者" prop="author">
  296. <el-input v-model="form.author" placeholder="请输入作者" />
  297. </el-form-item>
  298. </div>
  299. </el-col>
  300. </el-row>
  301. <el-row>
  302. <el-col :span="12">
  303. <el-card class="box-card" style="margin: 5px">
  304. <div slot="header" class="clearfix">
  305. <span>故障现象</span>
  306. </div>
  307. <div>
  308. <el-input
  309. v-model="form.faultPhenomenon"
  310. type="textarea"
  311. :rows="5"
  312. placeholder="请输入内容"
  313. maxlength="500"
  314. />
  315. </div>
  316. </el-card>
  317. </el-col>
  318. <el-col :span="12">
  319. <el-card class="box-card" style="margin: 5px">
  320. <div slot="header" class="clearfix">
  321. <span>故障原因</span>
  322. </div>
  323. <div>
  324. <el-input
  325. v-model="form.faultCause"
  326. type="textarea"
  327. :rows="5"
  328. placeholder="请输入内容"
  329. maxlength="500"
  330. />
  331. </div>
  332. </el-card>
  333. </el-col>
  334. </el-row>
  335. <el-row>
  336. <el-card class="box-card" style="margin: 5px">
  337. <div slot="header" class="clearfix">
  338. <span>故障树</span>
  339. </div>
  340. <div>
  341. <el-upload
  342. v-if="!form.faultTreePath"
  343. ref="loadtree"
  344. v-model="form.faultTreePath"
  345. class="avatar-uploader"
  346. :action="uploadFileUrl"
  347. :multiple="false"
  348. list-type="picture-card"
  349. :before-upload="beforeTreeUpload"
  350. :on-success="afterTreeUpload"
  351. :headers="headers"
  352. >
  353. <i class="el-icon-plus" />
  354. </el-upload>
  355. <div v-if="form.faultTreePath">
  356. <!-- <img :src="baseUrl+form.faultTreePath" style="max-width: 100%;" @load="showResetBtn = true;"> -->
  357. <img
  358. :src="baseUrl + form.faultTreePath"
  359. style="max-width: 100px"
  360. @load="showResetBtn = true"
  361. @click="
  362. showModal = true;
  363. imageSrc = form.faultTreePath;
  364. "
  365. />
  366. <div style="flex: 1" />
  367. <!-- 占位符,用于将重置按钮推到最右侧 -->
  368. <el-button
  369. v-if="showResetBtn"
  370. type="danger"
  371. @click="reuploadTree"
  372. >删除</el-button
  373. >
  374. </div>
  375. </div>
  376. </el-card>
  377. </el-row>
  378. <el-row>
  379. <el-card class="box-card" style="margin: 5px">
  380. <div slot="header" class="clearfix">
  381. <span>排故方法</span>
  382. </div>
  383. <el-row>
  384. <el-col :span="4">
  385. <span>故障图</span>
  386. <div>
  387. <el-upload
  388. v-if="!form.faultPicturePath"
  389. v-model="form.faultPicturePath"
  390. class="avatar-uploader"
  391. :action="uploadFileUrl"
  392. :multiple="false"
  393. list-type="picture-card"
  394. :before-upload="beforePicUpload"
  395. :on-success="afterPicUpload"
  396. :headers="headers"
  397. >
  398. <i class="el-icon-plus" />
  399. </el-upload>
  400. <div v-if="form.faultPicturePath">
  401. <img
  402. :src="baseUrl + form.faultPicturePath"
  403. style="max-width: 100px"
  404. @load="showResetBtnpic = true"
  405. @click="
  406. showModal = true;
  407. imageSrc = form.faultPicturePath;
  408. "
  409. />
  410. <div style="flex: 1" />
  411. <!-- 占位符,用于将重置按钮推到最右侧 -->
  412. <el-button
  413. v-if="showResetBtnpic"
  414. type="danger"
  415. @click="reuploadPic"
  416. >删除</el-button
  417. >
  418. </div>
  419. </div>
  420. </el-col>
  421. <el-col :span="20">
  422. <span>文档</span>
  423. <div>
  424. <el-upload
  425. v-if="!form.troubleshootingMethodPath"
  426. v-model="form.troubleshootingMethodPath"
  427. class="avatar-uploader"
  428. :action="uploadFileUrl"
  429. :multiple="false"
  430. list-type="picture-card"
  431. :before-upload="beforeMethodUpload"
  432. :on-success="afterMethodUpload"
  433. :headers="headers"
  434. >
  435. <i class="el-icon-plus" />
  436. </el-upload>
  437. <div v-if="form.troubleshootingMethodPath">
  438. <span style="margin: 10px">{{
  439. getFileNameByPath(form.troubleshootingMethodPath)
  440. }}</span>
  441. <el-button
  442. v-show="!viewWordFlag"
  443. type="primary"
  444. @click="viewWordFlag = true"
  445. >预览</el-button
  446. >
  447. <el-button
  448. v-show="viewWordFlag"
  449. type="primary"
  450. @click="viewWordFlag = false"
  451. >取消预览</el-button
  452. >
  453. <el-button
  454. type="primary"
  455. @click="download(form.troubleshootingMethodPath)"
  456. >下载</el-button
  457. >
  458. <el-button type="danger" @click="reuploadMethod"
  459. >删除</el-button
  460. >
  461. <div
  462. v-show="viewWordFlag"
  463. ref="troubleshootingMethodFile"
  464. />
  465. </div>
  466. </div>
  467. </el-col>
  468. </el-row>
  469. </el-card>
  470. </el-row>
  471. <div v-if="showModal" class="modal" @click="showModal = false">
  472. <img :src="baseUrl + imageSrc" class="full-image" />
  473. </div>
  474. </el-form>
  475. <div slot="footer" class="dialog-footer">
  476. <el-button type="primary" @click="submitForm">确 定</el-button>
  477. <el-button @click="cancel">取 消</el-button>
  478. </div>
  479. </el-dialog>
  480. </div>
  481. </template>
  482. <script>
  483. import {
  484. listCase,
  485. getCase,
  486. delCase,
  487. addCase,
  488. updateCase,
  489. } from "@/api/system/case";
  490. import { getTypeOption } from "@/api/system/type";
  491. import { getSystemOption } from "@/api/system/system";
  492. import { getSubSystemOption } from "@/api/system/subsystem";
  493. import { renderAsync } from "docx-preview";
  494. import { getToken } from "@/utils/auth";
  495. import axios from "axios";
  496. export default {
  497. name: "Case",
  498. data() {
  499. return {
  500. wordText: "",
  501. wordURL: "test.docx", // 文件地址,看你对应怎末获取、赋值
  502. showResetBtn: false,
  503. showResetBtnpic: false,
  504. name: "",
  505. fileList: [],
  506. hideUpload: false,
  507. // 遮罩层
  508. loading: true,
  509. // 选中数组
  510. ids: [],
  511. // 非单个禁用
  512. single: true,
  513. // 非多个禁用
  514. multiple: true,
  515. // 显示搜索条件
  516. showSearch: true,
  517. // 总条数
  518. total: 0,
  519. // 故障案例管理表格数据
  520. caseList: [],
  521. // 弹出层标题
  522. title: "",
  523. // 是否显示弹出层
  524. open: false,
  525. picUrl_tree: "",
  526. faultTreePath: "",
  527. // 查询参数
  528. queryParams: {
  529. pageNum: 1,
  530. pageSize: 10,
  531. aircraftTypeId: null,
  532. aircraftSystemId: null,
  533. aircraftSubsystemId: null,
  534. faultPhenomenon: null,
  535. faultCause: null,
  536. faultTreePath: null,
  537. faultPicturePath: null,
  538. troubleshootingMethodPath: null,
  539. viewCount: null,
  540. },
  541. // 表单参数
  542. form: {
  543. aircraftTypeId: null,
  544. aircraftSystemId: null,
  545. aircraftSubsystemId: null,
  546. faultPhenomenon: null,
  547. faultCause: null,
  548. id: null,
  549. faultTreePath: null, // 存储上传成功后的文件路径
  550. faultPicturePath: null,
  551. troubleshootingMethodPath: null,
  552. viewCount: null,
  553. createBy: null,
  554. createTime: null,
  555. updateBy: null,
  556. updateTime: null,
  557. },
  558. // 表单校验
  559. rules: {},
  560. fileList: [], // 存储上传文件列表
  561. typeOption: [],
  562. typeOption1: [],
  563. systemOption: [],
  564. subSystemOption: [],
  565. systemOption1: [],
  566. subSystemOption1: [],
  567. showModal: false, // 控制模态框显示的变量
  568. imageSrc: "", // 图片路径
  569. showResetBtnMethod: false,
  570. // file upload
  571. baseUrl: process.env.VUE_APP_BASE_API,
  572. uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传文件服务器地址
  573. headers: {
  574. Authorization: "Bearer " + getToken(),
  575. },
  576. viewWordFlag: false,
  577. };
  578. },
  579. created() {
  580. this.getList();
  581. this.getOption();
  582. this.getOption1();
  583. },
  584. activated() {
  585. this.getOption();
  586. this.getOption1();
  587. },
  588. methods: {
  589. getOption() {
  590. getTypeOption().then((resp) => {
  591. this.typeOption = resp.data;
  592. });
  593. },
  594. // 用于获取飞机机型(放到添加功能中)
  595. getOption1() {
  596. getTypeOption().then((resp) => {
  597. this.typeOption1 = resp.data;
  598. });
  599. },
  600. // 故障树
  601. beforeTreeUpload(file) {
  602. const fileName = file.name;
  603. const fileType = fileName.substring(fileName.lastIndexOf("."));
  604. const isOKType =
  605. fileType === ".jpg" ||
  606. fileType === ".png" ||
  607. fileType === ".jpeg" ||
  608. fileType === ".bmp" ||
  609. fileType === ".gif";
  610. if (!isOKType) {
  611. this.$message.error("图片格式只能为jpeg/png/jpg/bmp/gif");
  612. }
  613. const isLt2M = file.size / 1024 / 1024 < 20;
  614. if (!isLt2M) {
  615. this.$message.error("图片大小不能超过 20MB!");
  616. }
  617. return isLt2M && isOKType;
  618. },
  619. afterTreeUpload(response, file) {
  620. // 上传完成后的处理逻辑
  621. console.log("上传完成", response, file);
  622. if (response.code === 200) {
  623. this.form.faultTreePath = response.fileName;
  624. }
  625. },
  626. reuploadTree() {
  627. this.form.faultTreePath = "";
  628. this.showResetBtn = false;
  629. },
  630. // 故障图
  631. beforePicUpload(file) {
  632. const fileName = file.name;
  633. const fileType = fileName.substring(fileName.lastIndexOf("."));
  634. const isOKType =
  635. fileType === ".jpg" ||
  636. fileType === ".png" ||
  637. fileType === ".jpeg" ||
  638. fileType === ".bmp" ||
  639. fileType === ".gif";
  640. if (!isOKType) {
  641. this.$message.error("图片格式只能为jpeg/png/jpg/bmp/gif");
  642. }
  643. const isLt2M = file.size / 1024 / 1024 < 20;
  644. if (!isLt2M) {
  645. this.$message.error("图片大小不能超过 20MB!");
  646. }
  647. return isLt2M && isOKType;
  648. },
  649. afterPicUpload(response, file) {
  650. if (response.code === 200) {
  651. this.form.faultPicturePath = response.fileName;
  652. }
  653. // 上传完成后的处理逻辑
  654. console.log("上传完成", response, file);
  655. },
  656. reuploadPic() {
  657. this.form.faultPicturePath = "";
  658. // this.$refs.loadtree.clearFiles();
  659. this.showResetBtnpic = false;
  660. },
  661. // 排故流程word文档
  662. beforeMethodUpload(file) {
  663. const fileName = file.name;
  664. const fileType = fileName.substring(fileName.lastIndexOf("."));
  665. const isOKType = fileType === ".doc" || fileType === ".docx";
  666. if (!isOKType) {
  667. this.$message.error("文件格式只能为doc/docx");
  668. }
  669. const isLt2M = file.size / 1024 / 1024 < 20;
  670. if (!isLt2M) {
  671. this.$message.error("图片大小不能超过 20MB!");
  672. }
  673. return isLt2M && isOKType;
  674. },
  675. afterMethodUpload(response, file) {
  676. if (response.code === 200) {
  677. this.form.troubleshootingMethodPath = response.fileName;
  678. axios({
  679. method: "get",
  680. responseType: "blob",
  681. url: this.baseUrl + this.form.troubleshootingMethodPath,
  682. }).then((response) => {
  683. renderAsync(response.data, this.$refs.troubleshootingMethodFile);
  684. });
  685. }
  686. // 上传完成后的处理逻辑
  687. console.log("上传完成", response, file);
  688. },
  689. reuploadMethod() {
  690. this.form.troubleshootingMethodPath = "";
  691. // this.$refs.loadtree.clearFiles();
  692. this.showResetBtnMethod = false;
  693. },
  694. // 机型变化后更新系统下拉框
  695. handleaircraftChange() {
  696. this.queryParams.aircraftSystemId = "";
  697. this.queryParams.aircraftSubsystemId = "";
  698. // alert(this.queryParams.aircraftTypeId)
  699. getSystemOption(this.queryParams.aircraftTypeId).then((resp) => {
  700. this.systemOption = resp.data;
  701. });
  702. },
  703. // 系统变化后更新分系统
  704. handlesystemChange() {
  705. this.queryParams.aircraftSubsystemId = "";
  706. getSubSystemOption(this.queryParams.aircraftSystemId).then((resp) => {
  707. this.subSystemOption = resp.data;
  708. });
  709. },
  710. // 添加或修改对话框中机型变化后,修改系统
  711. handleaircraftChange1(isClear = true) {
  712. if (isClear) {
  713. this.form.aircraftSystemId = "";
  714. this.form.aircraftSubsystemId = "";
  715. }
  716. if (this.form.aircraftTypeId) {
  717. getSystemOption(this.form.aircraftTypeId).then((resp) => {
  718. this.systemOption1 = resp.data;
  719. });
  720. }
  721. },
  722. // 添加或修改对话框中系统变化后,修改分系统
  723. handlesystemChange1(isClear = true) {
  724. if (isClear) {
  725. this.form.aircraftSubsystemId = "";
  726. }
  727. if (this.form.aircraftSystemId) {
  728. getSubSystemOption(this.form.aircraftSystemId).then((resp) => {
  729. this.subSystemOption1 = resp.data;
  730. });
  731. }
  732. },
  733. /** 查询故障案例管理列表 */
  734. getList() {
  735. this.loading = true;
  736. listCase(this.queryParams).then((response) => {
  737. this.caseList = response.rows;
  738. this.total = response.total;
  739. this.loading = false;
  740. });
  741. },
  742. // 取消按钮
  743. cancel() {
  744. this.open = false;
  745. this.reset();
  746. },
  747. // 表单重置
  748. reset() {
  749. this.form = {
  750. id: null,
  751. aircraftTypeId: null,
  752. aircraftSystemId: null,
  753. aircraftSubsystemId: null,
  754. faultPhenomenon: null,
  755. faultCause: null,
  756. faultTreePath: null,
  757. faultPicturePath: null,
  758. troubleshootingMethodPath: null,
  759. viewCount: null,
  760. createBy: null,
  761. createTime: null,
  762. updateBy: null,
  763. updateTime: null,
  764. };
  765. this.resetForm("form");
  766. },
  767. /** 搜索按钮操作 */
  768. handleQuery() {
  769. this.queryParams.pageNum = 1;
  770. this.getList();
  771. },
  772. /** 重置按钮操作 */
  773. resetQuery() {
  774. this.resetForm("queryForm");
  775. (this.systemOption = []), (this.subSystemOption = []), this.handleQuery();
  776. },
  777. // 多选框选中数据
  778. handleSelectionChange(selection) {
  779. this.ids = selection.map((item) => item.id);
  780. this.single = selection.length !== 1;
  781. this.multiple = !selection.length;
  782. },
  783. /** 新增按钮操作 */
  784. handleAdd() {
  785. this.reset();
  786. this.open = true;
  787. this.title = "添加故障案例管理";
  788. },
  789. /** 修改按钮操作 */
  790. handleUpdate() {
  791. this.resetForm("queryForm");
  792. const id = row.id || this.ids;
  793. getCase(id).then((response) => {
  794. this.form = response.data;
  795. this.open = true;
  796. this.title = "修改故障案例管理";
  797. if (this.form.troubleshootingMethodPath) {
  798. axios({
  799. method: "get",
  800. responseType: "blob",
  801. url: this.baseUrl + this.form.troubleshootingMethodPath,
  802. }).then((response) => {
  803. renderAsync(response.data, this.$refs.troubleshootingMethodFile);
  804. });
  805. }
  806. this.handleaircraftChange1(false);
  807. this.handlesystemChange1(false);
  808. });
  809. },
  810. /** 修改按钮操作 */
  811. handleUpdate(row) {
  812. this.resetForm("queryForm");
  813. const id = row.id || this.ids;
  814. getCase(id).then((response) => {
  815. this.form = response.data;
  816. this.open = true;
  817. this.title = "修改故障案例管理";
  818. if (this.form.troubleshootingMethodPath) {
  819. axios({
  820. method: "get",
  821. responseType: "blob",
  822. url: this.baseUrl + this.form.troubleshootingMethodPath,
  823. }).then((response) => {
  824. renderAsync(response.data, this.$refs.troubleshootingMethodFile);
  825. });
  826. }
  827. this.handleaircraftChange1(false);
  828. this.handlesystemChange1(false);
  829. });
  830. },
  831. /** 提交按钮 */
  832. submitForm() {
  833. this.$refs["form"].validate((valid) => {
  834. if (valid) {
  835. if (this.form.id != null) {
  836. updateCase(this.form).then((response) => {
  837. this.$modal.msgSuccess("修改成功");
  838. this.open = false;
  839. this.queryParams.aircraftTypeId = null;
  840. this.queryParams.aircraftSystemId = null;
  841. this.queryParams.aircraftSubsystemId = null;
  842. this.getList();
  843. });
  844. } else {
  845. addCase(this.form).then((response) => {
  846. this.$modal.msgSuccess("新增成功");
  847. this.open = false;
  848. this.queryParams.aircraftTypeId = null;
  849. this.queryParams.aircraftSystemId = null;
  850. this.queryParams.aircraftSubsystemId = null;
  851. this.getList();
  852. });
  853. }
  854. }
  855. });
  856. },
  857. /** 删除按钮操作 */
  858. handleDelete(row) {
  859. const ids = row.id || this.ids;
  860. this.$modal
  861. .confirm('是否确认删除故障案例管理编号为"' + ids + '"的数据项?')
  862. .then(function () {
  863. return delCase(ids);
  864. })
  865. .then(() => {
  866. this.getList();
  867. this.$modal.msgSuccess("删除成功");
  868. })
  869. .catch(() => {});
  870. },
  871. /** 导出按钮操作 */
  872. handleExport() {
  873. this.download(
  874. "system/case/export",
  875. {
  876. ...this.queryParams,
  877. },
  878. `case_${new Date().getTime()}.xlsx`
  879. );
  880. },
  881. download(path) {
  882. this.$download.resource(path);
  883. },
  884. getFileNameByPath(path) {
  885. if (!path) {
  886. return "";
  887. } else if (path.lastIndexOf("/") > -1) {
  888. const newName = path.slice(path.lastIndexOf("/") + 1);
  889. const names = newName.split(".");
  890. if ((names.size = 2) && names[0].length > 19) {
  891. return newName.substring(0, names[0].length - 19) + "." + names[1];
  892. } else {
  893. return newName;
  894. }
  895. } else {
  896. return "";
  897. }
  898. },
  899. viewWord() {},
  900. },
  901. };
  902. </script>
  903. <style>
  904. .avatar-uploader {
  905. display: inline-block;
  906. text-align: center;
  907. position: relative;
  908. overflow: hidden;
  909. }
  910. .avatar {
  911. width: 100px;
  912. height: 100px;
  913. display: block;
  914. }
  915. .avatar-uploader-icon {
  916. font-size: 28px;
  917. color: #8c939d;
  918. display: block;
  919. width: 100px;
  920. height: 100px;
  921. line-height: 100px;
  922. }
  923. .modal {
  924. position: fixed;
  925. top: 0;
  926. left: 0;
  927. width: 100%;
  928. height: 100%;
  929. background-color: rgba(0, 0, 0, 0.8);
  930. display: flex;
  931. justify-content: center;
  932. align-items: center;
  933. z-index: 9999;
  934. }
  935. .full-image {
  936. max-width: 80%;
  937. max-height: 80%;
  938. }
  939. /* .disabled .el-upload.el-upload--picture-card {
  940. display: none !important;
  941. }
  942. .disabled .el-button--success.is-plain {
  943. display: none !important;
  944. } */
  945. </style>