product.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view>
  3. <view class="bg-white text-gray " style="padding: 20rpx 20rpx;position: fixed;top:0;width: 100%;z-index: 99999;">
  4. <view class="flex justify-between">
  5. <view class=" padding-top-10" style="font-size: 28rpx;">
  6. <u-icon style="margin-left: 20rpx" name="bell-fill"></u-icon>
  7. <text class="margin-left-10">左滑管理项目</text>
  8. </view>
  9. <view @click="add" class="sm cu-btn round base-bg-color" style="font-size: 24rpx;">
  10. <text class="cuIcon-add"></text>
  11. <text style="margin-left: 10rpx;">添加</text>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="" style="height: 80rpx;"></view>
  16. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  17. <u-swipe-action :show="item.show" :vibrate-short="true" btn-width="180" style="margin: 10rpx;" :index="index"
  18. v-for="(item, index) in list" :key="item.id"
  19. @click="click"
  20. @content-click="goDetail"
  21. @open="open"
  22. :options="options">
  23. <view class="item">
  24. <view class="tag" :class="item.tagColor">
  25. <text>{{item.name.substr(0,1)}}</text>
  26. </view>
  27. <view class="padding-left-30 flex flex-direction">
  28. <text class="text-xl">{{item.name}}</text>
  29. <text class="text-df text-gray padding-top-20">{{item.createTime}}</text>
  30. </view>
  31. </view>
  32. </u-swipe-action>
  33. </mescroll-body>
  34. </view>
  35. </template>
  36. <script>
  37. import wmListAdd from '@/components/wm-list-add/wm-list-add';
  38. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  39. export default {
  40. mixins: [MescrollMixin],
  41. data() {
  42. return {
  43. options: [
  44. {
  45. text: '编辑',
  46. style: {
  47. backgroundColor: '#5064eb'
  48. }
  49. },
  50. {
  51. text: '删除',
  52. style: {
  53. backgroundColor: '#dd524d'
  54. }
  55. }
  56. ],
  57. enterpriseId:'',
  58. };
  59. },
  60. onLoad() {
  61. this.enterpriseId=this.$cache.get('enterpriseId')
  62. },
  63. onShow() {
  64. this.$util.reload(this.mescroll)
  65. },
  66. methods: {
  67. click(index, index1) {
  68. if(index1 == 1) {
  69. let id= this.list[index].id
  70. this.$dialog.showModal('确定要删除此项吗?').then(res=>{
  71. this.$api.enterpriseproject.remove(id).then(res=>{
  72. if (res.success==true) {
  73. this.$u.toast('操作成功')
  74. this.reload()
  75. }else{
  76. this.$u.toast(res.msg)
  77. }
  78. })
  79. })
  80. } else {
  81. let item=this.list[index]
  82. let params={
  83. employmentNumber:item.employmentNumber,
  84. enterpriseId:item.enterpriseId,
  85. id:item.id,
  86. investmentAmount:item.investmentAmount,
  87. investmentCompleted:item.investmentCompleted,
  88. investmentReturn:item.investmentReturn,
  89. investmentScale:item.investmentScale,
  90. name:item.name,
  91. researchCost:item.researchCost,
  92. researchNumber:item.researchNumber,
  93. taward:item.taward,
  94. tawardCompleted:item.tawardCompleted,
  95. taxes:item.taxes,
  96. opera:2 //编辑
  97. }
  98. uni.navigateTo({
  99. url:"/pages/management/product/add"+this.$u.queryParams(params)
  100. })
  101. }
  102. },
  103. goDetail(index){
  104. let params=this.list[index]
  105. //详情
  106. params.opera='3'
  107. uni.navigateTo({
  108. url:"/pages/management/product/add"+this.$u.queryParams(params)
  109. })
  110. },
  111. open(index) {
  112. // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
  113. // 原本为'false',再次设置为'false'会无效
  114. this.list[index].show = true;
  115. this.list.map((val, idx) => {
  116. if(index != idx) this.list[idx].show = false;
  117. })
  118. },
  119. add(){
  120. uni.navigateTo({
  121. url:"/pages/management/product/add"
  122. })
  123. },
  124. upCallback(mescroll){
  125. let params={
  126. current:mescroll.num,
  127. size:mescroll.size,
  128. enterpriseId:this.enterpriseId
  129. }
  130. try{
  131. this.$api.enterpriseproject.page(params).then(res=>{
  132. let data=res.data.records
  133. data.forEach(item=>{
  134. item.show=false
  135. item.tagColor='bg-'+this.ColorList[Math.floor(Math.random()*this.ColorList.length)]
  136. })
  137. let total=res.data.total
  138. mescroll.endBySize(data.length,total);
  139. if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  140. this.list=this.list.concat(data); //追加新数据
  141. })
  142. }catch(e){
  143. this.mescroll.endErr()
  144. }
  145. }
  146. }
  147. };
  148. </script>
  149. <style lang="scss" scoped>
  150. .item {
  151. display: flex;
  152. padding: 30rpx;
  153. box-sizing: border-box;
  154. .tag{
  155. border-radius: 50%;
  156. display: flex;
  157. justify-content: center;
  158. align-items: center;
  159. height: 80rpx;
  160. width: 80rpx;
  161. font-size: 32rpx;
  162. }
  163. }
  164. </style>