大屏项目初始化
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
size="large"
|
||||
show-password
|
||||
show-password
|
||||
prefix-icon="Lock"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
@@ -33,7 +33,7 @@
|
||||
class="login-btn"
|
||||
size="small"
|
||||
:loading="isLoading"
|
||||
round
|
||||
round
|
||||
>
|
||||
登录
|
||||
</el-button>
|
||||
@@ -47,10 +47,14 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { login } from '@/api/user'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const loginFormRef = ref(null)
|
||||
const loginForm = ref({
|
||||
username: '',
|
||||
@@ -67,16 +71,16 @@ const handleLogin = async () => {
|
||||
await loginFormRef.value.validate();
|
||||
isLoading.value = true;
|
||||
const res = await login(loginForm.value);
|
||||
localStorage.setItem('token', res.token);
|
||||
localStorage.setItem('loginUser', JSON.stringify(res.loginUser));
|
||||
ElMessage.success('登录成功!');
|
||||
userStore.login(res);
|
||||
ElMessage.success('登录成功!');
|
||||
const redirect = route.query.redirect || '/dashboard';
|
||||
setTimeout(() => {
|
||||
router.push('/dashboard');
|
||||
router.push(redirect);
|
||||
}, 300);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}finally{
|
||||
isLoading.value = false;
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
placeholder="请选择性别"
|
||||
clearable
|
||||
>
|
||||
<el-option label="男" value="男" />
|
||||
<el-option label="女" value="女" />
|
||||
<el-option label="未知" value="未知" />
|
||||
<el-option label="男" value="0" />
|
||||
<el-option label="女" value="1" />
|
||||
<el-option label="未知" value="9" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
@@ -193,7 +193,6 @@ onMounted(() => {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 布局样式 */
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
@@ -98,9 +98,9 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Download, Edit, Delete } from '@element-plus/icons-vue'
|
||||
import { getHomeUserList } from '@/api/bizUser'
|
||||
import { getHomeUserList, getHomeUserSave, getHomeUserDelete } from '@/api/bizUser'
|
||||
|
||||
import CSearch from '@/components/Search/proSearch.vue'
|
||||
import STable from '@/components/Table/proTable.vue'
|
||||
@@ -124,9 +124,10 @@ const pagination = reactive({
|
||||
|
||||
const tableData = ref([])
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const formData = ref({})
|
||||
const currentRow = ref({})
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
async function getDataList() {
|
||||
loading.value = true
|
||||
@@ -174,12 +175,14 @@ const handleReset = () => {
|
||||
const handleAdd = () => {
|
||||
isEdit.value = false
|
||||
formData.value = {}
|
||||
currentRow.value = {}
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleEdit = (row) => {
|
||||
isEdit.value = true
|
||||
formData.value = { ...row }
|
||||
currentRow.value = { ...row }
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
@@ -187,8 +190,22 @@ const handleExport = () => {
|
||||
ElMessage.success('开始导出数据...')
|
||||
}
|
||||
|
||||
const handleDelete = (row) => {
|
||||
ElMessage.warning(`删除ID为 ${row.id} 的数据`)
|
||||
const handleDelete = async (row) => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要删除该条数据吗?', '删除确认', {
|
||||
type: 'warning',
|
||||
closeOnClickModal: false,
|
||||
showClose: false
|
||||
})
|
||||
const reqParams = {
|
||||
userId: row.userId
|
||||
}
|
||||
const res = await getHomeUserDelete(reqParams);
|
||||
ElMessage.success('删除成功');
|
||||
getDataList();
|
||||
} catch (error) {
|
||||
ElMessage.error('删除数据失败,请重试' ,error);
|
||||
}
|
||||
}
|
||||
|
||||
const handleSizeChange = (val) => {
|
||||
@@ -204,6 +221,7 @@ const handleCurrentChange = (val) => {
|
||||
const handleDialogClose = () => {
|
||||
formData.value = {}
|
||||
isEdit.value = false
|
||||
currentRow.value = {}
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
@@ -223,11 +241,19 @@ const handleSave = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
ElMessage.success(isEdit.value ? '编辑成功' : '新增成功')
|
||||
dialogVisible.value = false
|
||||
getDataList()
|
||||
}, 500)
|
||||
try {
|
||||
const reqParams = {
|
||||
...formData.value,
|
||||
isEdit: isEdit.value,
|
||||
userId: currentRow.value?.userId
|
||||
}
|
||||
const res = await getHomeUserSave(reqParams);
|
||||
dialogVisible.value = false;
|
||||
getDataList();
|
||||
ElMessage.success(res.msg)
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user