specimenBox.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 && !this.getEstimate(spe.showBooleanList1, form)) {
  76. return false
  77. }
  78. if (show2 && !this.getEstimate(spe.showBooleanList2, form)) {
  79. return false
  80. }
  81. if (show3 && !this.getEstimate(spe.showBooleanList3, form)) {
  82. return false
  83. }
  84. if (show4 && !this.getEstimate(spe.showBooleanList4, form)) {
  85. return false
  86. }
  87. return true
  88. },
  89. //数据判断是否必填
  90. getEstimate(list, form) {
  91. for (let item of list) {
  92. if (item.type == 'number' && form[item.value] == 0) {
  93. this.getShowToast(item.text, item.num)
  94. return false
  95. } else if (item.type == 'string' && form[item.value] == '') {
  96. this.getShowToast(item.text, item.num)
  97. return false
  98. }
  99. }
  100. return true
  101. },
  102. }