WaitPublish.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <a-card :bordered="false">
  3. <a-drawer title="筛选" placement="top" :closable="false" :visible="filterVisible" @close="filterVisible=false">
  4. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="5" :sm="24">
  8. <a-form-item label="标题">
  9. <a-input v-model.trim="queryParam.taskName" placeholder="请输入标题" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="5" :sm="24">
  13. <a-form-item label="状态">
  14. <a-select v-model="queryParam.taskStatus" placeholder="请选择状态">
  15. <template v-for="(label,value) in statusMap">
  16. <a-select-option v-if="value>2" :key="value" :value="parseInt(value)">{{label}}</a-select-option>
  17. </template>
  18. </a-select>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="7" :sm="24">
  22. <a-form-item label="任务创建时间">
  23. <a-range-picker style="width:100%" showTime :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN" v-model="createdTime" />
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="7" :sm="24">
  27. <a-form-item label="任务发起时间">
  28. <a-range-picker style="width:100%" PICKER_NORM_DATE_PATTERN :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN" v-model="applyTime" />
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md=" 24" :sm="24" style="text-align: right">
  32. <span class="table-page-search-submitButtons">
  33. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  34. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  35. </span>
  36. </a-col>
  37. </a-row>
  38. </a-form>
  39. </div>
  40. </a-drawer>
  41. <div v-show="visible">
  42. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  43. <a-form layout="inline">
  44. <a-row :gutter="48">
  45. <a-col :md="6" :sm="24">
  46. <a-form-item label="关键字">
  47. <a-input v-model.trim="queryParam.taskName" placeholder="请输入标题" />
  48. </a-form-item>
  49. </a-col>
  50. <a-col :md="6 || 24" :sm="24">
  51. <span class="table-page-search-submitButtons">
  52. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  53. <a-button type="primary" style="margin-left: 8px" @click="filterVisible=true">筛选</a-button>
  54. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  55. </span>
  56. </a-col>
  57. </a-row>
  58. </a-form>
  59. </div>
  60. <div class="table-operator" style="margin-bottom: 8px;">
  61. <a-row>
  62. <a-col :md="16">
  63. <!-- <a-button type="primary" icon="plus" @click="handleAdd()">新增</a-button> -->
  64. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0">
  65. <a-menu slot="overlay">
  66. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  67. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  68. </a-popconfirm>
  69. </a-menu>
  70. <a-button style="margin-left: 8px">
  71. 批量操作 <a-icon type="down" />
  72. </a-button>
  73. </a-dropdown>
  74. </a-col>
  75. </a-row>
  76. </div>
  77. <s-table ref="table" size="default" rowKey="id" :columns="columns" :data="loadData" :alert="options.alert" :rowSelection="options.rowSelection" showPagination="auto">
  78. <span slot="action" slot-scope="record">
  79. <template>
  80. <a @click="handleView(record)">查看</a>
  81. <operation-button @click="handleEdit(record)">修改</operation-button>
  82. <operation-button :type="2" title="确认发送" @confirm="handleSend(record.id)">发送</operation-button>
  83. </template>
  84. </span>
  85. </s-table>
  86. </div>
  87. </a-card>
  88. </template>
  89. <script>
  90. import { STable, Ellipsis } from '@/components'
  91. import { getWorplacePublishPage, sendWorkflow } from '@/api/workflow/publish'
  92. export default {
  93. name: 'WorkflowTaskList',
  94. components: {
  95. STable,
  96. Ellipsis,
  97. },
  98. props: {
  99. searchType: {
  100. type: [Number, null],
  101. default: 1,
  102. },
  103. personalType: {
  104. type: [Number, null],
  105. default: 1,
  106. },
  107. status: {
  108. type: [Number, null],
  109. default: null,
  110. },
  111. },
  112. data() {
  113. return {
  114. advanced: false,
  115. filterVisible: false,
  116. visible: true,
  117. // 查询参数
  118. queryParam: {},
  119. createdTime: [],
  120. applyTime: [],
  121. // 表头
  122. columns: [
  123. {
  124. title: '序号',
  125. dataIndex: 'index',
  126. customRender: (text, record, index) => {
  127. return `${
  128. (this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1
  129. }`
  130. },
  131. },
  132. {
  133. title: '标题',
  134. dataIndex: 'taskName',
  135. },
  136. {
  137. title: '创建时间',
  138. dataIndex: 'taskCreatedTime',
  139. },
  140. {
  141. title: '状态',
  142. dataIndex: 'taskStatus',
  143. customRender: (text, record, index) => {
  144. return this.statusMap[text]
  145. },
  146. },
  147. {
  148. title: '操作',
  149. key: 'action',
  150. width: '200px',
  151. align: 'center',
  152. scopedSlots: { customRender: 'action' },
  153. },
  154. ],
  155. // 下拉框map
  156. // 加载数据方法 必须为 Promise 对象
  157. loadData: (parameter) => {
  158. parameter = {
  159. searchType: this.searchType,
  160. personalType: this.personalType,
  161. status: this.status,
  162. ...parameter,
  163. ...this.queryParam,
  164. dataScope: {
  165. sortBy: 'desc',
  166. sortName: 'task.created_time',
  167. },
  168. }
  169. return getWorplacePublishPage(Object.assign(parameter, this.queryParam)).then((res) => {
  170. return res.data
  171. })
  172. },
  173. selectedRowKeys: [],
  174. selectedRows: [],
  175. options: {
  176. alert: {
  177. show: true,
  178. clear: () => {
  179. this.selectedRowKeys = []
  180. },
  181. },
  182. rowSelection: {
  183. selectedRowKeys: this.selectedRowKeys,
  184. onChange: this.onSelectChange,
  185. },
  186. },
  187. optionAlertShow: false,
  188. statusMap: {},
  189. }
  190. },
  191. watch: {
  192. createdTime(newVal) {
  193. ;[this.queryParam.taskCreatedTimeStart, this.queryParam.taskCreatedTimeEnd] = newVal.map((item) => {
  194. return this.BaseTool.Date.formatter(item, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  195. })
  196. },
  197. applyTime(newVal) {
  198. ;[this.queryParam.applyTimeStart, this.queryParam.applyTimeEnd] = newVal.map((item) => {
  199. return this.BaseTool.Date.formatter(item, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  200. })
  201. },
  202. },
  203. created() {
  204. // 下拉框map
  205. this.tableOption()
  206. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.FLOW_TASK_STATUS)
  207. },
  208. methods: {
  209. tableOption() {
  210. if (!this.optionAlertShow) {
  211. this.options = {
  212. alert: {
  213. show: true,
  214. clear: () => {
  215. this.selectedRowKeys = []
  216. },
  217. },
  218. rowSelection: {
  219. selectedRowKeys: this.selectedRowKeys,
  220. onChange: this.onSelectChange,
  221. getCheckboxProps: (record) => ({
  222. props: {
  223. disabled: false,
  224. name: record.id,
  225. },
  226. }),
  227. },
  228. }
  229. this.optionAlertShow = true
  230. } else {
  231. this.options = {
  232. alert: false,
  233. rowSelection: null,
  234. }
  235. this.optionAlertShow = false
  236. }
  237. },
  238. batchDelete(id) {
  239. let ids = []
  240. if (this.BaseTool.String.isBlank(id)) {
  241. const length = this.selectedRows.length
  242. if (length === 0) {
  243. this.$message.info('请选择要删除的记录')
  244. return
  245. }
  246. ids = this.selectedRows.map((item) => item.id)
  247. } else {
  248. ids = [id]
  249. }
  250. // deleteWorkflowTasks(ids).then((res) => {
  251. // this.$message.info('删除成功')
  252. // this.handleOk()
  253. // this.$refs.table.clearSelected()
  254. // })
  255. },
  256. handleAdd() {},
  257. handleEdit(record) {},
  258. handleView(record) {},
  259. handleSend(id) {
  260. sendWorkflow({ id }).then((res) => {
  261. this.$message.info('发送成功')
  262. this.$refs.table.refresh()
  263. })
  264. },
  265. handleOk(values) {
  266. this.visible = true
  267. this.$refs.table.refresh()
  268. },
  269. onSelectChange(selectedRowKeys, selectedRows) {
  270. this.selectedRowKeys = selectedRowKeys
  271. this.selectedRows = selectedRows
  272. },
  273. resetSearchForm() {
  274. this.queryParam = {}
  275. this.createdTime = []
  276. this.applyTime = []
  277. this.$refs.table.refresh(true)
  278. },
  279. handleEnter() {
  280. this.$refs.table.refresh(true)
  281. },
  282. },
  283. }
  284. </script>