123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702 |
- <template>
- <div class="app-container">
- <el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="68px">
- <el-form-item label="机型" prop="aircraftTypeId">
- <el-select v-model="queryParams.aircraftTypeId" placeholder="请选择" @change="handleaircraftChange">
- <el-option
- v-for="item in typeOption"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="系统" prop="aircraftSystemId">
- <el-select v-model="queryParams.aircraftSystemId" placeholder="请选择" @change="handlesystemChange">
- <el-option
- v-for="item in systemOption"
- :key="item.id"
- :label="item.aircraftSystemName"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="分系统" prop="aircraftSubsystemId">
- <el-select v-model="queryParams.aircraftSubsystemId" placeholder="请选择">
- <el-option
- v-for="item in subSystemOption"
- :key="item.id"
- :label="item.aircraftSubsystemName"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="故障现象" prop="faultPhenomenon">
- <el-input
- v-model="queryParams.faultPhenomenon"
- placeholder="请输入故障现象"
- clearable
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="排序" prop="orderBy">
- <el-select v-model="queryParams.orderBy" placeholder="请选择">
- <el-option
- v-for="item in orderByOption"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
- </el-row>
- <el-row>
- <el-col v-for="varCase in caseList" :key="varCase.id" :span="8">
- <el-card class="box-card" style="margin:10px">
- <div class="rounded-corners">
- <el-row style="background: #d3dce6;">
- <el-col :span="6"><div class="grid-content bg-purple" style="background-color: dodgerblue;text-align: center"><img :src="require('@/assets/icons/aircraft.png')" style="width: 1rem"><br>机型</div></el-col>
- <el-col :span="18"><div class="grid-content bg-purple-light flex-center">{{ varCase.aircraftTypeName }}</div></el-col>
- </el-row>
- <el-row style="background: #e5e9f2;">
- <el-col :span="6"><div class="grid-content bg-purple" style="background-color: dodgerblue;text-align: center"><img :src="require('@/assets/icons/system.png')" style="width: 1rem"><br>系统</div></el-col>
- <el-col :span="18"><div class="grid-content bg-purple-light flex-center">{{ varCase.aircraftSystemName }}</div></el-col>
- </el-row>
- <el-row style="background: #d3dce6;">
- <el-col :span="6"><div class="grid-content bg-purple" style="background-color: dodgerblue;text-align: center"><img :src="require('@/assets/icons/subsystem.png')" style="width: 1rem"><br>分系统</div></el-col>
- <el-col :span="18"><div class="grid-content bg-purple-light flex-center"> {{ varCase.aircraftSubsystemName }}</div></el-col>
- </el-row>
- <el-row style="background: #e5e9f2;">
- <el-col :span="6"><div class="grid-content bg-purple" style="background-color: dodgerblue;text-align: center"><img :src="require('@/assets/icons/fault.png')" style="width: 1rem"><br>故障现象</div></el-col>
- <el-col :span="18"><div class="grid-content bg-purple-light flex-center"> {{ truncatedText(varCase.faultPhenomenon) }}</div></el-col>
- </el-row>
- </div>
- <el-divider style="margin: 12px 0;" />
- <div class="container">
- <div class="left"><el-button type="text" class="button" @click="handleUpdate(varCase.id)">查看详情</el-button></div>
- <div class="right"><time class="time">{{ varCase.createTime }}</time> <img :src="require('@/assets/icons/hot.png')" style="width: 1rem"> {{ varCase.viewCount }}</div>
- </div>
- </el-card>
- </el-col>
- </el-row>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- :page-sizes="[12,24,36,48]"
- @pagination="getList"
- />
- <!-- 添加或修改故障案例管理对话框 -->
- <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" :close-on-press-escape="false">
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
- <el-row>
- <el-col :span="6"><div class="grid-content bg-purple">
- <el-form-item label="机型" prop="faultPhenomenon">
- <el-select v-model="form.aircraftTypeId" placeholder="请选择" @change="handleaircraftChange1" readonly>
- <el-option
- v-for="item in typeOption1"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- </div></el-col>
- <el-col :span="6"><div class="grid-content bg-purple">
- <el-form-item label="系统" prop="aircraftSystemId">
- <el-select v-model="form.aircraftSystemId" placeholder="请选择" @change="handlesystemChange1" readonly>
- <el-option
- v-for="item in systemOption1"
- :key="item.id"
- :label="item.aircraftSystemName"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- </div></el-col>
- <el-col :span="6"><div class="grid-content bg-purple">
- <el-form-item label="分系统" prop="aircraftSubsystemId">
- <el-select v-model="form.aircraftSubsystemId" placeholder="请选择" readonly>
- <el-option
- v-for="item in subSystemOption1"
- :key="item.id"
- :label="item.aircraftSubsystemName"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- </div>
- </el-col>
- <el-col :span="6"><div class="grid-content bg-purple" /></el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-card class="box-card" style="margin:5px">
- <div slot="header" class="clearfix">
- <span>故障现象</span>
- </div>
- <div>
- <el-input v-model="form.faultPhenomenon" type="textarea" :rows="5" placeholder="请输入内容" readonly/>
- </div>
- </el-card>
- </el-col>
- <el-col :span="12">
- <el-card class="box-card" style="margin:5px">
- <div slot="header" class="clearfix">
- <span>故障原因</span>
- </div>
- <div>
- <el-input v-model="form.faultCause" type="textarea" :rows="5" placeholder="请输入内容" readonly/>
- </div>
- </el-card>
- </el-col>
- </el-row>
- <el-row>
- <el-card class="box-card" style="margin:5px">
- <div slot="header" class="clearfix">
- <span>故障树</span>
- </div>
- <div>
- <div v-if="form.faultTreePath">
- <img :src="baseUrl+form.faultTreePath" style="max-width: 100%;" @load="showResetBtn = true;">
- <div style="flex: 1;" /> <!-- 占位符,用于将重置按钮推到最右侧 -->
- </div>
- </div>
- </el-card>
- </el-row>
- <el-row>
- <el-card class="box-card" style="margin:5px">
- <div slot="header" class="clearfix">
- <span>排故方法</span>
- </div>
- <el-row>
- <el-col :span="4">
- <span>故障图</span>
- <div>
- <div v-if="form.faultPicturePath">
- <img :src="baseUrl+form.faultPicturePath" style="max-width: 100px;" @load="showResetBtnpic = true" @click="showModal = true;imageSrc=form.faultPicturePath">
- <div style="flex: 1;" /> <!-- 占位符,用于将重置按钮推到最右侧 -->
- </div>
- </div>
- </el-col>
- <el-col :span="20">
- <span>文档</span>
- <div>
- <div v-if="form.troubleshootingMethodPath">
- <div ref="troubleshootingMethodFile" />
- <div style="flex: 1;" /> <!-- 占位符,用于将重置按钮推到最右侧 -->
- </div>
- </div>
- </el-col>
- </el-row>
- </el-card>
- </el-row>
- <div v-if="showModal" class="modal" @click="showModal = false">
- <img :src="baseUrl+imageSrc" class="full-image">
- </div>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="cancel">取 消</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { listCase, getCase, countPlus } from '@/api/system/case'
- import { getTypeOption } from '@/api/system/type'
- import { getSystemOption } from '@/api/system/system'
- import { getSubSystemOption } from '@/api/system/subsystem'
- import { renderAsync } from 'docx-preview'
- import { getToken } from '@/utils/auth'
- import axios from 'axios'
- export default {
- name: 'Index',
- data() {
- return {
- wordText: '',
- wordURL: 'test.docx', // 文件地址,看你对应怎末获取、赋值
- showResetBtn: false,
- showResetBtnpic: false,
- name: '',
- fileList: [],
- hideUpload: false,
- // 遮罩层
- loading: true,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 故障案例管理表格数据
- caseList: [],
- // 弹出层标题
- title: '',
- // 是否显示弹出层
- open: false,
- picUrl_tree: '',
- faultTreePath: '',
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- aircraftTypeId: null,
- aircraftSystemId: null,
- aircraftSubsystemId: null,
- faultPhenomenon: null,
- faultCause: null,
- faultTreePath: null,
- faultPicturePath: null,
- troubleshootingMethodPath: null,
- viewCount: null,
- orderBy: 'createTimeAsc'
- },
- // 表单参数
- form: {
- aircraftTypeId: null,
- aircraftSystemId: null,
- aircraftSubsystemId: null,
- faultPhenomenon: null,
- faultCause: null,
- id: null,
- faultTreePath: null, // 存储上传成功后的文件路径
- faultPicturePath: null,
- troubleshootingMethodPath: null,
- viewCount: null,
- createBy: null,
- createTime: null,
- updateBy: null,
- updateTime: null
- },
- // 表单校验
- rules: {
- },
- fileList: [], // 存储上传文件列表
- typeOption: [],
- typeOption1: [],
- systemOption: [],
- subSystemOption: [],
- systemOption1: [],
- subSystemOption1: [],
- showModal: false, // 控制模态框显示的变量
- imageSrc: '', // 图片路径
- showResetBtnMethod: false,
- // file upload
- baseUrl: process.env.VUE_APP_BASE_API,
- uploadFileUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传文件服务器地址
- headers: {
- Authorization: 'Bearer ' + getToken()
- },
- orderByOption: [
- {
- 'id': 'createTimeAsc',
- 'name': '按创建时间升序'
- },
- {
- 'id': 'createTimeDesc',
- 'name': '按创建时间降序'
- },
- {
- 'id': 'countAsc',
- 'name': '按点击量升序'
- },
- {
- 'id': 'countDesc',
- 'name': '按点击量降序'
- }
- ]
- }
- },
- created() {
- // this.getList()
- this.getOption()
- this.getOption1()
- },
- methods: {
- getOption() {
- getTypeOption().then(resp => {
- this.typeOption = resp.data
- })
- },
- // 用于获取飞机机型(放到添加功能中)
- getOption1() {
- getTypeOption().then(resp => {
- this.typeOption1 = resp.data
- })
- },
- // 故障树
- beforeTreeUpload(file) {
- const fileName = file.name
- const fileType = fileName.substring(fileName.lastIndexOf('.'))
- const isOKType =
- fileType === '.jpg' ||
- fileType === '.png' ||
- fileType === '.jpeg' ||
- fileType === '.bmp' ||
- fileType === '.gif'
- if (!isOKType) {
- this.$message.error('图片格式只能为jpeg/png/jpg/bmp/gif')
- }
- const isLt2M = file.size / 1024 / 1024 < 2
- if (!isLt2M) {
- this.$message.error('图片大小不能超过 2MB!')
- }
- return isLt2M && isOKType
- },
- afterTreeUpload(response, file) {
- // 上传完成后的处理逻辑
- console.log('上传完成', response, file)
- if (response.code === 200) {
- this.form.faultTreePath = response.fileName
- }
- },
- reuploadTree() {
- this.form.faultTreePath = ''
- this.showResetBtn = false
- },
- // 故障图
- beforePicUpload(file) {
- const fileName = file.name
- const fileType = fileName.substring(fileName.lastIndexOf('.'))
- const isOKType =
- fileType === '.jpg' ||
- fileType === '.png' ||
- fileType === '.jpeg' ||
- fileType === '.bmp' ||
- fileType === '.gif'
- if (!isOKType) {
- this.$message.error('图片格式只能为jpeg/png/jpg/bmp/gif')
- }
- const isLt2M = file.size / 1024 / 1024 < 2
- if (!isLt2M) {
- this.$message.error('图片大小不能超过 2MB!')
- }
- return isLt2M && isOKType
- },
- afterPicUpload(response, file) {
- if (response.code === 200) {
- this.form.faultPicturePath = response.fileName
- }
- // 上传完成后的处理逻辑
- console.log('上传完成', response, file)
- },
- reuploadPic() {
- this.form.faultPicturePath = ''
- // this.$refs.loadtree.clearFiles();
- this.showResetBtnpic = false
- },
- // 排故流程word文档
- beforeMethodUpload(file) {
- const fileName = file.name
- const fileType = fileName.substring(fileName.lastIndexOf('.'))
- const isOKType =
- fileType === '.doc' ||
- fileType === '.docx'
- if (!isOKType) {
- this.$message.error('文件格式只能为doc/docx')
- }
- const isLt2M = file.size / 1024 / 1024 < 5
- if (!isLt2M) {
- this.$message.error('图片大小不能超过 5MB!')
- }
- return isLt2M && isOKType
- },
- afterMethodUpload(response, file) {
- if (response.code === 200) {
- this.form.troubleshootingMethodPath = response.fileName
- axios({
- method: 'get',
- responseType: 'blob',
- url: this.baseUrl + this.form.troubleshootingMethodPath
- }).then((response) => {
- renderAsync(response.data, this.$refs.troubleshootingMethodFile)
- })
- }
- // 上传完成后的处理逻辑
- console.log('上传完成', response, file)
- },
- reuploadMethod() {
- this.form.troubleshootingMethodPath = ''
- // this.$refs.loadtree.clearFiles();
- this.showResetBtnMethod = false
- },
- // 机型变化后更新系统下拉框
- handleaircraftChange() {
- this.queryParams.aircraftSystemId = ''
- this.queryParams.aircraftSubsystemId = ''
- // alert(this.queryParams.aircraftTypeId)
- getSystemOption(this.queryParams.aircraftTypeId).then(resp => {
- this.systemOption = resp.data
- })
- },
- // 系统变化后更新分系统
- handlesystemChange() {
- this.queryParams.aircraftSubsystemId = ''
- getSubSystemOption(this.queryParams.aircraftSystemId).then(resp => {
- this.subSystemOption = resp.data
- })
- },
- // 添加或修改对话框中机型变化后,修改系统
- handleaircraftChange1(isClear = true) {
- if (isClear) {
- this.form.aircraftSystemId = ''
- this.form.aircraftSubsystemId = ''
- }
- if (this.form.aircraftTypeId) {
- getSystemOption(this.form.aircraftTypeId).then(resp => {
- this.systemOption1 = resp.data
- })
- }
- },
- // 添加或修改对话框中系统变化后,修改分系统
- handlesystemChange1(isClear = true) {
- if (isClear) {
- this.form.aircraftSubsystemId = ''
- }
- if (this.form.aircraftSystemId) {
- getSubSystemOption(this.form.aircraftSystemId).then(resp => {
- this.subSystemOption1 = resp.data
- })
- }
- },
- /** 查询故障案例管理列表 */
- getList() {
- this.loading = true
- listCase(this.queryParams).then(response => {
- this.caseList = response.rows
- this.total = response.total
- this.loading = false
- })
- },
- // 取消按钮
- cancel() {
- this.open = false
- this.reset()
- },
- // 表单重置
- reset() {
- this.form = {
- id: null,
- aircraftTypeId: null,
- aircraftSystemId: null,
- aircraftSubsystemId: null,
- faultPhenomenon: null,
- faultCause: null,
- faultTreePath: null,
- faultPicturePath: null,
- troubleshootingMethodPath: null,
- viewCount: null,
- createBy: null,
- createTime: null,
- updateBy: null,
- updateTime: null
- }
- this.resetForm('form')
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1
- this.getList()
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm('queryForm')
- this.handleQuery()
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.ids = selection.map(item => item.id)
- this.single = selection.length !== 1
- this.multiple = !selection.length
- },
- /** 新增按钮操作 */
- handleAdd() {
- this.reset()
- this.open = true
- this.title = '添加故障案例管理'
- },
- /** 修改按钮操作 */
- handleUpdate(id) {
- getCase(id).then(response => {
- this.form = response.data
- this.open = true
- this.title = '修改故障案例管理'
- if (this.form.troubleshootingMethodPath) {
- axios({
- method: 'get',
- responseType: 'blob',
- url: this.baseUrl + this.form.troubleshootingMethodPath
- }).then((response) => {
- renderAsync(response.data, this.$refs.troubleshootingMethodFile)
- })
- }
- this.handleaircraftChange1(false)
- this.handlesystemChange1(false)
- })
- countPlus(id).then(response =>{
- })
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs['form'].validate(valid => {
- if (valid) {
- if (this.form.id != null) {
- updateCase(this.form).then(response => {
- this.$modal.msgSuccess('修改成功')
- this.open = false
- this.queryParams.aircraftTypeId = null
- this.queryParams.aircraftSystemId = null
- this.queryParams.aircraftSubsystemId = null
- this.getList()
- })
- } else {
- addCase(this.form).then(response => {
- this.$modal.msgSuccess('新增成功')
- this.open = false
- this.queryParams.aircraftTypeId = null
- this.queryParams.aircraftSystemId = null
- this.queryParams.aircraftSubsystemId = null
- this.getList()
- })
- }
- }
- })
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const ids = row.id || this.ids
- this.$modal.confirm('是否确认删除故障案例管理编号为"' + ids + '"的数据项?').then(function() {
- return delCase(ids)
- }).then(() => {
- this.getList()
- this.$modal.msgSuccess('删除成功')
- }).catch(() => {})
- },
- /** 导出按钮操作 */
- handleExport() {
- this.download('system/case/export', {
- ...this.queryParams
- }, `case_${new Date().getTime()}.xlsx`)
- },
- truncatedText(text) {
- const maxLength = 30 // 你希望的最大字符数
- if (text.length > maxLength) {
- return text.substring(0, maxLength) + '...'
- }
- return text
- }
- }
- }
- </script>
- <style scoped>
- .avatar-uploader {
- display: inline-block;
- text-align: center;
- position: relative;
- overflow: hidden;
- }
- .avatar {
- width: 100px;
- height: 100px;
- display: block;
- }
- .avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- display: block;
- width: 100px;
- height: 100px;
- line-height: 100px;
- }
- .modal {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.8);
- display: flex;
- justify-content: center;
- align-items: center;
- z-index: 9999;
- }
- .full-image {
- max-width: 80%;
- max-height: 80%;
- }
- .el-divider--horizontal{
- display: block;
- height: 1px;
- width: 100%;
- margin: 12px 0;
- }
- .rounded-corners {
- border-radius: 10px; /* 你可以根据需要调整这个值 */
- }
- .flex-center {
- display: flex;
- align-items: center; /* 垂直居中 */
- height: 2.5rem; /* 你需要一个确定的高度 */
- }
- .ellipsis {
- white-space: nowrap; /* 防止文本换行 */
- overflow: hidden; /* 隐藏超出容器的文本 */
- text-overflow: ellipsis; /* 使用省略号表示被截断的文本 */
- max-width: 200px;
- }
- .left {
- float: left;
- /* 左边的样式 */
- }
- .right {
- float: right;
- padding: 10px 20px
- /* 右边的样式 */
- }
- .container::after {
- content: "";
- display: table;
- clear: both;
- }
- </style>
|