| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- 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.getFormNull(spe.showBooleanList1, form)
- }
- if (show1 && !this.getEstimate(spe.showBooleanList1, form)) {
- return false
- }
- if (!show2) {
- this.getFormNull(spe.showBooleanList2, form)
- }
- if (show2 && !this.getEstimate(spe.showBooleanList2, form)) {
- return false
- }
- if (!show3) {
- this.getFormNull(spe.showBooleanList3, form)
- }
- if (show3 && !this.getEstimate(spe.showBooleanList3, form)) {
- return false
- }
- if (!show4) {
- this.getFormNull(spe.showBooleanList4, form)
- }
- if (show4 && !this.getEstimate(spe.showBooleanList4, form)) {
- return false
- }
- return true
- },
- getFormNull(list, form) {
- for (let item of list) {
- form[item.value] = ''
- }
- },
- //数据判断是否必填
- 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
- },
- getForm(result) {
- let obj = {
- yang_pin_bian_hao: result.yang_pin_bian_hao,
- yang_pin_ming_che: result.yang_pin_ming_che,
- xing_bie_: result.xing_bie_,
- xing_ming_: result.xing_ming_,
- nian_ling_: result.nian_ling_,
- song_jian_pi_hao_: result.song_jian_pi_hao_,
- yang_pin_zhuang_t: result.yang_pin_zhuang_t,
- song_jian_shi_jia: result.song_jian_shi_jia,
- bei_zhu_1_: result.bei_zhu_1_,
- yang_pin_lei_xing: result.yang_pin_lei_xing,
- yang_ben_yun_shu_: result.yang_ben_yun_shu_,
- shu_liang_: parseInt(result.shu_liang_ || 0),
- yang_pin_gui_ge_: result.yang_pin_gui_ge_,
- yang_pin_lei_er_: result.yang_pin_lei_er_,
- yang_pin_yun_shu_: result.yang_pin_yun_shu_,
- yang_pin_gui_ge_e: result.yang_pin_gui_ge_e,
- shu_liang_er_: parseInt(result.shu_liang_er_ || 0),
- yang_pin_gui_ge_s: result.yang_pin_gui_ge_s,
- shu_liang_san_: parseInt(result.shu_liang_san_ || 0),
- yang_pin_yun_san: result.yang_pin_yun_san,
- yang_pin_lei_san_: result.yang_pin_lei_san_,
- yang_pin_gui_si_: result.yang_pin_gui_si_,
- shu_liang_si_: parseInt(result.shu_liang_si_ || 0),
- yang_pin_yun_si_: result.yang_pin_yun_si_,
- yang_pin_lei_si_: result.yang_pin_lei_si_,
- xiang_mu_ming_che: result.xiang_mu_ming_che,
- yang_pin_zong_shu: parseInt(result.yang_pin_zong_shu)
- }
- return obj
- }
- }
|