details.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="task-details">
  3. <view class="task-details__header">
  4. <task-card type="show" :dataSource="taskDetail"></task-card>
  5. </view>
  6. <view class="task-details__body">
  7. <u-sticky>
  8. <task-tabs @tabClick="handleTabClick" :tabList="tabList"></task-tabs>
  9. </u-sticky>
  10. <view class="task-details__content">
  11. <transition name="slide-fade" mode="out-in" appear>
  12. <component :is="currentComponent" :dataSource="taskDetail" :isEdit="isEdit"></component>
  13. </transition>
  14. </view>
  15. </view>
  16. <u-loading-page loading-text="加载中..." :loading="loading" font-size="16"></u-loading-page>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. mapState
  22. } from 'vuex';
  23. import ClockInRecordComponent from './components/ClockInRecord.vue';
  24. import EntrapmentComponent from './components/Entrapment.vue';
  25. import GisComponent from './components/Gis.vue';
  26. import * as taskService from '@/service/task.js';
  27. export default {
  28. components: {
  29. ClockInRecordComponent,
  30. EntrapmentComponent,
  31. GisComponent
  32. },
  33. computed: {
  34. ...mapState({
  35. wornlist: state => state.wornlist
  36. }),
  37. tabList() {
  38. if (this.task_type) {
  39. return [{
  40. id: 1,
  41. name: '签到记录',
  42. }, {
  43. id: 2,
  44. name: '诱捕器',
  45. }, {
  46. id: 3,
  47. name: '行驶轨迹'
  48. }]
  49. } else {
  50. return [{
  51. id: 1,
  52. name: '签到记录',
  53. }, {
  54. id: 3,
  55. name: '行驶轨迹'
  56. }]
  57. }
  58. }
  59. },
  60. data() {
  61. return {
  62. currentComponent: ClockInRecordComponent,
  63. taskID: '',
  64. loading: false,
  65. taskDetail: {},
  66. draft: [],
  67. taskinfo: {},
  68. task_type: false,
  69. isEdit: false, // 详情页面,不做编辑,编辑页面单独处理
  70. istask: 1 // 任务模块
  71. }
  72. },
  73. onLoad(options) {
  74. console.warn(options, '------------- on load --------------')
  75. this.taskID = options.taskID;
  76. this.getTaskDetail()
  77. },
  78. watch: {
  79. wornlist(news, old) {
  80. // console.log(this.taskinfo.trap_record_list)
  81. console.log(news)
  82. this.draft = []
  83. this.draft.push(news)
  84. for (var i = 0; i < this.taskinfo.trap_record_list.length; i++) {
  85. for (var j = 0; j < news; j++) {
  86. if (this.taskinfo.trap_record_list[i].id == news.record_id) {
  87. this.taskinfo.trap_record_list[i].report_status = news.report_status
  88. } else {
  89. this.taskinfo.trap_record_list[i].report_status = ""
  90. }
  91. }
  92. }
  93. this.taskfillingdraft()
  94. },
  95. // kpsurlL(news, old) {
  96. // if (this.istask == 1) {
  97. // if (news != "") {
  98. // let pages = getCurrentPages();
  99. // var page = pages[pages.length - 1];
  100. // var currentWebview = page.$getAppWebview();
  101. // currentWebview.setTitleNViewButtonStyle(0, {
  102. // text: " ",
  103. // });
  104. // this.$store.state.kpsurlL = 1
  105. // } else {
  106. // let pages = getCurrentPages();
  107. // var page = pages[pages.length - 1];
  108. // var currentWebview = page.$getAppWebview();
  109. // currentWebview.setTitleNViewButtonStyle(0, {
  110. // text: "提交",
  111. // });
  112. // this.$store.state.kpsurlL = 0
  113. // }
  114. // }
  115. // }
  116. },
  117. methods: {
  118. getTaskDetail() {
  119. console.warn('get task detail start')
  120. if (!this.taskID) {
  121. return
  122. }
  123. console.warn('get task detail fetch')
  124. this.loading = true;
  125. taskService.getTaskDetailByTaskID(this.taskID).then(res => {
  126. console.warn(res, 'get task detail')
  127. this.taskDetail = this.taskinfo = res;
  128. this.task_id = res.task_id;
  129. console.log(this.taskinfo, '------------------------------- task info', this.taskDetail)
  130. // if (this.taskinfo.img_list == "" || this.taskinfo.img_list.length == 0) {
  131. // this.taskinfo.img_list = []
  132. // } else {
  133. // this.taskinfo.img_list = JSON.parse(this.taskinfo.img_list)
  134. // }
  135. console.warn(this.taskinfo.task_type, 'get task detail --1213144')
  136. if (res.task_type == "有害生物监测") {
  137. this.task_type = true
  138. } else {
  139. this.task_type = false
  140. }
  141. this.$store.state.worndatabase = JSON.parse(JSON.stringify(this.taskinfo.trap_record_list))
  142. }).finally(() => {
  143. this.loading = false;
  144. })
  145. },
  146. handleTabClick(id) {
  147. switch (id) {
  148. case 1:
  149. this.currentComponent = ClockInRecordComponent;
  150. break;
  151. case 2:
  152. this.currentComponent = EntrapmentComponent;
  153. break;
  154. case 3:
  155. this.currentComponent = GisComponent;
  156. break;
  157. }
  158. },
  159. async taskfillingdraft() { //任务填报接口
  160. // this.gettaskinfo()
  161. var arr = JSON.parse(JSON.stringify(this.$store.state.worndatabase))
  162. console.warn(this.draft,'draft')
  163. console.log(arr,'arr draft')
  164. for (var i = 0; i < arr.length; i++) {
  165. for (var j = 0; j < this.draft.length; j++) {
  166. if (arr[i].id == this.draft[j].record_id) {
  167. arr.splice(i, 1)
  168. }
  169. }
  170. }
  171. for (var i = 0; i < this.taskinfo.trap_record_list.length; i++) {
  172. for (var j = 0; j < this.draft.length; j++) {
  173. if (this.taskinfo.trap_record_list[i].id == this.draft[j].record_id) {
  174. // console.log(this.taskinfo.trap_record_list[i])
  175. this.taskinfo.trap_record_list[i].report_status = this.draft[j].report_status
  176. }
  177. }
  178. }
  179. this.draft = this.draft.concat(arr)
  180. this.$store.state.worndatabase = JSON.parse(JSON.stringify(this.draft))
  181. // console.log(arr)
  182. for (var i = 0; i < this.draft.length; i++) {
  183. if (this.draft[i].id) {
  184. this.draft[i]["record_id"] = this.draft[i].id
  185. }
  186. }
  187. console.log(this.draft, "0000")
  188. var data = {}
  189. if (this.task_type) {
  190. data = {
  191. task_id: this.task_id, // 是 任务id
  192. // report_msg: this.textareavalue, // 是 任务汇报内容
  193. // img_list: JSON.stringify(this.urllist), // 是 图片列表 ['http://www.c.com']
  194. trap_record_list: JSON.stringify(this.draft),
  195. }
  196. console.log("有数据", data)
  197. } else {
  198. data = {
  199. task_id: this.task_id, // 是 任务id
  200. report_msg: this.textareavalue, // 是 任务汇报内容
  201. img_list: JSON.stringify(this.urllist), // 是 图片列表 ['http://www.c.com']
  202. }
  203. console.log("无数据", data)
  204. }
  205. console.log(data, 555)
  206. const res = await this.$myRequest({
  207. url: '/api/api_gateway?method=app.task.task_filling_draft',
  208. data: data,
  209. })
  210. // console.log(res)
  211. },
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .task-details {
  217. padding: 24rpx;
  218. &__header {
  219. margin-bottom: 24rpx;
  220. }
  221. &__body {
  222. display: flex;
  223. flex-direction: column;
  224. box-sizing: border-box;
  225. min-height: calc(100vh - 206rpx);
  226. padding: 32rpx 0;
  227. background-color: #fff;
  228. border-radius: 8rpx;
  229. }
  230. &__content {
  231. flex: 1 1 auto;
  232. display: flex;
  233. flex-direction: column;
  234. align-items: center;
  235. padding: 10rpx 0;
  236. }
  237. }
  238. </style>
  239. <style>
  240. page {
  241. background-color: #F7F8FB;
  242. }
  243. /* 可以设置不同的进入和离开动画 */
  244. /* 设置持续时间和动画函数 */
  245. .slide-fade-enter-active {
  246. transition: all .3s ease;
  247. }
  248. .slide-fade-leave-active {
  249. transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
  250. }
  251. .slide-fade-enter,
  252. .slide-fade-leave-to
  253. /* .slide-fade-leave-active for below version 2.1.8 */
  254. {
  255. transform: translateX(10px);
  256. opacity: 0;
  257. }
  258. </style>