index.vue 15 KB

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