GwFlowList.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div class="page">
  3. <el-form
  4. :inline="true"
  5. v-if="searchVisible"
  6. class="query-form m-b-10"
  7. ref="searchForm"
  8. :model="searchForm"
  9. @keyup.enter="refreshList()"
  10. @submit.prevent
  11. >
  12. <!-- 搜索框-->
  13. <el-form-item>
  14. <el-button type="primary" @click="refreshList()" icon="search">查询</el-button>
  15. <el-button type="default" @click="resetSearch()" icon="refresh-right">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <div class="jp-table">
  19. <vxe-toolbar ref="gwFlowToolbar" :refresh="{query: refreshList}" import export print custom>
  20. <template #buttons>
  21. <el-button v-if="hasPermission('gwflow:gwFlow:add')" type="primary" icon="plus" @click="add()">新建</el-button>
  22. <el-button v-if="hasPermission('gwflow:gwFlow:edit')" type="warning" icon="edit-filled" @click="edit()" v-show="$refs.gwFlowTable && $refs.gwFlowTable.getCheckboxRecords().length === 1" plain>修改</el-button>
  23. <el-button v-if="hasPermission('gwflow:gwFlow:del')" type="danger" icon="del-filled" @click="del()" v-show="$refs.gwFlowTable && $refs.gwFlowTable.getCheckboxRecords().length > 0" plain>删除</el-button>
  24. </template>
  25. <template #tools>
  26. <vxe-button
  27. type="text"
  28. :title="
  29. searchVisible ? '收起检索' : '展开检索'
  30. "
  31. icon="vxe-icon-search"
  32. class="tool-btn"
  33. @click="searchVisible = !searchVisible"
  34. ></vxe-button>
  35. <vxe-button
  36. type="text"
  37. title="下载导入模板"
  38. v-if="hasPermission('gwflow:gwFlow:import')"
  39. icon="iconfont icon-xiazaimoban1"
  40. class="tool-btn m-l-0"
  41. @click="downloadTpl()"
  42. >
  43. </vxe-button>
  44. </template>
  45. </vxe-toolbar>
  46. <div class="jp-table-body">
  47. <vxe-table
  48. border="inner"
  49. auto-resize
  50. resizable
  51. height="auto"
  52. :loading="loading"
  53. size="small"
  54. ref="gwFlowTable"
  55. show-header-overflow
  56. show-overflow
  57. highlight-hover-row
  58. :menu-config="{}"
  59. :print-config="{}"
  60. :import-config="{
  61. importMethod: importMethod,
  62. types: ['csv', 'xls', 'xlsx'],
  63. remote: true,
  64. }"
  65. :export-config="{
  66. remote: true,
  67. filename: `公文流程数据${moment(new Date()).format(
  68. 'YYYY-MM-DD'
  69. )}`,
  70. sheetName: '公文流程数据',
  71. exportMethod: exportMethod,
  72. types: ['xlsx'],
  73. modes: ['current', 'selected', 'all'],
  74. }"
  75. @sort-change="sortChangeHandle"
  76. :sort-config="{remote:true}"
  77. :data="dataList"
  78. :checkbox-config="{}">
  79. <vxe-column type="seq" width="40"></vxe-column>
  80. <vxe-column type="checkbox" width="40px"></vxe-column>
  81. <vxe-column
  82. field="gwId"
  83. sortable
  84. title="公文id">
  85. <template #default="{ row }">
  86. <el-link type="primary" :underline="false" v-if="hasPermission('gwflow:gwFlow:edit')" @click="edit(row.id)">{{row.gwId}}</el-link>
  87. <el-link type="primary" :underline="false" v-else-if="hasPermission('gwflow:gwFlow:view')" @click="view(row.id)">{{row.gwId}}</el-link>
  88. <span v-else>{{row.gwId}}</span>
  89. </template>
  90. </vxe-column>
  91. <vxe-column
  92. field="content"
  93. sortable
  94. title="内容">
  95. </vxe-column>
  96. <vxe-column
  97. field="signfj"
  98. sortable
  99. title="签名附件">
  100. <template #default="{ row }">
  101. <template v-if="row.signfj">
  102. <el-image
  103. style="height: 50px;width:50px;margin-right:10px;"
  104. :src="src" v-for="(src, index) in row.signfj.split(',')" :key="index"
  105. :preview-src-list="row.signfj.split(',')">
  106. </el-image>
  107. </template>
  108. </template>
  109. </vxe-column>
  110. <vxe-column
  111. field="state"
  112. sortable
  113. title="流程状态">
  114. <template #default="{ row }">
  115. {{ $dictUtils.getDictLabel("gw_flow_state", row.state, '-') }}
  116. </template>
  117. </vxe-column>
  118. <vxe-column
  119. field="createBy.id"
  120. sortable
  121. title="创建者">
  122. </vxe-column>
  123. <vxe-column
  124. fixed="right"
  125. align="center"
  126. width="200"
  127. title="操作">
  128. <template #default="{ row }">
  129. <el-button v-if="hasPermission('gwflow:gwFlow:view')" type="primary" text icon="view-filled" @click="view(row.id)">查看</el-button>
  130. <el-button v-if="hasPermission('gwflow:gwFlow:edit')" type="primary" text icon="edit-filled" @click="edit(row.id)">修改</el-button>
  131. <el-button v-if="hasPermission('gwflow:gwFlow:del')" type="danger" text icon="del-filled" @click="del(row.id)">删除</el-button>
  132. </template>
  133. </vxe-column>
  134. </vxe-table>
  135. <vxe-pager
  136. background
  137. size="small"
  138. :current-page="tablePage.currentPage"
  139. :page-size="tablePage.pageSize"
  140. :total="tablePage.total"
  141. :page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
  142. :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
  143. @page-change="currentChangeHandle">
  144. </vxe-pager>
  145. </div>
  146. </div>
  147. <!-- 弹窗, 新增 / 修改 -->
  148. <GwFlowForm ref="gwFlowForm" @refreshDataList="refreshList"></GwFlowForm>
  149. </div>
  150. </template>
  151. <script>
  152. import GwFlowForm from './GwFlowForm'
  153. import gwFlowService from '@/api/gwflow/gwFlowService'
  154. export default {
  155. data () {
  156. return {
  157. searchVisible: true,
  158. searchForm: {
  159. },
  160. dataList: [],
  161. tablePage: {
  162. total: 0,
  163. currentPage: 1,
  164. pageSize: 10,
  165. orders: [{ column: "create_time", asc: false }],
  166. },
  167. loading: false
  168. }
  169. },
  170. components: {
  171. GwFlowForm
  172. },
  173. created () {
  174. },
  175. mounted () {
  176. this.$nextTick(() => {
  177. // 将表格和工具栏进行关联
  178. const $table = this.$refs.gwFlowTable
  179. const $toolbar = this.$refs.gwFlowToolbar
  180. $table.connect($toolbar)
  181. })
  182. },
  183. activated () {
  184. this.refreshList()
  185. },
  186. methods: {
  187. // 获取数据列表
  188. refreshList () {
  189. this.loading = true
  190. gwFlowService.list({
  191. 'current': this.tablePage.currentPage,
  192. 'size': this.tablePage.pageSize,
  193. 'orders': this.tablePage.orders,
  194. ...this.searchForm
  195. }).then((data) => {
  196. this.dataList = data.records
  197. this.tablePage.total = data.total
  198. this.loading = false
  199. })
  200. },
  201. // 当前页
  202. currentChangeHandle ({ currentPage, pageSize }) {
  203. this.tablePage.currentPage = currentPage
  204. this.tablePage.pageSize = pageSize
  205. this.refreshList()
  206. },
  207. // 排序
  208. sortChangeHandle(obj) {
  209. this.tablePage.orders = [];
  210. if (obj.order != null) {
  211. this.tablePage.orders = [{ column: obj.column.sortBy || this.$utils.toLine(obj.property), asc: obj.order === "asc" }];
  212. } else {
  213. this.tablePage.orders = [{ column: "create_time", asc: false }];
  214. }
  215. this.refreshList();
  216. },
  217. // 新增
  218. add () {
  219. this.$refs.gwFlowForm.init('add', '')
  220. },
  221. // 修改
  222. edit (id) {
  223. id = id || this.$refs.gwFlowTable.getCheckboxRecords().map(item => {
  224. return item.id
  225. })[0]
  226. this.$refs.gwFlowForm.init('edit', id)
  227. },
  228. // 查看
  229. view (id) {
  230. this.$refs.gwFlowForm.init('view', id)
  231. },
  232. // 删除
  233. del (id) {
  234. let ids = id || this.$refs.gwFlowTable.getCheckboxRecords().map(item => {
  235. return item.id
  236. }).join(',')
  237. this.$confirm(`确定删除所选项吗?`, '提示', {
  238. confirmButtonText: '确定',
  239. cancelButtonText: '取消',
  240. type: 'warning'
  241. }).then(() => {
  242. this.loading = true
  243. gwFlowService.delete(ids).then((data) => {
  244. this.$message.success(data)
  245. this.refreshList()
  246. this.loading = false
  247. })
  248. })
  249. },
  250. // 下载模板
  251. downloadTpl() {
  252. this.loading = true
  253. gwFlowService
  254. .exportTemplate()
  255. .then((data) => {
  256. // 将二进制流文件写入excel表,以下为重要步骤
  257. this.$utils.downloadExcel(data, "公文流程导入模板");
  258. this.loading = false
  259. })
  260. .catch(function (err) {
  261. this.loading = false
  262. if (err.response) {
  263. console.log(err.response);
  264. }
  265. });
  266. },
  267. // 自定义服务端导入
  268. importMethod({ file }) {
  269. // 处理表单
  270. const formBody = new FormData();
  271. formBody.append("file", file);
  272. this.loading = true
  273. gwFlowService.importExcel(formBody).then((result) => {
  274. this.$message.success({
  275. dangerouslyUseHTMLString: true,
  276. message: result,
  277. });
  278. this.refreshList();
  279. });
  280. },
  281. // 自定义服务端导出
  282. exportMethod({ options }) {
  283. // 传给服务端的参数
  284. const params = {
  285. current: this.tablePage.currentPage,
  286. size: this.tablePage.pageSize,
  287. orders: this.tablePage.orders,
  288. ...this.searchForm,
  289. filename: options.filename,
  290. sheetName: options.sheetName,
  291. isHeader: options.isHeader,
  292. original: options.original,
  293. mode: options.mode,
  294. selectIds:
  295. options.mode === "selected"
  296. ? options.data.map((item) => item.id)
  297. : [],
  298. exportFields: options.columns.map(
  299. (column) => column.property && column.property.split(".")[0]
  300. ),
  301. };
  302. this.loading = true;
  303. return gwFlowService
  304. .exportExcel(params)
  305. .then((data) => {
  306. // 将二进制流文件写入excel表,以下为重要步骤
  307. this.$utils.downloadExcel(data, options.filename);
  308. this.loading = false;
  309. })
  310. .catch(function (err) {
  311. if (err.response) {
  312. console.log(err.response);
  313. }
  314. });
  315. },
  316. resetSearch () {
  317. this.$refs.searchForm.resetFields()
  318. this.refreshList()
  319. }
  320. }
  321. }
  322. </script>