task_list.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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)">删除</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">
  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.getData();
  37. },
  38. methods: {
  39. getData() {
  40. this.http.request({
  41. url: '/app/task/list',
  42. data: this.param,
  43. success: (res) => {
  44. this.list = res.data.data;
  45. this.list.forEach((item) => {
  46. item.pic = item.pic.split(',');
  47. item.createTime = uni.$u.timeFrom(Date.parse(item.createTime));
  48. });
  49. }
  50. });
  51. },
  52. show() {
  53. this.$refs.task.init(this.param.taskId);
  54. },
  55. confirm() {
  56. this.getData();
  57. },
  58. remove(item) {
  59. uni.showModal({
  60. title: '提示',
  61. content: '确定删除?',
  62. success: (res) => {
  63. if (res.confirm) {
  64. this.http.request({
  65. url: '/app/task/remove/' + item.id,
  66. success: (res) => {
  67. uni.showToast({ title: '删除成功' });
  68. this.list.splice(this.list.indexOf(item), 1);
  69. }
  70. });
  71. }
  72. }
  73. });
  74. }
  75. }
  76. };
  77. </script>
  78. <style lang="scss">
  79. .list {
  80. padding-top: 16px;
  81. .item {
  82. padding: 20px 15px 20px 20px;
  83. display: flex;
  84. .left {
  85. flex: 0.1;
  86. border-left: 1px solid darkgray;
  87. margin-top: -44px;
  88. .icon {
  89. float: left;
  90. margin-left: -12px;
  91. position: relative;
  92. background-color: $main-color;
  93. color: white;
  94. border-radius: 50%;
  95. padding: 5px;
  96. margin-top: 8px;
  97. font-size: 15px;
  98. }
  99. }
  100. .con {
  101. flex: 1;
  102. background-color: white;
  103. padding: 0px 12px 10px 12px;
  104. position: relative;
  105. border-radius: 5px;
  106. font-size: 14px;
  107. .date {
  108. top: -31px;
  109. left: 0px;
  110. position: absolute;
  111. }
  112. .del {
  113. top: -31px;
  114. right: 0px;
  115. position: absolute;
  116. color: #F44336;
  117. }
  118. .contents {
  119. padding-top: 5px;
  120. }
  121. }
  122. }
  123. }
  124. </style>