Browse Source

删除配方

master
maochaoying 2 years ago
parent
commit
28935545cb
  1. 29
      src/components/Formula.vue
  2. 2
      src/components/dialogs/AddPreModal.vue
  3. 17
      src/components/dialogs/DelPreModal.vue
  4. 4
      src/store/modules/formula.js

29
src/components/Formula.vue

@ -15,16 +15,14 @@
: 'content_wrap' : 'content_wrap'
" "
> >
<div
class="line"
v-for="item in formulaStore?.formulaList"
:key="item.id"
>
<!-- v-for="item in formulaStore?.formulaList"
:key="item.id" -->
<div class="line">
<div class="username">{{ item?.formula_id }}</div> <div class="username">{{ item?.formula_id }}</div>
<div class="btns"> <div class="btns">
<div class="btn" @click="delModalShow">删除</div>
<div class="btn mg" @click="showSetting">配置</div>
<div class="btn" @click="runConfig">执行</div>
<div class="btn" @click="delModalShow(item)">删除</div>
<div class="btn mg" @click="showSetting(item)">配置</div>
<div class="btn" @click="runConfig(item)">执行</div>
</div> </div>
</div> </div>
<svg <svg
@ -120,13 +118,15 @@ import AddPreModal from 'cpns/dialogs/AddPreModal'
import PreSetting from './PreSetting' import PreSetting from './PreSetting'
import { getAllFormulaJSON } from '@/mock/command' import { getAllFormulaJSON } from '@/mock/command'
import { useWebSocketStore, useFormulaStore } from '@/store' import { useWebSocketStore, useFormulaStore } from '@/store'
import { startFormulaJSON } from '@/mock/command'
const webSocketStore = useWebSocketStore() const webSocketStore = useWebSocketStore()
const formulaStore = useFormulaStore() const formulaStore = useFormulaStore()
const delPreModalVisible = ref(false) const delPreModalVisible = ref(false)
const delModalShow = () => {
const delModalShow = item => {
formulaStore.updateCurrentFormula(item)
delPreModalVisible.value = true delPreModalVisible.value = true
} }
@ -147,7 +147,8 @@ const hideAddNewPreModal = () => {
const isSettingVisible = ref(false) const isSettingVisible = ref(false)
const showSetting = () => {
const showSetting = item => {
formulaStore.updateCurrentFormula(item)
isSettingVisible.value = true isSettingVisible.value = true
} }
@ -156,12 +157,14 @@ const hideSettingModal = () => {
} }
// //
const runConfig = () => {
console.log('run config')
const runConfig = item => {
formulaStore.updateCurrentFormula(item)
webSocketStore.sendCommandMsg(startFormulaJSON(item.id))
console.log('run config', item)
} }
onMounted(() => { onMounted(() => {
webSocketStore.sendCommandMsg(getAllFormulaJSON)
// webSocketStore.sendCommandMsg(getAllFormulaJSON)
}) })
</script> </script>

2
src/components/dialogs/AddPreModal.vue

@ -55,7 +55,7 @@ const addNewRecord = () => {
justify-content: center; justify-content: center;
.modal_content { .modal_content {
width: 476px; width: 476px;
height: 414px;
height: 314px;
border-radius: 16px; border-radius: 16px;
background: #ffffff; background: #ffffff;
position: relative; position: relative;

17
src/components/dialogs/DelPreModal.vue

@ -22,7 +22,7 @@
<span class="red">确定要删除当前预设吗</span> <span class="red">确定要删除当前预设吗</span>
</p> </p>
<div class="btns"> <div class="btns">
<div class="ok style-btn">确定</div>
<div class="ok style-btn" @click="delThisPre">确定</div>
<div class="cancel style-btn" @click="handleCancel">取消</div> <div class="cancel style-btn" @click="handleCancel">取消</div>
</div> </div>
</div> </div>
@ -30,6 +30,11 @@
</template> </template>
<script setup> <script setup>
import { useFormulaStore, useWebSocketStore } from '@/store'
import { delFormulaJSON, getAllFormulaJSON } from '@/mock/command'
const formulaStore = useFormulaStore()
const webSocketStore = useWebSocketStore()
const props = defineProps({ const props = defineProps({
hideDelModal: { hideDelModal: {
type: Function, type: Function,
@ -39,6 +44,16 @@ const props = defineProps({
const handleCancel = () => { const handleCancel = () => {
props.hideDelModal() props.hideDelModal()
} }
const delThisPre = () => {
if (formulaStore.currentFormula) {
webSocketStore.sendCommandMsg(
delFormulaJSON(formulaStore.currentFormula?.id),
)
webSocketStore.sendCommandMsg(getAllFormulaJSON)
}
props.hideDelModal()
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

4
src/store/modules/formula.js

@ -5,10 +5,14 @@ export const useFormulaStore = defineStore({
state: () => { state: () => {
return { return {
formulaList: [], formulaList: [],
currentFormula: {},
} }
}, },
// actions // actions
actions: { actions: {
updateCurrentFormula(currentFormula) {
this.currentFormula = currentFormula
},
updateFormulaList(formulaList) { updateFormulaList(formulaList) {
this.formulaList = formulaList this.formulaList = formulaList
}, },

Loading…
Cancel
Save