index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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" @input="sumfontnum" 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. this.$set(this.addForm.formData4[index],'forData1',this.addForm.formData4[index].forList[e.detail.value].id);
  268. this.$set(this.addForm.formData4[index],'forData2',this.addForm.formData4[index].forList[e.detail.value].wasteName);
  269. this.$set(this.addForm.formData4[index],'forData5',this.addForm.formData4[index].forList[e.detail.value].unit);
  270. this.$set(this.addForm.formData4[index],'forData3',e.detail.value);
  271. this.filtrateList();
  272. },
  273. //单位值加减
  274. reductionAdd(type,index){
  275. if(type == 1){
  276. //减
  277. if(this.addForm.formData4[index].forData4>=1){
  278. this.$set(this.addForm.formData4[index],'forData4',this.addForm.formData4[index].forData4-1);
  279. }
  280. }else if(type == 2){
  281. //加
  282. if(this.addForm.formData4[index].forData4<9999){
  283. this.$set(this.addForm.formData4[index],'forData4',this.addForm.formData4[index].forData4+1);
  284. }
  285. }
  286. },
  287. //添加类型
  288. addItemButton(){
  289. if(this.addForm.formData4.length>= this.dialogOptionForList.length){
  290. uni.showToast({
  291. title: '没有更多类型可添加',
  292. icon: "none",
  293. mask: true,
  294. duration: 2000
  295. });
  296. return
  297. }
  298. this.addForm.formData4.push({
  299. forData1:'',
  300. forData2:'',
  301. forData3:'',
  302. forData4:0,
  303. forData5:'',
  304. forList:[],
  305. })
  306. this.filtrateList();
  307. },
  308. //删除类型
  309. reductionItemButton(index){
  310. this.addForm.formData4.splice(index,1);
  311. this.filtrateList();
  312. },
  313. // 小数点后两位
  314. handleInput(index,e){
  315. // 一定要加nextTick,否则特殊情况的更改不生效【如:000时,更改为0】
  316. this.$nextTick(() => {
  317. let value = e.detail.value
  318. // 如果当前输入为空,直接允许清空
  319. if (!value) {
  320. this.addForm.formData4[index].forData4 = ''
  321. } else if (value?.charAt(0) === '0' && value.charAt(1) && value.charAt(1) !== '.') {
  322. // // 1. 当第一位为0时,只能输入小数点【第二位必须是小数点】
  323. value = '0'
  324. }
  325. value = value.replace(/[^\d.]/g, '') // 清除"数字"和"."以外的字符
  326. value = value.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
  327. value = value.match(/^\d*(\.?\d{0,2})/g)[0] || '' // 保留2位小数
  328. this.addForm.formData4[index].forData4 = value
  329. })
  330. },
  331. //匹配数据
  332. filtrateList(){
  333. let self = this;
  334. let forList = JSON.parse(JSON.stringify(this.dialogOptionForList));
  335. let newList = JSON.parse(JSON.stringify(this.dialogOptionForList));
  336. for(let i=0;i<forList.length;i++){
  337. let num = 0;
  338. for(let o=0;o<self.addForm.formData4.length;o++){
  339. if(forList[i].id == self.addForm.formData4[o].forData1){
  340. num++
  341. break
  342. }
  343. }
  344. if(num!=0){
  345. forList.splice(i,1);
  346. i--
  347. }
  348. }
  349. for(let i=0;i<self.addForm.formData4.length;i++){
  350. let list = [];
  351. if(self.addForm.formData4[i].forData1){
  352. for(let o=0;o<newList.length;o++){
  353. if(self.addForm.formData4[i].forData1 == newList[o].id){
  354. list.push(newList[o]);
  355. }
  356. }
  357. }
  358. list = list.concat(forList)
  359. self.$set(self.addForm.formData4[i],'forList',JSON.parse(JSON.stringify(list)));
  360. }
  361. },
  362. },
  363. }
  364. </script>
  365. <style lang="stylus" scoped>
  366. .recyclingReportRecord{
  367. height: 100%;
  368. display flex;
  369. flex:1;
  370. flex-direction column;
  371. overflow: hidden;
  372. .recyclingReportRecord-top-box{
  373. height:380rpx;
  374. }
  375. .recyclingReportRecord-center-box{
  376. flex:1;
  377. overflow-y: scroll;
  378. overflow-x: hidden
  379. display flex;
  380. flex-direction column;
  381. }
  382. // .recyclingReportRecord-bottom-box{
  383. // height:200rpx;
  384. // }
  385. .text-title-p{
  386. font-size:32rpx;
  387. color:#0183FA;
  388. line-height:80rpx;
  389. margin:0 20rpx;
  390. }
  391. .content-box{
  392. margin:0 20rpx;
  393. background-color: #fff;
  394. border-radius:10rpx;
  395. padding:20rpx 20rpx 0 10rpx;
  396. .for-content-box{
  397. .right-button{
  398. margin-top:8rpx;
  399. margin-left:20rpx;
  400. width:50rpx;
  401. height:50rpx;
  402. }
  403. }
  404. .sub-picker-box{
  405. display: flex;
  406. padding:10rpx;
  407. .mark-box{
  408. color:red;
  409. margin-left:10rpx;
  410. height:60rpx;
  411. line-height:60rpx;
  412. margin-bottom:20rpx;
  413. }
  414. .title-box{
  415. width:100rpx;
  416. margin:0 10rpx;
  417. height:60rpx;
  418. line-height:60rpx;
  419. }
  420. .text-p{
  421. flex:1;
  422. text-align: right;
  423. height:60rpx;
  424. line-height:60rpx;
  425. }
  426. .picker-box{
  427. height:60rpx;
  428. flex:1;
  429. border:1rpx solid #dedede;
  430. border-radius:10rpx;
  431. .picker-p{
  432. padding:0 20rpx;
  433. color:#666;
  434. line-height:60rpx;
  435. width:400rpx;
  436. display:block;
  437. overflow:hidden;
  438. text-overflow:ellipsis;
  439. white-space:nowrap;
  440. }
  441. .check-picker-p{
  442. }
  443. }
  444. .reduction-button{
  445. width:60rpx;
  446. height:60rpx;
  447. border:1rpx solid #0183FA;
  448. color:#0183FA;
  449. text-align: center;
  450. font-size:30rpx;
  451. line-height:58rpx;
  452. border-radius:6rpx;
  453. font-size:34rpx;
  454. font-weight:700;
  455. }
  456. .input-p{
  457. width:140rpx;
  458. height:60rpx;
  459. height:60rpx;
  460. text-align: center;
  461. border:1rpx solid #dedede;
  462. border-radius:6rpx;
  463. margin:0 20rpx;
  464. }
  465. .add-button{
  466. width:60rpx;
  467. height:60rpx;
  468. border:1rpx solid #0183FA;
  469. color:#0183FA;
  470. text-align: center;
  471. font-size:30rpx;
  472. line-height:58rpx;
  473. border-radius:6rpx;
  474. font-size:34rpx;
  475. font-weight:700;
  476. }
  477. .unit-p{
  478. text-align: center;
  479. flex:1;
  480. height:62rpx;
  481. line-height:60rpx;
  482. font-size:30rpx;
  483. }
  484. .input-text-p{
  485. flex:1;
  486. height:185rpx;
  487. border:1rpx solid #dedede;
  488. border-radius:6rpx;
  489. padding:20rpx;
  490. margin-right:70rpx;
  491. margin-bottom:30rpx;
  492. }
  493. }
  494. .add-item-button{
  495. width:588rpx;
  496. line-height:80rpx;
  497. height:80rpx;
  498. margin:0 50rpx 20rpx;
  499. background-color: #fff;
  500. border:1rpx solid #0183FA;
  501. color:#0183FA;
  502. font-size:30rpx;
  503. text-align: center;
  504. border-radius:6rpx;
  505. }
  506. }
  507. .submit-button{
  508. width:650rpx;
  509. line-height:80rpx;
  510. height:80rpx;
  511. margin:20rpx 50rpx 60rpx;
  512. background-color: #0183FA;
  513. color:#fff;
  514. font-size:30rpx;
  515. text-align: center;
  516. border-radius:6rpx;
  517. }
  518. }
  519. </style>