261 lines
7.1 KiB
Vue
Raw Normal View History

<template>
<div class="table-box">
<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 #investmentPaymentId="scope">
<span>{{ scope.row.investmentPaymentId ? "已支付" : "未支付" }}</span>
</template>
<template #operation="{ row }">
<el-button type="primary" link @click="handleItemDetail(2, row)">
<img src="@/assets/images/tableIcon/updateIcon.png" alt="" class="configureIcon" />
<span>查看</span>
</el-button>
</template>
</ProTable>
<!-- 新增 -->
<DialogForm
title="新增"
:formConfig="formConfig"
:formData="formData"
v-model:visible="openVisible"
append-to-body
width="700px"
@confirm="saveItem"
>
</DialogForm>
<!-- 投资支付详情 -->
<transformInfo1 v-model:detailsDialog="detailsDialog" :relativeId="relativeId"></transformInfo1>
2023-08-09 16:56:27 +08:00
<!-- 侧边栏选择 -->
<engineeringEngDrawer v-model="engVisable" ref="engDrawer" :engList="engList">
<template #default="{ data }">
<span style="margin-left: 10px" @click="onUpdate(data)">{{ data.engineeringName }}</span>
</template>
</engineeringEngDrawer>
<allEngineering @click="engVisable = true" />
</div>
</template>
<script setup lang="tsx" name="ProjectSupervisionRecord">
2023-08-09 16:56:27 +08:00
import { ref, reactive, onMounted } from "vue";
import { ElMessage, ElMessageBox, UploadProps } from "element-plus";
import { useRouter } from "vue-router";
import { ColumnProps } from "@/components/ProTable/interface";
import ProTable from "@/components/ProTable/index.vue";
import { applyTimePage, applyTimeAdd } from "@/api/modules/enterpriseApi";
import { GlobalStore } from "@/stores";
import DialogForm from "@/components/DialogForm/index.vue";
import transformInfo1 from "./components/transformInfo1.vue";
2023-08-09 16:56:27 +08:00
import engineeringEngDrawer from "@/components/engineeringEngDrawer/index.vue";
import allEngineering from "@/components/allEngineering/index.vue";
import { getRelevanceList } from "@/api/modules/common";
const engList = ref([]);
const engVisable = ref(false);
const searchSn = ref("");
const relativeId = ref("");
const detailsDialog = ref(false);
const globalStore = GlobalStore();
const openVisible = ref(false);
// 弹窗中的配置
const formConfig = {
formItemConfig: [
{
label: "申报名称",
prop: "name",
type: "input"
},
{
label: "申报时段",
prop: "applyTime",
type: "date",
format: "YYYY-MM-DD",
valueFormat: "YYYY-MM-DD"
}
],
rules: {
name: [
{
required: true,
message: "请输入",
trigger: "blur"
}
],
applyTime: [
{
required: true,
message: "请选择",
trigger: "change"
}
]
}
};
const treeRef = ref(null);
const datas = reactive([]);
const router = useRouter();
const visible = ref(false);
const drawerVisible = ref(false);
const title = ref("");
const formData = ref({
name: "",
applyTime: ""
});
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTable = ref();
const getId = ref<number | undefined>(undefined);
// 表格配置项
const columns: ColumnProps[] = [
{ type: "index", label: "序号", width: 80 },
// 多级 prop
{ prop: "projectName", label: "项目名称" },
{ prop: "name", label: "申报时段名称", search: { el: "input" } },
{ prop: "applyTime", label: "申报时段" },
{ prop: "investmentPaymentId", label: "支付状态" },
// {
// prop: "contractTime",
// label: "合同签订日期",
// width: 150,
// search: {
// el: "date-picker",
// props: {
// type: "daterange",
// format: "YYYY-MM-DD",
// valueFormat: "YYYY-MM-DD"
// // defaultTime: defaultTime2
// }
// }
// },
{ prop: "operation", label: "操作", fixed: "right", width: 120 }
];
2023-08-09 16:56:27 +08:00
const getengineering = async () => {
// let newParams = JSON.parse(JSON.stringify(params));
const res = await getRelevanceList();
engList.value = res.result;
if (res.result && res.result.length > 0) {
searchSn.value = res.result[0].engineeringSn;
}
proTable.value.getTableList();
console.log(res);
};
// 点击抽屉的工程名称更新页面
const onUpdate = async row => {
searchSn.value = row.engineeringSn;
proTable.value.getTableList();
ElMessage.success("页面已更新");
};
const handleAddItem = () => {
formData.value = reactive({
name: "",
applyTime: ""
});
openVisible.value = true;
};
const saveItem = async (form: any) => {
2023-08-09 18:36:33 +08:00
form.engineeringSn = searchSn.value;
if (form.id) {
// console.log(form.dictCode);
const res = await applyTimeAdd(form);
proTable.value.getTableList();
ElMessage.success("编辑成功");
} else {
const res = await applyTimeAdd(form);
ElMessage.success("新增成功");
proTable.value.getTableList();
}
openVisible.value = false;
};
// 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)
};
};
const transfrom = (arr: Array<any>) => {
const result = [];
return arr
.map(item => {
if (arr.children && Array.isArray(arr.children)) {
result.concat(transfrom(arr.children));
}
return {
authorityId: item.name,
roleId: getId.value,
type: item.type
};
})
.concat(result);
};
// 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数params 为当前所有的请求参数(包括分页),最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
const getTableList = (params: any) => {
let newParams = JSON.parse(JSON.stringify(params));
if (newParams.contractTime) {
newParams.contractTime_begin = newParams.contractTime[0];
newParams.contractTime_end = newParams.contractTime[1];
delete newParams.contractTime;
}
2023-08-09 16:56:27 +08:00
newParams.engineeringSn = searchSn.value;
return applyTimePage(newParams);
};
const handleItemDetail = (index: number, row: any) => {
console.log(row);
// if (index === 1) {
// title.value = "新增角色";
// formData.value = reactive({});
// } else {
// title.value = "编辑角色";
// formData.value = reactive({ ...row });
// }
relativeId.value = row.id;
detailsDialog.value = true;
};
2023-08-09 16:56:27 +08:00
onMounted(() => {
getengineering();
});
</script>
<style scoped lang="scss">
.table-box {
height: 100%;
position: relative;
.imgDialog {
.uploadBtn {
color: white;
font-size: 20px;
border: 1px solid #087ba4;
background: #087ba4;
}
}
}
:deep() {
.el-form .el-form-item__content .el-range-editor {
width: 300px;
}
.el-range-separator {
color: var(--el-menu-text-color);
}
}
</style>