SbAllocateTask.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  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('sb-allocate-tasks-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  22. <a-button style="margin-left: 8px" v-if="$auth('sb-allocate-tasks-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-allocate-tasks-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. :bordered="this.MyGlobalConstant.BORDERED"
  39. :columns="columns"
  40. :data="loadData"
  41. :alert="options.alert"
  42. :rowSelection="options.rowSelection"
  43. showPagination="auto"
  44. >
  45. <span slot="action" slot-scope="record">
  46. <template>
  47. <a @click="handleView(record)">查看</a>
  48. <operation-button
  49. v-if="$auth('sb-allocate-tasks-edit')"
  50. @click="handleEdit(record)"
  51. >修改</operation-button>
  52. <operation-button
  53. v-if="$auth('sb-allocate-tasks-del')"
  54. :type="2"
  55. title="是否要删除该条数据?"
  56. @confirm="batchDelete(record.id)">删除</operation-button>
  57. </template>
  58. </span>
  59. </s-table>
  60. <base-form ref="baseModal" @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 Detail from './modules/Detail'
  68. import { getSbAllocateTaskPage, deleteSbAllocateTasks, fetchSbAllocateTask, exportSbAllocateTask } from '@/api/sb/allocate-task'
  69. export default {
  70. name: 'SbAllocateTaskList',
  71. components: {
  72. STable,
  73. Ellipsis,
  74. BaseForm,
  75. Detail
  76. },
  77. data () {
  78. return {
  79. // 查询参数
  80. queryParam: {
  81. },
  82. // 表头
  83. columns: [
  84. {
  85. title: '序号',
  86. dataIndex: 'index',
  87. customRender: (text, record, index) => {
  88. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  89. }
  90. },
  91. {
  92. title: '标题',
  93. dataIndex: 'title'
  94. },
  95. {
  96. title: '调拨ID',
  97. dataIndex: 'allocateId'
  98. },
  99. {
  100. title: '审批人ID',
  101. dataIndex: 'userId'
  102. },
  103. {
  104. title: '审批人',
  105. dataIndex: 'userName'
  106. },
  107. {
  108. title: '状态:0.已申请,1.未处理,2.已通过,3.未通过',
  109. dataIndex: 'status',
  110. customRender: (text, record, index) => {
  111. return this.BaseTool.Table.getMapText(this.statusMap, text)
  112. }
  113. },
  114. {
  115. title: '说明',
  116. dataIndex: 'remark'
  117. },
  118. {
  119. title: '创建人名称',
  120. dataIndex: 'createdUserName'
  121. },
  122. {
  123. title: '创建日期',
  124. dataIndex: 'createdTime'
  125. },
  126. {
  127. title: '操作',
  128. key: 'action',
  129. width: '200px',
  130. align: 'center',
  131. scopedSlots: { customRender: 'action' }
  132. }
  133. ],
  134. // 下拉框map
  135. statusMap: {},
  136. // 加载数据方法 必须为 Promise 对象
  137. loadData: parameter => {
  138. parameter = {
  139. ...parameter,
  140. ...this.queryParam
  141. }
  142. return getSbAllocateTaskPage(parameter)
  143. .then(res => {
  144. return res.data
  145. })
  146. },
  147. selectedRowKeys: [],
  148. selectedRows: [],
  149. options: {
  150. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  151. rowSelection: {
  152. selectedRowKeys: this.selectedRowKeys,
  153. onChange: this.onSelectChange
  154. }
  155. },
  156. optionAlertShow: false
  157. }
  158. },
  159. created () {
  160. // 下拉框map
  161. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_ALLOCATE_TASK_STATUS)
  162. this.tableOption()
  163. },
  164. methods: {
  165. tableOption () {
  166. if (!this.optionAlertShow) {
  167. this.options = {
  168. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  169. rowSelection: {
  170. selectedRowKeys: this.selectedRowKeys,
  171. onChange: this.onSelectChange,
  172. getCheckboxProps: record => ({
  173. props: {
  174. disabled: false,
  175. name: record.id
  176. }
  177. })
  178. }
  179. }
  180. this.optionAlertShow = true
  181. } else {
  182. this.options = {
  183. alert: false,
  184. rowSelection: null
  185. }
  186. this.optionAlertShow = false
  187. }
  188. },
  189. batchDelete (id) {
  190. let ids = []
  191. if (this.BaseTool.String.isBlank(id)) {
  192. const length = this.selectedRows.length
  193. if (length === 0) {
  194. this.$message.info('请选择要删除的记录')
  195. return
  196. }
  197. ids = this.selectedRows.map(item => item.id)
  198. } else {
  199. ids = [id]
  200. }
  201. deleteSbAllocateTasks(ids).then(res => {
  202. this.$message.info('删除成功')
  203. this.handleOk()
  204. this.$refs.table.clearSelected()
  205. })
  206. },
  207. handleEdit (record) {
  208. fetchSbAllocateTask({ id: record.id }).then(res => {
  209. const modal = this.$refs.baseModal
  210. modal.base(res.data)
  211. })
  212. },
  213. handleView (record) {
  214. fetchSbAllocateTask({ id: record.id }).then(res => {
  215. const modal = this.$refs.detailModal
  216. modal.base(res.data)
  217. })
  218. },
  219. handleOk () {
  220. this.$refs.table.refresh()
  221. },
  222. onSelectChange (selectedRowKeys, selectedRows) {
  223. this.selectedRowKeys = selectedRowKeys
  224. this.selectedRows = selectedRows
  225. },
  226. resetSearchForm () {
  227. this.queryParam = {
  228. }
  229. this.$refs.table.refresh(true)
  230. },
  231. doExport () {
  232. const parameter = {
  233. ...this.queryParam
  234. }
  235. exportSbAllocateTask(parameter).then(file => {
  236. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  237. })
  238. },
  239. handleEnter () {
  240. this.$refs.table.refresh(true)
  241. }
  242. }
  243. }
  244. </script>