PurchaseReimbursePage.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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">
  7. <a-col :md="8" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="8 || 24" :sm="24">
  13. <span class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <div class="table-operator" style="margin-bottom: 8px;">
  22. <a-button v-if="$auth('purchase-purchase-reimburses-add')" type="primary" icon="plus" @click="handleAdd">新增</a-button>
  23. <!-- <a-button style="margin-left: 8px" v-if="$auth('purchase-purchase-payments-export')" type="primary" icon="download" @click="doExport">导出</a-button>-->
  24. </div>
  25. <s-table
  26. ref="table"
  27. size="small"
  28. rowKey="id"
  29. :columns="columns"
  30. :data="loadData"
  31. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  32. showPagination="auto"
  33. >
  34. <span slot="action" slot-scope="record">
  35. <template>
  36. <a @click="handleView(record)">查看</a>
  37. <operation-button
  38. v-if="$auth('purchase-purchase-reimburses-edit') && user.userId === record.executorId && record.status === 0"
  39. @click="handleEdit(record)"
  40. >修改</operation-button>
  41. <operation-button
  42. v-if="$auth('purchase-purchase-reimburses-edit') && user.userId === record.executorId && record.status === 0"
  43. :type="2"
  44. title="提交后将无法再修改,确定提交数据?"
  45. @confirm="handleSubmit(record.id)">提交</operation-button>
  46. <!-- <operation-button-->
  47. <!-- @click="handlePrint(record)"-->
  48. <!-- v-if="user.userId === record.executorId"-->
  49. <!-- >打印</operation-button>-->
  50. <operation-button
  51. v-if="$auth('purchase-purchase-reimburses-del') && user.userId === record.executorId && record.status === 0"
  52. :type="2"
  53. title="是否要删除该条数据?"
  54. @confirm="batchDelete(record.id)">删除</operation-button>
  55. </template>
  56. </span>
  57. </s-table>
  58. </div>
  59. <base-form ref="baseModal" @ok="handleOk"/>
  60. <print-form ref="basePrintModal" @ok="handleOk"/>
  61. <detail ref="detailModal"/>
  62. </a-card>
  63. </template>
  64. <script>
  65. import { STable, Ellipsis } from '@/components'
  66. import BaseForm from './modules/BaseForm'
  67. import PrintForm from './modules/PrintForm'
  68. import Detail from './modules/Detail'
  69. import { getPurchaseReimbursePage, deletePurchaseReimburses, fetchPurchaseReimburse, exportPurchaseReimburse, submitPurchaseReimburse } from '@/api/purchase/purchase-reimburse'
  70. import DetailList from '@/components/tools/DetailList'
  71. const DetailListItem = DetailList.Item
  72. export default {
  73. name: 'PurchaseReimburseList',
  74. components: {
  75. STable,
  76. Ellipsis,
  77. BaseForm,
  78. PrintForm,
  79. DetailList,
  80. DetailListItem,
  81. Detail
  82. },
  83. data () {
  84. return {
  85. // 查询参数
  86. queryParam: {
  87. },
  88. record: {},
  89. visible: true,
  90. user: this.$store.getters.userInfo,
  91. isCreated: false,
  92. // 表头
  93. columns: [
  94. {
  95. title: '序号',
  96. dataIndex: 'index',
  97. checked: true,
  98. width: 70,
  99. customRender: (text, record, index) => {
  100. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  101. }
  102. },
  103. {
  104. title: '报销时间',
  105. dataIndex: 'payTime',
  106. checked: true,
  107. width: 120
  108. },
  109. {
  110. title: '经办人名称',
  111. dataIndex: 'executorName',
  112. checked: true,
  113. width: 120
  114. },
  115. {
  116. title: '报销金额',
  117. dataIndex: 'money',
  118. checked: true,
  119. width: 100,
  120. customRender: (text, record, index) => {
  121. return this.BaseTool.Amount.formatter(text)
  122. }
  123. },
  124. {
  125. title: '币种',
  126. dataIndex: 'moneyType',
  127. checked: true,
  128. width: 100,
  129. customRender: (text, record, index) => {
  130. return this.BaseTool.Table.getMapText(this.moneyTypeMap, text)
  131. }
  132. },
  133. {
  134. title: '发票号码',
  135. dataIndex: 'invoiceNo',
  136. checked: true,
  137. width: 180
  138. },
  139. {
  140. title: '备注',
  141. dataIndex: 'remark',
  142. checked: true,
  143. width: 120
  144. },
  145. {
  146. title: '创建人名称',
  147. dataIndex: 'createdUserName',
  148. width: 120
  149. },
  150. {
  151. title: '创建时间',
  152. dataIndex: 'createdTime',
  153. checked: true,
  154. width: 120
  155. },
  156. {
  157. title: '操作',
  158. key: 'action',
  159. width: '200px',
  160. checked: true,
  161. fixed: 'right',
  162. align: 'center',
  163. scopedSlots: { customRender: 'action' }
  164. }
  165. ],
  166. // 下拉框map
  167. itemMap: {},
  168. moneyTypeMap: {},
  169. // 加载数据方法 必须为 Promise 对象
  170. loadData: parameter => {
  171. parameter = {
  172. ...parameter,
  173. ...this.queryParam,
  174. dataScope: {
  175. sortBy: 'desc',
  176. sortName: 'update_time'
  177. }
  178. }
  179. return getPurchaseReimbursePage(Object.assign(parameter, this.queryParam))
  180. .then(res => {
  181. return res.data
  182. })
  183. },
  184. selectedRowKeys: [],
  185. selectedRows: [],
  186. options: {
  187. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  188. rowSelection: {
  189. selectedRowKeys: this.selectedRowKeys,
  190. onChange: this.onSelectChange
  191. }
  192. },
  193. optionAlertShow: false
  194. }
  195. },
  196. created () {
  197. // 下拉框map
  198. this.itemMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REIMBURSE_ITEM)
  199. this.moneyTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.MONEY_TYPE)
  200. this.tableOption()
  201. },
  202. methods: {
  203. tableOption () {
  204. if (!this.optionAlertShow) {
  205. this.options = {
  206. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  207. rowSelection: {
  208. selectedRowKeys: this.selectedRowKeys,
  209. onChange: this.onSelectChange,
  210. getCheckboxProps: record => ({
  211. props: {
  212. disabled: false,
  213. name: record.id
  214. }
  215. })
  216. }
  217. }
  218. this.optionAlertShow = true
  219. } else {
  220. this.options = {
  221. alert: false,
  222. rowSelection: null
  223. }
  224. this.optionAlertShow = false
  225. }
  226. },
  227. handlePrint (record) {
  228. const modal = this.$refs.basePrintModal
  229. this.visible = false
  230. modal.base(record)
  231. },
  232. batchDelete (id) {
  233. let ids = []
  234. if (this.BaseTool.String.isBlank(id)) {
  235. const length = this.selectedRows.length
  236. if (length === 0) {
  237. this.$message.info('请选择要删除的记录')
  238. return
  239. }
  240. ids = this.selectedRows.map(item => item.id)
  241. } else {
  242. ids = [id]
  243. }
  244. deletePurchaseReimburses(ids).then(res => {
  245. this.$message.info('删除成功')
  246. this.handleOk()
  247. this.$refs.table.clearSelected()
  248. })
  249. },
  250. handleSubmit (id) {
  251. submitPurchaseReimburse(id).then(res => {
  252. this.$message.info('提交成功')
  253. this.handleOk()
  254. this.$refs.table.clearSelected()
  255. })
  256. },
  257. handleEdit (record) {
  258. fetchPurchaseReimburse({ id: record.id }).then(res => {
  259. const modal = this.$refs.baseModal
  260. this.visible = false
  261. modal.base(res.data)
  262. })
  263. },
  264. handleAdd () {
  265. this.visible = false
  266. this.$refs.baseModal.base()
  267. },
  268. handleView (record) {
  269. fetchPurchaseReimburse({ id: record.id }).then(res => {
  270. const modal = this.$refs.detailModal
  271. modal.base(res.data)
  272. })
  273. },
  274. handleOk () {
  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. purchaseOrderId: this.purchaseOrderId
  285. }
  286. this.$refs.table.refresh(true)
  287. },
  288. doExport () {
  289. const parameter = {
  290. ...this.queryParam
  291. }
  292. exportPurchaseReimburse(parameter).then(file => {
  293. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  294. })
  295. },
  296. handleEnter () {
  297. this.$refs.table.refresh(true)
  298. },
  299. handleCancel (values) {
  300. this.visible = false
  301. this.$emit('ok', values)
  302. }
  303. }
  304. }
  305. </script>