Browse Source

蠕动泵的设置

master
maochaoying 2 years ago
parent
commit
9a81eb7db5
  1. 35
      src/components/Setting/components/Device.vue
  2. 3
      src/main.js
  3. 12
      src/store/modules/setting.js

35
src/components/Setting/components/Device.vue

@ -11,7 +11,7 @@
placeholder="设置加液蠕动泵转速" placeholder="设置加液蠕动泵转速"
/> />
</p> </p>
<div class="btn">设置</div>
<div class="btn" @click="setAddliquidVal">设置</div>
</div> </div>
<div class="row_wrap"> <div class="row_wrap">
<p class="title">喷液蠕动泵</p> <p class="title">喷液蠕动泵</p>
@ -24,17 +24,42 @@
placeholder="设置喷液蠕动泵转速" placeholder="设置喷液蠕动泵转速"
/> />
</p> </p>
<div class="btn">设置</div>
<div class="btn" @click="setSprayLiquidVal">设置</div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
const addLiquidVal = ref(0)
const sprayLiquidVal = ref(0)
import { showSuccessToast, showFailToast } from 'vant'
import { useSettingStore } from '@/store'
const settingStore = useSettingStore()
const addLiquidVal = ref(settingStore.addLiquidConfigVal)
const sprayLiquidVal = ref(settingStore.sprayLiquidConfigVal)
const formatter = value => value + '/g'
const formatter = value => {
if (value != 0) {
var newVal = value.replace(/\b(0+)/gi, '')
return newVal + '/g'
}
return '0/g'
}
const setAddliquidVal = () => {
const val = parseInt(
addLiquidVal.value.substring(0, addLiquidVal.value.length - 2),
)
settingStore.changeAddLiquidConfigVal(val)
showSuccessToast('设置成功')
}
const setSprayLiquidVal = () => {
const val = parseInt(
sprayLiquidVal.value.substring(0, sprayLiquidVal.value.length - 2),
)
settingStore.changeSprayLiquidConfigVal(val)
showSuccessToast('设置成功')
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

3
src/main.js

@ -2,7 +2,7 @@ import { createApp } from 'vue'
import router from './router' import router from './router'
import store from './store' import store from './store'
import App from './App.vue' import App from './App.vue'
import { DatePicker, TimePicker, Picker, Field } from 'vant'
import { DatePicker, TimePicker, Picker, Field, Toast } from 'vant'
import 'vant/lib/index.css' import 'vant/lib/index.css'
import '@/assets/css/reset.css' import '@/assets/css/reset.css'
import './style.scss' import './style.scss'
@ -13,5 +13,6 @@ createApp(App)
.use(DatePicker) .use(DatePicker)
.use(TimePicker) .use(TimePicker)
.use(Field) .use(Field)
.use(Toast)
.use(store) .use(store)
.mount('#app') .mount('#app')

12
src/store/modules/setting.js

@ -4,8 +4,14 @@ export const useSettingStore = defineStore({
// state // state
state: () => { state: () => {
return { return {
// 设置当前日期
currentDate: [], currentDate: [],
// 设置当前时间
currentTime: [], currentTime: [],
// 设置加液泵的参数
addLiquidConfigVal: 0,
// 设置喷液泵的参数
sprayLiquidConfigVal: 0,
} }
}, },
// actions // actions
@ -16,5 +22,11 @@ export const useSettingStore = defineStore({
updateCurrentTime(currentTime) { updateCurrentTime(currentTime) {
this.currentTime = currentTime this.currentTime = currentTime
}, },
changeAddLiquidConfigVal(val) {
this.addLiquidConfigVal = val
},
changeSprayLiquidConfigVal(val) {
this.sprayLiquidConfigVal = val
},
}, },
}) })
Loading…
Cancel
Save