master
xy 2 years ago
parent 4580ec963e
commit cab0c77c83

@ -47,3 +47,44 @@ export function getProgress(params){
params
})
}
export function paidIndex (params) {
return request({
method: 'get',
url: '/api/admin/paid-plan/index',
params
})
}
export function paidShow (params) {
return request({
method: 'get',
url: '/api/admin/paid-plan/show',
params
})
}
export function paidStore (data) {
return request({
method: 'post',
url: '/api/admin/paid-plan/store',
data
})
}
export function paidSave (data) {
return request({
method: 'post',
url: '/api/admin/paid-plan/save',
data
})
}
export function paidDestroy (params) {
return request({
method: 'get',
url: '/api/admin/paid-plan/destroy',
params
})
}

@ -59,6 +59,7 @@ export default {
return
}
this.$refs['elForm'].resetFields()
this.$emit('reset')
},
submit(){
if(this.type === 'normal'){

@ -0,0 +1,317 @@
<template>
<div>
<xy-dialog
ref="dialog"
:is-show.sync="isShow"
type="form"
title="付款计划"
:form="form"
@reset="getDetail"
@submit="submit"
>
<template v-slot:plan_id>
<div class="xy-table-item">
<div class="xy-table-item-label">项目 </div>
<div class="xy-table-item-content">
<el-input
readonly
:value="rowName"
clearable
placeholder="请输入项目"
style="width: 300px"
></el-input>
</div>
</div>
</template>
<template #item_list>
<el-button
icon="el-icon-plus"
type="primary"
size="small"
@click="
formList.push({
plan_id: id,
paid_money: 0,
remark: '',
paid_plan_date: '',
})
"
>新增</el-button
>
<xy-table
style="margin-top: 20px"
:height="320"
:table-item="itemTable"
:list="formList"
>
<template #btns> </template>
</xy-table>
</template>
</xy-dialog>
</div>
</template>
<script>
import { paidSave, paidIndex, paidStore, paidDestroy } from "@/api/budget/budget"
export default {
props: {},
data() {
return {
isShow: false,
id: "",
type: "",
itemTable: [
{
prop: "paid_money",
label: "付款金额",
width: 180,
sortable: false,
customFn: (row) => {
return (
<el-input-number
precision={2}
controls={false}
placeholder="付款金额"
style="width: 100%;"
v-model={row.paid_money}
size="small"
clearable={true}
on={{
['change']:e => {
if (row.id) {
this.editId.push(row.id)
}
}
}}
></el-input-number>
);
},
},
{
prop: "paid_plan_date",
label: "年份-月份",
sortable: false,
width: 140,
customFn: (row) => {
return (
<el-date-picker
type="month"
placeholder="年份-月份"
style="width: 100%;"
value-format="yyyy-MM"
v-model={row.paid_plan_date}
size="mini"
clearable={true}
on={{
['change']:e => {
if (row.id) {
this.editId.push(row.id)
}
}
}}
></el-date-picker>
);
},
},
{
prop: "remark",
label: "备注",
sortable: false,
minWidth: 200,
customFn: (row) => {
return (
<el-input
v-model={row.remark}
placeholder="备注"
style="width: 100%;"
size="mini"
clearable={true}
on={{
['change']:e => {
if (row.id) {
this.editId.push(row.id)
}
}
}}
></el-input>
);
},
},
{
label: "操作",
width: 180,
align: "left",
sortable: false,
customFn: (row, scope) => {
return (
<Poptip
confirm={true}
transfer={true}
placement="bottom"
title="确认要删除吗"
on={{
["on-ok"]: (_) => {
if (!row.id) {
this.formList.splice(scope.$index, 1);
} else {
paidDestroy({
id: row.id
}).then(res => {
this.$message({
type: 'success',
message: '删除成功'
})
this.getDetail();
})
}
},
}}
>
<Button
style="margin-left: 4px;"
ghost
size="small"
type="error"
>
删除
</Button>
</Poptip>
);
},
},
],
rowName: "",
formList: [],
editId: [],
form: {
plan_id: "",
item_list: [],
},
};
},
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() {
let res = await paidIndex({
plan_id: this.id
})
this.formList = res.data;
},
submit() {
for(let i = 0;i < this.formList.length;i++) {
if (!this.formList[i]?.paid_plan_date || !this.formList[i]?.paid_money) {
this.$message({
type: 'warning',
message: `${i+1}条金额或日期未填写`
})
return
}
}
let editIds = Array.from(new Set(this.editId))
let promiseAll = [];
editIds.forEach(id => {
promiseAll.push(paidSave(this.formList.find(i => i.id === id)))
})
for (let i = 0;i < this.formList.length;i++) {
if (!this.formList[i].id) {
promiseAll.push(paidStore(this.formList[i]))
}
}
if (promiseAll.length > 0) {
Promise.all(promiseAll).then(res => {
this.$message({
type: 'success',
message: '保存成功'
})
this.hidden();
})
}
},
},
watch: {
isShow(val) {
if (val) {
this.getDetail();
} else {
this.id = "";
this.type = "";
this.rowName = "";
this.init();
this.formList = [];
this.editId = [];
this.$refs["dialog"].clearValidate();
delete this.form.id;
}
},
},
created() {},
};
</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>

@ -31,7 +31,7 @@
<Button type="primary" style="margin-left: 10px" @click="getBudgets"></Button>
<Button type="primary" style="margin-left: 10px"
@click="()=>select={page:1,year:'', type:'', department:''}">重置</Button>
<Button class="slot-btns-item" size="small" type="primary" @click="">
<Button style="margin-left: 10px" type="primary" @click="">
资金申请
</Button>
</div>
@ -41,13 +41,19 @@
<xy-table ref="xyTable" :objectSpanMethod="objectSpanMethod" :table-item="table" :list="list" :show-summary="true"
:summary-method="summary">
<template v-slot:btns>
<div></div>
<el-table-column header-align="center" align="left" :width="130" label="操作" >
<template #default="{ row }">
<Button size="small" type="primary" @click="$refs['payPlan'].rowName = row.name,$refs['payPlan'].setId(row.id),$refs['payPlan'].show();">付款计划</Button>
</template>
</el-table-column>
</template>
</xy-table>
<div style="display: flex;justify-content: flex-end;">
<Page :total="total" show-elevator @on-change="pageChange" show-sizer @on-page-size-change="pageSizeChange" />
</div>
<payPlan ref="payPlan"></payPlan>
</div>
</template>
@ -68,8 +74,13 @@
} from "@/utils"
import {
mergeTableRow
} from "@/utils/mergeTableRow"
} from "@/utils/mergeTableRow";
import payPlan from './component/payPlan.vue'
export default {
components: {
payPlan
},
data() {
return {
isShowAdd: false,

@ -97,7 +97,7 @@
</template>
</xy-dialog>
<Modal title="项目" v-model="isShowModal" footer-hide :width="50">
<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"
@ -133,17 +133,18 @@
</Option>
</Select>
<Button style="float: right;" type="primary" @click="budgetSelect.page=1,getBudgets"
<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="rowPick"
@on-row-click="row => tempRow = row"
></Table>
<div style="padding: 10px 0; display: flex; justify-content: center">
@ -273,6 +274,7 @@ export default {
],
detail: {},
rowName: "",
tempRow: {},
form: {
plan_id: "",
state: 0,

Loading…
Cancel
Save