刘翔宇-旅管家 4 years ago
parent ddae7601e6
commit 9ff778ee0a

@ -1,14 +1,16 @@
<template> <template>
<div> <div>
<!-- 编辑--> <!-- 编辑-->
<xy-dialog :is-show.sync="isShowEditor" title="合同编辑" type="form" :form="detail" :rules="rules" @submit="editor" ref="addContract"> <xy-dialog :is-show.sync="isShowEditor" title="合同编辑" type="form" :form="detail" :rules="rules" @submit="editor"
ref="addContract">
<template v-slot:name> <template v-slot:name>
<div class="xy-table-item"> <div class="xy-table-item">
<div class="xy-table-item-label"> <div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>项目名称 <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>项目名称
</div> </div>
<div class="xy-table-item-content"> <div class="xy-table-item-content">
<el-input clearable placeholder="请填写项目名称" v-model="detail.name" style="width: 300px;"/> <el-input clearable placeholder="请填写项目名称" v-model="detail.name" style="width: 300px;" />
</div> </div>
</div> </div>
</template> </template>
@ -19,7 +21,8 @@
</div> </div>
<div class="xy-table-item-content"> <div class="xy-table-item-content">
<el-select clearable placeholder="请选择项目类型" v-model="detail.type" style="width: 300px;"> <el-select clearable placeholder="请选择项目类型" v-model="detail.type" style="width: 300px;">
<el-option v-for="item in [{label:'服务',value:1},{label:'货物',value:2},{label:'工程',value:3}]" :label="item.label" :value="item.value"></el-option> <el-option v-for="item in [{label:'',value:1},{label:'',value:2},{label:'',value:3}]"
:label="item.label" :value="item.value"></el-option>
</el-select> </el-select>
</div> </div>
</div> </div>
@ -48,13 +51,14 @@
</div> </div>
</div> </div>
</template> </template>
<template v-slot:price> <template v-slot:price>
<div class="xy-table-item"> <div class="xy-table-item">
<div class="xy-table-item-label"> <div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>合同预算价 <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>合同预算价
</div> </div>
<div class="xy-table-item-content xy-table-item-price"> <div class="xy-table-item-content xy-table-item-price">
<el-input clearable placeholder="请填写合同预算价" v-model="detail.price" style="width: 300px;"/> <el-input clearable placeholder="请填写合同预算价" v-model="detail.price" style="width: 300px;" />
</div> </div>
</div> </div>
</template> </template>
@ -76,7 +80,7 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>是否为预算内确定项目 <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>是否为预算内确定项目
</div> </div>
<div class="xy-table-item-content"> <div class="xy-table-item-content">
<el-switch v-model="detail.isBudget"/> <el-switch v-model="detail.isBudget" />
</div> </div>
</div> </div>
</template> </template>
@ -99,25 +103,78 @@
</div> </div>
</div> </div>
</template> </template>
<template v-slot:req_status v-if="adminEdit">
<div class="xy-table-item">
<div class="xy-table-item-label" style="width: 200px">请示流程
</div>
<div class="xy-table-item-content">
<el-select v-model="detail.req_status" placeholder="请选择">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:purchase_status v-if="adminEdit">
<div class="xy-table-item">
<div class="xy-table-item-label" style="width: 200px">采购流程
</div>
<div class="xy-table-item-content">
<el-select v-model="detail.purchase_status" placeholder="请选择">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:invite_status v-if="adminEdit">
<div class="xy-table-item">
<div class="xy-table-item-label" style="width: 200px">招标流程
</div>
<div class="xy-table-item-content">
<el-select v-model="detail.invite_status" placeholder="请选择">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:join_status v-if="adminEdit">
<div class="xy-table-item">
<div class="xy-table-item-label" style="width: 200px">
合同会签流程
</div>
<div class="xy-table-item-content">
<el-select v-model="detail.join_status" placeholder="请选择">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
</div>
</template>
</xy-dialog> </xy-dialog>
<!-- 编辑中 预算计划 --> <!-- 编辑中 预算计划 -->
<xy-dialog :is-show.sync="isShowPlan" title="预算计划" :width="640" @on-ok="planSelect"> <xy-dialog :is-show.sync="isShowPlan" title="预算计划" :width="640" @on-ok="planSelect">
<template v-slot:normalContent> <template v-slot:normalContent>
<Input v-model="planSearch" search enter-button=" " placeholder="搜索预算计划.." @on-search="getBudgets"/> <Input v-model="planSearch" search enter-button=" " placeholder="搜索预算计划.." @on-search="getBudgets" />
<xy-table :list="plans" :show-index="false" :table-item="planTable" :height="310" style="margin-top: 10px;" ref="editorPlanTable" @select="selectPlan"> <xy-table :list="plans" :show-index="false" :table-item="planTable" :height="310" style="margin-top: 10px;"
ref="editorPlanTable" @select="selectPlan">
<template v-slot:btns> <template v-slot:btns>
<el-table-column label="使用金额" header-align="center"> <el-table-column label="使用金额" header-align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<Input :value="scope.row.useMoney" @input="planInput($event,scope.row)"/> <Input :value="scope.row.useMoney" @input="planInput($event,scope.row)" />
</template> </template>
</el-table-column> </el-table-column>
</template> </template>
</xy-table> </xy-table>
<div style="display: flex;justify-content: flex-end;"> <div style="display: flex;justify-content: flex-end;">
<Page :total="planTotal" show-elevator @on-change="planPageChange"/> <Page :total="planTotal" show-elevator @on-change="planPageChange" />
</div> </div>
</template> </template>
@ -129,70 +186,103 @@
</template> </template>
<script> <script>
import {editorContract,detailContract} from "@/api/contract/contract"; import {
import {getBudget} from "@/api/budget/budget"; editorContract,
import {Message} from 'element-ui' detailContract
export default { } from "@/api/contract/contract";
props:{ import {
purchaseType:Array, getBudget
moneyWay:Array, } from "@/api/budget/budget";
purchaseWay:Array
import {
getInfo
} from '@/api/user.js'
import {
Message
} from 'element-ui'
export default {
props: {
purchaseType: Array,
moneyWay: Array,
purchaseWay: Array
}, },
data() { data() {
var planPass = (rule, value, callback) => { var planPass = (rule, value, callback) => {
if(this.detail.isBudget){ if (this.detail.isBudget) {
if(this.detail.plan.length === 0){ if (this.detail.plan.length === 0) {
return callback(new Error('必选')) return callback(new Error('必选'))
}else{ } else {
callback() callback()
} }
}else{ } else {
callback() callback()
} }
} }
return { return {
isFocus:false, userList: ["liuxiangyu", "zhushulan","admin"],
contrantId:'', user: null,
isShowEditor:false, adminEdit: false,
isShowPlan:false, isFocus: false,
detail:{}, contrantId: '',
plan:[], isShowEditor: false,
rules:{ isShowPlan: false,
name:[ detail: {},
{required:true,message:"必填"} plan: [],
], options: [{
type:[ value: 1,
{required:true,message:"必选"} label: '待申请'
], }, {
methods:[ value: 2,
{required:true,message:"必选"} label: '流转中'
], }, {
modality:[ value: 3,
{required:true,message:"必选"} label: '已办结'
], }],
price:[ rules: {
{required:true,message:"必填"}, name: [{
{pattern:/^\d+(\.\d+)?$/, message: '必须为数字'} required: true,
], message: "必填"
fundingChannels:[ }],
{required:true,message:"必填"} type: [{
], required: true,
plan:[ message: "必选"
{validator:planPass} }],
] methods: [{
required: true,
message: "必选"
}],
modality: [{
required: true,
message: "必选"
}],
price: [{
required: true,
message: "必填"
}, },
plans:[],
planSearch:'',
planTable:[
{ {
sortable:false, pattern: /^\d+(\.\d+)?$/,
width:36, message: '必须为数字'
type:"selection" }
],
fundingChannels: [{
required: true,
message: "必填"
}],
plan: [{
validator: planPass
}]
},
plans: [],
planSearch: '',
planTable: [{
sortable: false,
width: 36,
type: "selection"
}, },
{ {
label:"分类", label: "分类",
prop:'type', prop: 'type',
formatter:(cell, data, value) => { formatter: (cell, data, value) => {
let res = this.moneyWay.filter(item => { let res = this.moneyWay.filter(item => {
return item.id === value return item.id === value
}) })
@ -200,61 +290,61 @@ export default {
} }
}, },
{ {
label:"名称", label: "名称",
prop:'name', prop: 'name',
align:'left' align: 'left'
}, },
{ {
label:"计划金额", label: "计划金额",
prop:'money', prop: 'money',
align:'right' align: 'right'
} }
], ],
planTotal:0, planTotal: 0,
} }
}, },
methods: { methods: {
// //
planInput(e,row){ planInput(e, row) {
if(!/^[0-9]+.?[0-9]*$/.test(e) && e){ if (!/^[0-9]+.?[0-9]*$/.test(e) && e) {
Message({ Message({
type:'warning', type: 'warning',
message:'金额格式错误' message: '金额格式错误'
}) })
row.useMoney = 0 row.useMoney = 0
return return
} }
if(e <= (Number(row.money) - Number(row.use_money_total))){ if (e <= (Number(row.money) - Number(row.use_money_total))) {
row.useMoney = e row.useMoney = e
this.plan.forEach(item => { this.plan.forEach(item => {
if(item.value.plan_id == row.id){ if (item.value.plan_id == row.id) {
item.value.use_money = e item.value.use_money = e
} }
}) })
return return
} }
Message({ Message({
type:'warning', type: 'warning',
message:'使用金额大于剩余预算' message: '使用金额大于剩余预算'
}) })
row.useMoney = 0 row.useMoney = 0
}, },
// //
planSelect(){ planSelect() {
if(this.plan.length === 0){ if (this.plan.length === 0) {
Message({ Message({
type:'warning', type: 'warning',
message:'选择计划不能为空' message: '选择计划不能为空'
}) })
return return
} }
for(let item of this.plan){ for (let item of this.plan) {
console.log(item) console.log(item)
if(!item.value.use_money){ if (!item.value.use_money) {
Message({ Message({
type:'warning', type: 'warning',
message:'金额不能为空' message: '金额不能为空'
}) })
return return
} }
@ -263,32 +353,36 @@ export default {
this.isShowPlan = false this.isShowPlan = false
}, },
// //
selectPlan(sel,row){ selectPlan(sel, row) {
if(sel){ if (sel) {
this.plan = sel.map(item => { this.plan = sel.map(item => {
return { return {
label:item.name, label: item.name,
value:{ value: {
plan_id:item.id, plan_id: item.id,
use_money:item.useMoney, use_money: item.useMoney,
new_money:item.money new_money: item.money
} }
} }
}) })
}else{ } else {
this.plan = [] this.plan = []
} }
}, },
delPlan(val){ delPlan(val) {
this.detail.plan.map((item,index)=>{ this.detail.plan.map((item, index) => {
if(item.value.plan_id === val.value.plan_id){ if (item.value.plan_id === val.value.plan_id) {
this.detail.plan.splice(index,1) this.detail.plan.splice(index, 1)
} }
}) })
}, },
// //
async getBudgets(){ async getBudgets() {
let res = await getBudget({name:this.planSearch,page_size:10,page:this.plansPageIndex}) let res = await getBudget({
name: this.planSearch,
page_size: 10,
page: this.plansPageIndex
})
this.plans = res.list.data this.plans = res.list.data
this.planTotal = res.list.total this.planTotal = res.list.total
@ -296,7 +390,7 @@ export default {
return item.value.plan_id return item.value.plan_id
})) }))
}, },
planPageChange(e){ planPageChange(e) {
this.plansPageIndex = e this.plansPageIndex = e
this.getBudgets() this.getBudgets()
}, },
@ -304,7 +398,7 @@ export default {
toggleSelection(plans) { toggleSelection(plans) {
if (plans) { if (plans) {
this.plans.filter(plan => { this.plans.filter(plan => {
if(plans.includes(plan.id)){ if (plans.includes(plan.id)) {
plan.useMoney = this.detail.plan[plans.indexOf(plan.id)].value.use_money plan.useMoney = this.detail.plan[plans.indexOf(plan.id)].value.use_money
return true return true
} }
@ -315,67 +409,89 @@ export default {
this.$refs.editorPlanTable.clearSelection() this.$refs.editorPlanTable.clearSelection()
} }
}, },
async getDetail(id){ async getDetail(id) {
let res = await detailContract({id:id}) let res = await detailContract({
id: id
})
this.contrantId = res.id this.contrantId = res.id
this.detail = { this.detail = {
name:res.name, req_status: res.req_status,
type:res.type, purchase_status: res.purchase_status,
methods:res.purchase_type_id, join_status: res.join_status,
modality:res.purchase_way_id, invite_status: res.invite_status,
fundingChannels:res.money_way_id.split(',').map(item =>{return Number(item)}), name: res.name,
price:res.plan_price, type: res.type,
isBudget:res.is_plan === 1 ? true : false, methods: res.purchase_type_id,
plan:res.plans.map(item=>{ modality: res.purchase_way_id,
fundingChannels: res.money_way_id.split(',').map(item => {
return Number(item)
}),
price: res.plan_price,
isBudget: res.is_plan === 1 ? true : false,
plan: res.plans.map(item => {
return { return {
label:item.name, label: item.name,
value:{ value: {
plan_id:item.id, plan_id: item.id,
use_money:res.plan_link.filter(item1 => { use_money: res.plan_link.filter(item1 => {
return item1.plan_id === item.id return item1.plan_id === item.id
})[0].use_money, })[0].use_money,
new_money:item.money new_money: item.money
} }
} }
}) })
} }
this.plan = this.detail.plan this.plan = this.detail.plan
}, },
editor(){ editor() {
editorContract({ editorContract({
id:this.contrantId, id: this.contrantId,
type:this.detail.type, type: this.detail.type,
is_plan:this.detail.isBudget ? 1 : 0, is_plan: this.detail.isBudget ? 1 : 0,
purchase_type_id:this.detail.methods, purchase_type_id: this.detail.methods,
purchase_way_id:this.detail.modality, purchase_way_id: this.detail.modality,
money_way_id:this.detail.fundingChannels.toString(), money_way_id: this.detail.fundingChannels.toString(),
plan_price:this.detail.price, plan_price: this.detail.price,
name:this.detail.name, name: this.detail.name,
contract_plan_links:this.detail.plan.map(item=>{ req_status: this.detail.req_status,
purchase_status: this.detail.purchase_status,
join_status: this.detail.join_status,
invite_status: this.detail.invite_status,
contract_plan_links: this.detail.plan.map(item => {
return item.value return item.value
}) })
}).then(res=>{ }).then(res => {
this.isShowEditor = false this.isShowEditor = false
Message({ Message({
type:'success', type: 'success',
message:"操作成功" message: "操作成功"
}) })
this.$emit('success') this.$emit('success')
}) })
}, },
}, },
computed:{ computed: {
}, },
mounted() { mounted() {
let that = this;
getInfo().then(response => {
console.log(response)
this.user = response;
}, if (that.userList.indexOf(response.username) != -1) {
}
that.adminEdit = true;
}
}).catch(error => {})
}
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.contract-add-plan{ .contract-add-plan {
min-height: 30px; min-height: 30px;
border: 1px solid #dcdee2; border: 1px solid #dcdee2;
border-radius: 4px; border-radius: 4px;
@ -385,43 +501,50 @@ export default {
align-content: center; align-content: center;
padding: 0 8px; padding: 0 8px;
&-no-plan{
&-no-plan {
height: 30px; height: 30px;
line-height: 30px; line-height: 30px;
color: #CDD0D5; color: #CDD0D5;
} }
} }
.xy-table-item-label{ .xy-table-item-label {
width: 140px; width: 140px;
} }
.xy-table-item-price{
.xy-table-item-price {
position: relative; position: relative;
&::after{
&::after {
z-index: 1; z-index: 1;
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
content:'(元)' content: '(元)'
} }
::v-deep .el-input__clear{
::v-deep .el-input__clear {
position: relative; position: relative;
right: 30px; right: 30px;
z-index: 2; z-index: 2;
} }
} }
.xy-table-item-price-wan{
.xy-table-item-price-wan {
position: relative; position: relative;
&::after{
&::after {
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
content:'(万元)' content: '(万元)'
} }
::v-deep .el-input__clear{
::v-deep .el-input__clear {
position: relative; position: relative;
right: 46px; right: 46px;
z-index: 2; z-index: 2;
} }
} }
</style> </style>

@ -384,7 +384,7 @@ export default {
table: [ table: [
{ {
label: "项目名称", label: "项目名称",
width: 150, width: 380,
prop: 'name', prop: 'name',
fixed: 'left', fixed: 'left',
align: 'left' align: 'left'

Loading…
Cancel
Save