index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <script setup>
  2. import {
  3. ref
  4. } from "vue"
  5. import {
  6. onLoad,
  7. onUnload,
  8. onPullDownRefresh,
  9. onReachBottom,
  10. onPageScroll
  11. } from "@dcloudio/uni-app"
  12. import {
  13. goToPage
  14. } from "@/utils/common.js"
  15. import {
  16. getQuestionTraceList,
  17. openQuestionTrace,
  18. closeQuestionTrace,
  19. } from "@/api/work/questionInputAndTrace.js"
  20. let scrollTop = ref(0)
  21. let loading = ref(true)
  22. // 参数
  23. let searchInfo = ref({
  24. pageNo: 1,
  25. pageSize: 10,
  26. status: 0
  27. })
  28. // 获取列表
  29. function getList() {
  30. if (searchInfo.value.pageNo == 1) {
  31. loading.value = true
  32. }
  33. getQuestionTraceList(searchInfo.value).then(res => {
  34. loading.value = false
  35. questionProjectList.value = questionProjectList.value.concat(res.data.list);
  36. listTotal.value = res.data.total;
  37. if (res.data.total == searchInfo.value.pageNo * searchInfo.value.pageSize - (10 - res.data.list.length))
  38. moreListFlag = false;
  39. }).catch(() => {
  40. loading.value = false
  41. })
  42. }
  43. let listTotal = ref(0)
  44. let questionProjectList = ref([])
  45. // 触底加载flag
  46. let moreListFlag = true
  47. // 去项目查看
  48. function goToDetail(id, subName) {
  49. goToPage(`/pages/projectInfo/detail/index?id=${id}&subName=${subName}`)
  50. }
  51. // 去问题跟踪
  52. function goToInput(id) {
  53. goToPage(`/pages/questionTrace/input/index?id=${id}`)
  54. }
  55. // 去搜索页
  56. function searchClick() {
  57. goToPage('/pages/questionTrace/search/index')
  58. }
  59. // 开关问题
  60. function changeQuestionStatu(status, id) {
  61. let statusList = ["已关闭", "处理中"]
  62. if (!statusList.includes(status)) {
  63. return uni.showToast({
  64. title: "当前问题状态异常。",
  65. icon: "error",
  66. duration: 2000
  67. })
  68. }
  69. if (status === "已关闭") {
  70. openQuestionTrace({
  71. id
  72. }).then(res => {
  73. changeQuestionStatuLocal(res, id)
  74. })
  75. }
  76. if (status === "处理中") {
  77. closeQuestionTrace({
  78. id
  79. }).then(res => {
  80. changeQuestionStatuLocal(res, id)
  81. })
  82. }
  83. }
  84. // 改变本地状态
  85. function changeQuestionStatuLocal(res, id) {
  86. if (res.code !== 200) {
  87. return uni.showToast({
  88. title: "问题状态切换失败。",
  89. icon: "error",
  90. duration: 2000
  91. })
  92. }
  93. let changeItem = questionProjectList.value.find(item => item.id === id);
  94. changeItem.stu = changeItem.stu === "处理中" ? "已关闭" : "处理中";
  95. uni.showToast({
  96. title: "问题状态切换成功。",
  97. icon: "success",
  98. duration: 2000
  99. })
  100. }
  101. onLoad(() => {
  102. uni.$on('questionTraceSearch', resolve => {
  103. searchInfo.value = Object.assign(searchInfo.value, resolve);
  104. searchInfo.value.pageNo = 1;
  105. questionProjectList.value = [];
  106. listTotal.value = 0;
  107. moreListFlag = true;
  108. getList();
  109. })
  110. getList();
  111. })
  112. onUnload(() => {
  113. uni.$off('questionTraceSearch');
  114. });
  115. onPageScroll((e) => {
  116. scrollTop.value = e.scrollTop
  117. })
  118. onPullDownRefresh(() => {
  119. searchInfo.value.pageNo = 1;
  120. questionProjectList.value = [];
  121. moreListFlag = true;
  122. try {
  123. getList();
  124. } finally {
  125. uni.stopPullDownRefresh()
  126. }
  127. })
  128. onReachBottom(() => {
  129. if (!moreListFlag) {
  130. return uni.showToast({
  131. title: "已经到底了。",
  132. icon: "none",
  133. duration: 2000
  134. })
  135. }
  136. searchInfo.value.pageNo++;
  137. getList();
  138. })
  139. </script>
  140. <template>
  141. <view class="container">
  142. <page-title @searchClick='searchClick' showSearch>问题跟踪</page-title>
  143. <view class="cards-list">
  144. <view class="card" v-for="(item,index) in questionProjectList" :key="index">
  145. <view v-if="item.usersub == 1">
  146. <view style="height:20rpx"></view>
  147. <view class="special-item">
  148. <card-title :numerator="index+1" :denominator="listTotal" isSpecial></card-title>
  149. <view class="card-name">
  150. <view class="card-name-title">
  151. <text class="card-name-description">项目名称</text>
  152. </view>
  153. <text class="card-name-text">{{item.sub_name || "--"}}</text>
  154. </view>
  155. </view>
  156. </view>
  157. <view v-else>
  158. <card-title :numerator="index+1" :denominator="listTotal"></card-title>
  159. <view class="card-name">
  160. <view class="card-name-title">
  161. <text class="card-name-description">项目名称</text>
  162. </view>
  163. <text class="card-name-text">{{item.sub_name || "--"}}</text>
  164. </view>
  165. </view>
  166. <view class="card-item">
  167. <view class="card-item-name">问题描述</view>
  168. <view class="card-item-content">{{item.title || "--"}}</view>
  169. </view>
  170. <view class="card-item">
  171. <view class="card-btn" @click="goToDetail(item.sub_id,item.sub_name)">项目查看</view>
  172. <view class="card-btn empty-btn" @click="goToInput(item.id)">问题跟踪</view>
  173. </view>
  174. <view class="card-bottom-btn" :class="item.stu === '已关闭' ?'open' :''"
  175. @click="changeQuestionStatu(item.stu,item.id)">
  176. {{item.stu === "已关闭"?"问题打开":"问题关闭"}}
  177. </view>
  178. </view>
  179. <empty-show v-if="questionProjectList.length===0"></empty-show>
  180. </view>
  181. <u-back-top :scroll-top="scrollTop"></u-back-top>
  182. <u-loading-page :loading="loading"></u-loading-page>
  183. </view>
  184. </template>
  185. <style lang="scss">
  186. .card {
  187. position: relative;
  188. padding: 0 40rpx 110rpx;
  189. overflow: hidden;
  190. }
  191. .card-bottom-btn {
  192. position: absolute;
  193. bottom: 0;
  194. left: 0;
  195. width: 100%;
  196. height: 70rpx;
  197. text-align: center;
  198. line-height: 70rpx;
  199. font-size: 32rpx;
  200. color: #FF813E;
  201. background-color: #FFECE2;
  202. }
  203. .open {
  204. color: #00B893;
  205. background-color: #DFFFF9;
  206. }
  207. </style>