SparePartInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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: 'currentStock',
  206. scopedSlots: { customRender: 'status' }
  207. },
  208. {
  209. title: '最高库存',
  210. width: '150px',
  211. checked: true,
  212. dataIndex: 'maxStock'
  213. },
  214. {
  215. title: '最低库存',
  216. width: '150px',
  217. checked: true,
  218. dataIndex: 'minStock'
  219. },
  220. {
  221. title: '是否预警',
  222. dataIndex: 'minStock',
  223. width: '150px',
  224. checked: true,
  225. customRender: (text, record, index) => {
  226. return record.currentStock < record.mixStock ? '是' : '否'
  227. }
  228. },
  229. {
  230. title: '生产商',
  231. dataIndex: 'producerId',
  232. width: '150px',
  233. checked: true,
  234. customRender: (text, record, index) => {
  235. return record.producerName
  236. }
  237. },
  238. {
  239. title: '单位',
  240. dataIndex: 'unit',
  241. width: '150px',
  242. checked: true,
  243. customRender: (text, record, index) => {
  244. return this.BaseTool.Object.getField(this.unitMap, text)
  245. }
  246. },
  247. {
  248. title: '等级',
  249. checked: true,
  250. width: '150px',
  251. dataIndex: 'level',
  252. customRender: (text, record, index) => {
  253. return this.BaseTool.Object.getField(this.levelMap, text)
  254. }
  255. },
  256. {
  257. title: '用途',
  258. checked: true,
  259. width: '150px',
  260. dataIndex: 'yt',
  261. customRender: (text, record, index) => {
  262. return this.BaseTool.Object.getField(this.ytMap, text)
  263. }
  264. },
  265. {
  266. title: '备注',
  267. width: '150px',
  268. checked: true,
  269. dataIndex: 'remark'
  270. },
  271. {
  272. title: '创建日期',
  273. width: '150px',
  274. checked: true,
  275. dataIndex: 'createdTime'
  276. },
  277. {
  278. title: '操作',
  279. key: 'action',
  280. checked: true,
  281. fixed: 'right',
  282. width: '400px',
  283. align: 'center',
  284. scopedSlots: { customRender: 'action' }
  285. }
  286. ],
  287. levelMap: {},
  288. specialMap: {},
  289. ytMap: {},
  290. unitMap: {},
  291. spareTypeTreeData: [],
  292. // 加载数据方法 必须为 Promise 对象
  293. loadData: parameter => {
  294. parameter = {
  295. ...parameter,
  296. ...this.queryParam,
  297. dataScope: {
  298. sortBy: 'desc',
  299. sortName: 'update_time'
  300. }
  301. }
  302. return getSparePartInfoPage(Object.assign(parameter, this.queryParam))
  303. .then(res => {
  304. return res.data
  305. })
  306. },
  307. selectedRowKeys: [],
  308. selectedRows: [],
  309. options: {
  310. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  311. rowSelection: {
  312. selectedRowKeys: this.selectedRowKeys,
  313. onChange: this.onSelectChange
  314. }
  315. },
  316. optionAlertShow: false
  317. }
  318. },
  319. created () {
  320. // 下拉框map
  321. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  322. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  323. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  324. this.specialMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  325. this.tableOption()
  326. fetchSpareTypeTree({}).then(res => {
  327. this.spareTypeTreeData = res.data
  328. })
  329. },
  330. methods: {
  331. tableOption () {
  332. if (!this.optionAlertShow) {
  333. this.options = {
  334. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  335. rowSelection: {
  336. selectedRowKeys: this.selectedRowKeys,
  337. onChange: this.onSelectChange,
  338. getCheckboxProps: record => ({
  339. props: {
  340. disabled: false,
  341. name: record.id
  342. }
  343. })
  344. }
  345. }
  346. this.optionAlertShow = true
  347. } else {
  348. this.options = {
  349. alert: false,
  350. rowSelection: null
  351. }
  352. this.optionAlertShow = false
  353. }
  354. },
  355. batchDelete (id) {
  356. let ids = []
  357. if (this.BaseTool.String.isBlank(id)) {
  358. const length = this.selectedRows.length
  359. if (length === 0) {
  360. this.$message.info('请选择要删除的记录')
  361. return
  362. }
  363. ids = this.selectedRows.map(item => item.id)
  364. } else {
  365. ids = [id]
  366. }
  367. deleteSparePartInfos(ids).then(res => {
  368. this.$message.info('删除成功')
  369. this.handleOk()
  370. this.$refs.table.clearSelected()
  371. })
  372. },
  373. handleEdit (record) {
  374. fetchSparePartInfo({ id: record.id }).then(res => {
  375. const modal = this.$refs.baseModal
  376. modal.base(res.data)
  377. })
  378. },
  379. handleStore (record) {
  380. fetchStoreList({ id: record.id }).then(res => {
  381. const modal = this.$refs.storeListModal
  382. modal.base(res.data)
  383. })
  384. },
  385. handleInStore (record) {
  386. fetchInStoreList({ id: record.id }).then(res => {
  387. const modal = this.$refs.inStoreListModal
  388. modal.base(res.data)
  389. })
  390. },
  391. handleSparePartUsed (record) {
  392. this.$refs.sparePartUsedSelectModal.base({}, { spareId: record.id })
  393. },
  394. handleOutStore (record) {
  395. fetchOutStoreList({ id: record.id }).then(res => {
  396. const modal = this.$refs.outStoreListModal
  397. modal.base(res.data)
  398. })
  399. },
  400. handleView (record) {
  401. fetchSparePartInfo({ id: record.id }).then(res => {
  402. const modal = this.$refs.detailModal
  403. modal.base(res.data)
  404. })
  405. },
  406. handleOk () {
  407. this.$refs.table.refresh()
  408. },
  409. onSelectChange (selectedRowKeys, selectedRows) {
  410. this.selectedRowKeys = selectedRowKeys
  411. this.selectedRows = selectedRows
  412. },
  413. resetSearchForm () {
  414. this.queryParam = {
  415. }
  416. this.$refs.table.refresh(true)
  417. },
  418. doExport () {
  419. const parameter = {
  420. ...this.queryParam
  421. }
  422. exportSparePartInfo(parameter).then(file => {
  423. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  424. })
  425. },
  426. handleCopy (record) {
  427. fetchSparePartInfo({ id: record.id }).then(res => {
  428. const modal = this.$refs.baseModal
  429. res.data.id = null
  430. modal.base(res.data)
  431. })
  432. }
  433. }
  434. }
  435. </script>