InStoreCount.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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="6" :sm="24">
  7. <a-form-item label="仓库">
  8. <a-tree-select
  9. style="width: 100%"
  10. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  11. :treeData="storeTreeData"
  12. :treeNodeFilterProp="'name'"
  13. :showSearch="true"
  14. v-decorator="['storeId']"
  15. v-model="queryParam.storeId"
  16. placeholder="请选择"
  17. >
  18. </a-tree-select>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-item label="单据起始日期">
  23. <a-date-picker
  24. v-model="queryParam.searchStartTime"
  25. style="width: 100%"
  26. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  27. v-decorator="['searchStartTime']"/>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="单据结束日期">
  32. <a-date-picker
  33. v-model="queryParam.searchEndTime"
  34. style="width: 100%"
  35. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  36. v-decorator="['searchEndTime']"/>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="4 || 24" :sm="24">
  40. <span class="table-page-search-submitButtons">
  41. <a-button type="primary" @click="handleOk">查询</a-button>
  42. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  43. </span>
  44. </a-col>
  45. </a-row>
  46. </a-form>
  47. </div>
  48. <div class="table-operator">
  49. <a-button style="margin-left: 8px" v-if="$auth('store-in-store-details-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  50. </div>
  51. <s-table
  52. ref="table"
  53. size="default"
  54. rowKey="spareId"
  55. :columns="columns"
  56. :data="loadData"
  57. :alert="options.alert"
  58. :rowSelection="options.rowSelection"
  59. showPagination="auto"
  60. >
  61. </s-table>
  62. <base-form ref="baseModal" @ok="handleOk"/>
  63. <detail ref="detailModal"/>
  64. </a-card>
  65. </template>
  66. <script>
  67. import { STable, Ellipsis } from '@/components'
  68. import BaseForm from './modules/BaseForm'
  69. import Detail from './modules/Detail'
  70. import { fetchStoreTree } from '@/api/store/store'
  71. import { getInStoreDetailPage, deleteInStoreDetails, fetchInStoreDetail, exportInStoreDetail } from '@/api/report/instoredetail'
  72. export default {
  73. name: 'InStoreDetailList',
  74. components: {
  75. STable,
  76. Ellipsis,
  77. BaseForm,
  78. Detail
  79. },
  80. data () {
  81. return {
  82. storeTreeData: [],
  83. // 查询参数
  84. queryParam: {
  85. storeId: null,
  86. searchStartTime: null,
  87. searchEndTime: null
  88. },
  89. // 表头
  90. columns: [
  91. {
  92. title: '序号',
  93. dataIndex: 'index',
  94. customRender: (text, record, index) => {
  95. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  96. }
  97. },
  98. {
  99. title: '备件规格',
  100. dataIndex: 'ggxh'
  101. },
  102. {
  103. title: '原厂编号',
  104. dataIndex: 'initNo'
  105. },
  106. {
  107. title: '备件',
  108. dataIndex: 'spareId',
  109. customRender: (text, record, index) => {
  110. return record.spareName
  111. }
  112. },
  113. {
  114. title: '备件类型',
  115. dataIndex: 'typeName'
  116. },
  117. {
  118. title: '入库总数',
  119. dataIndex: 'totalNum'
  120. },
  121. {
  122. title: '入库总价',
  123. dataIndex: 'totalPrice',
  124. customRender: (text, record, index) => {
  125. return this.BaseTool.Amount.formatter(text)
  126. }
  127. }
  128. ],
  129. // 下拉框map
  130. // 加载数据方法 必须为 Promise 对象
  131. loadData: parameter => {
  132. parameter = {
  133. ...parameter,
  134. ...this.queryParam,
  135. searchStartTime: this.queryParam.searchStartTime ? this.queryParam.searchStartTime.format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null,
  136. searchEndTime: this.queryParam.searchEndTime ? this.queryParam.searchEndTime.format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null,
  137. dataScope: {
  138. }
  139. }
  140. return getInStoreDetailPage(parameter)
  141. .then(res => {
  142. return res.data
  143. })
  144. },
  145. selectedRowKeys: [],
  146. selectedRows: [],
  147. options: {
  148. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  149. rowSelection: {
  150. selectedRowKeys: this.selectedRowKeys,
  151. onChange: this.onSelectChange
  152. }
  153. },
  154. optionAlertShow: false
  155. }
  156. },
  157. created () {
  158. // 下拉框map
  159. this.tableOption()
  160. // 设置仓库选项
  161. this.setTree()
  162. },
  163. methods: {
  164. setTree () {
  165. fetchStoreTree().then(res => {
  166. this.storeTreeData = res.data
  167. })
  168. },
  169. tableOption () {
  170. if (!this.optionAlertShow) {
  171. this.options = {
  172. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  173. rowSelection: {
  174. selectedRowKeys: this.selectedRowKeys,
  175. onChange: this.onSelectChange,
  176. getCheckboxProps: record => ({
  177. props: {
  178. disabled: false,
  179. name: record.id
  180. }
  181. })
  182. }
  183. }
  184. this.optionAlertShow = true
  185. } else {
  186. this.options = {
  187. alert: false,
  188. rowSelection: null
  189. }
  190. this.optionAlertShow = false
  191. }
  192. },
  193. batchDelete (id) {
  194. let ids = []
  195. if (this.BaseTool.String.isBlank(id)) {
  196. const length = this.selectedRows.length
  197. if (length === 0) {
  198. this.$message.info('请选择要删除的记录')
  199. return
  200. }
  201. ids = this.selectedRows.map(item => item.id)
  202. } else {
  203. ids = [id]
  204. }
  205. deleteInStoreDetails(ids).then(res => {
  206. this.$message.info('删除成功')
  207. this.handleOk()
  208. this.$refs.table.clearSelected()
  209. })
  210. },
  211. handleEdit (record) {
  212. fetchInStoreDetail({ id: record.id }).then(res => {
  213. const modal = this.$refs.baseModal
  214. modal.base(res.data)
  215. })
  216. },
  217. handleView (record) {
  218. fetchInStoreDetail({ id: record.id }).then(res => {
  219. const modal = this.$refs.detailModal
  220. modal.base(res.data)
  221. })
  222. },
  223. handleOk () {
  224. this.$refs.table.refresh()
  225. },
  226. onSelectChange (selectedRowKeys, selectedRows) {
  227. this.selectedRowKeys = selectedRowKeys
  228. this.selectedRows = selectedRows
  229. },
  230. resetSearchForm () {
  231. this.queryParam = {
  232. }
  233. this.$refs.table.refresh(true)
  234. },
  235. doExport () {
  236. const parameter = {
  237. ...this.queryParam
  238. }
  239. exportInStoreDetail(parameter).then(file => {
  240. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  241. })
  242. }
  243. }
  244. }
  245. </script>