SparePartInfo.vue 14 KB

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