| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import spe from '../json/spe.json'
- export default {
- //时间
- time(index) {
- var nowDate = new Date((new Date).getTime() + 8 * 60 * 60 * 1000)
- var time = nowDate.toJSON().split('T').join(' ').substr(0, index)
- return time
- },
- //弹出提示
- getPrompt(title, icon = 'none', duration = 2000) {
- uni.showToast({
- title: title,
- icon: icon,
- duration: duration
- })
- },
- getShowToast(val1, val2) {
- let title = '必填'
- switch (val2) {
- case 1:
- title = '必选一项'
- break
- case 2:
- title = '必添加'
- break
- case 3:
- title = '大于1'
- break
- default:
- title = '必填'
- }
- this.getPrompt(val1 + title)
- },
- getLHBata(form, parentForm, show1, show2, show3, show4) {
- // console.log(form, parentForm)
- let formLhypbIndex = form.lhypb.findIndex(item => item.yangPinBianHao == parentForm.yang_pin_bian_hao)
- let formLhypb = form.lhypb[formLhypbIndex]
- // formLhypb
- formLhypb.yangPinMingCheng = parentForm.yang_pin_ming_che
- formLhypb.xingBie = parentForm.xing_bie_
- formLhypb.xingMing = parentForm.xing_ming_
- formLhypb.nianLing = parentForm.nian_ling_
- formLhypb.songJianPiHao = parentForm.song_jian_pi_hao_
- formLhypb.yangPinZhuangTai = parentForm.yang_pin_zhuang_t
- formLhypb.songJianShiJian = parentForm.song_jian_shi_jia
- formLhypb.beiZhu1 = parentForm.bei_zhu_1_
- formLhypb.yangPinLeiXing = parentForm.yang_pin_lei_xing
- formLhypb.yangBenYunShuTiao = parentForm.yang_ben_yun_shu_
- formLhypb.shuLiang = parseInt(parentForm.shu_liang_ || 0)
- formLhypb.yangPinGuiGe = parentForm.yang_pin_gui_ge_
- formLhypb.yangPinLeiXingEr = parentForm.yang_pin_lei_er_
- formLhypb.yangPinYunShuTiao = parentForm.yang_pin_yun_shu_
- formLhypb.yangPinGuiGeEr = parentForm.yang_pin_gui_ge_e
- formLhypb.shuLiangEr = parseInt(parentForm.shu_liang_er_ || 0)
- formLhypb.yangPinLeiXingSan = parentForm.yang_pin_gui_ge_s
- formLhypb.shuLiangSan = parseInt(parentForm.shu_liang_san_ || 0)
- formLhypb.yangPinYunShuSan = parentForm.yang_pin_yun_san
- formLhypb.yangPinLeiXingSan = parentForm.yang_pin_lei_san_
- formLhypb.yangPinGuiGeSi = parentForm.yang_pin_gui_si_
- formLhypb.shuLiangSi = parseInt(parentForm.shu_liang_si_ || 0)
- formLhypb.yangPinYunShuSi = parentForm.yang_pin_yun_si_
- formLhypb.yangPinLeiXingSi = parentForm.yang_pin_lei_si_
- formLhypb.showBoolean1 = show1
- formLhypb.showBoolean2 = show2
- formLhypb.showBoolean3 = show3
- formLhypb.showBoolean4 = show4
- form.lhypb[formLhypbIndex] = formLhypb
- return form
- },
- getLHBataToast(form, show1, show2, show3, show4) {
- if (!show1 && !show2 && !show3 && !show4) {
- this.getPrompt('至少填写一组样品类型信息')
- return false
- }
- if (show1 && !this.getEstimate(spe.showBooleanList1, form)) {
- return false
- }
- if (show2 && !this.getEstimate(spe.showBooleanList2, form)) {
- return false
- }
- if (show3 && !this.getEstimate(spe.showBooleanList3, form)) {
- return false
- }
- if (show4 && !this.getEstimate(spe.showBooleanList4, form)) {
- return false
- }
- return true
- },
- //数据判断是否必填
- getEstimate(list, form) {
- for (let item of list) {
- if (item.type == 'number' && form[item.value] == 0) {
- this.getShowToast(item.text, item.num)
- return false
- } else if (item.type == 'string' && form[item.value] == '') {
- this.getShowToast(item.text, item.num)
- return false
- }
- }
- return true
- },
- }
|