task_list.vue 2.5 KB

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