taskCheck.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <div>
  3. <!--流程表单-->
  4. <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%" :closable="false">
  5. <component
  6. :disabled="lcModa.disabled"
  7. v-if="lcModa.visible"
  8. :is="lcModa.formComponent"
  9. :processData="lcModa.processData"
  10. :isNew="lcModa.isNew"
  11. @close=";(lcModa.visible = false), (lcModa.disabled = false)"
  12. @getDataList="getDataList"
  13. ></component>
  14. </a-modal>
  15. <!-- 审批操作 -->
  16. <a-modal :title="modalTaskTitle" v-model="modalTaskVisible" :mask-closable="false" width="100%">
  17. <div v-if="modalTaskVisible">
  18. <a-form ref="form" :model="form" :label-width="85" :rules="formValidate">
  19. <a-form-item label="审批意见" prop="reason">
  20. <a-input type="textarea" v-model="form.comment" :rows="4" />
  21. </a-form-item>
  22. <a-form-item label="下一审批人" prop="assignees" v-show="showAssign" :error="error">
  23. <a-select v-model="form.assignees" placeholder="请选择" allowClear mode="multiple" :loading="userLoading">
  24. <a-select-option v-for="(item, i) in assigneeList" :key="i" :value="item.username">{{
  25. item.realname
  26. }}</a-select-option>
  27. </a-select>
  28. </a-form-item>
  29. <a-form-item label="下一审批人" v-show="isGateway">
  30. <span>分支网关处暂不支持自定义选择下一审批人,将发送给下一节点所有人</span>
  31. </a-form-item>
  32. <div v-show="form.type == 1">
  33. <a-form-item label="驳回至">
  34. <a-select v-model="form.backTaskKey" :loading="backLoading" @change="changeBackTask">
  35. <a-select-option v-for="(item, i) in backList" :key="i" :value="item.key">{{item.name}}
  36. </a-select-option>
  37. </a-select>
  38. </a-form-item>
  39. <a-form-item label="指定原节点审批人" prop="assignees" v-show="form.backTaskKey != -1" :error="error">
  40. <a-select v-model="form.assignees" placeholder="请选择" allowClear mode="multiple" :loading="userLoading">
  41. <a-select-option v-for="(item, i) in assigneeList" :key="i" :value="item.username">{{item.realname}}
  42. </a-select-option>
  43. </a-select>
  44. </a-form-item>
  45. </div>
  46. <a-form-item label="选择委托人" prop="userId" :error="error" v-show="form.type == 2">
  47. <JSelectUserByDep v-model="form.userId" :multi="false"></JSelectUserByDep>
  48. </a-form-item>
  49. <a-form-item label="消息通知">
  50. <a-checkbox v-model="form.sendMessage">站内消息通知</a-checkbox>
  51. <!-- <a-checkbox v-model="form.sendSms" disabled>短信通知</a-checkbox>
  52. <a-checkbox v-model="form.sendEmail" disabled>邮件通知</a-checkbox> -->
  53. </a-form-item>
  54. </a-form>
  55. </div>
  56. <div slot="footer">
  57. <a-button type="text" @click="modalTaskVisible = false">取消</a-button>
  58. <a-button type="primary" :loading="submitLoading" @click="handelSubmit">提交</a-button>
  59. </div>
  60. </a-modal>
  61. <outerForm-check ref="outerFormCheck" @refreshData="handleSearch" ></outerForm-check>
  62. </div>
  63. </template>
  64. <script>
  65. import { getAction,postAction } from '@/api/manage'
  66. import { mapActions } from 'vuex'
  67. import store from '@/store/'
  68. import outerFormCheck from '../../share/modal/OuterFormCheck'
  69. import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
  70. export default {
  71. name: "taskCheck",
  72. components: { JSelectUserByDep, outerFormCheck },
  73. data() {
  74. return {
  75. key : "",
  76. taskInfo:{},
  77. modalTaskVisible: false,
  78. backList: [
  79. {
  80. key: '-1',
  81. name: '发起人'
  82. }
  83. ],
  84. error: '',
  85. showAssign: false,
  86. searchForm: {
  87. // 搜索框对应data对象
  88. name: ''
  89. },
  90. modalTaskTitle: '',
  91. modalTitle: '', // 添加或编辑标题
  92. form: {
  93. id: '',
  94. userId: '',
  95. procInstId: '',
  96. comment: '',
  97. type: 0,
  98. assignees: [],
  99. backTaskKey: '-1',
  100. sendMessage: true,
  101. sendSms: false,
  102. sendEmail: false
  103. },
  104. formValidate: {
  105. // 表单验证规则
  106. },
  107. submitLoading: false, // 添加或编辑提交状态
  108. data: [], // 表单数据
  109. total: 0, // 表单数据总数
  110. dictPriority: [],
  111. isGateway: false,
  112. lcModa: {
  113. title: '',
  114. disabled: false,
  115. visible: false,
  116. formComponent: null,
  117. isNew: false
  118. },
  119. url:{
  120. taskInfoUrl:"/actTask/getSelfTaskById",
  121. outformViewUrl:"/actBusiness/external/getViewUrl",
  122. }
  123. }
  124. },
  125. created () {
  126. this.key = this.$route.params.id;
  127. this.$message.info(this.key)
  128. this.login(this.key);
  129. },
  130. methods: {
  131. ...mapActions(['OaLogin']),
  132. login(key){
  133. this.OaLogin({key,key})
  134. .then(res => {
  135. this.getTaskInfo(key);
  136. })
  137. },
  138. // 根据taskid获取待办任务的某一条
  139. getTaskInfo(key){
  140. getAction(this.url.taskInfoUrl,{key:key}).then(res => {
  141. if (res.success) {
  142. if (res.result.length == 0){
  143. this.$message.info("待办任务不存在");
  144. return;
  145. }
  146. this.taskInfo = res.result[0];
  147. this.showTask(this.taskInfo);
  148. }else{
  149. this.$message.error(res.message);
  150. }
  151. })
  152. },
  153. // 显示任务信息
  154. showTask(r){
  155. if (!r.routeName) {
  156. this.$message.warning('该流程信息未配置表单,请联系开发人员!')
  157. return
  158. }
  159. r.operationType = '1' //代办
  160. if (r.routeName.indexOf('外部表单') != -1||r.tableName.indexOf('外部表单') != -1) {
  161. //其他项目的表单流程
  162. var id = r.tableId //项目管理合同数据id
  163. this.showOuterFormViewDlg(r.tableId, '业务流程审批:' + r.processName, r);
  164. } else if (r.routeName.indexOf('自定义') != -1) {
  165. //自定义的表单流程
  166. this.lcModa.disabled = true
  167. this.lcModa.title = '查看流程业务信息:' + r.processName
  168. let com = { component: () => import(`@/views/activiti/form/demoForm2`) }
  169. this.lcModa.formComponent = com.component
  170. this.lcModa.isNew = false
  171. this.lcModa.processData = r
  172. this.lcModa.visible = true
  173. } else {
  174. //固定的表单流程
  175. this.lcModa.disabled = true
  176. this.lcModa.title = '查看流程业务信息:' + r.processName
  177. this.lcModa.formComponent = this.getFormComponent(r.routeName).component
  178. this.lcModa.processData = r
  179. this.lcModa.isNew = false
  180. this.lcModa.visible = true
  181. }
  182. },
  183. // 显示外部表单
  184. showOuterFormViewDlg(tableId, title, processData){
  185. getAction(this.url.outformViewUrl,{tableId:tableId}).then(res=>{
  186. if (res.success){
  187. var url = res.result.url;
  188. var param = res.result.param;
  189. url = url+"?"+this.jsonToUrlParam(param);
  190. this.$refs.outerFormCheck.openDialog(url, title, processData);
  191. }else{
  192. this.$message.error(res.message);
  193. }
  194. });
  195. },
  196. // 封装跳转地址
  197. jsonToUrlParam(query){
  198. var tmpArr = [];
  199. for (var i in query){
  200. var key = encodeURIComponent(i);
  201. var value = encodeURIComponent(query[i]);
  202. tmpArr.push(key+"="+value);
  203. }
  204. return tmpArr.join("&");
  205. },
  206. // 提交表单
  207. handelSubmit() {
  208. console.log('提交')
  209. this.submitLoading = true
  210. var formData = Object.assign({}, this.form)
  211. formData.assignees = formData.assignees.join(',')
  212. if (formData.type == 0) {
  213. // 通过
  214. if (this.showAssign && formData.assignees.length < 1) {
  215. this.$message.error('请至少选择一个审批人')
  216. this.submitLoading = false
  217. return
  218. } else {
  219. this.error = ''
  220. }
  221. this.postFormAction(this.url.pass, formData).then(res => {
  222. this.submitLoading = false
  223. if (res.success) {
  224. this.$message.success('操作成功')
  225. this.modalTaskVisible = false
  226. this.getDataList()
  227. }
  228. })
  229. } else if (formData.type == 1) {
  230. // 驳回
  231. if (formData.backTaskKey == '-1') {
  232. // 驳回至发起人
  233. this.postFormAction(this.url.back, formData).then(res => {
  234. this.submitLoading = false
  235. if (res.success) {
  236. this.$message.success('操作成功')
  237. this.modalTaskVisible = false
  238. this.getDataList()
  239. }
  240. })
  241. } else {
  242. // 自定义驳回
  243. if (formData.backTaskKey != '-1' && formData.assignees.length < 1) {
  244. this.$message.error('请至少选择一个审批人')
  245. this.submitLoading = false
  246. return
  247. } else {
  248. this.error = ''
  249. }
  250. this.postFormAction(this.url.backToTask, formData).then(res => {
  251. this.submitLoading = false
  252. if (res.success) {
  253. this.$message.success('操作成功')
  254. this.modalTaskVisible = false
  255. this.getDataList()
  256. }
  257. })
  258. }
  259. } else if (formData.type == 2) {
  260. // 委托
  261. if (!formData.userId) {
  262. this.$message.error('请选择一委托人')
  263. this.submitLoading = false
  264. return
  265. } else {
  266. this.error = ''
  267. }
  268. this.postFormAction(this.url.delegate, formData).then(res => {
  269. this.submitLoading = false
  270. if (res.success) {
  271. this.$message.success('操作成功')
  272. this.modalTaskVisible = false
  273. this.getDataList()
  274. }
  275. })
  276. }
  277. },
  278. handleSearch(){
  279. }
  280. }
  281. }
  282. </script>
  283. <style scoped>
  284. </style>