SparePartInfo.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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. dataIndex: 'currentStock',
  229. width: '150px',
  230. scopedSlots: { customRender: 'status' }
  231. },
  232. {
  233. title: '计量单位',
  234. checked: true,
  235. width: '150px',
  236. dataIndex: 'unit'
  237. },
  238. {
  239. title: '最高库存',
  240. checked: true,
  241. width: '150px',
  242. dataIndex: 'maxStock'
  243. },
  244. {
  245. title: '最低库存',
  246. checked: true,
  247. width: '150px',
  248. dataIndex: 'minStock'
  249. },
  250. {
  251. title: '等级',
  252. checked: true,
  253. width: '150px',
  254. dataIndex: 'level',
  255. customRender: (text, record, index) => {
  256. return this.BaseTool.Object.getField(this.levelMap, text)
  257. }
  258. },
  259. {
  260. title: '生产商',
  261. checked: true,
  262. width: '150px',
  263. dataIndex: 'producerId',
  264. customRender: (text, record, index) => {
  265. return record.producerName
  266. }
  267. },
  268. {
  269. title: '英文名称',
  270. checked: true,
  271. width: '150px',
  272. dataIndex: 'englishName'
  273. },
  274. {
  275. title: '助记码',
  276. checked: true,
  277. width: '150px',
  278. dataIndex: 'zjm'
  279. },
  280. {
  281. title: '产地',
  282. checked: true,
  283. width: '150px',
  284. dataIndex: 'cd',
  285. customRender: (text, record, index) => {
  286. return this.BaseTool.Object.getField(this.cdMap, text)
  287. }
  288. },
  289. {
  290. title: '用途',
  291. checked: true,
  292. width: '150px',
  293. dataIndex: 'yt',
  294. customRender: (text, record, index) => {
  295. return this.BaseTool.Object.getField(this.ytMap, text)
  296. }
  297. },
  298. {
  299. title: '备注',
  300. checked: true,
  301. width: '150px',
  302. dataIndex: 'remark'
  303. },
  304. {
  305. title: '创建日期',
  306. checked: true,
  307. width: '200px',
  308. dataIndex: 'createdTime'
  309. },
  310. {
  311. title: '操作',
  312. checked: true,
  313. width: '250px',
  314. fixed: 'right',
  315. key: 'action',
  316. align: 'center',
  317. scopedSlots: { customRender: 'action' }
  318. }
  319. ],
  320. // 加载数据方法 必须为 Promise 对象
  321. loadData: parameter => {
  322. parameter = {
  323. ...parameter,
  324. ...this.queryParam,
  325. dataScope: {
  326. sortBy: 'desc',
  327. sortName: 'name'
  328. }
  329. }
  330. return getSparePartInfoPage(Object.assign(parameter, this.queryParam))
  331. .then(res => {
  332. return res.data
  333. })
  334. },
  335. selectedRowKeys: [],
  336. selectedRows: [],
  337. expandedKeys: [],
  338. selectedKeys: [],
  339. levelMap: {},
  340. unitMap: {},
  341. cdMap: {},
  342. ytMap: {},
  343. id: null,
  344. visible: true,
  345. spareTypeTreeData: [],
  346. options: {
  347. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  348. rowSelection: {
  349. selectedRowKeys: this.selectedRowKeys,
  350. onChange: this.onSelectChange
  351. }
  352. },
  353. optionAlertShow: false
  354. }
  355. },
  356. created () {
  357. // 下拉框map
  358. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  359. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  360. this.cdMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PRODUCER_AREA)
  361. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  362. this.tableOption()
  363. fetchSpareTypeTree({}).then(res => {
  364. this.spareTypeTreeData = res.data
  365. })
  366. },
  367. methods: {
  368. tableOption () {
  369. if (!this.optionAlertShow) {
  370. this.options = {
  371. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  372. rowSelection: {
  373. selectedRowKeys: this.selectedRowKeys,
  374. onChange: this.onSelectChange,
  375. getCheckboxProps: record => ({
  376. props: {
  377. disabled: false,
  378. name: record.id
  379. }
  380. })
  381. }
  382. }
  383. this.optionAlertShow = true
  384. } else {
  385. this.options = {
  386. alert: false,
  387. rowSelection: null
  388. }
  389. this.optionAlertShow = false
  390. }
  391. },
  392. batchDelete (id) {
  393. let ids = []
  394. if (this.BaseTool.String.isBlank(id)) {
  395. const length = this.selectedRows.length
  396. if (length === 0) {
  397. this.$message.info('请选择要删除的记录')
  398. return
  399. }
  400. ids = this.selectedRows.map(item => item.id)
  401. } else {
  402. ids = [id]
  403. }
  404. deleteSparePartInfos(ids).then(res => {
  405. this.$message.info('删除成功')
  406. this.handleOk()
  407. this.$refs.table.clearSelected()
  408. })
  409. },
  410. handleEdit (record) {
  411. this.visible = false
  412. fetchSparePartInfo({ id: record.id }).then(res => {
  413. const modal = this.$refs.baseModal
  414. modal.base(res.data)
  415. })
  416. },
  417. handleDetailBom (record) {
  418. this.visible = false
  419. const modal = this.$refs.detailBomModal
  420. modal.base(record)
  421. },
  422. handleCopy (record) {
  423. this.visible = false
  424. fetchSparePartInfo({ id: record.id }).then(res => {
  425. const modal = this.$refs.baseModal
  426. res.data.id = null
  427. modal.base(res.data)
  428. })
  429. },
  430. handleStore (record) {
  431. fetchStoreList({ id: record.id }).then(res => {
  432. const modal = this.$refs.storeListModal
  433. modal.base(res.data)
  434. })
  435. },
  436. handleInStore (record) {
  437. fetchInStoreList({ id: record.id }).then(res => {
  438. const modal = this.$refs.inStoreListModal
  439. modal.base(res.data)
  440. })
  441. },
  442. handleSparePartUsed (record) {
  443. this.$refs.sparePartUsedSelectModal.base({}, { spareId: record.id })
  444. },
  445. handleOutStore (record) {
  446. fetchOutStoreList({ id: record.id }).then(res => {
  447. const modal = this.$refs.outStoreListModal
  448. modal.base(res.data)
  449. })
  450. },
  451. handleAdd (record) {
  452. this.visible = false
  453. this.$refs.baseModal.base()
  454. },
  455. handleView (record) {
  456. this.visible = false
  457. fetchSparePartInfo({ id: record.id }).then(res => {
  458. const modal = this.$refs.detailModal
  459. modal.base(res.data)
  460. })
  461. },
  462. handleOk () {
  463. this.visible = true
  464. this.$refs.table.refresh()
  465. },
  466. onSelectChange (selectedRowKeys, selectedRows) {
  467. this.selectedRowKeys = selectedRowKeys
  468. this.selectedRows = selectedRows
  469. },
  470. resetSearchForm () {
  471. this.queryParam = {
  472. }
  473. this.$refs.table.refresh(true)
  474. },
  475. onSelect: function (selectedKeys, info) {
  476. this.selectedKeys = selectedKeys
  477. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  478. this.$refs.table.refresh(true)
  479. },
  480. onExpand (expandedKeys) {
  481. this.expandedKeys = expandedKeys
  482. this.autoExpandParent = false
  483. },
  484. doExport () {
  485. this.$message.info('数据正在处理,耐心等待,请勿重复点击')
  486. const parameter = {
  487. ...this.queryParam
  488. }
  489. exportSparePartInfo(parameter).then(file => {
  490. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  491. })
  492. },
  493. doImport () {
  494. this.$refs.importModal.base()
  495. },
  496. doImportForUpdate () {
  497. this.$refs.importModalForUpdate.base()
  498. },
  499. handleSpareSelect (id) {
  500. const length = this.selectedRows.length
  501. if (length < 2) {
  502. this.$message.info('请至少选择2个备件')
  503. return
  504. }
  505. this.$refs.spareSelectModal.base(this.selectedRows)
  506. },
  507. handleSpareSelected (keys) {
  508. const spareId = keys[0]
  509. let ids = []
  510. ids = this.selectedRows.map(item => item.id).filter(id => id !== spareId)
  511. updateSpareIdsBatch(spareId, ids)
  512. .then((res) => {
  513. this.$message.info('校正成功')
  514. this.handleOk()
  515. this.id = null
  516. this.$refs.table.clearSelected()
  517. }).catch(() => {
  518. this.confirmLoading = false
  519. })
  520. }
  521. }
  522. }
  523. </script>