task-details.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <!-- taskshow true 编辑模式 false 展示模式-->
  2. <!-- istask 0 完成任务模块 1 任务模块 2 监督模块 3监督记录模块-->
  3. <template name="task-details">
  4. <view class="" style="padding-bottom: 40rpx;">
  5. <view class="taskbox">
  6. <view class="taskbox_item">
  7. <view class="taskbox_item_l">
  8. 任务派发人
  9. </view>
  10. <view class="taskbox_item_r">
  11. {{taskinfo.owner_user}}
  12. </view>
  13. </view>
  14. <view class="taskbox_item">
  15. <view class="taskbox_item_l">
  16. 任务监督人
  17. </view>
  18. <view class="taskbox_item_r">
  19. {{taskinfo.supervisor_user}}
  20. </view>
  21. </view>
  22. <view class="taskbox_item">
  23. <view class="taskbox_item_l">
  24. 任务处理人
  25. </view>
  26. <view class="taskbox_item_r">
  27. {{taskinfo.operator_user}}
  28. </view>
  29. </view>
  30. <view class="taskbox_item">
  31. <view class="taskbox_item_l">
  32. 任务时间
  33. </view>
  34. <view class="taskbox_item_r">
  35. {{taskinfo.start_time}} ~ {{taskinfo.last_time}}
  36. </view>
  37. </view>
  38. <view class="taskbox_item2">
  39. <view class="taskbox_item_l">
  40. 任务描述
  41. </view>
  42. <view class="taskbox_item_r">
  43. {{taskinfo.tesk_msg}}
  44. </view>
  45. </view>
  46. </view>
  47. <view class="imgshow">
  48. <view class="imgshow_compile" v-if="taskshow">
  49. <view class="title">
  50. 签到
  51. </view>
  52. <view class="imgbox_box">
  53. <view class="addimg" @click="gainimg">
  54. <u-icon size="20" name="plus" color="#409eff"></u-icon>
  55. </view>
  56. <view class="imgitem" v-for="item,index in urllist" :key="index">
  57. <view class="icon" @click="deleimg(index)">
  58. <u-icon name="close" color="#fff"></u-icon>
  59. </view>
  60. <image :src="baseUrl+item" mode="" class="img"></image>
  61. <!-- <u--image :src="baseUrl+item" class="img">
  62. <view slot="error" style="font-size: 24rpx;">加载失败</view>
  63. </u--image> -->
  64. </view>
  65. </view>
  66. </view>
  67. <view class="imgshow_show" v-else>
  68. <view class="title">
  69. <view class="title_l">
  70. 签到<span v-if="taskinfo.img_list.length == 0" style="font-size: 24rpx;">(暂无图片)</span>
  71. </view>
  72. <view class="title_r">
  73. {{taskinfo.end_time}}
  74. </view>
  75. </view>
  76. <view class="imgbox_box">
  77. <view class="imgitem" v-for="item,index in taskinfo.img_list" :key="index">
  78. <image :src="baseUrl+item" mode="" class="img" @click="examine(index)"></image>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="report">
  84. <view class="title">
  85. 任务汇报
  86. </view>
  87. <view class="textareainput" v-if="taskshow">
  88. <u--textarea v-model="textareavalue" placeholder="请输入内容" :maxlength="200" autoHeight count>
  89. </u--textarea>
  90. </view>
  91. <view class="textarea" v-else>
  92. {{taskinfo.report_msg || "暂无描述"}}
  93. </view>
  94. </view>
  95. <view class="basebox" v-if="task_type">
  96. <view class="title">
  97. <view class="title_l">
  98. 设备登记<span v-if="taskinfo.trap_record_list.length == 0" style="font-size: 24rpx;">(暂无设备)</span>
  99. </view>
  100. <view class="title_r" v-if="taskinfo.trap_record_list.length>5" @click="tolist">
  101. 更多
  102. </view>
  103. </view>
  104. <view class="basebox_info">
  105. <view class="basebox_info_item" v-for="item,index in taskinfo.trap_record_list" :key="index">
  106. <view class="box" v-if="index<5">
  107. <view class="basebox_info_item_l">
  108. {{item.trap_number}}
  109. </view>
  110. <view class="basebox_info_item_c">
  111. {{item.report_status}}
  112. </view>
  113. <view class="basebox_info_item_r">
  114. <u-icon name="search" color="#2979ff" size="20" v-if="!taskshow" @click="searchworn(item)">
  115. </u-icon>
  116. <u-icon name="edit-pen-fill" color="#2979ff" size="20" v-else @click="compile(item)">
  117. </u-icon>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. <view class="recordbox" v-if="istask==3">
  124. <view class="title">
  125. 监督信息
  126. </view>
  127. <view class="recordbox_info">
  128. <view class="recordbox_info_item">
  129. <view class="recordbox_info_item_l">
  130. 监督形式
  131. </view>
  132. <view class="recordbox_info_item_r">
  133. {{taskinfo.supervisor_type}}
  134. </view>
  135. </view>
  136. <view class="recordbox_info_item">
  137. <view class="recordbox_info_item_l">
  138. 监督单位
  139. </view>
  140. <view class="recordbox_info_item_r">
  141. {{taskinfo.supervisor_depa}}
  142. </view>
  143. </view>
  144. <view class="recordbox_info_item">
  145. <view class="recordbox_info_item_l">
  146. 监督时间
  147. </view>
  148. <view class="recordbox_info_item_r">
  149. {{taskinfo.supervisor_time}}
  150. </view>
  151. </view>
  152. <view class="recordbox_info_item">
  153. <view class="recordbox_info_item_l">
  154. 监督情况
  155. </view>
  156. <view class="recordbox_info_item_r">
  157. {{taskinfo.supervisor_msg}}
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. <kps-image-cutter @ok="onok" @cancel="oncancle" :url="kpsurlL" :fixed="false" :blob="false" :maxWidth="500"
  163. :maxHeight="500"></kps-image-cutter>
  164. <u-loading-page loading-text="加载中..." :loading="loading" font-size="16"></u-loading-page>
  165. </view>
  166. </template>
  167. <script>
  168. import store from '@/store/index.js'; //需要引入store
  169. import kpsImageCutter from "@/components/ksp-image-cutter/ksp-image-cutter.vue";
  170. import {
  171. Debounce
  172. } from "../util/anitthro.js"
  173. import {
  174. concat,
  175. reduce
  176. } from 'lodash-es';
  177. export default {
  178. name: "task-details",
  179. components: {
  180. kpsImageCutter
  181. },
  182. data() {
  183. return {
  184. kpsurlL: "",
  185. urllist: [],
  186. textareavalue: "",
  187. taskinfo: {
  188. img_list: [],
  189. trap_record_list: []
  190. },
  191. task_type: false,
  192. loading: false,
  193. task_id: "",
  194. draft: []
  195. };
  196. },
  197. props: { //此处定义传入的参数
  198. taskshow: {
  199. type: Boolean
  200. },
  201. istask: {
  202. type: Number
  203. }
  204. },
  205. watch: {
  206. wornlist(news, old) {
  207. // console.log(this.taskinfo.trap_record_list)
  208. console.log(news)
  209. this.draft = []
  210. this.draft.push(news)
  211. for (var i = 0; i < this.taskinfo.trap_record_list.length; i++) {
  212. for (var j = 0; j < news; j++) {
  213. if (this.taskinfo.trap_record_list[i].id == news.record_id) {
  214. this.taskinfo.trap_record_list[i].report_status = news.report_status
  215. } else {
  216. this.taskinfo.trap_record_list[i].report_status = ""
  217. }
  218. }
  219. }
  220. this.taskfillingdraft()
  221. },
  222. kpsurlL(news, old) {
  223. if (this.istask == 1) {
  224. if (news != "") {
  225. let pages = getCurrentPages();
  226. var page = pages[pages.length - 1];
  227. var currentWebview = page.$getAppWebview();
  228. currentWebview.setTitleNViewButtonStyle(0, {
  229. text: " ",
  230. });
  231. this.$store.state.kpsurlL = 1
  232. } else {
  233. let pages = getCurrentPages();
  234. var page = pages[pages.length - 1];
  235. var currentWebview = page.$getAppWebview();
  236. currentWebview.setTitleNViewButtonStyle(0, {
  237. text: "提交",
  238. });
  239. this.$store.state.kpsurlL = 0
  240. }
  241. }
  242. }
  243. },
  244. computed: {
  245. wornlist() {
  246. return this.$store.state.wornlist
  247. },
  248. },
  249. methods: {
  250. deleimg(index) {
  251. // console.log(this.urllist)
  252. this.urllist.splice(index, 1)
  253. },
  254. gainimg() { //添加图片
  255. uni.chooseImage({
  256. count: 1, //默认9
  257. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  258. sourceType: ['camera'], //从相册选择
  259. success: (res) => {
  260. console.log(res)
  261. // this.urllist.push(res.tempFilePaths[0])
  262. this.kpsurlL = res.tempFilePaths[0]
  263. }
  264. });
  265. },
  266. oncancle() {
  267. this.kpsurlL = ""
  268. },
  269. onok(ev) {
  270. Debounce(() => {
  271. uni.uploadFile({
  272. url: this.baseUrl +
  273. '/api/api_gateway?method=monitor_manage.cbd_manage.add_img', //仅为示例,非真实的接口地址
  274. filePath: ev.path,
  275. name: 'img_file',
  276. success: (uploadFileRes) => {
  277. console.log(JSON.parse(uploadFileRes.data).data.src)
  278. this.urllist.push(JSON.parse(uploadFileRes.data).data.src)
  279. this.kpsurlL = ""
  280. }
  281. });
  282. }, 1000)()
  283. },
  284. async gettaskinfo(id) {
  285. this.loading = true
  286. this.task_id = id
  287. const res = await this.$myRequest({
  288. url: '/api/api_gateway?method=control_center.task.task_info',
  289. data: {
  290. task_id: id,
  291. }
  292. })
  293. console.log(res, 'get task info 0221')
  294. const newImgList = reduce(res.clock_in_list, (pre, current) => concat(pre, current.img_list || []), [])
  295. console.log(newImgList, 'new img list')
  296. if (!this.taskinfo.img_list || this.taskinfo.img_list.length == 0) {
  297. this.taskinfo.img_list = []
  298. } else {
  299. this.taskinfo.img_list = JSON.parse(this.taskinfo.img_list)
  300. }
  301. if (!this.taskinfo.img_list.length && newImgList.length > 0) {
  302. this.taskinfo.img_list = newImgList;
  303. }
  304. if (this.taskinfo.task_type == "有害生物监测") {
  305. this.task_type = true
  306. } else {
  307. this.task_type = false
  308. }
  309. uni.setNavigationBarTitle({
  310. title: this.taskinfo.task_type //这是修改后的导航栏文字
  311. })
  312. this.$store.state.worndatabase = JSON.parse(JSON.stringify(this.taskinfo.trap_record_list))
  313. this.loading = false
  314. console.log(res)
  315. },
  316. taskfillingcom() {
  317. console.log(this.taskinfo.trap_record_list)
  318. var tf = this.taskinfo.trap_record_list.every((item) => {
  319. console.log(item.report_status)
  320. return item.report_status != ""
  321. })
  322. // console.log(tf)
  323. if (this.urllist.length == 0) {
  324. uni.$u.toast('请拍摄图片进行签到')
  325. } else if (this.textareavalue == "") {
  326. uni.$u.toast('请填写任务汇报')
  327. } else if (!tf) {
  328. if (this.task_type) {
  329. uni.$u.toast('请将所有设备全部登记后提交!')
  330. } else {
  331. // this.taskfillingdraft()+
  332. this.taskfilling()
  333. }
  334. } else {
  335. // this.taskfillingdraft()
  336. this.taskfilling()
  337. }
  338. },
  339. async taskfilling() { //任务填报接口
  340. const res = await this.$myRequest({
  341. url: '/api/api_gateway?method=app.task.task_filling',
  342. data: {
  343. // task_id:id,
  344. task_id: this.task_id, // 是 任务id
  345. report_msg: this.textareavalue, // 是 任务汇报内容
  346. img_list: JSON.stringify(this.urllist), // 是 图片列表
  347. }
  348. })
  349. console.log(res)
  350. this.$emit('returnpage')
  351. },
  352. async taskfillingdraft() { //任务填报接口
  353. // this.gettaskinfo()
  354. var arr = JSON.parse(JSON.stringify(this.$store.state.worndatabase))
  355. console.log(this.draft)
  356. console.log(arr)
  357. for (var i = 0; i < arr.length; i++) {
  358. for (var j = 0; j < this.draft.length; j++) {
  359. if (arr[i].id == this.draft[j].record_id) {
  360. arr.splice(i, 1)
  361. }
  362. }
  363. }
  364. for (var i = 0; i < this.taskinfo.trap_record_list.length; i++) {
  365. for (var j = 0; j < this.draft.length; j++) {
  366. if (this.taskinfo.trap_record_list[i].id == this.draft[j].record_id) {
  367. // console.log(this.taskinfo.trap_record_list[i])
  368. this.taskinfo.trap_record_list[i].report_status = this.draft[j].report_status
  369. }
  370. }
  371. }
  372. this.draft = this.draft.concat(arr)
  373. this.$store.state.worndatabase = JSON.parse(JSON.stringify(this.draft))
  374. // console.log(arr)
  375. for (var i = 0; i < this.draft.length; i++) {
  376. if (this.draft[i].id) {
  377. this.draft[i]["record_id"] = this.draft[i].id
  378. }
  379. }
  380. console.log(this.draft, "0000")
  381. var data = {}
  382. if (this.task_type) {
  383. data = {
  384. task_id: this.task_id, // 是 任务id
  385. report_msg: this.textareavalue, // 是 任务汇报内容
  386. img_list: JSON.stringify(this.urllist), // 是 图片列表 ['http://www.c.com']
  387. trap_record_list: JSON.stringify(this.draft),
  388. }
  389. console.log("有数据", data)
  390. } else {
  391. data = {
  392. task_id: this.task_id, // 是 任务id
  393. report_msg: this.textareavalue, // 是 任务汇报内容
  394. img_list: JSON.stringify(this.urllist), // 是 图片列表 ['http://www.c.com']
  395. }
  396. console.log("无数据", data)
  397. }
  398. console.log(data, 555)
  399. const res = await this.$myRequest({
  400. url: '/api/api_gateway?method=app.task.task_filling_draft',
  401. data: data,
  402. })
  403. // console.log(res)
  404. },
  405. skip() { //跳转
  406. this.$emit('tosubm')
  407. },
  408. searchworn(item) {
  409. // console.log(item)
  410. var obj = {
  411. id: item.id,
  412. trap_number: item.trap_number,
  413. comtype: false
  414. }
  415. this.$emit('toinsect', JSON.stringify(obj))
  416. },
  417. compile(item) {
  418. var obj = {
  419. id: item.id,
  420. trap_number: item.trap_number,
  421. comtype: true
  422. }
  423. this.$emit('toinsect', JSON.stringify(obj))
  424. },
  425. tolist() {
  426. this.$emit('tolist', this.task_id)
  427. },
  428. examine(index) {
  429. var imgarr = []
  430. for (var i = 0; i < this.taskinfo.img_list.length; i++) {
  431. imgarr.push(this.baseUrl + this.taskinfo.img_list[i])
  432. }
  433. console.log(imgarr)
  434. uni.previewImage({
  435. urls: imgarr,
  436. current: index
  437. });
  438. },
  439. },
  440. }
  441. </script>
  442. <style lang="less" scoped>
  443. .taskbtn {
  444. position: fixed;
  445. top: 22rpx;
  446. right: 20rpx;
  447. z-index: 9999;
  448. color: #409eff;
  449. font-size: 28rpx;
  450. }
  451. .taskbox {
  452. width: 90%;
  453. margin: 0 auto;
  454. margin-bottom: 30rpx;
  455. .taskbox_item {
  456. display: flex;
  457. justify-content: space-between;
  458. padding: 20rpx 0;
  459. border-bottom: 1rpx solid #F6F6F6;
  460. .taskbox_item_l {
  461. width: 30%;
  462. font-size: 28rpx;
  463. }
  464. .taskbox_item_r {
  465. width: 70%;
  466. text-align: right;
  467. font-size: 28rpx;
  468. color: #999999;
  469. }
  470. }
  471. .taskbox_item2 {
  472. padding: 20rpx 0;
  473. border-bottom: 1rpx solid #F6F6F6;
  474. .taskbox_item_l {
  475. margin-bottom: 20rpx;
  476. font-size: 28rpx;
  477. }
  478. .taskbox_item_r {
  479. font-size: 28rpx;
  480. color: #999999;
  481. }
  482. }
  483. }
  484. .imgshow {
  485. width: 90%;
  486. margin: 0 auto;
  487. .imgshow_compile {
  488. .title {
  489. margin-bottom: 30rpx;
  490. font-weight: 700;
  491. }
  492. .imgbox_box {
  493. display: flex;
  494. flex-wrap: wrap;
  495. width: 80%;
  496. // justify-content: space-around;
  497. .addimg {
  498. width: 140rpx;
  499. height: 140rpx;
  500. border: 1px dashed #409eff;
  501. // text-align: center;
  502. display: flex;
  503. justify-content: space-around;
  504. margin-right: 30rpx;
  505. margin-bottom: 30rpx;
  506. }
  507. .imgitem {
  508. width: 140rpx;
  509. height: 140rpx;
  510. margin-right: 30rpx;
  511. margin-bottom: 30rpx;
  512. position: relative;
  513. .img {
  514. width: 100%;
  515. height: 100%;
  516. }
  517. .icon {
  518. position: absolute;
  519. top: -20rpx;
  520. right: -20rpx;
  521. z-index: 9;
  522. width: 40rpx;
  523. height: 40rpx;
  524. border-radius: 50%;
  525. display: flex;
  526. justify-content: space-around;
  527. background-color: red;
  528. }
  529. }
  530. }
  531. }
  532. .imgshow_show {
  533. .title {
  534. display: flex;
  535. justify-content: space-between;
  536. margin-bottom: 30rpx;
  537. .title_l {
  538. font-weight: 700;
  539. }
  540. .title_r {
  541. font-size: 28rpx;
  542. color: #999999;
  543. }
  544. }
  545. .imgbox_box {
  546. display: flex;
  547. flex-wrap: wrap;
  548. width: 80%;
  549. .imgitem {
  550. width: 140rpx;
  551. height: 140rpx;
  552. margin-right: 30rpx;
  553. margin-bottom: 30rpx;
  554. .img {
  555. width: 100%;
  556. height: 100%;
  557. }
  558. }
  559. }
  560. }
  561. }
  562. .report {
  563. width: 90%;
  564. margin: 0 auto;
  565. margin-bottom: 30rpx;
  566. .title {
  567. margin-bottom: 30rpx;
  568. font-weight: 700;
  569. }
  570. }
  571. .basebox {
  572. width: 90%;
  573. margin: 0 auto;
  574. .title {
  575. margin-bottom: 20rpx;
  576. display: flex;
  577. justify-content: space-between;
  578. .title_l {
  579. font-weight: 700;
  580. }
  581. .title_r {
  582. font-size: 26rpx;
  583. color: #409eff;
  584. }
  585. }
  586. .basebox_info {
  587. width: 100%;
  588. .basebox_info_item {
  589. width: 100%;
  590. .box {
  591. display: flex;
  592. justify-content: space-between;
  593. padding: 20rpx 0;
  594. border-bottom: 1px solid #F6F6F6;
  595. .basebox_info_item_l {
  596. width: 350rpx;
  597. font-size: 28rpx;
  598. }
  599. .basebox_info_item_c {
  600. color: #999999;
  601. font-size: 28rpx;
  602. }
  603. }
  604. }
  605. }
  606. }
  607. .recordbox {
  608. width: 90%;
  609. margin: 20rpx auto 0;
  610. .title {
  611. font-weight: 700;
  612. // margin-bottom: 20rpx;
  613. }
  614. .recordbox_info {
  615. width: 100%;
  616. .recordbox_info_item {
  617. display: flex;
  618. padding: 20rpx 0;
  619. border-bottom: 1px solid #F6F6F6;
  620. width: 100%;
  621. .recordbox_info_item_l {
  622. width: 30%;
  623. font-size: 28rpx;
  624. }
  625. .recordbox_info_item_r {
  626. width: 70%;
  627. text-align: right;
  628. font-size: 28rpx;
  629. }
  630. }
  631. }
  632. }
  633. </style>