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