processList.vue 9.7 KB

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