InStoreDetail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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_DATETIME_PATTERN"
  27. />
  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_DATETIME_PATTERN"
  36. />
  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="id"
  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/store/instoredetail'
  72. export default {
  73. name: 'InStoreDetailList',
  74. components: {
  75. STable,
  76. Ellipsis,
  77. BaseForm,
  78. Detail
  79. },
  80. props: {
  81. filter: {
  82. type: Number,
  83. default: -1
  84. }
  85. },
  86. data () {
  87. return {
  88. storeTreeData: [],
  89. // 查询参数
  90. queryParam: {
  91. storeId: null,
  92. searchStartTime: null,
  93. searchEndTime: null,
  94. filter: this.filter
  95. },
  96. // 表头
  97. columns: [
  98. {
  99. title: '序号',
  100. dataIndex: 'index',
  101. customRender: (text, record, index) => {
  102. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  103. }
  104. },
  105. {
  106. title: '入库单号',
  107. dataIndex: 'inNo'
  108. },
  109. {
  110. title: '备件规格',
  111. dataIndex: 'ggxh'
  112. },
  113. {
  114. title: '原厂编号',
  115. dataIndex: 'initNo'
  116. },
  117. {
  118. title: '备件名称',
  119. dataIndex: 'spareId',
  120. customRender: (text, record, index) => {
  121. return record.spareName
  122. }
  123. },
  124. {
  125. title: '入库数量',
  126. dataIndex: 'num'
  127. },
  128. {
  129. title: '入库单价',
  130. dataIndex: 'price',
  131. customRender: (text, record, index) => {
  132. return this.BaseTool.Amount.formatter(text)
  133. }
  134. },
  135. {
  136. title: '入库总价',
  137. dataIndex: 'totalPrice',
  138. customRender: (text, record, index) => {
  139. return this.BaseTool.Amount.formatter(text)
  140. }
  141. },
  142. {
  143. title: '入库日期',
  144. dataIndex: 'createdTime'
  145. },
  146. {
  147. title: '入库仓库',
  148. dataIndex: 'storeId',
  149. customRender: (text, record, index) => {
  150. return record.storeName
  151. }
  152. }
  153. ],
  154. // 下拉框map
  155. // 加载数据方法 必须为 Promise 对象
  156. loadData: parameter => {
  157. parameter = {
  158. ...parameter,
  159. ...this.queryParam,
  160. dataScope: {
  161. sortBy: 'desc',
  162. sortName: 'created_time'
  163. }
  164. }
  165. return getInStoreDetailPage(parameter)
  166. .then(res => {
  167. return res.data
  168. })
  169. },
  170. selectedRowKeys: [],
  171. selectedRows: [],
  172. options: {
  173. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  174. rowSelection: {
  175. selectedRowKeys: this.selectedRowKeys,
  176. onChange: this.onSelectChange
  177. }
  178. },
  179. optionAlertShow: false
  180. }
  181. },
  182. created () {
  183. // 下拉框map
  184. this.tableOption()
  185. // 设置仓库选项
  186. this.setTree()
  187. },
  188. methods: {
  189. tableOption () {
  190. if (!this.optionAlertShow) {
  191. this.options = {
  192. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  193. rowSelection: {
  194. selectedRowKeys: this.selectedRowKeys,
  195. onChange: this.onSelectChange,
  196. getCheckboxProps: record => ({
  197. props: {
  198. disabled: true,
  199. name: record.id
  200. }
  201. })
  202. }
  203. }
  204. this.optionAlertShow = true
  205. } else {
  206. this.options = {
  207. alert: false,
  208. rowSelection: null
  209. }
  210. this.optionAlertShow = false
  211. }
  212. },
  213. setTree () {
  214. fetchStoreTree().then(res => {
  215. this.storeTreeData = res.data
  216. })
  217. },
  218. batchDelete (id) {
  219. let ids = []
  220. if (this.BaseTool.String.isBlank(id)) {
  221. const length = this.selectedRows.length
  222. if (length === 0) {
  223. this.$message.info('请选择要删除的记录')
  224. return
  225. }
  226. ids = this.selectedRows.map(item => item.id)
  227. } else {
  228. ids = [id]
  229. }
  230. deleteInStoreDetails(ids).then(res => {
  231. this.$message.info('删除成功')
  232. this.handleOk()
  233. this.$refs.table.clearSelected()
  234. })
  235. },
  236. handleEdit (record) {
  237. fetchInStoreDetail({ id: record.id }).then(res => {
  238. const modal = this.$refs.baseModal
  239. modal.base(res.data)
  240. })
  241. },
  242. handleView (record) {
  243. fetchInStoreDetail({ id: record.id }).then(res => {
  244. const modal = this.$refs.detailModal
  245. modal.base(res.data)
  246. })
  247. },
  248. handleOk () {
  249. this.queryParam.searchStartTime = this.queryParam.searchStartTime ? this.queryParam.searchStartTime.format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  250. this.queryParam.searchEndTime = this.queryParam.searchEndTime ? this.queryParam.searchEndTime.format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  251. this.$refs.table.refresh()
  252. },
  253. onSelectChange (selectedRowKeys, selectedRows) {
  254. this.selectedRowKeys = selectedRowKeys
  255. this.selectedRows = selectedRows
  256. },
  257. resetSearchForm () {
  258. this.queryParam = {
  259. }
  260. this.$refs.table.refresh(true)
  261. },
  262. doExport () {
  263. const parameter = {
  264. ...this.queryParam,
  265. }
  266. exportInStoreDetail(parameter).then(file => {
  267. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  268. })
  269. }
  270. }
  271. }
  272. </script>