Detail.vue 10.0 KB

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