index.vue 14 KB

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