detail.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <!--
  2. * @Author: wanglj wanglijie@dashoo.cn
  3. * @Date: 2025-03-11 18:02:10
  4. * @LastEditors: wanglj wanglijie@dashoo.cn
  5. * @LastEditTime: 2025-04-16 14:02:44
  6. * @FilePath: \vant-demo-master\vant\vue3-ts\src\view\login\index.vue
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. -->
  9. <template>
  10. <div class="app-container">
  11. <header>
  12. <h4 class="mb10">{{ state.form.startUserName }}发起的{{ state.form.defName }}</h4>
  13. <p>{{ state.form.startUserName }}发起于{{ state.form.startTime }}</p>
  14. </header>
  15. <h4>审批信息</h4>
  16. <van-cell-group>
  17. <van-cell title="审批名称" title-class="cell-title" :value="state.form.instTitle" />
  18. <van-cell title="审批编号" title-class="cell-title" :value="state.form.instTitle" />
  19. <van-cell title="审批类型" title-class="cell-title" :value="state.form.defName" />
  20. <van-cell title="申请人" title-class="cell-title" :value="state.form.startUserName" />
  21. <van-cell title="申请时间" title-class="cell-title" :value="state.form.startTime" />
  22. </van-cell-group>
  23. <!-- <h4>附件信息</h4>
  24. <van-cell-group>
  25. <van-cell title="文件名称" :value="state.form.instTitle" />
  26. <van-cell title="文件类型" :value="state.form.instTitle" />
  27. <van-cell title="文件" :value="state.form.defName" />
  28. </van-cell-group> -->
  29. <h4>审批记录</h4>
  30. <FlowTable :id="state.form.id" :businessCode="state.form.businessCode" :defCode="state.form.defCode" />
  31. <h4 v-if="state.type === 'approval'">审批意见</h4>
  32. <van-form v-if="state.type === 'approval'" class="mb20" ref="formRef" required="auto">
  33. <van-cell-group>
  34. <van-field
  35. v-model="state.approvalForm.approveOpinion"
  36. label="审批意见"
  37. placeholder="请输入审批意见"
  38. :rules="[{ required: true, message: '请输入审批意见' }]"
  39. rows="3"
  40. type="textarea"
  41. />
  42. <van-field
  43. v-model="state.approvalForm.approveResult"
  44. label="审批结果"
  45. placeholder="请选择审批结果"
  46. :rules="[{ required: true, message: '请选择审批结果' }]"
  47. >
  48. <template #input>
  49. <van-radio-group v-model="state.approvalForm.approveResult" direction="horizontal">
  50. <van-radio name="pass">通过</van-radio>
  51. <van-radio name="rejection">拒绝</van-radio>
  52. </van-radio-group>
  53. </template>
  54. </van-field>
  55. </van-cell-group>
  56. </van-form>
  57. <van-action-bar v-if="state.type === 'approval'" placeholder>
  58. <van-action-bar-icon icon="wap-home-o" text="首页" @click="onRouterPush('/home')" />
  59. <van-action-bar-icon icon="cluster-o" text="待办事项" @click="onRouterPush('/todo')" />
  60. <van-action-bar-button class="w100" type="primary" text="提交" @click="onSave" />
  61. </van-action-bar>
  62. </div>
  63. </template>
  64. <script name="home" lang="ts" setup>
  65. import to from 'await-to-js'
  66. import { formatDate } from '/@/utils/formatTime'
  67. import { defineAsyncComponent, onMounted, reactive, ref } from 'vue'
  68. import { useRouter, useRoute } from 'vue-router'
  69. import { useExecutionApi } from '/@/api/execution'
  70. import { useFlowApi } from '/@/api/execution/flow'
  71. import { showNotify } from 'vant'
  72. const FlowTable = defineAsyncComponent(() => import('/@/components/FlowTable.vue'))
  73. const executionApi = useExecutionApi()
  74. const flowApi = useFlowApi()
  75. const router = useRouter()
  76. const route = useRoute()
  77. const apprList = ref<any[]>([])
  78. const formRef = ref()
  79. const state = reactive({
  80. type: 'approval',
  81. form: {
  82. id: 0,
  83. defId: 0,
  84. defCode: '',
  85. defName: '',
  86. instTitle: '',
  87. nodeId: '',
  88. candidate: '',
  89. taskId: 0,
  90. startTime: '',
  91. endTime: '',
  92. duration: 0,
  93. startUserId: 0,
  94. startUserName: '',
  95. isFinish: '',
  96. platformId: 0,
  97. remark: '',
  98. createdBy: 0,
  99. createdName: '',
  100. createdTime: '',
  101. updatedBy: 0,
  102. updatedName: '',
  103. updatedTime: '',
  104. formConfig: {},
  105. formData: {},
  106. processTask: [],
  107. businessCode: ''
  108. },
  109. approvalForm: {
  110. approveOpinion: '',
  111. approveResult: 'pass'
  112. }
  113. })
  114. const onClickRight = () => {
  115. router.go(-1)
  116. }
  117. // 审核方式翻译
  118. const getNodeModel = (type: string, model: string) => {
  119. if (type === 'start') return ''
  120. if (model === '10') {
  121. return '会签'
  122. } else if (model === '20') {
  123. return '或签'
  124. }
  125. }
  126. // 详情工作流列表
  127. const getFlowInstance = async () => {
  128. const [err, res]: ToResponse = await to(flowApi.getFlowInstance({ id: state.form.id, businessCode: state.form.businessCode, defCode: state.form.defCode }))
  129. if (err) return
  130. const arr = res?.data?.nodes || []
  131. apprList.value = arr
  132. }
  133. const init = async (id: number) => {
  134. const [err, res]: ToResponse = await to(executionApi.getInstanceById({ id }))
  135. if (err) return
  136. if (res?.data) {
  137. state.form = res.data
  138. }
  139. }
  140. const onRouterPush = (val: string, params?: any) => {
  141. router.push({
  142. path: val,
  143. query: { ...params }
  144. })
  145. }
  146. const onSave = async () => {
  147. const [errValid] = await to(formRef.value.validate())
  148. if (errValid) return
  149. const params = {
  150. taskId: state.form.taskId,
  151. result: state.approvalForm.approveResult,
  152. opinion: state.approvalForm.approveOpinion
  153. }
  154. const [err]: ToResponse = await to(executionApi.approve(params))
  155. if (err) return
  156. showNotify({
  157. type: 'success',
  158. message: '审批成功'
  159. })
  160. router.push({
  161. path: '/todo'
  162. })
  163. }
  164. onMounted(() => {
  165. const id = route.query.id ? +route.query.id : 0
  166. state.type = route.query.type.toString()
  167. init(id)
  168. })
  169. </script>
  170. <style lang="scss" scoped>
  171. .app-container {
  172. header {
  173. padding: 14px;
  174. background-color: #f9ffff;
  175. border-radius: 4px;
  176. margin-top: 10px;
  177. }
  178. > h4 {
  179. margin: 10px 0;
  180. height: 20px;
  181. line-height: 20px;
  182. &::before {
  183. display: inline-block;
  184. content: '';
  185. background-color: #3c78e3;
  186. width: 4px;
  187. height: 20px;
  188. margin-right: 4px;
  189. vertical-align: top;
  190. }
  191. }
  192. :deep(.flow-cell) {
  193. margin-left: 22px;
  194. display: flex;
  195. justify-content: space-between;
  196. color: #333;
  197. }
  198. :deep(.cell-title) {
  199. flex: 0 0 80px;
  200. }
  201. .van-action-bar {
  202. z-index: 2;
  203. }
  204. }
  205. </style>