index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="view-table-content">
  3. <div class="view-dataSpecies-left">
  4. <MenuTree :currentNodeKey="currentNodeKey" nodeKey="id" :treedata="menuTreeData" @TreeNodeclick="treeNodeClick" v-bind="treeObj"> </MenuTree>
  5. </div>
  6. <div class="view-dataSpecies-right">
  7. <div class="view-dataType-title">
  8. <div class="view-dataType-title-btn">
  9. <el-button type="success" @click="openDialog()" :disabled="currentNode && currentNode.type == 0">新增</el-button>
  10. <el-button type="warning" @click="remove(tableCheckItems)" :disabled="tableCheckItems.length == 0">删除</el-button>
  11. <el-button type="primary">导入模板</el-button>
  12. <el-button type="primary">导出模板</el-button>
  13. </div>
  14. <div class="view-dataType-title-search">
  15. <el-input placeholder="请输入关键字" v-model="keyWord" class="input1">
  16. <el-button slot="append" icon="el-icon-search" @click="searchClick"></el-button>
  17. </el-input>
  18. </div>
  19. </div>
  20. <div class="view-dataType-table">
  21. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequset"></LTable>
  22. </div>
  23. <!-- 添加或修改故障诊断结果对话框 -->
  24. <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
  25. <el-form ref="form" :model="form" label-width="80px">
  26. <el-form-item label="故障诊断编号" prop="diagnosisId">
  27. <el-input v-model="form.diagnosisId" placeholder="请输入故障诊断编号" />
  28. </el-form-item>
  29. <el-form-item label="架次号" prop="sortieNo">
  30. <el-input v-model="form.sortieNo" placeholder="请输入架次号" />
  31. </el-form-item>
  32. <el-form-item label="机号" prop="aircraftId">
  33. <el-input v-model="form.aircraftId" placeholder="请输入机号" />
  34. </el-form-item>
  35. </el-form>
  36. <span slot="footer" class="dialog-footer">
  37. <el-button @click="handleClose">取 消</el-button>
  38. <el-button type="primary" @click="submit">确 定</el-button>
  39. </span>
  40. </el-dialog>
  41. </div>
  42. </div>
  43. </template>
  44. <script>
  45. import { getFaultDiagnosisResult, getAircaftTypeAndModelTree, addFaultDiagnosisResult, updateFaultDiagnosisResult, removeFaultDiagnosisResult } from '@/api/als/faultDiagnosisResult'
  46. import { deepClone, debounce } from '@/utils/index'
  47. export default {
  48. name: 'FaultDiagnosisResult',
  49. components: {},
  50. data() {
  51. // 这里存放数据
  52. return {
  53. dialogTitle: '新增',
  54. dialogVisible: false,
  55. keyWord: '',
  56. aircaftModelIdList: [],
  57. currentNodeKey: null,
  58. currentNode: null,
  59. menuTreeData: [],
  60. treeObj: {
  61. title: '所属机种',
  62. activityheight: '275px',
  63. searchIcon: false,
  64. configure: {
  65. children: 'children',
  66. label: 'label'
  67. }
  68. },
  69. typeTree: {
  70. children: 'children',
  71. label: 'label'
  72. },
  73. searchValue: '',
  74. columns: [
  75. { prop: 'id', label: '编号' },
  76. {
  77. prop: 'diagnosisId',
  78. label: '故障诊断编号'
  79. },
  80. {
  81. prop: 'sortieNo',
  82. label: '架次号'
  83. },
  84. {
  85. prop: 'aircraftId',
  86. label: '机号'
  87. },
  88. {
  89. prop: 'status',
  90. label: '状态'
  91. },
  92. {
  93. button: true,
  94. label: '操作',
  95. width: '240px',
  96. group: [
  97. {
  98. name: '编辑',
  99. type: 'text',
  100. round: false,
  101. plain: false,
  102. onClick: (row, index, scope) => {
  103. _this.handUpdate(row)
  104. }
  105. },
  106. {
  107. name: '删除',
  108. type: 'text',
  109. round: false,
  110. plain: false,
  111. onClick: (row, index, scope) => {
  112. _this.remove([row])
  113. }
  114. }
  115. ]
  116. }
  117. ],
  118. options: {
  119. stripe: true, // 斑马纹
  120. mutiSelect: true, // 多选框
  121. index: false, // 显示序号, 多选则 mutiSelect
  122. loading: false, // 表格动画
  123. initTable: false, // 是否一挂载就加载数据
  124. border: true,
  125. height: 'calc(100vh - 300px)'
  126. },
  127. tableCheckItems: [],
  128. tableData: [],
  129. tableRequset: {
  130. total: 0,
  131. pageIndex: 1,
  132. pageSize: 10,
  133. searchValue: ''
  134. },
  135. form: {
  136. id: '',
  137. diagnosisId: '',
  138. sortieNo: '',
  139. aircraftId: '',
  140. status: '',
  141. tenantId: '',
  142. version: '',
  143. delFlag: '',
  144. createBy: '',
  145. createTime: '',
  146. updateBy: '',
  147. updateTime: ''
  148. },
  149. debounceFn: debounce(this.fetch, 500)
  150. }
  151. },
  152. watch: {
  153. keyWord() {
  154. this.tableRequset.pageIndex = 1
  155. this.debounceFn()
  156. }
  157. },
  158. mounted() {
  159. this.getAircaftTypeAndModelTreeAPI()
  160. },
  161. methods: {
  162. async getAircaftTypeAndModelTreeAPI(params) {
  163. const { data } = await getAircaftTypeAndModelTree(params)
  164. this.menuTreeData = data
  165. if (data.length) {
  166. this.currentNodeKey = data[0].value
  167. this.currentNode = data[0]
  168. this.aircaftModelIdList = this.getTreeLeafData(data[0]?.children).map((e) => e.id)
  169. this.getFaultDiagnosisResultAPI({ aircaftModelIdList: this.aircaftModelIdList })
  170. }
  171. },
  172. async removeFaultDiagnosisResultAPI(params) {
  173. try {
  174. const { success } = await removeFaultDiagnosisResult(params)
  175. if (success) {
  176. this.$message({
  177. type: 'success',
  178. message: '操作成功!'
  179. })
  180. await this.getFaultDiagnosisResultAPI({ aircaftModelIdList: this.aircaftModelIdList })
  181. this.handleClose()
  182. }
  183. } catch (error) {}
  184. },
  185. getTreeLeafData(list) {
  186. const newArr = []
  187. function getLeaf(data, arr) {
  188. data.forEach((e) => {
  189. if (e.type === 1) {
  190. arr.push(e)
  191. }
  192. if (e.children.length) {
  193. getLeaf(e.children, arr)
  194. }
  195. })
  196. }
  197. getLeaf(list, newArr)
  198. return newArr
  199. },
  200. async getFaultDiagnosisResultAPI(params) {
  201. if (this.$refs.table) this.$refs.table.clearSelection()
  202. const { keyWord } = this
  203. const { pageSize, pageIndex } = this.tableRequset
  204. const {
  205. data: { list, totalCount }
  206. } = await getFaultDiagnosisResult({ pageSize, pageIndex, keyWord, ...params })
  207. this.tableData = list
  208. this.tableRequset.total = totalCount
  209. },
  210. fetch() {
  211. this.getFaultDiagnosisResultAPI({ aircaftModelIdList: this.aircaftModelIdList })
  212. },
  213. searchClick() {
  214. this.getFaultDiagnosisResultAPI({ aircaftModelIdList: this.aircaftModelIdList })
  215. },
  216. async addFaultDiagnosisResultAPI() {
  217. try {
  218. delete this.form.aircaftModelName
  219. const { success } = await addFaultDiagnosisResult({ ...this.form })
  220. if (success) {
  221. this.$message({
  222. type: 'success',
  223. message: '操作成功!'
  224. })
  225. this.getFaultDiagnosisResultAPI({ aircaftModelIdList: this.aircaftModelIdList })
  226. }
  227. } catch (error) {}
  228. },
  229. async updateFaultDiagnosisResultAPI() {
  230. try {
  231. const { success } = await updateFaultDiagnosisResult({ ...this.form })
  232. if (success) {
  233. this.$message({
  234. type: 'success',
  235. message: '操作成功!'
  236. })
  237. this.getFaultDiagnosisResultAPI({ aircaftModelIdList: this.aircaftModelIdList })
  238. }
  239. } catch (error) {}
  240. },
  241. treeNodeClick(data) {
  242. this.$refs.table.clearSelection()
  243. this.currentNodeKey = data.id
  244. this.currentNode = data
  245. this.aircaftModelIdList = this.getTreeLeafData(data.children.length ? data.children : [data]).map((e) => e.id)
  246. this.getFaultDiagnosisResultAPI({ aircaftModelIdList: this.aircaftModelIdList })
  247. },
  248. openDialog() {
  249. this.dialogTitle = '新增'
  250. this.dialogVisible = true
  251. this.form.aircaftModelName = this.currentNode.label
  252. this.form.aircaftModelId = this.currentNode.id
  253. },
  254. handleClose() {
  255. this.dialogVisible = false
  256. this.form = {
  257. id: '',
  258. diagnosisId: '',
  259. sortieNo: '',
  260. aircraftId: '',
  261. status: '',
  262. tenantId: '',
  263. version: '',
  264. delFlag: '',
  265. createBy: '',
  266. createTime: '',
  267. updateBy: '',
  268. updateTime: ''
  269. }
  270. },
  271. handUpdate(row) {
  272. this.dialogTitle = '编辑'
  273. this.form = deepClone(row)
  274. this.dialogVisible = true
  275. },
  276. submit() {
  277. switch (this.dialogTitle) {
  278. case '编辑':
  279. this.updateFaultDiagnosisResultAPI()
  280. this.handleClose()
  281. break
  282. case '新增':
  283. this.addFaultDiagnosisResultAPI()
  284. this.handleClose()
  285. break
  286. }
  287. },
  288. selection(val) {
  289. this.tableCheckItems = val
  290. },
  291. remove(row) {
  292. this.$confirm('是否删除该数据', '提示', {
  293. confirmButtonText: '确定',
  294. cancelButtonText: '取消',
  295. type: 'warning'
  296. })
  297. .then(() => {
  298. this.removeFaultDiagnosisResultAPI(row.map((e) => e.id))
  299. })
  300. .catch(() => {})
  301. }
  302. }
  303. }
  304. </script>
  305. <style lang="scss" scoped>
  306. @import '../index.scss';
  307. </style>