|
@@ -10,56 +10,47 @@
|
|
|
@cancel="isShow = false"
|
|
|
v-model="isShow">
|
|
|
<!-- 表单 -->
|
|
|
- <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
|
|
+ <a-form-model
|
|
|
+ ref="ruleForm"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ :label-col="{ span: 6 }"
|
|
|
+ :wrapper-col="{ span: 18 }"
|
|
|
+ v-if="setmealData">
|
|
|
<!-- 合作商名称 -->
|
|
|
- <a-form-model-item label="合作商名称" class="item-con"><p class="item-main">清泉洗车(VIP)</p></a-form-model-item>
|
|
|
+ <a-form-model-item label="合作商名称" class="item-con"><p class="item-main">{{ setmealData.salesChannelName }}</p></a-form-model-item>
|
|
|
<!-- 套餐名称 -->
|
|
|
- <a-form-model-item label="套餐名称" class="item-con"><p class="item-main">2020-11-28</p></a-form-model-item>
|
|
|
+ <a-form-model-item label="套餐名称" class="item-con"><p class="item-main">{{ setmealData.bundle.name || '--' }}</p></a-form-model-item>
|
|
|
<!-- 套餐别名 -->
|
|
|
- <a-form-model-item label="套餐别名" class="item-con"><p class="item-main">15次</p></a-form-model-item>
|
|
|
+ <a-form-model-item label="套餐别名" class="item-con">
|
|
|
+ <a-input id="attr-goodsAlias" v-model.trim="form.goodsAlias" :maxLength="30" placeholder="请输入套餐别名" />
|
|
|
+ </a-form-model-item>
|
|
|
<!-- 所属地区 -->
|
|
|
- <a-form-model-item label="所属地区" style="margin: 0;">
|
|
|
- <a-row :gutter="20">
|
|
|
- <a-col span="8">
|
|
|
- <a-form-model-item>
|
|
|
- <a-select id="attr-edit-provinceCode" @change="getCityList" v-model="form.provinceCode" placeholder="请选择省">
|
|
|
- <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-form-model-item>
|
|
|
- </a-col>
|
|
|
- <a-col span="8">
|
|
|
- <a-form-model-item prop="cityCode">
|
|
|
- <a-select id="attr-edit-cityCode" v-model="form.cityCode" @change="getAreaList" placeholder="请选择市">
|
|
|
- <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-form-model-item>
|
|
|
- </a-col>
|
|
|
- <a-col span="8">
|
|
|
- <a-form-model-item prop="districtCode">
|
|
|
- <a-select id="attr-edit-districtCode" v-model="form.districtCode" placeholder="请选择区/县">
|
|
|
- <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-form-model-item>
|
|
|
- </a-col>
|
|
|
- </a-row>
|
|
|
+ <a-form-model-item label="所属地区" class="item-con">
|
|
|
+ <a-cascader id="attr-areas" v-model="areas" :options="options" placeholder="请选择省市区" />
|
|
|
</a-form-model-item>
|
|
|
<!-- 所属项目名称 -->
|
|
|
- <a-form-model-item label="所属项目名称" class="item-con" prop="itemName">
|
|
|
- <a-input id="attr-itemName" v-model.trim="form.itemName" :maxLength="30" placeholder="请输入所属项目名称" />
|
|
|
+ <a-form-model-item label="所属项目名称" class="item-con" prop="belongProject" v-if="propertiesConfig.indexOf('BELONG_PROJECT')!=-1">
|
|
|
+ <a-input id="attr-belongProject" v-model.trim="form.belongProject" :maxLength="30" placeholder="请输入所属项目名称" />
|
|
|
</a-form-model-item>
|
|
|
<!-- 分公司名称 -->
|
|
|
- <a-form-model-item label="分公司名称" class="item-con" prop="company">
|
|
|
- <a-select id="attr-company" v-model="form.company" placeholder="请选择分公司名称">
|
|
|
- <a-select-option v-for="item in companyList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
|
|
|
- </a-select>
|
|
|
+ <a-form-model-item label="分公司名称" class="item-con" prop="belongCompany" v-if="propertiesConfig.indexOf('BELONG_COMPANY')!=-1">
|
|
|
+ <v-select
|
|
|
+ code="BELONG_COMPANY"
|
|
|
+ ref="belongCompany"
|
|
|
+ v-model="form.belongCompany"
|
|
|
+ id="attr-belongCompany"
|
|
|
+ allowClear
|
|
|
+ placeholder="请选择分公司名称" ></v-select>
|
|
|
</a-form-model-item>
|
|
|
<!-- 折扣比例 -->
|
|
|
- <a-form-model-item label="折扣比例" class="item-con" prop="discount">
|
|
|
+ <a-form-model-item label="折扣比例" class="item-con" prop="useDiscountRate" v-if="propertiesConfig.indexOf('USE_DISCOUNT_RATE')!=-1">
|
|
|
<a-input-number
|
|
|
- id="attr-discount"
|
|
|
- v-model="form.discount"
|
|
|
+ id="attr-useDiscountRate"
|
|
|
+ v-model="form.useDiscountRate"
|
|
|
:min="0"
|
|
|
- :max="999999"
|
|
|
+ :max="100"
|
|
|
+ :precision="2"
|
|
|
placeholder="请输入折扣比例"
|
|
|
style="width: 80%;margin-right: 10px;" />%
|
|
|
</a-form-model-item>
|
|
@@ -72,9 +63,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getProvince, getCityByPro, getDistrictByCity } from '@/api/lookup'
|
|
|
+import { VSelect } from '@/components'
|
|
|
+import addrData, { province, city, area } from '@/api/address'
|
|
|
+import { salesChannelGoodsConfig } from '@/api/SetmealSales'
|
|
|
+import _ from 'lodash'
|
|
|
export default {
|
|
|
name: 'AttrModal',
|
|
|
+ components: { VSelect },
|
|
|
props: {
|
|
|
openModal: {
|
|
|
// 弹框是否展示
|
|
@@ -85,27 +80,31 @@ export default {
|
|
|
// 套餐id
|
|
|
type: [String, Number],
|
|
|
default: ''
|
|
|
+ },
|
|
|
+ setmealData: { // 套餐数据
|
|
|
+ type: Object,
|
|
|
+ default: () => { return {} }
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
isShow: this.openModal, // 弹框是否展示
|
|
|
form: {
|
|
|
- provinceCode: undefined, // 省
|
|
|
- provinceName: '',
|
|
|
- cityCode: undefined, // 市
|
|
|
- cityName: '',
|
|
|
- districtCode: undefined, // 区
|
|
|
- districtName: '',
|
|
|
- itemName: '', // 所属项目名称
|
|
|
- company: undefined, // 分公司名称
|
|
|
- discount: '' // 折扣比例
|
|
|
+ goodsAlias: '', // 套餐别名
|
|
|
+ addrProvince: undefined, // 省
|
|
|
+ addrProvinceName: '',
|
|
|
+ addrCity: undefined, // 市
|
|
|
+ addrCityName: '',
|
|
|
+ addrDistrict: undefined, // 区
|
|
|
+ addrDistrictName: '',
|
|
|
+ belongProject: '', // 所属项目名称
|
|
|
+ belongCompany: undefined, // 分公司名称
|
|
|
+ useDiscountRate: '' // 折扣比例
|
|
|
},
|
|
|
rules: {},
|
|
|
- addrProvinceList: [], // 省下拉
|
|
|
- addrCityList: [], // 市下拉
|
|
|
- addrDistrictList: [], // 区下拉
|
|
|
- companyList: [] // 分公司 下拉
|
|
|
+ options: addrData,
|
|
|
+ areas: [],
|
|
|
+ propertiesConfig: [] // 套餐属性
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -116,88 +115,53 @@ export default {
|
|
|
},
|
|
|
// 重置表单
|
|
|
resetForm () {
|
|
|
- this.form.provinceCode = undefined
|
|
|
- this.form.provinceName = ''
|
|
|
- this.form.cityCode = undefined
|
|
|
- this.form.cityName = ''
|
|
|
- this.form.districtCode = undefined
|
|
|
- this.form.districtName = ''
|
|
|
- this.form.itemName = ''
|
|
|
- this.form.company = undefined
|
|
|
- this.form.discount = ''
|
|
|
+ this.form.goodsAlias = ''
|
|
|
+ this.form.addrProvince = undefined
|
|
|
+ this.form.addrProvinceName = ''
|
|
|
+ this.form.addrCity = undefined
|
|
|
+ this.form.addrCityName = ''
|
|
|
+ this.form.addrDistrict = undefined
|
|
|
+ this.form.addrDistrictName = ''
|
|
|
+ this.areas = []
|
|
|
+ this.form.belongProject = ''
|
|
|
+ this.form.belongCompany = undefined
|
|
|
+ this.form.useDiscountRate = ''
|
|
|
},
|
|
|
// 提交
|
|
|
onSubmit () {
|
|
|
this.$refs.ruleForm.validate(valid => {
|
|
|
if (valid) {
|
|
|
+ if (this.areas.length) {
|
|
|
+ this.form.addrProvince = this.areas[0]
|
|
|
+ this.form.addrProvinceName = _.find(province, ['code', this.areas[0]]).name
|
|
|
+ this.form.addrCity = this.areas[1]
|
|
|
+ this.form.addrCityName = _.find(city, ['code', this.areas[1]]).name
|
|
|
+ this.form.addrDistrict = this.areas[2]
|
|
|
+ this.form.addrDistrictName = _.find(area, ['code', this.areas[2]]).name
|
|
|
+ }
|
|
|
const params = {
|
|
|
- bundleId: this.setmealId,
|
|
|
- provinceCode: this.form.provinceCode,
|
|
|
- provinceName: this.form.provinceName,
|
|
|
- cityCode: this.form.cityCode,
|
|
|
- cityName: this.form.cityName,
|
|
|
- districtCode: this.form.districtCode,
|
|
|
- districtName: this.form.districtName,
|
|
|
- itemName: this.form.itemName,
|
|
|
- company: this.form.company,
|
|
|
- discount: this.form.discount
|
|
|
+ id: this.setmealId,
|
|
|
+ goodsAlias: this.form.goodsAlias,
|
|
|
+ addrProvince: this.form.addrProvince,
|
|
|
+ addrProvinceName: this.form.addrProvinceName,
|
|
|
+ addrCity: this.form.addrCity,
|
|
|
+ addrCityName: this.form.addrCityName,
|
|
|
+ addrDistrict: this.form.addrDistrict,
|
|
|
+ addrDistrictName: this.form.addrDistrictName,
|
|
|
+ belongProject: this.form.belongProject,
|
|
|
+ belongCompany: this.form.belongCompany,
|
|
|
+ useDiscountRate: this.form.useDiscountRate
|
|
|
}
|
|
|
- // bundleBuy(params).then(res => {
|
|
|
- // if (res.status == 200) {
|
|
|
- // this.cancel()
|
|
|
- // }
|
|
|
- // })
|
|
|
+ salesChannelGoodsConfig(params).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.cancel()
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
console.log('error submit!!')
|
|
|
return false
|
|
|
}
|
|
|
})
|
|
|
- },
|
|
|
- // 获取省列表'
|
|
|
- getProvinceList () {
|
|
|
- getProvince().then(res => {
|
|
|
- if (res.status == 200) {
|
|
|
- this.addrProvinceList = res.data || []
|
|
|
- } else {
|
|
|
- this.addrProvinceList = []
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- // 获取城市列表
|
|
|
- getCityList (val) {
|
|
|
- this.addrCityList = []
|
|
|
- this.addrDistrictList = []
|
|
|
- this.form.cityCode = undefined
|
|
|
- this.form.districtCode = undefined
|
|
|
- this.getCityListRequest(val)
|
|
|
- },
|
|
|
- getCityListRequest (val) {
|
|
|
- getCityByPro({
|
|
|
- id: val
|
|
|
- }).then(res => {
|
|
|
- if (res.status == 200) {
|
|
|
- this.addrCityList = res.data || []
|
|
|
- } else {
|
|
|
- this.addrCityList = []
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- // 获取区县列表
|
|
|
- getAreaList (val) {
|
|
|
- this.addrDistrictList = []
|
|
|
- this.form.districtCode = undefined
|
|
|
- this.getAreaListRequest(val)
|
|
|
- },
|
|
|
- getAreaListRequest (val) {
|
|
|
- getDistrictByCity({
|
|
|
- id: val
|
|
|
- }).then(res => {
|
|
|
- if (res.status == 200) {
|
|
|
- this.addrDistrictList = res.data || []
|
|
|
- } else {
|
|
|
- this.addrDistrictList = []
|
|
|
- }
|
|
|
- })
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -211,15 +175,21 @@ export default {
|
|
|
this.$emit('close')
|
|
|
} else {
|
|
|
this.resetForm() // 重置表单数据
|
|
|
- this.getProvinceList()
|
|
|
}
|
|
|
},
|
|
|
- setmealId (newValue, oldValue) {
|
|
|
- if (newValue && this.isShow) {
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
+ setmealData: {
|
|
|
+ handler: function (obj) {
|
|
|
+ if (obj) {
|
|
|
+ this.propertiesConfig = obj.salesChannel.propertiesConfig ? obj.salesChannel.propertiesConfig.split(',') : []
|
|
|
+ this.form.goodsAlias = obj.goodsAlias
|
|
|
+ // 省市区
|
|
|
+ this.areas = obj.addrProvince ? [obj.addrProvince + '', obj.addrCity + '', obj.addrDistrict + ''] : []
|
|
|
+ this.form.belongProject = obj.belongProject || ''
|
|
|
+ this.form.belongCompany = obj.belongCompany || undefined
|
|
|
+ this.form.useDiscountRate = obj.useDiscountRate || ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
}
|
|
|
}
|
|
|
}
|