SparePartInfo.vue 16 KB

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