index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <view class="process_detail_container">
  3. <uni-card>
  4. <view class="main_container">
  5. <uni-section titleFontSize="1.3rem" title="申请内容" type="line"></uni-section>
  6. <uni-list>
  7. <uni-list-item v-for="(elem, index) in formElements" :key="index">
  8. <template v-slot:header>
  9. <text class="element_name">{{ elem.elementName }}</text>
  10. </template>
  11. <template v-slot:footer>
  12. <view class="element_value">
  13. <view v-if="elem.canEdit == '1'" class="element_value">
  14. <uni-easyinput v-if="'1' == elem.type" placeholder="请输入内容"
  15. v-model="elem.defaultValue" type="textarea"></uni-easyinput>
  16. </view>
  17. <text v-else>{{ elem.defaultValue }}</text>
  18. </view>
  19. </template>
  20. </uni-list-item>
  21. </uni-list>
  22. </view>
  23. </uni-card>
  24. <view>
  25. <!-- 重复表 -->
  26. <uni-card v-if="repeatingFormNotEmpty" spacing="0" padding="0">
  27. <button @click="handlerepeatingForm" type="primary">查看重复表</button>
  28. </uni-card>
  29. <uni-popup v-if="repeatingFormNotEmpty" ref="repeatingFormPopup">
  30. <uni-card margin="0px" spacing="0px" padding="0px">
  31. <view class="repeating_table_container">
  32. <uni-table :border="true" stripe>
  33. <uni-tr>
  34. <uni-th align="center" v-for="(item, index) in repeatingForm.elementItem" :key="index">
  35. {{ item.elementName.slice(3, 5) }}
  36. </uni-th>
  37. </uni-tr>
  38. <uni-tr
  39. v-for="(item, index) in (repeatingForm.elements.length / repeatingForm.elementItem.length)"
  40. :key="index">
  41. <uni-td align="center" v-for="col in repeatingForm.elementItem.length" :key="col">
  42. <!-- (列数 - 1) * 总行数 + 当前行数 -->
  43. {{ repeatingForm.elements[(col - 1) * (repeatingForm.elements.length /
  44. repeatingForm.elementItem.length) + index]!.defaultValue }}
  45. </uni-td>
  46. </uni-tr>
  47. </uni-table>
  48. </view>
  49. </uni-card>
  50. </uni-popup>
  51. </view>
  52. <!-- 附件 -->
  53. <view v-for="(item, index) in fileList" :key="index">
  54. <uni-card v-if="item.files.length != undefined && item.files.length > 0">
  55. <uni-section titleFontSize="1.3rem" title="附件" type="line"></uni-section>
  56. <attachment-list :attachments="item.files"></attachment-list>
  57. </uni-card>
  58. </view>
  59. <view>
  60. <uni-card>
  61. <view class="flow_step_container">
  62. <uni-section titleFontSize="1.3rem" title="流转过程" type="line"></uni-section>
  63. <up-steps :current="stepActive" activeColor="#18bc37" inactiveColor="#2979ff" direction="column">
  64. <view v-for="(step, index) in options">
  65. <up-steps-item v-if="step.state == 3" :title="step.title + ' 退回'" :desc="step.desc"
  66. :key="index" error></up-steps-item>
  67. <up-steps-item v-else-if="step.state == 0" :title="step.title + ' 撤销'" :desc="step.desc"
  68. :key="index" error></up-steps-item>
  69. <up-steps-item v-else-if="index == stepActive" :title="step.title" :desc="step.desc"
  70. :key="index">
  71. <template #icon>
  72. <view class="active_step_circle">
  73. <text class="active_step_text">{{ index + 1 }}</text>
  74. </view>
  75. </template>
  76. </up-steps-item>
  77. <up-steps-item v-else :title="step.title" :desc="step.desc" :key="index"></up-steps-item>
  78. </view>
  79. </up-steps>
  80. </view>
  81. </uni-card>
  82. </view>
  83. <view v-if="processInfo.tinsId">
  84. <view class="remark_container">
  85. <uni-card>
  86. <uni-section titleFontSize="1.3rem" title="环节备注" type="line"></uni-section>
  87. <view class="remark_content">
  88. <uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入"></uni-easyinput>
  89. </view>
  90. </uni-card>
  91. </view>
  92. </view>
  93. <view v-if="processInfo.tinsId" class="approve_button">
  94. <uni-card spacing="0" padding="0">
  95. <button :loading="!button_state" type="primary" @click="handleSubmitProcess('1')">通过</button>
  96. </uni-card>
  97. </view>
  98. </view>
  99. <view v-if="processInfo.tinsId">
  100. <view class="reject_button">
  101. <uni-card spacing="0" padding="0" :is-shadow="false" :border="false">
  102. <uni-row>
  103. <uni-col :span="11">
  104. <button :loading="!button_state" type="warn" @click="handleSubmitProcess('0')">退回上一级</button>
  105. </uni-col>
  106. <uni-col :span="11" :offset="2">
  107. <button :loading="!button_state" type="warn" @click="handleSubmitProcess('2')">退回发起人</button>
  108. </uni-col>
  109. </uni-row>
  110. </uni-card>
  111. </view>
  112. </view>
  113. <view v-else-if="processInfo.username == userStore.user.name">
  114. <view class="remark_container">
  115. <uni-card>
  116. <uni-section titleFontSize="1.3rem" title="撤销备注" type="line"></uni-section>
  117. <view class="remark_content">
  118. <uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入"></uni-easyinput>
  119. </view>
  120. </uni-card>
  121. </view>
  122. <view class="cancel_button_container">
  123. <uni-card spacing="0" padding="0">
  124. <button :loading="!button_state" type="warn" @click="handleCancelProcess">撤销</button>
  125. </uni-card>
  126. </view>
  127. </view>
  128. <view style="height: 5px; margin-top: 20px;"></view>
  129. </template>
  130. <script setup lang="ts">
  131. import { onMounted, reactive, ref } from 'vue'
  132. import { onLoad } from '@dcloudio/uni-app'
  133. import attachmentList from '@/components/ygoa/attachmentList.vue'
  134. import $tab from '@/plugins/tab.js'
  135. import $modal from '@/plugins/modal.js'
  136. import { getProcessFlowInfo, getProcessFormInfo, getProcessFormInfoInFlow, getProcessFlow, submitProcessFlow, cancelProcessFlow } from '@/api/process.js'
  137. import { useUserStore } from '@/store/user.js'
  138. const userStore = useUserStore()
  139. const processInfo = reactive({
  140. insId: '',
  141. insName: '',
  142. control: 1,
  143. username: '',
  144. tinsId: undefined
  145. })
  146. onLoad(({ username, insId, tinsId, insName, control }) => {
  147. // 获取传入的标题参数
  148. const title = insName || '流程信息';
  149. processInfo.insId = insId
  150. processInfo.insName = insName
  151. processInfo.control = control
  152. processInfo.username = username
  153. if (tinsId) {
  154. processInfo['tinsId'] = tinsId
  155. }
  156. // 设置导航栏标题
  157. uni.setNavigationBarTitle({
  158. title: title
  159. });
  160. })
  161. onMounted(() => {
  162. initProcessInfo()
  163. initProcessFlow()
  164. })
  165. const repeatingForm = ref({
  166. elements: [],
  167. elementItem: [],
  168. })
  169. const repeatingFormNotEmpty = ref(false)
  170. function repeatingFormHasValue() {
  171. if (repeatingForm.value === undefined) return
  172. if (repeatingForm.value.elementItem.length <= 0) return
  173. repeatingForm.value.elements.forEach(({ defaultValue }) => {
  174. if (defaultValue != "") {
  175. repeatingFormNotEmpty.value = true
  176. return new Promise((resolve, reject) => {
  177. resolve(repeatingFormNotEmpty)
  178. })
  179. }
  180. })
  181. }
  182. const formElements = ref([])
  183. const formInfo = ref({
  184. formElements: [],
  185. formId: '',
  186. formInsId: ''
  187. })
  188. const fileList = ref([])
  189. function initProcessInfo() {
  190. if (processInfo.tinsId) {
  191. getProcessFormInfoInFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  192. formElements.value = returnParams.formElements
  193. formInfo.value = returnParams.formInfo[0]
  194. repeatingForm.value = returnParams.repeatingForm
  195. // fileList.value = returnParams.fileList
  196. repeatingFormHasValue()
  197. })
  198. } else {
  199. getProcessFormInfo(userStore.user.useId, processInfo.insId).then(({ returnParams }) => {
  200. formElements.value = returnParams.formElements
  201. repeatingForm.value = returnParams.repeatingForm
  202. fileList.value = returnParams.fileList
  203. repeatingFormHasValue()
  204. })
  205. }
  206. }
  207. const options = ref([])
  208. const stepActive = ref(-1)
  209. const flowInfo = ref({})
  210. function initProcessFlow() {
  211. getProcessFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  212. options.value = returnParams.list.map((item, index) => {
  213. const { tmodelName, name, createdate, finishdate, remark, state } = item
  214. if (state == 1) {
  215. stepActive.value = index
  216. }
  217. const title = tmodelName + (name == '' ? '' : ' ( ' + name + ' )')
  218. const desc = '创建时间: ' + createdate
  219. + (finishdate == '' ? '\n' : '\n办理时间: ' + finishdate)
  220. + (remark == '' ? '\n' : '\n环节意见: ' + remark)
  221. return {
  222. title,
  223. desc,
  224. state
  225. }
  226. })
  227. if (stepActive.value === -1) stepActive.value = returnParams.list.length
  228. // 获取未完成过程
  229. if (processInfo.tinsId) {
  230. getProcessFlowInfo(userStore.user.useId, processInfo).then(({ returnParams }) => {
  231. options.value.push({ title: returnParams.nextTmodels[0].nextTmodelName })
  232. flowInfo.value = returnParams.flow[0]
  233. fileList.value = [
  234. { files: returnParams.flow[0].files }
  235. ]
  236. })
  237. }
  238. })
  239. }
  240. const repeatingFormPopup = ref(null)
  241. function handlerepeatingForm() {
  242. repeatingFormPopup.value.open()
  243. }
  244. const button_state = ref(true)
  245. const remark = ref('')
  246. function handleSubmitProcess(result) {
  247. let content = '确认退回'
  248. if (result == "1") {
  249. content = '确认通过'
  250. }
  251. $modal.confirm(content).then(() => {
  252. submitProcess(result)
  253. }).catch(() => { })
  254. }
  255. function submitProcess(result) {
  256. formInfo.value.formElements = formElements.value.map(({ tableField, defaultValue }) => {
  257. return {
  258. name: tableField,
  259. value: defaultValue
  260. }
  261. })
  262. let flow = Object.assign({}, flowInfo.value)
  263. flow['staffId'] = userStore.user.useId
  264. flow['gxId'] = userStore.user.gxId
  265. flow['groupId'] = flowInfo.value.groupid
  266. flow['fileIds'] = ''
  267. // result: 1通过 2退回发起人 0退回上一级
  268. flow['result'] = result
  269. flow['remark'] = remark.value
  270. flow['nextTmodelId'] = 'undefined'
  271. submitProcessFlow(flow, formInfo.value, processInfo.control).then(({ returnMsg }) => {
  272. if (returnMsg.includes('提交失败')) {
  273. // 启用提交按钮
  274. button_state.value = true
  275. $modal.msgError(returnMsg)
  276. } else {
  277. $modal.msgSuccess(returnMsg)
  278. // 通知列表刷新数据
  279. uni.$emit('ReloadProcessData');
  280. setTimeout(() => {
  281. $tab.navigateBack();
  282. }, 1000)
  283. }
  284. })
  285. }
  286. function handleCancelProcess() {
  287. $modal.confirm('确认撤销').then(() => {
  288. cancelProcess()
  289. }).catch(() => { })
  290. }
  291. function cancelProcess() {
  292. cancelProcessFlow(userStore.user.useId, remark.value, processInfo).then(({ returnMsg }) => {
  293. if (returnMsg.includes('success')) {
  294. $modal.msgSuccess('撤销成功')
  295. // 通知列表刷新数据
  296. uni.$emit('ReloadProcessData');
  297. setTimeout(() => {
  298. $tab.navigateBack();
  299. }, 1000)
  300. } else {
  301. // 启用按钮
  302. button_state.value = true
  303. $modal.msgError(returnMsg)
  304. }
  305. })
  306. }
  307. </script>
  308. <style lang="scss">
  309. .element_name {
  310. width: 10rem;
  311. font-weight: 600;
  312. }
  313. .element_value {
  314. width: 60%;
  315. }
  316. .uni-section {
  317. margin-left: -15px;
  318. margin-bottom: 10px;
  319. }
  320. .process_detail_container {
  321. position: relative;
  322. .main_container {
  323. min-height: 70vh;
  324. }
  325. .repeating_table_container {
  326. width: 98vw;
  327. .uni-table-scroll {
  328. max-height: 80vh;
  329. .uni-table {
  330. min-width: 100% !important;
  331. .uni-table-th {
  332. min-width: 50px;
  333. background-color: #2979ff;
  334. font-weight: bold;
  335. color: #fcfcfc;
  336. }
  337. }
  338. }
  339. }
  340. .flow_step_container {
  341. min-height: 200px;
  342. .u-steps {
  343. .u-steps-item {
  344. padding-bottom: 11px;
  345. .active_step_circle {
  346. width: 20px;
  347. height: 20px;
  348. box-sizing: border-box;
  349. flex-shrink: 0;
  350. border-radius: 100px;
  351. border-width: 1px;
  352. border-color: #A78BFA;
  353. background-color: #A78BFA;
  354. border-style: solid;
  355. display: flex;
  356. flex-direction: row;
  357. align-items: center;
  358. justify-content: center;
  359. transition: background-color .3s;
  360. .active_step_text {
  361. color: #fff;
  362. font-size: 11px;
  363. display: flex;
  364. flex-direction: row;
  365. align-items: center;
  366. justify-content: center;
  367. text-align: center;
  368. line-height: 11px;
  369. }
  370. }
  371. }
  372. .u-steps-item view:last-of-type {
  373. margin-top: 0 !important;
  374. .u-text__value--content {
  375. font-size: 16px !important;
  376. }
  377. .u-text__value--main {
  378. font-size: 16px !important;
  379. }
  380. }
  381. }
  382. }
  383. .remark_container {
  384. .remark_content {
  385. margin-bottom: 10px;
  386. }
  387. }
  388. .approve_button {
  389. position: sticky;
  390. z-index: 999;
  391. width: 100%;
  392. bottom: 10px;
  393. }
  394. .reject_button {
  395. ::v-deep uni-card {
  396. background-color: #f5f5f5;
  397. }
  398. }
  399. }
  400. </style>