DetailSbBom.vue 8.0 KB

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