<template>
|
<div class="app-container">
|
<el-form
|
class="responsive-form"
|
:model="queryParams"
|
ref="queryRef"
|
:inline="true"
|
v-show="showSearch"
|
label-width="68px"
|
>
|
<el-row type="flex" justify="right">
|
<el-form-item label="日历描述" prop="description">
|
<el-input
|
style="width: 140px"
|
v-model="queryParams.description"
|
placeholder="请输入描述关键词"
|
clearable
|
@keyup.enter="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="日历类型" prop="effectiveDate">
|
<el-select clearable v-model="dateType" style="width: 90px">
|
<el-option
|
v-for="(item, index) of dateTypeList"
|
:key="index"
|
:label="item.name"
|
:value="item.name"
|
>{{ item.name }}</el-option
|
>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="生效日期" prop="effectiveDate">
|
<el-date-picker
|
clearable
|
v-model="queryParams.effectiveDate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="选择日期"
|
>
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="适用工厂" prop="expiringDate">
|
<!-- <el-date-picker clearable
|
v-model="queryParams.expiringDate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="请选择失效日期">
|
</el-date-picker> -->
|
<el-input
|
style="width: 180px"
|
v-model="queryParams.description"
|
placeholder="请输入工厂关键词"
|
clearable
|
@keyup.enter="handleQuery"
|
/>
|
</el-form-item>
|
</el-row>
|
<el-row type="flex" justify="end">
|
<el-form-item class="column-with-margin">
|
<el-button type="primary" icon="Search" @click="handleQuery"
|
>查询</el-button
|
>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
<!-- <el-button
|
type="success"
|
icon="Plus"
|
@click="handleAdd"
|
v-hasPermi="['core:calendar:add']"
|
>新增日历</el-button
|
> -->
|
</el-form-item>
|
</el-row>
|
</el-form>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="Plus"
|
@click="handleAdd"
|
v-hasPermi="['core:calendar:add']"
|
>新增</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="success"
|
plain
|
icon="Edit"
|
:disabled="single"
|
@click="handleUpdate"
|
v-hasPermi="['core:calendar:edit']"
|
>修改</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="Delete"
|
:disabled="multiple"
|
@click="handleDelete"
|
v-hasPermi="['core:calendar:remove']"
|
>删除</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="warning"
|
plain
|
icon="Download"
|
@click="handleExport"
|
v-hasPermi="['core:calendar:export']"
|
>导出</el-button
|
>
|
</el-col>
|
<right-toolbar
|
v-model:showSearch="showSearch"
|
@queryTable="getList"
|
></right-toolbar>
|
</el-row>
|
<HxlhTable
|
style="width: 100%"
|
:columns="columns"
|
:data="calendarList"
|
:loading="loading"
|
:height="height"
|
:page="page"
|
@changePageNo="changePageNo"
|
@changePageSize="changePageSize"
|
@on-checkbox="handleCheckboxChange"
|
>
|
<template #status="{ row }">
|
<vxe-tag v-if="row.type === '1'" status="primary">周工作日</vxe-tag>
|
<vxe-tag v-if="row.type === '2'" status="success">节假日</vxe-tag>
|
</template>
|
<template #content="{ row }">
|
<vxe-tag>周工作日</vxe-tag>
|
</template>
|
</HxlhTable>
|
|
<!-- 添加或修改日历管理对话框 -->
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
<el-form
|
ref="calendarRef"
|
:model="form"
|
:rules="rules"
|
label-width="105px"
|
>
|
<el-form-item label="日历描述" prop="description">
|
<el-input v-model="form.description" placeholder="请输入描述" />
|
</el-form-item>
|
<el-form-item label="日历类型" prop="type">
|
<el-radio-group v-model="form.type" @change="handleSwitchType">
|
<el-radio :label="1">周工作</el-radio>
|
<el-radio :label="2">节假日</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item label="生效时间" prop="effectiveDate">
|
<el-date-picker
|
clearable
|
v-model="form.effectiveDate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="选择日期"
|
>
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="失效时间" prop="expiringDate">
|
<el-date-picker
|
clearable
|
v-model="form.expiringDate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="选择日期"
|
>
|
</el-date-picker>
|
</el-form-item>
|
<div v-if="form.type === 1">
|
<div class="title_bar_line">
|
<div class="line_short"></div>
|
<div>周工作设置</div>
|
<div class="line_long"></div>
|
</div>
|
<div
|
class="week_flex"
|
v-for="(item, index) in weekDaysSettingList"
|
:key="index"
|
>
|
<div class="week_flex_item">{{ item.chineseName }}</div>
|
<div class="week_flex_item">
|
<el-radio-group v-model="item.work" @change="handleSetWorkDays">
|
<el-radio :label="'y'">工作日</el-radio>
|
<el-radio :label="'n'">非工作日</el-radio>
|
</el-radio-group>
|
</div>
|
</div>
|
</div>
|
<div v-if="form.type === 2">
|
<div class="title_bar_line">
|
<div class="line_short"></div>
|
<div>节假日设置</div>
|
<div class="line_long"></div>
|
</div>
|
<div class="week_flex mt20">
|
<div class="week_flex_item">节日开始时间</div>
|
<div class="week_flex_item">
|
<el-date-picker
|
clearable
|
v-model="holidays.startdate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="选择日期"
|
>
|
</el-date-picker>
|
</div>
|
</div>
|
<div class="week_flex mt20">
|
<div class="week_flex_item">节日结束时间</div>
|
<div class="week_flex_item">
|
<el-date-picker
|
clearable
|
v-model="holidays.enddate"
|
type="date"
|
value-format="YYYY-MM-DD"
|
placeholder="选择日期"
|
>
|
</el-date-picker>
|
</div>
|
</div>
|
</div>
|
<el-form-item
|
label="适用工厂"
|
prop="applicableFactory"
|
class="factory_use_item"
|
>
|
<el-select
|
clearable
|
v-model="form.applicableFactory"
|
style="width: 160px"
|
placeholder="请输入适用工厂"
|
@change="changePlant($event)"
|
>
|
<el-option
|
v-for="plant in plantList"
|
:key="plant.id"
|
:label="plant.plantName"
|
:value="plant.plantCode"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item
|
label="适用车间"
|
prop="applicableWorkshop"
|
class="factory_use_item"
|
>
|
<el-select
|
clearable
|
v-model="form.applicableWorkshop"
|
style="width: 160px"
|
placeholder="请输入适用车间"
|
>
|
<el-option
|
v-for="shop in shopList"
|
:key="shop.id"
|
:label="shop.shopName"
|
:value="shop.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item
|
label="适用工序"
|
prop="applicableProcess"
|
class="factory_use_item"
|
>
|
<el-select
|
clearable
|
v-model="form.applicableProcess"
|
style="width: 160px"
|
placeholder="请输入适用工序"
|
>
|
<el-option
|
v-for="process in processList"
|
:key="process.id"
|
:label="process.processName"
|
:value="process.processName"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button @click="cancel">取 消</el-button>
|
<el-button type="primary" @click="submitForm">保存</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup name="Calendar">
|
import HxlhTable from "@/components/HxlhTable";
|
import {
|
listCalendar,
|
getCalendar,
|
delCalendar,
|
addCalendar,
|
updateCalendar,
|
} from "@/api/basicData/calendar";
|
import { listAll_plant } from "@/api/basicData/plant";
|
import { listAll_shop, listAps_shop } from "@/api/basicData/shop";
|
import { selectProcessNameList } from "@/api/basicData/processRoute.js";
|
const { proxy } = getCurrentInstance();
|
const calendarList = ref([]);
|
const open = ref(false);
|
const loading = ref(true);
|
const showSearch = ref(true);
|
const ids = ref([]);
|
const single = ref(true);
|
const multiple = ref(true);
|
const total = ref(0);
|
const title = ref("");
|
const data = reactive({
|
form: {},
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
description: null,
|
type: null,
|
effectiveDate: null,
|
expiringDate: null,
|
content: null,
|
applicableFactory: null,
|
applicableWorkshop: null,
|
applicableProcess: null,
|
},
|
rules: {
|
description: [
|
{
|
required: true,
|
message: "请输入日历描述",
|
trigger: "blur",
|
},
|
],
|
type: [
|
{
|
required: true,
|
message: "请选择日历类型",
|
trigger: "blur",
|
},
|
],
|
effectiveDate: [
|
{
|
required: true,
|
message: "请选择日历生效时间",
|
trigger: "blur",
|
},
|
],
|
expiringDate: [
|
{
|
required: true,
|
message: "请选择日历失效时间",
|
trigger: "blur",
|
},
|
],
|
applicableFactory: [
|
{
|
required: true,
|
message: "请选择适用工厂",
|
trigger: "blur",
|
},
|
],
|
},
|
});
|
const { queryParams, form, rules } = toRefs(data);
|
const dateType = ref("周工作");
|
const dateTypeList = ref([
|
{
|
name: "周工作",
|
},
|
{
|
name: "节假日",
|
},
|
]);
|
const typeRadioNumber = ref(1);
|
const weekDaysSettingList = ref([
|
{
|
day: "Monday",
|
chineseName: "星期一",
|
work: "y",
|
},
|
{
|
day: "TuesDay",
|
chineseName: "星期二",
|
work: "y",
|
},
|
{
|
day: "Wednesday",
|
chineseName: "星期三",
|
work: "y",
|
},
|
{
|
day: "Thursday",
|
chineseName: "星期四",
|
work: "y",
|
},
|
{
|
day: "Friday",
|
chineseName: "星期五",
|
work: "y",
|
},
|
{
|
day: "Saturday",
|
chineseName: "星期六",
|
work: "y",
|
},
|
{
|
day: "Sunday",
|
chineseName: "星期日",
|
work: "y",
|
},
|
]);
|
const holidays = ref({
|
startdate: "",
|
enddate: "",
|
});
|
const plantList = ref([]);
|
const shopList = ref([]);
|
const allShopList = ref([]);
|
const processList = ref([]);
|
const height = ref(document.documentElement.clientHeight - 260 + "px;");
|
// 表格配置-列表
|
const columns = ref([
|
{ type: "checkbox", width: 60, align: "center" },
|
{
|
title: "日历描述",
|
field: "description",
|
width: 150,
|
align: "center",
|
},
|
{
|
title: "日历类型",
|
field: "type",
|
width: 150,
|
align: "center",
|
slots: { default: "status" },
|
},
|
{
|
title: "日历生效时间",
|
field: "effectiveDate",
|
width: 100,
|
align: "center",
|
},
|
{
|
title: "日历失效时间",
|
field: "expiringDate",
|
width: 150,
|
align: "center",
|
},
|
{
|
title: "日历内容",
|
field: "content",
|
width: 200,
|
align: "center",
|
slots: { default: "content" },
|
},
|
{
|
title: "适用工厂",
|
field: "applicableFactory",
|
width: 200,
|
align: "center",
|
formatter: ({ cellValue, row, column }) => {
|
console.log(cellValue, "000hsudhwhuwhuhwu");
|
for (let i = 0; i < plantList.value.length; i++) {
|
console.log(
|
cellValue,
|
plantList.value[i].plantCode,
|
plantList.value[i].plantName,
|
"111hsudhwhuwhuhwu"
|
);
|
if (cellValue === plantList.value[i].plantCode) {
|
return plantList.value[i].plantName;
|
}
|
}
|
},
|
},
|
{
|
title: "适用车间",
|
field: "applicableWorkshop",
|
width: 90,
|
align: "center",
|
formatter: ({ cellValue, row, column }) => {
|
console.log(row.applicableFactory, "llll");
|
listAps_shop({ plantCode: row.applicableFactory }).then((response) => {
|
console.log(response.rows, "适用车间");
|
shopList.value = response.rows;
|
});
|
for (let i = 0; i < shopList.value.length; i++) {
|
if (cellValue === shopList.value[i].id) {
|
return shopList.value[i].shopName;
|
}
|
}
|
},
|
},
|
{
|
title: "适用工序",
|
field: "applicableProcess",
|
width: 90,
|
align: "center",
|
},
|
{
|
title: "创建者",
|
field: "createBy",
|
width: 90,
|
align: "center",
|
},
|
{
|
title: "创建时间",
|
field: "createTime",
|
width: 90,
|
align: "center",
|
},
|
]);
|
// 分页属性
|
const page = ref({
|
total: 0,
|
current: 1,
|
size: 10,
|
});
|
|
/** 查询日历管理列表 */
|
async function getList() {
|
loading.value = true;
|
listCalendar(queryParams.value).then((response) => {
|
calendarList.value = response.rows;
|
total.value = response.total;
|
loading.value = false;
|
});
|
const res = await listAll_plant({});
|
plantList.value = res.data;
|
}
|
|
// 取消按钮
|
function cancel() {
|
open.value = false;
|
reset();
|
}
|
|
// 表单重置
|
function reset() {
|
form.value = {
|
id: null,
|
description: null,
|
type: null,
|
effectiveDate: null,
|
expiringDate: null,
|
content: null,
|
applicableFactory: null,
|
applicableWorkshop: null,
|
applicableProcess: null,
|
createBy: null,
|
createTime: null,
|
updateBy: null,
|
updateTime: null,
|
};
|
proxy.resetForm("calendarRef");
|
}
|
|
/** 搜索按钮操作 */
|
function handleQuery() {
|
queryParams.value.pageNum = 1;
|
getList();
|
}
|
|
/** 重置按钮操作 */
|
function resetQuery() {
|
proxy.resetForm("queryRef");
|
handleQuery();
|
}
|
|
// 多选框选中数据
|
function handleSelectionChange(selection) {
|
ids.value = selection.map((item) => item.id);
|
single.value = selection.length != 1;
|
multiple.value = !selection.length;
|
}
|
|
/** 新增按钮操作 */
|
async function handleAdd() {
|
reset();
|
open.value = true;
|
title.value = "添加日历管理";
|
const res = await listAll_plant({});
|
plantList.value = res.data;
|
|
console.log(res, "sjchhscwhciwhcwi");
|
}
|
/** 选择工厂后事件 加载车间 和 工序 **/
|
function changePlant(plant) {
|
listAps_shop({ plantCode: plant }).then((response) => {
|
console.log(response, "sbcsuhcuhscschsc");
|
shopList.value = response.rows;
|
});
|
selectProcessNameList({ orgCode: plant }).then((response) => {
|
processList.value = response.rows;
|
});
|
}
|
/** 修改按钮操作 */
|
function handleUpdate(row) {
|
reset();
|
const _id = row.id || ids.value;
|
getCalendar(_id).then((response) => {
|
form.value = response.data;
|
open.value = true;
|
title.value = "修改日历管理";
|
});
|
}
|
|
/** 提交按钮 */
|
function submitForm() {
|
proxy.$refs["calendarRef"].validate((valid) => {
|
if (valid) {
|
if (form.value.id != null) {
|
updateCalendar(form.value).then((response) => {
|
proxy.$modal.msgSuccess("修改成功");
|
open.value = false;
|
getList();
|
});
|
} else {
|
if (typeRadioNumber.value === 1) {
|
addCalendar({
|
...form.value,
|
content: {
|
weekdays: weekDaysSettingList.value,
|
},
|
}).then((response) => {
|
proxy.$modal.msgSuccess("新增成功");
|
open.value = false;
|
getList();
|
});
|
}else if(typeRadioNumber.value === 2){
|
addCalendar({
|
...form.value,
|
content: {
|
holidays: holidays.value,
|
},
|
}).then((response) => {
|
proxy.$modal.msgSuccess("新增成功");
|
open.value = false;
|
getList();
|
});
|
}
|
}
|
}
|
});
|
}
|
|
/** 删除按钮操作 */
|
function handleDelete(row) {
|
const _ids = row.id || ids.value;
|
proxy.$modal
|
.confirm('是否确认删除日历管理编号为"' + _ids + '"的数据项?')
|
.then(function () {
|
return delCalendar(_ids);
|
})
|
.then(() => {
|
getList();
|
proxy.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {});
|
}
|
|
/** 导出按钮操作 */
|
function handleExport() {
|
proxy.download(
|
"core/calendar/export",
|
{
|
...queryParams.value,
|
},
|
`calendar_${new Date().getTime()}.xlsx`
|
);
|
}
|
function handleSwitchType(e) {
|
console.log(e, "日期类型切换");
|
typeRadioNumber.value = e;
|
form.value.effectiveDate = null;
|
form.value.expiringDate = null;
|
form.value.content = null;
|
form.value.applicableFactory = null;
|
form.value.applicableWorkshop = null;
|
form.value.applicableProcess = null;
|
}
|
// 设置周工作日
|
function handleSetWorkDays(e) {
|
console.log(weekDaysSettingList.value, "设置周工作日");
|
}
|
function changePageNo(currentPage) {
|
queryParams.value.pageNum = currentPage;
|
page.value.current = currentPage;
|
getList();
|
}
|
function changePageSize(pageSize) {
|
page.value.current = 1;
|
queryParams.value.pageNum = 1;
|
queryParams.value.pageSize = pageSize;
|
getList();
|
}
|
// function formatType(type) {
|
// if(type===1){
|
// return "周工作"
|
// }else{
|
// return "节假日"
|
// }
|
// }
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
<style lang="scss" scoped>
|
.column-with-margin {
|
margin-right: 0px;
|
}
|
.title_bar_line {
|
display: flex;
|
justify-content: flex-start;
|
align-items: center;
|
color: #333;
|
margin-bottom: 10px;
|
.line_short {
|
width: 5%;
|
height: 1px;
|
margin-right: 20px;
|
border-top: 1px solid #ddd;
|
}
|
.line_long {
|
width: 60%;
|
height: 1px;
|
margin-left: 20px;
|
border-top: 1px solid #ddd;
|
}
|
}
|
.week_flex {
|
display: flex;
|
justify-content: flex-start;
|
align-content: center;
|
color: #606266;
|
font-weight: 700;
|
margin-left: 20px;
|
&.mt20 {
|
margin-top: 20px;
|
margin-left: 0 !important;
|
}
|
.week_flex_item {
|
&:nth-child(1) {
|
margin-top: 5px;
|
}
|
&:nth-child(2) {
|
margin-left: 20px;
|
}
|
}
|
}
|
.factory_use_item {
|
margin-top: 10px;
|
}
|
</style>
|