Browse Source

user禁止删除超管

配方选中bug
master
王梦远 2 weeks ago
parent
commit
1c9fecd70b
  1. 24
      src/components/formula/FormulaTable.vue
  2. 4
      src/components/setting/User.vue

24
src/components/formula/FormulaTable.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { syncSendCmd } from 'apis/system' import { syncSendCmd } from 'apis/system'
import { ElMessageBox } from 'element-plus' import { ElMessageBox } from 'element-plus'
import { onMounted, ref, watchEffect } from 'vue'
import { onMounted, ref, watch } from 'vue'
import { FtMessage } from '@/libs/message' import { FtMessage } from '@/libs/message'
import { FtMessageBox } from '@/libs/messageBox' import { FtMessageBox } from '@/libs/messageBox'
@ -9,7 +9,7 @@ import { convertValuesToInt } from '@/libs/utils'
import { useFormulaStore } from '@/stores/formulaStore' import { useFormulaStore } from '@/stores/formulaStore'
const formulaStore = useFormulaStore() const formulaStore = useFormulaStore()
const selectedIndex = ref<number | null>(null)
const selectedIndex = ref<number | null>(0)
const recipes = ref<Formula.FormulaItem[]>([]) const recipes = ref<Formula.FormulaItem[]>([])
const currectFormula = ref<Formula.FormulaItem>() const currectFormula = ref<Formula.FormulaItem>()
@ -28,10 +28,15 @@ onMounted(() => {
initFormulaList() initFormulaList()
}) })
watchEffect(() => {
watch(formulaStore.formulaList, () => {
recipes.value = formulaStore.formulaList recipes.value = formulaStore.formulaList
if (formulaStore.formulaList) { if (formulaStore.formulaList) {
selectedIndex.value = formulaStore.selectedIndex || formulaStore.formulaList.length
if (formulaStore.selectedIndex != null) {
selectedIndex.value = formulaStore.selectedIndex
}
else {
selectedIndex.value = formulaStore.formulaList.length - 1
}
} }
}) })
@ -43,7 +48,9 @@ const initFormulaList = () => {
formulaStore.initFormulaList() formulaStore.initFormulaList()
} }
} }
watch(selectedIndex, () => {
})
const selectRecipe = (item: Formula.FormulaItem, index: number) => { const selectRecipe = (item: Formula.FormulaItem, index: number) => {
selectedIndex.value = selectedIndex.value === index ? null : index selectedIndex.value = selectedIndex.value === index ? null : index
formulaStore.updateSelectedIndex(index) formulaStore.updateSelectedIndex(index)
@ -109,7 +116,7 @@ const deleteRecipe = (item: Formula.FormulaItem) => {
<ul class="recipe-list"> <ul class="recipe-list">
<li <li
v-for="(item, index) in recipes" v-for="(item, index) in recipes"
:key="index + 1"
:key="index"
:class="{ selected: selectedIndex === index }" :class="{ selected: selectedIndex === index }"
@click="selectRecipe(item, index)" @click="selectRecipe(item, index)"
> >
@ -121,9 +128,6 @@ const deleteRecipe = (item: Formula.FormulaItem) => {
<el-button class="delete-button" @click.stop="deleteRecipe(item)"> <el-button class="delete-button" @click.stop="deleteRecipe(item)">
删除 删除
</el-button> </el-button>
<span v-if="selectedIndex === index" class="selected-icon">
<el-icon><Check /></el-icon> <!-- 使 -->
</span>
</div> </div>
</li> </li>
</ul> </ul>
@ -175,8 +179,8 @@ const deleteRecipe = (item: Formula.FormulaItem) => {
.recipe-list li.selected { .recipe-list li.selected {
background-color: #e6f7ff; background-color: #e6f7ff;
/* border: 1px solid #1890ff; */
/* padding: 9px; */
border-left: 5px solid #1890ff;
padding: 9px;
} }
.actions { .actions {

4
src/components/setting/User.vue

@ -45,10 +45,6 @@ const onAddUser = () => {
settingStore.updateVisible(true) settingStore.updateVisible(true)
} }
const onDelUser = (user: User.UserItem) => { const onDelUser = (user: User.UserItem) => {
// if (selectedUserList.value.length !== 1) {
// FtMessage.warning('')
// return
// }
// //
if (user.id === userInfo.id) { if (user.id === userInfo.id) {
FtMessage.warning('自己不可删除自己') FtMessage.warning('自己不可删除自己')

Loading…
Cancel
Save