DetailC.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div v-if="visible">
  3. <div class="card">
  4. <a-tabs v-model="activeKey">
  5. <template v-for="(item,i) in components">
  6. <a-tab-pane v-if="item.show" :key="i">
  7. <div slot="tab" v-if="item.badge">
  8. <a-badge :count="item.badge.count" :title="item.badge.title" :number-style="{ backgroundColor: '#52c41a' }">
  9. <div class="tab-title">
  10. <my-icon v-if="item.isMy" class="icon" :type="item.icon"></my-icon>
  11. <a-icon v-else class="icon" :type="item.icon" />
  12. <div>
  13. {{ item.name }}
  14. </div>
  15. </div>
  16. </a-badge>
  17. </div>
  18. <div slot="tab" class="tab-title" v-else>
  19. <my-icon v-if="item.isMy" class="icon" :type="item.icon"></my-icon>
  20. <a-icon v-else class="icon" :type="item.icon" />
  21. <div>
  22. {{ item.name }}
  23. </div>
  24. </div>
  25. </a-tab-pane>
  26. </template>
  27. </a-tabs>
  28. </div>
  29. <div v-show="show">
  30. <keep-alive>
  31. <component :is="components[activeKey].component" v-bind="props" />
  32. </keep-alive>
  33. </div>
  34. <div class="btn">
  35. <a-space>
  36. <a-button style="margin-left: 20px" type="default" @click="handleEdit()">修改</a-button>
  37. <a-button type="default" :loading="confirmLoading" @click="handleOk()">刷新</a-button>
  38. <a-button type="primary" @click="handleBack">返回</a-button>
  39. </a-space>
  40. </div>
  41. <base-form ref="baseModal" @ok="handleOk"/>
  42. </div>
  43. </template>
  44. <script>
  45. // 组件
  46. import BaseForm from './BaseForm'
  47. import DetailInfo from './detail/DetailInfo.vue'
  48. import Children from './detail/Children.vue'
  49. import PartInfoList from './detail/PartInfoList.vue'
  50. import LocationList from './detail/LocationList.vue'
  51. import SbModelBom from '@/views/sb/modelbom/SbModelBom.vue'
  52. import CheckStandard from '@/views/check/checkstandard/CheckStandard.vue'
  53. import CheckJob from '@/views/check/checkjob/CheckJob.vue'
  54. import DetailSbMeasure from './detail/DetailSbCheck.vue'
  55. // api
  56. import { queryNumCheckStandard } from '@/api/check/checkstandard'
  57. import { queryNumCheckjob } from '@/api/check/checkjob'
  58. import { queryNumRepairReason } from '@/api/repair/repair-reason'
  59. import { queryNumPartInfo } from '@/api/part/info'
  60. import { queryNumSbLocation } from '@/api/sb/location'
  61. import { queryNumModelbom } from '@/api/sb/modelbom'
  62. import { fetchSbInfo, queryChildNumSbInfo } from '@/api/sb/info'
  63. export default {
  64. name: 'DetailC',
  65. components: {
  66. BaseForm,
  67. DetailInfo,
  68. Children,
  69. PartInfoList,
  70. LocationList,
  71. SbModelBom,
  72. CheckStandard,
  73. CheckJob,
  74. DetailSbMeasure
  75. },
  76. data () {
  77. return {
  78. visible: false,
  79. confirmLoading: false,
  80. show: true,
  81. activeKey: 0,
  82. model: {},
  83. numCheckStandard1: 0,
  84. numCheckjob1: 0,
  85. numCheckStandard2: 0,
  86. numCheckjob2: 0,
  87. numCheckStandard3: 0,
  88. numCheckjob3: 0,
  89. numRepairReason: 0,
  90. numModelbom: 0,
  91. numPartInfo: 0,
  92. numLocation: 0,
  93. numChildSbInfo: 0
  94. }
  95. },
  96. computed: {
  97. props () {
  98. let props = null
  99. switch (this.activeKey) {
  100. case 0:
  101. case 1:
  102. case 7:
  103. props = {
  104. model: this.model
  105. }
  106. break
  107. case 2:
  108. case 3:
  109. case 4:
  110. props = {
  111. sbId: this.model.id
  112. }
  113. break
  114. case 5:
  115. case 6:
  116. props = {
  117. checkType: 1,
  118. sbId: this.model.id,
  119. sbNo: this.model.no
  120. }
  121. break
  122. }
  123. return props
  124. },
  125. components () {
  126. return [
  127. {
  128. name: '设备详情',
  129. icon: 'appstore',
  130. show: true,
  131. isMy: false,
  132. component: 'DetailInfo'
  133. },
  134. {
  135. name: '子设备',
  136. icon: 'appstore',
  137. show: true,
  138. isMy: false,
  139. component: 'Children',
  140. badge: {
  141. title: '子设备总数',
  142. count: this.numChildSbInfo
  143. }
  144. },
  145. {
  146. name: '设备部位',
  147. icon: 'appstore',
  148. show: true,
  149. isMy: false,
  150. component: 'PartInfoList',
  151. badge: {
  152. title: '部位总数',
  153. count: this.numPartInfo
  154. }
  155. },
  156. {
  157. name: '设备位号',
  158. icon: 'appstore',
  159. show: true,
  160. isMy: false,
  161. component: 'LocationList',
  162. badge: {
  163. title: '位号总数',
  164. count: this.numLocation
  165. }
  166. },
  167. {
  168. name: '备件BOM',
  169. icon: 'appstore',
  170. show: true,
  171. isMy: false,
  172. component: 'SbModelBom',
  173. badge: {
  174. title: '备件总数',
  175. count: this.numModelbom
  176. }
  177. },
  178. {
  179. name: '点检标准',
  180. icon: 'appstore',
  181. show: true,
  182. isMy: false,
  183. component: 'CheckStandard',
  184. badge: {
  185. title: '点检标准',
  186. count: this.numCheckStandard1
  187. }
  188. },
  189. {
  190. name: '点检任务',
  191. icon: 'appstore',
  192. isMy: false,
  193. show: true,
  194. component: 'CheckJob',
  195. badge: {
  196. title: '点检任务',
  197. count: this.numCheckjob1
  198. }
  199. },
  200. {
  201. name: '检定记录',
  202. icon: 'appstore',
  203. show: this.model.useType === 4,
  204. isMy: false,
  205. component: 'DetailSbMeasure'
  206. },
  207. {
  208. name: '设备履历',
  209. icon: 'appstore',
  210. show: true,
  211. isMy: false,
  212. component: 'DetailSbMeasure'
  213. },
  214. {
  215. name: '配件记录',
  216. icon: 'appstore',
  217. show: true,
  218. isMy: false,
  219. component: 'DetailSbMeasure'
  220. },
  221. {
  222. name: '保养记录',
  223. icon: 'appstore',
  224. show: true,
  225. isMy: false,
  226. component: 'DetailSbMeasure'
  227. },
  228. {
  229. name: '历史故障',
  230. icon: 'appstore',
  231. show: true,
  232. isMy: false,
  233. component: 'DetailSbMeasure'
  234. },
  235. {
  236. name: '历史费用',
  237. icon: 'appstore',
  238. show: true,
  239. isMy: false,
  240. component: 'DetailSbMeasure'
  241. },
  242. {
  243. name: '状态变更记录',
  244. icon: 'appstore',
  245. show: true,
  246. isMy: false,
  247. component: 'DetailSbMeasure'
  248. },
  249. {
  250. name: '停机记录',
  251. icon: 'appstore',
  252. show: true,
  253. isMy: false,
  254. component: 'DetailSbMeasure'
  255. },
  256. {
  257. name: '遥测点位',
  258. icon: 'appstore',
  259. show: true,
  260. isMy: false,
  261. component: 'DetailSbMeasure'
  262. },
  263. {
  264. name: '设备树',
  265. icon: 'appstore',
  266. show: true,
  267. isMy: false,
  268. component: 'DetailSbMeasure'
  269. },
  270. {
  271. name: '检点日历',
  272. icon: 'appstore',
  273. show: true,
  274. isMy: false,
  275. component: 'DetailSbMeasure'
  276. },
  277. {
  278. name: '工单分析',
  279. icon: 'appstore',
  280. show: true,
  281. isMy: false,
  282. component: 'DetailSbMeasure'
  283. },
  284. {
  285. name: '费用分析',
  286. icon: 'appstore',
  287. show: true,
  288. isMy: false,
  289. component: 'DetailSbMeasure'
  290. }
  291. ]
  292. }
  293. },
  294. methods: {
  295. base (record) {
  296. this.visible = true
  297. this.model = record
  298. this.fetchNum()
  299. },
  300. handleEdit () {
  301. fetchSbInfo({ id: this.model.id }).then(res => {
  302. this.show = false
  303. const modal = this.$refs.baseModal
  304. modal.base(res.data)
  305. })
  306. },
  307. handleOk () {
  308. this.confirmLoading = true
  309. this.show = true
  310. fetchSbInfo({ id: this.model.id }).then(res => {
  311. this.confirmLoading = false
  312. this.base(res.data)
  313. })
  314. },
  315. handleBack () {
  316. this.visible = false
  317. this.activeKey = 0
  318. this.$emit('ok')
  319. },
  320. fetchNum () {
  321. Promise.all([
  322. queryNumPartInfo({ sbId: this.model.id }),
  323. queryNumModelbom({ sbId: this.model.id }),
  324. queryNumRepairReason({ sbId: this.model.id }),
  325. queryNumCheckStandard({ sbId: this.model.id, type: 1 }),
  326. queryNumCheckStandard({ sbId: this.model.id, type: 2 }),
  327. queryNumCheckStandard({ sbId: this.model.id, type: 3 }),
  328. queryNumCheckjob({ sbId: this.model.id, type: 1 }),
  329. queryNumCheckjob({ sbId: this.model.id, type: 2 }),
  330. queryNumCheckjob({ sbId: this.model.id, type: 3 }),
  331. queryNumSbLocation({ sbId: this.model.id }),
  332. queryChildNumSbInfo({ parentId: this.model.id })
  333. ])
  334. .then((values) => {
  335. this.numPartInfo = values[0].data
  336. this.numModelbom = values[1].data
  337. this.numRepairReason = values[2].data
  338. this.numCheckStandard1 = values[3].data
  339. this.numCheckStandard2 = values[4].data
  340. this.numCheckStandard3 = values[5].data
  341. this.numCheckjob1 = values[6].data
  342. this.numCheckjob2 = values[7].data
  343. this.numCheckjob3 = values[8].data
  344. this.numLocation = values[9].data
  345. this.numChildSbInfo = values[10].data
  346. }).then(() => {
  347. this.$forceUpdate()
  348. })
  349. }
  350. }
  351. }
  352. </script>
  353. <style lang="less" scoped>
  354. .card{
  355. background: #fff;
  356. padding: 10px 10px 0 10px;
  357. margin-bottom: 15px;
  358. }
  359. .tab-title{
  360. text-align: center;
  361. font-size: 18px;
  362. .icon{
  363. font-size: 30px;
  364. }
  365. }
  366. .btn{
  367. position: absolute;
  368. bottom: 30px;
  369. left:50%;
  370. transform: translateX(-50%);
  371. }
  372. /deep/.ant-tabs-bar{
  373. border:none;
  374. }
  375. /deep/.ant-tabs-ink-bar{
  376. visibility: hidden;
  377. }
  378. /deep/ .ant-tabs-tab-prev-icon-target,/deep/ .ant-tabs-tab-next-icon-target {
  379. font-size: 20px;
  380. }
  381. </style>