task-details.vue 13 KB

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