processList.vue 10 KB

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