<script setup>
|
import {reactive, ref} from "vue";
|
import {VXETable} from "vxe-table";
|
import {ElMessage} from "element-plus";
|
import request from "@/utils/request"
|
import CreateBasicData from "@/views/sd/basicData/CreateBasicData.vue"
|
import {useRouter,useRoute} from "vue-router"
|
import {useI18n} from "vue-i18n"
|
const { t } = useI18n()
|
|
let dialogTableVisible = ref(false)
|
const router = useRouter()
|
const xGrid = ref()
|
const gridOptions = reactive({
|
border: "full",//表格加边框
|
keepSource: true,//保持源数据
|
align: 'center',//文字居中
|
stripe:true,//斑马纹
|
rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮
|
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
|
},
|
|
//表头参数
|
columns:[
|
{title: t('basicData.operate'), width: 110, slots: { default: 'button_slot' },fixed:"left",},
|
{type: 'seq', title: '序号', width: 80 ,fixed:"left",},
|
{field:'basicName',title: '名称'},
|
{field:'createTime',title: '创建日期'},
|
|
|
],
|
|
//表头按钮
|
toolbarConfig: {
|
buttons: [
|
{'code': 'add', 'name': '新增',status: 'primary'},
|
],
|
|
// import: false,
|
// export: true,
|
// print: true,
|
zoom: true,
|
custom: true
|
},
|
|
footerMethod ({ columns, data }) {//页脚函数
|
return[
|
columns.map((column, columnIndex) => {
|
// if (columnIndex === 0) {
|
// return t('basicData.total')
|
// }
|
// if (props.tableProp.footList.includes(column.field)) {
|
// return sumNum(data, column.field)
|
// }
|
return ''
|
})
|
]
|
}
|
|
})
|
const gridEvents = {
|
toolbarButtonClick ({ code }) {
|
const $grid = xGrid.value
|
if ($grid) {
|
switch (code) {
|
case 'add': {
|
rowIndex.value = null
|
dialogTableVisible.value = true
|
break
|
}
|
|
}
|
}
|
},
|
menuClick ({ menu, row, column }) {
|
const $grid = xGrid.value
|
if ($grid) {
|
switch (menu.code) {
|
|
|
}
|
}
|
}
|
}
|
|
request.get('/basicData/getBasicData').then(res => {
|
if(res.code==='200'){
|
xGrid.value.reloadData(res.data)
|
}
|
})
|
|
const getChildrenFunction = (flag) => {
|
if(flag){
|
router.push({
|
path:'/main/orderBasicData/searchBasicData',
|
query:{random:Math.random()
|
}
|
})
|
}
|
}
|
|
let rowIndex = ref(null)
|
const getTableRow = (row,type) => {
|
switch (type) {
|
case 'edit': {
|
rowIndex.value = row
|
dialogTableVisible.value = true
|
break
|
}
|
case 'delete': {
|
request.post(`/basicData/deleteBasicData`,row).then((res) => {
|
if(res.code==200){
|
ElMessage.success(t('searchOrder.msgDeleteSuccess'))
|
router.push({
|
path:'/main/orderBasicData/searchBasicData',
|
query:{random:Math.random()
|
}
|
})
|
}else{
|
ElMessage.warning(t('searchOrder.msgDeleteFail'))
|
}
|
})
|
break
|
}
|
|
}
|
}
|
|
</script>
|
|
<template>
|
<div>
|
<vxe-grid
|
style="width: 40vw;"
|
class="mytable-scrollbar"
|
max-height="500px"
|
ref="xGrid"
|
v-bind="gridOptions"
|
v-on="gridEvents"
|
>
|
<template #button_slot="{ row }">
|
<el-button @click="getTableRow(row,'edit')" link type="primary" size="small">{{ $t('basicData.edit') }}</el-button>
|
<el-popconfirm @confirm="getTableRow(row,'delete')" :title="$t('searchOrder.deleteConfirm')">
|
<template #reference>
|
<el-button link type="primary" size="small">{{ $t('basicData.delete') }}</el-button>
|
</template>
|
</el-popconfirm>
|
</template>
|
|
</vxe-grid>
|
<el-dialog
|
v-model="dialogTableVisible"
|
destroy-on-close
|
style="width: 30%;height:30% ">
|
<create-basic-data :rowIndex="rowIndex" @gaveParent='getChildrenFunction'/>
|
</el-dialog>
|
</div>
|
</template>
|
|
<style scoped>
|
|
</style>
|