<script lang="ts" setup>
|
import {Search} from "@element-plus/icons-vue";
|
import {reactive} from "vue";
|
import {useRouter} from "vue-router"
|
import { ref } from 'vue'
|
|
const router = useRouter()
|
const value1 = ref(true)
|
const add = ref(false)
|
const adda = ref(false)
|
|
const changer = ref(false)
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
const tableData = [
|
{
|
id: '1',
|
long: '1005',
|
wide: '183.6',
|
thick: '1991',
|
time: '2024/4/1',
|
type: '待识别',
|
typea: '1',
|
},
|
{
|
id: '2',
|
long: '105',
|
wide: '183',
|
time: '2024/4/1',
|
thick: '191',
|
typea: '1',
|
type: '待识别'
|
},
|
{
|
id: '2',
|
long: '105',
|
wide: '183',
|
time: '2024/4/1',
|
thick: '191',
|
typea: '1',
|
type: '待识别'
|
},
|
]
|
const open = () => {
|
ElMessageBox.confirm(
|
'是否删除该条信息?',
|
'提示',
|
{
|
confirmButtonText: '是',
|
cancelButtonText: '取消',
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
ElMessage({
|
type: 'success',
|
message: '删除成功!',
|
})
|
})
|
.catch(() => {
|
ElMessage({
|
type: 'info',
|
message: '删除失败',
|
})
|
})
|
}
|
const getTableRow = (row,type) =>{
|
switch (type) {
|
case 'edit' :{
|
//alert('我接收到子组件传送的编辑信息')
|
router.push({path: '/main/returns/createReturns', query: { ReturnID: 'TH24010101' }})
|
break
|
}
|
case 'delete':{
|
alert('我接收到子组件传送的删除信息')
|
break
|
}
|
}
|
}
|
const dialogForm = () => {
|
ElMessageBox.confirm(
|
'是否重置密码?',
|
'提示',
|
{
|
confirmButtonText: '是',
|
cancelButtonText: '取消',
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
// this.boxa = true
|
// this.box = false
|
|
})
|
}
|
const dialogForma = () => {
|
ElMessageBox.confirm(
|
'是否删除该条信息?',
|
'提示',
|
{
|
confirmButtonText: '是',
|
cancelButtonText: '取消',
|
type: 'warning',
|
}
|
)
|
}
|
|
const options = [
|
{
|
value: 'Option1',
|
label: 'admin',
|
},
|
{
|
value: 'Option2',
|
label: 'ueser2',
|
},
|
{
|
value: 'Option3',
|
label: 'ueser3',
|
},
|
]
|
const optionsa = [
|
{
|
valuea: 'Option1',
|
labela: '正常',
|
},
|
{
|
valuea: 'Option2',
|
labela: '禁用',
|
},
|
]
|
|
const data= reactive({
|
tableList:[]//table数据
|
})
|
|
const beforeChange = () => {
|
return new Promise((resolve) => {
|
setTimeout(() => {
|
ElMessage.success("修改成功!");
|
return resolve(true);
|
}, 1000);
|
});
|
};
|
|
// //js层,实战版本,与后台接口交互
|
// const gettableList = (id) = >{
|
// xxx接口.({
|
// id:id
|
// }).then((res)=>{
|
// //将数据传给el-table绑定的:data=>data.tableList
|
// data.tableList = res.data
|
|
// })
|
// }
|
|
// //最后将请求函数挂载到vue视图上
|
// onMounted(() => {
|
// gettableList ()
|
|
// })
|
// const delete = () => {
|
// ElMessageBox.confirm(
|
// '是否删除该条信息?',
|
// '提示',
|
// {
|
// confirmButtonText: '是',
|
// cancelButtonText: '取消',
|
// type: 'warning',
|
// }
|
// )
|
// .then(() => {
|
|
// })
|
// }
|
const gridOptions = reactive({
|
border: "full",//表格加边框
|
keepSource: true,//保持源数据
|
align: 'center',//文字居中
|
stripe:true,//斑马纹
|
rowConfig: {isCurrent: true, isHover: true,height: 50},//鼠标移动或选择高亮
|
id: 'OrderList',
|
showFooter: true,//显示脚
|
printConfig: {},
|
importConfig: {},
|
exportConfig: {},
|
scrollY:{ enabled: true },//开启虚拟滚动
|
showOverflow:true,
|
columnConfig: {
|
resizable: true,
|
useKey: true
|
},
|
filterConfig: { //筛选配置项
|
remote: true
|
},
|
customConfig: {
|
storage: true
|
},
|
editConfig: {
|
trigger: 'click',
|
mode: 'row',
|
showStatus: true
|
},
|
data: [
|
{
|
'id': '1',
|
'long': '5',
|
'wide': '1005',
|
'thick': '183.6',
|
'time': '2024/4/1',
|
}
|
]
|
})
|
|
</script>
|
|
<template>
|
<div>
|
<el-button type="primary" style="margin-top: 10px;margin-left: 10px;" size="mini" id="searchButton" @click="add = true">添加用户</el-button>
|
<el-input
|
clearable
|
placeholder="请输入用户名"
|
size="mini"
|
style="margin-right: 20px; width: 200px;margin-left: 10px;margin-top: 10px;"
|
/>
|
<el-input
|
clearable
|
placeholder="请输入邮箱"
|
size="mini"
|
style="margin-right: 20px; width: 200px;margin-left: 10px;margin-top: 10px;"
|
/>
|
<el-button type="primary" size="mini" @click="searchSubmit" style="margin-top: 10px;">查询</el-button >
|
<el-button type="primary" size="mini" @click="empty" style="margin-top: 10px;">清空</el-button>
|
<el-card style="flex: 1;margin-left: 10px;margin-top: 15px;" v-loading="loading">
|
<div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;max-height: 200px;">
|
<el-table height="100%" ref="table"
|
@selection-change="handleSelectionChange"
|
:data="tableData" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
|
<el-table-column prop="id" align="center" label="用户名" min-width="80" />
|
<el-table-column prop="long" align="center" label="邮箱" min-width="120" />
|
<el-table-column prop="time" align="center" label="创建时间" min-width="120" />
|
<el-table-column align="center" prop="changer" label="是否禁用" min-width="140" >
|
<template #default="scope">
|
<el-switch v-model="scope.row.changer" :before-change="beforeChange" />
|
</template>
|
</el-table-column>
|
|
<el-table-column fixed="right" label="操作" align="center" width="200">
|
<template #default>
|
<el-button size="mini" type="text" plain @click="dialogForm">重置密码</el-button>
|
<el-button size="mini" type="text" plain @click="adda = true">编辑</el-button>
|
<el-button size="mini" type="text" plain @click="dialogForma">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</el-card>
|
|
</div>
|
|
<el-dialog v-model="add" top="23vh" width="37%" title="添加用户" >
|
<div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;">
|
<el-form size="mini" label-width="150px">
|
<el-form label-width="100px" label-position="right">
|
<el-row style="margin-top: -15px;margin-bottom: -2px;">
|
<el-col :span="6">
|
<div id="dt" style="font-size: 15px;">
|
<div>
|
<el-form-item label="用户名:" :required="true" style="width: 25vw">
|
<el-input autocomplete="off" />
|
</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="角色:" :required="true" style="width: 25vw;">
|
<el-select
|
v-model="value"
|
clearable
|
placeholder="请选择角色"
|
style="width: 330px"
|
>
|
<el-option
|
v-for="item in options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</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="邮箱:" :required="true" style="width: 25vw;">
|
<el-input autocomplete="off" />
|
</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="是否禁用" :required="true" style="width: 25vw;">
|
<el-select
|
v-model="value"
|
clearable
|
placeholder="请选择是否禁用"
|
style="width: 330px"
|
>
|
<el-option
|
v-for="item in optionsa"
|
:key="item.valuea"
|
:label="item.labela"
|
:value="item.valuea"
|
/>
|
</el-select>
|
</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="密码:" :required="true" style="width: 25vw;">
|
<el-input autocomplete="off" />
|
</el-form-item></div></div>
|
</el-col>
|
</el-row>
|
</el-form>
|
</el-form>
|
</div>
|
<template #footer>
|
<div id="dialog-footer">
|
<el-button type="primary" @click="getTableRow('edit')">
|
确认
|
</el-button>
|
<el-button @click="add = false">取消</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
<el-dialog v-model="adda" top="23vh" width="37%" title="修改用户" >
|
<div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;">
|
<el-form size="mini" label-width="150px">
|
<el-form label-width="100px" label-position="right">
|
<el-row style="margin-top: -15px;margin-bottom: -2px;">
|
<el-col :span="6">
|
<div id="dt" style="font-size: 15px;">
|
<div>
|
<el-form-item label="用户名:" :required="true" style="width: 25vw">
|
<el-input autocomplete="off" />
|
</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="角色:" :required="true" style="width: 25vw;">
|
<el-select
|
v-model="value"
|
clearable
|
placeholder="请选择角色"
|
style="width: 330px"
|
>
|
<el-option
|
v-for="item in options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</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="邮箱:" :required="true" style="width: 25vw;">
|
<el-input autocomplete="off" />
|
</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="是否禁用" :required="true" style="width: 25vw;">
|
<el-select
|
v-model="value"
|
clearable
|
placeholder="请选择是否禁用"
|
style="width: 330px"
|
>
|
<el-option
|
v-for="item in optionsa"
|
:key="item.valuea"
|
:label="item.labela"
|
:value="item.valuea"
|
/>
|
</el-select>
|
</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="密码:" :required="true" style="width: 25vw;">
|
<el-input autocomplete="off" />
|
</el-form-item></div></div>
|
</el-col>
|
</el-row>
|
</el-form>
|
</el-form>
|
</div>
|
<template #footer>
|
<div id="dialog-footer">
|
<el-button type="primary" @click="getTableRow('edit')">
|
确认
|
</el-button>
|
<el-button @click="adda = false">取消</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</template>
|
|
<style scoped>
|
|
#dt { display:block; float:left;line-height: 20px;margin-left: 100px;}
|
#dta { display:block; float:left;line-height: 20px;margin-left: 80%;}
|
#dialog-footer{
|
text-align: center;
|
margin-top: -15px;
|
}
|
#message{
|
text-align: center;
|
align-items: center;
|
color: black;
|
width: 200px;
|
height: 100px;
|
background-color: #337ecc;
|
margin-left: 28%;
|
}
|
#awatch{
|
height: 450px;
|
}
|
#main-body{
|
margin-top: -20px;
|
margin-left: 300px;
|
}
|
#main-bodya{
|
margin-top: -10px;
|
margin-left: 100px;
|
}
|
</style>
|