DetailSbInfo.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div v-show="visible">
  3. <a-row :gutter="48" slot="extra">
  4. <a-col :md="48" :sm="48">
  5. <span class="table-page-search-submitButtons" style="float: right">
  6. <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  7. </span>
  8. </a-col>
  9. </a-row>
  10. <title-divider title="设备信息" width="90px"></title-divider>
  11. <detail-list title="" :col="3">
  12. <detail-list-item term="设备新号">{{ model.no }}</detail-list-item>
  13. <detail-list-item term="设备旧号">{{ model.zbh }}</detail-list-item>
  14. <detail-list-item term="型号">{{ model.model }}</detail-list-item>
  15. <detail-list-item term="设备名称">{{ model.name }}</detail-list-item>
  16. </detail-list>
  17. <title-divider title="子设备" width="90px"></title-divider>
  18. <div class="table-operator" style="margin-bottom:8px;">
  19. <a-button style="margin-left:8px;" type="primary" @click="handleSbSelect">
  20. <a-icon type="plus"/>
  21. 添加子设备
  22. </a-button>
  23. </div>
  24. <a-table
  25. :data-source="data"
  26. :columns="columns"
  27. size="default"
  28. :scroll="{x: 1500 }"
  29. tableLayout="auto"
  30. rowKey="id">
  31. <span slot="action" slot-scope="record">
  32. <template>
  33. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要取消关联?" @confirm="batchCancel(record.id)">
  34. <a>取消</a>
  35. </a-popconfirm>
  36. </template>
  37. </span>
  38. </a-table>
  39. <sb-info-select-modal :type="'checkbox'" ref="sbInfoSelectModal" @selected="handleSbSelected"/>
  40. </div>
  41. </template>
  42. <script>
  43. import DetailList from '@/components/tools/DetailList'
  44. import { updateSbInfoChildBatch, updateSbInfoChildCancel, querySbInfo, deleteSbInfos, fetchSbInfo, exportSbInfo } from '@/api/sb/info'
  45. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  46. const DetailListItem = DetailList.Item
  47. export default {
  48. name: 'DetailSbCheck',
  49. components: {
  50. DetailList,
  51. DetailListItem,
  52. SbInfoSelectModal
  53. },
  54. props: {
  55. /**
  56. * 检查类型: 1-点检 2-巡检
  57. */
  58. checkType: {
  59. type: Number,
  60. default: 2
  61. }
  62. },
  63. data () {
  64. return {
  65. confirmLoading: false,
  66. mdl: {},
  67. model: {
  68. 'id': null,
  69. 'modelId': null,
  70. 'no': null,
  71. 'zbh': null,
  72. 'name': null,
  73. 'nameModel': null,
  74. 'unit': null,
  75. 'level': null,
  76. 'useType': null
  77. },
  78. modalTitle: null,
  79. visible: false,
  80. typeMap: {},
  81. actionTypeMap: {},
  82. // 表头
  83. columns: [
  84. {
  85. title: '序号',
  86. dataIndex: 'index',
  87. checked: true,
  88. customRender: (text, record, index) => {
  89. return index + 1
  90. }
  91. },
  92. {
  93. title: '设备名称',
  94. checked: true,
  95. width: 250,
  96. dataIndex: 'name'
  97. },
  98. {
  99. title: '设备编号',
  100. dataIndex: 'no',
  101. width: 150,
  102. checked: true
  103. },
  104. {
  105. title: '设备类型',
  106. checked: true,
  107. dataIndex: 'type',
  108. width: 150,
  109. customRender: (text, record, index) => {
  110. return record.typeName
  111. }
  112. },
  113. {
  114. title: '设备等级',
  115. checked: true,
  116. dataIndex: 'level',
  117. width: 150,
  118. customRender: (text, record, index) => {
  119. return this.BaseTool.Object.getField(this.levelMap, text)
  120. }
  121. },
  122. {
  123. title: '购置日期',
  124. dataIndex: 'buyDate',
  125. width: 100,
  126. checked: true
  127. },
  128. {
  129. title: '投用日期',
  130. dataIndex: 'startDate',
  131. width: 100,
  132. checked: true
  133. },
  134. {
  135. title: '检定日期',
  136. dataIndex: 'checkDate',
  137. width: 150,
  138. checked: true
  139. },
  140. {
  141. title: '检定周期',
  142. dataIndex: 'checkPeriod',
  143. width: 100,
  144. checked: true,
  145. customRender: (text, record, index) => {
  146. if (record.nextCheckDate == null) {
  147. return '未知'
  148. } else {
  149. return text + '月'
  150. }
  151. }
  152. },
  153. {
  154. title: '检定有效期',
  155. dataIndex: 'nextCheckDate',
  156. width: 150,
  157. fixed: 'right',
  158. checked: true
  159. },
  160. {
  161. title: '检定截止',
  162. dataIndex: 'restDay',
  163. width: 100,
  164. fixed: 'right',
  165. checked: true,
  166. customRender: (text, record, index) => {
  167. if (record.nextCheckDate == null) {
  168. return '未知'
  169. } else {
  170. return this.BaseTool.Date.getCountBetween(new Date(), record.nextCheckDate, 1) + '天'
  171. }
  172. }
  173. },
  174. {
  175. title: '状态',
  176. checked: true,
  177. dataIndex: 'status',
  178. width: 100,
  179. fixed: 'right',
  180. scopedSlots: { customRender: 'status' }
  181. },
  182. {
  183. title: '操作',
  184. key: 'action',
  185. checked: true,
  186. align: 'center',
  187. width: 100,
  188. fixed: 'right',
  189. scopedSlots: { customRender: 'action' }
  190. }
  191. ],
  192. data: []
  193. }
  194. },
  195. created () {
  196. // 下拉框map
  197. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  198. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  199. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  200. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  201. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  202. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  203. },
  204. methods: {
  205. base (record) {
  206. this.visible = true
  207. this.model = record
  208. this.modalTitle = '详情2'
  209. querySbInfo({ parentId: record.id }).then(res => {
  210. this.data = res.data
  211. })
  212. },
  213. handleOk () {
  214. querySbInfo({ parentId: this.model.id, type: this.checkType }).then(res => {
  215. this.data = res.data
  216. })
  217. },
  218. handleAdd () {
  219. const modal = this.$refs.baseModal
  220. modal.base(null, this.model.id)
  221. },
  222. handleView (record) {
  223. fetchSbInfo({ id: record.id }).then(res => {
  224. const modal = this.$refs.detailModal
  225. res.data.partName = record.partName
  226. modal.base(res.data)
  227. })
  228. },
  229. handleEdit (record) {
  230. fetchSbInfo({ id: record.id }).then(res => {
  231. const modal = this.$refs.baseModal
  232. modal.base(res.data)
  233. })
  234. },
  235. handleCopy (record) {
  236. const modal = this.$refs.baseModal
  237. const data = record
  238. data.id = null
  239. modal.base(data)
  240. },
  241. handleGenerate (record) {
  242. const modal = this.$refs.baseModalInsert
  243. modal.base(null, record.id)
  244. },
  245. handleCancel () {
  246. this.visible = false
  247. this.confirmLoading = false
  248. this.$emit('ok')
  249. },
  250. batchDelete (id) {
  251. let ids = []
  252. if (this.BaseTool.String.isBlank(id)) {
  253. if (length === 0) {
  254. this.$message.info('请选择要删除的记录')
  255. return
  256. }
  257. ids = this.selectedRows.map(item => item.id)
  258. } else {
  259. ids = [id]
  260. }
  261. deleteSbInfos(ids).then(res => {
  262. this.$message.info('删除成功')
  263. this.handleOk()
  264. })
  265. },
  266. batchCancel (id) {
  267. if (this.BaseTool.String.isBlank(id)) {
  268. this.$message.info('请选择要取消的记录')
  269. return
  270. }
  271. updateSbInfoChildCancel({ id: id }).then(res => {
  272. this.$message.info('取消成功')
  273. this.handleOk()
  274. })
  275. },
  276. doExport () {
  277. const parameter = {
  278. ...this.queryParam
  279. }
  280. parameter.modelId = this.model.id
  281. exportSbInfo(parameter).then(file => {
  282. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  283. })
  284. },
  285. handleSbSelect () {
  286. this.$refs.sbInfoSelectModal.base()
  287. },
  288. handleSbSelected (keys, rows) {
  289. const data = []
  290. for (let i = 0; i < rows.length; i++) {
  291. data.push({ parentId: this.model.id, id: rows[i].id })
  292. }
  293. updateSbInfoChildBatch(data)
  294. .then((response) => {
  295. this.$message.info('绑定成功')
  296. this.handleOk()
  297. }).catch(() => {
  298. this.confirmLoading = false
  299. })
  300. }
  301. }
  302. }
  303. </script>