|
|
@ -1,6 +1,6 @@ |
|
|
|
<script setup> |
|
|
|
import { ref, onMounted, computed, reactive } from "vue"; |
|
|
|
import { ElMessageBox } from "element-plus"; |
|
|
|
import { ElMessage, ElMessageBox } from "element-plus"; |
|
|
|
import axios from "axios"; |
|
|
|
import { createApp } from "vue"; |
|
|
|
import moment from "moment"; |
|
|
@ -39,7 +39,32 @@ const getObj = ref({ |
|
|
|
}); |
|
|
|
const total = ref(0); |
|
|
|
//分页总条目 |
|
|
|
|
|
|
|
//时间选择器 |
|
|
|
const value1 = ref({ |
|
|
|
startTime: "", |
|
|
|
endTime: "", |
|
|
|
}); // 时间数组 |
|
|
|
function handleDateChange(value) { |
|
|
|
if (value && value.length === 2) { |
|
|
|
value1.value.startTime = value[0]; // 开始日期 |
|
|
|
value1.value.endTime = value[1]; // 结束日期 |
|
|
|
} |
|
|
|
console.log(value1); |
|
|
|
} |
|
|
|
|
|
|
|
const time = ref({}); |
|
|
|
const get = async function (val) { |
|
|
|
// 搜索参数时间赋值 |
|
|
|
if (value1.value != null) { |
|
|
|
if (value1.value.startDate != "" && value1.value.endDate != "") { |
|
|
|
time.value.startTime = value1.value[0]; |
|
|
|
time.value.endTime = value1.value[1]; |
|
|
|
} |
|
|
|
} else { |
|
|
|
time.value.startTime = ""; |
|
|
|
time.value.endTime = ""; |
|
|
|
} |
|
|
|
try { |
|
|
|
// 搜索参数页码赋值 |
|
|
|
if (typeof val === "number") { |
|
|
@ -50,7 +75,7 @@ const get = async function (val) { |
|
|
|
// 发送POST请求 |
|
|
|
const result = await API.post("http://192.168.8.93:10010/rates/search", { |
|
|
|
...getObj.value, |
|
|
|
rate: { ...value1.value }, |
|
|
|
rate: { ...time.value }, |
|
|
|
}); |
|
|
|
|
|
|
|
// 将响应结果存储到响应式数据中 |
|
|
@ -73,10 +98,9 @@ const search = function () { |
|
|
|
get(); |
|
|
|
}; |
|
|
|
// 添加方法 |
|
|
|
const rateAdd = ref({ |
|
|
|
adminId: "1", |
|
|
|
}); |
|
|
|
const rateAdd = ref({}); |
|
|
|
const addRate = async function () { |
|
|
|
rateAdd.value.adminId = adminData.value.adminId; |
|
|
|
try { |
|
|
|
console.log("搜索参数", getObj.value); |
|
|
|
// 发送POST请求 |
|
|
@ -84,7 +108,9 @@ const addRate = async function () { |
|
|
|
"http://192.168.8.93:10010/rates/add", |
|
|
|
rateAdd.value |
|
|
|
); |
|
|
|
|
|
|
|
if (result.code == 0) { |
|
|
|
ElMessage.error(result.msg); |
|
|
|
} |
|
|
|
// 将响应结果存储到响应式数据中 |
|
|
|
console.log("请求成功", result); |
|
|
|
get(); |
|
|
@ -128,17 +154,16 @@ const getEditData = async function (row) { |
|
|
|
console.log("搜索参数", getObj.value); |
|
|
|
// 发送POST请求 |
|
|
|
const result = await API.post( |
|
|
|
"http://192.168.8.93:10010/rates/searchById", |
|
|
|
{ |
|
|
|
rate: { rateId: row.rateId }, |
|
|
|
} |
|
|
|
"http://192.168.8.93:10010/rates/searchById?rateId=" + row.rateId, |
|
|
|
{} |
|
|
|
); |
|
|
|
|
|
|
|
// 将响应结果存储到响应式数据中 |
|
|
|
console.log("请求成功", result); |
|
|
|
// 存储表格数据 |
|
|
|
|
|
|
|
rateEdit.value = result.data[0]; |
|
|
|
rateEdit.value = result.data; |
|
|
|
rateEdit.value.adminId = adminData.value.adminId; |
|
|
|
console.log("这是编辑的数值", rateEdit.value); |
|
|
|
} catch (error) { |
|
|
|
console.log("请求失败", error); |
|
|
@ -221,19 +246,6 @@ const options = [ |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
|
//时间选择器 |
|
|
|
const value1 = ref({ |
|
|
|
startTime: "", |
|
|
|
endTime: "", |
|
|
|
}); // 时间数组 |
|
|
|
function handleDateChange(value) { |
|
|
|
if (value && value.length === 2) { |
|
|
|
value1.value.startTime = value[0]; // 开始日期 |
|
|
|
value1.value.endTime = value[1]; // 结束日期 |
|
|
|
} |
|
|
|
console.log(value1); |
|
|
|
} |
|
|
|
|
|
|
|
function formatDate(value) { |
|
|
|
if (!value) return ""; |
|
|
|
const date = new Date(value); |
|
|
@ -337,6 +349,26 @@ const checkNumber = function () { |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 删除========================================================= |
|
|
|
// 删除按钮 |
|
|
|
|
|
|
|
// 删除按钮的气泡弹出框确认按钮 |
|
|
|
const delConfirm = async function (row) { |
|
|
|
try { |
|
|
|
// 发送POST请求 |
|
|
|
const result = await API.post( |
|
|
|
"http://192.168.8.93:10010/rates/delete/ " + row.rateId, |
|
|
|
{} |
|
|
|
); |
|
|
|
// 将响应结果存储到响应式数据中 |
|
|
|
console.log("请求成功", result); |
|
|
|
get(); |
|
|
|
} catch (error) { |
|
|
|
console.log("请求失败", error); |
|
|
|
// 在这里可以处理错误逻辑,比如显示错误提示等 |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
@ -353,7 +385,6 @@ const checkNumber = function () { |
|
|
|
range-separator="至" |
|
|
|
start-placeholder="开始时间" |
|
|
|
end-placeholder="结束时间" |
|
|
|
@change="handleDateChange" |
|
|
|
:size="size" |
|
|
|
value-format="YYYY-MM-DD" |
|
|
|
/> |
|
|
@ -413,6 +444,28 @@ const checkNumber = function () { |
|
|
|
</template> |
|
|
|
</el-table-column> --> |
|
|
|
<el-table-column prop="adminName" label="提交人" :span="1" /> |
|
|
|
<el-table-column prop="status" label="状态"> |
|
|
|
<template #default="scope"> |
|
|
|
<span v-if="scope.row.status === 1"> |
|
|
|
<div class="status"> |
|
|
|
<span class="green-dot"></span> |
|
|
|
<span>使用中</span> |
|
|
|
</div> |
|
|
|
</span> |
|
|
|
<span v-if="scope.row.status === 0"> |
|
|
|
<div class="status"> |
|
|
|
<span class="red-dot"></span> |
|
|
|
<span>未开始</span> |
|
|
|
</div> |
|
|
|
</span> |
|
|
|
<span v-if="scope.row.status === 2"> |
|
|
|
<div class="status"> |
|
|
|
<span class="grey-dot"></span> |
|
|
|
<span>已过期</span> |
|
|
|
</div> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="startTime" label="持续时间" :span="10"> |
|
|
|
<template #default="scope"> |
|
|
|
<span>{{ formatDateTwe(scope.row.startTime) }}</span> |
|
|
@ -430,9 +483,24 @@ const checkNumber = function () { |
|
|
|
" |
|
|
|
>编辑</el-button |
|
|
|
> |
|
|
|
<el-button type="text" @click="deleteRate(scope.row)" |
|
|
|
>删除</el-button |
|
|
|
<el-popconfirm |
|
|
|
title="确定将此条活动删除吗?" |
|
|
|
@confirm="delConfirm" |
|
|
|
> |
|
|
|
<template #reference> |
|
|
|
<el-button type="primary" text> 删除 </el-button> |
|
|
|
</template> |
|
|
|
<template #actions="{ confirm, cancel }"> |
|
|
|
<el-button size="small" @click="cancel">取消</el-button> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
size="small" |
|
|
|
@click="confirm(scope.row)" |
|
|
|
> |
|
|
|
确定 |
|
|
|
</el-button> |
|
|
|
</template> |
|
|
|
</el-popconfirm> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
@ -667,4 +735,7 @@ p { |
|
|
|
.pagination { |
|
|
|
display: flex; |
|
|
|
} |
|
|
|
.status { |
|
|
|
display: flex; |
|
|
|
} |
|
|
|
</style> |