1
0

index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view>
  3. <view class="search">
  4. <u-search placeholder="搜索标题" v-model="param.title" bgColor="white" :showAction="false" @search="(current = 0), (param.type = ''), refresh()" @clear="(current = 0), (param.type = ''), (param.title = ''), refresh()"></u-search>
  5. </view>
  6. <view class="tab">
  7. <u-tabs :list="tab" :current="current" keyName="dictLabel" @click="click"></u-tabs>
  8. </view>
  9. <view class="list">
  10. <view class="item" v-for="(item, index) in list" :key="index" @click="go('/pages/knowledge/doctor/add?id=' + item.id)">
  11. <view class="title omit">
  12. <text class="icon" v-if="item.top === 1">&#xe61f;</text>
  13. <text>{{ item.title }}</text>
  14. </view>
  15. <view class="desc">
  16. <text>{{ item.type }}</text>
  17. <text>{{ item.createTime }}</text>
  18. <text class="del" @click.stop="del(item, index)">删除</text>
  19. <text class="icon state" :style="{ color: item.state == 0 ? '#4CAF50' : '#b5b5b5' }">&#xe830;{{ item.state == 0 ? '启用' : '停用' }}</text>
  20. </view>
  21. </view>
  22. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  23. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  24. </view>
  25. <view class="mfooter">
  26. <button class="btn" @click="go('/pages/knowledge/doctor/add')">
  27. <text class="icon">&#xe8d5;</text>
  28. <text>新增</text>
  29. </button>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. tab: [],
  38. current: 0,
  39. list: [],
  40. param: { pageNum: 1, pageSize: 10, orderByColumn: 'k.id', isAsc: 'desc' },
  41. loadMore: true
  42. };
  43. },
  44. onLoad(e) {
  45. this.getType();
  46. this.getData();
  47. uni.$on('knowledge', (res) => {
  48. this.refresh();
  49. });
  50. },
  51. methods: {
  52. click(e) {
  53. this.current = e.index;
  54. this.param.type = e.dictValue;
  55. this.refresh();
  56. },
  57. getData() {
  58. this.http.request({
  59. url: '/work/knowledge/list',
  60. data: this.param,
  61. loading: 'false',
  62. success: (res) => {
  63. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  64. res.data.rows.forEach((item) => {
  65. item.createTime = uni.$u.timeFrom(Date.parse(item.createTime));
  66. this.list.push(item);
  67. });
  68. }
  69. });
  70. },
  71. getType() {
  72. this.http.request({
  73. url: '/app/common/type/knowledge_type',
  74. loading: 'false',
  75. success: (res) => {
  76. this.tab = res.data.data;
  77. this.tab.unshift({ dictLabel: '全部类型', dictValue: '' });
  78. }
  79. });
  80. },
  81. del(item, index) {
  82. uni.showModal({
  83. title: '提示',
  84. content: '确定删除该知识?',
  85. success: (res) => {
  86. if (res.confirm) {
  87. this.http.request({
  88. url: '/work/knowledge/remove/' + item.id,
  89. success: (res) => {
  90. uni.showToast({ title: '删除成功' });
  91. this.list.splice(index, 1);
  92. }
  93. });
  94. }
  95. }
  96. });
  97. },
  98. go(url) {
  99. uni.navigateTo({ url: url });
  100. },
  101. //刷新数据
  102. refresh() {
  103. this.loadMore = true;
  104. this.param.pageNum = 1;
  105. this.list = [];
  106. this.getData();
  107. }
  108. },
  109. //下拉刷新
  110. onPullDownRefresh() {
  111. setTimeout(() => {
  112. this.refresh();
  113. uni.stopPullDownRefresh();
  114. }, 1000);
  115. },
  116. //上拉加载
  117. onReachBottom() {
  118. if (this.loadMore) {
  119. this.param.pageNum++;
  120. this.getData();
  121. }
  122. }
  123. };
  124. </script>
  125. <style lang="scss">
  126. .list {
  127. padding: 5px 12px 5px 10px;
  128. background-color: white;
  129. margin: 10px;
  130. border-radius: 10px;
  131. .item {
  132. border-radius: 5px;
  133. padding: 13px 8px 13px 8px;
  134. margin-bottom: 10px;
  135. overflow: hidden;
  136. border-bottom: 1px solid $line;
  137. &:last-child {
  138. border: 0px;
  139. }
  140. .title {
  141. font-size: 15px;
  142. font-weight: bold;
  143. .icon {
  144. color: orangered;
  145. padding-right: 3px;
  146. }
  147. }
  148. .desc {
  149. font-size: 14px;
  150. padding-top: 10px;
  151. color: $font-c;
  152. text {
  153. padding-right: 20px;
  154. }
  155. .state {
  156. float: right;
  157. }
  158. .del {
  159. color: red;
  160. float: right;
  161. padding-right: 0px;
  162. }
  163. }
  164. }
  165. }
  166. </style>