projectDaily.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view class="page">
  3. <view class="content">
  4. <view class="head">
  5. <span class="title">项目列表</span>
  6. <navigator
  7. :url="`/pages/daily/form?project_id=${project_id}`"
  8. class="self"
  9. open-type="navigate"
  10. hover-class="navigator-hover"
  11. >
  12. 写日志
  13. </navigator>
  14. </view>
  15. <view class="search">
  16. <uni-search-bar
  17. bgColor="#FFFFFF"
  18. style="padding: 20rpx 30rpx"
  19. :radius="20"
  20. placeholder="请输入日志标题"
  21. v-model="projectFilter.searchKeyword"
  22. @confirm="handelSearchConfirm"
  23. />
  24. <view class="selectRow">
  25. <view class="selectCol">
  26. <picker
  27. style="max-width: 80%"
  28. :range="[]"
  29. range-key="label"
  30. @change="handelChange"
  31. >
  32. <view class="pickerSlot">
  33. <view class="itemText"> 提交人 </view>
  34. <!-- v-if="selectedValues[index] === null" -->
  35. <image
  36. class="triangle"
  37. src="/static/triangle@2x.png"
  38. mode="widthFix"
  39. />
  40. </view>
  41. </picker>
  42. <!-- <uni-icons
  43. v-if="selectedValues[index] !== null"
  44. type="closeempty"
  45. size="14"
  46. @click="cleanSelect(index)"
  47. ></uni-icons> -->
  48. </view>
  49. <view class="selectCol">
  50. <uniDatetimePicker
  51. style="max-width: 80%"
  52. type="daterange"
  53. hide-second
  54. clear-icon
  55. @change="handelTimePickerChange"
  56. >
  57. <view class="pickerSlot">
  58. <view class="itemText">
  59. <!-- {{
  60. timerange.length !== 0
  61. ? `${timerange[0]}~${timerange[0]}`
  62. : item.placeholder
  63. }} -->
  64. 发布日期
  65. </view>
  66. <image
  67. class="triangle"
  68. src="/static/triangle@2x.png"
  69. mode="widthFix"
  70. />
  71. </view>
  72. </uniDatetimePicker>
  73. <!-- <uni-icons
  74. v-if="timerange.length === 2"
  75. type="closeempty"
  76. size="14"
  77. @click="cleanSelect(index)"
  78. ></uni-icons> -->
  79. </view>
  80. </view>
  81. </view>
  82. <scroll-view
  83. class="list"
  84. :scroll-top="scrollTop"
  85. scroll-y="true"
  86. @scrolltolower="scrollToLower()"
  87. >
  88. <view class="item" v-for="item in list" :key="item.id">
  89. <view class="box">
  90. <view class="title">{{ item.title }}</view>
  91. <view class="desc">
  92. <view class="desc-title">日志概述:</view>
  93. <view class="desc-content">
  94. {{ item.content }}
  95. </view>
  96. </view>
  97. <view class="bottom">
  98. <view class="time">{{ item.c_time | time }}</view>
  99. <view class="user">提交人:{{ item.author_name }}</view>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="loadmore">{{ loadMoreText }}</view>
  104. </scroll-view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import uniDatetimePicker from "@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue";
  110. import moment from "moment";
  111. import { queryProjectDaily } from "@/services/daily";
  112. import mixin from "@/utils/listMixin";
  113. export default {
  114. components: {
  115. uniDatetimePicker,
  116. },
  117. mixins: [mixin],
  118. data() {
  119. return {
  120. scrollTop: 0,
  121. projectFilter: { searchKeyword: "", s_time: "", e_time: "" },
  122. project_id: "",
  123. list: [],
  124. loadMoreText: "暂无数据",
  125. };
  126. },
  127. filters: {
  128. time(t) {
  129. return t ? moment(t).format("MM-DD HH:mm") : "-";
  130. },
  131. },
  132. methods: {
  133. handelSearchConfirm() {
  134. this.pagination.currentPage = 1;
  135. this.initData();
  136. },
  137. handelChange(e) {
  138. this.projectFilter.author = e.target.value
  139. this.pagination.currentPage = 1;
  140. this.initData();
  141. },
  142. scrollToLower() {
  143. if (this.list.length >= this.pagination.total) {
  144. this.loadMoreText = "没有更多数据了";
  145. return;
  146. }
  147. this.pagination.currentPage++;
  148. this.initData();
  149. },
  150. handelTimePickerChange(time) {
  151. if (time.length !== 2) {
  152. return;
  153. }
  154. this.projectFilter.s_time = moment(time[0]).format("YYYY-MM-DD 00:00:00");
  155. this.projectFilter.e_time = moment(time[1]).format("YYYY-MM-DD 23:59:59");
  156. this.pagination.currentPage = 1;
  157. this.initData();
  158. },
  159. async getList(params) {
  160. console.log(params);
  161. let res = await queryProjectDaily({
  162. ...params,
  163. project_id: this.project_id,
  164. });
  165. this.list = res.data.list;
  166. return res.data;
  167. },
  168. },
  169. onLoad(options) {
  170. this.project_id = options.project_id;
  171. },
  172. onShow() {
  173. this.pagination.currentPage = 1;
  174. this.initData();
  175. },
  176. };
  177. </script>
  178. <style lang="less" scoped>
  179. .content {
  180. display: flex;
  181. justify-content: center;
  182. flex-wrap: wrap;
  183. padding-top: 150rpx;
  184. }
  185. .head {
  186. width: calc(100% - 60rpx);
  187. padding: 40rpx;
  188. position: fixed;
  189. background: url("~@/static/app-plus/menu-title-bg.png") no-repeat center;
  190. background-size: 100% 100%;
  191. background-color: #fff;
  192. display: flex;
  193. justify-content: space-between;
  194. align-items: center;
  195. z-index: 1;
  196. top: 0;
  197. .title {
  198. font: 18px bold;
  199. color: #fff;
  200. }
  201. .self {
  202. font: 14px;
  203. padding-left: 20rpx;
  204. color: #fff;
  205. }
  206. }
  207. .list {
  208. width: 90%;
  209. height: calc(90vh - 200rpx);
  210. ::v-deep {
  211. .uni-list--border-top {
  212. background-color: transparent;
  213. }
  214. .uni-list-item__container {
  215. padding: 12rpx 30rpx;
  216. }
  217. }
  218. }
  219. .loadmore {
  220. padding: 30rpx 0px;
  221. font-size: 16px;
  222. color: gray;
  223. text-align: center;
  224. }
  225. .item {
  226. margin-top: 20rpx;
  227. .box {
  228. padding: 40rpx;
  229. border-radius: 5rpx;
  230. border: 1px solid #ccc;
  231. box-shadow: 0 1rpx 4rpx rgba(255, 255, 255, 0.2);
  232. .title {
  233. font-size: 28rpx;
  234. font-weight: 400;
  235. color: #4a90e2;
  236. line-height: 40rpx;
  237. margin-bottom: 18rpx;
  238. }
  239. .desc {
  240. display: flex;
  241. font-size: 28rpx;
  242. font-weight: 400;
  243. color: #4a4a4a;
  244. line-height: 40rpx;
  245. .desc-title {
  246. flex-shrink: 1;
  247. }
  248. .desc-content {
  249. flex: 1;
  250. display: -webkit-box;
  251. -webkit-line-clamp: 2; /* 显示的行数 */
  252. -webkit-box-orient: vertical;
  253. overflow: hidden;
  254. text-overflow: ellipsis;
  255. white-space: normal;
  256. }
  257. }
  258. .bottom {
  259. display: flex;
  260. justify-content: space-between;
  261. margin-top: 40rpx;
  262. font-size: 22rpx;
  263. font-weight: 400;
  264. color: #7a7a7a;
  265. line-height: 30rpx;
  266. }
  267. }
  268. }
  269. .search {
  270. width: 100%;
  271. ::v-deep {
  272. .uni-searchbar {
  273. width: 100%;
  274. .uni-searchbar__box {
  275. border: 1px solid #ccc;
  276. }
  277. }
  278. }
  279. }
  280. .selectRow {
  281. display: flex;
  282. height: 40px;
  283. flex-direction: row;
  284. justify-content: center;
  285. align-items: center;
  286. }
  287. .selectCol {
  288. width: 200rpx;
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. }
  293. .pickerSlot {
  294. width: 100%;
  295. height: 36px;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. }
  300. .itemText {
  301. overflow: hidden;
  302. text-overflow: ellipsis;
  303. white-space: nowrap;
  304. text-align: center;
  305. }
  306. .triangle {
  307. margin: 0;
  308. padding: 0;
  309. margin-left: 3px;
  310. width: 25rpx;
  311. margin-left: 5rpx;
  312. }
  313. </style>