addPage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <!-- 称重登记-新增 -->
  2. <template>
  3. <view class="weighingRegistrationAddPage">
  4. <view class="weighingRegistrationAddPage-center-box">
  5. <view class="text-title-p">基础信息</view>
  6. <view class="content-box" style="padding-bottom:20rpx;">
  7. <view class="sub-picker-box">
  8. <view class="title-box-1" style="width:220rpx;">报备单编号:</view>
  9. <view class="text-p-1">{{addForm.reportNo}}</view>
  10. </view>
  11. <view class="sub-picker-box">
  12. <view class="title-box-1" style="width:220rpx;">实验室:</view>
  13. <view class="text-p-1">{{addForm.subName}}({{addForm.roomNum}})</view>
  14. </view>
  15. <view class="sub-picker-box">
  16. <view class="title-box-1" style="width:220rpx;">上门回收日期:</view>
  17. <view class="text-p-1">{{addForm.expectTime}}({{addForm.expectWeek}})</view>
  18. </view>
  19. <view class="sub-picker-box">
  20. <view class="title-box-1" style="width:220rpx;">废物种类:</view>
  21. <view class="text-p-1">{{addForm.typeNum}}</view>
  22. </view>
  23. <view class="sub-picker-box">
  24. <view class="title-box-1" style="width:220rpx;">报备人:</view>
  25. <view class="text-p-1">{{addForm.reportName}}({{addForm.reportAccount}})</view>
  26. </view>
  27. <view class="sub-picker-box">
  28. <view class="title-box-1" style="width:220rpx;">报备时间:</view>
  29. <view class="text-p-1">{{addForm.reportTime}}</view>
  30. </view>
  31. </view>
  32. <view class="text-title-p">称重登记</view>
  33. <view class="content-box">
  34. <view class="for-content-box" v-for="(item,index) in addForm.formData4" :key="index">
  35. <view class="sub-picker-box">
  36. <view class="mark-box">*</view>
  37. <view class="title-box">类型:</view>
  38. <view class="picker-box">
  39. <picker @change="(val)=>forChange(index,val)" :value="item.forData3" :range="item.forList" :range-key="'wasteName'">
  40. <view class="picker-p" :class="item.forData1?'check-picker-p':''">{{item.forData1?item.forData2:'请选择危废类型'}}</view>
  41. </picker>
  42. </view>
  43. <img class="right-button" v-if="addForm.formData4[1]"
  44. @click="reductionItemButton(index)"
  45. :src="imagesUrl('commonality/icon_zgsq_jian.png')">
  46. </view>
  47. <view class="sub-picker-box" v-if="item.forData1&&item.forData4">
  48. <view class="mark-box">*</view>
  49. <view class="title-box">数量:</view>
  50. <view class="picker-text-box">{{item.forData4+item.forData5}}</view>
  51. </view>
  52. <view class="sub-picker-box">
  53. <view class="mark-box">*</view>
  54. <view class="title-box">称重:</view>
  55. <view class="reduction-button" @click="reductionAdd(1,index)">-</view>
  56. <input class="input-p" type="digit" maxlength="10" @input="(val)=>handleInput(index,val)" v-model="item.forData6">
  57. <view class="add-button" @click="reductionAdd(2,index)">+</view>
  58. <view class="unit-p">kg</view>
  59. </view>
  60. </view>
  61. <view class="add-item-button" v-if="this.addForm.formData4.length < this.dialogOptionForList.length"
  62. @click="addItemButton()">补充其他未报备类型</view>
  63. <view class="sub-picker-box">
  64. <view class="mark-box"></view>
  65. <view class="title-box">图片:</view>
  66. <view class="explain-box">可拍摄称重凭据或回收人员照片,最多可上传3张</view>
  67. </view>
  68. <view class="sub-picker-box">
  69. <view class="img-list-box" v-if="addForm.imgList[0]">
  70. <view class="for-img-box" v-for="(img,imgIndex) in addForm.imgList" :key="imgIndex" >
  71. <p @click="delImg(imgIndex)">x</p>
  72. <img :src="baseUrl+img">
  73. </view>
  74. </view>
  75. <view class="img-up-p" @click="selectImage()" v-if="!addForm.imgList[2]">+</view>
  76. </view>
  77. <view class="sub-picker-box" style="padding-bottom:50rpx;">
  78. </view>
  79. </view>
  80. <view class="submit-button" @click="submitButton">登记完成,提交</view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. parseTime
  87. } from '@/component/public.js'
  88. import { config } from '@/api/request/config.js'
  89. import {
  90. hwmsAppWasteOrderList,
  91. hwmsAppWasteOrderWasteDetail,
  92. } from '@/pages_hazardousWasteRecycling/api/index.js'
  93. export default {
  94. data() {
  95. return {
  96. baseUrl:config.base_url,
  97. addForm:{
  98. expectTime: "",
  99. expectWeek: "",
  100. id: 0,
  101. subId: 0,
  102. reportAccount: "",
  103. reportName: "",
  104. reportNo: "",
  105. reportTime: "",
  106. roomNum: "",
  107. subName: "",
  108. typeNum: 0,
  109. formData4:[],
  110. imgList:[],
  111. },
  112. dialogOptionList:[],
  113. dialogOptionForList:[],
  114. }
  115. },
  116. onLoad(option) {
  117. this.hwmsAppWasteOrderList(option.id);
  118. },
  119. onShow() {
  120. },
  121. mounted() {
  122. },
  123. methods: {
  124. //提交按钮
  125. submitButton(){
  126. let self = this;
  127. if(!this.addForm.formData4[0]){
  128. uni.showToast({
  129. title: '请添加危废类型',
  130. icon: "none",
  131. mask: true,
  132. duration: 2000
  133. });
  134. return
  135. }
  136. for(let i=0;i<self.addForm.formData4.length;i++){
  137. if(!self.addForm.formData4[i].forData1){
  138. uni.showToast({
  139. title: '第'+(i+1)+'个类型没有选择',
  140. icon: "none",
  141. mask: true,
  142. duration: 2000
  143. });
  144. return
  145. }
  146. if(self.addForm.formData4[i].forData6 == 0){
  147. uni.showToast({
  148. title: self.addForm.formData4[i].forData2+'没有填写数量',
  149. icon: "none",
  150. mask: true,
  151. duration: 2000
  152. });
  153. return
  154. }
  155. }
  156. let obj = {
  157. id:this.addForm.id,
  158. recycleTime:this.addForm.expectTime,
  159. subId:this.addForm.subId,
  160. registerOrderAddItemBos:[],
  161. images:self.addForm.imgList,
  162. };
  163. for(let i=0;i<self.addForm.formData4.length;i++){
  164. obj.registerOrderAddItemBos.push({
  165. typeId:self.addForm.formData4[i].forData1,
  166. weight:self.addForm.formData4[i].forData6,
  167. })
  168. }
  169. uni.navigateTo({
  170. url: "/pages_hazardousWasteRecycling/views/weighingRegistration/signatureComponent?data=" + encodeURIComponent(JSON.stringify(obj))
  171. });
  172. },
  173. async hwmsAppWasteOrderList(id){
  174. const {
  175. data
  176. } = await hwmsAppWasteOrderList();
  177. if (data.code == 200) {
  178. this.$set(this,'dialogOptionForList',data.data.wasteOrder);
  179. this.hwmsAppWasteOrderWasteDetail(id);
  180. }
  181. },
  182. //详情
  183. async hwmsAppWasteOrderWasteDetail(id) {
  184. let self = this;
  185. const {
  186. data
  187. } = await hwmsAppWasteOrderWasteDetail({id:id});
  188. if (data.code == 200) {
  189. let list = [];
  190. for(let i=0;i<data.data.wasteOrderDetailItemVos.length;i++){
  191. for(let o=0;o<self.dialogOptionForList.length;o++){
  192. if(data.data.wasteOrderDetailItemVos[i].typeId == self.dialogOptionForList[o].id){
  193. let obj = {
  194. forData1:self.dialogOptionForList[o].id,
  195. forData2:self.dialogOptionForList[o].wasteName,
  196. forData3:o,
  197. forData4:data.data.wasteOrderDetailItemVos[i].quantity,
  198. forData5:self.dialogOptionForList[o].unit,
  199. forData6:0,
  200. forList:self.dialogOptionForList,
  201. }
  202. list.push(JSON.parse(JSON.stringify(obj)))
  203. }
  204. }
  205. }
  206. // item2.endDate = parseTime(item2.endDate, "{y}-{m}-{d}");
  207. this.$set(self.addForm,'expectTime',data.data.expectTime);
  208. this.$set(self.addForm,'expectWeek',data.data.expectWeek);
  209. this.$set(self.addForm,'id',data.data.id);
  210. this.$set(self.addForm,'subId',data.data.subId);
  211. this.$set(self.addForm,'reportAccount',data.data.reportAccount);
  212. this.$set(self.addForm,'reportName',data.data.reportName);
  213. this.$set(self.addForm,'reportNo',data.data.reportNo);
  214. this.$set(self.addForm,'reportTime',parseTime(data.data.reportTime, "{y}-{m}-{d} {h}:{i}:{s}"));
  215. this.$set(self.addForm,'roomNum',data.data.roomNum);
  216. this.$set(self.addForm,'subName',data.data.subName);
  217. this.$set(self.addForm,'typeNum',data.data.typeNum);
  218. this.$set(self.addForm,'formData4',list);
  219. this.filtrateList();
  220. }
  221. },
  222. //选中类型
  223. forChange(index,e){
  224. this.$set(this.addForm.formData4[index],'forData1',this.addForm.formData4[index].forList[e.detail.value].id);
  225. this.$set(this.addForm.formData4[index],'forData2',this.addForm.formData4[index].forList[e.detail.value].wasteName);
  226. this.$set(this.addForm.formData4[index],'forData5',this.addForm.formData4[index].forList[e.detail.value].unit);
  227. this.$set(this.addForm.formData4[index],'forData3',e.detail.value);
  228. this.filtrateList();
  229. },
  230. //单位值加减
  231. reductionAdd(type,index){
  232. if(type == 1){
  233. //减
  234. if(this.addForm.formData4[index].forData6>=1){
  235. this.$set(this.addForm.formData4[index],'forData6',this.addForm.formData4[index].forData6-1);
  236. }
  237. }else if(type == 2){
  238. //加
  239. if(this.addForm.formData4[index].forData6<9999){
  240. this.$set(this.addForm.formData4[index],'forData6',this.addForm.formData4[index].forData6+1);
  241. }
  242. }
  243. },
  244. //添加类型
  245. addItemButton(){
  246. if(this.addForm.formData4.length>= this.dialogOptionForList.length){
  247. uni.showToast({
  248. title: '没有更多类型可添加',
  249. icon: "none",
  250. mask: true,
  251. duration: 2000
  252. });
  253. return
  254. }
  255. this.addForm.formData4.push({
  256. forData1:'',
  257. forData2:'',
  258. forData3:'',
  259. forData4:0,
  260. forData5:'',
  261. forData6:0,
  262. forList:[],
  263. })
  264. this.filtrateList();
  265. },
  266. //删除类型
  267. reductionItemButton(index){
  268. let self = this;
  269. uni.showModal({
  270. // title: '确认要退出吗?',
  271. content: '确认删除该类型?',
  272. cancelColor: "#999",
  273. confirmColor: "#0183FA",
  274. success: function(res) {
  275. if (res.confirm) {
  276. self.addForm.formData4.splice(index,1);
  277. self.filtrateList();
  278. } else if (res.cancel) {}
  279. }
  280. });
  281. },
  282. // 图片上传
  283. selectImage() {
  284. let self = this;
  285. wx.chooseImage({
  286. count: 1,
  287. sizeType: ["original", "compressed"],
  288. sourceType: ["album", "camera"],
  289. success: function(res) {
  290. let tempFilePaths = res.tempFilePaths[0];
  291. self.uploadImg(tempFilePaths);
  292. }
  293. });
  294. },
  295. async uploadImg(tempFilePaths){
  296. var self = this;
  297. uni.showLoading({
  298. title: '上传中',
  299. mask: true
  300. });
  301. uni.uploadFile({
  302. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  303. header:{'Authorization':uni.getStorageSync('token')},
  304. filePath: tempFilePaths,
  305. name: 'file',
  306. formData: {
  307. 'user': 'test'
  308. },
  309. success: (uploadFileRes) => {
  310. let res = JSON.parse(uploadFileRes.data);
  311. if(res.code == 200){
  312. self.addForm.imgList.push(res.data.url)
  313. }else{
  314. uni.showToast({
  315. title: res.msg,
  316. icon:"none",
  317. mask:true,
  318. duration: 2000
  319. });
  320. }
  321. },
  322. fail: err => {},
  323. complete: () => {
  324. uni.hideLoading()
  325. }
  326. });
  327. },
  328. //删除图片
  329. delImg(index){
  330. let self = this;
  331. uni.showModal({
  332. // title: '确认要退出吗?',
  333. content: '确认删除该图片?',
  334. cancelColor: "#999",
  335. confirmColor: "#0183FA",
  336. success: function(res) {
  337. if (res.confirm) {
  338. self.addForm.imgList.splice(index,1);
  339. } else if (res.cancel) {}
  340. }
  341. });
  342. },
  343. // 小数点后两位
  344. handleInput(index,e){
  345. // 一定要加nextTick,否则特殊情况的更改不生效【如:000时,更改为0】
  346. this.$nextTick(() => {
  347. let value = e.detail.value
  348. // 如果当前输入为空,直接允许清空
  349. if (!value) {
  350. this.addForm.formData4[index].forData6 = ''
  351. } else if (value?.charAt(0) === '0' && value.charAt(1) && value.charAt(1) !== '.') {
  352. // // 1. 当第一位为0时,只能输入小数点【第二位必须是小数点】
  353. value = '0'
  354. }
  355. value = value.replace(/[^\d.]/g, '') // 清除"数字"和"."以外的字符
  356. value = value.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
  357. value = value.match(/^\d*(\.?\d{0,3})/g)[0] || '' // 保留3位小数
  358. this.addForm.formData4[index].forData6 = value
  359. })
  360. },
  361. //匹配数据
  362. filtrateList(){
  363. let self = this;
  364. let forList = JSON.parse(JSON.stringify(this.dialogOptionForList));
  365. let newList = JSON.parse(JSON.stringify(this.dialogOptionForList));
  366. for(let i=0;i<forList.length;i++){
  367. let num = 0;
  368. for(let o=0;o<self.addForm.formData4.length;o++){
  369. if(forList[i].id == self.addForm.formData4[o].forData1){
  370. num++
  371. break
  372. }
  373. }
  374. if(num!=0){
  375. forList.splice(i,1);
  376. i--
  377. }
  378. }
  379. for(let i=0;i<self.addForm.formData4.length;i++){
  380. let list = [];
  381. if(self.addForm.formData4[i].forData1){
  382. for(let o=0;o<newList.length;o++){
  383. if(self.addForm.formData4[i].forData1 == newList[o].value){
  384. list.push(newList[o]);
  385. }
  386. }
  387. }
  388. list = list.concat(forList)
  389. self.$set(self.addForm.formData4[i],'forList',JSON.parse(JSON.stringify(list)));
  390. }
  391. },
  392. },
  393. }
  394. </script>
  395. <style lang="stylus" scoped>
  396. .weighingRegistrationAddPage{
  397. height: 100%;
  398. display flex;
  399. flex:1;
  400. flex-direction column;
  401. overflow: hidden;
  402. .weighingRegistrationAddPage-top-box{
  403. height:380rpx;
  404. }
  405. .weighingRegistrationAddPage-center-box{
  406. flex:1;
  407. overflow-y: scroll;
  408. overflow-x: hidden
  409. display flex;
  410. flex-direction column;
  411. }
  412. .text-title-p{
  413. font-size:32rpx;
  414. color:#0183FA;
  415. line-height:80rpx;
  416. margin:0 20rpx;
  417. }
  418. .content-box{
  419. margin:0 20rpx;
  420. background-color: #fff;
  421. border-radius:10rpx;
  422. padding:20rpx 20rpx 0 10rpx;
  423. .for-content-box:nth-child(1){
  424. padding-top:0;
  425. border-top:none;
  426. }
  427. .for-content-box{
  428. margin-bottom:20rpx;
  429. padding-top:30rpx;
  430. border-top:1px solid #dedede;
  431. .right-button{
  432. margin-top:8rpx;
  433. margin-left:20rpx;
  434. width:50rpx;
  435. height:50rpx;
  436. }
  437. }
  438. .sub-picker-box{
  439. display: flex;
  440. padding:10rpx;
  441. .mark-box{
  442. width:17rpx;
  443. color:red;
  444. margin-left:10rpx;
  445. height:60rpx;
  446. line-height:60rpx;
  447. margin-bottom:20rpx;
  448. }
  449. .title-box-1{
  450. width:100rpx;
  451. margin:0 10rpx;
  452. height:40rpx;
  453. line-height:40rpx;
  454. }
  455. .text-p-1{
  456. flex:1;
  457. height:40rpx;
  458. line-height:40rpx;
  459. display:block;
  460. overflow:hidden;
  461. text-overflow:ellipsis;
  462. white-space:nowrap;
  463. }
  464. .title-box{
  465. width:100rpx;
  466. margin:0 10rpx;
  467. height:60rpx;
  468. line-height:60rpx;
  469. }
  470. .text-p{
  471. flex:1;
  472. text-align: right;
  473. height:60rpx;
  474. line-height:60rpx;
  475. }
  476. .picker-box{
  477. height:60rpx;
  478. flex:1;
  479. border:1rpx solid #dedede;
  480. border-radius:10rpx;
  481. .picker-p{
  482. padding:0 20rpx;
  483. color:#666;
  484. line-height:60rpx;
  485. width:300rpx;
  486. display:block;
  487. overflow:hidden;
  488. text-overflow:ellipsis;
  489. white-space:nowrap;
  490. }
  491. .check-picker-p{
  492. }
  493. }
  494. .picker-text-box{
  495. width:400rpx;
  496. line-height:60rpx;
  497. }
  498. .reduction-button{
  499. width:60rpx;
  500. height:60rpx;
  501. border:1rpx solid #0183FA;
  502. color:#0183FA;
  503. text-align: center;
  504. font-size:30rpx;
  505. line-height:58rpx;
  506. border-radius:6rpx;
  507. font-size:34rpx;
  508. font-weight:700;
  509. }
  510. .input-p{
  511. width:140rpx;
  512. height:60rpx;
  513. height:60rpx;
  514. text-align: center;
  515. border:1rpx solid #dedede;
  516. border-radius:6rpx;
  517. margin:0 20rpx;
  518. }
  519. .add-button{
  520. width:60rpx;
  521. height:60rpx;
  522. border:1rpx solid #0183FA;
  523. color:#0183FA;
  524. text-align: center;
  525. font-size:30rpx;
  526. line-height:58rpx;
  527. border-radius:6rpx;
  528. font-size:34rpx;
  529. font-weight:700;
  530. }
  531. .unit-p{
  532. text-align: center;
  533. flex:1;
  534. height:62rpx;
  535. line-height:60rpx;
  536. font-size:30rpx;
  537. }
  538. .input-text-p{
  539. flex:1;
  540. height:185rpx;
  541. border:1rpx solid #dedede;
  542. border-radius:6rpx;
  543. padding:20rpx;
  544. margin-right:70rpx;
  545. margin-bottom:30rpx;
  546. }
  547. .explain-box{
  548. flex:1;
  549. height:32rpx;
  550. line-height:30rpx;
  551. font-size:28rpx;
  552. color:#999;
  553. }
  554. .img-list-box{
  555. display: flex;
  556. .for-img-box{
  557. position: relative;
  558. width:200rpx;
  559. height:200rpx;
  560. margin-left:18rpx;
  561. p{
  562. position: absolute;
  563. top:0;
  564. right:0;
  565. border-radius:50%;
  566. width:40rpx;
  567. height:40rpx;
  568. line-height:38rpx;
  569. text-align: center;
  570. color:#fff;
  571. background-color: #FF6A6A;
  572. }
  573. img{
  574. display: inline-block;
  575. width:200rpx;
  576. height:200rpx;
  577. }
  578. }
  579. }
  580. .img-up-p{
  581. width:200rpx;
  582. height:200rpx;
  583. margin-left:18rpx;
  584. line-height:200rpx;
  585. text-align: center;
  586. border:1rpx solid #999;
  587. border-radius:10rpx;
  588. color:#999;
  589. line-height:200rpx;
  590. font-size:50rpx;
  591. }
  592. }
  593. .add-item-button{
  594. width:588rpx;
  595. line-height:80rpx;
  596. height:80rpx;
  597. margin:0 50rpx 20rpx;
  598. background-color: #fff;
  599. border:1rpx solid #0183FA;
  600. color:#0183FA;
  601. font-size:30rpx;
  602. text-align: center;
  603. border-radius:6rpx;
  604. }
  605. }
  606. .submit-button{
  607. width:650rpx;
  608. line-height:80rpx;
  609. height:80rpx;
  610. margin:20rpx 50rpx 60rpx;
  611. background-color: #0183FA;
  612. color:#fff;
  613. font-size:30rpx;
  614. text-align: center;
  615. border-radius:6rpx;
  616. }
  617. }
  618. </style>