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.

279 lines
8.9 KiB

<template>
<div class="app-container">
<div v-show="viewState == 1">
<!--标题按钮部分开始-->
<div class="tab-header webtop">
<!--标题-->
<div>{{ viewTitle }}</div>
<!--start 添加修改按钮-->
<div>
<el-button type="primary" size="small" :disabled="submitdisabled" @click="save()">保存
</el-button>
<el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
</div>
</div>
<!--标题按钮部分结束-->
<!--Start 新增修改部分-->
<div class="listconadd">
<div class="titwu"><span>单车返利</span></div>
<el-form ref="form_obj" :model="formobj" :rules="rules" class="formadd">
<el-row style="border-top: 1px solid #E0E3EB">
<el-col :span="4" class="tleftb">
<span>返利类型</span>
</el-col>
<el-col :span="4">
<el-form-item><span>{{ formobj.createOrgName }}</span></el-form-item>
</el-col>
<el-col :span="4" class="tleftb">
<span>厂家返利名称</span>
</el-col>
<el-col :span="4">
<el-form-item><span>{{ formobj.applyPeoName }}</span></el-form-item>
</el-col>
<el-col :span="4" class="tleftb">
<span>所属年月</span>
</el-col>
<el-col :span="4">
<el-form-item><span>{{ formobj.createTime }}</span></el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4" class="tleftb">
<span>计算方式</span>
</el-col>
<el-col :span="4">
<el-form-item><el-input v-model="formobj.modpriceReason" clearable placeholder="" class="addinputw"></el-input></el-form-item>
</el-col>
<el-col :span="4" class="tleftb">
<span>计算标注(%)</span>
</el-col>
<el-col :span="12">
<el-form-item><el-input v-model="formobj.modpriceReason" clearable placeholder="" class="addinputw"></el-input></el-form-item>
</el-col>
</el-row>
<div class="title">
<div>返利车辆列表</div>
<div>
<el-button type="primary" size="mini" icon="el-icon-plus" @click="addjacket()">添加</el-button>
<el-button type="primary" size="mini" icon="el-icon-plus" @click="addjacket()">批量选择</el-button>
</div>
</div>
<el-table :key="tableKey" :data="formobj.baseVehinstallModpricedetails" :index="index" border style="width: 100%">
<el-table-column fixed width="80px" label="序号" type="index" :index="index + 1" align="center"/>
<el-table-column fixed prop="name" label="操作" width="100px" align="center" header-align="center">
<template slot-scope="scope">
<el-button size="mini" type="danger" @click="dataDelete(scope.$index)">删除
</el-button>
</template>
</el-table-column>
<el-table-column label="车架号" align="center">
<template slot-scope="scope">
<span>{{ scope.row.jacketName }}</span>
</template>
</el-table-column>
<el-table-column label="厂家结算价" align="center">
<template slot-scope="scope">
<span>{{ scope.row.vinNo }}</span>
</template>
</el-table-column>
<el-table-column label="其中运费" align="center">
<template slot-scope="scope">
<span>{{ scope.row.modelName }}</span>
</template>
</el-table-column>
<el-table-column label="预计返利" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.vehGuidedPrice" clearable placeholder="" class="addinputw"></el-input>
</template>
</el-table-column>
<el-table-column label="备注" align="center">
<template slot-scope="scope">
<span>{{ scope.row.costPrice }}</span>
</template>
</el-table-column>
</el-table>
</el-form>
</div>
</div>
<!--End 添加修改部分-->
</div>
</template>
<script>
import req from '@/api/othermenu/shangzhuangtiaojia'
import { getPathSidByUserSid, fetchBySid } from '@/api/cheliang/dictcommons'
export default {
name: 'bicyclerebatemanagementAdd',
data() {
return {
viewTitle: '',
index: 0,
tableKey: 0,
viewState: 1,
// 表单数据
formobj: {
applyPeoName: '',
applyTitle: '',
createBySid: '',
createOrgName: '',
createOrgSid: '',
modpriceReason: '',
nodeState: '',
sid: '',
useOrgName: '',
useOrgSid: '',
baseVehinstallModpricedetails: []
},
rules: {},
submitdisabled: false
}
},
methods: {
// 获取制单日期
newDate() {
let date = new Date()
let year = date.getFullYear() // 年
let month = date.getMonth() + 1 // 月
let day = date.getDate() // 日
if (month < 10) {
month = '0' + month
}
if (day < 10) {
day = '0' + day
}
this.formobj.createTime = year + '-' + month + '-' + day
},
init() {
getPathSidByUserSid({ userSid: window.sessionStorage.getItem('userSid') }).then((resp) => {
if (resp.success) {
this.formobj.createOrgSid = resp.data
this.formobj.useOrgSid = resp.data
fetchBySid(this.formobj.createOrgSid).then((res) => {
if (res.success) {
this.formobj.createOrgName = res.data.name
this.formobj.useOrgName = res.data.name
}
})
}
})
},
showAdd() {
this.init()
this.newDate()
this.$nextTick(() => {
this.$refs['form_obj'].clearValidate()
})
this.formobj.createBySid = window.sessionStorage.getItem('userSid')
this.formobj.applyPeoName = window.sessionStorage.getItem('name')
this.viewTitle = '【新增】单车返利'
},
showEdit(row) {
this.$nextTick(() => {
this.$refs['form_obj'].clearValidate()
})
this.viewTitle = '【编辑】单车返利'
console.log('编辑回显', row.sid)
req.fetchBySid(row.sid).then((resp) => {
this.formobj = resp.data
}).catch((e) => {
this.formobj = row
})
},
// 明细表添加一行数据
addjacket() {
this.viewState = 2
this.$refs['divSelect'].showData(this.formobj.baseVehinstallModpricedetails)
},
backData(value) {
this.viewState = 1
if (value.length > 0) {
value.forEach((e) => {
this.formobj.baseVehinstallModpricedetails.push({
adjustVehGuidedPrice: '',
costPrice: e.costPrice,
guidedPrice: e.guidedPrice,
incOrDecInPrice: '',
jacketName: e.jacketName,
jacketSid: e.jacketSid,
mainSid: '',
modelName: e.modelName,
modelSid: e.modelSid,
sid: '',
vehGuidedPrice: '',
vinNo: e.vinNo,
remarks: ''
})
})
}
},
// 明细表删除一行数据
dataDelete(index) {
this.formobj.baseVehinstallModpricedetails.splice(index, 1)
},
resetState() {
this.viewState = 1
},
save() {
this.$refs['form_obj'].validate((valid) => {
if (valid) {
this.submitdisabled = true
req.saveOrUpdate(this.formobj).then((resp) => {
this.submitdisabled = false
if (resp.success) {
this.$message({
showClose: true,
type: 'success',
message: resp.msg
})
this.handleReturn('true')
}
}).catch(() => {
this.submitdisabled = false
})
} else {
return false
}
})
},
// 返回(===既判断)
handleReturn(isreload) {
if (isreload === 'true') this.$emit('reloadlist')
// 表单数据
this.formobj = {
applyPeoName: '',
applyTitle: '',
createBySid: '',
createOrgName: '',
createOrgSid: '',
modpriceReason: '',
nodeState: '',
sid: '',
useOrgName: '',
useOrgSid: '',
baseVehinstallModpricedetails: []
}
this.$refs['form_obj'].resetFields()
this.$emit('doback')
}
}
}
</script>
<style scoped>
.title {
padding: 7px;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.rowStyle {
border-left: 0px;
}
.colOneStyle {
border-right: 0px !important;
border-bottom: 0px !important;
}
</style>