| | |
| | | import { useI18n } from 'vue-i18n' |
| | | const { t } = useI18n() |
| | | let language = ref(localStorage.getItem('lang') || 'zh') |
| | | // import LanguageMixin from './lang/LanguageMixin' |
| | | const selectedProjectNoa = ref(null); // 当前选中的角色 |
| | | // const options = ref<any[]>([]); // 下拉选项列表 |
| | | const userName = ref(''); |
| | | const account = ref(''); |
| | | const password = ref(''); |
| | | const menuNumber = ref(''); |
| | | const remark = ref(''); |
| | | const menuName = ref(''); |
| | | |
| | | const tableData = ref([]) |
| | | const slot = ref('') |
| | | request.post("/deviceInteraction/menu/findMenusAll").then((res) => { |
| | | if (res.code == 200) { |
| | | console.log(res.data); |
| | | tableData.value = res.data |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | |
| | | } |
| | | }); |
| | | const titleSelectJsona = ref({ |
| | | processType: [], |
| | | |
| | | }) |
| | | // const handleInputChangea = async (value: string) => { |
| | | // if (value) { |
| | | // await fetchOptionsa(value); |
| | | // } else { |
| | | // options.value = []; // 清空选项列表 |
| | | // } |
| | | // }; |
| | | onMounted(() => { |
| | | // 在组件挂载后调用 fetchOptions('') 来加载初始数据(如果需要) |
| | | fetchOptionsa(''); |
| | | list(''); |
| | | }); |
| | | // 角色下拉选 |
| | | const fetchOptionsa = async () => { |
| | | const list = async () => { |
| | | try { |
| | | // 发送请求到后端接口 |
| | | const response = await request.post('/deviceInteraction/role/findRolesAll'); |
| | | const response = await request.post('/deviceInteraction/menu/findMenusAll'); |
| | | if (response.code === 200) { |
| | | titleSelectJsona.value.processTypea = response.data; |
| | | console.log(response.data); |
| | | |
| | | tableData.value = response.data |
| | | } else { |
| | | ElMessage.warning(response.data); |
| | | } |
| | |
| | | }; |
| | | // 处理编辑按钮点击 |
| | | function handleEdit(row) { |
| | | menuName.value = row.menuName; |
| | | menuNumber.value = row.menuNumber; |
| | | remark.value = row.remark; |
| | | window.localStorage.setItem('ids', row.id); |
| | | userName.value = row.userName; |
| | | if (row.roleList && row.roleList.length > 0) { |
| | | const firstRole = row.roleList[0]; |
| | | selectedProjectNoa.value = firstRole.id; // 设置为ID,而不是name |
| | | } |
| | | adda.value = true; // 显示对话框 |
| | | } |
| | | |
| | | function closeDialog(row) { |
| | | add.value = false; |
| | | userName.value = ''; |
| | | nickName.value = ''; |
| | | password.value = ''; |
| | | selectedProjectNoa.value = ''; |
| | | menuName.value = ''; |
| | | menuNumber.value = ''; |
| | | remark.value = ''; |
| | | } |
| | | function closeDialoga(row) { |
| | | adda.value = false; |
| | | userName.value = ''; |
| | | nickName.value = ''; |
| | | password.value = ''; |
| | | menuName.value = ''; |
| | | menuNumber.value = ''; |
| | | remark.value = ''; |
| | | } |
| | | // 添加 |
| | | const getTableRow = async () => { |
| | | try { |
| | | const response = await request.post('/deviceInteraction/account/addAccount', { |
| | | const response = await request.post('/deviceInteraction/menu/addMenu', { |
| | | id: 0, |
| | | menuName: menuName.value, |
| | | menuNumber: menuNumber.value, |
| | | remark: passwremarkord.value, |
| | | menuNumber: '', |
| | | remark: remark.value |
| | | }); |
| | | if (response.code === 200) { |
| | | // 绑定成功,处理逻辑 |
| | | ElMessage.success(response.message); |
| | | add.value = false; |
| | | tableData.value = response.data; |
| | | list() |
| | | // tableData.value = response.data; |
| | | } else { |
| | | // 请求失败,显示错误消息 |
| | | ElMessage.error(response.message); |
| | |
| | | let ids = window.localStorage.getItem('ids') |
| | | try { |
| | | const response = await request.post('/deviceInteraction/menu/updateMenu', { |
| | | account: account.value, |
| | | roleId: selectedProjectNoa.value, |
| | | userName: userName.value, |
| | | password: password.value, |
| | | id: ids, |
| | | menuName: menuName.value, |
| | | menuNumber: menuNumber.value, |
| | | remark: remark.value, |
| | | } |
| | | ); |
| | | if (response.code === 200) { |
| | | // 绑定成功,处理逻辑 |
| | | ElMessage.success(response.message); |
| | | adda.value = false; |
| | | tableData.value = response.data; |
| | | list() |
| | | // tableData.value = response.data; |
| | | } else { |
| | | // 请求失败,显示错误消息 |
| | | ElMessage.error(response.message); |
| | |
| | | }) |
| | | if (response.code === 200) { |
| | | ElMessage.success(response.message); |
| | | list() |
| | | } else { |
| | | // 删除失败,您可以处理错误或显示错误信息给用户 |
| | | ElMessage.error(response.msg); |
| | |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item :label="$t('customer.firstmenua')" :required="true" style="width: 25vw"> |
| | | <el-input v-model="userName" autocomplete="off" :placeholder="$t('customer.infirstmenu')" /> |
| | | <el-input v-model="menuName" autocomplete="off" :placeholder="$t('customer.infirstmenu')" /> |
| | | </el-form-item></div></div> |
| | | |
| | | </el-col> |
| | | </el-row> |
| | | <el-row style="margin-top: 10px;"> |
| | | <el-col :span="6"> |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item :label="$t('customer.remark')" style="width: 25vw"> |
| | | <el-input v-model="remark" autocomplete="off" :placeholder="$t('customer.inremark')" /> |
| | | </el-form-item></div></div> |
| | | |
| | | </el-col> |
| | |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item :label="$t('customer.firstmenua')" :required="true" style="width: 25vw"> |
| | | <el-input v-model="userName" autocomplete="off" :placeholder="$t('customer.infirstmenu')" /> |
| | | <el-input v-model="menuName" autocomplete="off" :placeholder="$t('customer.infirstmenu')" /> |
| | | </el-form-item></div></div> |
| | | |
| | | </el-col> |
| | | </el-row> |
| | | <el-row style="margin-top: 10px;"> |
| | | <el-col :span="6"> |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item :label="$t('customer.remark')" style="width: 25vw"> |
| | | <el-input v-model="remark" autocomplete="off" :placeholder="$t('customer.inremark')" /> |
| | | </el-form-item></div></div> |
| | | |
| | | </el-col> |
| | |
| | | </div> |
| | | <template #footer> |
| | | <div id="dialog-footer"> |
| | | <el-button type="primary" @click="getTableRow"> |
| | | <el-button type="primary" @click="getTableRowa"> |
| | | {{ $t('customer.sure') }} |
| | | </el-button> |
| | | <el-button @click="closeDialog">{{ $t('customer.cancel') }}</el-button> |
| | | <el-button @click="closeDialoga">{{ $t('customer.cancel') }}</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |