index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <div class="view-table-content">
  3. <div class="view-dataSpecies-left" style="display: flex; width: 430px">
  4. <MenuTree :currentNodeKey="currentNodeKey" nodeKey="id" :treedata="menuTreeData" @TreeNodeclick="treeNodeClick" v-bind="treeObj" style="width: 250px"> </MenuTree>
  5. <MenuTree :currentNodeKey="currentConfigNodeKey" nodeKey="id" :treedata="configTreeData" @TreeNodeclick="treeConfigNodeClick" v-bind="configurationTreeObj" style="width: 250px"> </MenuTree>
  6. </div>
  7. <div class="view-dataSpecies-right" style="width: calc(100% - 460px)">
  8. <div class="view-dataType-title">
  9. <div class="view-dataType-title-btn">
  10. <el-button type="success" @click="openDialog()" :disabled="!(currentNode.type == 2) || currentConfigNodeKey === ''">新增</el-button>
  11. <el-button type="warning" @click="remove(tableCheckItems)" :disabled="tableCheckItems.length == 0">删除</el-button>
  12. </div>
  13. <div class="view-dataType-title-search">
  14. <el-input placeholder="请输入航材名称" v-model="keyWordData" class="input1">
  15. <el-button slot="append" icon="el-icon-search" @click="searchClick"></el-button>
  16. </el-input>
  17. </div>
  18. </div>
  19. <div class="view-dataType-table">
  20. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequset"></LTable>
  21. </div>
  22. <!-- 添加或修改装机信息对话框 -->
  23. <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="1000px" :before-close="handleClose">
  24. <LTable ref="avmatTableRef" @current-change="avmatSelection" :showColumnSetting="false" :defaultFetch="false" :columns="avmatColumns" :dataSource="avmatTableData" :options="avmatOptions" :pagination="avmatTableRequset"></LTable>
  25. <el-form ref="formRef" style="margin-top: 20px" :inline="true" :model="form" :rules="rules" label-width="80px">
  26. <el-form-item label="航材名称" prop="devicesName">
  27. <el-input v-model="form.devicesName" placeholder="请输入航材名称" disabled />
  28. </el-form-item>
  29. <el-form-item label="航材编码" prop="devicesEncode">
  30. <el-input v-model="form.devicesEncode" placeholder="请输入航材编码" disabled />
  31. </el-form-item>
  32. <el-form-item label="规格型号" prop="specsModel">
  33. <el-input disabled v-model="form.specsModel" placeholder="请输入规格型号" />
  34. </el-form-item>
  35. <el-form-item label="图号" prop="drawingNumber">
  36. <el-input disabled v-model="form.drawingNumber" placeholder="请输入图号" />
  37. </el-form-item>
  38. <el-form-item label="所属分类" prop="category">
  39. <el-input disabled v-model="form.category" placeholder="请输入所属分类" />
  40. </el-form-item>
  41. <el-form-item label="是否可修" prop="repairable">
  42. <el-select disabled v-model="form.repairable" placeholder="请选择是否可修">
  43. <el-option label="是" :value="1"></el-option>
  44. <el-option label="否" :value="0"></el-option>
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="是否成套" prop="completeSet">
  48. <el-select v-model="form.completeSet" placeholder="请选择是否成套" disabled>
  49. <el-option label="是" :value="1"></el-option>
  50. <el-option label="否" :value="0"></el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="是否有寿" prop="serviceLife">
  54. <el-select v-model="form.serviceLife" placeholder="请选择是否有寿" disabled>
  55. <el-option label="是" :value="1"></el-option>
  56. <el-option label="否" :value="0"></el-option>
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="额定寿命(s)" label-width="90px" prop="ratedLife">
  60. <el-input-number label="额定寿命(s)" v-model="form.ratedLife" :precision="1" :step="0.5" :min="0"></el-input-number>
  61. </el-form-item>
  62. <el-form-item label="航材代码" prop="devicesCode">
  63. <el-input v-model="form.devicesCode" placeholder="请输入航材代码" />
  64. </el-form-item>
  65. <el-form-item label="装机数量" prop="quantity">
  66. <el-input v-model="form.quantity" placeholder="请输入装机数量" />
  67. </el-form-item>
  68. <el-form-item label="装机时间" prop="installTime">
  69. <el-date-picker v-model="form.installTime" type="date" placement="bottom-start" value-format="yyyy-MM-dd" placeholder="请选择装机时间"></el-date-picker>
  70. </el-form-item>
  71. <el-form-item label="软件版本" prop="softwareVersion">
  72. <el-input v-model="form.softwareVersion" placeholder="请输入软件版本" />
  73. </el-form-item>
  74. <el-form-item label="备注" prop="remarks">
  75. <el-input v-model="form.remarks" type="textarea" :rows="2" placeholder="请输入备注" />
  76. </el-form-item>
  77. </el-form>
  78. <span slot="footer" class="dialog-footer">
  79. <el-button @click="handleClose">取 消</el-button>
  80. <el-button type="primary" @click="submit">确 定</el-button>
  81. </span>
  82. </el-dialog>
  83. </div>
  84. </div>
  85. </template>
  86. <script>
  87. import { getAirInstall, addAirInstall, updateAirInstall, removeAirInstall } from '@/api/als/airInstall'
  88. import { getAircaftCatalogTree, getAircaftTypeAndModelTree } from '@/api/als/sideTree'
  89. import { getAircaftModelAll, getAircaftCatalogAll } from '@/api/als/aircraft'
  90. import { getAirConfiguration } from '@/api/als/airConfiguration'
  91. import { deepClone, debounce } from '@/utils/index'
  92. import { handleTree, flattenTree } from '../utils/common'
  93. import { getAvmatCatalog } from '@/api/basicData/dataSailingMaterialMaterialCoding'
  94. export default {
  95. name: 'AirInstall',
  96. components: {},
  97. data() {
  98. // 这里存放数据
  99. return {
  100. dialogTitle: '新增',
  101. dialogVisible: false,
  102. keyWordData: '',
  103. aircaftConfigIdList: [],
  104. currentNodeKey: '',
  105. currentNode: {},
  106. currentConfigNodeKey: '',
  107. currentConfigNode: {},
  108. menuTreeData: [],
  109. configTreeData: [],
  110. treeObj: {
  111. title: '所属机种',
  112. activityheight: '275px',
  113. searchIcon: false,
  114. configure: {
  115. children: 'children',
  116. label: 'label'
  117. }
  118. },
  119. configurationTreeObj: {
  120. title: '飞机构型',
  121. activityheight: '275px',
  122. searchIcon: false,
  123. configure: {
  124. children: 'children',
  125. label: 'name'
  126. }
  127. },
  128. typeTree: {
  129. children: 'children',
  130. label: 'label'
  131. },
  132. rules: {
  133. devicesName: [{ required: true, message: '请在列表中选择航材数据', trigger: 'blur' }]
  134. },
  135. searchValue: '',
  136. columns: [
  137. {
  138. prop: 'devicesEncode',
  139. label: '航材编码'
  140. },
  141. {
  142. prop: 'devicesCode',
  143. label: '航材代码'
  144. },
  145. {
  146. prop: 'devicesName',
  147. label: '航材名称'
  148. },
  149. {
  150. prop: 'specsModel',
  151. label: '规格型号'
  152. },
  153. {
  154. prop: 'drawingNumber',
  155. label: '图号'
  156. },
  157. {
  158. prop: 'category',
  159. label: '所属分类'
  160. },
  161. {
  162. prop: 'quantity',
  163. label: '装机数量'
  164. },
  165. {
  166. prop: 'installTime',
  167. label: '装机时间'
  168. },
  169. {
  170. prop: 'softwareVersion',
  171. label: '软件版本'
  172. },
  173. {
  174. prop: 'repairable',
  175. label: '是否可修',
  176. render: (h, params) => {
  177. if (params.row.repairable == 1) {
  178. return h('span', { class: 'success-state' }, '是')
  179. } else {
  180. return h('span', { class: 'warning-state' }, '否')
  181. }
  182. }
  183. },
  184. {
  185. prop: 'completeSet',
  186. label: '是否成套',
  187. render: (h, params) => {
  188. if (params.row.completeSet == 1) {
  189. return h('span', { class: 'success-state' }, '是')
  190. } else {
  191. return h('span', { class: 'warning-state' }, '否')
  192. }
  193. }
  194. },
  195. {
  196. prop: 'serviceLife',
  197. label: '是否有寿',
  198. render: (h, params) => {
  199. if (params.row.serviceLife == 1) {
  200. return h('span', { class: 'success-state' }, '是')
  201. } else {
  202. return h('span', { class: 'warning-state' }, '否')
  203. }
  204. }
  205. },
  206. {
  207. prop: 'ratedLife',
  208. label: '额定寿命(s)'
  209. },
  210. {
  211. button: true,
  212. label: '操作',
  213. width: '200px',
  214. group: [
  215. {
  216. name: '编辑',
  217. type: 'text',
  218. round: false,
  219. plain: false,
  220. onClick: (row, index, scope) => {
  221. this.handUpdate(row)
  222. }
  223. },
  224. {
  225. name: '删除',
  226. type: 'text',
  227. round: false,
  228. plain: false,
  229. onClick: (row, index, scope) => {
  230. this.remove([row])
  231. }
  232. }
  233. ]
  234. }
  235. ],
  236. avmatColumns: [
  237. {
  238. prop: 'avmatCatalogName',
  239. label: '航材名称',
  240. align: 'left'
  241. },
  242. {
  243. prop: 'avmatCatalogCode',
  244. label: '航材编码'
  245. },
  246. {
  247. prop: 'avmatCategoriesName',
  248. label: '所属分类'
  249. },
  250. {
  251. prop: 'specification',
  252. label: '规格型号'
  253. },
  254. {
  255. prop: 'diagramNumber',
  256. label: '图号'
  257. },
  258. {
  259. prop: 'unit',
  260. label: '计量单位'
  261. },
  262. {
  263. prop: 'specialty',
  264. label: '专业'
  265. },
  266. {
  267. prop: 'manufacturer',
  268. label: '生产厂家'
  269. },
  270. {
  271. prop: 'isRepairable',
  272. label: '是否可修',
  273. render: (h, params) => {
  274. if (params.row.status == 1) {
  275. return h('span', { class: 'success-state' }, '是')
  276. } else {
  277. return h('span', { class: 'warning-state' }, '否')
  278. }
  279. }
  280. },
  281. {
  282. prop: 'isCompleteSet',
  283. label: '是否成套',
  284. render: (h, params) => {
  285. if (params.row.isCompleteSet == 1) {
  286. return h('span', { class: 'success-state' }, '是')
  287. } else {
  288. return h('span', { class: 'warning-state' }, '否')
  289. }
  290. }
  291. },
  292. {
  293. prop: 'isOrdered',
  294. label: '是否有寿',
  295. render: (h, params) => {
  296. if (params.row.isOrdered == 1) {
  297. return h('span', { class: 'success-state' }, '是')
  298. } else {
  299. return h('span', { class: 'warning-state' }, '否')
  300. }
  301. }
  302. },
  303. {
  304. prop: 'isImported',
  305. label: '是否进口',
  306. render: (h, params) => {
  307. if (params.row.isImported == 1) {
  308. return h('span', { class: 'theme-state' }, '进口')
  309. } else {
  310. return h('span', { class: 'success-state' }, '国产')
  311. }
  312. }
  313. }
  314. ],
  315. options: {
  316. stripe: false, // 斑马纹
  317. mutiSelect: false, // 多选框
  318. index: true, // 显示序号, 多选则 mutiSelect
  319. loading: false, // 表格动画
  320. initTable: false, // 是否一挂载就加载数据
  321. border: true,
  322. height: 'calc(100vh - 300px)'
  323. },
  324. avmatOptions: {
  325. stripe: false, // 斑马纹
  326. mutiSelect: false, // 多选框
  327. index: true, // 显示序号, 多选则 mutiSelect
  328. loading: false, // 表格动画
  329. initTable: false, // 是否一挂载就加载数据
  330. border: true,
  331. height: '300px'
  332. },
  333. tableCheckItems: [],
  334. tableData: [],
  335. avmatTableData: [],
  336. tableRequset: {
  337. total: 0,
  338. pageIndex: 1,
  339. pageSize: 20,
  340. searchValue: ''
  341. },
  342. avmatTableRequset: {
  343. total: 0,
  344. pageIndex: 1,
  345. pageSize: 20,
  346. searchValue: ''
  347. },
  348. form: {
  349. id: '',
  350. airId: '', //编目id
  351. airModelId: '', //机号id
  352. configId: '', //构型id
  353. devicesEncode: '',
  354. devicesCode: '',
  355. devicesName: '',
  356. specsModel: '',
  357. drawingNumber: '',
  358. category: '',
  359. quantity: '',
  360. installTime: '',
  361. softwareVersion: '',
  362. repairable: '',
  363. completeSet: '',
  364. serviceLife: '',
  365. ratedLife: '',
  366. remarks: ''
  367. },
  368. debounceFn: debounce(this.fetch, 500),
  369. currentAirId: '',
  370. currentAirModelId: '',
  371. configNodeIdList: []
  372. }
  373. },
  374. watch: {
  375. keyWord() {
  376. this.tableRequset.pageIndex = 1
  377. this.debounceFn()
  378. }
  379. },
  380. mounted() {
  381. this.getAircaftCatalogTreeAPI()
  382. },
  383. methods: {
  384. async getAircaftCatalogTreeAPI(params) {
  385. const { data } = await getAircaftCatalogTree(params)
  386. this.menuTreeData = data
  387. const { pageSize, pageIndex } = this.avmatTableRequset
  388. const {
  389. data: { list, totalCount }
  390. } = await getAvmatCatalog({
  391. pageIndex,
  392. pageSize,
  393. avmatCategoriesId: '',
  394. avmatType: '1'
  395. })
  396. this.avmatTableData = flattenTree(list)
  397. this.avmatTableRequset.total = totalCount
  398. // if (data.length) {
  399. // this.currentNodeKey = data[0].id
  400. // this.currentNode = data[0]
  401. // this.getAirInstallAPI()
  402. // }
  403. },
  404. async removeAirInstallAPI(params) {
  405. try {
  406. const { code } = await removeAirInstall(params)
  407. if (code === 200) {
  408. this.$message({
  409. type: 'success',
  410. message: '操作成功!'
  411. })
  412. await this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  413. this.handleClose()
  414. }
  415. } catch (error) {}
  416. },
  417. getTreeLeafData(list) {
  418. const newArr = []
  419. function getLeaf(data, arr) {
  420. data.forEach((e) => {
  421. if (e.type === 2) {
  422. arr.push(e)
  423. }
  424. if (e.children.length) {
  425. getLeaf(e.children, arr)
  426. }
  427. })
  428. }
  429. getLeaf(list, newArr)
  430. return newArr
  431. },
  432. getAllTreeData(list) {
  433. const newArr = []
  434. function getLeaf(data, arr) {
  435. data.forEach((e) => {
  436. if (e.children && e.children.length) {
  437. getLeaf(e.children, arr)
  438. } else {
  439. arr.push(e)
  440. }
  441. })
  442. }
  443. getLeaf(list, newArr)
  444. return newArr
  445. },
  446. async getAirInstallAPI(params) {
  447. if (this.$refs.table) this.$refs.table.clearSelection()
  448. const { pageSize, pageIndex } = this.tableRequset
  449. const {
  450. data: { list, total }
  451. } = await getAirInstall({ pageSize, pageNum: pageIndex, ...params })
  452. this.tableData = list
  453. this.tableRequset.total = total
  454. },
  455. fetch() {
  456. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  457. },
  458. searchClick() {
  459. this.getAirInstallAPI({ configId: this.currentConfigNodeKey, devicesName: this.keyWordData })
  460. },
  461. async addAirInstallAPI() {
  462. try {
  463. delete this.form.aircaftModelName
  464. const { code } = await addAirInstall({ ...this.form })
  465. if (code === 200) {
  466. this.$message({
  467. type: 'success',
  468. message: '操作成功!'
  469. })
  470. this.handleClose()
  471. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  472. }
  473. } catch (error) {}
  474. },
  475. async updateAirInstallAPI() {
  476. try {
  477. const { code } = await updateAirInstall({ ...this.form })
  478. if (code === 200) {
  479. this.$message({
  480. type: 'success',
  481. message: '操作成功!'
  482. })
  483. this.handleClose()
  484. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  485. }
  486. } catch (error) {}
  487. },
  488. async treeNodeClick(data) {
  489. // this.$refs.table.clearSelection()
  490. this.currentAirId = this.form.airId = data.id
  491. this.currentAirModelId = this.form.airModelId = data.parentId
  492. this.currentNode = data
  493. // this.getAirInstallAPI(this.currentNodeKey)
  494. let dataTree = []
  495. if (data.type === 1) {
  496. const { data: data1 } = await getAirConfiguration({ aircraftType: data.id })
  497. dataTree = data1
  498. } else if (data.type === 2) {
  499. const { data: data1 } = await getAirConfiguration({ aircraftType: data.parentId })
  500. dataTree = data1
  501. }
  502. this.configTreeData = []
  503. const topNode = { id: 1, name: '整机', children: [] }
  504. // topNode.children = data1
  505. topNode.children = handleTree(dataTree, 'id')
  506. this.configTreeData.push(topNode)
  507. },
  508. treeConfigNodeClick(data) {
  509. this.$refs.table.clearSelection()
  510. this.currentConfigNodeKey = this.form.configId = data.id
  511. this.currentConfigNode = data
  512. // const dataTree = this.configTreeData
  513. // console.log('dataTree', dataTree)
  514. // this.configNodeIdList = String(this.getAllTreeData(dataTree[0].children.length ? dataTree[0].children : [dataTree[0]]).map((e) => e.id))
  515. // console.log('this.configNodeIdList', this.configNodeIdList)
  516. // this.getAirInstallAPI({ configId: this.configNodeIdList })
  517. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  518. },
  519. openDialog() {
  520. this.dialogTitle = '新增'
  521. this.dialogVisible = true
  522. this.form.configId = this.currentConfigNodeKey
  523. this.form.airId = this.currentAirId
  524. this.form.airModelId = this.currentAirModelId
  525. },
  526. handleClose() {
  527. this.$refs.avmatTableRef.clearSelection()
  528. this.dialogVisible = false
  529. this.form = {
  530. id: '',
  531. airId: '', //编目id
  532. airModelId: '', //机型id
  533. configId: '', //构型id
  534. devicesEncode: '',
  535. devicesCode: '',
  536. devicesName: '',
  537. specsModel: '',
  538. drawingNumber: '',
  539. category: '',
  540. quantity: '',
  541. installTime: '',
  542. softwareVersion: '',
  543. repairable: '',
  544. completeSet: '',
  545. serviceLife: '',
  546. ratedLife: '',
  547. remarks: ''
  548. }
  549. },
  550. handUpdate(row) {
  551. this.dialogTitle = '编辑'
  552. this.form = deepClone(row)
  553. this.dialogVisible = true
  554. },
  555. submit() {
  556. this.$refs.formRef.validate((valid) => {
  557. if (valid) {
  558. switch (this.dialogTitle) {
  559. case '编辑':
  560. this.updateAirInstallAPI()
  561. break
  562. case '新增':
  563. this.addAirInstallAPI()
  564. break
  565. }
  566. }
  567. })
  568. },
  569. selection(val) {
  570. this.tableCheckItems = val
  571. },
  572. avmatSelection(val) {
  573. this.form.devicesName = val.avmatCatalogName
  574. this.form.devicesEncode = val.avmatCatalogCode
  575. this.form.category = val.avmatCategoriesName
  576. this.form.specsModel = val.specification
  577. this.form.drawingNumber = val.diagramNumber
  578. this.form.repairable = val.isRepairable
  579. this.form.completeSet = val.isCompleteSet
  580. this.form.serviceLife = val.isOrdered
  581. },
  582. remove(row) {
  583. this.$confirm('是否删除该数据', '提示', {
  584. confirmButtonText: '确定',
  585. cancelButtonText: '取消',
  586. type: 'warning'
  587. })
  588. .then(() => {
  589. this.removeAirInstallAPI(row.map((e) => e.id))
  590. })
  591. .catch(() => {})
  592. },
  593. async changeDevicesName(avmatCatalogId) {
  594. const {
  595. data: { list }
  596. } = await getAvmatCatalog({
  597. avmatCatalogId: avmatCatalogId
  598. })
  599. // this.form = list[0]
  600. // console.log(this.form, list[0])
  601. }
  602. }
  603. }
  604. </script>
  605. <style lang="scss" scoped>
  606. @import '../index.scss';
  607. </style>