OutStoreDetail.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8 || 24" :sm="24">
  12. <span class="table-page-search-submitButtons">
  13. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  14. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  15. </span>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <div class="table-operator" style="margin-bottom: 8px;">
  21. <a-button v-if="$auth('store-out-store-details-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  22. <a-button style="margin-left: 8px" v-if="$auth('store-out-store-details-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('store-out-store-details-del')">
  24. <a-menu slot="overlay">
  25. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  26. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  27. </a-popconfirm>
  28. </a-menu>
  29. <a-button style="margin-left: 8px">
  30. 批量操作 <a-icon type="down" />
  31. </a-button>
  32. </a-dropdown>
  33. </div>
  34. <s-table
  35. ref="table"
  36. size="default"
  37. rowKey="id"
  38. :columns="columns"
  39. :data="loadData"
  40. :alert="options.alert"
  41. :rowSelection="options.rowSelection"
  42. showPagination="auto"
  43. >
  44. <span slot="action" slot-scope="record">
  45. <template>
  46. <a @click="handleView(record)">查看</a>
  47. <a-divider type="vertical" />
  48. <a v-if="$auth('store-out-store-details-edit')" @click="handleEdit(record)">修改</a>
  49. <a-divider type="vertical" />
  50. <a-popconfirm v-if="$auth('store-out-store-details-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  51. <a>删除</a>
  52. </a-popconfirm>
  53. </template>
  54. </span>
  55. </s-table>
  56. <base-form ref="baseModal" @ok="handleOk"/>
  57. <detail ref="detailModal"/>
  58. </a-card>
  59. </template>
  60. <script>
  61. import { STable, Ellipsis } from '@/components'
  62. import BaseForm from './modules/BaseForm'
  63. import Detail from './modules/Detail'
  64. import { getOutStoreDetailPage, deleteOutStoreDetails, fetchOutStoreDetail, exportOutStoreDetail } from '@/api/store/outstoredetail'
  65. export default {
  66. name: 'OutStoreDetailList',
  67. components: {
  68. STable,
  69. Ellipsis,
  70. BaseForm,
  71. Detail
  72. },
  73. data () {
  74. return {
  75. // 查询参数
  76. queryParam: {
  77. },
  78. // 表头
  79. columns: [
  80. {
  81. title: '序号',
  82. dataIndex: 'index',
  83. customRender: (text, record, index) => {
  84. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  85. }
  86. },
  87. {
  88. title: '出库单号',
  89. dataIndex: 'outNo'
  90. },
  91. {
  92. title: '出库仓库',
  93. dataIndex: 'storeId',
  94. customRender: (text, record, index) => {
  95. return record.storeName
  96. }
  97. },
  98. /* {
  99. title: '备件编号',
  100. dataIndex: 'spareNo'
  101. }, */
  102. {
  103. title: '备件名称',
  104. dataIndex: 'spareId',
  105. customRender: (text, record, index) => {
  106. return record.spareName
  107. }
  108. },
  109. {
  110. title: '备件规格',
  111. dataIndex: 'ggxh'
  112. },
  113. {
  114. title: '原厂编号',
  115. dataIndex: 'initNo'
  116. },
  117. {
  118. title: '出库数量',
  119. dataIndex: 'num'
  120. },
  121. {
  122. title: '创建日期',
  123. dataIndex: 'createdTime'
  124. },
  125. {
  126. title: '操作',
  127. key: 'action',
  128. width: '200px',
  129. align: 'center',
  130. scopedSlots: { customRender: 'action' }
  131. }
  132. ],
  133. // 下拉框map
  134. // 加载数据方法 必须为 Promise 对象
  135. loadData: parameter => {
  136. parameter = {
  137. ...parameter,
  138. ...this.queryParam,
  139. dataScope: {
  140. sortBy: 'desc',
  141. sortName: 'created_time'
  142. }
  143. }
  144. return getOutStoreDetailPage(Object.assign(parameter, this.queryParam))
  145. .then(res => {
  146. return res.data
  147. })
  148. },
  149. selectedRowKeys: [],
  150. selectedRows: [],
  151. options: {
  152. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  153. rowSelection: {
  154. selectedRowKeys: this.selectedRowKeys,
  155. onChange: this.onSelectChange
  156. }
  157. },
  158. optionAlertShow: false
  159. }
  160. },
  161. created () {
  162. // 下拉框map
  163. this.tableOption()
  164. },
  165. methods: {
  166. tableOption () {
  167. if (!this.optionAlertShow) {
  168. this.options = {
  169. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  170. rowSelection: {
  171. selectedRowKeys: this.selectedRowKeys,
  172. onChange: this.onSelectChange,
  173. getCheckboxProps: record => ({
  174. props: {
  175. disabled: false,
  176. name: record.id
  177. }
  178. })
  179. }
  180. }
  181. this.optionAlertShow = true
  182. } else {
  183. this.options = {
  184. alert: false,
  185. rowSelection: null
  186. }
  187. this.optionAlertShow = false
  188. }
  189. },
  190. batchDelete (id) {
  191. let ids = []
  192. if (this.BaseTool.String.isBlank(id)) {
  193. const length = this.selectedRows.length
  194. if (length === 0) {
  195. this.$message.info('请选择要删除的记录')
  196. return
  197. }
  198. ids = this.selectedRows.map(item => item.id)
  199. } else {
  200. ids = [id]
  201. }
  202. deleteOutStoreDetails(ids).then(res => {
  203. this.$message.info('删除成功')
  204. this.handleOk()
  205. this.$refs.table.clearSelected()
  206. })
  207. },
  208. handleEdit (record) {
  209. fetchOutStoreDetail({ id: record.id }).then(res => {
  210. const modal = this.$refs.baseModal
  211. modal.base(res.data)
  212. })
  213. },
  214. handleView (record) {
  215. fetchOutStoreDetail({ id: record.id }).then(res => {
  216. const modal = this.$refs.detailModal
  217. modal.base(res.data)
  218. })
  219. },
  220. handleOk () {
  221. this.$refs.table.refresh()
  222. },
  223. onSelectChange (selectedRowKeys, selectedRows) {
  224. this.selectedRowKeys = selectedRowKeys
  225. this.selectedRows = selectedRows
  226. },
  227. resetSearchForm () {
  228. this.queryParam = {
  229. }
  230. this.$refs.table.refresh(true)
  231. },
  232. doExport () {
  233. const parameter = {
  234. ...this.queryParam
  235. }
  236. exportOutStoreDetail(parameter).then(file => {
  237. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  238. })
  239. }
  240. }
  241. }
  242. </script>