OutStoreCount.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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="8" :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="8" :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="8" :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="8" :sm="24">
  92. <a-form-item label="仓库">
  93. <a-tree-select
  94. style="width: 100%"
  95. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  96. :treeData="storeTreeData"
  97. :treeNodeFilterProp="'name'"
  98. :showSearch="true"
  99. v-decorator="['storeId']"
  100. v-model="queryParam.storeId"
  101. placeholder="请选择"
  102. >
  103. </a-tree-select>
  104. </a-form-item>
  105. </a-col>
  106. <a-col :md="8" :sm="24">
  107. <a-form-item label="单据起始日期">
  108. <a-date-picker
  109. v-model="queryParam.searchStartTime"
  110. style="width: 100%"
  111. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  112. v-decorator="['searchStartTime']"/>
  113. </a-form-item>
  114. </a-col>
  115. <a-col :md="8" :sm="24">
  116. <a-form-item label="单据结束日期">
  117. <a-date-picker
  118. v-model="queryParam.searchEndTime"
  119. style="width: 100%"
  120. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  121. v-decorator="['searchEndTime']"/>
  122. </a-form-item>
  123. </a-col>
  124. <a-col :md="4 || 24" :sm="24">
  125. <span class="table-page-search-submitButtons">
  126. <a-button type="primary" @click="handleOk">查询</a-button>
  127. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  128. </span>
  129. </a-col>
  130. </a-row>
  131. </a-form>
  132. </div>
  133. <div class="table-operator">
  134. <a-button style="margin-left: 8px" v-if="$auth('store-out-store-details-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  135. </div>
  136. <s-table
  137. ref="table"
  138. size="default"
  139. rowKey="spareId"
  140. :columns="columns"
  141. :data="loadData"
  142. :scroll="{x: 1500, y: BaseTool.Constant.scrollY}"
  143. :alert="options.alert"
  144. :rowSelection="options.rowSelection"
  145. showPagination="auto"
  146. >
  147. </s-table>
  148. <base-form ref="baseModal" @ok="handleOk"/>
  149. <detail ref="detailModal"/>
  150. </a-card>
  151. </template>
  152. <script>
  153. import { STable, Ellipsis } from '@/components'
  154. import BaseForm from './modules/BaseForm'
  155. import { fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
  156. import Detail from './modules/Detail'
  157. import { fetchStoreTree } from '@/api/store/store'
  158. import { getOutStoreDetailPage, deleteOutStoreDetails, fetchOutStoreDetail, exportOutStoreDetail } from '@/api/report/outstoredetail'
  159. export default {
  160. name: 'OutStoreDetailList',
  161. components: {
  162. STable,
  163. Ellipsis,
  164. BaseForm,
  165. Detail
  166. },
  167. data () {
  168. return {
  169. storeTreeData: [],
  170. // 查询参数
  171. queryParam: {
  172. storeId: null,
  173. searchStartTime: null,
  174. searchEndTime: null
  175. },
  176. // 表头
  177. columns: [
  178. {
  179. title: '序号',
  180. width: '100px',
  181. checked: true,
  182. dataIndex: 'index',
  183. customRender: (text, record, index) => {
  184. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  185. }
  186. },
  187. {
  188. title: '备件编码',
  189. dataIndex: 'no',
  190. checked: true,
  191. width: '150px'
  192. },
  193. {
  194. title: '品牌',
  195. checked: true,
  196. width: '150px',
  197. dataIndex: 'brand'
  198. },
  199. {
  200. title: '备件名称',
  201. dataIndex: 'name',
  202. checked: true,
  203. width: '150px'
  204. },
  205. {
  206. title: '备件规格',
  207. checked: true,
  208. width: '150px',
  209. dataIndex: 'ggxh'
  210. },
  211. {
  212. title: '计量单位',
  213. checked: true,
  214. width: '150px',
  215. dataIndex: 'unit'
  216. },
  217. {
  218. title: '出库总数',
  219. checked: true,
  220. width: '150px',
  221. dataIndex: 'totalNum'
  222. },
  223. {
  224. title: '当前库存',
  225. dataIndex: 'currentStock',
  226. checked: true,
  227. width: '100px',
  228. scopedSlots: { customRender: 'status' }
  229. },
  230. {
  231. title: '最高库存',
  232. checked: true,
  233. width: '100px',
  234. dataIndex: 'maxStock'
  235. },
  236. {
  237. title: '最低库存',
  238. checked: true,
  239. width: '100px',
  240. dataIndex: 'minStock'
  241. },
  242. {
  243. title: '等级',
  244. checked: true,
  245. width: '150px',
  246. dataIndex: 'level',
  247. customRender: (text, record, index) => {
  248. return this.BaseTool.Object.getField(this.levelMap, text)
  249. }
  250. },
  251. {
  252. title: '备件类型',
  253. dataIndex: 'typeName',
  254. checked: true,
  255. width: '150px'
  256. },
  257. // {
  258. // title: '入库总价',
  259. // dataIndex: 'totalPrice',
  260. // checked: true,
  261. // width: '150px',
  262. // customRender: (text, record, index) => {
  263. // return this.BaseTool.Amount.formatter(text)
  264. // }
  265. // },
  266. {
  267. title: '备件价值',
  268. dataIndex: 'initialValue',
  269. checked: true,
  270. width: '150px',
  271. customRender: (text, record, index) => {
  272. return this.BaseTool.Amount.formatter(text)
  273. }
  274. },
  275. // {
  276. // checked: true,
  277. // width: '150px',
  278. // title: '总价',
  279. // dataIndex: 'totalPrice'
  280. // },
  281. {
  282. title: '生产商',
  283. checked: true,
  284. width: '150px',
  285. dataIndex: 'producerId',
  286. customRender: (text, record, index) => {
  287. return record.producerName
  288. }
  289. },
  290. {
  291. title: '用途',
  292. checked: true,
  293. width: '150px',
  294. dataIndex: 'yt',
  295. customRender: (text, record, index) => {
  296. return this.BaseTool.Object.getField(this.ytMap, text)
  297. }
  298. }
  299. ],
  300. // 下拉框map
  301. levelMap: {},
  302. specialMap: {},
  303. ytMap: {},
  304. unitMap: {},
  305. spareTypeTreeData: [],
  306. // 加载数据方法 必须为 Promise 对象
  307. loadData: parameter => {
  308. parameter = {
  309. ...parameter,
  310. ...this.queryParam,
  311. searchStartTime: this.queryParam.searchStartTime ? this.queryParam.searchStartTime.format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null,
  312. searchEndTime: this.queryParam.searchEndTime ? this.queryParam.searchEndTime.format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null,
  313. dataScope: {
  314. }
  315. }
  316. return getOutStoreDetailPage(parameter)
  317. .then(res => {
  318. return res.data
  319. })
  320. },
  321. selectedRowKeys: [],
  322. selectedRows: [],
  323. options: {
  324. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  325. rowSelection: {
  326. selectedRowKeys: this.selectedRowKeys,
  327. onChange: this.onSelectChange
  328. }
  329. },
  330. optionAlertShow: false
  331. }
  332. },
  333. created () {
  334. // 下拉框map
  335. this.tableOption()
  336. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  337. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  338. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  339. this.specialMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  340. fetchSpareTypeTree({}).then(res => {
  341. this.spareTypeTreeData = res.data
  342. })
  343. // 设置仓库选项
  344. this.setTree()
  345. },
  346. methods: {
  347. setTree () {
  348. fetchStoreTree().then(res => {
  349. this.storeTreeData = res.data
  350. })
  351. },
  352. tableOption () {
  353. if (!this.optionAlertShow) {
  354. this.options = {
  355. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  356. rowSelection: {
  357. selectedRowKeys: this.selectedRowKeys,
  358. onChange: this.onSelectChange,
  359. getCheckboxProps: record => ({
  360. props: {
  361. disabled: false,
  362. name: record.id
  363. }
  364. })
  365. }
  366. }
  367. this.optionAlertShow = true
  368. } else {
  369. this.options = {
  370. alert: false,
  371. rowSelection: null
  372. }
  373. this.optionAlertShow = false
  374. }
  375. },
  376. batchDelete (id) {
  377. let ids = []
  378. if (this.BaseTool.String.isBlank(id)) {
  379. const length = this.selectedRows.length
  380. if (length === 0) {
  381. this.$message.info('请选择要删除的记录')
  382. return
  383. }
  384. ids = this.selectedRows.map(item => item.id)
  385. } else {
  386. ids = [id]
  387. }
  388. deleteOutStoreDetails(ids).then(res => {
  389. this.$message.info('删除成功')
  390. this.handleOk()
  391. this.$refs.table.clearSelected()
  392. })
  393. },
  394. handleEdit (record) {
  395. fetchOutStoreDetail({ id: record.id }).then(res => {
  396. const modal = this.$refs.baseModal
  397. modal.base(res.data)
  398. })
  399. },
  400. handleView (record) {
  401. fetchOutStoreDetail({ 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. exportOutStoreDetail(parameter).then(file => {
  423. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  424. })
  425. }
  426. }
  427. }
  428. </script>