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.

297 lines
8.6 KiB

3 years ago
<template>
<div>
<xy-dialog
3 years ago
:width="74"
3 years ago
ref="dialog"
:is-show.sync="isShow"
type="form"
3 years ago
:title="type === 'add' ? '新增收款单' : '编辑收款单'"
3 years ago
:form="form"
:rules="rules"
@submit="submit">
3 years ago
<template v-slot:account_id >
3 years ago
<div class="xy-table-item">
<div class="xy-table-item-label">
3 years ago
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>付款方
3 years ago
</div>
<div class="xy-table-item-content">
3 years ago
<el-select disabled v-model="form.account_id" placeholder="请选择付款对象" style="width: 300px;">
3 years ago
<el-option v-for="item in accounts" :value="item.id" :label="item.name" :key="item.id"></el-option>
</el-select>
3 years ago
</div>
</div>
</template>
3 years ago
<template v-slot:money>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>金额
</div>
3 years ago
<div class="xy-table-item-content xy-table-item-price">
3 years ago
<el-input-number disabled :controls="false" :precision="2" v-model="form.money" clearable placeholder="请输入金额" style="width: 300px;"></el-input-number>
3 years ago
</div>
</div>
</template>
<template v-slot:invoice_type>
<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-select v-model="form.invoice_type" style="width: 300px" placeholder="请选择发票类型">
<el-option v-for="item in [{label:'无',value:0},{label:'服务类发票',value:1}]" :label="item.label" :value="item.value" :key="item.value"></el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:date >
<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-date-picker
placeholder="请选择收款单日期"
value-format="yyyy-MM-dd"
v-model="form.date"
style="width: 300px;"></el-date-picker>
</div>
</div>
</template>
<template v-slot:status >
<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-select v-model="form.status " style="width: 300px" placeholder="请选择付款状态">
<el-option v-for="item in [{label:'未付款',value:0},{label:'部分付款',value:1},{label:'已付清',value:2}]" :label="item.label" :value="item.value" :key="item.value"></el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:schedule_links >
<div class="xy-table-item">
<div class="xy-table-item-label">
3 years ago
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>结算排班
3 years ago
</div>
<div class="xy-table-item-content">
3 years ago
<template v-if="form.schedule_links.length > 0">
<Button type="primary" style="margin-bottom: 10px;" @click="$refs['scheduleList'].form = form.schedule_links,$refs['scheduleList'].isShow = true">
排班选择
</Button>
<div style="width: 500px">
<xy-table :height="300" :is-page="false" :list="form.schedule_links" :table-item="scheduleTable">
<template v-slot:btns>
<el-table-column width="68" align="center" fixed="right">
<template v-slot:default="scope">
<Button size="small" type="primary" ghost @click="removeSchedule(scope)"></Button>
</template>
</el-table-column>
</template>
</xy-table>
</div>
</template>
<template v-else>
<el-input readonly placeholder="请选择结算排班" style="width: 300px;" @focus="$refs['scheduleList'].form = form.schedule_links,$refs['scheduleList'].isShow = true"></el-input>
</template>
3 years ago
</div>
</div>
</template>
3 years ago
</xy-dialog>
3 years ago
3 years ago
<scheduleList :accounts="accounts" ref="scheduleList" @submit="setSchedule"></scheduleList>
3 years ago
</div>
</template>
<script>
import {save,getForm} from '@/api/collectMoney'
3 years ago
import scheduleList from "@/views/finance/component/scheduleList";
3 years ago
import {parseTime} from "@/utils";
3 years ago
export default {
3 years ago
props:{
accounts:{
type:Array,
default:()=>[]
}
},
3 years ago
components:{
scheduleList
},
3 years ago
data() {
3 years ago
let validatorSchedule = (rule, value, callback) => {
if(value.length > 0){
callback()
}else{
callback(new Error('请选择结算排班'))
}
}
3 years ago
return {
isShow:false,
id:'',
type:'',
form:{
3 years ago
account_id :'',
3 years ago
money:0,
3 years ago
invoice_type:'',
date:'',
status:'',
3 years ago
schedule_links:[],
3 years ago
},
rules:{
3 years ago
account_id:[
{required:true,message:'请选择付款方'}
],
money:[
{required:true,message:'请填写金额'}
],
invoice_type:[
{required:true,message:'请选择发票类型'}
],
date:[
{required:true,message:'请选择收款单日期'}
],
status:[
{required:true,message:'请选择状态'}
],
schedule_links:[
{validator:validatorSchedule}
3 years ago
]
3 years ago
},
scheduleTable:[
{
label:'第三方结算对象',
prop:'orders.account.name',
minWidth: 160,
sortable:false
},
{
label:'护工',
prop:'nurse.name',
width: 160,
sortable:false
},
{
label:'服务日期',
prop:'date',
width: 200,
sortable:false
},
{
label:'时间段',
width: 150,
sortable:false,
customFn:(row)=>{
return (
<div>{parseTime(row.start_time,'{h}:{i}')}~{parseTime(row.end_time,'{h}:{i}')}</div>
)
}
},
{
label:'订单编号',
prop:'orders.no',
width: 220,
sortable:false
},
{
label:'服务对象',
prop:'customer.name',
width: 200,
sortable:false
},
{
label:'服务状态',
prop:'status',
width: 140,
sortable:false,
formatter:(cell,data,value) => {
switch (value){
case 0:
return '已排班未服务'
break;
case 1:
return '已排班未服务'
break;
case 2:
return '已服务'
break;
default:
return value
}
}
}
]
3 years ago
}
},
methods: {
3 years ago
3 years ago
async getDetail(){
const res = await getForm(this.id)
this.$integrateData(this.form,res)
},
3 years ago
setSchedule(array){
this.form.schedule_links = array
3 years ago
this.form.account_id = Number(array[0]?.orders.account_id)
3 years ago
array.forEach(item => {
this.form.money += Number(item.orders.unit_price)
})
3 years ago
},
removeSchedule(scope){
this.form.schedule_links.splice(scope.$index,1)
},
3 years ago
submit(){
3 years ago
this.form.schedule_links = this.form.schedule_links.map(item => {
return {
schedule_id:item.id,
order_id:item.order_id
}
})
3 years ago
if(this.type === 'editor'){
Object.defineProperty(this.form,'id',{
value:this.id,
enumerable:true,
configurable:true,
writable:true
})
}
save(this.form).then(res => {
this.$successMessage(this.type,'')
this.isShow = false
this.$emit('refresh')
})
}
},
watch:{
isShow(val){
if(val){
if(this.type === 'editor'){
this.getDetail()
}
}else{
this.id = ''
this.type = ''
this.$refs['dialog'].reset()
delete this.form.id
}
}
}
}
</script>
<style scoped lang="scss">
::v-deep .el-input__inner{
text-align: left;
}
3 years ago
3 years ago
</style>