FastOutStore.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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 v-model="queryParam.keyword" placeholder="请输入名称/编码"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="8" :sm="24">
  14. <a-form-item label="品牌">
  15. <a-input v-model="queryParam.brand" placeholder="模糊查询"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="8" :sm="24">
  19. <a-form-item label="类型">
  20. <a-tree-select
  21. style="width: 100%"
  22. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  23. :treeData="spareTypeTreeData"
  24. :treeNodeFilterProp="'title'"
  25. :showSearch="true"
  26. v-model="queryParam.typeId"
  27. placeholder="请选择"
  28. >
  29. </a-tree-select>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="8" :sm="24">
  33. <a-form-item label="规格型号">
  34. <a-input v-model="queryParam.ggxh" placeholder="模糊查询"/>
  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.initNo" 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.producerName" 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.supplierName" placeholder="名称模糊查询"/>
  50. </a-form-item>
  51. </a-col>
  52. <a-col :md="8" :sm="24">
  53. <a-form-item label="等级">
  54. <a-select v-model="queryParam.level" placeholder="请选择">
  55. <a-select-option
  56. v-for="(label,value) in levelMap"
  57. :key="value"
  58. :label="label"
  59. :value="parseInt(value)">{{ label }}
  60. </a-select-option>
  61. </a-select>
  62. </a-form-item>
  63. </a-col>
  64. <a-col :md="6" :sm="24">
  65. <a-form-item label="用途">
  66. <a-select v-model="queryParam.yt" placeholder="请选择">
  67. <a-select-option
  68. v-for="(label,value) in ytMap"
  69. :key="value"
  70. :label="label"
  71. :value="parseInt(value)">{{ label }}
  72. </a-select-option>
  73. </a-select>
  74. </a-form-item>
  75. </a-col>
  76. <a-col :md="6" :sm="24">
  77. <a-form-item label="是否专用">
  78. <a-select v-model="queryParam.isSpecial" placeholder="请选择">
  79. <a-select-option
  80. v-for="(label,value) in specialMap"
  81. :key="value"
  82. :label="label"
  83. :value="parseInt(value)">{{ label }}
  84. </a-select-option>
  85. </a-select>
  86. </a-form-item>
  87. </a-col>
  88. <a-col :md="6" :sm="24">
  89. <a-form-item label="关联设备">
  90. <a-input v-model="queryParam.model" placeholder="新号/旧号/名称/规格"/>
  91. </a-form-item>
  92. </a-col>
  93. <a-col :md="6 || 24" :sm="24">
  94. <span class="table-page-search-submitButtons">
  95. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  96. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  97. </span>
  98. </a-col>
  99. </a-row>
  100. </a-form>
  101. </div>
  102. <s-table
  103. ref="table"
  104. size="default"
  105. rowKey="id"
  106. :columns="columns"
  107. :data="loadData"
  108. :scroll="{x: 1500, y: BaseTool.Constant.scrollY}"
  109. showPagination="auto"
  110. >
  111. <span slot="status" slot-scope="text, record">
  112. <a @click="handleStore(record)">{{ text||"无" }}</a>
  113. </span>
  114. <span slot="num" slot-scope="record">
  115. <template>
  116. <a-input-number
  117. v-model="record.num"
  118. :min="1"
  119. :formatter="value => `${value}${record.unit}`"
  120. :parser="value => value.replace(record.unit, '')" />
  121. </template>
  122. </span>
  123. <span slot="action" slot-scope="record">
  124. <template>
  125. <a @click="changeStore(record,1)">出库</a>
  126. <a-divider type="vertical" />
  127. <a @click="changeStore(record,2)">入库</a>
  128. </template>
  129. </span>
  130. </s-table>
  131. </a-col>
  132. </a-row>
  133. </a-card>
  134. </template>
  135. <script>
  136. import { STable } from '@/components'
  137. import { getSqarePage, outSqare, inSqare } from '@/api/store/fastoutstore'
  138. import { fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
  139. export default {
  140. name: 'FastOutStore',
  141. components: {
  142. STable
  143. },
  144. data () {
  145. return {
  146. // 查询参数
  147. queryParam: {
  148. },
  149. confirmLoading: false,
  150. // 表头
  151. columns: [
  152. // {
  153. // title: '备件类别',
  154. // dataIndex: 'typeId',
  155. // checked: true,
  156. // width: '150px',
  157. // customRender: (text, record, index) => {
  158. // return record.typeName
  159. // }
  160. // },
  161. {
  162. title: '序号',
  163. dataIndex: 'index',
  164. checked: true,
  165. width: '70px',
  166. customRender: (text, record, index) => {
  167. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  168. }
  169. },
  170. {
  171. title: '仓库名称',
  172. dataIndex: 'storeName',
  173. checked: true,
  174. width: '150px'
  175. },
  176. {
  177. title: '备件编码',
  178. dataIndex: 'no',
  179. checked: true,
  180. width: '150px'
  181. },
  182. {
  183. title: '备件名称',
  184. dataIndex: 'name',
  185. checked: true,
  186. width: '150px'
  187. },
  188. {
  189. title: '规格型号',
  190. checked: true,
  191. width: '150px',
  192. dataIndex: 'ggxh'
  193. },
  194. {
  195. title: '品牌',
  196. checked: true,
  197. width: '150px',
  198. dataIndex: 'brand'
  199. },
  200. {
  201. title: '计量单位',
  202. checked: true,
  203. width: '150px',
  204. dataIndex: 'unit'
  205. },
  206. {
  207. title: '当前库存',
  208. dataIndex: 'currentStock',
  209. checked: true,
  210. width: '100px',
  211. scopedSlots: { customRender: 'status' }
  212. },
  213. {
  214. title: '最高库存',
  215. checked: true,
  216. width: '100px',
  217. dataIndex: 'maxStock'
  218. },
  219. {
  220. title: '最低库存',
  221. checked: true,
  222. width: '100px',
  223. dataIndex: 'minStock'
  224. },
  225. {
  226. title: '等级',
  227. checked: true,
  228. width: '150px',
  229. dataIndex: 'level',
  230. customRender: (text, record, index) => {
  231. return this.BaseTool.Object.getField(this.levelMap, text)
  232. }
  233. },
  234. {
  235. title: '生产商',
  236. checked: true,
  237. width: '150px',
  238. dataIndex: 'producerId',
  239. customRender: (text, record, index) => {
  240. return record.producerName
  241. }
  242. },
  243. {
  244. title: '用途',
  245. checked: true,
  246. width: '150px',
  247. dataIndex: 'yt',
  248. customRender: (text, record, index) => {
  249. return this.BaseTool.Object.getField(this.ytMap, text)
  250. }
  251. },
  252. {
  253. title: '备注',
  254. checked: true,
  255. width: '150px',
  256. dataIndex: 'remark'
  257. },
  258. {
  259. title: '创建日期',
  260. checked: true,
  261. width: '200px',
  262. dataIndex: 'createdTime'
  263. },
  264. {
  265. title: '填报',
  266. checked: true,
  267. width: '100px',
  268. fixed: 'right',
  269. key: 'num',
  270. align: 'center',
  271. scopedSlots: { customRender: 'num' }
  272. },
  273. {
  274. title: '操作',
  275. checked: true,
  276. width: '150px',
  277. fixed: 'right',
  278. key: 'action',
  279. align: 'center',
  280. scopedSlots: { customRender: 'action' }
  281. }
  282. ],
  283. // 加载数据方法 必须为 Promise 对象
  284. loadData: parameter => {
  285. parameter = {
  286. ...parameter,
  287. ...this.queryParam
  288. // dataScope: {
  289. // sortBy: 'desc',
  290. // sortName: 'name'
  291. // }
  292. }
  293. return getSqarePage(Object.assign(parameter, this.queryParam))
  294. .then(res => {
  295. console.log(res)
  296. return res.data
  297. })
  298. },
  299. selectedRowKeys: [],
  300. selectedRows: [],
  301. spareTypeTreeData: [],
  302. levelMap: {},
  303. specialMap: {},
  304. ytMap: {},
  305. unitMap: {},
  306. visible: true,
  307. num: 1,
  308. options: {
  309. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  310. rowSelection: {
  311. selectedRowKeys: this.selectedRowKeys,
  312. onChange: this.onSelectChange
  313. }
  314. },
  315. optionAlertShow: false
  316. }
  317. },
  318. created () {
  319. // 下拉框map
  320. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  321. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  322. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  323. this.specialMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  324. this.tableOption()
  325. fetchSpareTypeTree({}).then(res => {
  326. this.spareTypeTreeData = res.data
  327. })
  328. },
  329. methods: {
  330. tableOption () {
  331. if (!this.optionAlertShow) {
  332. this.options = {
  333. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  334. rowSelection: {
  335. selectedRowKeys: this.selectedRowKeys,
  336. onChange: this.onSelectChange,
  337. getCheckboxProps: record => ({
  338. props: {
  339. disabled: false,
  340. name: record.id
  341. }
  342. })
  343. }
  344. }
  345. this.optionAlertShow = true
  346. } else {
  347. this.options = {
  348. alert: false,
  349. rowSelection: null
  350. }
  351. this.optionAlertShow = false
  352. }
  353. },
  354. handleOk () {
  355. this.visible = true
  356. this.$refs.table.refresh()
  357. },
  358. onSelectChange (selectedRowKeys, selectedRows) {
  359. this.selectedRowKeys = selectedRowKeys
  360. this.selectedRows = selectedRows
  361. },
  362. resetSearchForm () {
  363. this.queryParam = {
  364. }
  365. this.$refs.table.refresh(true)
  366. },
  367. onSelect: function (selectedKeys, info) {
  368. this.selectedKeys = selectedKeys
  369. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  370. this.$refs.table.refresh(true)
  371. },
  372. changeStore (val, type) {
  373. if (!val.num) {
  374. this.$message.success('请填报数量')
  375. return
  376. }
  377. if (type === 1) {
  378. outSqare({
  379. spareId: val.id,
  380. outNum: val.num
  381. }).then(res => {
  382. this.$message.success('出库成功!')
  383. this.$refs.table.refresh()
  384. })
  385. return
  386. }
  387. inSqare({
  388. spareId: val.id,
  389. inNum: val.num
  390. }).then(res => {
  391. this.$message.success('入库成功!')
  392. this.$refs.table.refresh()
  393. })
  394. }
  395. }
  396. }
  397. </script>