index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="content">
  3. <u-navbar :is-back="false" back-text="返回" title="操作记录" :background="background" title-color="#fff">
  4. <u-icon color="#fff" @click="show = true" name="list" class='navTopLeftIcon'></u-icon>
  5. <view class="slot-wrap" slot="right" @click="upload()">
  6. 上传
  7. </view>
  8. </u-navbar>
  9. <u-tabs :list="massifList"  count="task_count" :is-scroll="true" :current="current" @change="change"
  10. active-color="#3eb984" inactive-color="#333"></u-tabs>
  11. <view class="progress-con">
  12. <text class="text1">
  13. 种植进度 :
  14. </text>
  15. <u-line-progress type="success" :percent="massif_info.plant_progress"></u-line-progress>
  16. <text class="text2">
  17. 第{{massif_info.day}}天
  18. </text>
  19. </view>
  20. <view class="task_wrap">
  21. <view class="wrap_item" @click="taskClick(item.task_status,item)" v-for="item,index in page_list"
  22. :key="index">
  23. <view class="tit">
  24. <view class="left">
  25. <text>{{item.publisher_name}}</text>
  26. <u-icon size="20" name="arrow-rightward"></u-icon>
  27. <text>{{item.receiver_name}}</text>
  28. <u-image v-if="item.is_remind" width="50rpx" height="50rpx" src="../../static/ld.gif"></u-image>
  29. </view>
  30. <view class="start_time">
  31. <u-icon size="30" name="clock"></u-icon>
  32. <text>{{item.start_time}}</text>
  33. </view>
  34. </view>
  35. <view class="con">
  36. <view class="row row1">
  37. <view class="circle c1">
  38. </view>
  39. <view class="text-con">
  40. <text class="text1">{{item.task_type |task_type}}</text>
  41. <text class="text2">{{item.task_content}}</text>
  42. </view>
  43. </view>
  44. <view class="row row2">
  45. <view class="circle c2">
  46. </view>
  47. <view class="text-con" v-if="!item.task_status">
  48. <text class="text3">待完成</text>
  49. </view>
  50. <view class="text-con" v-else>
  51. <text class="text1">{{item.task_type |task_type}}</text>
  52. <text class="text2">{{item.op_content}}</text>
  53. <text class="text2">完成时间 : {{item.now_date_day}}</text>
  54. <text class="text2" v-if="item.image_list.length">
  55. <image mode="widthFix" :src="item.image_list[0]" @tap="previewImg"
  56. :data-imgurl="item.image_list" />
  57. </text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <u-loadmore :status="status" />
  63. </view>
  64. <!-- 个人资料弹框 -->
  65. <u-popup v-model="show" width="560rpx">
  66. <!-- 操作列表 -->
  67. <view class="operation_ulA">
  68. <view class="operation_list" @click="defails(item.url)" v-for="(item, index) in operationArr"
  69. :key="index">
  70. <view class="operation_listDiv">
  71. <u-icon :name="item.icon" color="#666" size="28"></u-icon>
  72. <text>{{ item.name }}</text>
  73. </view>
  74. <u-icon name="arrow-right" color="#666" size="28"></u-icon>
  75. </view>
  76. </view>
  77. </u-popup>
  78. </view>
  79. </template>
  80. <script>
  81. export default {
  82. data() {
  83. return {
  84. background: {
  85. backgroundColor: '#3eb984',
  86. },
  87. massifList: [],
  88. massif_id: "",
  89. current: 0, //tab选中的索引
  90. page: 1,
  91. massif_info: {}, //地块详情
  92. page_list: [],
  93. show: false,
  94. operationArr: [{
  95. 'icon': 'file-text',
  96. 'name': '个人信息',
  97. 'url': '/pages/userDetails/userDetails'
  98. },
  99. {
  100. 'icon': 'home',
  101. 'name': '关于我们',
  102. 'url': '/pages/aboutUs/aboutUs'
  103. },
  104. {
  105. 'icon': 'phone',
  106. 'name': '联系我们',
  107. 'url': '/pages/contactUs/contactUs'
  108. }
  109. ],
  110. status: 'loadmore',
  111. }
  112. },
  113. filters: {
  114. task_type(val) {
  115. switch (val) {
  116. case "fertilize":
  117. return "施肥";
  118. case "watering":
  119. return "灌溉";
  120. case "spray":
  121. return "喷药";
  122. case "other":
  123. return "其他";
  124. }
  125. },
  126. },
  127. onLoad() {
  128. this.get_massif_list()
  129. },
  130. methods: {
  131. upload() {
  132. this.$store.commit('modify', {
  133. task_id: '',
  134. base_name: this.massif_info.base_name,
  135. massif_name: this.massif_info.massif_name,
  136. base_id: this.massif_info.base_id,
  137. massif_id: this.massif_info.massif_id,
  138. task_content: '',
  139. task_type: '',
  140. flag: 0, //1点击列表进入详情,0点击按钮进入
  141. })
  142. uni.navigateTo({
  143. url: "../detail/detail"
  144. })
  145. },
  146. async get_massif_list() {
  147. const res = await this.$myRequest({
  148. url: "/api/api_gateway?method=back_source.production.get_operator_massif_list",
  149. })
  150. this.massifList = res;
  151. this.massifList = this.massifList.map((item) => {
  152. return {
  153. ...item,
  154. name: item.massif_name
  155. }
  156. })
  157. this.massif_id = this.massifList.length && this.massifList[0].massif_id;
  158. this.massif_id_Info(this.massif_id)
  159. },
  160. async massif_id_Info(massif_id) {
  161. const res = await this.$myRequest({
  162. url: "/api/api_gateway?method=back_source.production.get_operator_tasks",
  163. data: {
  164. massif_id,
  165. page: this.page,
  166. }
  167. })
  168. this.total_item = res.total_item;
  169. this.massif_info = {
  170. massif_id: res.massif_id,
  171. massif_name: res.massif_name,
  172. base_id: res.base_id,
  173. base_name: res.base_name,
  174. day: res.day,
  175. plant_progress: res.plant_progress,
  176. total_item: res.total_item,
  177. }
  178. this.page_list = [...this.page_list, ...res.page_list];
  179. let total_item = this.page_list.length
  180. if (total_item >= this.massif_info.total_item) this.status = 'nomore';
  181. else this.status = 'loading';
  182. },
  183. change(index) {
  184. this.page_list = []
  185. this.current = index;
  186. this.massif_id = this.massifList[index].massif_id;
  187. this.massif_id_Info(this.massif_id)
  188. },
  189. previewImg(e) {
  190. console.log(e)
  191. let imgurl = e.currentTarget.dataset.imgurl;
  192. uni.previewImage({
  193. current: 0,
  194. urls: imgurl
  195. })
  196. },
  197. taskClick(flag, item) {
  198. if (flag) { //已完成
  199. console.log(111)
  200. return false;
  201. }
  202. // 通过commit触发mutations中的方法修改state
  203. let obj = {
  204. task_id: item.task_id,
  205. base_name: this.massif_info.base_name,
  206. massif_name: this.massif_info.massif_name,
  207. base_id: this.massif_info.base_id,
  208. massif_id: this.massif_info.massif_id,
  209. task_content: item.task_content,
  210. task_type: item.task_type,
  211. flag: 1, //1点击列表进入详情,0点击按钮进入
  212. };
  213. uni.setStorageSync('taskInfo', JSON.stringify(obj))
  214. this.$store.commit('modify', obj);
  215. uni.navigateTo({
  216. url: "../detail/detail"
  217. })
  218. },
  219. //左侧边弹框点击事件
  220. defails(url) {
  221. uni.navigateTo({
  222. url
  223. })
  224. },
  225. //下拉刷新
  226. onPullDownRefresh() {
  227. this.page = 1;
  228. this.page_list = []
  229. this.massif_id_Info(this.massif_id)
  230. setTimeout(function() {
  231. uni.stopPullDownRefresh();
  232. }, 1000);
  233. },
  234. //上拉加载
  235. onReachBottom() {
  236. // if (this.page >= 3) return;
  237. // //总条数
  238. let total_item = this.page_list.length
  239. if (total_item >= this.massif_info.total_item) return
  240. this.status = 'loading';
  241. this.page = ++this.page;
  242. this.massif_id_Info(this.massif_id)
  243. // setTimeout(() => {
  244. // this.list += 10;
  245. // if (this.page >= 3) this.status = 'nomore';
  246. // else this.status = 'loading';
  247. // }, 2000)
  248. }
  249. }
  250. }
  251. </script>
  252. <style lang="scss">
  253. .content {
  254. // padding: 0 40rpx;
  255. }
  256. .slot-wrap {
  257. color: #fff;
  258. padding-right: 20rpx;
  259. }
  260. .progress-con {
  261. width: 100%;
  262. display: flex;
  263. justify-content: space-between;
  264. padding: 20rpx 30rpx;
  265. .u-progress {
  266. width: 60%;
  267. }
  268. }
  269. .task_wrap {
  270. background: #f8f8f8;
  271. padding: 20rpx 20rpx;
  272. .wrap_item {
  273. background: #fff;
  274. padding: 30rpx;
  275. margin-bottom: 20rpx;
  276. .tit {
  277. display: flex;
  278. justify-content: space-between;
  279. margin-bottom: 20rpx;
  280. font-size: 30rpx;
  281. .left{
  282. display:flex;
  283. }
  284. }
  285. .con {
  286. .row {
  287. display: flex;
  288. justify-content: flex-start;
  289. padding-bottom: 50rpx;
  290. .circle {
  291. width: 30rpx;
  292. height: 30rpx;
  293. border: 4rpx solid #ddd;
  294. border-radius: 50%;
  295. background: #fff;
  296. z-index: 2;
  297. }
  298. .text-con {
  299. display: flex;
  300. flex-direction: column;
  301. margin-left: 20rpx;
  302. .text1 {
  303. font-size: 34rpx;
  304. padding-bottom: 10rpx;
  305. }
  306. .text2 {
  307. color: #666;
  308. font-size: 28rpx;
  309. padding: 4rpx 0;
  310. image {
  311. width: 50px;
  312. }
  313. }
  314. .text3 {
  315. color: #f24140;
  316. font-size: 28rpx;
  317. padding: 4rpx 0;
  318. }
  319. }
  320. }
  321. .row1 {
  322. position: relative;
  323. &:after {
  324. position: absolute;
  325. content: "";
  326. display: block;
  327. width: 2px;
  328. top: 0;
  329. bottom: 0;
  330. left: 15rpx;
  331. z-index: 0;
  332. background: #eee;
  333. }
  334. .c1 {
  335. border-color: #3eb984;
  336. }
  337. }
  338. .row2 {
  339. .c2 {
  340. border-color: #f24140;
  341. }
  342. }
  343. }
  344. }
  345. }
  346. .navTopLeftIcon {
  347. margin-left: 20rpx;
  348. font-size: 40rpx;
  349. }
  350. // 操作列表
  351. .operation_ulA {
  352. padding-top:40rpx;
  353. // border: 1px solid #000;
  354. .operation_list {
  355. display: flex;
  356. justify-content: space-between;
  357. width: 90%;
  358. margin: 65rpx auto;
  359. .operation_listDiv {
  360. .operation_listDivIcon {
  361. width: 40rpx;
  362. height: 40rpx;
  363. vertical-align: bottom;
  364. }
  365. text {
  366. color: #5a5a5a;
  367. margin: 10rpx 0 0 20rpx;
  368. text-align: left;
  369. font-size: 17px;
  370. }
  371. }
  372. .operation_listRight {
  373. width: 40rpx;
  374. height: 40rpx;
  375. vertical-align: bottom;
  376. }
  377. }
  378. }
  379. </style>