master
271556543@qq.com 4 years ago
parent 6022c6161d
commit 29a0f3bbe5

@ -61,6 +61,23 @@ export default {
showChange(e){
this.$emit('update:isShow',e)
},
validate(){
return new Promise((resolve,reject)=>{
this.$refs['elForm'].validate().then(res=>{
if(res){
resolve(res)
}else{
reject(res)
}
}).catch(err=>{
reject(err)
this.$Message.warning({
content:'请填写完整信息',
duration:1
})
})
})
},
reset(){
this.$emit('reset')
if(this.type === 'normal'){
@ -116,14 +133,16 @@ export default {
default(){
if(type === "form"){
let formItems = []
Object.keys(form).map((key)=>{
formItems.push(
<el-form-item
prop={key}>
{eval(`{$scopedSlots.${key} ? $scopedSlots.${key}() : ''}`)}
</el-form-item>
)
})
for(let key in form){
if(form.hasOwnProperty(key) && $scopedSlots[key]){
formItems.push(
<el-form-item
prop={key}>
{eval(`{$scopedSlots.${key} ? $scopedSlots.${key}() : ''}`)}
</el-form-item>
)
}
}
return (
<el-form
style={title.length === 0 ? {'margin-top':'32px'} : {}}
@ -163,6 +182,11 @@ export default {
)
}
},
header(){
if($scopedSlots.headerContent){
return $scopedSlots.headerContent()
}
},
footer(){
{
if(type === 'form' || type === 'normal') return ($scopedSlots.footerContent ? $scopedSlots.footerContent() : footerRender())

@ -110,7 +110,7 @@ export default {
var lxHeader_height = 96.5; //
var paginationHeight = 37; //
var topHeight = 50; //
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20 - 25;
that.tableHeight = tableHeight;
},
deleteClick(row) {
@ -133,13 +133,7 @@ export default {
if (this.isPage)
return (
<div>
<Icon
color='#fff'
class={this.isShowPage ? 'xy-table-page__close icon-recover' : 'xy-table-page__close icon-scale-left'}
type='ios-arrow-down'
size={22}
on={{['click']: () => this.isShowPage = !this.isShowPage}}>
</Icon>
<transition
enter-active-class="slide-in-bottom"
leave-to-class="slide-out-down">
@ -380,6 +374,9 @@ export default {
<style lang="scss" scoped>
@import "../../styles/variables.scss";
::v-deep .el-table{
margin-bottom: 0!important;
}
.xy-table-page {
display: flex;
justify-content: right;
@ -389,8 +386,8 @@ export default {
z-index: 10;
padding: 6px 10px !important;
position: absolute;
bottom: 0;
position: relative;
top: 0;
left: 0;
right: 0;

@ -1,8 +1,26 @@
<template>
<div>
<xy-dialog ref="dialog" :form="form" :is-show.sync="isShow" :rules="rules" :title="type === 'add' ? '新增用户' : '编辑用户'"
:width="74" type="form"
@submit="submit">
<xy-dialog ref="dialog" :form="flag === 1 ? form : form1" :is-show.sync="isShow" :rules="flag === 1 ? rules : rules1" title="编辑客户"
:width="74" type="form">
<template v-if="type === 'add'" v-slot:headerContent>
<el-steps :active="flag" simple style="width: 72%;margin: auto;">
<el-step title="客户录入" icon="el-icon-user-solid"></el-step>
<el-step title="订单录入" icon="el-icon-document-add"></el-step>
</el-steps>
</template>
<template v-slot:footerContent>
<Button @click="$refs['dialog'].reset()"></Button>
<template v-if="flag === 1">
<Button type="primary" @click="submit">{{type === 'add' ? ',退' : ''}}</Button>
<template v-if="type === 'add'">
<Button type="primary" @click="submit1">,</Button>
</template>
</template>
<template v-else>
<Button type="primary" @click="submitOrder"></Button>
</template>
</template>
<template v-slot:name>
<div class="xy-table-item">
<div class="xy-table-item-label">
@ -97,53 +115,6 @@
</div>
<div class="xy-table-item-content">
<div v-if="form.customer_address_list.length > 0" class="xy-table-item-content-address">
<!-- <el-table :stripe="true" :data="form.customer_address_list" :height="260" size="mini" :highlight-current-row="true">-->
<!-- <el-table-column type="index" width="40">-->
<!-- </el-table-column>-->
<!-- <el-table-column label="是否默认" width="120" align="center">-->
<!-- <template v-slot:default="scope">-->
<!-- <el-radio-->
<!-- :value="scope.row.default"-->
<!-- :label="1"-->
<!-- @change="radioPick($event,scope)">默认地址-->
<!-- </el-radio>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="名称" width="140" align="center">-->
<!-- <template v-slot:default="scope">-->
<!-- <el-input v-model="scope.row.name" placeholder="名称"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="区域" width="200" align="center">-->
<!-- <template v-slot:default="scope">-->
<!-- <el-cascader-->
<!-- placeholder="区域选择"-->
<!-- :options="cities"-->
<!-- :props="{-->
<!-- label:'value',-->
<!-- value:'id',-->
<!-- lazy:true,-->
<!-- lazyLoad:loadLeaf-->
<!-- }">-->
<!-- </el-cascader>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="地址" min-width="200" align="center">-->
<!-- <template v-slot:default="scope">-->
<!-- <el-input v-model="scope.row.address"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="备注" min-width="200" align="center">-->
<!-- <template v-slot:default="scope">-->
<!-- <el-input v-model="scope.row.remark" type="textarea" :autosize="{minRows:2}" placeholder="备注"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="操作" width="70" fixed="right" align="center">-->
<!-- <template v-slot:default="scope">-->
<!-- <Button ghost type="primary" size="small">删除</Button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </el-table>-->
<xy-table :height="200" :is-page="false" :list="form.customer_address_list" :table-item="addressTable">
<template v-slot:btns>
<el-table-column align="center" fixed="right" header-align="center" label="操作" width="80">
@ -218,6 +189,129 @@
</div>
</div>
</template>
<!-- 订单-->
<template v-slot:product_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-select
:value="pickedProduct.name"
v-load-more="productLoad"
placeholder="请选择产品"
style="width: 300px"
@change="productPick">
<el-option
v-for="item in products"
value-key="id"
:key="item.id"
:label="item.name"
:value="item"></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
range-separator="~"
v-model="form1.date"
end-placeholder="结束时间"
start-placeholder="开始时间"
style="width: 300px;"
type="daterange"
:picker-options="pickerOptions"
value-format="yyyy-MM-dd"></el-date-picker>
</div>
</div>
</template>
<template v-slot:service_times>
<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-number v-model="form1.service_times" :controls="false" :precision="0"
placeholder="请输入服务次数" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:unit_price>
<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 xy-table-item-price">
<el-input-number v-model="form1.unit_price" :controls="false" :precision="2"
placeholder="请输入单次单价" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:total_time>
<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 xy-table-item-min">
<el-input v-model="form1.total_time"
placeholder="请输入总计时长" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:total_money>
<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 xy-table-item-price">
<el-input-number :precision="2" :controls="false" v-model="form1.total_money"
placeholder="请输入总计金额" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:account_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-select
v-model="form1.account_id"
placeholder="请选择结算对象"
style="width: 300px">
<el-option v-for="item in accounts" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</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">
<div style="width: 300px;display: flex;">
<el-radio v-model="form1.status" :label="0"></el-radio>
<el-radio v-model="form1.status" :label="1"></el-radio>
<el-radio v-model="form1.status" :label="2"></el-radio>
</div>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
@ -225,6 +319,8 @@
<script>
import {getparameter} from '@/api/system/dictionary'
import {save, getInfo} from '@/api/customer'
import {save as orderSave} from '@/api/order'
import {getList as productList} from "@/api/product";
export default {
props: {
@ -235,6 +331,10 @@ export default {
cities:{
type: Array,
default: () => []
},
accounts:{
type: Array,
default: () => []
}
},
data() {
@ -250,6 +350,7 @@ export default {
}
}
return {
flag:1,//step
id: '',
type: '',
isShow: false,
@ -397,7 +498,7 @@ export default {
{required: true, message: '请选择失能等级'},
]
},
map: {},
map: [],
option: {
column: [
{
@ -411,24 +512,124 @@ export default {
// dragEnable: false,
}
}]
}
},
//
products: [],
pickedProduct:{},
productSelect: {
page: 1,
page_size: 10
},
pickerOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
},{
text: '最近一年',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 365);
picker.$emit('pick', [start, end]);
}
}]
},
form1: {
product_id: '',
date: '',
service_times: '',
unit_price: '',
total_time: '',
total_money: '',
account_id:'',
status: 0,
customer_id: '',
product_type_id:'',
},
rules1: {
customer_id:[
{required: true, message: '请选择客户'}
],
product_id:[
{required: true, message: '请选择产品'}
],
date:[
{required: true, message: '请选择开始结束时间'}
],
service_times:[
{required: true, message: '请填写服务次数'}
],
unit_price:[
{required: true, message: '请填写单次单价'}
],
total_time:[
{required: true, message: '请填写总计时长'}
],
total_money:[
{required: true, message: '请填写总计金额'}
],
status:[
{required: true, message: '请选择状态'}
],
account_id:[
{required: true, message: '请选择结算对象'}
]
},
}
},
methods: {
// async loadLeaf(node, resolve){
// if(node?.root){
// return
// }
// const res = await getparameter({number:node.data.remark},false)
// console.log(res)
// resolve(res.detail)
// },
// radioPick(e,scope){
// this.form.customer_address_list.map((item, index) => {
// index === scope.$index ? item.default = 1 : item.default = 0
// })
// },
init(){
this.form = {
name: '',
phone: '',
idcard: '',
contact_name: '',
contact_phone: '',
idcard_address: '',
area:'',
customer_address_list: [],
sex: '',
birthday: '',
remark: '',
level_id: '',
}
this.form1 = {
product_id: '',
date: '',
service_times: '',
unit_price: '',
total_time: '',
total_money: '',
account_id:'',
status: 0,
customer_id: '',
product_type_id:'',
}
},
areaPick(e){
console.log(e)
},
@ -446,40 +647,136 @@ export default {
},
submit() {
Object.defineProperty(this.form,'city_id',{
value:this.form.area[0] || '',
enumerable: true,
writable: true,
configurable: true
})
Object.defineProperty(this.form,'area_id',{
value:this.form.area[1] || '',
enumerable: true,
writable: true,
configurable: true
})
Object.defineProperty(this.form,'street_id',{
value:this.form.area[2] || '',
enumerable: true,
writable: true,
configurable: true
})
this.$refs['dialog'].validate().then(res => {
Object.defineProperty(this.form,'city_id',{
value:this.form.area[0] || '',
enumerable: true,
writable: true,
configurable: true
})
Object.defineProperty(this.form,'area_id',{
value:this.form.area[1] || '',
enumerable: true,
writable: true,
configurable: true
})
Object.defineProperty(this.form,'street_id',{
value:this.form.area[2] || '',
enumerable: true,
writable: true,
configurable: true
})
if (this.type === 'editor') {
Object.defineProperty(this.form, 'id', {
value: this.id,
if (this.type === 'editor') {
Object.defineProperty(this.form, 'id', {
value: this.id,
enumerable: true,
writable: true,
configurable: true
})
}
console.log(this.form)
save(this.form).then(res => {
this.$successMessage(this.type, '客户')
this.isShow = false
this.$emit('refresh')
})
})
},
submit1(){
this.$refs['dialog'].validate().then(res => {
Object.defineProperty(this.form,'city_id',{
value:this.form.area[0] || '',
enumerable: true,
writable: true,
configurable: true
})
Object.defineProperty(this.form,'area_id',{
value:this.form.area[1] || '',
enumerable: true,
writable: true,
configurable: true
})
Object.defineProperty(this.form,'street_id',{
value:this.form.area[2] || '',
enumerable: true,
writable: true,
configurable: true
})
if (this.type === 'editor') {
Object.defineProperty(this.form, 'id', {
value: this.id,
enumerable: true,
writable: true,
configurable: true
})
}
console.log(this.form)
save(this.form).then(res => {
this.$successMessage(this.type, '客户')
this.flag = 2
this.form1.customer_id = res.id
})
})
},
//
productPick(e){
this.pickedProduct = e
this.form1.product_id = e.id
this.form1.product_type_id = e.product_type_id
console.log(e)
},
productLoad() {
this.productSelect.page++
this.getProducts()
},
async getProducts() {
const res = await productList(this.productSelect, false)
if (res.data.length === 0) {
this.productSelect.page--
this.$message({
type: 'warning',
message: '没有跟多产品了'
})
return
}
console.log(this.form)
save(this.form).then(res => {
this.$successMessage(this.type, '客户')
this.isShow = false
this.$emit('refresh')
this.products.push(...res.data)
},
submitOrder(){
this.$refs['dialog'].validate().then(res => {
console.log(this.form1)
Object.defineProperty(this.form1,'start_date',{
value:this.form1.date[0],
enumerable:true,
writable:true,
configurable:true
})
Object.defineProperty(this.form1,'end_date',{
value:this.form1.date[1],
enumerable:true,
writable:true,
configurable:true
})
delete this.form1.date
if(this.type === 'editor'){
Object.defineProperty(this.form,'id',{
value:this.id,
enumerable:true,
writable:true,
configurable:true
})
}
orderSave(this.form1).then(res => {
this.$successMessage(this.type,'订单')
this.isShow = false
this.$emit('refresh')
})
})
}
},
},
watch: {
isShow(val) {
@ -490,9 +787,9 @@ export default {
} else {
this.id = ''
this.type = ''
this.map = {}
this.$refs['dialog'].reset()
delete this.form.id
this.map = []
this.flag = 1
this.init()
}
},
map(val) {
@ -506,6 +803,9 @@ export default {
comment: ''
})
}
},
mounted() {
this.getProducts()
}
}
</script>
@ -611,4 +911,19 @@ export default {
}
}
}
::v-deep .el-step__title{
font-size: 15px !important;
}
::v-deep .el-steps--simple{
background: transparent !important;
}
.xy-table-item-label {
width: 160px;
}
::v-deep .el-input__inner {
text-align: left;
}
</style>

@ -0,0 +1,369 @@
<template>
<div>
<xy-dialog
ref="dialog"
:form="form"
:is-show.sync="isShow"
:rules="rules"
title="新增订单"
type="form"
@submit="submit">
<template v-slot:product_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-select
:value="pickedProduct.name"
v-load-more="productLoad"
placeholder="请选择产品"
style="width: 300px"
@change="productPick">
<el-option
v-for="item in products"
value-key="id"
:key="item.id"
:label="item.name"
:value="item"></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
v-model="form.date"
end-placeholder="结束时间"
start-placeholder="开始时间"
style="width: 300px;"
range-separator="~"
type="daterange"
:picker-options="pickerOptions"
value-format="yyyy-MM-dd"
@change="datePick"></el-date-picker>
</div>
</div>
</template>
<template v-slot:service_times>
<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-number v-model="form.service_times" :controls="false" :precision="0"
placeholder="请输入服务次数" style="width: 300px;" @blur="totalComputed"/>
</div>
</div>
</template>
<template v-slot:unit_price>
<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 xy-table-item-price">
<el-input-number v-model="form.unit_price" :controls="false" :precision="2"
placeholder="请输入单次单价" style="width: 300px;" @blur="totalComputed"/>
</div>
</div>
</template>
<template v-slot:total_time>
<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 xy-table-item-min">
<el-input v-model="form.total_time"
placeholder="请输入总计时长" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:total_money>
<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 xy-table-item-price">
<el-input-number :precision="2" :controls="false" v-model="form.total_money"
placeholder="请输入总计金额" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:account_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-select
v-model="form.account_id"
v-load-more="productLoad"
placeholder="请选择结算对象"
style="width: 300px">
<el-option v-for="item in accounts" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</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">
<div style="width: 300px;display: flex;">
<el-radio v-model="form.status" :label="0"></el-radio>
<el-radio v-model="form.status" :label="1"></el-radio>
<el-radio v-model="form.status" :label="2"></el-radio>
</div>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {getList as productList} from '@/api/product'
import {save} from '@/api/order'
import moment from "moment";
export default {
props:{
accounts:{
type:Array,
default:()=>[]
}
},
data() {
return {
id: '',
type: '',
isShow: false,
pickerOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
},{
text: '最近一年',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 365);
picker.$emit('pick', [start, end]);
}
}]
},
products: [],
productSelect: {
page: 1,
page_size: 10
},
pickedProduct:{},
form: {
product_id: '',
date: '',
service_times: '',
unit_price: '',
total_time: '',
total_money: '',
account_id:'',
status: 0,
customer_id: '',
product_type_id:'',
},
rules: {
customer_id:[
{required: true, message: '请选择客户'}
],
product_id:[
{required: true, message: '请选择产品'}
],
date:[
{required: true, message: '请选择开始结束时间'}
],
service_times:[
{required: true, message: '请填写服务次数'}
],
unit_price:[
{required: true, message: '请填写单次单价'}
],
total_time:[
{required: true, message: '请填写总计时长'}
],
total_money:[
{required: true, message: '请填写总计金额'}
],
status:[
{required: true, message: '请选择状态'}
],
account_id:[
{required: true, message: '请选择结算对象'}
]
}
}
},
methods: {
initForm(){
this.form = {
product_id: '',
date: '',
service_times: '',
unit_price: '',
total_time: '',
total_money: '',
account_id: '',
status: 0,
customer_id: '',
product_type_id:'',
}
},
totalComputed(){
if(this.form.service_times && this.form.unit_price){
this.form.total_money = this.form.service_times * this.form.unit_price
}
},
productLoad() {
this.productSelect.page++
this.getProducts()
},
async getProducts() {
const res = await productList(this.productSelect, false)
if (res.data.length === 0) {
this.productSelect.page--
this.$message({
type: 'warning',
message: '没有跟多产品了'
})
return
}
this.products.push(...res.data)
},
productPick(e){
this.pickedProduct = e
this.form.product_id = e.id
this.form.product_type_id = e.product_type_id
console.log(e)
if(this.form.product_id && this.form.date.length>0){
let times;
let t1= moment(this.form.date[0])
let t2 = moment(this.form.date[1])
let unit;
switch (this.pickedProduct.cycle){
case 1:
unit = 'year'
break;
case 2:
unit = 'month'
break;
case 3:
unit = 'week'
break;
}
this.pickedProduct.cycle === 4 ? times = 1 : times = t2.diff(t1,unit) //
this.form.service_times = this.pickedProduct.frequency * times
this.form.total_money = Number(this.pickedProduct.purchase_price) * this.form.service_times
this.form.unit_price = Number(this.pickedProduct.purchase_price)
if(this.pickedProduct.type === 1){
this.form.total_time = Number(this.pickedProduct.time_lenth) * this.form.service_times
}else{
this.form.total_time = this.pickedProduct.total
}
}
},
datePick(){
if(this.form.product_id && this.form.date.length>0){
let t1= moment(this.form.date[0])
let t2 = moment(this.form.date[1])
let times = t2.diff(t1,'month') //
this.form.service_times = this.pickedProduct.frequency * times
this.form.total_money = Number(this.pickedProduct.purchase_price) * this.form.service_times
this.form.unit_price = Number(this.pickedProduct.purchase_price)
if(this.pickedProduct.type === 1){
this.form.total_time = Number(this.pickedProduct.time_lenth) * this.form.service_times * times
}else{
this.form.total_time = this.pickedProduct.total * times
}
}
},
submit() {
console.log(this.form)
Object.defineProperty(this.form,'start_date',{
value:this.form.date[0],
enumerable:true,
writable:true,
configurable:true
})
Object.defineProperty(this.form,'end_date',{
value:this.form.date[1],
enumerable:true,
writable:true,
configurable:true
})
delete this.form.date
save(this.form).then(res => {
this.$successMessage(this.type,'订单')
this.isShow = false
this.$emit('refresh')
})
}
},
watch: {
isShow(val) {
if (val) {
this.getProducts()
} else {
this.products = []
this.$refs['dialog'].reset()
this.initForm()
}
}
},
}
</script>
<style lang="scss" scoped>
.xy-table-item-label {
width: 160px;
}
::v-deep .el-input__inner {
text-align: left;
}
</style>

@ -10,7 +10,7 @@
<div>
<Input placeholder="关键字搜索" style="width: 200px; margin-right: 10px"/>
<Button style="margin-left: 10px" type="primary" @click="select.page = 1,getCustomers">查询</Button>
<Button style="margin-left: 10px" type="primary" @click="select.page = 1,getCustomers()">查询</Button>
<Button style="margin-left: 10px" type="primary"
@click="$refs['addCustomer'].type = 'add',$refs['addCustomer'].isShow = true">录入客户
</Button>
@ -26,24 +26,41 @@
:list="list"
:table-item="tableItem"
@pageSizeChange="e => select.page_size = e"
@pageIndexChange="e => {select.page = e;getCustomers()}"
@editor="editor"
@delete="destroy">
@pageIndexChange="e => {select.page = e;getCustomers()}">
<template v-slot:btns>
<el-table-column fixed="right" width="166" header-align="center" align="center" label="操作">
<template v-slot:default="scope">
<Poptip
transfer
confirm
title="确认要删除?"
@on-ok="destroy(scope.row)">
<Button size="small" type="error" ghost style="margin-right: 6px">删除</Button>
</Poptip>
<Button size="small" ghost type="primary" @click="editor(scope.row)" style="margin-right: 6px">编辑</Button>
<Button size="small" ghost type="primary" @click="$refs['addOrder'].isShow = true,$refs['addOrder'].form.customer_id = scope.row.id">录入</Button>
</template>
</el-table-column>
</template>
</xy-table>
<add-customer ref="addCustomer" :cities="cities" :disability-level="disabilityLevel" @refresh="getCustomers"></add-customer>
<addOrder ref="addOrder" :accounts="accounts"></addOrder>
<add-customer ref="addCustomer" :accounts="accounts" :cities="cities" :disability-level="disabilityLevel" @refresh="getCustomers"></add-customer>
</div>
</template>
<script>
import {getList,destroy} from '@/api/customer'
import {getparameter} from '@/api/system/dictionary'
import {getList as getUnit} from "@/api/payUnit";
import addCustomer from "@/views/customer/component/addCustomer";
import addCustomer from "@/views/customer/component/addCustomer";
import addOrder from './component/addOrder'
export default {
components: {
addCustomer
addCustomer,
addOrder
},
data() {
return {
@ -54,6 +71,7 @@ export default {
},
disabilityLevel: [],
cities:[],
accounts:[],
total: 0,
list: [],
@ -69,6 +87,22 @@ export default {
width: "180",
fixed:'left'
},
{
label:'订单产品',
width: 220,
align:'left',
customFn:(row) => {
return (
<div>
{
row.orders.map(item => {
return item.product.name
}).toString()
}
</div>
)
}
},
{
prop: "idcard",
label: "身份证号",
@ -130,6 +164,11 @@ export default {
this.total = res.data.total
},
async getAccounts(){
const res = await getUnit({page:1,page_size:9999})
this.accounts = res.data
},
async getCity(){
let city = await getparameter({number: 'city'},false)
for(let i = 0;i < city.detail.length;i ++){
@ -161,6 +200,7 @@ export default {
this.getDisabilityLevel()
this.getCustomers()
this.getCity()
this.getAccounts()
}
}
</script>

@ -9,7 +9,7 @@
<div>
<Input v-model="select.keyword" style="width: 200px; margin-right: 10px" placeholder="关键字搜索" />
<Button type="primary" style="margin-left: 10px" @click="select.page = 1,getOrder()">查询</Button>
<Button type="primary" style="margin-left: 10px" @click="$refs['addOrder'].type = 'add',$refs['addOrder'].isShow = true">创建订单</Button>
<!-- <Button type="primary" style="margin-left: 10px" @click="$refs['addOrder'].type = 'add',$refs['addOrder'].isShow = true">创建订单</Button>-->
</div>
</slot>
</lx-header>

@ -40,6 +40,42 @@
</div>
</template>
<template v-slot:service_rule>
<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-switch v-model="form.service_rule"
active-text="总时长"
inactive-text="单次限时"
style="width: 300px;"></el-switch>
</div>
</div>
</template>
<template v-slot:total v-if="form.service_rule">
<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 xy-table-item-min">
<el-input v-model="form.total" clearable placeholder="请输入总计时长" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:time_lenth v-else>
<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 xy-table-item-min">
<el-input v-model="form.time_lenth" clearable placeholder="请输入单次时长" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:frequency>
<div class="xy-table-item">
<div class="xy-table-item-label">
@ -76,17 +112,6 @@
</div>
</template>
<template v-slot:time_lenth>
<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 v-model="form.time_lenth" clearable placeholder="请输入单次时长" style="width: 300px;"/>
</div>
</div>
</template>
<template v-slot:type>
<div class="xy-table-item">
<div class="xy-table-item-label">
@ -127,8 +152,9 @@ export default {
frequency: 0,
purchase_price: '',
nurse_price: '',
service_rule:false,
time_lenth: '',
//type: '',
total:'',
},
rules: {
product_type_id: [
@ -162,12 +188,11 @@ export default {
async getDetail() {
const res = await getForm(this.id)
this.$integrateData(this.form, res)
this.form.product_sku_list = res.product_skus.map(item => {
return {sku_id:item.sku_id}
})
this.form.service_rule = res.service_rule === 2
},
submit() {
this.form.service_rule = this.form.service_rule ? 2 : 1
if (this.type === 'editor') {
Object.defineProperty(this.form, 'id', {
value: this.id,
@ -208,4 +233,11 @@ export default {
::v-deep .el-input__inner {
text-align: left !important;
}
.xy-table-item-min{
::v-deep .el-input__clear{
position: relative;
right: 46px;
z-index: 2;
}
}
</style>

@ -26,7 +26,7 @@
@pageSizeChange="e => select.page_size = e"
@pageIndexChange="e => {select.page = e;getList()}"></xy-table>
<add-product ref="addProduct" :product-type="productType"></add-product>
<add-product ref="addProduct" :product-type="productType" @refresh="getList"></add-product>
</div>
</template>

Loading…
Cancel
Save