processList.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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-apply-sign-contract'
  129. }
  130. const props = defineProps({
  131. contentHeight: { type: String, default: '85vh' },
  132. current: { type: Number, default: 0 }, // 消息类型
  133. pSize: { type: Number, default: 10 }, // 分页大小
  134. pageNo: { type: Number, default: 1 }, // 默认页
  135. })
  136. const emits = defineEmits([
  137. 'clickSegment', // 点击分段器
  138. 'clickItem', // 点击内容项
  139. 'scrollToBottom', // 到达底部
  140. 'clickCancel', // 点击取消按钮
  141. ])
  142. const paging = ref(null)
  143. // 加载完成 更新数据
  144. const list = ref([])
  145. const totalPage = ref(0)
  146. function handleCollapseChange(process, index) {
  147. // console.log('handleCollapseChange', process);
  148. if (list.value[index].flowStepItem == undefined) {
  149. getProcessFlow(userStore.user.useId, process).then(({ returnParams }) => {
  150. const flowStepItem = {
  151. options: [],
  152. stepActive: -1,
  153. show: true
  154. }
  155. flowStepItem.options = returnParams.list.map((item, index) => {
  156. const { tmodelName, name, createdate, finishdate, remark, state } = item
  157. if (state == 1) {
  158. flowStepItem.stepActive = index
  159. }
  160. const title = tmodelName + (name == '' ? '' : ' ( ' + name + ' )')
  161. const desc = (finishdate == '' ? '\n' : '办理时间: ' + finishdate)
  162. return {
  163. title,
  164. desc,
  165. state
  166. }
  167. })
  168. if (flowStepItem.stepActive === -1) flowStepItem.stepActive = returnParams.list.length
  169. list.value[index]['flowStepItem'] = flowStepItem
  170. })
  171. return
  172. }
  173. list.value[index].flowStepItem.show = !list.value[index].flowStepItem.show
  174. }
  175. function complete(dataList, total, pageNo) {
  176. totalPage.value = Math.ceil(total / props.pSize)
  177. if (pageNo <= totalPage.value) {
  178. list.value.push(...dataList);
  179. }
  180. // 第一页直接加载数据
  181. if (pageNo === 1) {
  182. list.value = dataList
  183. paging.value.complete(dataList)
  184. return
  185. }
  186. // 防止重复获取最后一次信息
  187. if (props.pSize * pageNo < total) {
  188. paging.value.complete(dataList)
  189. } else {
  190. paging.value.complete([])
  191. }
  192. }
  193. // 点击分段器
  194. function onClickItem() {
  195. // 重新加载数据 pageNo恢复为默认值
  196. list.value = []
  197. paging.value.reload()
  198. }
  199. // 刷新
  200. function queryData(pageNo, pSize, queryType) {
  201. switch (queryType) {
  202. case 0: // 下拉刷新
  203. case 1: // 初始加载
  204. reloadData()
  205. break
  206. case 3: // 上拉加载
  207. scrollQuery(pageNo, pSize)
  208. break
  209. default: // 默认刷新
  210. reloadData()
  211. break
  212. }
  213. }
  214. // 刷新数据
  215. function reloadData() {
  216. const params = {
  217. pSize: props.pSize,
  218. pageNo: props.pageNo,
  219. }
  220. emits('clickSegment', params, complete)
  221. }
  222. // 上拉加载
  223. function scrollQuery(pageNo, pSize) {
  224. const params = {
  225. pSize,
  226. pageNo,
  227. }
  228. emits('scrollToBottom', params, complete)
  229. }
  230. function handleToDetail(process) { // 跳转流程详情页
  231. emits('clickItem', process)
  232. }
  233. function handleToCancel(process) {
  234. emits('clickCancel', process)
  235. }
  236. defineExpose({
  237. onClickItem,
  238. });
  239. </script>
  240. <style lang="scss" scoped>
  241. // @import url("@/static/font/ygoa/iconfont.css");
  242. .flow_step_section {
  243. .uni-section .uni-section-header {
  244. padding: 5px 10px;
  245. }
  246. }
  247. .flow_step_container {
  248. min-height: 100px;
  249. .up_step_view {
  250. ::v-deep .u-steps {
  251. .u-steps-item {
  252. padding-bottom: 11px;
  253. .redcontent {
  254. .u-text__value--content {
  255. color: #ff4500;
  256. }
  257. }
  258. .active_step_circle {
  259. width: 20px;
  260. height: 20px;
  261. box-sizing: border-box;
  262. flex-shrink: 0;
  263. border-radius: 100px;
  264. border-width: 1px;
  265. border-color: #A78BFA;
  266. background-color: #A78BFA;
  267. border-style: solid;
  268. display: flex;
  269. flex-direction: row;
  270. align-items: center;
  271. justify-content: center;
  272. transition: background-color .3s;
  273. .active_step_text {
  274. color: #fff;
  275. font-size: 0.6875rem;
  276. display: flex;
  277. flex-direction: row;
  278. align-items: center;
  279. justify-content: center;
  280. text-align: center;
  281. line-height: 0.6875rem;
  282. }
  283. }
  284. }
  285. .u-steps-item view:last-of-type {
  286. margin-top: 0 !important;
  287. .u-text__value--content {
  288. font-size: 1rem !important;
  289. }
  290. .u-text__value--main {
  291. font-size: 1rem !important;
  292. }
  293. }
  294. }
  295. }
  296. }
  297. .content {
  298. .icon_container {
  299. margin: 45% 0;
  300. }
  301. .process_title {
  302. // TODO 长度限制15字
  303. line-height: 1.5rem;
  304. font-weight: 500;
  305. font-size: 1.1rem;
  306. margin: 5px 0;
  307. color: #333;
  308. }
  309. .process_status {
  310. margin: 5px 0;
  311. height: 1.5rem;
  312. display: flex;
  313. align-items: center;
  314. justify-content: center;
  315. text-align: center;
  316. white-space: nowrap;
  317. overflow: hidden;
  318. }
  319. .process_contant {
  320. color: #777;
  321. }
  322. }
  323. </style>