projectDaily.vue 8.1 KB

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