SparePartInfo.vue 17 KB

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