index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="order-v">
  3. <view class="head-warp com-dropdown">
  4. <u-dropdown class="u-dropdown" ref="uDropdown">
  5. <u-dropdown-item :title="$t('app.apply.sort')" :options="sortOptions">
  6. <view class="screen-box">
  7. <view class="screen-list">
  8. <view class="u-p-l-20 u-p-r-20 list">
  9. <scroll-view scroll-y="true" style="height: 100%;">
  10. <u-cell-group>
  11. <u-cell-item @click="cellClick(item)" :arrow="false" :title="item.label"
  12. v-for="(item, index) in sortOptions" :key="index" :title-style="{
  13. color: sortValue.includes(item.value)? '#2979ff' : '#606266' }">
  14. <u-icon v-if="sortValue.includes(item.value)" name="checkbox-mark"
  15. color="#2979ff" size="32"></u-icon>
  16. </u-cell-item>
  17. </u-cell-group>
  18. </scroll-view>
  19. </view>
  20. <view class="u-flex screen-btn">
  21. <text @click="handleSortReset" class="btn btn1">{{$t('common.cleanText')}}</text>
  22. <text @click="handleSortSearch" class="btn btn2">{{$t('common.okText')}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </u-dropdown-item>
  27. <u-dropdown-item :title="$t('app.apply.screen')">
  28. <view class="screen-box u-flex-col">
  29. <view class="screen-list">
  30. <view class="u-p-l-20 u-p-r-20 list">
  31. <scroll-view scroll-y="true" style="height: 100%;">
  32. <u-form label-position="left" label-width="150" label-align="left">
  33. <u-form-item :label="$t('component.jnpf.dateRange.startPlaceholder')"
  34. prop="startTime">
  35. <JnpfDatePicker v-model="listQuery.startTime" />
  36. </u-form-item>
  37. <u-form-item :label="$t('component.jnpf.dateRange.endPlaceholder')"
  38. prop="endTime">
  39. <JnpfDatePicker v-model="listQuery.endTime" />
  40. </u-form-item>
  41. </u-form>
  42. </scroll-view>
  43. </view>
  44. <view class="u-flex screen-btn">
  45. <text @click="reset" class="btn btn1">{{$t('component.cropper.btn_reset')}}</text>
  46. <text @click="closeDropdown" class="btn btn2">{{$t('common.queryText')}}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </u-dropdown-item>
  51. </u-dropdown>
  52. </view>
  53. <view class="list-warp">
  54. <mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" top="100"
  55. :up="upOption">
  56. <view class="flow-list">
  57. <uni-swipe-action ref="swipeAction">
  58. <uni-swipe-action-item v-for="(item, index) in list" :key="item.id" :right-options="options"
  59. @click="handleClick(index)">
  60. <view class="order-item" @click="goDetail(item.id,item.currentState,item.flowId)"
  61. :id="'item'+index">
  62. <view class="order-item-title u-border-bottom">
  63. <text class="order-title u-line-1">{{item.customerName}}</text>
  64. </view>
  65. <view class="order-item-down">
  66. <view class="order-item-cell u-flex">
  67. <text class="time">{{item.orderCode}}</text>
  68. <text :class="'status '+getFlowStatus(item.currentState).statusCss">
  69. {{getFlowStatus(item.currentState).text}}
  70. </text>
  71. </view>
  72. <view class="order-item-cell u-flex">
  73. <text class="time">{{item.salesmanName}}</text>
  74. <text class="time">{{$u.timeFormat(item.orderDate,'yyyy-mm-dd')}}</text>
  75. </view>
  76. </view>
  77. </view>
  78. </uni-swipe-action-item>
  79. </uni-swipe-action>
  80. </view>
  81. </mescroll-uni>
  82. </view>
  83. <view class="com-addBtn" @click="addPage()" v-if="showAddBtn">
  84. <u-icon name="plus" size="48" color="#fff" />
  85. </view>
  86. <u-picker mode="selector" v-model="show" :default-selector="[0]" title="请选择流程" :range="selector"
  87. range-key="fullName" @confirm="confirm"></u-picker>
  88. </view>
  89. </template>
  90. <script>
  91. import resources from '@/libs/resources.js'
  92. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  93. import {
  94. getOrderList,
  95. Delete
  96. } from '@/api/apply/order'
  97. import {
  98. getFlowStartFormId
  99. } from '@/api/workFlow/flowEngine'
  100. export default {
  101. mixins: [MescrollMixin],
  102. data() {
  103. return {
  104. templateId: '',
  105. selector: [],
  106. show: false,
  107. sortValue: [],
  108. sortOptions: [{
  109. label: '单据升序',
  110. value: 1,
  111. },
  112. {
  113. label: '单据降序',
  114. value: 2,
  115. },
  116. {
  117. label: '日期升序',
  118. value: 3,
  119. },
  120. {
  121. label: '日期降序',
  122. value: 4,
  123. }
  124. ],
  125. upOption: {
  126. page: {
  127. num: 0,
  128. size: 20,
  129. time: null
  130. },
  131. empty: {
  132. icon: resources.message.nodata,
  133. tip: this.$t('common.noData'),
  134. top: "300rpx"
  135. },
  136. textNoMore: this.$t('app.apply.noMoreData'),
  137. toTop: {
  138. bottom: 250
  139. }
  140. },
  141. list: [],
  142. listQuery: {
  143. sort: 'desc',
  144. sidx: '',
  145. keyword: '',
  146. startTime: '',
  147. endTime: ''
  148. },
  149. options: [{
  150. text: '删除',
  151. style: {
  152. backgroundColor: '#dd524d'
  153. }
  154. }],
  155. menuId: '',
  156. flowId: '585361795057715206',
  157. key: +new Date()
  158. }
  159. },
  160. computed: {
  161. showAddBtn() {
  162. return this.$permission.hasBtnP('btn_add', this.menuId)
  163. }
  164. },
  165. onLoad(e) {
  166. this.menuId = e.menuId
  167. },
  168. onShow() {
  169. this.$nextTick(() => {
  170. this.list = [];
  171. this.mescroll.resetUpScroll();
  172. })
  173. },
  174. onUnload() {
  175. uni.$off('refresh')
  176. },
  177. methods: {
  178. confirm(e) {
  179. this.jumPage()
  180. },
  181. upCallback(page) {
  182. let query = {
  183. currentPage: page.num,
  184. pageSize: page.size,
  185. flowId: this.flowId,
  186. ...this.listQuery
  187. }
  188. getOrderList(query, {
  189. load: page.num == 1
  190. }).then(res => {
  191. if (page.num == 1) this.list = [];
  192. this.mescroll.endSuccess(res.data.list.length);
  193. const list = res.data.list.map(o => ({
  194. show: false,
  195. ...o
  196. }));
  197. this.list = this.list.concat(list);
  198. this.$nextTick(() => {
  199. this.key = +new Date()
  200. })
  201. }).catch(() => {
  202. this.mescroll.endErr();
  203. })
  204. },
  205. handleClick(index, index1) {
  206. const item = this.list[index]
  207. if ([1, 2, 3, 5].includes(item.currentState)) {
  208. this.$u.toast("流程正在审核,请勿删除")
  209. this.list[index].show = false
  210. return
  211. }
  212. if (!this.$permission.hasBtnP('btn_remove', this.menuId)) return this.$u.toast("未开启删除权限")
  213. Delete(item.id).then(res => {
  214. this.$u.toast(res.msg)
  215. this.list.splice(index, 1)
  216. if (!this.list.length) this.mescroll.resetUpScroll()
  217. })
  218. this.$nextTick(() => {
  219. this.key = +new Date()
  220. })
  221. },
  222. open(index) {
  223. this.list[index].show = true;
  224. this.list.map((val, idx) => {
  225. if (index != idx) this.list[idx].show = false;
  226. })
  227. },
  228. search() {
  229. this.searchTimer && clearTimeout(this.searchTimer)
  230. this.searchTimer = setTimeout(() => {
  231. this.list = [];
  232. this.mescroll.resetUpScroll();
  233. }, 300)
  234. },
  235. addPage() {
  236. this.jumPage()
  237. },
  238. jumPage(id, status) {
  239. let opType = '-1'
  240. if ([1, 2, 4, 5, 6].includes(status)) opType = 0
  241. const config = {
  242. id: id,
  243. flowId: this.flowId,
  244. opType: opType,
  245. status: status,
  246. }
  247. uni.navigateTo({
  248. url: '/pages/workFlow/flowBefore/index?config=' +
  249. this.jnpf.base64.encode(JSON.stringify(config))
  250. })
  251. },
  252. goDetail(id, status, flowId) {
  253. if (!this.$permission.hasBtnP('btn_edit', this.menuId) && status == 3) return
  254. if (!this.$permission.hasBtnP('btn_detail', this.menuId) && [1, 2, 4, 5, 6].includes(status)) return
  255. this.jumPage(id, status)
  256. },
  257. getFlowStatus(val) {
  258. let status
  259. switch (val) {
  260. case 0:
  261. status = {
  262. text: '等待提交',
  263. statusCss: 'u-type-info'
  264. }
  265. break;
  266. case 1:
  267. status = {
  268. text: '等待审核',
  269. statusCss: 'u-type-primary'
  270. }
  271. break;
  272. case 2:
  273. status = {
  274. text: '审核通过',
  275. statusCss: 'u-type-success'
  276. }
  277. break;
  278. case 3:
  279. status = {
  280. text: '审核退回',
  281. statusCss: 'u-type-error'
  282. }
  283. break;
  284. case 4:
  285. case 7:
  286. status = {
  287. text: '流程撤回',
  288. statusCss: 'u-type-warning'
  289. }
  290. break;
  291. case 5:
  292. status = {
  293. text: '审核终止',
  294. statusCss: 'u-type-info'
  295. }
  296. break;
  297. default:
  298. status = {
  299. text: '等待提交',
  300. statusCss: 'u-type-info'
  301. }
  302. break;
  303. }
  304. return status
  305. },
  306. handleSortReset() {
  307. this.sortValue = []
  308. },
  309. handleSortSearch() {
  310. if (this.sortValue.length) {
  311. this.listQuery.sidx = this.sortValue.join(',')
  312. } else {
  313. this.setDefaultQuery()
  314. }
  315. this.$refs.uDropdown.close();
  316. this.$nextTick(() => {
  317. this.list = [];
  318. this.mescroll.resetUpScroll();
  319. })
  320. },
  321. cellClick(item) {
  322. const findIndex = this.sortValue.findIndex(o => o === item.value);
  323. if (findIndex < 0) {
  324. this.listQuery.sort = item.value == 1 || item.value == 3 ? 'asc' : 'desc'
  325. this.listQuery.sidx = item.value == 1 || item.value == 2 ? 'orderCode' : 'orderDate'
  326. this.sortValue.push(item.value)
  327. } else {
  328. this.sortValue.splice(findIndex, 1)
  329. }
  330. },
  331. reset() {
  332. this.listQuery.startTime = ''
  333. this.listQuery.endTime = ''
  334. },
  335. closeDropdown() {
  336. this.$refs.uDropdown.close();
  337. this.$nextTick(() => {
  338. this.list = [];
  339. this.mescroll.resetUpScroll();
  340. })
  341. }
  342. }
  343. }
  344. </script>
  345. <style lang="scss">
  346. page {
  347. background-color: #f0f2f6;
  348. height: 100%;
  349. /* #ifdef MP-ALIPAY */
  350. position: absolute;
  351. top: 0;
  352. left: 0;
  353. width: 100%;
  354. /* #endif */
  355. }
  356. </style>