You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

581 lines
15 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<xy-dialog
ref="dialog"
:is-show.sync="isShow"
type="form"
:title="type === 'add' ? '新增财评评审' : '编辑财评评审'"
:form="form"
:rules="rules"
@submit="submit"
>
<template v-slot:plan_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
项目
</div>
<div class="xy-table-item-content">
<el-input
readonly
:disabled="type === 'editor'"
:value="rowName"
clearable
placeholder="请输入项目"
style="width: 300px"
@focus="isShowModal = true"
></el-input>
</div>
</div>
</template>
<template v-slot:content>
<div class="xy-table-item">
<div class="xy-table-item-label">评审内容 </div>
<div class="xy-table-item-content">
<el-select
v-model="form.content"
clearable
placeholder="请选择评审内容"
style="width: 300px"
>
<el-option v-for="i in ['概算评审','预算评审','竣工结算评审','竣工财务评审']" :label="i" :value="i">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:plan_date v-if="role === 0">
<div class="xy-table-item">
<div class="xy-table-item-label">计划评审时间 </div>
<div class="xy-table-item-content">
<el-date-picker
type="month"
v-model="form.plan_date"
placeholder="请选择计划评审时间"
style="width: 300px"
value-format="yyyy-MM-dd"
></el-date-picker>
</div>
</div>
</template>
<template v-slot:actually_date v-if="role === 1">
<div class="xy-table-item">
<div class="xy-table-item-label">实际评审时间 </div>
<div class="xy-table-item-content">
<el-date-picker
v-model="form.actually_date"
placeholder="请选择实际评审时间"
style="width: 300px"
value-format="yyyy-MM-dd"
></el-date-picker>
</div>
</div>
</template>
<template #item_list>
<el-button
v-if="role == 0"
icon="el-icon-plus"
type="primary"
size="small"
@click="
form.item_list.push({
content: '',
plan_date: '',
actually_date: '',
})
"
>新增</el-button
>
<xy-table
style="margin-top: 20px"
:height="320"
:table-item="itemTable"
:list="form.item_list"
>
<template #btns> </template>
</xy-table>
</template>
</xy-dialog>
<Modal title="项目" v-model="isShowModal" :width="50" @on-ok="rowPick(tempRow)" @on-visible-change="t => t ? '' : (tempRow = {},$refs['budgetTable'].clearCurrentRow())">
<div class="select">
<DatePicker
:value="budgetSelect.year"
placeholder="选择所属年份"
placement="bottom"
style="width: 130px"
type="year"
@on-change="(e) => (budgetSelect.year = e)"
></DatePicker>
<Select
v-model="budgetSelect.type"
clearable
placeholder="选择预算类型"
style="width: 130px"
>
<Option v-for="item in moneyWay" :key="item.id" :value="item.id">{{
item.value
}}</Option>
</Select>
<Select
placeholder="科室选择"
clearable
v-model="budgetSelect.department"
style="width: 160px"
>
<Option
v-for="item in departments"
:value="item.id"
:key="item.id"
>{{item.name}}
</Option>
</Select>
<Button style="float: right;" type="primary" @click="budgetSelect.page=1,getBudgets()"
>查询</Button
>
</div>
<Table
ref="budgetTable"
:height="440"
:data="budgets"
:columns="budgetTable"
highlight-row
@on-row-click="row => tempRow = row"
></Table>
<div style="padding: 10px 0; display: flex; justify-content: center">
<Page
:total="budgetTotal"
show-elevator
@on-change="
(e) => {
budgetSelect.page = e;
getBudgets();
}
"
/>
</div>
</Modal>
</div>
</template>
<script>
import { getBudget } from "@/api/budget/budget";
import { show, save, store } from "@/api/propertyPlan";
import { moneyFormatter, parseTime } from "@/utils";
import { getparameter } from "@/api/system/dictionary";
import {listdeptNoAuth} from "@/api/system/department";
export default {
props: {
role: {
type: Number,
default: 0,
},
},
data() {
return {
isShowModal: false,
isShow: false,
id: "",
pid: "",
type: "",
itemTable: [
{
prop: "content",
label: "评审内容",
minWidth: 200,
sortable: false,
customFn: (row) => {
return (
<el-select
placeholder="评审内容"
readonly={this.role == 1}
style="width: 100%;"
v-model={row.content}
size="mini"
clearable={true}
>
{
['概算评审','预算评审','竣工结算评审','竣工财务评审'].map(i => {
return (
<el-option label={i} value={i}></el-option>
)
})
}
</el-select>
);
},
},
{
prop: "plan_date",
label: "计划评审时间",
sortable: false,
width: 160,
customFn: (row) => {
return (
<el-date-picker
type="money"
placeholder="计划评审时间"
readonly={this.role == 1}
style="width: 100%;"
value-format="yyyy-MM-dd"
v-model={row.plan_date}
size="mini"
clearable={true}
></el-date-picker>
);
},
},
{
prop: "actually_date",
label: "实际评审时间",
sortable: false,
width: 160,
customFn: (row) => {
return (
<el-date-picker
placeholder="实际评审时间"
readonly={this.role == 0}
style="width: 100%;"
value-format="yyyy-MM-dd"
v-model={row.actually_date}
size="mini"
clearable={true}
></el-date-picker>
);
},
},
{
label: "操作",
width: 180,
align: "left",
sortable: false,
customFn: (row, scope) => {
return (
<Poptip
confirm={true}
transfer={true}
placement="bottom"
title="确认要删除吗"
on={{
["on-ok"]: (_) => {
this.form.item_list.splice(scope.$index, 1);
},
}}
>
<Button
style="margin-left: 4px;"
ghost
size="small"
type="error"
>
删除
</Button>
</Poptip>
);
},
},
],
detail: {},
rowName: "",
tempRow: {},
form: {
plan_id: "",
state: 0,
item_list: [],
content_list: [],
attachment_list: [],
// content: "",
// plan_date: "",
// actually_date: "",
},
rules: {
actually_date: [
{
validator: (rule, value, callback) => {
if (this.role == 1) {
value ? callback() : callback(new Error("请选择实际时间"));
} else {
callback();
}
},
message: "请选择实际时间",
},
],
plan_date: [
{
validator: (rule, value, callback) => {
if (this.role == 0) {
value ? callback() : callback(new Error("请选择计划时间"));
} else {
callback();
}
},
message: "请选择计划时间",
},
],
},
departments: [],
moneyWay: [],
budgets: [],
budgetTotal: 0,
budgetSelect: {
department: '',
type: '',
year: '',
page: 1,
page_size: 20,
},
budgetTable: [
{
title: "项目名称",
key: "name",
width: 200,
align: "left",
fixed: "left",
},
{
title: "预算类型",
key: "type",
width: 115,
render: (h, { row }) => {
return h(
"span",
this.moneyWay.find((item) => {
return item.id === row.type;
})?.value || "未知"
);
},
},
{
title: "所属年份",
key: "year",
width: 105,
},
{
title: "相关科室",
key: "plan_department.name",
width: 110,
render: (h, { row }) => {
return h("span", row.plan_department?.name);
},
},
{
title: "年初预算金额(元)",
key: "money",
align: "right",
width: 180,
render: (h, { row }) => {
return h("span", row.money == 0 ? "--" : moneyFormatter(row.money));
},
},
{
title: "调整后预算金额(元)",
key: "update_money",
align: "right",
width: 200,
render: (h, { row }) => {
return h("span", moneyFormatter(row.update_money));
},
},
{
title: "创建信息",
key: "created_at",
width: 180,
formatter: (cell, data, value) => {
return parseTime(new Date(value), "{y}-{m}-{d}");
},
},
{
title: "描述",
minWidth: 300,
key: "content",
align: "left",
},
],
};
},
methods: {
show() {
this.isShow = true;
},
hidden() {
this.isShow = false;
},
init() {
for (let key in this.form) {
if (this.form[key] instanceof Array) {
this.form[key] = [];
} else {
this.form[key] = "";
}
}
this.$refs["dialog"].clearValidate();
},
setId(id) {
if (typeof id == "number") {
this.id = id;
} else {
console.error("error typeof id: " + typeof id);
}
},
getId() {
return this.id;
},
setType(type = "add") {
let types = ["add", "editor"];
if (types.includes(type)) {
this.type = type;
} else {
console.warn("Unknown type: " + type);
}
},
setForm(key = [], value = []) {
if (key instanceof Array) {
key.forEach((key, index) => {
this.form[key] = value[index] ?? "";
});
}
if (typeof key === "string") {
this.form[key] = value;
}
if (!key) {
this.init();
}
},
async getDetail() {
const res = await show({ id: this.pid });
console.log(res.item.find((i) => i.id === this.id));
this.$integrateData(this.form, res);
console.log(this.form)
this.rowName = res.plan?.name;
this.form.item_list = res.item?.map((i) => {
return {
content: i.content || '',
plan_date: i.plan_date || '',
actually_date: i.actually_date || '',
};
});
},
submit() {
if (this.type === "add") {
store(this.form).then((res) => {
this.$message({
type: "success",
message: "新增成功",
});
this.hidden();
this.$emit("refresh");
});
}
if (this.type === "editor") {
save({
id: this.pid,
...this.form,
}).then((res) => {
this.$message({
type: "success",
message: "编辑成功",
});
this.hidden();
this.$emit("refresh");
});
}
// let temp = this.detail.item?.find((i) => i.id === this.id);
// let index = this.detail.item?.indexOf(temp);
// this.detail.item?.splice(index, 1, this.form);
// this.detail.item_list = this.detail.item.map((i) => {
// return {
// content: i.content,
// actually_date: i.actually_date,
// plan_date: i.plan_date,
// };
// });
//
// save(this.detail).then((res) => {
// this.$message({
// type: "success",
// message: "保存成功",
// });
// this.hidden();
// this.$emit("refresh");
// });
},
async getBudgets() {
const res = await getBudget(this.budgetSelect);
this.budgets = res.list.data;
this.budgetTotal = res.list.total;
},
async getMoneyWay() {
const res = await getparameter({
number: "money_way",
});
this.moneyWay = res.detail;
},
getDepartment() {
listdeptNoAuth().then((res) => {
this.departments = res;
});
},
rowPick(row) {
this.form.plan_id = row.id;
this.rowName = row.name;
},
},
watch: {
isShow(val) {
if (val) {
if (this.type === "editor") {
this.getDetail();
}
} else {
this.id = "";
this.type = "";
this.rowName = "";
this.init();
this.$refs["dialog"].clearValidate();
delete this.form.id;
}
},
},
created() {
this.getMoneyWay();
this.getBudgets();
this.getDepartment();
},
};
</script>
<style scoped lang="scss">
::v-deep .el-input__inner {
text-align: left;
}
.xy-table-item-label {
width: 150px;
}
.select {
margin-bottom: 10px;
& > * {
margin-left: 6px;
}
}
</style>