specimenBox.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import spe from '../json/spe.json'
  2. export default {
  3. //时间
  4. time(index) {
  5. var nowDate = new Date((new Date).getTime() + 8 * 60 * 60 * 1000)
  6. var time = nowDate.toJSON().split('T').join(' ').substr(0, index)
  7. return time
  8. },
  9. //弹出提示
  10. getPrompt(title, icon = 'none', duration = 2000) {
  11. uni.showToast({
  12. title: title,
  13. icon: icon,
  14. duration: duration
  15. })
  16. },
  17. getShowToast(val1, val2) {
  18. let title = '必填'
  19. switch (val2) {
  20. case 1:
  21. title = '必选一项'
  22. break
  23. case 2:
  24. title = '必添加'
  25. break
  26. case 3:
  27. title = '大于1'
  28. break
  29. default:
  30. title = '必填'
  31. }
  32. this.getPrompt(val1 + title)
  33. },
  34. getLHBata(form, parentForm, show1, show2, show3, show4) {
  35. // console.log(form, parentForm)
  36. let formLhypbIndex = form.lhypb.findIndex(item => item.yangPinBianHao == parentForm.yang_pin_bian_hao)
  37. let formLhypb = form.lhypb[formLhypbIndex]
  38. // formLhypb
  39. formLhypb.yangPinMingCheng = parentForm.yang_pin_ming_che
  40. formLhypb.xingBie = parentForm.xing_bie_
  41. formLhypb.xingMing = parentForm.xing_ming_
  42. formLhypb.nianLing = parentForm.nian_ling_
  43. formLhypb.songJianPiHao = parentForm.song_jian_pi_hao_
  44. formLhypb.yangPinZhuangTai = parentForm.yang_pin_zhuang_t
  45. formLhypb.songJianShiJian = parentForm.song_jian_shi_jia
  46. formLhypb.beiZhu1 = parentForm.bei_zhu_1_
  47. formLhypb.yangPinLeiXing = parentForm.yang_pin_lei_xing
  48. formLhypb.yangBenYunShuTiao = parentForm.yang_ben_yun_shu_
  49. formLhypb.shuLiang = parseInt(parentForm.shu_liang_ || 0)
  50. formLhypb.yangPinGuiGe = parentForm.yang_pin_gui_ge_
  51. formLhypb.yangPinLeiXingEr = parentForm.yang_pin_lei_er_
  52. formLhypb.yangPinYunShuTiao = parentForm.yang_pin_yun_shu_
  53. formLhypb.yangPinGuiGeEr = parentForm.yang_pin_gui_ge_e
  54. formLhypb.shuLiangEr = parseInt(parentForm.shu_liang_er_ || 0)
  55. formLhypb.yangPinLeiXingSan = parentForm.yang_pin_gui_ge_s
  56. formLhypb.shuLiangSan = parseInt(parentForm.shu_liang_san_ || 0)
  57. formLhypb.yangPinYunShuSan = parentForm.yang_pin_yun_san
  58. formLhypb.yangPinLeiXingSan = parentForm.yang_pin_lei_san_
  59. formLhypb.yangPinGuiGeSi = parentForm.yang_pin_gui_si_
  60. formLhypb.shuLiangSi = parseInt(parentForm.shu_liang_si_ || 0)
  61. formLhypb.yangPinYunShuSi = parentForm.yang_pin_yun_si_
  62. formLhypb.yangPinLeiXingSi = parentForm.yang_pin_lei_si_
  63. formLhypb.showBoolean1 = show1
  64. formLhypb.showBoolean2 = show2
  65. formLhypb.showBoolean3 = show3
  66. formLhypb.showBoolean4 = show4
  67. form.lhypb[formLhypbIndex] = formLhypb
  68. return form
  69. },
  70. getLHBataToast(form, show1, show2, show3, show4) {
  71. if (!show1 && !show2 && !show3 && !show4) {
  72. this.getPrompt('至少填写一组样品类型信息')
  73. return false
  74. }
  75. if (!show1) {
  76. this.getFormNull(spe.showBooleanList1, form)
  77. }
  78. if (show1 && !this.getEstimate(spe.showBooleanList1, form)) {
  79. return false
  80. }
  81. if (!show2) {
  82. this.getFormNull(spe.showBooleanList2, form)
  83. }
  84. if (show2 && !this.getEstimate(spe.showBooleanList2, form)) {
  85. return false
  86. }
  87. if (!show3) {
  88. this.getFormNull(spe.showBooleanList3, form)
  89. }
  90. if (show3 && !this.getEstimate(spe.showBooleanList3, form)) {
  91. return false
  92. }
  93. if (!show4) {
  94. this.getFormNull(spe.showBooleanList4, form)
  95. }
  96. if (show4 && !this.getEstimate(spe.showBooleanList4, form)) {
  97. return false
  98. }
  99. return true
  100. },
  101. getFormNull(list, form) {
  102. for (let item of list) {
  103. form[item.value] = ''
  104. }
  105. },
  106. //数据判断是否必填
  107. getEstimate(list, form) {
  108. for (let item of list) {
  109. if (item.type == 'number' && form[item.value] == 0) {
  110. this.getShowToast(item.text, item.num)
  111. return false
  112. } else if (item.type == 'string' && form[item.value] == '') {
  113. this.getShowToast(item.text, item.num)
  114. return false
  115. }
  116. }
  117. return true
  118. },
  119. getForm(result) {
  120. let obj = {
  121. yang_pin_bian_hao: result.yang_pin_bian_hao,
  122. yang_pin_ming_che: result.yang_pin_ming_che,
  123. xing_bie_: result.xing_bie_,
  124. xing_ming_: result.xing_ming_,
  125. nian_ling_: result.nian_ling_,
  126. song_jian_pi_hao_: result.song_jian_pi_hao_,
  127. yang_pin_zhuang_t: result.yang_pin_zhuang_t,
  128. song_jian_shi_jia: result.song_jian_shi_jia,
  129. bei_zhu_1_: result.bei_zhu_1_,
  130. yang_pin_lei_xing: result.yang_pin_lei_xing,
  131. yang_ben_yun_shu_: result.yang_ben_yun_shu_,
  132. shu_liang_: parseInt(result.shu_liang_ || 0),
  133. yang_pin_gui_ge_: result.yang_pin_gui_ge_,
  134. yang_pin_lei_er_: result.yang_pin_lei_er_,
  135. yang_pin_yun_shu_: result.yang_pin_yun_shu_,
  136. yang_pin_gui_ge_e: result.yang_pin_gui_ge_e,
  137. shu_liang_er_: parseInt(result.shu_liang_er_ || 0),
  138. yang_pin_gui_ge_s: result.yang_pin_gui_ge_s,
  139. shu_liang_san_: parseInt(result.shu_liang_san_ || 0),
  140. yang_pin_yun_san: result.yang_pin_yun_san,
  141. yang_pin_lei_san_: result.yang_pin_lei_san_,
  142. yang_pin_gui_si_: result.yang_pin_gui_si_,
  143. shu_liang_si_: parseInt(result.shu_liang_si_ || 0),
  144. yang_pin_yun_si_: result.yang_pin_yun_si_,
  145. yang_pin_lei_si_: result.yang_pin_lei_si_,
  146. xiang_mu_ming_che: result.xiang_mu_ming_che,
  147. yang_pin_zong_shu: parseInt(result.yang_pin_zong_shu)
  148. }
  149. return obj
  150. }
  151. }