processList.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <view class="content" :style="`height: ${contentHeight}`">
  3. <z-paging :fixed="false" @query="queryData" :value="list" :default-page-size="pSize" :default-page-no="pageNo"
  4. ref="paging">
  5. <view v-for="(process, index) in list" :key="index">
  6. <uni-card @click="handleToDetail(process)" :isFull="true" padding="10px 0">
  7. <uni-row>
  8. <uni-col :xs="3" :sm="2">
  9. <view class="icon_container">
  10. <text style="font-size: calc(40px + 0.5 * (1rem - 16px));" class="ygoa-icon"
  11. :class="iconDict[process.modelName]"></text>
  12. </view>
  13. </uni-col>
  14. <uni-col :xs="21" :sm="22">
  15. <uni-card padding="0" :isFull="true" :border="false" :is-shadow="false">
  16. <template v-slot:title>
  17. <uni-row>
  18. <uni-col :xs="19" :sm="22" v-if="current !== 0">
  19. <view class="process_title uni-ellipsis">
  20. <text>{{ process.insName }}</text>
  21. </view>
  22. </uni-col>
  23. <uni-col v-else>
  24. <view class="process_title uni-ellipsis">
  25. <text>{{ process.insName }}</text>
  26. </view>
  27. </uni-col>
  28. <uni-col :xs="5" :sm="2" v-if="current !== 0">
  29. <view class="process_status">
  30. <uni-tag v-if="current === 1" text="审批中" type="success"></uni-tag>
  31. <uni-tag v-else-if="current === 2" text="审批中" type="success"></uni-tag>
  32. <uni-tag v-else-if="current === 3" text="已办结" type="primary"></uni-tag>
  33. </view>
  34. </uni-col>
  35. </uni-row>
  36. </template>
  37. <view class="process_contant">
  38. <uni-row>
  39. <uni-col :xs="19" :sm="19">
  40. <view v-if="process.tmodelName == undefined">
  41. <uni-row>
  42. <uni-col :xs="8" :sm="7">流程类型:</uni-col>
  43. <uni-col :xs="16" :sm="17">{{ process.typeName || '无'
  44. }}</uni-col>
  45. </uni-row>
  46. <uni-row>
  47. <uni-col :xs="8" :sm="7">创建时间:</uni-col>
  48. <uni-col :xs="16" :sm="17">{{ process.createdate }}</uni-col>
  49. </uni-row>
  50. </view>
  51. <view v-else @click.stop.prevent="handleCollapseChange(process, index)">
  52. <uni-row>
  53. <uni-col :xs="8" :sm="7">当前流程:</uni-col>
  54. <uni-col :xs="16" :sm="17">
  55. <text style="color: #79abff; text-decoration: underline;">{{
  56. process.tmodelName }}</text>
  57. </uni-col>
  58. </uni-row>
  59. <uni-row>
  60. <uni-col :xs="8" :sm="7">创建时间:</uni-col>
  61. <uni-col :xs="16" :sm="17">{{ process.createdate }}</uni-col>
  62. </uni-row>
  63. </view>
  64. </uni-col>
  65. <uni-col :xs="5" :sm="5" v-if="process.isCancel == '1'">
  66. <uni-row>
  67. <button type="warn" size="mini"
  68. @click.stop.prevent="handleToCancel(process)">撤回</button>
  69. </uni-row>
  70. </uni-col>
  71. </uni-row>
  72. </view>
  73. </uni-card>
  74. </uni-col>
  75. </uni-row>
  76. </uni-card>
  77. <uni-collapse v-if="process.flowStepItem != undefined">
  78. <uni-collapse-item :border="false" :show-arrow="false" :open="process.flowStepItem.show">
  79. <template v-slot:title>
  80. <!-- <view class="flow_step_section">
  81. <uni-section title="当前流程" type="line" titleFontSize="0.8rem"></uni-section>
  82. </view> -->
  83. </template>
  84. <view class="flow_step_container">
  85. <up-steps class="up_step_view" :current="process.flowStepItem.stepActive"
  86. activeColor="#18bc37" inactiveColor="#2979ff" direction="column">
  87. <view v-for="(step, index) in process.flowStepItem.options" :key="index">
  88. <up-steps-item :contentClass="'redcontent'" v-if="step.state == '3'"
  89. :title="step.title + ' 退回'" :desc="step.desc" error></up-steps-item>
  90. <up-steps-item :contentClass="'redcontent'" v-else-if="step.state == '0'"
  91. :title="step.title + ' 撤销'" :desc="step.desc" error></up-steps-item>
  92. <up-steps-item v-else-if="step.state == '8' || step.state == '9'"
  93. :title="step.title + ' 回收'" :desc="step.desc" error></up-steps-item>
  94. <up-steps-item v-else-if="index == process.flowStepItem.stepActive"
  95. :title="step.title" :desc="step.desc">
  96. <template #icon>
  97. <view class="active_step_circle">
  98. <text class="active_step_text">{{ index + 1 }}</text>
  99. </view>
  100. </template>
  101. </up-steps-item>
  102. <up-steps-item v-else :title="step.title" :desc="step.desc"></up-steps-item>
  103. </view>
  104. </up-steps>
  105. </view>
  106. </uni-collapse-item>
  107. </uni-collapse>
  108. </view>
  109. </z-paging>
  110. </view>
  111. </template>
  112. <script setup lang="ts">
  113. import { ref } from 'vue';
  114. import { getProcessFlow } from '@/api/process'
  115. import { useUserStore } from '@/store/user.js'
  116. const userStore = useUserStore()
  117. const iconDict = {
  118. '外协结算申请': 'icon-outsourcing',
  119. '用车申请': 'icon-apply-car',
  120. '出差申请': 'icon-apply-business',
  121. '外出申请': 'icon-apply-out',
  122. '费用报销申请': 'icon-apply-expense',
  123. '加班申请': 'icon-apply-overtime',
  124. '请假申请': 'icon-apply-leave',
  125. '采购申请': 'icon-apply-purchase',
  126. '合同会签': 'icon-apply-sign-contract'
  127. }
  128. const props = defineProps({
  129. contentHeight: { type: String, default: '85vh' },
  130. current: { type: Number, default: 0 }, // 消息类型
  131. pSize: { type: Number, default: 10 }, // 分页大小
  132. pageNo: { type: Number, default: 1 }, // 默认页
  133. })
  134. const emits = defineEmits([
  135. 'clickSegment', // 点击分段器
  136. 'clickItem', // 点击内容项
  137. 'scrollToBottom', // 到达底部
  138. 'clickCancel', // 点击取消按钮
  139. ])
  140. const paging = ref(null)
  141. // 加载完成 更新数据
  142. const list = ref([])
  143. const totalPage = ref(0)
  144. function handleCollapseChange(process, index) {
  145. // console.log('handleCollapseChange', process);
  146. if (list.value[index].flowStepItem == undefined) {
  147. getProcessFlow(userStore.user.useId, process).then(({ returnParams }) => {
  148. const flowStepItem = {
  149. options: [],
  150. stepActive: -1,
  151. show: true
  152. }
  153. flowStepItem.options = returnParams.list.map((item, index) => {
  154. const { tmodelName, name, createdate, finishdate, remark, state } = item
  155. if (state == 1) {
  156. flowStepItem.stepActive = index
  157. }
  158. const title = tmodelName + (name == '' ? '' : ' ( ' + name + ' )')
  159. const desc = (finishdate == '' ? '\n' : '办理时间: ' + finishdate)
  160. return {
  161. title,
  162. desc,
  163. state
  164. }
  165. })
  166. if (flowStepItem.stepActive === -1) flowStepItem.stepActive = returnParams.list.length
  167. list.value[index]['flowStepItem'] = flowStepItem
  168. })
  169. return
  170. }
  171. list.value[index].flowStepItem.show = !list.value[index].flowStepItem.show
  172. }
  173. function complete(dataList, total, pageNo) {
  174. totalPage.value = Math.ceil(total / props.pSize)
  175. if (pageNo <= totalPage.value) {
  176. list.value.push(...dataList);
  177. }
  178. // 第一页直接加载数据
  179. if (pageNo === 1) {
  180. list.value = dataList
  181. paging.value.complete(dataList)
  182. return
  183. }
  184. // 防止重复获取最后一次信息
  185. if (props.pSize * pageNo < total) {
  186. paging.value.complete(dataList)
  187. } else {
  188. paging.value.complete([])
  189. }
  190. }
  191. // 点击分段器
  192. function onClickItem() {
  193. // 重新加载数据 pageNo恢复为默认值
  194. list.value = []
  195. paging.value.reload()
  196. }
  197. // 刷新
  198. function queryData(pageNo, pSize, queryType) {
  199. switch (queryType) {
  200. case 0: // 下拉刷新
  201. case 1: // 初始加载
  202. reloadData()
  203. break
  204. case 3: // 上拉加载
  205. scrollQuery(pageNo, pSize)
  206. break
  207. default: // 默认刷新
  208. reloadData()
  209. break
  210. }
  211. }
  212. // 刷新数据
  213. function reloadData() {
  214. const params = {
  215. pSize: props.pSize,
  216. pageNo: props.pageNo,
  217. }
  218. emits('clickSegment', params, complete)
  219. }
  220. // 上拉加载
  221. function scrollQuery(pageNo, pSize) {
  222. const params = {
  223. pSize,
  224. pageNo,
  225. }
  226. emits('scrollToBottom', params, complete)
  227. }
  228. function handleToDetail(process) { // 跳转流程详情页
  229. emits('clickItem', process)
  230. }
  231. function handleToCancel(process) {
  232. emits('clickCancel', process)
  233. }
  234. defineExpose({
  235. onClickItem,
  236. });
  237. </script>
  238. <style lang="scss" scoped>
  239. @import url("@/static/font/ygoa/iconfont.css");
  240. .flow_step_section {
  241. .uni-section .uni-section-header {
  242. padding: 5px 10px;
  243. }
  244. }
  245. .flow_step_container {
  246. min-height: 100px;
  247. .up_step_view {
  248. ::v-deep .u-steps {
  249. .u-steps-item {
  250. padding-bottom: 11px;
  251. .redcontent {
  252. .u-text__value--content {
  253. color: #ff4500;
  254. }
  255. }
  256. .active_step_circle {
  257. width: 20px;
  258. height: 20px;
  259. box-sizing: border-box;
  260. flex-shrink: 0;
  261. border-radius: 100px;
  262. border-width: 1px;
  263. border-color: #A78BFA;
  264. background-color: #A78BFA;
  265. border-style: solid;
  266. display: flex;
  267. flex-direction: row;
  268. align-items: center;
  269. justify-content: center;
  270. transition: background-color .3s;
  271. .active_step_text {
  272. color: #fff;
  273. font-size: 0.6875rem;
  274. display: flex;
  275. flex-direction: row;
  276. align-items: center;
  277. justify-content: center;
  278. text-align: center;
  279. line-height: 0.6875rem;
  280. }
  281. }
  282. }
  283. .u-steps-item view:last-of-type {
  284. margin-top: 0 !important;
  285. .u-text__value--content {
  286. font-size: 1rem !important;
  287. }
  288. .u-text__value--main {
  289. font-size: 1rem !important;
  290. }
  291. }
  292. }
  293. }
  294. }
  295. .content {
  296. .icon_container {
  297. margin: 45% 0;
  298. }
  299. .process_title {
  300. // TODO 长度限制15字
  301. line-height: 1.5rem;
  302. font-weight: 500;
  303. font-size: 1.1rem;
  304. margin: 5px 0;
  305. color: #333;
  306. }
  307. .process_status {
  308. margin: 5px 0;
  309. height: 1.5rem;
  310. display: flex;
  311. align-items: center;
  312. justify-content: center;
  313. text-align: center;
  314. white-space: nowrap;
  315. overflow: hidden;
  316. }
  317. .process_contant {
  318. color: #777;
  319. }
  320. }
  321. </style>