addPage.vue 18 KB

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