addPage.vue 17 KB

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