applyListByTableName.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  1. <style lang="less">
  2. @import '~@assets/less/common.less';
  3. </style>
  4. <template>
  5. <a-card :bordered="false">
  6. <!-- 查询区域 -->
  7. <div class="table-page-search-wrapper">
  8. <a-form layout="inline" @keyup.enter.native="searchQuery">
  9. <a-row :gutter="24">
  10. <a-col :md="4" :sm="12">
  11. <a-form-item label="标题">
  12. <a-input placeholder="请输入搜索关键词" v-model="queryParam.title"></a-input>
  13. </a-form-item>
  14. </a-col>
  15. <a-col :md="4" :sm="12">
  16. <a-form-item label="状态">
  17. <a-select v-model="queryParam.status" placeholder="请选择" :allowClear="true">
  18. <a-select-option value="0">草稿</a-select-option>
  19. <a-select-option value="1">处理中</a-select-option>
  20. <a-select-option value="2">已结束</a-select-option>
  21. <a-select-option value="3">已撤回</a-select-option>
  22. </a-select>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="4" :sm="12">
  26. <a-form-item label="结果">
  27. <a-select v-model="queryParam.result" placeholder="请选择" :allowClear="true">
  28. <a-select-option value="0">未提交</a-select-option>
  29. <a-select-option value="1">处理中</a-select-option>
  30. <a-select-option value="2">通过</a-select-option>
  31. <a-select-option value="3">驳回</a-select-option>
  32. </a-select>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="12">
  36. <a-form-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
  37. <a-range-picker
  38. style="width: 100%"
  39. v-model="queryParam.createTimeRange"
  40. format="YYYY-MM-DD"
  41. :placeholder="['开始时间', '结束时间']"
  42. @change="onDateChange"
  43. @ok="onDateOk"
  44. />
  45. </a-form-item>
  46. </a-col>
  47. <!-- 查询 重置 -->
  48. <a-col :md="6" :sm="12">
  49. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  50. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px;">重置</a-button>
  51. <a-dropdown
  52. v-if="data.length > 0"
  53. v-model="visible"
  54. :trigger="['click']"
  55. class="selectMenuCont"
  56. placement="bottomLeft"
  57. >
  58. <a-menu slot="overlay">
  59. <a-tree
  60. class="paperCheck"
  61. v-model="checkedColumn"
  62. checkable
  63. :tree-data="tableColumns"
  64. :default-expanded-keys="expandedKeys"
  65. draggable
  66. @dragenter="onDragEnter"
  67. @drop="onDrop"
  68. style="height:300px;overflow:auto"
  69. />
  70. <a-menu-divider />
  71. <a-menu-item>
  72. <a-button style="margin: 0px 2px;" @click="handleMenuClickAll_comm">{{ selectText }}</a-button>
  73. <a-button style="margin: 0px 2px;" @click="handleMenuClick_comm">确定</a-button>
  74. <a-button style="margin: 0px 2px;" @click="colseMenuClick">取消</a-button>
  75. </a-menu-item>
  76. </a-menu>
  77. <a-button
  78. style="margin-left: 8px;"
  79. @click="e => e.preventDefault()"
  80. v-has="'applyListByTableName:display-column'"
  81. >
  82. 显示列
  83. <a-icon type="down" />
  84. </a-button>
  85. </a-dropdown>
  86. </a-col>
  87. </a-row>
  88. <!-- 发起申请 按钮 -->
  89. <a-col :md="12" :sm="12">
  90. <a-button
  91. type="primary"
  92. @click="addApply"
  93. :loading="addApplyLoading"
  94. style="margin:10px 0;"
  95. icon="plus-circle"
  96. >
  97. 发起申请
  98. </a-button>
  99. </a-col>
  100. </a-form>
  101. </div>
  102. <!-- 表 -->
  103. <a-row :gutter="24">
  104. <a-col :md="24" :sm="24">
  105. <a-table
  106. bordered
  107. ref="table"
  108. rowKey="id"
  109. :dataSource="dataSource"
  110. :pagination="ipagination"
  111. :loading="loading"
  112. @change="handleTableChange"
  113. :columns="selectedColumns"
  114. >
  115. <!-- 状态 -->
  116. <template slot="status" slot-scope="t, r, i">
  117. <span :style="{ color: getStatus(t).color }">{{ getStatus(t).text }}</span>
  118. </template>
  119. <!-- 结果 -->
  120. <template slot="result" slot-scope="t, r, i">
  121. <span :style="{ color: getResult(t).color }">{{ getResult(t).text }}</span>
  122. </template>
  123. <a-table-column title="创建时间" data-index="createTime" :width="150" align="center">
  124. <template slot-scope="t, r, i">
  125. <span>{{ t }}</span>
  126. </template>
  127. </a-table-column>
  128. <a-table-column title="提交申请时间" data-index="applyTime" :width="150" align="center">
  129. <template slot-scope="t, r, i">
  130. <span>{{ t }}</span>
  131. </template>
  132. </a-table-column>
  133. <!-- <a-table-column title="操作" data-index align="center" :width="200"></a-table-column> -->
  134. <!-- <span slot-scope="text, record"> -->
  135. <template slot="action" slot-scope="t, r, i">
  136. <template v-if="r.status == 0">
  137. <a href="javascript:void(0);" style="color: #00A0E9" @click="apply(r)">提交申请</a>
  138. <a-divider type="vertical" />
  139. <a href="javascript:void(0);" @click="edit(r)" style="color: #000000">编辑</a>
  140. <a-divider type="vertical" />
  141. <a-popconfirm title="确定删除吗?" @confirm="() => remove(r)">
  142. <a href="javascript:void(0);" style="color: red">删除</a>
  143. </a-popconfirm>
  144. </template>
  145. <template v-else-if="r.status == 1">
  146. <a href="javascript:void(0);" @click="cancel(r)" style="color:orange;">撤回</a>
  147. <a-divider type="vertical" />
  148. <a href="javascript:void(0);" @click="history(r)" style="color:gray;">审批历史</a>
  149. <a-divider type="vertical" />
  150. <a href="javascript:void(0);" @click="detail(r)">详情</a>
  151. </template>
  152. <template v-else-if="(r.status == 2 && r.result == 3) || r.status == 3">
  153. <a-popconfirm title="确定提交申请吗?" @confirm="() => apply(r)">
  154. <a href="javascript:void(0);" style="color:#00A0E9;">再次申请</a>
  155. </a-popconfirm>
  156. <a-divider type="vertical" />
  157. <a href="javascript:void(0);" @click="edit(r)" style="color:#000000;">编辑</a>
  158. <a-divider type="vertical" />
  159. <a href="javascript:void(0);" @click="history(r)" style="color:gray;">审批历史</a>
  160. <a-divider type="vertical" />
  161. <a-popconfirm title="确定删除吗?" @confirm="() => remove(r)">
  162. <a href="javascript:void(0);" style="color: red">删除</a>
  163. </a-popconfirm>
  164. </template>
  165. <template v-else>
  166. <a href="javascript:void(0);" @click="detail(r)">详情</a>
  167. <a-divider type="vertical" />
  168. <a href="javascript:void(0);" @click="history(r)" style="color:blue;">审批历史</a>
  169. </template>
  170. </template>
  171. <!-- </span> -->
  172. </a-table>
  173. </a-col>
  174. </a-row>
  175. <!--流程申请选择-->
  176. <a-drawer
  177. title="选择流程"
  178. width="33%"
  179. placement="right"
  180. :closable="false"
  181. @close="processModalVisible = false"
  182. :visible="processModalVisible"
  183. >
  184. <a-input-search style="margin-bottom: 10px;width: 200px" placeholder="输入流程名称" @search="onSearchProcess" />
  185. <a-empty description="无流程可供选择" v-if="activeKeyAll.length == 0" />
  186. <div v-else>
  187. <a-collapse v-model="activeKey">
  188. <a-collapse-panel
  189. v-for="(value, index) in activeKeyAll"
  190. :header="filterDictText(dictOptions, value) || '未分类'"
  191. :key="value"
  192. >
  193. <a-list :grid="{ gutter: 10, column: 1 }" :dataSource="processDataMap[value]">
  194. <a-list-item slot="renderItem" slot-scope="item">
  195. <a-card>
  196. <div slot="title">
  197. <a-row>
  198. <a-col span="12" :title="item.name">{{ item.name }}</a-col>
  199. <a-col span="12" style="text-align: right;">
  200. <a href="javascript:void (0)" @click="chooseProcess(item)">发起申请</a>
  201. </a-col>
  202. </a-row>
  203. </div>
  204. <b>版本:</b>
  205. v.{{ item.version }}
  206. <br />
  207. <b>说明:</b>
  208. {{ item.description }}
  209. </a-card>
  210. </a-list-item>
  211. </a-list>
  212. </a-collapse-panel>
  213. </a-collapse>
  214. </div>
  215. </a-drawer>
  216. <!--流程表单-->
  217. <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
  218. <component
  219. :disabled="lcModa.disabled"
  220. v-if="lcModa.visible"
  221. :is="lcModa.formComponent"
  222. :processData="lcModa.processData"
  223. :isNew="lcModa.isNew"
  224. @afterSubmit="afterSub"
  225. @close=";(lcModa.visible = false), (lcModa.disabled = false)"
  226. ></component>
  227. </a-modal>
  228. <!-- <onl-cgform-auto-modal ref="modal" code="b0bea65bfce141deb0ae3fcb18982d76" /> -->
  229. <!--提交申请表单-->
  230. <a-modal title="提交申请" v-model="modalVisible" :mask-closable="false" :width="500" :footer="null">
  231. <div v-if="modalVisible">
  232. <a-form-item label="选择审批人" v-show="showAssign">
  233. <a-select style="width: 80%" v-model="form.assignees" placeholder="请选择" mode="multiple" :allowClear="true">
  234. <a-select-option v-for="(item, i) in assigneeList" :key="i" :value="item.username">{{
  235. item.realname
  236. }}</a-select-option>
  237. </a-select>
  238. </a-form-item>
  239. <a-form-item label="下一审批人" v-show="isGateway">
  240. <a-alert type="info" showIcon message="分支网关处不支持自定义选择下一审批人,将自动下发给所有可审批人。"
  241. >,将发送给下一节点所有人</a-alert
  242. >
  243. </a-form-item>
  244. <a-form-item label="优先级" prop="priority">
  245. <a-select v-model="form.priority" placeholder="请选择" :allowClear="true" style="width: 100%">
  246. <a-select-option :value="0">普通</a-select-option>
  247. <a-select-option :value="1">重要</a-select-option>
  248. <a-select-option :value="2">紧急</a-select-option>
  249. </a-select>
  250. </a-form-item>
  251. <a-form-item label="消息通知">
  252. <a-checkbox v-model="form.sendMessage">站内消息通知</a-checkbox>
  253. <!-- <a-checkbox v-model="form.sendSms" disabled>短信通知</a-checkbox>
  254. <a-checkbox v-model="form.sendEmail" disabled>邮件通知</a-checkbox>-->
  255. </a-form-item>
  256. <div slot="footer">
  257. <a-button type="text" @click="modalVisible = false">取消</a-button>
  258. <div style="display:inline-block;width: 20px;"></div>
  259. <a-button type="primary" :disabled="submitLoading" @click="applySubmit">提交</a-button>
  260. </div>
  261. </div>
  262. </a-modal>
  263. <a-modal title="审批历史" v-model="modalLsVisible" :mask-closable="false" :width="'80%'" :footer="null">
  264. <div v-if="modalLsVisible">
  265. <historicDetail :procInstId="procInstId"></historicDetail>
  266. </div>
  267. </a-modal>
  268. <a-modal title="确认撤回" v-model="modalCancelVisible" :mask-closable="false" :width="500">
  269. <a-form ref="delForm" v-model="cancelForm" :label-width="70" v-if="modalCancelVisible">
  270. <a-form-item label="撤回原因" prop="reason">
  271. <a-input type="textarea" v-model="cancelForm.reason" :rows="4" />
  272. </a-form-item>
  273. </a-form>
  274. <div slot="footer">
  275. <a-button type="text" @click="modalCancelVisible = false">取消</a-button>
  276. <a-button type="primary" :disabled="submitLoading" @click="handelSubmitCancel">提交</a-button>
  277. </div>
  278. </a-modal>
  279. </a-card>
  280. </template>
  281. <script>
  282. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  283. import { activitiMixin } from '@/views/activiti/mixins/activitiMixin'
  284. import { filterObj } from '@/utils/util'
  285. import JEllipsis from '@/components/jeecg/JEllipsis'
  286. import { saveBuchColumnsShow, getColumnsShowList } from '@/api/api'
  287. import { deleteAction, getAction, downFile } from '@/api/manage'
  288. import pick from 'lodash.pick'
  289. import JTreeSelect from '@/components/jeecg/JTreeSelect'
  290. import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'
  291. import historicDetail from '@/views/activiti/historicDetail'
  292. const data = []
  293. for (let i = 0; i < 5; i++) {
  294. data.push({
  295. key: i,
  296. uuid: `小灰灰`,
  297. name: `平底锅`,
  298. code: `2010-01-06`,
  299. sortNum: `¥16,340.20`,
  300. squarePerPage: `小白`,
  301. pathName: `水波`,
  302. psPath: `现金`,
  303. Path: `国家`
  304. })
  305. }
  306. export default {
  307. name: 'applyList',
  308. mixins: [activitiMixin, JeecgListMixin],
  309. components: {
  310. JEllipsis,
  311. JTreeSelect,
  312. historicDetail
  313. },
  314. data() {
  315. return {
  316. columns: [],
  317. selectText: '全选',
  318. checkedColumn: [],
  319. selectedColumns: [],
  320. expandedKeys: [],
  321. loading: false,
  322. data,
  323. visible: false,
  324. tableColumns: [],
  325. description: '我的申请',
  326. dictOptions: [],
  327. url: {
  328. list: '/actBusiness/getActBusinessList',
  329. getProcessDataList: '/activiti_process/listData',
  330. delByIds: '/actBusiness/delByIds',
  331. getFirstNode: '/actProcessIns/getFirstNode',
  332. applyBusiness: '/actBusiness/apply',
  333. cancelApply: '/actBusiness/cancel'
  334. },
  335. // 查询条件
  336. queryParam: {
  337. createTimeRange: [],
  338. keyWord: ''
  339. },
  340. // 表头
  341. labelCol: {
  342. xs: { span: 4 },
  343. sm: { span: 4 }
  344. },
  345. wrapperCol: {
  346. xs: { span: 20 },
  347. sm: { span: 20 }
  348. },
  349. processModalVisible: null,
  350. activeKeyAll: [],
  351. activeKey: [],
  352. processDataMap: {},
  353. searchProcessKey: null,
  354. addApplyLoading: false,
  355. lcModa: {
  356. title: '',
  357. disabled: false,
  358. visible: false,
  359. formComponent: null,
  360. isNew: false
  361. },
  362. form: {
  363. priority: 0,
  364. assignees: [],
  365. sendMessage: true
  366. },
  367. modalVisible: false,
  368. showAssign: false,
  369. assigneeList: [],
  370. isGateway: false,
  371. dictPriority: [],
  372. submitLoading: false,
  373. error: '',
  374. /*审批历史*/
  375. modalLsVisible: false,
  376. procInstId: '',
  377. modalCancelVisible: false,
  378. cancelForm: {},
  379. tableDataObject: {}, //表单发起所属表单相关数据
  380. tableName: '' //当前页面地址
  381. }
  382. },
  383. created() {
  384. console.log(this.$route.params)
  385. this.tableName = this.$route.params.tableName
  386. },
  387. //时刻监听,一旦切换到其他申请表单则重新加载数据
  388. watch: {
  389. $route(to, from) {
  390. if (this.tableName != this.$route.params.tableName) {
  391. this.clear()
  392. this.tableName = this.$route.params.tableName
  393. ///////根据表单名称查询对应相关数据
  394. let businessTable = this.$route.params.tableName //表单表名称
  395. this.postFormAction('/activiti_process/listData', {
  396. businessTable: businessTable,
  397. status: 1,
  398. roles: true
  399. }).then(res => {
  400. // this.activeKeyAll = []
  401. //是否查询成功
  402. if (res.success) {
  403. var result = res.result || []
  404. if (result.length > 0) {
  405. //获取所属表单的相关数据
  406. this.tableDataObject = result[0]
  407. }
  408. }
  409. })
  410. this.loadData(1)
  411. }
  412. }
  413. },
  414. activated: function() {},
  415. mounted() {},
  416. computed: {},
  417. methods: {
  418. handleMenuClickAll_comm() {
  419. console.log(this.tableColumns)
  420. if (this.checkedColumn.length === this.tableColumns.length) {
  421. this.selectText = '全选'
  422. this.checkedColumn = []
  423. } else if (this.checkedColumn.length > 0 && this.checkedColumn.length < this.tableColumns.length) {
  424. if (this.selectText === '全选') {
  425. this.checkedColumn = []
  426. this.tableColumns.forEach(item => {
  427. this.checkedColumn.push(item.key)
  428. })
  429. this.selectText = '全取消'
  430. } else {
  431. this.checkedColumn = []
  432. this.selectText = '全选'
  433. }
  434. } else {
  435. this.selectText = '全取消'
  436. this.checkedColumn = []
  437. this.tableColumns.forEach(item => {
  438. this.checkedColumn.push(item.key)
  439. })
  440. }
  441. // console.log(this.columns)
  442. // if (this.checkedColumn.length === this.columns.length) {
  443. // this.selectText = '全选'
  444. // this.checkedColumn = []
  445. // } else if (this.checkedColumn.length > 0 && this.checkedColumn.length < this.columns.length) {
  446. // if (this.selectText === '全选') {
  447. // this.checkedColumn = []
  448. // this.columns.forEach(item => {
  449. // this.checkedColumn.push(item.key)
  450. // })
  451. // this.selectText = '全取消'
  452. // } else {
  453. // this.checkedColumn = []
  454. // this.selectText = '全选'
  455. // }
  456. // } else {
  457. // this.selectText = '全取消'
  458. // this.checkedColumn = []
  459. // this.columns.forEach(item => {
  460. // this.checkedColumn.push(item.key)
  461. // })
  462. // }
  463. },
  464. handleMenuClick_comm(e) {
  465. if (this.checkedColumn.length === 0) {
  466. this.$message.info('请至少勾选一项!')
  467. return
  468. }
  469. let cdColumnsShowList = [] //整理保存数据
  470. this.visible = false
  471. if (this.checkedColumn.length > 0) {
  472. let selectedColumns = this.tableColumns.map(item => {
  473. //判断是否页面临时处理字段
  474. let isscopedSlots = '1'
  475. if (item.scopedSlots) {
  476. isscopedSlots = '2'
  477. }
  478. if (this.checkedColumn.indexOf(item.key) >= 0) {
  479. //选中显示数据
  480. cdColumnsShowList.push({
  481. columnName: item.key,
  482. columnDescribe: item.title,
  483. isShow: '2',
  484. isScopedSlots: isscopedSlots
  485. })
  486. item.isShow = '1'
  487. return item
  488. } else {
  489. //未选中显示数据
  490. cdColumnsShowList.push({
  491. columnName: item.key,
  492. columnDescribe: item.title,
  493. isShow: '1',
  494. isScopedSlots: isscopedSlots
  495. })
  496. return null
  497. }
  498. })
  499. this.selectedColumns = _.cloneDeep([...selectedColumns.filter(item => item !== null)])
  500. // console.log(this.tableColumns)
  501. }
  502. //显示列记录保存到数据库
  503. let dataObject = {
  504. tableName: this.$route.params.tableName,
  505. cdColumnsShowList: cdColumnsShowList
  506. }
  507. saveBuchColumnsShow(dataObject).then(res => {
  508. if (res.success) {
  509. this.$message.success('保存成功')
  510. this.loadData(1)
  511. } else {
  512. this.$message.error('保存失败')
  513. }
  514. })
  515. // if (this.checkedColumn.length === 0) {
  516. // this.$message.info('请至少勾选一项!')
  517. // return
  518. // }
  519. // this.visible = false
  520. // if (this.checkedColumn.length > 0) {
  521. // let selectedColumns =this.tableColumns.map(item => {
  522. // if (this.checkedColumn.indexOf(item.key) >= 0) {
  523. // item.isShow = '1'
  524. // return item
  525. // } else {
  526. // return null
  527. // }
  528. // })
  529. // this.selectedColumns = _.cloneDeep([...selectedColumns.filter(item => item !== null)])
  530. // }
  531. },
  532. colseMenuClick() {
  533. this.checkedColumn = []
  534. this.tableColumns.forEach(t => {
  535. if (t.isShow == '2') {
  536. //默认显示列选择选中的列
  537. this.checkedColumn.push(t.key)
  538. }
  539. })
  540. this.visible = false
  541. },
  542. onDrop(info) {
  543. const dropKey = info.node.eventKey
  544. const dragKey = info.dragNode.eventKey
  545. const dropPos = info.node.pos.split('-')
  546. const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1])
  547. const loop = (data, key, callback) => {
  548. data.forEach((item, index, arr) => {
  549. if (item.key === key) {
  550. return callback(item, index, arr)
  551. }
  552. if (item.children) {
  553. return loop(item.children, key, callback)
  554. }
  555. })
  556. }
  557. const data = [...this.tableColumns]
  558. // Find dragObject
  559. // 只在父级下进行拖拽
  560. let dragObj
  561. loop(data, dragKey, (item, index, arr) => {
  562. arr.splice(index, 1)
  563. dragObj = item
  564. })
  565. let ar
  566. let i
  567. loop(data, dropKey, (item, index, arr) => {
  568. ar = arr
  569. i = index
  570. })
  571. if (dropPosition === -1) {
  572. ar.splice(i, 0, dragObj)
  573. } else {
  574. ar.splice(i + 1, 0, dragObj)
  575. }
  576. this.tableColumns = data
  577. },
  578. onDragEnter(info) {
  579. console.log(info)
  580. },
  581. clear() {
  582. this.dictOptions = []
  583. // 查询条件
  584. this.queryParam = {}
  585. this.processModalVisible = null
  586. this.activeKeyAll = []
  587. this.activeKey = []
  588. this.processDataMap = {}
  589. this.searchProcessKey = null
  590. this.addApplyLoading = false
  591. this.lcModa = {
  592. title: '',
  593. disabled: false,
  594. visible: false,
  595. formComponent: null,
  596. isNew: false
  597. }
  598. this.form = {
  599. priority: 0,
  600. assignees: [],
  601. sendMessage: true
  602. }
  603. this.modalVisible = false
  604. this.showAssign = false
  605. this.assigneeList = []
  606. this.isGateway = false
  607. this.dictPriority = []
  608. this.submitLoading = false
  609. this.error = ''
  610. /*审批历史*/
  611. this.modalLsVisible = false
  612. this.procInstId = ''
  613. this.modalCancelVisible = false
  614. this.cancelForm = {}
  615. this.tableDataObject = {} //表单发起所属表单相关数据
  616. this.tableName = '' //当前页面地址
  617. this.columns = []
  618. this.selectText = '全选'
  619. this.checkedColumn = []
  620. this.selectedColumns = []
  621. this.expandedKeys = []
  622. this.loading = false
  623. this.visible = false
  624. },
  625. initDictConfig() {
  626. //初始化字典 - 流程分类
  627. initDictOptions('bpm_process_type').then(res => {
  628. if (res.success) {
  629. this.dictOptions = res.result
  630. }
  631. })
  632. },
  633. filterDictText(dictOptions, text) {
  634. if (dictOptions instanceof Array) {
  635. for (let dictItem of dictOptions) {
  636. if (text === dictItem.value) {
  637. return dictItem.text
  638. }
  639. }
  640. }
  641. return text || text == 'null' ? '' : text
  642. },
  643. getProcessList() {
  644. this.addApplyLoading = true
  645. this.postFormAction(this.url.getProcessDataList, { status: 1, roles: true })
  646. .then(res => {
  647. this.activeKeyAll = []
  648. if (res.success) {
  649. var result = res.result || []
  650. if (result.length > 0) {
  651. let searchProcessKey = this.searchProcessKey
  652. if (searchProcessKey) {
  653. //过滤条件
  654. result = _.filter(result, function(o) {
  655. return o.name.indexOf(searchProcessKey) > -1
  656. })
  657. }
  658. this.processDataMap = _.groupBy(result, 'categoryId')
  659. for (const categoryId in this.processDataMap) {
  660. this.activeKeyAll.push(categoryId)
  661. }
  662. this.activeKey = this.activeKeyAll
  663. }
  664. this.processModalVisible = true
  665. } else {
  666. this.$message.warning(res.message)
  667. }
  668. })
  669. .finally(() => (this.addApplyLoading = false))
  670. },
  671. loadData(arg) {
  672. console.log('loadData')
  673. if (!this.url.list) {
  674. this.$message.error('请设置url.list属性!')
  675. return
  676. }
  677. //获取显示列相关数据
  678. getColumnsShowList({ tableName: this.$route.params.tableName }).then(res => {
  679. this.selectedColumns = []
  680. this.checkedColumn = []
  681. this.tableColumns = res.result
  682. this.tableColumns.forEach(t => {
  683. if (t.isShow == '2') {
  684. //获取需要显示列
  685. this.selectedColumns.push(t)
  686. //默认显示列选择选中的列
  687. this.checkedColumn.push(t.key)
  688. }
  689. })
  690. })
  691. //加载数据 若传入参数1则加载第一页的内容
  692. if (arg === 1) {
  693. this.ipagination.current = 1
  694. }
  695. this.queryParam.tableName = this.$route.params.tableName
  696. var params = this.getQueryParams() //查询条件
  697. console.log(params)
  698. this.loading = true
  699. getAction(this.url.list, params).then(res => {
  700. if (res.success) {
  701. let records = res.result || []
  702. this.dataSource = records
  703. this.ipagination.total = records.length
  704. }
  705. if (res.code === 510) {
  706. this.$message.warning(res.message)
  707. }
  708. this.loading = false
  709. })
  710. },
  711. getQueryParams() {
  712. var param = Object.assign({}, this.queryParam, this.isorter)
  713. delete param.createTimeRange // 时间参数不传递后台
  714. return filterObj(param)
  715. },
  716. // 重置
  717. searchReset() {
  718. var that = this
  719. var logType = that.queryParam.logType
  720. that.queryParam = {} //清空查询区域参数
  721. that.queryParam.logType = logType
  722. that.loadData(this.ipagination.current)
  723. },
  724. onDateChange: function(value, dateString) {
  725. console.log(dateString[0], dateString[1])
  726. this.queryParam.createTime_begin = dateString[0]
  727. this.queryParam.createTime_end = dateString[1]
  728. },
  729. onDateOk(value) {
  730. console.log(value)
  731. },
  732. getStatus(status) {
  733. let text = '未知',
  734. color = ''
  735. if (status == 0) {
  736. text = '草稿'
  737. color = 'default'
  738. } else if (status == 1) {
  739. text = '处理中'
  740. color = 'orange'
  741. } else if (status == 2) {
  742. text = '已结束'
  743. color = 'blue'
  744. } else if (status == 3) {
  745. text = '已撤回'
  746. color = 'magenta'
  747. }
  748. return { text: text, color: color }
  749. },
  750. getResult(result) {
  751. let text = '未知',
  752. color = ''
  753. if (result == 0) {
  754. text = '未提交'
  755. color = 'default'
  756. } else if (result == 1) {
  757. text = '处理中'
  758. color = 'orange'
  759. } else if (result == 2) {
  760. text = '已通过'
  761. color = 'green'
  762. } else if (result == 3) {
  763. text = '已驳回'
  764. color = 'red'
  765. }
  766. return { text: text, color: color }
  767. },
  768. apply(v) {
  769. if (!v.procDefId || v.procDefId == 'null') {
  770. this.$message.error('流程定义为空')
  771. return
  772. }
  773. this.form.id = v.id
  774. this.form.procDefId = v.procDefId
  775. this.form.title = v.title
  776. // 加载审批人
  777. this.getAction(this.url.getFirstNode, { procDefId: v.procDefId }).then(res => {
  778. if (res.success) {
  779. if (res.result.type == 3 || res.result.type == 4) {
  780. this.isGateway = true
  781. this.modalVisible = true
  782. this.form.firstGateway = true
  783. this.showAssign = false
  784. this.error = ''
  785. return
  786. }
  787. this.form.firstGateway = false
  788. this.isGateway = false
  789. if (res.result.users && res.result.users.length > 0) {
  790. this.error = ''
  791. this.assigneeList = res.result.users
  792. // 默认勾选
  793. let ids = []
  794. res.result.users.forEach(e => {
  795. ids.push(e.username)
  796. })
  797. this.form.assignees = ids
  798. this.showAssign = true
  799. } else {
  800. this.form.assignees = []
  801. this.showAssign = true
  802. this.error = '审批节点未分配候选审批人员,请联系管理员!'
  803. }
  804. if (this.error) {
  805. this.$message.error(this.error)
  806. return
  807. }
  808. this.modalVisible = true
  809. } else {
  810. this.$message.error(res.message)
  811. }
  812. })
  813. },
  814. applySubmit() {
  815. if (this.showAssign && this.form.assignees.length < 1) {
  816. this.error = '请至少选择一个审批人'
  817. this.$message.error(this.error)
  818. return
  819. } else {
  820. this.error = ''
  821. }
  822. this.submitLoading = true
  823. var params = Object.assign({}, this.form)
  824. params.assignees = params.assignees.join(',')
  825. this.postFormAction(this.url.applyBusiness, params)
  826. .then(res => {
  827. if (res.success) {
  828. this.$message.success('操作成功')
  829. this.loadData()
  830. this.modalVisible = false
  831. } else {
  832. this.$message.error(res.message)
  833. }
  834. })
  835. .finally(() => (this.submitLoading = false))
  836. },
  837. edit(r, isView) {
  838. if (!r.routeName) {
  839. this.$message.warning('该流程信息未配置表单,请联系开发人员!')
  840. return
  841. }
  842. if (r.routeName.indexOf('外部表单') != -1) {
  843. alert('调用其他项目页面')
  844. } else if (r.routeName.indexOf('自定义') != -1) {
  845. isView = isView || false
  846. this.lcModa.disabled = isView
  847. this.lcModa.title = '修改流程业务信息:' + r.title
  848. if (isView) this.lcModa.title = '查看流程业务信息:' + r.title
  849. let com = { component: () => import(`@/views/activiti/form/demoForm2`) }
  850. this.lcModa.formComponent = com.component
  851. this.lcModa.isNew = false
  852. this.lcModa.processData = r
  853. this.lcModa.visible = true
  854. } else {
  855. isView = isView || false
  856. this.lcModa.disabled = isView
  857. this.lcModa.title = '修改流程业务信息:' + r.title
  858. if (isView) this.lcModa.title = '查看流程业务信息:' + r.title
  859. this.lcModa.formComponent = this.getFormComponent(r.routeName).component
  860. this.lcModa.processData = r
  861. this.lcModa.isNew = false
  862. this.lcModa.visible = true
  863. }
  864. },
  865. remove(r) {
  866. this.postFormAction(this.url.delByIds, { ids: r.id }).then(res => {
  867. if (res.success) {
  868. this.$message.success(res.message)
  869. this.loadData()
  870. } else {
  871. this.$message.error(res.message)
  872. }
  873. })
  874. },
  875. cancel(v) {
  876. this.cancelForm.id = v.id
  877. this.cancelForm.procInstId = v.procInstId
  878. this.modalCancelVisible = true
  879. },
  880. handelSubmitCancel() {
  881. this.submitLoading = true
  882. this.postFormAction(this.url.cancelApply, this.cancelForm)
  883. .then(res => {
  884. if (res.success) {
  885. this.$message.success('操作成功')
  886. this.loadData()
  887. this.modalCancelVisible = false
  888. } else {
  889. this.$message.error(res.message)
  890. }
  891. })
  892. .finally(() => (this.submitLoading = false))
  893. },
  894. history(v) {
  895. if (!v.procInstId) {
  896. this.$message.error('流程实例ID不存在')
  897. return
  898. }
  899. this.procInstId = v.procInstId
  900. this.modalLsVisible = true
  901. },
  902. detail(v) {
  903. // this.$refs.modal.detail("1","8a8080f079ea4ed50179ea4f6c470001")
  904. this.edit(v, true)
  905. },
  906. handleTableChange(pagination, filters, sorter) {
  907. //分页、排序、筛选变化时触发
  908. //TODO 筛选
  909. if (Object.keys(sorter).length > 0) {
  910. this.isorter.column = sorter.field
  911. this.isorter.order = 'ascend' == sorter.order ? 'asc' : 'desc'
  912. }
  913. this.ipagination = pagination
  914. // this.loadData();
  915. },
  916. addApply() {
  917. // this.getProcessList()
  918. let v = this.tableDataObject //表单所需相关数据
  919. if (!v.routeName) {
  920. this.$message.warning('该流程信息未配置表单,请联系开发人员!')
  921. return
  922. }
  923. if (v.routeName.indexOf('外部表单') != -1) {
  924. alert('调用其他项目页面')
  925. } else if (v.routeName.indexOf('自定义') != -1) {
  926. this.lcModa.disabled = false
  927. let com = { component: () => import(`@/views/activiti/form/demoForm2`) }
  928. this.lcModa.formComponent = com.component
  929. this.lcModa.title = '发起流程:' + v.name
  930. this.lcModa.isNew = true
  931. this.lcModa.processData = v
  932. this.lcModa.visible = true
  933. } else {
  934. this.lcModa.disabled = false
  935. this.lcModa.formComponent = this.getFormComponent(v.routeName).component
  936. this.lcModa.title = '发起流程:' + v.name
  937. this.lcModa.isNew = true
  938. this.lcModa.processData = v
  939. this.lcModa.visible = true
  940. }
  941. },
  942. onSearchProcess(value) {
  943. this.searchProcessKey = value
  944. this.getProcessList()
  945. },
  946. chooseProcess(v) {
  947. console.log(v)
  948. // this.$refs.modal.add("1")
  949. if (!v.routeName) {
  950. this.$message.warning('该流程信息未配置表单,请联系开发人员!')
  951. return
  952. }
  953. if (v.routeName.indexOf('外部表单') != -1) {
  954. alert('调用其他项目页面')
  955. } else if (v.routeName.indexOf('自定义') != -1) {
  956. this.lcModa.disabled = false
  957. let com = { component: () => import(`@/views/activiti/form/demoForm2`) }
  958. this.lcModa.formComponent = com.component
  959. this.lcModa.title = '发起流程:' + v.name
  960. this.lcModa.isNew = true
  961. this.lcModa.processData = v
  962. this.lcModa.visible = true
  963. } else {
  964. this.lcModa.disabled = false
  965. this.lcModa.formComponent = this.getFormComponent(v.routeName).component
  966. this.lcModa.title = '发起流程:' + v.name
  967. this.lcModa.isNew = true
  968. this.lcModa.processData = v
  969. this.lcModa.visible = true
  970. }
  971. console.log('发起', v)
  972. },
  973. afterSub(formData) {
  974. this.lcModa.visible = false
  975. this.loadData()
  976. }
  977. }
  978. }
  979. </script>
  980. <style scoped>
  981. @import '~@assets/less/common.less';
  982. </style>