index.vue 12 KB

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