index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class='purchase-list'>
  3. <my-tabs @change="tapChange" :modelData="modelData" :initIndex="initIndex"></my-tabs>
  4. <scroll-view class="purchase-body" scroll-y="true" @scrolltolower="scrolltolower" @scrolltoupper="scrolltoupper" @scroll="scroll" @touchstart="touchstart" @touchend="touchend">
  5. <view class="searchBox">
  6. <uni-search-bar placeholder="请输入搜索内容" @confirm="search" @blur="blur" @cancel="cancel" @clear="clear">
  7. </uni-search-bar>
  8. </view>
  9. <my-unit v-for="(item,index) in listData" :key="index" :info="item" :initIndex="initIndex" @faClick="handdle"></my-unit>
  10. </scroll-view>
  11. <!-- 底部弹窗 -->
  12. <uni-popup ref="popup" background-color="#fff" border-radius="10px 10px 0 0">
  13. <view class="popup-body">
  14. <view class="popup-close">
  15. <uni-icons type="closeempty" size="20" @click="closePopup"></uni-icons>
  16. </view>
  17. <view class="popup-content">
  18. <async-form-component :id="businessKey" :name="initIndex.toString()" @popupClose="popupClose"></async-form-component>
  19. </view>
  20. </view>
  21. </uni-popup>
  22. </view>
  23. </template>
  24. <script>
  25. import Vue from 'vue'
  26. import { getTodoTaskPage, getDoneTaskPage,getMyProcessInstancePage } from "@/api/work/index"
  27. import myTabs from '@/components/myTabs/myTabs.vue'
  28. import myUnit from '@/components/myUnits/purchaseUnit/unit.vue'
  29. import myPull from '@/static/js/myPull.js'
  30. export default {
  31. components:{myTabs,myUnit},
  32. data() {
  33. return {
  34. name:'',
  35. businessKey:'',
  36. initIndex:0,
  37. pageNo: 1,
  38. pageSize: 10
  39. }
  40. },
  41. onShow(){
  42. let option = uni.getStorageSync('option');
  43. this.initIndex = option.initIndex?option.initIndex:0;
  44. this.refresh();
  45. },
  46. methods: {
  47. search(res) {
  48. this.name = res.value;
  49. this.page = 1;
  50. this.getList(this.page,this.__pulldone)
  51. },
  52. clear(res) {
  53. this.name = '';
  54. this.page = 1;
  55. this.getList(this.page,this.__pulldone)
  56. },
  57. blur(res) {
  58. this.name = res.value;
  59. this.page = 1;
  60. this.getList(this.page,this.__pulldone)
  61. },
  62. cancel(res) {
  63. this.name = '';
  64. this.page = 1;
  65. this.getList(this.page,this.__pulldone)
  66. },
  67. handdle(row) {
  68. this.businessKey = row.businessKey;
  69. //将业务表单,注册为动态组件
  70. const path = row.path;
  71. console.log("path:" + path)
  72. Vue.component("async-form-component", function (resolve) {
  73. require([`@/pages${path}`], resolve);
  74. });
  75. this.$refs.popup.open('bottom');
  76. },
  77. closePopup(){
  78. this.$refs.popup.close();
  79. },
  80. popupClose(){
  81. this.$refs.popup.close();
  82. // this.page = 1;
  83. // this.getList(this.page,this.__pulldone)
  84. setTimeout(() => {
  85. this.$router.go(0)
  86. }, 500)
  87. },
  88. /**
  89. * @name 获取列表
  90. */
  91. getList(page,done){
  92. console.log(`获取第${page}页数据`);
  93. if(this.initIndex==0){
  94. getTodoTaskPage({pageNo:page,pageSize: this.pageSize,name:this.name}).then(response => {
  95. let dataList = response.data.list;
  96. let list = []
  97. dataList.forEach(v => {
  98. list.push({
  99. businessKey:v.processInstance.businessKey,
  100. path:v.taskDefinitionKey == 'modifyApply' ? v.processDefinition.formCustomCreatePath : v.processDefinition.formCustomViewPath,
  101. title:v.processInstance.name,
  102. status: v.name,
  103. time:v.createTime,
  104. nickname:v.processInstance.startUser.nickname
  105. })
  106. })
  107. done(list);
  108. });
  109. }
  110. if(this.initIndex==1){
  111. getDoneTaskPage({pageNo:page,pageSize: this.pageSize,name:this.name}).then(response => {
  112. let dataList = response.data.list;
  113. let list = []
  114. dataList.forEach(v => {
  115. list.push({
  116. businessKey:v.processInstance.businessKey,
  117. path:v.processDefinition.formCustomViewPath,
  118. title:v.processInstance.name,
  119. status: v.name,
  120. time:v.createTime,
  121. nickname:v.processInstance.startUser.nickname
  122. })
  123. })
  124. done(list);
  125. });
  126. }
  127. if(this.initIndex==2){
  128. getMyProcessInstancePage({pageNo:page,pageSize: this.pageSize,name:this.name}).then(response => {
  129. let dataList = response.data.list;
  130. let list = []
  131. dataList.forEach(v => {
  132. list.push({
  133. businessKey:v.businessKey,
  134. path:v.processDefinition.formCustomViewPath,
  135. title:v.name,
  136. status: v.statusDesc,
  137. time:v.startTime,
  138. nickname:v.currentAuditUser?v.currentAuditUser.nickname:''
  139. })
  140. })
  141. done(list);
  142. });
  143. }
  144. },
  145. /**
  146. * @name 触底加载
  147. */
  148. scrolltolower(event){
  149. this.getList(this.page,this.__pulldone)
  150. },
  151. scroll(e){
  152. // 重新设置pulldown
  153. this.setPullDown(e.detail.scrollTop<10)
  154. },
  155. scrolltoupper(){
  156. },
  157. /**
  158. * @name 改变tab
  159. * @param val 索引
  160. */
  161. tapChange(val){
  162. this.initIndex=val;
  163. uni.setStorageSync('option',{initIndex:val, val:'switchTab'})
  164. this.page = 1;
  165. this.getList(this.page,this.__pulldone)
  166. }
  167. },
  168. mixins:[myPull({})],
  169. }
  170. </script>
  171. <style lang='scss' scoped>
  172. .searchBox{
  173. background-color: #fff;
  174. position: -webkit-sticky; /* Safari */
  175. position: sticky;
  176. top: 0; /* 设置元素距离顶部的位置 */
  177. width: 100%;
  178. }
  179. .popup-body{
  180. z-index: 99;
  181. }
  182. .popup-close{
  183. cursor: pointer;
  184. height: 40px;
  185. line-height: 40px;
  186. padding-left: 10px;
  187. border-bottom: 1px solid #eaecef;
  188. }
  189. .popup-content{
  190. height: 550px;
  191. overflow-x: auto;
  192. padding-bottom: 50px;
  193. }
  194. .purchase-list {
  195. background-color: #f5f5f5;
  196. height: 100%;
  197. overflow: hidden;
  198. .purchase-body{
  199. height: calc(100% - 88upx);
  200. overflow: auto
  201. }
  202. }
  203. </style>