index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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="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="keyWord" 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="600px" :before-close="handleClose">
  24. <el-form ref="form" :model="form" label-width="80px">
  25. <el-form-item label="器材编码" prop="devicesEncode">
  26. <el-input v-model="form.devicesEncode" placeholder="请输入航材编码" />
  27. </el-form-item>
  28. <el-form-item label="器材代码" prop="devicesCode">
  29. <el-input v-model="form.devicesCode" placeholder="请输入航材代码" />
  30. </el-form-item>
  31. <el-form-item label="器材名称" prop="devicesName">
  32. <el-input v-model="form.devicesName" placeholder="请输入器材名称" />
  33. </el-form-item>
  34. <el-form-item label="规格型号" prop="specsModel">
  35. <el-input v-model="form.specsModel" placeholder="请输入规格型号" />
  36. </el-form-item>
  37. <el-form-item label="图号" prop="drawingNumber">
  38. <el-input v-model="form.drawingNumber" placeholder="请输入图号" />
  39. </el-form-item>
  40. <el-form-item label="所属分类" prop="category">
  41. <el-input v-model="form.category" placeholder="请输入所属分类" />
  42. </el-form-item>
  43. <el-form-item label="装机数量" prop="quantity">
  44. <el-input v-model="form.quantity" placeholder="请输入装机数量" />
  45. </el-form-item>
  46. <el-form-item label="装机时间" prop="installTime">
  47. <el-date-picker v-model="form.installTime" type="date" placement="bottom-start" value-format="yyyy-MM-dd" placeholder="请选择装机时间"></el-date-picker>
  48. </el-form-item>
  49. <el-form-item label="软件版本" prop="softwareVersion">
  50. <el-input v-model="form.softwareVersion" placeholder="请输入软件版本" />
  51. </el-form-item>
  52. <el-form-item label="是否可修" prop="repairable">
  53. <el-select v-model="form.repairable" placeholder="请选择是否可修">
  54. <el-option label="是" value="1"></el-option>
  55. <el-option label="否" value="0"></el-option>
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item label="是否成套" prop="completeSet">
  59. <el-select v-model="form.completeSet" placeholder="请选择是否成套">
  60. <el-option label="是" value="1"></el-option>
  61. <el-option label="否" value="0"></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="是否有寿" prop="serviceLife">
  65. <el-select v-model="form.serviceLife" placeholder="请选择是否有寿">
  66. <el-option label="是" value="1"></el-option>
  67. <el-option label="否" value="0"></el-option>
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item label="备注" prop="remarks">
  71. <el-input v-model="form.remarks" type="textarea" :rows="2" placeholder="请输入备注" />
  72. </el-form-item>
  73. </el-form>
  74. <span slot="footer" class="dialog-footer">
  75. <el-button @click="handleClose">取 消</el-button>
  76. <el-button type="primary" @click="submit">确 定</el-button>
  77. </span>
  78. </el-dialog>
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. import { getAirInstall, addAirInstall, updateAirInstall, removeAirInstall } from '@/api/als/airInstall'
  84. import { getAircaftCatalogTree, getAircaftTypeAndModelTree } from '@/api/als/sideTree'
  85. import { getAircaftModelAll, getAircaftCatalogAll } from '@/api/als/aircraft'
  86. import { getAirConfiguration } from '@/api/als/airConfiguration'
  87. import { deepClone, debounce } from '@/utils/index'
  88. import { handleTree } from '../utils/common'
  89. export default {
  90. name: 'AirInstall',
  91. components: {},
  92. data() {
  93. // 这里存放数据
  94. return {
  95. dialogTitle: '新增',
  96. dialogVisible: false,
  97. keyWord: '',
  98. aircaftConfigIdList: [],
  99. currentNodeKey: '',
  100. currentNode: {},
  101. currentConfigNodeKey: '',
  102. currentConfigNode: {},
  103. menuTreeData: [],
  104. configTreeData: [],
  105. treeObj: {
  106. title: '所属机种',
  107. activityheight: '275px',
  108. searchIcon: false,
  109. configure: {
  110. children: 'children',
  111. label: 'label'
  112. }
  113. },
  114. configurationTreeObj: {
  115. title: '飞机构型',
  116. activityheight: '275px',
  117. searchIcon: false,
  118. configure: {
  119. children: 'children',
  120. label: 'name'
  121. }
  122. },
  123. typeTree: {
  124. children: 'children',
  125. label: 'label'
  126. },
  127. searchValue: '',
  128. columns: [
  129. {
  130. prop: 'devicesEncode',
  131. label: '器材编码'
  132. },
  133. {
  134. prop: 'devicesCode',
  135. label: '器材代码'
  136. },
  137. {
  138. prop: 'devicesName',
  139. label: '器材名称'
  140. },
  141. {
  142. prop: 'specsModel',
  143. label: '规格型号'
  144. },
  145. {
  146. prop: 'drawingNumber',
  147. label: '图号'
  148. },
  149. {
  150. prop: 'category',
  151. label: '所属分类'
  152. },
  153. {
  154. prop: 'quantity',
  155. label: '装机数量'
  156. },
  157. {
  158. prop: 'installTime',
  159. label: '装机时间'
  160. },
  161. {
  162. prop: 'softwareVersion',
  163. label: '软件版本'
  164. },
  165. {
  166. prop: 'repairable',
  167. label: '是否可修',
  168. render: (h, params) => {
  169. if (params.row.repairable == 1) {
  170. return h('span', '是')
  171. } else {
  172. return h('span', '否')
  173. }
  174. }
  175. },
  176. {
  177. prop: 'completeSet',
  178. label: '是否成套',
  179. render: (h, params) => {
  180. if (params.row.completeSet == 1) {
  181. return h('span', '是')
  182. } else {
  183. return h('span', '否')
  184. }
  185. }
  186. },
  187. {
  188. prop: 'serviceLife',
  189. label: '是否有寿',
  190. render: (h, params) => {
  191. if (params.row.serviceLife == 1) {
  192. return h('span', '是')
  193. } else {
  194. return h('span', '否')
  195. }
  196. }
  197. },
  198. {
  199. button: true,
  200. label: '操作',
  201. width: '200px',
  202. group: [
  203. {
  204. name: '编辑',
  205. type: 'text',
  206. round: false,
  207. plain: false,
  208. onClick: (row, index, scope) => {
  209. this.handUpdate(row)
  210. }
  211. },
  212. {
  213. name: '删除',
  214. type: 'text',
  215. round: false,
  216. plain: false,
  217. onClick: (row, index, scope) => {
  218. this.remove([row])
  219. }
  220. }
  221. ]
  222. }
  223. ],
  224. options: {
  225. stripe: true, // 斑马纹
  226. mutiSelect: false, // 多选框
  227. index: true, // 显示序号, 多选则 mutiSelect
  228. loading: false, // 表格动画
  229. initTable: false, // 是否一挂载就加载数据
  230. border: true,
  231. height: 'calc(100vh - 300px)'
  232. },
  233. tableCheckItems: [],
  234. tableData: [],
  235. tableRequset: {
  236. total: 0,
  237. pageIndex: 1,
  238. pageSize: 10,
  239. searchValue: ''
  240. },
  241. form: {
  242. id: '',
  243. configId: '',
  244. devicesEncode: '',
  245. devicesCode: '',
  246. devicesName: '',
  247. specsModel: '',
  248. drawingNumber: '',
  249. category: '',
  250. quantity: '',
  251. installTime: '',
  252. softwareVersion: '',
  253. repairable: '',
  254. completeSet: '',
  255. serviceLife: '',
  256. remarks: '',
  257. tenantId: '',
  258. delFlag: '',
  259. version: '',
  260. createdBy: '',
  261. createdTime: '',
  262. updatedBy: '',
  263. updatedTime: ''
  264. },
  265. debounceFn: debounce(this.fetch, 500)
  266. }
  267. },
  268. watch: {
  269. keyWord() {
  270. this.tableRequset.pageIndex = 1
  271. this.debounceFn()
  272. }
  273. },
  274. mounted() {
  275. this.getAircaftCatalogTreeAPI()
  276. },
  277. methods: {
  278. async getAircaftCatalogTreeAPI(params) {
  279. const { data } = await getAircaftCatalogTree(params)
  280. this.menuTreeData = data
  281. // if (data.length) {
  282. // this.currentNodeKey = data[0].id
  283. // this.currentNode = data[0]
  284. // this.getAirInstallAPI()
  285. // }
  286. },
  287. async removeAirInstallAPI(params) {
  288. try {
  289. const { code } = await removeAirInstall(params)
  290. if (code === 200) {
  291. this.$message({
  292. type: 'success',
  293. message: '操作成功!'
  294. })
  295. await this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  296. this.handleClose()
  297. }
  298. } catch (error) {}
  299. },
  300. getTreeLeafData(list) {
  301. const newArr = []
  302. function getLeaf(data, arr) {
  303. data.forEach((e) => {
  304. if (e.type === 1) {
  305. arr.push(e)
  306. }
  307. if (e.children.length) {
  308. getLeaf(e.children, arr)
  309. }
  310. })
  311. }
  312. getLeaf(list, newArr)
  313. return newArr
  314. },
  315. async getAirInstallAPI(params) {
  316. if (this.$refs.table) this.$refs.table.clearSelection()
  317. const { keyWord } = this
  318. const { pageSize, pageIndex } = this.tableRequset
  319. const {
  320. data: { list, total }
  321. } = await getAirInstall({ pageSize, pageNum: pageIndex, ...params })
  322. this.tableData = list
  323. this.tableRequset.total = total
  324. },
  325. fetch() {
  326. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  327. },
  328. searchClick() {
  329. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  330. },
  331. async addAirInstallAPI() {
  332. try {
  333. delete this.form.aircaftModelName
  334. const { code } = await addAirInstall({ ...this.form })
  335. if (code === 200) {
  336. this.$message({
  337. type: 'success',
  338. message: '操作成功!'
  339. })
  340. this.handleClose()
  341. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  342. }
  343. } catch (error) {}
  344. },
  345. async updateAirInstallAPI() {
  346. try {
  347. const { code } = await updateAirInstall({ ...this.form })
  348. if (code === 200) {
  349. this.$message({
  350. type: 'success',
  351. message: '操作成功!'
  352. })
  353. this.handleClose()
  354. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  355. }
  356. } catch (error) {}
  357. },
  358. async treeNodeClick(data) {
  359. // this.$refs.table.clearSelection()
  360. // this.currentNodeKey = this.form.aircraftId = data.id
  361. // this.currentNode = data
  362. // this.form.aircraftType = data.label
  363. // this.getAirInstallAPI(this.currentNodeKey)
  364. console.log('data', data)
  365. this.configTreeData = []
  366. const { data: data1 } = await getAirConfiguration({ aircraftType: data.parentId })
  367. const topNode = { id: 1, name: '整机', children: [] }
  368. // topNode.children = data1
  369. topNode.children = handleTree(data1, 'id')
  370. this.configTreeData.push(topNode)
  371. },
  372. treeConfigNodeClick(data) {
  373. this.$refs.table.clearSelection()
  374. this.currentConfigNodeKey = this.form.configId = data.id
  375. this.currentConfigNode = data
  376. this.getAirInstallAPI({ configId: this.currentConfigNodeKey })
  377. },
  378. openDialog() {
  379. this.dialogTitle = '新增'
  380. this.dialogVisible = true
  381. this.form.configId = this.currentConfigNodeKey
  382. },
  383. handleClose() {
  384. this.dialogVisible = false
  385. this.form = {
  386. id: '',
  387. configId: '',
  388. devicesEncode: '',
  389. devicesCode: '',
  390. devicesName: '',
  391. specsModel: '',
  392. drawingNumber: '',
  393. category: '',
  394. quantity: '',
  395. installTime: '',
  396. softwareVersion: '',
  397. repairable: '',
  398. completeSet: '',
  399. serviceLife: '',
  400. remarks: '',
  401. tenantId: '',
  402. delFlag: '',
  403. version: '',
  404. createdBy: '',
  405. createdTime: '',
  406. updatedBy: '',
  407. updatedTime: ''
  408. }
  409. },
  410. handUpdate(row) {
  411. this.dialogTitle = '编辑'
  412. this.form = deepClone(row)
  413. this.dialogVisible = true
  414. },
  415. submit() {
  416. switch (this.dialogTitle) {
  417. case '编辑':
  418. this.updateAirInstallAPI()
  419. break
  420. case '新增':
  421. this.addAirInstallAPI()
  422. break
  423. }
  424. },
  425. selection(val) {
  426. this.tableCheckItems = val
  427. },
  428. remove(row) {
  429. this.$confirm('是否删除该数据', '提示', {
  430. confirmButtonText: '确定',
  431. cancelButtonText: '取消',
  432. type: 'warning'
  433. })
  434. .then(() => {
  435. this.removeAirInstallAPI(row.map((e) => e.id))
  436. })
  437. .catch(() => {})
  438. }
  439. }
  440. }
  441. </script>
  442. <style lang="scss" scoped>
  443. @import '../index.scss';
  444. </style>