flowForm.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="flow_form_box">
  3. <div class="flow_container">
  4. <template v-if="tabs.length !== 0">
  5. <van-tabs v-model:active="currentActive" :sticky="true">
  6. <van-tab title="基础信息">
  7. <slot></slot>
  8. </van-tab>
  9. <van-tab title="审批意见">
  10. <div class="flowOpinionBox">
  11. <template v-for="(tItem,tIndex) in templateOpinions">
  12. <template v-if="tItem['opinions'].length > 0">
  13. <div v-for="(item,index) in tItem['opinions']" :key="tIndex-index" :class="{'flowOpinionItem': true, 'disabled': !item['isEditor']}">
  14. <h4>{{ tItem['opinionName'] }}</h4>
  15. <div class="content">
  16. <van-field
  17. v-model="currentOpinion.opinionContent"
  18. rows="3"
  19. autosize
  20. label=""
  21. type="textarea"
  22. :disabled="!item['isEditor']"
  23. maxlength="50"
  24. placeholder="请输入留言"
  25. />
  26. </div>
  27. <div class="footer">
  28. <p>
  29. <span>办理人:</span>
  30. <span>{{item['sign'] ?? currentUserName}}</span>
  31. </p>
  32. <p>
  33. <span>办理时间:</span>
  34. <span>{{currentOpinion['opinionTime']}}</span>
  35. </p>
  36. </div>
  37. </div>
  38. </template>
  39. <template v-else>
  40. <div class="flowOpinionItem" :key="tIndex">
  41. <h4>{{ tItem['opinionName'] }}</h4>
  42. <div class="content">
  43. <van-field
  44. rows="3"
  45. autosize
  46. label=""
  47. type="textarea"
  48. :disabled="true"
  49. maxlength="50"
  50. placeholder="请输入留言"
  51. />
  52. </div>
  53. <div class="footer">
  54. <p>
  55. <span>办理人:</span>
  56. <span></span>
  57. </p>
  58. <p>
  59. <span>办理时间:</span>
  60. <span></span>
  61. </p>
  62. </div>
  63. </div>
  64. </template>
  65. </template>
  66. </div>
  67. </van-tab>
  68. </van-tabs>
  69. </template>
  70. <template v-else>
  71. <slot></slot>
  72. </template>
  73. </div>
  74. <div class="fixed-btn">
  75. <van-button round block type="primary" @click="submitHandle">
  76. 转件
  77. </van-button>
  78. </div>
  79. </div>
  80. </template>
  81. <script setup lang="ts">
  82. import { formatDate } from "@/utils/common";
  83. import { getTemplateOpinionListByFlowInstanceId, getOpinionListByFlowInstanceId } from '@/service/flow';
  84. defineOptions({
  85. name: 'FlowForm'
  86. })
  87. const userInfo = JSON.parse(localStorage.getItem('_userInfo') as string);
  88. const currentUserName = userInfo ? userInfo['nickname'] ?? '' : ''
  89. defineProps<{
  90. data: any
  91. }>();
  92. const emit = defineEmits<{
  93. (e: 'submit', payload?: any):void
  94. }>()
  95. const route = useRoute();
  96. const tabs = ref<{
  97. title: string
  98. }[]>([{}])
  99. const currentActive = ref<string>('基础信息')
  100. const { flowInstanceId, activityInstanceId } = route.query as {
  101. flowInstanceId: string
  102. activityInstanceId: string
  103. }
  104. const currentOpinion = ref({
  105. id: '',
  106. opinionContent: '',
  107. opinionTime: '',
  108. sign: null
  109. })
  110. const templateOpinions = ref<any[]>([]);
  111. getTemplateOpinionListByFlowInstanceId(flowInstanceId).then((tResult) => {
  112. const tList = tResult.data ?? []
  113. getOpinionListByFlowInstanceId(flowInstanceId).then((oResult) => {
  114. const oList = oResult.data ?? []
  115. if (oList.length > 0) {
  116. tList.forEach((tItem: any) => {
  117. tItem['opinions'] = []
  118. for (let i = 0; i < oList.length; i++) {
  119. const oItem = oList[i]
  120. if (tItem['id'] === oItem['flowOpinionId']) {
  121. if (oItem['activityInstanceId'] === activityInstanceId) {
  122. oItem['isEditor'] = true;
  123. currentOpinion.value.id = oItem['id']
  124. currentOpinion.value.opinionContent = oItem['opinionContent']
  125. currentOpinion.value.opinionTime = formatDate(new Date())
  126. if (oItem['sign']) {
  127. currentOpinion.value.sign = oItem['sign']
  128. }
  129. }
  130. tItem['opinions'].push(oItem);
  131. oList.splice(i, 1)
  132. i--;
  133. }
  134. }
  135. })
  136. }
  137. templateOpinions.value = tList
  138. })
  139. })
  140. const submitHandle = () => {
  141. emit('submit', currentOpinion.value);
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .flow_form_box {
  146. height: 100%;
  147. display: flex;
  148. flex-direction: column;
  149. background-color: #f7f8fa;
  150. >.flow_container {
  151. flex-grow: 1;
  152. height: 0px;
  153. overflow-y: scroll;
  154. }
  155. >.fixed-btn {
  156. padding: 10px 20px;
  157. }
  158. .flowOpinionBox {
  159. margin: 10px;
  160. >.flowOpinionItem {
  161. margin-bottom: 15px;
  162. background-color: #fff;
  163. padding: 10px 0px;
  164. >h4 {
  165. font-size: 17px;
  166. margin: 0px;
  167. padding: 0px 16px;
  168. }
  169. >.content {
  170. :deep(.van-field__value) {
  171. border: 1px solid #ececec;
  172. border-radius: 5px;
  173. padding: 10px
  174. }
  175. }
  176. >.footer {
  177. display: flex;
  178. padding: 0px 16px;
  179. >p {
  180. margin: 0px;
  181. flex: 1;
  182. white-space: nowrap;
  183. >span {
  184. color: #333;
  185. &:first-child {
  186. display: inline-block;
  187. margin-right: 5px;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>