<template>
|
<div class="app-container">
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-position="left" >
|
<el-row :gutter="20">
|
<el-col
|
:span="6">
|
<el-form-item label="资源组" label-width="60px" prop="resourceGroupName">
|
<el-input
|
v-model="queryParams.resourceGroupName"
|
placeholder="请输入资源组名称"
|
clearable
|
@keyup.enter="handleQuery"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col
|
:span="6">
|
<el-form-item label="截止机加需求日期" style="width: 400px" label-width="140px">
|
<el-date-picker
|
v-model="daterangeRequestDate"
|
value-format="YYYY-MM-DD"
|
type="daterange"
|
range-separator="-"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
></el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col
|
:span="12"
|
style="text-align: right;">
|
<el-form-item>
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="info"
|
plain
|
icon="Upload"
|
@click="handleImport"
|
v-hasPermi="['ApsResourceGroup:ApsResourceGroup:importData']"
|
>导入</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="warning"
|
plain
|
icon="Download"
|
@click="handleExport"
|
v-hasPermi="['ApsResourceGroup:ApsResourceGroup:export']"
|
>导出</el-button>
|
</el-col>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
|
<HxlhTable
|
style="width: 100%"
|
:columns="columns"
|
:data="ApsResourceGroupList"
|
:loading="loading"
|
:height="height"
|
@on-checkbox="handleCheckboxChange"
|
>
|
</HxlhTable>
|
<!-- 用户导入对话框 -->
|
<el-dialog :title="upload.title" v-model="upload.open" width="90%" append-to-body @close="dialogCancel">
|
<el-row :gutter="10">
|
<el-col>
|
<div style="border-bottom: 1px solid #ccc;" >
|
<p>上传Excel文件,包含资源池信息。系统将解析数据并保存到本地,用于关联到零件计划中。</p>
|
</div>
|
</el-col>
|
<el-col >
|
<div></div>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="10" style="margin-top: 20px;">
|
</el-row>
|
<el-row>
|
<el-col>
|
<el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="true" drag>
|
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
<template #tip>
|
<div class="el-upload__tip">
|
<span>仅允许导入xls、xlsx格式文件。</span>
|
</div>
|
</template>
|
</el-upload>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col style="margin-top: 20px;">
|
<div v-show="isVisible">
|
<el-alert icon="Check" :show-icon="true" title="资源池数据已成功解析" type="success" :closable="false"/>
|
</div>
|
<div v-show="isError">
|
<el-alert icon="Close" :show-icon="true" title="资源池数据已解析失败" type="error" :closable="false"/>
|
</div>
|
</el-col>
|
</el-row>
|
<el-row v-show="isVisible">
|
<el-col>
|
<div>
|
<h2>数据预览</h2>
|
</div>
|
<HxlhTable
|
style="width: 100%"
|
:columns="exampleColumns"
|
:data="exampleList"
|
:loading="loading"
|
:maxHeight="exampleHeight"
|
@on-checkbox="handleCheckboxChange"
|
>
|
</HxlhTable>
|
</el-col>
|
<el-col>
|
<div style="text-align: right;">
|
<h4>共上传<span style="color: blue;">{{ total }}</span>条资源池数据</h4>
|
</div>
|
</el-col>
|
<el-col>
|
<el-form-item label="截止机加需求日期" prop="requestDate" >
|
<el-date-picker clearable
|
v-model="requestDate"
|
type="date"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
placeholder="请选择机加需求日期"
|
:disabled-date="disabledDate"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button
|
type="success"
|
plain
|
icon="Check"
|
:disabled="planned"
|
@click="uploadParse"
|
v-hasPermi="['partPlan:edit']"
|
>确认上传</el-button>
|
<el-button @click="dialogCancel">取 消</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup name="ApsResourceGroup">
|
import { listApsResourceGroup, getApsResourceGroup, delApsResourceGroup, addApsResourceGroup, updateApsResourceGroup,apsResourceGroupTempList,confirmApsResourceGroup } from "@/api/basicData/ApsResourceGroup.js";
|
import HxlhTable from '@/components/HxlhTable/index.vue'
|
import { getToken } from "@/utils/auth.js";
|
import { ref } from "vue";
|
// import { ElMessage } from 'element-plus'
|
const { proxy } = getCurrentInstance();
|
|
const ApsResourceGroupList = 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 daterangeRequestDate = ref([]);
|
//弹窗相关
|
const height = ref(document.documentElement.clientHeight - 230 + "px;")
|
const isVisible = ref(false);
|
const isError = ref(false);
|
const planned = ref(true);
|
const batchNumber = ref(null);
|
const exampleHeight = ref("500px");
|
const uploadRef = ref();
|
const exampleList = ref([]);
|
const requestDate = ref(null);
|
// 计算当前时间往后推 15 天的日期
|
const disabledDate = (time) => {
|
// return time.getTime() > Date.now()
|
// 计算 15 天的毫秒数
|
const fifteenDaysInMillis = 15 * 24 * 60 * 60 * 1000;
|
// 计算当前时间加上 15 天后的毫秒数
|
const maxTime = Date.now() + fifteenDaysInMillis;
|
return time.getTime() > maxTime;
|
}
|
/*** 用户导入参数 */
|
const upload = reactive({
|
// 是否显示弹出层(用户导入)
|
open: false,
|
// 弹出层标题(用户导入)
|
title: "",
|
// 是否禁用上传
|
isUploading: false,
|
// 是否更新已经存在的用户数据
|
updateSupport: 0,
|
// 设置上传的请求头部
|
headers: { Authorization: "Bearer " + getToken() },
|
// 上传的地址
|
url: import.meta.env.VITE_APP_BASE_API + "/aps/apsResourceGroup/importData"
|
});
|
// 表格配置-列表
|
const columns = ref([
|
{ type: 'checkbox', width: 60, align:"center"},
|
{ type: 'seq', title: '序号', width: 60 },
|
{
|
title: '资源组名称',
|
field: 'resourceGroupName',
|
width: 300,
|
align:"center",
|
},
|
{
|
title: '设备数量',
|
field: 'devicesQuantity',
|
width: 150,
|
align:"center",
|
},
|
{
|
title: '每日理论时间',
|
field: 'theoryHours',
|
width: 300,
|
align:"center",
|
},
|
{
|
title: '截止需求日剩余天数',
|
field: 'restDays',
|
width: 210,
|
align:"center",
|
},
|
{
|
title: '理论产能',
|
field: 'theoryCapacity',
|
width: 300,
|
align:"center",
|
},
|
{
|
title: '截止机加需求日期',
|
field: 'requestDate',
|
width: 300,
|
align:"center",
|
}
|
]);
|
// 表格配置-弹窗
|
const exampleColumns = ref([
|
{ type: 'seq', title: '序号', width: 60 },
|
{
|
title: '资源组名称',
|
field: 'resourceGroupName',
|
width: 300,
|
align:"center",
|
},
|
{
|
title: '设备数量',
|
field: 'devicesQuantity',
|
width: 150,
|
align:"center",
|
},
|
{
|
title: '每日理论时间',
|
field: 'theoryHours',
|
width: 300,
|
align:"center",
|
},
|
{
|
title: '截止需求日剩余天数',
|
field: 'restDays',
|
width: 210,
|
align:"center",
|
},
|
{
|
title: '理论产能',
|
field: 'theoryCapacity',
|
width: 300,
|
align:"center",
|
},
|
{
|
title: '截止机加需求日期',
|
field: 'requestDate',
|
width: 370,
|
align:"center",
|
}
|
]);
|
const data = reactive({
|
form: {},
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
resourceGroupName: null,
|
devicesQuantity: null,
|
theoryHours: null,
|
restDays: null,
|
theoryCapacity: null,
|
requestDate: null,
|
plant: null
|
},
|
rules: {
|
|
}
|
});
|
|
const { queryParams, form, rules } = toRefs(data);
|
|
/** 查询资源组列表 */
|
function getList() {
|
loading.value = true;
|
queryParams.value.params = {};
|
if (null != daterangeRequestDate && '' != daterangeRequestDate) {
|
queryParams.value.params["beginRequestDate"] = daterangeRequestDate.value[0];
|
queryParams.value.params["endRequestDate"] = daterangeRequestDate.value[1];
|
}
|
listApsResourceGroup(queryParams.value).then(response => {
|
ApsResourceGroupList.value = response.rows;
|
total.value = response.total;
|
loading.value = false;
|
});
|
}
|
function handleCheckboxChange(){}
|
// 取消按钮
|
function cancel() {
|
open.value = false;
|
reset();
|
}
|
|
// 表单重置
|
function reset() {
|
form.value = {
|
id: null,
|
resourceGroupName: null,
|
devicesQuantity: null,
|
theoryHours: null,
|
restDays: null,
|
theoryCapacity: null,
|
requestDate: null,
|
delFlag: null,
|
createBy: null,
|
createTime: null,
|
updateBy: null,
|
updateTime: null,
|
plant: null
|
};
|
proxy.resetForm("ApsResourceGroupRef");
|
}
|
|
/** 搜索按钮操作 */
|
function handleQuery() {
|
queryParams.value.pageNum = 1;
|
getList();
|
}
|
|
/** 重置按钮操作 */
|
function resetQuery() {
|
daterangeRequestDate.value = [];
|
proxy.resetForm("queryRef");
|
handleQuery();
|
}
|
|
// 多选框选中数据
|
function handleSelectionChange(selection) {
|
ids.value = selection.map(item => item.id);
|
single.value = selection.length != 1;
|
multiple.value = !selection.length;
|
}
|
|
/** 新增按钮操作 */
|
function handleAdd() {
|
reset();
|
open.value = true;
|
title.value = "添加资源组";
|
}
|
|
/** 修改按钮操作 */
|
function handleUpdate(row) {
|
reset();
|
const _id = row.id || ids.value
|
getApsResourceGroup(_id).then(response => {
|
form.value = response.data;
|
open.value = true;
|
title.value = "修改资源组";
|
});
|
}
|
|
/** 提交按钮 */
|
function submitForm() {
|
proxy.$refs["ApsResourceGroupRef"].validate(valid => {
|
if (valid) {
|
if (form.value.id != null) {
|
updateApsResourceGroup(form.value).then(response => {
|
proxy.$modal.msgSuccess("修改成功");
|
open.value = false;
|
getList();
|
});
|
} else {
|
addApsResourceGroup(form.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 delApsResourceGroup(_ids);
|
}).then(() => {
|
getList();
|
proxy.$modal.msgSuccess("删除成功");
|
}).catch(() => {});
|
}
|
|
/** 导入按钮操作 */
|
function handleImport() {
|
upload.title = "资源池数据上传";
|
upload.open = true;
|
};
|
/** 导出按钮操作 */
|
function handleExport() {
|
proxy.download('aps/apsResourceGroup/export', {
|
...queryParams.value
|
}, `apsResourceGroup_${new Date().getTime()}.xlsx`)
|
}
|
|
|
/**文件上传中处理 */
|
const handleFileUploadProgress = (event, file, fileList) => {
|
upload.isUploading = true;
|
};
|
|
/** 文件上传成功处理 */
|
const handleFileSuccess = (response, file, fileList) => {
|
if(response.code == '200'){
|
batchNumber.value = response.data;
|
isVisible.value = true;
|
planned.value = false;
|
isError.value = false;
|
getExampleList();
|
}else{
|
isError.value = true;
|
proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
|
}
|
proxy.$refs["uploadRef"].handleRemove(file);
|
upload.isUploading = false;
|
};
|
/** 查询临时管理列表 */
|
function getExampleList() {
|
loading.value = true;
|
queryParams.value = {};
|
queryParams.value.batchNumber = batchNumber.value;
|
apsResourceGroupTempList(queryParams.value).then(response => {
|
exampleList.value = response.rows;
|
total.value = response.total;
|
loading.value = false;
|
});
|
}
|
/** 上传并解析按钮操作 */
|
function uploadParse() {
|
if (requestDate.value === null || typeof requestDate.value === 'undefined' || requestDate.value === '') {
|
ElMessage({
|
message: '请选择截止机加需求日期',
|
type: 'warning',
|
})
|
return
|
}
|
queryParams.value.params = {};
|
queryParams.value.params["requestDate"] = requestDate.value;
|
confirmApsResourceGroup(queryParams.value).then(response => {
|
exampleList.value = response.rows;
|
loading.value = false;
|
isVisible.value = false;
|
isError.value = false;
|
planned.value = true;
|
upload.open = false;
|
requestDate.value = null;
|
ElMessage({
|
message: '资源池数据已成功上传和解析',
|
type: 'success',
|
})
|
getList();
|
});
|
}
|
|
/** dialog取消 */
|
function dialogCancel(){
|
if (uploadRef.value) {
|
uploadRef.value.clearFiles();
|
}
|
requestDate.value = null;
|
isVisible.value = false;
|
isError.value = false;
|
planned.value = true;
|
upload.open = false;
|
upload.isUploading = false;
|
}
|
|
getList();
|
</script>
|