DetailSbBom.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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.model }}</detail-list-item>
  13. <detail-list-item term="名称型号">{{ model.nameModel }}</detail-list-item>
  14. <detail-list-item term="设备名称">{{ model.name }}</detail-list-item>
  15. </detail-list>
  16. <title-divider title="BOM信息" width="90px"></title-divider>
  17. <div class="table-operator" style="margin-bottom: 8px;">
  18. <a-button type="primary" @click="handleAdd">
  19. <a-icon type="plus"/>
  20. 关联BOM
  21. </a-button>
  22. <a-button style="margin-left:8px;" type="primary" @click="handleSpareSelect">
  23. <a-icon type="plus"/>
  24. 批量关联BOM
  25. </a-button>
  26. <a-button style="margin-left:8px;" type="primary" @click="handleSbSelect">
  27. <a-icon type="plus"/>
  28. 复制BOM
  29. </a-button>
  30. <a-button style="margin-left:8px;" type="primary" @click="handleSpareAdd">
  31. <a-icon type="plus"/>
  32. 添加备件
  33. </a-button>
  34. <!-- <a-button style="margin-left: 8px" type="primary" icon="download" @click="downTemplate">下载模板</a-button>
  35. <a-button style="margin-left: 8px" type="primary" icon="download" @click="doExport">导出</a-button>
  36. <a-button style="margin-left:8px;" type="primary" @click="doImport">
  37. <a-icon type="upload"/>
  38. 导入
  39. </a-button>-->
  40. </div>
  41. <a-table
  42. :data-source="data"
  43. :columns="columns"
  44. tableLayout="auto"
  45. rowKey="id">
  46. <span slot="action" slot-scope="record">
  47. <template>
  48. <a @click="handleEdit(record)">修改备件</a>
  49. <a-divider type="vertical" />
  50. <a @click="handleEditRelation(record)">修改bom</a>
  51. <a-divider type="vertical" />
  52. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  53. <a>取消bom</a>
  54. </a-popconfirm>
  55. </template>
  56. </span>
  57. </a-table>
  58. <base-form-sb ref="baseModalSb" @ok="handleOk"/>
  59. <base-form ref="baseModal" @ok="handleOk"/>
  60. <import-form-add ref="importModal" @ok="handleOk"></import-form-add>
  61. <spare-part-info-select-modal :type="'checkbox'" ref="spareSelectModal" @selected="handleSpareSelected"/>
  62. <sb-info-select-modal :type="'radio'" ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
  63. </div>
  64. </template>
  65. <script>
  66. import DetailList from '@/components/tools/DetailList'
  67. import { addSbModelBomBatch, copy, selectSpareInfoListBySbId, deleteSbModelBoms, exportSbModelBom } from '@/api/sb/modelbom'
  68. import SparePartInfoSelectModal from '@/views/sqarepartmanage/sparepartinfo/modules/SparePartInfoSelectModal'
  69. import BaseFormSb from './BaseFormSb'
  70. import ImportFormAdd from './ImportFormAdd'
  71. import BaseForm from '@/views/sqarepartmanage/sparepartinfo/modules/BaseForm'
  72. import { fetchSparePartInfo } from '@/api/sqarepartmanage/sparepartinfo'
  73. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  74. const DetailListItem = DetailList.Item
  75. export default {
  76. name: 'SbBomDetail',
  77. components: {
  78. DetailList,
  79. DetailListItem,
  80. BaseFormSb,
  81. SparePartInfoSelectModal,
  82. ImportFormAdd,
  83. BaseForm,
  84. SbInfoSelectModal
  85. },
  86. data () {
  87. return {
  88. confirmLoading: false,
  89. mdl: {},
  90. model: {
  91. 'id': null,
  92. 'modelId': null,
  93. 'no': null,
  94. 'name': null,
  95. 'nameModel': null,
  96. 'unit': null,
  97. 'level': null,
  98. 'useType': null
  99. },
  100. modalTitle: null,
  101. visible: false,
  102. useTypeMap: {},
  103. levelMap: {},
  104. unitMap: {},
  105. periodTypeMap: {},
  106. // 表头
  107. columns: [
  108. {
  109. title: '序号',
  110. dataIndex: 'index',
  111. customRender: (text, record, index) => {
  112. return `${index + 1}`
  113. }
  114. },
  115. {
  116. title: '部位',
  117. dataIndex: 'sbPartName'
  118. },
  119. {
  120. title: '名称',
  121. dataIndex: 'name'
  122. },
  123. {
  124. title: '编码',
  125. dataIndex: 'no'
  126. },
  127. {
  128. title: '自编号',
  129. dataIndex: 'zbh'
  130. },
  131. {
  132. title: '规格型号',
  133. dataIndex: 'ggxh'
  134. },
  135. {
  136. title: '更换周期',
  137. dataIndex: 'period',
  138. customRender: (text, record, index) => {
  139. return text + this.BaseTool.Table.getMapText(this.periodTypeMap, record.periodType)
  140. }
  141. },
  142. {
  143. title: '更换日期',
  144. dataIndex: 'checkDate'
  145. },
  146. {
  147. title: '下次更换日期',
  148. dataIndex: 'nextCheckDate'
  149. },
  150. {
  151. title: '数量',
  152. dataIndex: 'num'
  153. },
  154. {
  155. title: '助记码',
  156. dataIndex: 'zjm'
  157. },
  158. {
  159. title: '操作',
  160. key: 'action',
  161. checked: true,
  162. align: 'center',
  163. // fixed: 'right',
  164. scopedSlots: { customRender: 'action' }
  165. }
  166. ],
  167. data: []
  168. }
  169. },
  170. created () {
  171. // 下拉框map
  172. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  173. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  174. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_MODEL_RECOMMEND)
  175. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  176. this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  177. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  178. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  179. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  180. },
  181. methods: {
  182. base (record) {
  183. this.visible = true
  184. this.model = record
  185. this.modalTitle = '详情Bom'
  186. selectSpareInfoListBySbId({ id: record.id }).then(res => {
  187. this.data = res.data
  188. })
  189. },
  190. handleOk () {
  191. selectSpareInfoListBySbId({ id: this.model.id }).then(res => {
  192. this.data = res.data
  193. })
  194. },
  195. handleSpareSelect () {
  196. this.$refs.spareSelectModal.base({})
  197. },
  198. handleSpareSelected (record, keys, rows) {
  199. const addData = []
  200. for (let i = 0; i < rows.length; i++) {
  201. addData.push({ sbId: this.model.id, spareId: rows[i].id, spareName: rows[i].name, num: 1, period: 500, periodType: 6 })
  202. }
  203. addSbModelBomBatch(addData)
  204. .then((response) => {
  205. this.$message.info('批量添加成功')
  206. this.handleOk()
  207. }).catch(() => {
  208. this.confirmLoading = false
  209. })
  210. },
  211. handleAdd () {
  212. const modal = this.$refs.baseModalSb
  213. modal.base({ sbId: this.model.id })
  214. },
  215. handleSpareAdd () {
  216. const modal = this.$refs.baseModal
  217. modal.base(null, this.model.id)
  218. },
  219. handleEdit (record) {
  220. fetchSparePartInfo({ id: record.spareId }).then(res => {
  221. const modal = this.$refs.baseModal
  222. modal.base(res.data)
  223. })
  224. },
  225. handleEditRelation (record) {
  226. const modal = this.$refs.baseModalSb
  227. modal.base(record)
  228. },
  229. handleCancel () {
  230. this.visible = false
  231. this.confirmLoading = false
  232. this.$emit('ok')
  233. },
  234. doImport () {
  235. this.$refs.importModal.base(this.model.id)
  236. },
  237. downTemplate () {
  238. const a = document.createElement('a')
  239. a.href = this.DictCache.getValueByCode(this.DictCache.TYPE.FILE_DOWNLOAD_TEMPLATE, 'SB_MODEL_BOM_DOWNLOAD_TEMPLATE')
  240. a.target = '_blank'
  241. a.click()
  242. },
  243. batchDelete (id) {
  244. let ids = []
  245. if (this.BaseTool.String.isBlank(id)) {
  246. if (length === 0) {
  247. this.$message.info('请选择要删除的记录')
  248. return
  249. }
  250. ids = this.selectedRows.map(item => item.id)
  251. } else {
  252. ids = [id]
  253. }
  254. deleteSbModelBoms(ids).then(res => {
  255. this.$message.info('删除成功')
  256. this.handleOk()
  257. })
  258. },
  259. doExport () {
  260. const parameter = {
  261. ...this.queryParam
  262. }
  263. parameter.modelId = this.model.id
  264. exportSbModelBom(parameter).then(file => {
  265. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  266. })
  267. },
  268. handleSbSelect () {
  269. this.$refs.sbInfoSelectModal.base()
  270. },
  271. handleSbSelectd (keys, rows) {
  272. const [ key ] = keys
  273. const [ row ] = rows
  274. // 日期处理
  275. copy({ sbId: this.model.id, copySbId: row.id })
  276. .then((response) => {
  277. this.$message.info(response.data)
  278. this.handleOk()
  279. }).catch(() => {
  280. this.confirmLoading = false
  281. })
  282. }
  283. }
  284. }
  285. </script>