index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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="'label'">
  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.remarks"
  54. maxlength="100" @input="sumfontnum" placeholder="请输入备注说明"
  55. placeholder-style="font-size:28rpx;color:#999;"></textarea>
  56. </view>
  57. </view>
  58. <view class="submit-button">填写完毕,立即报备</view>
  59. </view>
  60. <!-- <view class="recyclingReportRecord-bottom-box">
  61. </view> -->
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. demo1,
  67. demo2
  68. } from '@/pages_hazardousWasteRecycling/api/index.js'
  69. export default {
  70. data() {
  71. return {
  72. timeData:'2025-11-04(星期四)',
  73. addForm:{
  74. subId:'',
  75. subName:'',
  76. subIndex:'',
  77. remarks:'',
  78. formData4:[],
  79. },
  80. subList: [
  81. { subId: 1, subName: "实验室1" },
  82. { subId: 2, subName: "实验室2" },
  83. { subId: 3, subName: "实验室3" },
  84. ],
  85. dialogOptionList:[],
  86. dialogOptionForList:[
  87. {value:'1',label:'数据1',dict:'斤'},
  88. {value:'2',label:'数据2',dict:'公斤'},
  89. {value:'3',label:'数据3',dict:'升'},
  90. {value:'4',label:'数据4',dict:'毫升'},
  91. {value:'5',label:'数据5',dict:'公升'},
  92. {value:'6',label:'数据6',dict:'克'},
  93. ],
  94. }
  95. },
  96. onLoad(option) {
  97. },
  98. onShow() {
  99. },
  100. mounted() {
  101. this.initialize(1);
  102. },
  103. methods: {
  104. //初始化
  105. initialize(type){
  106. let self = this;
  107. if(type == 1){
  108. //无数据-初始化
  109. for(let i=0;i<self.dialogOptionForList.length;i++){
  110. if(i<4){
  111. let obj = {
  112. forData1:self.dialogOptionForList[i].value,
  113. forData2:self.dialogOptionForList[i].label,
  114. forData3:i,
  115. forData4:0,
  116. forData5:self.dialogOptionForList[i].dict,
  117. forList:self.dialogOptionForList,
  118. }
  119. self.addForm.formData4.push(JSON.parse(JSON.stringify(obj)))
  120. }
  121. }
  122. this.filtrateList();
  123. }else if(type == 2){
  124. //有数据-初始化
  125. }
  126. },
  127. //选中实验室
  128. subChange(e) {
  129. this.$set(this.addForm,'subId',this.subList[e.detail.value].subId);
  130. this.$set(this.addForm,'subName',this.subList[e.detail.value].subName);
  131. this.$set(this.addForm,'subIndex',e.detail.value);
  132. },
  133. //选中类型
  134. forChange(index,e){
  135. this.$set(this.addForm.formData4[index],'forData1',this.addForm.formData4[index].forList[e.detail.value].value);
  136. this.$set(this.addForm.formData4[index],'forData2',this.addForm.formData4[index].forList[e.detail.value].label);
  137. this.$set(this.addForm.formData4[index],'forData5',this.addForm.formData4[index].forList[e.detail.value].dict);
  138. this.$set(this.addForm.formData4[index],'forData3',e.detail.value);
  139. this.filtrateList();
  140. },
  141. //单位值加减
  142. reductionAdd(type,index){
  143. if(type == 1){
  144. //减
  145. if(this.addForm.formData4[index].forData4>=1){
  146. this.$set(this.addForm.formData4[index],'forData4',this.addForm.formData4[index].forData4-1);
  147. }
  148. }else if(type == 2){
  149. //加
  150. if(this.addForm.formData4[index].forData4<9999){
  151. this.$set(this.addForm.formData4[index],'forData4',this.addForm.formData4[index].forData4+1);
  152. }
  153. }
  154. },
  155. //添加类型
  156. addItemButton(){
  157. if(this.addForm.formData4.length>= this.dialogOptionForList.length){
  158. uni.showToast({
  159. title: '没有更多类型可添加',
  160. icon: "none",
  161. mask: true,
  162. duration: 2000
  163. });
  164. return
  165. }
  166. this.addForm.formData4.push({
  167. forData1:'',
  168. forData2:'',
  169. forData3:'',
  170. forData4:0,
  171. forData5:'',
  172. forList:[],
  173. })
  174. this.filtrateList();
  175. },
  176. //删除类型
  177. reductionItemButton(index){
  178. this.addForm.formData4.splice(index,1);
  179. this.filtrateList();
  180. },
  181. // 小数点后两位
  182. handleInput(index,e){
  183. // 一定要加nextTick,否则特殊情况的更改不生效【如:000时,更改为0】
  184. this.$nextTick(() => {
  185. let value = e.detail.value
  186. // 如果当前输入为空,直接允许清空
  187. if (!value) {
  188. this.addForm.formData4[index].forData4 = ''
  189. } else if (value?.charAt(0) === '0' && value.charAt(1) && value.charAt(1) !== '.') {
  190. // // 1. 当第一位为0时,只能输入小数点【第二位必须是小数点】
  191. value = '0'
  192. }
  193. value = value.replace(/[^\d.]/g, '') // 清除"数字"和"."以外的字符
  194. value = value.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
  195. value = value.match(/^\d*(\.?\d{0,2})/g)[0] || '' // 保留2位小数
  196. this.addForm.formData4[index].forData4 = value
  197. })
  198. },
  199. //匹配数据
  200. filtrateList(){
  201. let self = this;
  202. let forList = JSON.parse(JSON.stringify(this.dialogOptionForList));
  203. let newList = JSON.parse(JSON.stringify(this.dialogOptionForList));
  204. for(let i=0;i<forList.length;i++){
  205. let num = 0;
  206. for(let o=0;o<self.addForm.formData4.length;o++){
  207. if(forList[i].value == self.addForm.formData4[o].forData1){
  208. num++
  209. break
  210. }
  211. }
  212. if(num!=0){
  213. forList.splice(i,1);
  214. i--
  215. }
  216. }
  217. for(let i=0;i<self.addForm.formData4.length;i++){
  218. let list = [];
  219. if(self.addForm.formData4[i].forData1){
  220. for(let o=0;o<newList.length;o++){
  221. if(self.addForm.formData4[i].forData1 == newList[o].value){
  222. list.push(newList[o]);
  223. }
  224. }
  225. }
  226. list = list.concat(forList)
  227. self.$set(self.addForm.formData4[i],'forList',JSON.parse(JSON.stringify(list)));
  228. }
  229. },
  230. },
  231. }
  232. </script>
  233. <style lang="stylus" scoped>
  234. .recyclingReportRecord{
  235. height: 100%;
  236. display flex;
  237. flex:1;
  238. flex-direction column;
  239. overflow: hidden;
  240. .recyclingReportRecord-top-box{
  241. height:380rpx;
  242. }
  243. .recyclingReportRecord-center-box{
  244. flex:1;
  245. overflow-y: scroll;
  246. overflow-x: hidden
  247. display flex;
  248. flex-direction column;
  249. }
  250. // .recyclingReportRecord-bottom-box{
  251. // height:200rpx;
  252. // }
  253. .text-title-p{
  254. font-size:32rpx;
  255. color:#0183FA;
  256. line-height:80rpx;
  257. margin:0 20rpx;
  258. }
  259. .content-box{
  260. margin:0 20rpx;
  261. background-color: #fff;
  262. border-radius:10rpx;
  263. padding:20rpx 20rpx 0 10rpx;
  264. .for-content-box{
  265. .right-button{
  266. margin-top:8rpx;
  267. margin-left:20rpx;
  268. width:50rpx;
  269. height:50rpx;
  270. }
  271. }
  272. .sub-picker-box{
  273. display: flex;
  274. padding:10rpx;
  275. .mark-box{
  276. color:red;
  277. margin-left:10rpx;
  278. height:60rpx;
  279. line-height:60rpx;
  280. margin-bottom:20rpx;
  281. }
  282. .title-box{
  283. width:100rpx;
  284. margin:0 10rpx;
  285. height:60rpx;
  286. line-height:60rpx;
  287. }
  288. .text-p{
  289. flex:1;
  290. text-align: right;
  291. height:60rpx;
  292. line-height:60rpx;
  293. }
  294. .picker-box{
  295. height:60rpx;
  296. flex:1;
  297. border:1rpx solid #dedede;
  298. border-radius:10rpx;
  299. .picker-p{
  300. padding:0 20rpx;
  301. color:#666;
  302. line-height:60rpx;
  303. }
  304. .check-picker-p{
  305. }
  306. }
  307. .reduction-button{
  308. width:60rpx;
  309. height:60rpx;
  310. border:1rpx solid #0183FA;
  311. color:#0183FA;
  312. text-align: center;
  313. font-size:30rpx;
  314. line-height:58rpx;
  315. border-radius:6rpx;
  316. font-size:34rpx;
  317. font-weight:700;
  318. }
  319. .input-p{
  320. width:140rpx;
  321. height:60rpx;
  322. height:60rpx;
  323. text-align: center;
  324. border:1rpx solid #dedede;
  325. border-radius:6rpx;
  326. margin:0 20rpx;
  327. }
  328. .add-button{
  329. width:60rpx;
  330. height:60rpx;
  331. border:1rpx solid #0183FA;
  332. color:#0183FA;
  333. text-align: center;
  334. font-size:30rpx;
  335. line-height:58rpx;
  336. border-radius:6rpx;
  337. font-size:34rpx;
  338. font-weight:700;
  339. }
  340. .unit-p{
  341. text-align: center;
  342. flex:1;
  343. height:62rpx;
  344. line-height:60rpx;
  345. font-size:30rpx;
  346. }
  347. .input-text-p{
  348. flex:1;
  349. height:185rpx;
  350. border:1rpx solid #dedede;
  351. border-radius:6rpx;
  352. padding:20rpx;
  353. margin-right:70rpx;
  354. margin-bottom:30rpx;
  355. }
  356. }
  357. .add-item-button{
  358. width:588rpx;
  359. line-height:80rpx;
  360. height:80rpx;
  361. margin:0 50rpx 20rpx;
  362. background-color: #fff;
  363. border:1rpx solid #0183FA;
  364. color:#0183FA;
  365. font-size:30rpx;
  366. text-align: center;
  367. border-radius:6rpx;
  368. }
  369. }
  370. .submit-button{
  371. width:650rpx;
  372. line-height:80rpx;
  373. height:80rpx;
  374. margin:20rpx 50rpx 60rpx;
  375. background-color: #0183FA;
  376. color:#fff;
  377. font-size:30rpx;
  378. text-align: center;
  379. border-radius:6rpx;
  380. }
  381. }
  382. </style>