index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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="popupClose"></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;
  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. popupClose(){
  78. this.$refs.popup.close();
  79. this.page = 1;
  80. this.getList(this.page,this.__pulldone)
  81. },
  82. /**
  83. * @name 获取列表
  84. */
  85. getList(page,done){
  86. console.log(`获取第${page}页数据`);
  87. if(this.initIndex==0){
  88. getTodoTaskPage({pageNo:page,pageSize: this.pageSize,name:this.name}).then(response => {
  89. let dataList = response.data.list;
  90. let list = []
  91. dataList.forEach(v => {
  92. list.push({
  93. businessKey:v.processInstance.businessKey,
  94. path:v.taskDefinitionKey == 'modifyApply' ? v.processDefinition.formCustomCreatePath : v.processDefinition.formCustomViewPath,
  95. title:v.processInstance.name,
  96. status: v.name,
  97. time:v.createTime,
  98. nickname:v.processInstance.startUser.nickname
  99. })
  100. })
  101. done(list);
  102. });
  103. }
  104. if(this.initIndex==1){
  105. getDoneTaskPage({pageNo:page,pageSize: this.pageSize,name:this.name}).then(response => {
  106. let dataList = response.data.list;
  107. let list = []
  108. dataList.forEach(v => {
  109. list.push({
  110. businessKey:v.processInstance.businessKey,
  111. path:v.processDefinition.formCustomViewPath,
  112. title:v.processInstance.name,
  113. status: v.name,
  114. time:v.createTime,
  115. nickname:v.processInstance.startUser.nickname
  116. })
  117. })
  118. done(list);
  119. });
  120. }
  121. if(this.initIndex==2){
  122. getMyProcessInstancePage({pageNo:page,pageSize: this.pageSize,name:this.name}).then(response => {
  123. let dataList = response.data.list;
  124. let list = []
  125. dataList.forEach(v => {
  126. list.push({
  127. businessKey:v.businessKey,
  128. path:v.processDefinition.formCustomViewPath,
  129. title:v.name,
  130. status: v.status,
  131. time:v.startTime,
  132. nickname:v.currentAuditUser?v.currentAuditUser.nickname:''
  133. })
  134. })
  135. done(list);
  136. });
  137. }
  138. },
  139. /**
  140. * @name 触底加载
  141. */
  142. scrolltolower(event){
  143. this.getList(this.page,this.__pulldone)
  144. },
  145. scroll(e){
  146. // 重新设置pulldown
  147. this.setPullDown(e.detail.scrollTop<10)
  148. },
  149. scrolltoupper(){
  150. },
  151. /**
  152. * @name 改变tab
  153. * @param val 索引
  154. */
  155. tapChange(val){
  156. this.initIndex=val;
  157. uni.setStorageSync('option',{initIndex:val, val:'switchTab'})
  158. this.page = 1;
  159. this.getList(this.page,this.__pulldone)
  160. }
  161. },
  162. mixins:[myPull({})],
  163. }
  164. </script>
  165. <style lang='scss' scoped>
  166. .searchBox{
  167. background-color: #fff;
  168. position: -webkit-sticky; /* Safari */
  169. position: sticky;
  170. top: 0; /* 设置元素距离顶部的位置 */
  171. width: 100%;
  172. }
  173. .popup-body{
  174. z-index: 99;
  175. }
  176. .popup-close{
  177. cursor: pointer;
  178. height: 40px;
  179. line-height: 40px;
  180. padding-left: 10px;
  181. border-bottom: 1px solid #eaecef;
  182. }
  183. .popup-content{
  184. height: 450px;
  185. overflow-x: auto;
  186. padding-bottom: 50px;
  187. }
  188. .purchase-list {
  189. background-color: #f5f5f5;
  190. height: 100%;
  191. overflow: hidden;
  192. .purchase-body{
  193. height: calc(100% - 88upx);
  194. overflow: auto
  195. }
  196. }
  197. </style>