PurchaseStoreForm.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <a-card :bordered='false'>
  3. <div v-show='visible'>
  4. <div class='table-page-search-wrapper' @keyup.enter='handleEnter'>
  5. <a-form layout='inline'>
  6. <a-row :gutter='48' v-show='advanced'>
  7. <a-col :md='6' :sm='24'>
  8. <a-form-item label='关键字'>
  9. <a-input v-model='queryParam.keyword' placeholder='请输入名称/类型名称' />
  10. </a-form-item>
  11. </a-col>
  12. </a-row>
  13. <a-row :gutter='48'>
  14. <a-col :md='24 || 24' :sm='24' style='text-align: right'>
  15. <span class='table-page-search-submitButtons'>
  16. <a-button type='primary' @click='$refs.table.refresh(true)'>查询</a-button>
  17. <a-button style='margin-left: 8px' @click='resetSearchForm'>重置</a-button>
  18. <a @click='()=>{ this.advanced = !this.advanced}' style='margin-left: 8px'>
  19. {{ advanced ? '收起' : '展开' }}
  20. <a-icon :type="advanced ? 'up' : 'down'" />
  21. </a>
  22. </span>
  23. </a-col>
  24. </a-row>
  25. </a-form>
  26. </div>
  27. <div class='table-operator' style='margin-bottom: 8px;'>
  28. <a-row>
  29. <a-col :md='16'>
  30. <a-button v-if="$auth('purchase-store-forms-add')" type='primary' icon='plus' @click='handleAdd()'>新增</a-button>
  31. <a-button style='margin-left: 8px' v-if="$auth('purchase-store-forms-export')" type='primary' icon='download'
  32. @click='doExport'>导出
  33. </a-button>
  34. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-store-forms-del')">
  35. <a-menu slot='overlay'>
  36. <a-popconfirm title='是否要删除所选数据?' @confirm='batchDelete()'>
  37. <a-menu-item key='1'>
  38. <a-icon type='delete' />
  39. <a>删除</a></a-menu-item>
  40. </a-popconfirm>
  41. </a-menu>
  42. <a-button style='margin-left: 8px'>
  43. 批量操作
  44. <a-icon type='down' />
  45. </a-button>
  46. </a-dropdown>
  47. </a-col>
  48. </a-row>
  49. </div>
  50. <s-table
  51. ref='table'
  52. size='default'
  53. rowKey='id'
  54. :columns='columns'
  55. :data='loadData'
  56. :alert='options.alert'
  57. :rowSelection='options.rowSelection'
  58. showPagination='auto'
  59. >
  60. <span slot='action' slot-scope='record'>
  61. <template>
  62. <a @click='handleView(record)'>查看修改</a>
  63. <!-- <operation-button
  64. v-if="$auth('purchase-store-forms-edit')" @click='handleEdit(record)'
  65. >修改</operation-button>-->
  66. <operation-button v-if="$auth('purchase-store-forms-edit') && record.status == 1" @click='handleInStoreApply(record)'
  67. >提交入库</operation-button>
  68. <!-- <operation-button
  69. v-if="$auth('store-stores-del')"
  70. :type='2'
  71. title='是否要删除该条数据?'
  72. @confirm='batchDelete(record.id)'>删除</operation-button>-->
  73. <operation-button
  74. v-if="$auth('purchase-store-forms-edit') && record.status == 0 "
  75. :type='2'
  76. title='是否要封存当前采购单?'
  77. @confirm='batchDelete(record.id)'>暂时封存</operation-button>
  78. <operation-button
  79. v-if="$auth('purchase-store-forms-edit') && record.status == 4 "
  80. :type='2'
  81. title='是否要解封当前采购单?'
  82. @confirm='batchDelete(record.id)'>解除封存</operation-button>
  83. </template>
  84. </span>
  85. <span slot="status" slot-scope="text">
  86. <badge
  87. :status="DictCache.COLOR.PURCHASE_FORM_STATUS[text]"
  88. :text="statusMap[text]" />
  89. </span>
  90. </s-table>
  91. </div>
  92. <base-form ref='baseModal' @ok='handleOk' />
  93. <detail ref='detailModal' @ok='handleOk' />
  94. </a-card>
  95. </template>
  96. <script>
  97. import { STable, Ellipsis } from '@/components'
  98. import BaseForm from './modules/BaseForm'
  99. import Detail from './modules/Detail'
  100. import {
  101. getPurchaseStoreFormPage,
  102. deletePurchaseStoreForms,
  103. fetchPurchaseStoreForm,
  104. exportPurchaseStoreForm,
  105. applyInStore
  106. } from '@/api/store/purchaseForm'
  107. export default {
  108. name: 'PurchaseStoreForm',
  109. components: {
  110. STable,
  111. Ellipsis,
  112. BaseForm,
  113. Detail
  114. },
  115. data() {
  116. return {
  117. advanced: false,
  118. visible: true,
  119. // 查询参数
  120. queryParam: {},
  121. // 表头
  122. columns: [
  123. {
  124. title: '序号',
  125. dataIndex: 'index',
  126. customRender: (text, record, index) => {
  127. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  128. }
  129. },
  130. {
  131. title: '名称',
  132. dataIndex: 'name'
  133. },
  134. {
  135. title: '仓库名称',
  136. dataIndex: 'spareStoreName'
  137. },
  138. {
  139. title: '采购人',
  140. dataIndex: 'createdUserName'
  141. },
  142. {
  143. title: '状态',
  144. dataIndex: 'status',
  145. scopedSlots: { customRender: 'status' }
  146. },
  147. {
  148. title: '采购总价值',
  149. dataIndex: 'totalAmount',
  150. customRender: (text, record, index) => {
  151. return this.BaseTool.Amount.formatter(text)
  152. }
  153. },
  154. {
  155. title: '采购总数',
  156. dataIndex: 'totalNum'
  157. },
  158. {
  159. title: '添加时间',
  160. dataIndex: 'createdTime'
  161. },
  162. {
  163. title: '操作',
  164. key: 'action',
  165. width: '250px',
  166. align: 'center',
  167. scopedSlots: { customRender: 'action' }
  168. }
  169. ],
  170. // 下拉框map
  171. statusMap: {},
  172. // 加载数据方法 必须为 Promise 对象
  173. loadData: parameter => {
  174. parameter = {
  175. ...parameter,
  176. ...this.queryParam,
  177. dataScope: {
  178. sortBy: 'desc',
  179. sortName: 'update_time'
  180. }
  181. }
  182. return getPurchaseStoreFormPage(Object.assign(parameter, this.queryParam))
  183. .then(res => {
  184. return res.data
  185. })
  186. },
  187. selectedRowKeys: [],
  188. selectedRows: [],
  189. options: {
  190. alert: {
  191. show: true, clear: () => {
  192. this.selectedRowKeys = []
  193. }
  194. },
  195. rowSelection: {
  196. selectedRowKeys: this.selectedRowKeys,
  197. onChange: this.onSelectChange
  198. }
  199. },
  200. optionAlertShow: false
  201. }
  202. },
  203. created () {
  204. // 下拉框map
  205. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_STORE_FORM_STATUS)
  206. this.tableOption()
  207. },
  208. methods: {
  209. tableOption () {
  210. if (!this.optionAlertShow) {
  211. this.options = {
  212. alert: {
  213. show: true, clear: () => {
  214. this.selectedRowKeys = []
  215. }
  216. },
  217. rowSelection: {
  218. selectedRowKeys: this.selectedRowKeys,
  219. onChange: this.onSelectChange,
  220. getCheckboxProps: record => ({
  221. props: {
  222. disabled: false,
  223. name: record.id
  224. }
  225. })
  226. }
  227. }
  228. this.optionAlertShow = true
  229. } else {
  230. this.options = {
  231. alert: false,
  232. rowSelection: null
  233. }
  234. this.optionAlertShow = false
  235. }
  236. },
  237. batchDelete (id) {
  238. let ids = []
  239. if (this.BaseTool.String.isBlank(id)) {
  240. const length = this.selectedRows.length
  241. if (length === 0) {
  242. this.$message.info('请选择要删除的记录')
  243. return
  244. }
  245. ids = this.selectedRows.map(item => item.id)
  246. } else {
  247. ids = [id]
  248. }
  249. deletePurchaseStoreForms(ids).then(res => {
  250. this.$message.info('删除成功')
  251. this.handleOk()
  252. this.$refs.table.clearSelected()
  253. })
  254. },
  255. handleAdd () {
  256. this.visible = false
  257. const modal = this.$refs.baseModal
  258. modal.base()
  259. },
  260. handleEdit (record) {
  261. this.visible = false
  262. fetchPurchaseStoreForm({ id: record.id }).then(res => {
  263. const modal = this.$refs.baseModal
  264. modal.base(res.data)
  265. })
  266. },
  267. handleView (record) {
  268. this.visible = false
  269. fetchPurchaseStoreForm({ id: record.id }).then(res => {
  270. const modal = this.$refs.detailModal
  271. modal.base(res.data)
  272. })
  273. },
  274. handleOk (values) {
  275. this.visible = true
  276. this.$refs.table.refresh()
  277. },
  278. onSelectChange (selectedRowKeys, selectedRows) {
  279. this.selectedRowKeys = selectedRowKeys
  280. this.selectedRows = selectedRows
  281. },
  282. resetSearchForm () {
  283. this.queryParam = {}
  284. this.$refs.table.refresh(true)
  285. },
  286. doExport () {
  287. const parameter = {
  288. ...this.queryParam
  289. }
  290. exportPurchaseStoreForm(parameter).then(file => {
  291. this.BaseTool.Util.downLoadExportExcel(file)
  292. })
  293. },
  294. handleEnter () {
  295. this.$refs.table.refresh(true)
  296. },
  297. handleInStoreApply (record) {
  298. const params = { id: record.id }
  299. applyInStore(params).then(res => {
  300. this.$message.info(res.message)
  301. this.handleOk()
  302. }).catch(err => {
  303. console.log(err)
  304. })
  305. }
  306. }
  307. }
  308. </script>