index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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. obj.isUpdate = this.subId?true:false;
  171. const {
  172. data
  173. } = await hwmsAppWasteOrderAdd(obj);
  174. if (data.code == 200) {
  175. uni.showToast({
  176. title: '提交成功',
  177. icon: "none",
  178. mask: true,
  179. duration: 2000
  180. });
  181. setTimeout(function() {
  182. uni.navigateBack();
  183. }, 2000);
  184. }
  185. },
  186. async hwmsAppWasteOrderFillWasteList(){
  187. let self = this;
  188. let obj = {
  189. isUpdate : this.subId?true:false
  190. };
  191. const {
  192. data
  193. } = await hwmsAppWasteOrderFillWasteList(obj);
  194. if (data.code == 200) {
  195. this.$set(this,'timeData',data.data.expectTime+'('+data.data.expectWeek+')');
  196. this.$set(this.addForm,'expectTime',data.data.expectTime);
  197. this.$set(this,'subList',data.data.subjectVos);
  198. this.$set(this,'dialogOptionForList',data.data.wasteOrder);
  199. if(this.subId){
  200. for(let i=0;i<self.subList.length;i++){
  201. if(this.subId == self.subList[i].subId){
  202. this.$set(this.addForm,'subId',self.subList[i].subId);
  203. this.$set(this.addForm,'subName',self.subList[i].subName);
  204. this.$set(this.addForm,'subIndex',i);
  205. }
  206. }
  207. this.hwmsAppWasteOrderWasteItems(this.subId);
  208. }
  209. }
  210. },
  211. //选中实验室
  212. subChange(e) {
  213. this.$set(this.addForm,'subId',this.subList[e.detail.value].subId);
  214. this.$set(this.addForm,'subName',this.subList[e.detail.value].subName);
  215. this.$set(this.addForm,'subIndex',e.detail.value);
  216. this.hwmsAppWasteOrderWasteItems(this.subList[e.detail.value].subId);
  217. },
  218. async hwmsAppWasteOrderWasteItems(subId){
  219. let self = this;
  220. const {
  221. data
  222. } = await hwmsAppWasteOrderWasteItems({subId:subId});
  223. if (data.code == 200) {
  224. if(data.data.id){
  225. //编辑
  226. let list = [];
  227. for(let i=0;i<data.data.wasteTypeVos.length;i++){
  228. for(let o=0;o<self.dialogOptionForList.length;o++){
  229. if(data.data.wasteTypeVos[i].typeId == self.dialogOptionForList[o].id){
  230. let obj = {
  231. forData1:self.dialogOptionForList[o].id,
  232. forData2:self.dialogOptionForList[o].wasteName,
  233. forData3:o,
  234. forData4:data.data.wasteTypeVos[i].quantity,
  235. forData5:self.dialogOptionForList[o].unit,
  236. forList:self.dialogOptionForList,
  237. }
  238. list.push(JSON.parse(JSON.stringify(obj)))
  239. }
  240. }
  241. }
  242. this.$set(self.addForm,'id',data.data.id);
  243. this.$set(self.addForm,'remark',data.data.remark);
  244. this.$set(self.addForm,'formData4',list);
  245. this.filtrateList();
  246. }else{
  247. //无数据-初始化
  248. let list = [];
  249. for(let i=0;i<self.dialogOptionForList.length;i++){
  250. if(i<4){
  251. let obj = {
  252. forData1:self.dialogOptionForList[i].id,
  253. forData2:self.dialogOptionForList[i].wasteName,
  254. forData3:i,
  255. forData4:0,
  256. forData5:self.dialogOptionForList[i].unit,
  257. forList:self.dialogOptionForList,
  258. }
  259. list.push(JSON.parse(JSON.stringify(obj)))
  260. }
  261. }
  262. this.$set(self.addForm,'id',null);
  263. this.$set(self.addForm,'remark','');
  264. this.$set(self.addForm,'formData4',list);
  265. this.filtrateList();
  266. }
  267. }
  268. },
  269. //选中类型
  270. forChange(index,e){
  271. let self = this;
  272. if(self.addForm.formData4[index].forList[e.detail.value].remarkEnable){
  273. uni.showModal({
  274. title: '确认添加?',
  275. content: self.addForm.formData4[index].forList[e.detail.value].remark,
  276. cancelColor: "#999",
  277. confirmColor: "#0183FA",
  278. success: function(res) {
  279. if(res.confirm){
  280. self.$set(self.addForm.formData4[index],'forData1',self.addForm.formData4[index].forList[e.detail.value].id);
  281. self.$set(self.addForm.formData4[index],'forData2',self.addForm.formData4[index].forList[e.detail.value].wasteName);
  282. self.$set(self.addForm.formData4[index],'forData5',self.addForm.formData4[index].forList[e.detail.value].unit);
  283. self.$set(self.addForm.formData4[index],'forData3',e.detail.value);
  284. self.filtrateList();
  285. }
  286. }
  287. });
  288. }else{
  289. self.$set(self.addForm.formData4[index],'forData1',self.addForm.formData4[index].forList[e.detail.value].id);
  290. self.$set(self.addForm.formData4[index],'forData2',self.addForm.formData4[index].forList[e.detail.value].wasteName);
  291. self.$set(self.addForm.formData4[index],'forData5',self.addForm.formData4[index].forList[e.detail.value].unit);
  292. self.$set(self.addForm.formData4[index],'forData3',e.detail.value);
  293. self.filtrateList();
  294. }
  295. },
  296. //单位值加减
  297. reductionAdd(type,index){
  298. if(type == 1){
  299. //减
  300. if(this.addForm.formData4[index].forData4>=1){
  301. this.$set(this.addForm.formData4[index],'forData4',this.addForm.formData4[index].forData4-1);
  302. }
  303. }else if(type == 2){
  304. //加
  305. if(this.addForm.formData4[index].forData4<9999){
  306. this.$set(this.addForm.formData4[index],'forData4',this.addForm.formData4[index].forData4+1);
  307. }
  308. }
  309. },
  310. //添加类型
  311. addItemButton(){
  312. if(this.addForm.formData4.length>= this.dialogOptionForList.length){
  313. uni.showToast({
  314. title: '没有更多类型可添加',
  315. icon: "none",
  316. mask: true,
  317. duration: 2000
  318. });
  319. return
  320. }
  321. this.addForm.formData4.push({
  322. forData1:'',
  323. forData2:'',
  324. forData3:'',
  325. forData4:0,
  326. forData5:'',
  327. forList:[],
  328. })
  329. this.filtrateList();
  330. },
  331. //删除类型
  332. reductionItemButton(index){
  333. let self = this;
  334. let num = 0;
  335. for(let i=0;i<self.dialogOptionForList.length;i++){
  336. if(self.dialogOptionForList[i].id == this.addForm.formData4[index].forData1){
  337. if(self.dialogOptionForList[i].remarkEnable){
  338. num++
  339. uni.showModal({
  340. title: '确认删除?',
  341. content: self.dialogOptionForList[i].remark,
  342. cancelColor: "#999",
  343. confirmColor: "#0183FA",
  344. success: function(res) {
  345. if(res.confirm){
  346. self.addForm.formData4.splice(index,1);
  347. self.filtrateList();
  348. }
  349. }
  350. });
  351. }
  352. }
  353. }
  354. if(num == 0){
  355. self.addForm.formData4.splice(index,1);
  356. self.filtrateList();
  357. }
  358. },
  359. // 小数点后两位
  360. handleInput(index,e){
  361. // 一定要加nextTick,否则特殊情况的更改不生效【如:000时,更改为0】
  362. this.$nextTick(() => {
  363. let value = e.detail.value
  364. // 如果当前输入为空,直接允许清空
  365. if (!value) {
  366. this.addForm.formData4[index].forData4 = ''
  367. } else if (value?.charAt(0) === '0' && value.charAt(1) && value.charAt(1) !== '.') {
  368. // // 1. 当第一位为0时,只能输入小数点【第二位必须是小数点】
  369. value = '0'
  370. }
  371. value = value.replace(/[^\d.]/g, '') // 清除"数字"和"."以外的字符
  372. value = value.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
  373. value = value.match(/^\d*(\.?\d{0,2})/g)[0] || '' // 保留2位小数
  374. this.addForm.formData4[index].forData4 = value
  375. })
  376. },
  377. //匹配数据
  378. filtrateList(){
  379. let self = this;
  380. let forList = JSON.parse(JSON.stringify(this.dialogOptionForList));
  381. let newList = JSON.parse(JSON.stringify(this.dialogOptionForList));
  382. for(let i=0;i<forList.length;i++){
  383. let num = 0;
  384. for(let o=0;o<self.addForm.formData4.length;o++){
  385. if(forList[i].id == self.addForm.formData4[o].forData1){
  386. num++
  387. break
  388. }
  389. }
  390. if(num!=0){
  391. forList.splice(i,1);
  392. i--
  393. }
  394. }
  395. for(let i=0;i<self.addForm.formData4.length;i++){
  396. let list = [];
  397. if(self.addForm.formData4[i].forData1){
  398. for(let o=0;o<newList.length;o++){
  399. if(self.addForm.formData4[i].forData1 == newList[o].id){
  400. list.push(newList[o]);
  401. }
  402. }
  403. }
  404. list = list.concat(forList)
  405. self.$set(self.addForm.formData4[i],'forList',JSON.parse(JSON.stringify(list)));
  406. }
  407. },
  408. },
  409. }
  410. </script>
  411. <style lang="stylus" scoped>
  412. .recyclingReportRecord{
  413. height: 100%;
  414. display flex;
  415. flex:1;
  416. flex-direction column;
  417. overflow: hidden;
  418. .recyclingReportRecord-top-box{
  419. height:380rpx;
  420. }
  421. .recyclingReportRecord-center-box{
  422. flex:1;
  423. overflow-y: scroll;
  424. overflow-x: hidden
  425. display flex;
  426. flex-direction column;
  427. }
  428. // .recyclingReportRecord-bottom-box{
  429. // height:200rpx;
  430. // }
  431. .text-title-p{
  432. font-size:32rpx;
  433. color:#0183FA;
  434. line-height:80rpx;
  435. margin:0 20rpx;
  436. }
  437. .content-box{
  438. margin:0 20rpx;
  439. background-color: #fff;
  440. border-radius:10rpx;
  441. padding:20rpx 20rpx 0 10rpx;
  442. .for-content-box{
  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. color:red;
  455. margin-left:10rpx;
  456. height:60rpx;
  457. line-height:60rpx;
  458. margin-bottom:20rpx;
  459. }
  460. .title-box{
  461. width:100rpx;
  462. margin:0 10rpx;
  463. height:60rpx;
  464. line-height:60rpx;
  465. }
  466. .text-p{
  467. flex:1;
  468. text-align: right;
  469. height:60rpx;
  470. line-height:60rpx;
  471. }
  472. .picker-box{
  473. height:60rpx;
  474. flex:1;
  475. border:1rpx solid #dedede;
  476. border-radius:10rpx;
  477. .picker-p{
  478. padding:0 20rpx;
  479. color:#666;
  480. line-height:60rpx;
  481. width:400rpx;
  482. display:block;
  483. overflow:hidden;
  484. text-overflow:ellipsis;
  485. white-space:nowrap;
  486. }
  487. .check-picker-p{
  488. }
  489. }
  490. .reduction-button{
  491. width:60rpx;
  492. height:60rpx;
  493. border:1rpx solid #0183FA;
  494. color:#0183FA;
  495. text-align: center;
  496. font-size:30rpx;
  497. line-height:58rpx;
  498. border-radius:6rpx;
  499. font-size:34rpx;
  500. font-weight:700;
  501. }
  502. .input-p{
  503. width:140rpx;
  504. height:60rpx;
  505. height:60rpx;
  506. text-align: center;
  507. border:1rpx solid #dedede;
  508. border-radius:6rpx;
  509. margin:0 20rpx;
  510. }
  511. .add-button{
  512. width:60rpx;
  513. height:60rpx;
  514. border:1rpx solid #0183FA;
  515. color:#0183FA;
  516. text-align: center;
  517. font-size:30rpx;
  518. line-height:58rpx;
  519. border-radius:6rpx;
  520. font-size:34rpx;
  521. font-weight:700;
  522. }
  523. .unit-p{
  524. text-align: center;
  525. flex:1;
  526. height:62rpx;
  527. line-height:60rpx;
  528. font-size:30rpx;
  529. }
  530. .input-text-p{
  531. flex:1;
  532. height:185rpx;
  533. border:1rpx solid #dedede;
  534. border-radius:6rpx;
  535. padding:20rpx;
  536. margin-right:70rpx;
  537. margin-bottom:30rpx;
  538. }
  539. }
  540. .add-item-button{
  541. width:588rpx;
  542. line-height:80rpx;
  543. height:80rpx;
  544. margin:0 50rpx 20rpx;
  545. background-color: #fff;
  546. border:1rpx solid #0183FA;
  547. color:#0183FA;
  548. font-size:30rpx;
  549. text-align: center;
  550. border-radius:6rpx;
  551. }
  552. }
  553. .submit-button{
  554. width:650rpx;
  555. line-height:80rpx;
  556. height:80rpx;
  557. margin:20rpx 50rpx 60rpx;
  558. background-color: #0183FA;
  559. color:#fff;
  560. font-size:30rpx;
  561. text-align: center;
  562. border-radius:6rpx;
  563. }
  564. }
  565. </style>