SparePartInfoCheckWarn.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <a-card :bordered="false">
  3. <a-row :gutter="8" v-show="visible">
  4. <a-col :span="24">
  5. <div class="table-page-search-wrapper">
  6. <a-form layout="inline">
  7. <a-row :gutter="48">
  8. <a-col :md="8" :sm="24">
  9. <a-form-item label="月份">
  10. <a-input-number
  11. :step="1"
  12. :min="1"
  13. v-model="queryParam.month"
  14. placeholder="请输入要查询最近多少月份"/>
  15. </a-form-item>
  16. </a-col>
  17. <!--<a-col :md="8" :sm="24">
  18. <a-form-item label="类型">
  19. <a-tree-select
  20. style="width: 100%"
  21. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  22. :treeData="spareTypeTreeData"
  23. :treeNodeFilterProp="'title'"
  24. :showSearch="true"
  25. v-model="queryParam.typeId"
  26. placeholder="请选择"
  27. >
  28. </a-tree-select>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="8" :sm="24">
  32. <a-form-item label="规格型号">
  33. <a-input v-model="queryParam.ggxh" placeholder="模糊查询"/>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="8" :sm="24">
  37. <a-form-item label="原厂编号">
  38. <a-input v-model="queryParam.initNo" placeholder="模糊查询"/>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :md="8" :sm="24">
  42. <a-form-item label="生产商">
  43. <a-input v-model="queryParam.producerName" placeholder="名称模糊查询"/>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="8" :sm="24">
  47. <a-form-item label="供应商">
  48. <a-input v-model="queryParam.supplierName" placeholder="名称模糊查询"/>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="8" :sm="24">
  52. <a-form-item label="等级">
  53. <a-select v-model="queryParam.level" placeholder="请选择">
  54. <a-select-option
  55. v-for="(label,value) in levelMap"
  56. :key="value"
  57. :label="label"
  58. :value="parseInt(value)">{{ label }}
  59. </a-select-option>
  60. </a-select>
  61. </a-form-item>
  62. </a-col>
  63. <a-col :md="6" :sm="24">
  64. <a-form-item label="用途">
  65. <a-select v-model="queryParam.yt" placeholder="请选择">
  66. <a-select-option
  67. v-for="(label,value) in ytMap"
  68. :key="value"
  69. :label="label"
  70. :value="parseInt(value)">{{ label }}
  71. </a-select-option>
  72. </a-select>
  73. </a-form-item>
  74. </a-col>-->
  75. <a-col :md="6 || 24" :sm="24">
  76. <span class="table-page-search-submitButtons">
  77. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  78. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  79. </span>
  80. </a-col>
  81. </a-row>
  82. </a-form>
  83. </div>
  84. <div class="table-operator">
  85. </div>
  86. <s-table
  87. ref="table"
  88. size="default"
  89. rowKey="spareId"
  90. :columns="columns"
  91. :data="loadData"
  92. :scroll="{x: 1500, y: BaseTool.Constant.scrollY}"
  93. :alert="options.alert"
  94. :rowSelection="options.rowSelection"
  95. showPagination="auto"
  96. >
  97. </s-table>
  98. </a-col>
  99. </a-row>
  100. <base-form ref="baseModal" @ok="handleOk"/>
  101. <detail ref="detailModal" @ok="handleOk"/>
  102. <detail-bom ref="detailBomModal" @ok="handleOk"/>
  103. <storeList ref="storeListModal"/>
  104. <inStoreList ref="inStoreListModal"/>
  105. <outStoreList ref="outStoreListModal"/>
  106. <spare-part-used-select-modal ref="sparePartUsedSelectModal"/>
  107. <spare-part-info-select-modal-for-adjust :type="'radio'" ref="spareSelectModal" @selected="handleSpareSelected"/>
  108. <import-form-add ref="importModal" @ok="handleOk"/>
  109. <import-form-update ref="importModalForUpdate" @ok="handleOk"/>
  110. </a-card>
  111. </template>
  112. <script>
  113. import { STable, Ellipsis } from '@/components'
  114. import BaseForm from './modules/BaseForm'
  115. import Detail from './modules/Detail'
  116. import DetailBom from './modules/DetailBom'
  117. import StoreList from './modules/StoreList'
  118. import InStoreList from './modules/InStoreList'
  119. import OutStoreList from './modules/OutStoreList'
  120. import SparePartUsedSelectModal from '@/views/sqarepartmanage/sparepartused/modules/SparePartUsedSelectModal'
  121. import { getSparePartInfoCheckWarnPage, updateSpareIdsBatch, deleteSparePartInfos, fetchSparePartInfo, fetchStoreList, fetchInStoreList, fetchOutStoreList, exportSparePartInfo } from '@/api/sqarepartmanage/sparepartinfo'
  122. import { fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
  123. import ImportFormAdd from './modules/ImportFormAdd'
  124. import ImportFormUpdate from './modules/ImportFormUpdate'
  125. import SparePartInfoSelectModalForAdjust from '@/views/sqarepartmanage/sparepartinfo/modules/SparePartInfoSelectModalForAdjust'
  126. export default {
  127. name: 'SparePartInfoListCheckWarn',
  128. components: {
  129. STable,
  130. Ellipsis,
  131. BaseForm,
  132. Detail,
  133. DetailBom,
  134. StoreList,
  135. InStoreList,
  136. OutStoreList,
  137. SparePartUsedSelectModal,
  138. ImportFormAdd,
  139. SparePartInfoSelectModalForAdjust,
  140. ImportFormUpdate
  141. },
  142. data () {
  143. return {
  144. // 查询参数
  145. queryParam: {
  146. type: 2,
  147. month: 6
  148. },
  149. // 表头
  150. columns: [
  151. {
  152. title: '序号',
  153. dataIndex: 'index',
  154. width: 100,
  155. checked: true,
  156. customRender: (text, record, index) => {
  157. return `${index + 1}`
  158. }
  159. },
  160. {
  161. title: '备件名称',
  162. dataIndex: 'spareName',
  163. checked: true,
  164. width: '150px'
  165. },
  166. {
  167. title: '规格型号',
  168. checked: true,
  169. width: '150px',
  170. dataIndex: 'ggxh'
  171. },
  172. {
  173. title: '预消耗数量',
  174. checked: true,
  175. width: '150px',
  176. dataIndex: 'num'
  177. },
  178. {
  179. title: '库存数量',
  180. checked: true,
  181. width: '150px',
  182. dataIndex: 'storeNum'
  183. }
  184. ],
  185. // 加载数据方法 必须为 Promise 对象
  186. loadData: parameter => {
  187. parameter = {
  188. ...parameter,
  189. ...this.queryParam,
  190. dataScope: {
  191. sortBy: 'desc',
  192. sortName: 'name'
  193. }
  194. }
  195. return getSparePartInfoCheckWarnPage(Object.assign(parameter, this.queryParam))
  196. .then(res => {
  197. return res.data
  198. })
  199. },
  200. selectedRowKeys: [],
  201. selectedRows: [],
  202. expandedKeys: [],
  203. selectedKeys: [],
  204. levelMap: {},
  205. unitMap: {},
  206. cdMap: {},
  207. ytMap: {},
  208. id: null,
  209. visible: true,
  210. spareTypeTreeData: [],
  211. options: {
  212. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  213. rowSelection: {
  214. selectedRowKeys: this.selectedRowKeys,
  215. onChange: this.onSelectChange
  216. }
  217. },
  218. optionAlertShow: false
  219. }
  220. },
  221. created () {
  222. // 下拉框map
  223. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  224. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  225. this.cdMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PRODUCER_AREA)
  226. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  227. this.tableOption()
  228. fetchSpareTypeTree({}).then(res => {
  229. this.spareTypeTreeData = res.data
  230. })
  231. },
  232. methods: {
  233. tableOption () {
  234. if (!this.optionAlertShow) {
  235. this.options = {
  236. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  237. rowSelection: {
  238. selectedRowKeys: this.selectedRowKeys,
  239. onChange: this.onSelectChange,
  240. getCheckboxProps: record => ({
  241. props: {
  242. disabled: false,
  243. name: record.id
  244. }
  245. })
  246. }
  247. }
  248. this.optionAlertShow = true
  249. } else {
  250. this.options = {
  251. alert: false,
  252. rowSelection: null
  253. }
  254. this.optionAlertShow = false
  255. }
  256. },
  257. batchDelete (id) {
  258. let ids = []
  259. if (this.BaseTool.String.isBlank(id)) {
  260. const length = this.selectedRows.length
  261. if (length === 0) {
  262. this.$message.info('请选择要删除的记录')
  263. return
  264. }
  265. ids = this.selectedRows.map(item => item.id)
  266. } else {
  267. ids = [id]
  268. }
  269. deleteSparePartInfos(ids).then(res => {
  270. this.$message.info('删除成功')
  271. this.handleOk()
  272. this.$refs.table.clearSelected()
  273. })
  274. },
  275. handleEdit (record) {
  276. this.visible = false
  277. fetchSparePartInfo({ id: record.id }).then(res => {
  278. const modal = this.$refs.baseModal
  279. modal.base(res.data)
  280. })
  281. },
  282. handleDetailBom (record) {
  283. this.visible = false
  284. const modal = this.$refs.detailBomModal
  285. modal.base(record)
  286. },
  287. handleCopy (record) {
  288. this.visible = false
  289. fetchSparePartInfo({ id: record.id }).then(res => {
  290. const modal = this.$refs.baseModal
  291. res.data.id = null
  292. modal.base(res.data)
  293. })
  294. },
  295. handleStore (record) {
  296. fetchStoreList({ id: record.id }).then(res => {
  297. const modal = this.$refs.storeListModal
  298. modal.base(res.data)
  299. })
  300. },
  301. handleInStore (record) {
  302. fetchInStoreList({ id: record.id }).then(res => {
  303. const modal = this.$refs.inStoreListModal
  304. modal.base(res.data)
  305. })
  306. },
  307. handleSparePartUsed (record) {
  308. this.$refs.sparePartUsedSelectModal.base({}, { spareId: record.id })
  309. },
  310. handleOutStore (record) {
  311. fetchOutStoreList({ id: record.id }).then(res => {
  312. const modal = this.$refs.outStoreListModal
  313. modal.base(res.data)
  314. })
  315. },
  316. handleAdd (record) {
  317. this.visible = false
  318. this.$refs.baseModal.base()
  319. },
  320. handleView (record) {
  321. this.visible = false
  322. fetchSparePartInfo({ id: record.id }).then(res => {
  323. const modal = this.$refs.detailModal
  324. modal.base(res.data)
  325. })
  326. },
  327. handleOk () {
  328. this.visible = true
  329. this.$refs.table.refresh()
  330. },
  331. onSelectChange (selectedRowKeys, selectedRows) {
  332. this.selectedRowKeys = selectedRowKeys
  333. this.selectedRows = selectedRows
  334. },
  335. resetSearchForm () {
  336. this.queryParam = {
  337. }
  338. this.$refs.table.refresh(true)
  339. },
  340. onSelect: function (selectedKeys, info) {
  341. this.selectedKeys = selectedKeys
  342. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  343. this.$refs.table.refresh(true)
  344. },
  345. onExpand (expandedKeys) {
  346. this.expandedKeys = expandedKeys
  347. this.autoExpandParent = false
  348. },
  349. doExport () {
  350. this.$message.info('数据正在处理,耐心等待,请勿重复点击')
  351. const parameter = {
  352. ...this.queryParam
  353. }
  354. exportSparePartInfo(parameter).then(file => {
  355. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  356. })
  357. },
  358. doImport () {
  359. this.$refs.importModal.base()
  360. },
  361. doImportForUpdate () {
  362. this.$refs.importModalForUpdate.base()
  363. },
  364. handleSpareSelect (id) {
  365. const length = this.selectedRows.length
  366. if (length < 2) {
  367. this.$message.info('请至少选择2个备件')
  368. return
  369. }
  370. this.$refs.spareSelectModal.base(this.selectedRows)
  371. },
  372. handleSpareSelected (keys) {
  373. const spareId = keys[0]
  374. let ids = []
  375. ids = this.selectedRows.map(item => item.id).filter(id => id !== spareId)
  376. updateSpareIdsBatch(spareId, ids)
  377. .then((res) => {
  378. this.$message.info('校正成功')
  379. this.handleOk()
  380. this.id = null
  381. this.$refs.table.clearSelected()
  382. }).catch(() => {
  383. this.confirmLoading = false
  384. })
  385. }
  386. }
  387. }
  388. </script>