|
|
export default {
|
|
|
name: 'busyConfig',
|
|
|
template: '',
|
|
|
components: {
|
|
|
},
|
|
|
props: [],
|
|
|
setup(props, {attrs, slots, emit}) {
|
|
|
const {proxy} = Vue.getCurrentInstance();
|
|
|
let height = Vue.ref(window.innerHeight);
|
|
|
let yearCheckList=Vue.ref([]);//年选择数据
|
|
|
let monthCheckList=Vue.ref([]);//月选择数据
|
|
|
let dayCheckList=Vue.ref([]);//日选择数据
|
|
|
let hourCheckList=Vue.ref([]);//时选择数据
|
|
|
let dialog=Vue.ref({
|
|
|
title:'忙时配置',
|
|
|
show:false,
|
|
|
id:''
|
|
|
});
|
|
|
let search = Vue.ref({
|
|
|
status: 0,
|
|
|
keyWords: '',
|
|
|
page: 1,
|
|
|
limit: 50,
|
|
|
});
|
|
|
|
|
|
//表格字段
|
|
|
let tableData = Vue.ref({
|
|
|
count:0,
|
|
|
dataList: [],
|
|
|
columns: [
|
|
|
{
|
|
|
prop: 'years',
|
|
|
label: '年',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '200',
|
|
|
},
|
|
|
{
|
|
|
prop: 'months',
|
|
|
label: '月',
|
|
|
sortable: true,
|
|
|
align: '200',
|
|
|
},
|
|
|
{
|
|
|
prop: 'days',
|
|
|
label: '日',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
}, {
|
|
|
prop: 'hours',
|
|
|
label: '时',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '200'
|
|
|
}
|
|
|
]
|
|
|
})
|
|
|
// 表格全选事件
|
|
|
let checkData=Vue.ref([]);
|
|
|
let selectionChange = (val) => {
|
|
|
let checkArr = [];
|
|
|
val.map(item => {
|
|
|
checkArr.push(item.id)
|
|
|
})
|
|
|
checkData.value = checkArr;
|
|
|
|
|
|
}
|
|
|
// 获取列表
|
|
|
let getDataList = () => {
|
|
|
proxy.$http.get(`/api-analysis/busyAnalysis/getList?keyWords=`+search.value.keyWords, {
|
|
|
page: search.value.page,
|
|
|
limit: search.value.limit,
|
|
|
}, function (res) {
|
|
|
if (res && res.data) {
|
|
|
tableData.value.dataList = res.data;
|
|
|
tableData.value.count = res.count;
|
|
|
tableData.value.dataList.map(item=>{
|
|
|
if(item.year){
|
|
|
item.years=item.year.split(",");
|
|
|
}
|
|
|
if(item.month){
|
|
|
item.months=item.month.split(",");
|
|
|
}
|
|
|
if(item.day){
|
|
|
item.days=item.day.split(",");
|
|
|
}
|
|
|
if(item.hour){
|
|
|
item.hours=item.hour.split(",");
|
|
|
}
|
|
|
|
|
|
})
|
|
|
} else {
|
|
|
tableData.value.dataList = [];
|
|
|
tableData.value.count = 0;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
let loaddata = ({page, limit}) => {
|
|
|
search.value.page = page;
|
|
|
search.value.limit = limit;
|
|
|
}
|
|
|
|
|
|
let hideDialog = (flg) => {
|
|
|
dialog.value.show = flg;
|
|
|
if(!flg){
|
|
|
dialog.value.id='';
|
|
|
yearCheckList.value=[];
|
|
|
monthCheckList.value=[];
|
|
|
dayCheckList.value=[];
|
|
|
hourCheckList.value=[];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 处理弹框
|
|
|
let handle = (row) =>{
|
|
|
dialog.value.id = row.id;
|
|
|
yearCheckList.value=row.years?row.years:[];
|
|
|
monthCheckList.value=row.months?row.months:[];
|
|
|
dayCheckList.value=row.days?row.days:[];
|
|
|
hourCheckList.value=row.hours?row.hours:[];
|
|
|
console.log("////",yearCheckList.value,monthCheckList.value,dayCheckList.value,hourCheckList.value)
|
|
|
hideDialog(true);
|
|
|
}
|
|
|
|
|
|
//修改详情
|
|
|
let handleEdit = (row) =>{
|
|
|
handle(row);
|
|
|
}
|
|
|
//删除数据
|
|
|
let handleDelete=(row)=>{
|
|
|
deletData(row);
|
|
|
}
|
|
|
//获取当前年的前后三年
|
|
|
let yearData=Vue.ref([])
|
|
|
let getYearData=()=>{
|
|
|
let date=new Date();
|
|
|
let arr=[];
|
|
|
for(let i=0;i<=3;i++){
|
|
|
arr.push(date.getFullYear()-i);
|
|
|
if(i!=0){
|
|
|
arr.push(date.getFullYear()+i)
|
|
|
}
|
|
|
}
|
|
|
arr.sort((a, b) => {
|
|
|
return a - b
|
|
|
});
|
|
|
yearData.value=arr;
|
|
|
}
|
|
|
//新增配置
|
|
|
let addConfig=()=>{
|
|
|
hideDialog(true);
|
|
|
}
|
|
|
//批量删除配置
|
|
|
let delConfig=()=>{
|
|
|
if(checkData.value.length<1){
|
|
|
proxy.$global.showMsg('请至少选择一项','warning');
|
|
|
return;
|
|
|
}
|
|
|
deletData();
|
|
|
}
|
|
|
//删除操作
|
|
|
let deletData=(row)=>{
|
|
|
let idList='';
|
|
|
if(row){
|
|
|
idList=row.id;
|
|
|
}else{
|
|
|
if(checkData.value.length>0){
|
|
|
idList=checkData.value.join(',')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
proxy.$global.confirm("确认删除数据吗?", function () {
|
|
|
proxy.$http.get(`/api-analysis/busyAnalysis/remove`, {
|
|
|
idList: idList
|
|
|
}, function (res) {
|
|
|
if(res && res.success){
|
|
|
proxy.$global.showMsg('删除成功');
|
|
|
}else{
|
|
|
proxy.$global.showMsg('删除失败','error');
|
|
|
}
|
|
|
getDataList();
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
//保存配置
|
|
|
let saveConfig=()=>{
|
|
|
if(hourCheckList.value.length<1){
|
|
|
proxy.$global.showMsg('请至少选择一个时间','warning');
|
|
|
return;
|
|
|
}
|
|
|
let year='';
|
|
|
if(yearCheckList.value.length>0){
|
|
|
year=yearCheckList.value.join(",");
|
|
|
}
|
|
|
let month='';
|
|
|
if(monthCheckList.value.length>0){
|
|
|
month=monthCheckList.value.join(",");
|
|
|
}
|
|
|
let day='';
|
|
|
if(dayCheckList.value.length>0){
|
|
|
day=dayCheckList.value.join(",");
|
|
|
}
|
|
|
let hour='';
|
|
|
if(hourCheckList.value.length>0){
|
|
|
hour=hourCheckList.value.join(",");
|
|
|
}
|
|
|
if(dialog.value.id){
|
|
|
proxy.$http.post(`/api-analysis/busyAnalysis/update`, {
|
|
|
year: year,
|
|
|
month: month,
|
|
|
day: day,
|
|
|
hour: hour,
|
|
|
id:dialog.value.id
|
|
|
}, function (res) {
|
|
|
if(res && res.success){
|
|
|
proxy.$global.showMsg('修改成功');
|
|
|
}else{
|
|
|
proxy.$global.showMsg('修改失败','error');
|
|
|
}
|
|
|
hideDialog(false);
|
|
|
getDataList();
|
|
|
})
|
|
|
}else{
|
|
|
proxy.$http.post(`/api-analysis/busyAnalysis/add`, {
|
|
|
year: year,
|
|
|
month: month,
|
|
|
day: day,
|
|
|
hour: hour
|
|
|
}, function (res) {
|
|
|
if(res && res.success){
|
|
|
proxy.$global.showMsg('保存成功');
|
|
|
}else{
|
|
|
proxy.$global.showMsg('保存失败','error');
|
|
|
}
|
|
|
hideDialog(false);
|
|
|
getDataList();
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
// 挂载完
|
|
|
Vue.onMounted(() => {
|
|
|
getYearData();
|
|
|
getDataList();
|
|
|
})
|
|
|
|
|
|
|
|
|
return {
|
|
|
saveConfig,
|
|
|
delConfig,
|
|
|
addConfig,
|
|
|
selectionChange,
|
|
|
handleDelete,
|
|
|
checkData,
|
|
|
yearData,
|
|
|
dialog,
|
|
|
getYearData,
|
|
|
height,
|
|
|
search,
|
|
|
hideDialog,
|
|
|
handle,
|
|
|
loaddata,
|
|
|
tableData,
|
|
|
getDataList,
|
|
|
handleEdit,
|
|
|
yearCheckList,
|
|
|
monthCheckList,
|
|
|
dayCheckList,
|
|
|
hourCheckList
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|