SparePartInfoSbModel.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <a-card :bordered="false">
  3. <a-row :gutter="8">
  4. <a-col :span="4">
  5. <a-tree
  6. @expand="onExpand"
  7. :expandedKeys="expandedKeys"
  8. :autoExpandParent="true"
  9. @select="onSelect"
  10. :selectedKeys="selectedKeys"
  11. :treeData="spareTypeTreeData"
  12. />
  13. </a-col>
  14. <a-col :span="20">
  15. <div class="table-page-search-wrapper">
  16. <a-form layout="inline">
  17. <a-row :gutter="48">
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="关键字">
  20. <a-input v-model="queryParam.keyword" placeholder="请输入名称/编码"/>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="等级">
  25. <a-select v-model="queryParam.level" placeholder="请选择">
  26. <a-select-option
  27. v-for="(label,value) in levelMap"
  28. :key="value"
  29. :label="label"
  30. :value="parseInt(value)">{{ label }}
  31. </a-select-option>
  32. </a-select>
  33. </a-form-item>
  34. </a-col>
  35. <!--<a-col :md="6" :sm="24">
  36. <a-form-item label="用途">
  37. <a-select v-model="queryParam.yt" placeholder="请选择">
  38. <a-select-option
  39. v-for="(label,value) in ytMap"
  40. :key="value"
  41. :label="label"
  42. :value="parseInt(value)">{{ label }}
  43. </a-select-option>
  44. </a-select>
  45. </a-form-item>
  46. </a-col>-->
  47. <a-col :md="6 || 24" :sm="24">
  48. <span class="table-page-search-submitButtons">
  49. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  50. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  51. </span>
  52. </a-col>
  53. </a-row>
  54. </a-form>
  55. </div>
  56. <div class="table-operator">
  57. <a-button v-if="$auth('sqarepartmanage-spare-part-info-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  58. <a-button style="margin-left: 8px" v-if="$auth('sqarepartmanage-spare-part-info-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  59. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sqarepartmanage-spare-part-info-del')">
  60. <a-menu slot="overlay">
  61. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  62. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  63. </a-popconfirm>
  64. </a-menu>
  65. <a-button style="margin-left: 8px">
  66. 批量操作 <a-icon type="down" />
  67. </a-button>
  68. </a-dropdown>
  69. </div>
  70. <s-table
  71. ref="table"
  72. size="default"
  73. rowKey="id"
  74. :columns="columns"
  75. :data="loadData"
  76. :alert="options.alert"
  77. :rowSelection="options.rowSelection"
  78. showPagination="auto"
  79. >
  80. <span slot="status" slot-scope="text, record">
  81. <a @click="handleStore(record)">{{ text||"无" }}</a>
  82. </span>
  83. <span slot="action" slot-scope="record">
  84. <template>
  85. <a @click="handleView(record)">查看</a>
  86. <a-divider type="vertical" />
  87. <a v-if="$auth('sqarepartmanage-spare-part-info-edit')" @click="handleEdit(record)">修改</a>
  88. <a-divider type="vertical" />
  89. <a-popconfirm v-if="$auth('sqarepartmanage-spare-part-info-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  90. <a>删除</a>
  91. </a-popconfirm>
  92. <a-divider type="vertical" />
  93. <a @click="handleCopy(record)">复制</a>
  94. </template>
  95. </span>
  96. </s-table>
  97. </a-col>
  98. </a-row>
  99. <base-form ref="baseModal" @ok="handleOk"/>
  100. <detail ref="detailModal"/>
  101. <storeList ref="storeListModal"/>
  102. <inStoreList ref="inStoreListModal"/>
  103. <outStoreList ref="outStoreListModal"/>
  104. <spare-part-used-select-modal ref="sparePartUsedSelectModal"/>
  105. </a-card>
  106. </template>
  107. <script>
  108. import { STable, Ellipsis } from '@/components'
  109. import BaseForm from './modules/BaseForm'
  110. import Detail from './modules/Detail'
  111. import StoreList from './modules/StoreList'
  112. import InStoreList from './modules/InStoreList'
  113. import OutStoreList from './modules/OutStoreList'
  114. import SparePartUsedSelectModal from '@/views/sqarepartmanage/sparepartused/modules/SparePartUsedSelectModal'
  115. import { fetchSpareTypeAndSbModelTree } from '@/api/sqarepartmanage/sparetype'
  116. import { addSbModelBomBatch, selectSpareInfoListByModelId, deleteSbModelBoms } from '@/api/sb/modelbom'
  117. export default {
  118. name: 'SparePartInfoList',
  119. components: {
  120. STable,
  121. Ellipsis,
  122. BaseForm,
  123. Detail,
  124. StoreList,
  125. InStoreList,
  126. OutStoreList,
  127. SparePartUsedSelectModal
  128. },
  129. data () {
  130. return {
  131. // 查询参数
  132. queryParam: {
  133. },
  134. // 表头
  135. columns: [
  136. {
  137. title: '备件ID',
  138. dataIndex: 'id'
  139. },
  140. {
  141. title: '备件编码',
  142. dataIndex: 'no'
  143. },
  144. {
  145. title: '备件类别',
  146. dataIndex: 'typeId',
  147. customRender: (text, record, index) => {
  148. return record.typeName
  149. }
  150. },
  151. {
  152. title: '备件名称',
  153. dataIndex: 'name'
  154. },
  155. {
  156. title: '原厂编号',
  157. dataIndex: 'initNo'
  158. },
  159. // {
  160. // title: '规格型号',
  161. // dataIndex: 'ggxh'
  162. // },
  163. {
  164. title: '等级',
  165. dataIndex: 'level',
  166. customRender: (text, record, index) => {
  167. return this.BaseTool.Object.getField(this.levelMap, text)
  168. }
  169. },
  170. {
  171. title: '备件价值',
  172. dataIndex: 'initialValue',
  173. customRender: (text, record, index) => {
  174. return this.BaseTool.Amount.formatter(text)
  175. }
  176. },
  177. // {
  178. // title: '当前库存',
  179. // dataIndex: 'currentStock',
  180. // scopedSlots: { customRender: 'status' }
  181. // },
  182. {
  183. title: '最高库存',
  184. dataIndex: 'maxStock'
  185. },
  186. {
  187. title: '最低库存',
  188. dataIndex: 'minStock'
  189. },
  190. {
  191. title: '生产商',
  192. dataIndex: 'producerId',
  193. customRender: (text, record, index) => {
  194. return record.producerName
  195. }
  196. },
  197. {
  198. title: '单位',
  199. dataIndex: 'unit',
  200. customRender: (text, record, index) => {
  201. return this.BaseTool.Object.getField(this.unitMap, text)
  202. }
  203. },
  204. {
  205. title: '自编号',
  206. dataIndex: 'zbh'
  207. },
  208. {
  209. title: '规格型号',
  210. dataIndex: 'ggxh'
  211. },
  212. {
  213. title: '英文名称',
  214. dataIndex: 'englishName'
  215. },
  216. {
  217. title: '助记码',
  218. dataIndex: 'zjm'
  219. },
  220. {
  221. title: '产地',
  222. dataIndex: 'cd',
  223. customRender: (text, record, index) => {
  224. return this.BaseTool.Object.getField(this.cdMap, text)
  225. }
  226. },
  227. {
  228. title: '用途',
  229. dataIndex: 'yt',
  230. customRender: (text, record, index) => {
  231. return this.BaseTool.Object.getField(this.ytMap, text)
  232. }
  233. },
  234. {
  235. title: '备注',
  236. dataIndex: 'remark'
  237. },
  238. {
  239. title: '创建日期',
  240. dataIndex: 'createdTime'
  241. },
  242. {
  243. title: '操作',
  244. key: 'action',
  245. align: 'center',
  246. scopedSlots: { customRender: 'action' }
  247. }
  248. ],
  249. // 加载数据方法 必须为 Promise 对象
  250. loadData: parameter => {
  251. parameter = {
  252. ...parameter,
  253. ...this.queryParam,
  254. dataScope: {
  255. sortBy: 'desc',
  256. sortName: 'update_time'
  257. }
  258. }
  259. return getSparePartInfoPage(Object.assign(parameter, this.queryParam))
  260. .then(res => {
  261. return res.data
  262. })
  263. },
  264. selectedRowKeys: [],
  265. selectedRows: [],
  266. expandedKeys: [],
  267. selectedKeys: [],
  268. levelMap: {},
  269. unitMap: {},
  270. cdMap: {},
  271. ytMap: {},
  272. spareTypeTreeData: [],
  273. options: {
  274. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  275. rowSelection: {
  276. selectedRowKeys: this.selectedRowKeys,
  277. onChange: this.onSelectChange
  278. }
  279. },
  280. optionAlertShow: false
  281. }
  282. },
  283. created () {
  284. // 下拉框map
  285. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  286. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  287. this.cdMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PRODUCER_AREA)
  288. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  289. this.tableOption()
  290. fetchSpareTypeAndSbModelTree({}).then(res => {
  291. this.spareTypeTreeData = res.data
  292. })
  293. },
  294. methods: {
  295. tableOption () {
  296. if (!this.optionAlertShow) {
  297. this.options = {
  298. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  299. rowSelection: {
  300. selectedRowKeys: this.selectedRowKeys,
  301. onChange: this.onSelectChange,
  302. getCheckboxProps: record => ({
  303. props: {
  304. disabled: false,
  305. name: record.id
  306. }
  307. })
  308. }
  309. }
  310. this.optionAlertShow = true
  311. } else {
  312. this.options = {
  313. alert: false,
  314. rowSelection: null
  315. }
  316. this.optionAlertShow = false
  317. }
  318. },
  319. batchDelete (id) {
  320. let ids = []
  321. if (this.BaseTool.String.isBlank(id)) {
  322. const length = this.selectedRows.length
  323. if (length === 0) {
  324. this.$message.info('请选择要删除的记录')
  325. return
  326. }
  327. ids = this.selectedRows.map(item => item.id)
  328. } else {
  329. ids = [id]
  330. }
  331. deleteSparePartInfos(ids).then(res => {
  332. this.$message.info('删除成功')
  333. this.handleOk()
  334. this.$refs.table.clearSelected()
  335. })
  336. },
  337. handleEdit (record) {
  338. fetchSparePartInfo({ id: record.id }).then(res => {
  339. const modal = this.$refs.baseModal
  340. modal.base(res.data)
  341. })
  342. },
  343. handleStore (record) {
  344. fetchStoreList({ id: record.id }).then(res => {
  345. const modal = this.$refs.storeListModal
  346. modal.base(res.data)
  347. })
  348. },
  349. handleInStore (record) {
  350. fetchInStoreList({ id: record.id }).then(res => {
  351. const modal = this.$refs.inStoreListModal
  352. modal.base(res.data)
  353. })
  354. },
  355. handleSparePartUsed (record) {
  356. this.$refs.sparePartUsedSelectModal.base({}, { spareId: record.id })
  357. },
  358. handleOutStore (record) {
  359. fetchOutStoreList({ id: record.id }).then(res => {
  360. const modal = this.$refs.outStoreListModal
  361. modal.base(res.data)
  362. })
  363. },
  364. handleView (record) {
  365. fetchSparePartInfo({ id: record.id }).then(res => {
  366. const modal = this.$refs.detailModal
  367. modal.base(res.data)
  368. })
  369. },
  370. handleOk () {
  371. this.$refs.table.refresh()
  372. },
  373. onSelectChange (selectedRowKeys, selectedRows) {
  374. this.selectedRowKeys = selectedRowKeys
  375. this.selectedRows = selectedRows
  376. },
  377. resetSearchForm () {
  378. this.queryParam = {
  379. }
  380. this.$refs.table.refresh(true)
  381. },
  382. onSelect: function (selectedKeys, info) {
  383. this.selectedKeys = selectedKeys
  384. this.queryParam.modelId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  385. this.$refs.table.refresh(true)
  386. },
  387. onExpand (expandedKeys) {
  388. this.expandedKeys = expandedKeys
  389. this.autoExpandParent = false
  390. },
  391. doExport () {
  392. const parameter = {
  393. ...this.queryParam
  394. }
  395. exportSparePartInfo(parameter).then(file => {
  396. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  397. })
  398. },
  399. handleCopy (record) {
  400. fetchSparePartInfo({ id: record.id }).then(res => {
  401. const modal = this.$refs.baseModal
  402. res.data.id = null
  403. modal.base(res.data)
  404. })
  405. }
  406. }
  407. }
  408. </script>