index.vue 14 KB

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