SparePartInfo.vue 17 KB

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