524 lines
13 KiB
Vue
524 lines
13 KiB
Vue
<template>
|
||
<div class="warning-page">
|
||
<LeftMenu
|
||
v-model="active"
|
||
:tabs="['项目名称', '工程名称']"
|
||
:records="records"
|
||
@change-page="onCurChange"
|
||
@search="onSearchInput"
|
||
:pageable="pages"
|
||
class="leftMenu"
|
||
>
|
||
<template #default="{ data }">
|
||
<div class="leftProject" @click="onSearch(data)">
|
||
<span class="projectName">{{ data.projectName || data.engineeringName }}</span>
|
||
<div class="leftMenu_item">
|
||
<div class="leftMenu_item flx-justify-between">
|
||
<div style="margin-top: 5px" class="flx-justify-between">
|
||
<img style="margin-right: 5px" src="@/assets/images/AIwaring/dustMap.png" alt="" />
|
||
<el-tooltip effect="dark" :content="data.projectAddress || data.address" placement="top-start">
|
||
<span class="middleSize">{{ data.projectAddress || data.address }}</span>
|
||
</el-tooltip>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</LeftMenu>
|
||
<div class="table-box">
|
||
<div class="table">
|
||
<ProTable
|
||
ref="proTable"
|
||
title="用户列表"
|
||
:columns="columns"
|
||
:requestApi="getTableList"
|
||
:dataCallback="dataCallback"
|
||
:tool-button="false"
|
||
:pagination="true"
|
||
background
|
||
:isShowSearch="false"
|
||
:onReset="true"
|
||
>
|
||
<template #formButton="scope">
|
||
<el-button type="primary" @click="handleAddItem()">新增</el-button>
|
||
</template>
|
||
<!-- 表格操作 -->
|
||
<template #operation="{ row }">
|
||
<el-button type="primary" link @click="handleEditItem(row)">
|
||
<img src="@/assets/images/tableIcon/updateIcon.png" alt="" class="configureIcon" />
|
||
<span>编辑</span>
|
||
</el-button>
|
||
<el-button type="primary" link @click="handleItemDetail(row)">
|
||
<img src="@/assets/images/tableIcon/look.png" alt="" class="configureIcon" />
|
||
<span>查看</span>
|
||
</el-button>
|
||
</template>
|
||
</ProTable>
|
||
<DialogForm
|
||
:title="title"
|
||
:formConfig="formConfig"
|
||
:formData="formData"
|
||
v-model:visible="visible"
|
||
append-to-body
|
||
width="36%"
|
||
@confirm="saveItem"
|
||
>
|
||
</DialogForm>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import { ref, reactive, onMounted, watch } from "vue";
|
||
import { GlobalStore } from "@/stores";
|
||
import LeftMenu from "@/components/LeftMenu/LeftMenu.vue";
|
||
import ProTable from "@/components/ProTable/index.vue";
|
||
import DialogForm from "@/components/DialogForm/index.vue";
|
||
import { ColumnProps } from "@/components/ProTable/interface";
|
||
import {
|
||
globalPlanGovermentList,
|
||
globalPlanProList,
|
||
globalPlanEngList,
|
||
globalPlanGovermentAdd,
|
||
globalPlanGovermentEdit
|
||
} from "@/api/modules/goverment";
|
||
import { getDicList } from "@/api/modules/jxjview";
|
||
import { ElMessage } from "element-plus";
|
||
const pages = ref({
|
||
pageNo: 1,
|
||
pageSize: 7,
|
||
total: 0
|
||
});
|
||
const records = ref([]);
|
||
const DicMainList = ref([]);
|
||
const active = ref(0);
|
||
const store = GlobalStore();
|
||
// 表格配置项
|
||
const columns: ColumnProps[] = [
|
||
{ type: "index", label: "序号", width: 80 },
|
||
{
|
||
prop: "nodeNumber",
|
||
label: "节点编号",
|
||
width: 150
|
||
},
|
||
// 多级 prop
|
||
{ prop: "nodeName", label: "节点名称", width: 150, search: { el: "input" } },
|
||
{ prop: "type", label: "节点类型", width: 150 },
|
||
{ prop: "standardCompleteTime", label: "标准完成时间", width: 150 },
|
||
{ prop: "planCompleteTime", label: "计划完成时间", width: 150 },
|
||
{ prop: "expectCompleteTime", label: "预计完成时间", width: 150 },
|
||
// {
|
||
// prop: "state",
|
||
// label: "状态",
|
||
// width: 150,
|
||
// isShow: false,
|
||
// search: { el: "select" },
|
||
// enum: DicMainList.value,
|
||
// fieldNames: { label: "dictValue", value: "dictLabel" }
|
||
// },
|
||
{
|
||
prop: "status",
|
||
label: "状态",
|
||
width: 150
|
||
},
|
||
{
|
||
prop: "realCompleteTime",
|
||
label: "实际完成时间",
|
||
width: 150,
|
||
search: {
|
||
el: "date-picker",
|
||
span: 2,
|
||
props: { type: "daterange", format: "YYYY-MM-DD", valueFormat: "YYYY-MM-DD" }
|
||
// defaultValue: "2023-05"
|
||
}
|
||
},
|
||
{ prop: "phaseName", label: "智能条线", width: 150 },
|
||
// { prop: "chargerPhone", label: "负责人联系方式", width: 180 },
|
||
{ prop: "chargerNumber", label: "节点责任编号", width: 150 },
|
||
{ prop: "chargerName", label: "节点责任人", width: 150 },
|
||
{
|
||
prop: "isDeleted",
|
||
label: "节点失效标记",
|
||
width: 150,
|
||
render: scoped => {
|
||
return scoped.row.isDeleted == 0 ? "有效" : "失效";
|
||
}
|
||
},
|
||
{
|
||
prop: "isSendBack",
|
||
label: "是否退回",
|
||
width: 150,
|
||
render: scoped => {
|
||
return scoped.row.isSendBack == 1 ? "是" : "否";
|
||
}
|
||
},
|
||
{ prop: "operation", label: "操作", width: 160, fixed: "right" }
|
||
];
|
||
const formData = ref({
|
||
nodeNumber: "",
|
||
nodeName: "",
|
||
type: "",
|
||
standardCompleteTime: "",
|
||
planCompleteTime: "",
|
||
expectCompleteTime: "",
|
||
realCompleteTime: "",
|
||
state: null,
|
||
actualDeviation: "",
|
||
phaseName: "",
|
||
chargerNumber: "",
|
||
chargerName: ""
|
||
});
|
||
const visible = ref(false);
|
||
const title = ref("新增");
|
||
// 搜索用的项目sn或者工程sn
|
||
const searchSn = ref("");
|
||
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
|
||
const proTable = ref();
|
||
// 弹窗中的配置
|
||
const formConfig = {
|
||
formItemConfig: [
|
||
{
|
||
label: "节点编码",
|
||
prop: "nodeNumber",
|
||
type: "input",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "节点名称",
|
||
prop: "nodeName",
|
||
type: "input",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "节点类型",
|
||
prop: "type",
|
||
type: "input",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "标准完成时间",
|
||
prop: "standardCompleteTime",
|
||
type: "date",
|
||
format: "YYYY-MM-DD",
|
||
valueFormat: "YYYY-MM-DD",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "计划完成时间",
|
||
prop: "planCompleteTime",
|
||
type: "date",
|
||
format: "YYYY-MM-DD",
|
||
valueFormat: "YYYY-MM-DD",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "预计完成时间",
|
||
prop: "expectCompleteTime",
|
||
type: "date",
|
||
format: "YYYY-MM-DD",
|
||
valueFormat: "YYYY-MM-DD",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "实际完成时间",
|
||
prop: "realCompleteTime",
|
||
type: "date",
|
||
format: "YYYY-MM-DD",
|
||
valueFormat: "YYYY-MM-DD",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "状态",
|
||
prop: "state",
|
||
type: "select",
|
||
data: [],
|
||
clearable: true,
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "实际偏差",
|
||
prop: "actualDeviation",
|
||
type: "input",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "职能线条",
|
||
prop: "phaseName",
|
||
type: "input",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "节点责任人编号",
|
||
prop: "chargerNumber",
|
||
type: "input",
|
||
disabled: true
|
||
},
|
||
{
|
||
label: "节点责任人",
|
||
prop: "chargerName",
|
||
type: "input",
|
||
disabled: true
|
||
}
|
||
],
|
||
rules: {
|
||
nodeNumber: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "blur"
|
||
}
|
||
],
|
||
nodeName: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "blur"
|
||
}
|
||
],
|
||
type: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "blur"
|
||
}
|
||
],
|
||
standardCompleteTime: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "blur"
|
||
}
|
||
],
|
||
planCompleteTime: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "blur"
|
||
}
|
||
],
|
||
engineeringSn: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "change"
|
||
}
|
||
],
|
||
phaseName: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "blur"
|
||
}
|
||
],
|
||
chargerNumber: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "blur"
|
||
}
|
||
],
|
||
chargerName: [
|
||
{
|
||
required: true,
|
||
message: "请输入",
|
||
trigger: "blur"
|
||
}
|
||
]
|
||
}
|
||
};
|
||
// 项目或者工程名字
|
||
const searchName = ref<string>("");
|
||
// 修改数据按钮
|
||
const handleEditItem = async (row: any) => {
|
||
console.log(row);
|
||
formData.value = reactive({ ...row });
|
||
title.value = "编辑";
|
||
formConfig.formItemConfig.map(item => {
|
||
item.disabled = false;
|
||
});
|
||
visible.value = true;
|
||
};
|
||
const handleAddItem = () => {
|
||
formData.value = reactive({
|
||
nodeNumber: "",
|
||
nodeName: "",
|
||
type: "",
|
||
standardCompleteTime: "",
|
||
planCompleteTime: "",
|
||
expectCompleteTime: "",
|
||
realCompleteTime: "",
|
||
state: null,
|
||
actualDeviation: "",
|
||
phaseName: "",
|
||
chargerNumber: "",
|
||
chargerName: ""
|
||
});
|
||
title.value = "新增";
|
||
// fileList.value = reactive([]);
|
||
formConfig.formItemConfig.map(item => {
|
||
item.disabled = false;
|
||
});
|
||
visible.value = true;
|
||
};
|
||
const getDicMainList = async () => {
|
||
// 获取状态字典
|
||
const { result } = await getDicList({ dictType: "node_plan_state" });
|
||
console.log(result);
|
||
if (result.length > 0) {
|
||
formConfig.formItemConfig[7].data = result.map(item => {
|
||
return {
|
||
label: item.dictValue,
|
||
value: item.status
|
||
};
|
||
});
|
||
DicMainList.value.length = 0;
|
||
DicMainList.value.push(...result);
|
||
}
|
||
};
|
||
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,那么你可以在这里进行处理成这些字段
|
||
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
|
||
const dataCallback = (data: any) => {
|
||
// console.log(data);
|
||
return {
|
||
list: data.records,
|
||
total: Number(data.total),
|
||
pageNo: Number(data.current),
|
||
pageSize: Number(data.size)
|
||
};
|
||
};
|
||
// 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
|
||
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
|
||
const getTableList = (params: any) => {
|
||
let newParams = JSON.parse(JSON.stringify(params));
|
||
if (newParams.realCompleteTime) {
|
||
newParams.realCompleteTime_begin = newParams.realCompleteTime[0];
|
||
newParams.realCompleteTime_end = newParams.realCompleteTime[1];
|
||
delete newParams.realCompleteTime;
|
||
}
|
||
if (searchSn.value) {
|
||
if (active.value === 0) {
|
||
newParams.projectSn = searchSn.value;
|
||
} else {
|
||
newParams.engineeringSn = searchSn.value;
|
||
}
|
||
} else {
|
||
return { result: { current: "1", pages: "1", records: [], size: "10", total: "0" } };
|
||
}
|
||
return globalPlanGovermentList(newParams);
|
||
};
|
||
// 页面的项目名称和工程名称的div点击事件
|
||
const onSearch = async (params: any) => {
|
||
active.value === 0 ? (searchSn.value = params ? params.projectSn : "") : (searchSn.value = params ? params.engineeringSn : "");
|
||
active.value === 0
|
||
? (searchName.value = params ? params.projectName : "")
|
||
: (searchName.value = params ? params.engineeringName : "");
|
||
proTable.value.getTableList();
|
||
};
|
||
// leftMenu页面的搜索按钮
|
||
const onSearchInput = async (params: string) => {
|
||
console.log(params);
|
||
if (active.value === 0) {
|
||
const { result } = await globalPlanProList({ projectName: params, ...pages.value });
|
||
records.value = result.records;
|
||
} else {
|
||
const { result } = await globalPlanEngList({ engineeringName: params, ...pages.value });
|
||
records.value = result.records;
|
||
}
|
||
proTable.value.getTableList();
|
||
};
|
||
// leftMenu页面的分页
|
||
const onCurChange = async (params: number) => {
|
||
if (active.value === 0) {
|
||
const { result } = await globalPlanProList({ ...pages.value, pageNo: params });
|
||
records.value = result.records;
|
||
} else {
|
||
const { result } = await globalPlanEngList({ ...pages.value, pageNo: params });
|
||
records.value = result.records;
|
||
pages.value.total = +result.total;
|
||
}
|
||
pages.value.total = +res.result.total;
|
||
};
|
||
// 获取项目名称分页
|
||
const getProPage = async () => {
|
||
const { result } = await globalPlanProList(pages.value);
|
||
records.value = result.records;
|
||
records.value.map(item => {
|
||
let showGif = false;
|
||
item.showGif = showGif;
|
||
});
|
||
pages.value.total = Number(result.total);
|
||
};
|
||
// 获取工程名称分页
|
||
const getEngPage = async () => {
|
||
const { result } = await globalPlanEngList(pages.value);
|
||
records.value = result.records;
|
||
records.value.map(item => {
|
||
let showGif = false;
|
||
item.showGif = showGif;
|
||
});
|
||
pages.value.total = +result.total;
|
||
};
|
||
// 查看数据按钮
|
||
const handleItemDetail = async (row: any) => {
|
||
console.log(row);
|
||
formData.value = reactive({ ...row });
|
||
formConfig.formItemConfig.map(item => {
|
||
item.disabled = true;
|
||
});
|
||
title.value = "查看";
|
||
visible.value = true;
|
||
};
|
||
// 新增,编辑数据
|
||
const saveItem = async (form: any) => {
|
||
if (active.value === 0) {
|
||
form.projectSn = searchSn.value;
|
||
delete form.engineeringSn;
|
||
} else {
|
||
form.engineeringSn = searchSn.value;
|
||
delete form.projectSn;
|
||
}
|
||
if (form.id && title.value != "查看") {
|
||
// console.log(form.dictCode);
|
||
const res = await globalPlanGovermentEdit(form);
|
||
proTable.value.getTableList();
|
||
ElMessage.success("编辑成功");
|
||
} else if (title.value != "查看" && !form.id) {
|
||
const res = await globalPlanGovermentAdd(form);
|
||
ElMessage.success("新增成功");
|
||
proTable.value.getTableList();
|
||
}
|
||
visible.value = false;
|
||
};
|
||
watch(
|
||
() => active.value,
|
||
async (value: number) => {
|
||
pages.value.pageNo = 1;
|
||
pages.value.total = 0;
|
||
// console.log(value);
|
||
|
||
if (value === 0) {
|
||
await getProPage();
|
||
onSearch(records.value[0]);
|
||
} else {
|
||
await getEngPage();
|
||
onSearch(records.value[0]);
|
||
}
|
||
},
|
||
{
|
||
deep: true
|
||
}
|
||
);
|
||
onMounted(async () => {
|
||
getDicMainList();
|
||
await getProPage();
|
||
searchSn.value = records.value[0].projectSn;
|
||
searchName.value = records.value[0].projectName;
|
||
onSearch(records.value[0]);
|
||
});
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
@import "./index.scss";
|
||
</style>
|