index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <!-- 回收报备 -->
  2. <template>
  3. <view class="recyclingReportRecord">
  4. <view class="recyclingReportRecord-top-box">
  5. <view class="text-title-p">基础信息填写</view>
  6. <view class="content-box">
  7. <view class="sub-picker-box">
  8. <view class="mark-box">*</view>
  9. <view class="title-box">实验室</view>
  10. <view class="picker-box">
  11. <picker @change="subChange" :value="addForm.subIndex" :range="subList" :range-key="'subName'">
  12. <view class="picker-p" :class="addForm.subId?'check-picker-p':''">{{addForm.subId?addForm.subName:'请选择实验室'}}</view>
  13. </picker>
  14. </view>
  15. </view>
  16. <view class="sub-picker-box">
  17. <view class="mark-box">*</view>
  18. <view class="title-box" style="width:220rpx;">上门回收日期:</view>
  19. <view class="text-p">{{timeData}}</view>
  20. </view>
  21. </view>
  22. <view class="text-title-p">危废信息填报</view>
  23. </view>
  24. <view class="recyclingReportRecord-center-box">
  25. <view class="content-box">
  26. <view class="for-content-box" v-for="(item,index) in addForm.formData4" :key="index">
  27. <view class="sub-picker-box">
  28. <view class="mark-box">*</view>
  29. <view class="title-box">类型:</view>
  30. <view class="picker-box">
  31. <picker @change="(val)=>forChange(index,val)" :value="item.forData3" :range="item.forList" :range-key="'wasteName'">
  32. <view class="picker-p" :class="item.forData1?'check-picker-p':''">{{item.forData1?item.forData2:'请选择危废类型'}}</view>
  33. </picker>
  34. </view>
  35. <img class="right-button" v-if="addForm.formData4[1]"
  36. @click="reductionItemButton(index)"
  37. :src="imagesUrl('commonality/icon_zgsq_jian.png')">
  38. </view>
  39. <view class="sub-picker-box">
  40. <view class="mark-box">*</view>
  41. <view class="title-box">数量:</view>
  42. <view class="reduction-button" @click="reductionAdd(1,index)">-</view>
  43. <input class="input-p" type="digit" maxlength="10" @input="(val)=>handleInput(index,val)" v-model="item.forData4">
  44. <view class="add-button" @click="reductionAdd(2,index)">+</view>
  45. <view class="unit-p">{{item.forData1?item.forData5:''}}</view>
  46. </view>
  47. </view>
  48. <view class="add-item-button" v-if="this.addForm.formData4.length < this.dialogOptionForList.length"
  49. @click="addItemButton()">添加类型</view>
  50. <view class="sub-picker-box">
  51. <view class="mark-box"></view>
  52. <view class="title-box">备注:</view>
  53. <textarea class="input-text-p" type="text" v-model="addForm.remark"
  54. maxlength="100" placeholder="请输入备注说明"
  55. placeholder-style="font-size:28rpx;color:#999;"></textarea>
  56. </view>
  57. </view>
  58. <view class="submit-button" @click="submitButton">填写完毕,立即报备</view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. hwmsAppWasteOrderFillWasteList,
  65. hwmsAppWasteOrderAdd,
  66. hwmsAppWasteOrderWasteItems,
  67. } from '@/pages_hazardousWasteRecycling/api/index.js'
  68. export default {
  69. data() {
  70. return {
  71. timeData:'',
  72. addForm:{
  73. id:null,
  74. expectTime:'',
  75. subId:'',
  76. subName:'',
  77. subIndex:'',
  78. remark:'',
  79. formData4:[],
  80. },
  81. subList: [],
  82. dialogOptionList:[],
  83. dialogOptionForList:[],
  84. subId:null,
  85. }
  86. },
  87. onLoad(option) {
  88. if(option.skipType){
  89. uni.setStorageSync('recyclingReportRecord',true);
  90. }
  91. if(option.subId){
  92. this.$set(this,'subId',option.subId);
  93. }
  94. },
  95. onShow() {
  96. },
  97. mounted() {
  98. this.hwmsAppWasteOrderFillWasteList();
  99. },
  100. methods: {
  101. //提交
  102. submitButton(){
  103. let self = this;
  104. if(!this.addForm.subId){
  105. uni.showToast({
  106. title: '请选择实验室',
  107. icon: "none",
  108. mask: true,
  109. duration: 2000
  110. });
  111. return
  112. }
  113. if(!this.addForm.formData4[0]){
  114. uni.showToast({
  115. title: '请添加危废类型',
  116. icon: "none",
  117. mask: true,
  118. duration: 2000
  119. });
  120. return
  121. }
  122. for(let i=0;i<self.addForm.formData4.length;i++){
  123. if(!self.addForm.formData4[i].forData1){
  124. uni.showToast({
  125. title: '第'+(i+1)+'个类型没有选择',
  126. icon: "none",
  127. mask: true,
  128. duration: 2000
  129. });
  130. return
  131. }
  132. if(self.addForm.formData4[i].forData4 == 0){
  133. uni.showToast({
  134. title: self.addForm.formData4[i].forData2+'没有填写数量',
  135. icon: "none",
  136. mask: true,
  137. duration: 2000
  138. });
  139. return
  140. }
  141. }
  142. let obj = {
  143. id:this.addForm.id,
  144. expectTime:this.addForm.expectTime,
  145. remark:this.addForm.remark,
  146. subId:this.addForm.subId,
  147. wasteOrderItemList:[],
  148. }
  149. for(let i=0;i<self.addForm.formData4.length;i++){
  150. obj.wasteOrderItemList.push({
  151. quantity:self.addForm.formData4[i].forData4,
  152. typeId:self.addForm.formData4[i].forData1,
  153. })
  154. }
  155. uni.showModal({
  156. // title: '确认要退出吗?',
  157. content: '确认提交?',
  158. cancelColor: "#999",
  159. confirmColor: "#0183FA",
  160. success: function(res) {
  161. if (res.confirm) {
  162. self.hwmsAppWasteOrderAdd(obj);
  163. } else if (res.cancel) {}
  164. }
  165. });
  166. },
  167. //新增
  168. async hwmsAppWasteOrderAdd(obj){
  169. let self = this;
  170. const {
  171. data
  172. } = await hwmsAppWasteOrderAdd(obj);
  173. if (data.code == 200) {
  174. uni.showToast({
  175. title: '提交成功',
  176. icon: "none",
  177. mask: true,
  178. duration: 2000
  179. });
  180. setTimeout(function() {
  181. uni.navigateBack();
  182. }, 2000);
  183. }
  184. },
  185. async hwmsAppWasteOrderFillWasteList(){
  186. let self = this;
  187. const {
  188. data
  189. } = await hwmsAppWasteOrderFillWasteList();
  190. if (data.code == 200) {
  191. this.$set(this,'timeData',data.data.expectTime+'('+data.data.expectWeek+')');
  192. this.$set(this.addForm,'expectTime',data.data.expectTime);
  193. this.$set(this,'subList',data.data.subjectVos);
  194. this.$set(this,'dialogOptionForList',data.data.wasteOrder);
  195. if(this.subId){
  196. for(let i=0;i<self.subList.length;i++){
  197. if(this.subId == self.subList[i].subId){
  198. this.$set(this.addForm,'subId',self.subList[i].subId);
  199. this.$set(this.addForm,'subName',self.subList[i].subName);
  200. this.$set(this.addForm,'subIndex',i);
  201. }
  202. }
  203. this.hwmsAppWasteOrderWasteItems(this.subId);
  204. }
  205. }
  206. },
  207. //选中实验室
  208. subChange(e) {
  209. this.$set(this.addForm,'subId',this.subList[e.detail.value].subId);
  210. this.$set(this.addForm,'subName',this.subList[e.detail.value].subName);
  211. this.$set(this.addForm,'subIndex',e.detail.value);
  212. this.hwmsAppWasteOrderWasteItems(this.subList[e.detail.value].subId);
  213. },
  214. async hwmsAppWasteOrderWasteItems(subId){
  215. let self = this;
  216. const {
  217. data
  218. } = await hwmsAppWasteOrderWasteItems({subId:subId});
  219. if (data.code == 200) {
  220. if(data.data.id){
  221. //编辑
  222. let list = [];
  223. for(let i=0;i<data.data.wasteTypeVos.length;i++){
  224. for(let o=0;o<self.dialogOptionForList.length;o++){
  225. if(data.data.wasteTypeVos[i].typeId == self.dialogOptionForList[o].id){
  226. let obj = {
  227. forData1:self.dialogOptionForList[o].id,
  228. forData2:self.dialogOptionForList[o].wasteName,
  229. forData3:o,
  230. forData4:data.data.wasteTypeVos[i].quantity,
  231. forData5:self.dialogOptionForList[o].unit,
  232. forList:self.dialogOptionForList,
  233. }
  234. list.push(JSON.parse(JSON.stringify(obj)))
  235. }
  236. }
  237. }
  238. this.$set(self.addForm,'id',data.data.id);
  239. this.$set(self.addForm,'remark',data.data.remark);
  240. this.$set(self.addForm,'formData4',list);
  241. this.filtrateList();
  242. }else{
  243. //无数据-初始化
  244. let list = [];
  245. for(let i=0;i<self.dialogOptionForList.length;i++){
  246. if(i<4){
  247. let obj = {
  248. forData1:self.dialogOptionForList[i].id,
  249. forData2:self.dialogOptionForList[i].wasteName,
  250. forData3:i,
  251. forData4:0,
  252. forData5:self.dialogOptionForList[i].unit,
  253. forList:self.dialogOptionForList,
  254. }
  255. list.push(JSON.parse(JSON.stringify(obj)))
  256. }
  257. }
  258. this.$set(self.addForm,'id',null);
  259. this.$set(self.addForm,'remark','');
  260. this.$set(self.addForm,'formData4',list);
  261. this.filtrateList();
  262. }
  263. }
  264. },
  265. //选中类型
  266. forChange(index,e){
  267. let self = this;
  268. if(self.addForm.formData4[index].forList[e.detail.value].remarkEnable){
  269. uni.showModal({
  270. title: '确认添加?',
  271. content: self.addForm.formData4[index].forList[e.detail.value].remark,
  272. cancelColor: "#999",
  273. confirmColor: "#0183FA",
  274. success: function(res) {
  275. if(res.confirm){
  276. self.$set(self.addForm.formData4[index],'forData1',self.addForm.formData4[index].forList[e.detail.value].id);
  277. self.$set(self.addForm.formData4[index],'forData2',self.addForm.formData4[index].forList[e.detail.value].wasteName);
  278. self.$set(self.addForm.formData4[index],'forData5',self.addForm.formData4[index].forList[e.detail.value].unit);
  279. self.$set(self.addForm.formData4[index],'forData3',e.detail.value);
  280. self.filtrateList();
  281. }
  282. }
  283. });
  284. }else{
  285. self.$set(self.addForm.formData4[index],'forData1',self.addForm.formData4[index].forList[e.detail.value].id);
  286. self.$set(self.addForm.formData4[index],'forData2',self.addForm.formData4[index].forList[e.detail.value].wasteName);
  287. self.$set(self.addForm.formData4[index],'forData5',self.addForm.formData4[index].forList[e.detail.value].unit);
  288. self.$set(self.addForm.formData4[index],'forData3',e.detail.value);
  289. self.filtrateList();
  290. }
  291. },
  292. //单位值加减
  293. reductionAdd(type,index){
  294. if(type == 1){
  295. //减
  296. if(this.addForm.formData4[index].forData4>=1){
  297. this.$set(this.addForm.formData4[index],'forData4',this.addForm.formData4[index].forData4-1);
  298. }
  299. }else if(type == 2){
  300. //加
  301. if(this.addForm.formData4[index].forData4<9999){
  302. this.$set(this.addForm.formData4[index],'forData4',this.addForm.formData4[index].forData4+1);
  303. }
  304. }
  305. },
  306. //添加类型
  307. addItemButton(){
  308. if(this.addForm.formData4.length>= this.dialogOptionForList.length){
  309. uni.showToast({
  310. title: '没有更多类型可添加',
  311. icon: "none",
  312. mask: true,
  313. duration: 2000
  314. });
  315. return
  316. }
  317. this.addForm.formData4.push({
  318. forData1:'',
  319. forData2:'',
  320. forData3:'',
  321. forData4:0,
  322. forData5:'',
  323. forList:[],
  324. })
  325. this.filtrateList();
  326. },
  327. //删除类型
  328. reductionItemButton(index){
  329. let self = this;
  330. let num = 0;
  331. for(let i=0;i<self.dialogOptionForList.length;i++){
  332. if(self.dialogOptionForList[i].id == this.addForm.formData4[index].forData1){
  333. if(self.dialogOptionForList[i].remarkEnable){
  334. num++
  335. uni.showModal({
  336. title: '确认删除?',
  337. content: self.dialogOptionForList[i].remark,
  338. cancelColor: "#999",
  339. confirmColor: "#0183FA",
  340. success: function(res) {
  341. if(res.confirm){
  342. self.addForm.formData4.splice(index,1);
  343. self.filtrateList();
  344. }
  345. }
  346. });
  347. }
  348. }
  349. }
  350. if(num == 0){
  351. self.addForm.formData4.splice(index,1);
  352. self.filtrateList();
  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].forData4 = ''
  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,2})/g)[0] || '' // 保留2位小数
  370. this.addForm.formData4[index].forData4 = 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].id){
  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. .recyclingReportRecord{
  409. height: 100%;
  410. display flex;
  411. flex:1;
  412. flex-direction column;
  413. overflow: hidden;
  414. .recyclingReportRecord-top-box{
  415. height:380rpx;
  416. }
  417. .recyclingReportRecord-center-box{
  418. flex:1;
  419. overflow-y: scroll;
  420. overflow-x: hidden
  421. display flex;
  422. flex-direction column;
  423. }
  424. // .recyclingReportRecord-bottom-box{
  425. // height:200rpx;
  426. // }
  427. .text-title-p{
  428. font-size:32rpx;
  429. color:#0183FA;
  430. line-height:80rpx;
  431. margin:0 20rpx;
  432. }
  433. .content-box{
  434. margin:0 20rpx;
  435. background-color: #fff;
  436. border-radius:10rpx;
  437. padding:20rpx 20rpx 0 10rpx;
  438. .for-content-box{
  439. .right-button{
  440. margin-top:8rpx;
  441. margin-left:20rpx;
  442. width:50rpx;
  443. height:50rpx;
  444. }
  445. }
  446. .sub-picker-box{
  447. display: flex;
  448. padding:10rpx;
  449. .mark-box{
  450. color:red;
  451. margin-left:10rpx;
  452. height:60rpx;
  453. line-height:60rpx;
  454. margin-bottom:20rpx;
  455. }
  456. .title-box{
  457. width:100rpx;
  458. margin:0 10rpx;
  459. height:60rpx;
  460. line-height:60rpx;
  461. }
  462. .text-p{
  463. flex:1;
  464. text-align: right;
  465. height:60rpx;
  466. line-height:60rpx;
  467. }
  468. .picker-box{
  469. height:60rpx;
  470. flex:1;
  471. border:1rpx solid #dedede;
  472. border-radius:10rpx;
  473. .picker-p{
  474. padding:0 20rpx;
  475. color:#666;
  476. line-height:60rpx;
  477. width:400rpx;
  478. display:block;
  479. overflow:hidden;
  480. text-overflow:ellipsis;
  481. white-space:nowrap;
  482. }
  483. .check-picker-p{
  484. }
  485. }
  486. .reduction-button{
  487. width:60rpx;
  488. height:60rpx;
  489. border:1rpx solid #0183FA;
  490. color:#0183FA;
  491. text-align: center;
  492. font-size:30rpx;
  493. line-height:58rpx;
  494. border-radius:6rpx;
  495. font-size:34rpx;
  496. font-weight:700;
  497. }
  498. .input-p{
  499. width:140rpx;
  500. height:60rpx;
  501. height:60rpx;
  502. text-align: center;
  503. border:1rpx solid #dedede;
  504. border-radius:6rpx;
  505. margin:0 20rpx;
  506. }
  507. .add-button{
  508. width:60rpx;
  509. height:60rpx;
  510. border:1rpx solid #0183FA;
  511. color:#0183FA;
  512. text-align: center;
  513. font-size:30rpx;
  514. line-height:58rpx;
  515. border-radius:6rpx;
  516. font-size:34rpx;
  517. font-weight:700;
  518. }
  519. .unit-p{
  520. text-align: center;
  521. flex:1;
  522. height:62rpx;
  523. line-height:60rpx;
  524. font-size:30rpx;
  525. }
  526. .input-text-p{
  527. flex:1;
  528. height:185rpx;
  529. border:1rpx solid #dedede;
  530. border-radius:6rpx;
  531. padding:20rpx;
  532. margin-right:70rpx;
  533. margin-bottom:30rpx;
  534. }
  535. }
  536. .add-item-button{
  537. width:588rpx;
  538. line-height:80rpx;
  539. height:80rpx;
  540. margin:0 50rpx 20rpx;
  541. background-color: #fff;
  542. border:1rpx solid #0183FA;
  543. color:#0183FA;
  544. font-size:30rpx;
  545. text-align: center;
  546. border-radius:6rpx;
  547. }
  548. }
  549. .submit-button{
  550. width:650rpx;
  551. line-height:80rpx;
  552. height:80rpx;
  553. margin:20rpx 50rpx 60rpx;
  554. background-color: #0183FA;
  555. color:#fff;
  556. font-size:30rpx;
  557. text-align: center;
  558. border-radius:6rpx;
  559. }
  560. }
  561. </style>