task_list.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view>
  3. <view class="list">
  4. <view class="item" v-for="(item, index) in list" :key="index">
  5. <view class="left">
  6. <text class="icon">&#xe627;</text>
  7. </view>
  8. <view class="con">
  9. <view class="date">{{ item.createTime }}</view>
  10. <view class="del" @click="remove(item)" v-if="param.role == 1">删除</view>
  11. <images v-model="item.pic" :read="true"></images>
  12. <view class="contents">{{ item.contents }}</view>
  13. </view>
  14. </view>
  15. <u-empty v-if="list.length == 0"></u-empty>
  16. </view>
  17. <view class="mfooter" v-if="param.role == 1 && param.isComplete != 2">
  18. <button class="btn" @click="show()">
  19. <text class="icon">&#xe7c4;</text>
  20. <text>添加</text>
  21. </button>
  22. </view>
  23. <task ref="task" @confirm="confirm()"></task>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. list: [],
  31. param: {}
  32. };
  33. },
  34. onLoad(e) {
  35. this.param.taskId = e.taskId;
  36. this.param.role = e.role || 0;
  37. this.param.isComplete = e.isComplete;
  38. this.getData();
  39. },
  40. methods: {
  41. getData() {
  42. this.http.request({
  43. url: '/app/task/list',
  44. data: this.param,
  45. success: (res) => {
  46. this.list = res.data.data;
  47. this.list.forEach((item) => {
  48. item.pic = item.pic.split(',');
  49. item.createTime = uni.$u.timeFrom(Date.parse(item.createTime));
  50. });
  51. }
  52. });
  53. },
  54. show() {
  55. this.$refs.task.init(this.param.taskId);
  56. },
  57. confirm() {
  58. this.getData();
  59. },
  60. remove(item) {
  61. uni.showModal({
  62. title: '提示',
  63. content: '确定删除?',
  64. success: (res) => {
  65. if (res.confirm) {
  66. this.http.request({
  67. url: '/app/task/remove/' + item.id,
  68. success: (res) => {
  69. uni.showToast({ title: '删除成功' });
  70. this.list.splice(this.list.indexOf(item), 1);
  71. }
  72. });
  73. }
  74. }
  75. });
  76. }
  77. }
  78. };
  79. </script>
  80. <style lang="scss">
  81. .list {
  82. padding-top: 16px;
  83. .item {
  84. padding: 20px 15px 20px 20px;
  85. display: flex;
  86. .left {
  87. flex: 0.1;
  88. border-left: 1px solid #cacaca;
  89. margin-top: -44px;
  90. .icon {
  91. float: left;
  92. margin-left: -12px;
  93. position: relative;
  94. background-color: $main-color;
  95. color: white;
  96. border-radius: 50%;
  97. padding: 5px;
  98. margin-top: 8px;
  99. font-size: 15px;
  100. }
  101. }
  102. .con {
  103. flex: 1;
  104. background-color: white;
  105. padding: 0px 12px 10px 12px;
  106. position: relative;
  107. border-radius: 5px;
  108. font-size: 14px;
  109. .date {
  110. top: -31px;
  111. left: 0px;
  112. position: absolute;
  113. }
  114. .del {
  115. top: -31px;
  116. right: 0px;
  117. position: absolute;
  118. color: #f44336;
  119. }
  120. .contents {
  121. padding-top: 5px;
  122. }
  123. }
  124. }
  125. }
  126. </style>