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.

341 lines
12 KiB

<template>
<div class="app-container">
<div v-show="viewState == 1">
<div class="tab-header webtop">
<div>{{ viewTitle }}</div>
<div>
<el-button type="primary" size="small" :disabled="submitdisabled" @click="saveOrUpdate()">保存</el-button>
<el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
</div>
</div>
<div class="listconadd">
<el-form ref="form_obj" :model="formobj" :rules="rules" class="formaddcopy02">
<el-row style="border-top: 1px solid #e0e3eb">
<el-col :span="24">
<div class="span-sty">客户</div>
<el-form-item>
<el-popover placement="right" width="600" trigger="click">
<div>
<el-table :data="clientData" v-loading="clientLoading" highlight-current-row @current-change="clientCurrentChange">
<el-table-column fixed prop="vehMark" label="车辆拍照" align="center" width="130" />
<el-table-column prop="name" label="客户" align="center" width="100" />
<el-table-column prop="mobile" label="联系方式" align="center" min-width="300" />
<el-table-column prop="orgName" label="客户单位" align="center" width="100" />
</el-table>
<el-pagination :page.sync="clientQuery.current" :page-size="clientQuery.size" layout="total, pager" :total="clientQuery.total" />
</div>
<el-input slot="reference" class="addinputInfo" style="width: 20%" v-model="formobj.customerName" @input="clientInput(formobj.customerName)" clearable placeholder="客户"/>
</el-popover>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<div class="span-sty">客户</div>
<el-form-item><span class="addinputInfo">{{ formobj.customerName }}</span></el-form-item>
</el-col>
<el-col :span="8">
<div class="span-sty">车辆牌照</div>
<el-form-item><span class="addinputInfo">{{ formobj.vehMark }}</span></el-form-item>
</el-col>
<el-col :span="8">
<div class="span-sty">联系电话</div>
<el-form-item><span class="addinputInfo">{{ formobj.mobile }}</span></el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<div class="span-sty">车型</div>
<el-form-item><span class="addinputInfo">{{ formobj.vehModel }}</span></el-form-item>
</el-col>
<el-col :span="8">
<div class="span-sty">单号</div>
<el-form-item><span class="addinputInfo">{{ formobj.billNo }}</span></el-form-item>
</el-col>
<el-col :span="8">
<div class="span-sty">预约服务顾问</div>
<el-form-item><span class="addinputInfo">{{ formobj.waitorName }}</span></el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<div class="span-sty">预约设备</div>
<el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.reserveEquip" clearable placeholder="" /></el-form-item>
</el-col>
<el-col :span="12">
<div class="span-sty">预约日期</div>
<el-form-item><el-date-picker class="addinputInfo" v-model="formobj.reserveStart" type="daterange" range-separator="" start-placeholder="开始日期" end-placeholder="结束日期" /></el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<div class="span-sty">备注</div>
<el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.remarks" clearable placeholder="" /></el-form-item>
</el-col>
</el-row>
<el-table :key="serviceKey" :data="formobj.sitemVos" :index="index" border style="width: 100%">
<el-table-column fixed width="60" label="序号" type="index" :index="index + 1" align="center"/>
<el-table-column align="center" width="70" :render-header="serviceHeader">
<template slot-scope="scope">
<i class="el-icon-delete" @click="serviceDelete(scope.$index)"></i>
</template>
</el-table-column>
<el-table-column label="服务项目" align="center" min-width="200">
<template slot-scope="scope">
<el-popover placement="right" width="600" trigger="click">
<div>
<el-table :data="serviceData" v-loading="serviceLoading" highlight-current-row @current-change="serviceCurrentChange($event, scope.row)">
<el-table-column fixed prop="goodsName" label="商品名称" align="center" width="130" />
<el-table-column prop="goodsCode" label="零件号" align="center" width="100" />
<el-table-column prop="goodsModel" label="车型" align="center" min-width="300" />
<el-table-column prop="warehouse" label="仓库" align="center" width="" />
<el-table-column prop="price" label="销售价" align="center" width="100" />
<el-table-column prop="count" label="数量" align="center" width="100" />
</el-table>
<el-pagination :page.sync="serviceQuery.current" :page-size="serviceQuery.size" layout="total, pager" :total="serviceQuery.total" />
</div>
<el-input slot="reference" v-model="scope.row.goodsName" @input="serviceInput(scope.row.goodsName)" clearable placeholder="项目名称、拼音"/>
</el-popover>
</template>
</el-table-column>
<el-table-column label="工时单价" align="center" width="130">
<template slot-scope="scope">
<el-input @input="computeXSJ(scope.row)" v-model="scope.row.hourPrice" clearable placeholder="" />
</template>
</el-table-column>
<el-table-column label="工时数" align="center" width="100">
<template slot-scope="scope">
<el-input @input="computeXSJ(scope.row)" v-model="scope.row.hours" clearable placeholder="" />
</template>
</el-table-column>
<el-table-column label="销售价" align="center" width="100">
<template slot-scope="scope">
<el-input @input="computeGSS(scope.row)" v-model="scope.row.price" clearable placeholder="" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" width="200">
<template slot-scope="scope">
<el-input v-model="scope.row.remarks" clearable placeholder="" />
</template>
</el-table-column>
</el-table>
</el-form>
</div>
</div>
</div>
</template>
<script>
import req from '@/api/operation/preregistration'
export default {
name: '',
data() {
return {
viewTitle: '',
viewState: 1,
submitdisabled: false,
index: 0,
// client客户
clientKey: 1,
clientLoading: false,
clientQuery: {
current: 1,
size: 2,
total: 0,
params: {
queryName: '',
useOrgSid: ''
}
},
clientData: [],
// service服务
serviceKey: 1,
serviceLoading: false,
serviceQuery: {
current: 1,
size: 2,
total: 0,
params: {
name: ''
}
},
serviceData: [],
formobj: {
sid: '',
createBySid: '',
remarks: '',
createByName: '',
billNo: '',
reserveStart: '',
reserveEnd: '',
waitorSid: '',
waitorName: '',
reserveEquip: '',
customerSid: '',
customerName: '',
mobile: '',
vehMark: '',
vehModel: '',
useOrgSid: '',
createOrgSid: '',
sitemVos: []
},
rules: {}
}
},
methods: {
showAdd() {
this.viewTitle = '【新增】预约登记'
this.$nextTick(() => {
this.$refs['form_obj'].clearValidate()
})
},
showEdit() {
this.viewTitle = '【编辑】预约登记'
this.$nextTick(() => {
this.$refs['form_obj'].clearValidate()
})
},
clientInput(value) {
this.clientQuery.params.queryName = value
this.clientLoading = true
req.customerListPage(this.clientQuery).then((response) => {
if (response.success) {
this.clientLoading = false
this.clientData = response.data.records
this.clientQuery.total = response.data.total
} else {
this.serviceLoading = false
this.clientData = []
this.clientQuery.total = 0
}
})
},
clientCurrentChange(value) {
// this.formobj.customerName = value.name
// this.formobj.vehMark = value.vehMark
// this.formobj.mobile = value.mobile
document.body.click()
},
// 在头部标题上添加“新增”图标
serviceHeader(h, { column }) {
return h(
'div',
[
h('span', column.label),
h('i', {
class: 'add-btn-icon el-icon-plus',
style: 'color: red;font-size:20px',
on: {
click: this.serviceAdd // 点击执行函数
}
})
]
)
},
serviceAdd() {
this.formobj.sitemVos.push({
serviceItemSid: '',
serviceItem: '',
hourPrice: '',
hours: '',
price: '',
remarks: ''
})
},
serviceInput(value) {
this.serviceQuery.params.orgPath = window.sessionStorage.getItem('defaultOrgPath')
this.serviceQuery.params.name = value
this.serviceLoading = true
req.listPageSales(this.serviceQuery).then((response) => {
if (response.success) {
this.serviceLoading = false
this.serviceData = response.data.records
this.serviceQuery.total = response.data.total
} else {
this.serviceLoading = false
this.serviceData = []
this.serviceQuery.total = 0
}
})
},
serviceDelete(index) {
this.formobj.sitemVos.splice(index, 1)
},
serviceCurrentChange(value, row) {
row.serviceItemSid = value.sid
row.serviceItem = value.sitemName
row.hourPrice = value.hourPrice
row.hours = value.hours
row.price = value.price
row.remarks = value.remarks
document.body.click()
},
// 计算销售价=工时数*工时单价
computeXSJ(row) {
row.price = Math.round((parseFloat(row.hourPrice === '' ? '0' : row.hourPrice) * parseFloat(row.hours === '' ? '0' : row.hours)) * 100) / 100
},
// 计算工时数=销售价除以工时单价
computeGSS(row) {
row.hours = Math.round((parseFloat(row.price === '' ? '0' : row.price) / parseFloat(row.hourPrice === '' ? '0' : row.hourPrice)) * 100) / 100
},
saveOrUpdate() {
this.$refs['form_obj'].validate((valid) => {
if (valid) {
this.submitdisabled = true
req.saveOrUpdate(this.formobj).then((res) => {
if (res.success) {
this.$message({ showClose: true, type: 'success', message: '保存成功' })
this.handleReturn('true')
} else {
this.submitdisabled = false
}
}).catch(() => {
this.submitdisabled = false
})
}
})
},
handleReturn(isreload) {
if (isreload === 'true') this.$emit('reloadlist')
this.formobj = {
sid: '',
createBySid: '',
remarks: '',
createByName: '',
billNo: '',
reserveStart: '',
reserveEnd: '',
waitorSid: '',
waitorName: '',
reserveEquip: '',
customerSid: '',
customerName: '',
mobile: '',
vehMark: '',
vehModel: '',
useOrgSid: '',
createOrgSid: '',
sitemVos: []
}
this.submitdisabled = false
this.$emit('doback')
}
}
}
</script>
<style scoped>
.span-sty {
width: 130px !important;
}
.addinputInfo {
margin-left: 120px !important;
}
.formaddcopy02 .el-row .el-col /deep/ .el-form-item .addinputw {
margin-left: 120px !important;
width: calc(100% - 115px);
}
</style>