main
fanfan 8 months ago
parent 3ae7c67b8f
commit 7ba5457985
  1. 109
      src/views/goods/modules/Update.vue

@ -169,11 +169,13 @@
v-for="(item, index) in formData.deliveryList"
:key="index"
:value="item.delivery_id"
>{{ item.name }}</a-select-option
>{{ item.name }}</a-select-option
>
</a-select>
<div class="form-item-help">
<router-link target="_blank" :to="{ path: '/setting/delivery/template/create' }">新增模板</router-link>
<router-link target="_blank" :to="{ path: '/setting/delivery/template/create' }"
>新增模板</router-link
>
<a href="javascript:;" @click="onReloadDeliveryList">刷新</a>
</div>
</a-form-item>
@ -230,7 +232,12 @@
/>
<span class="ml-10"></span>
</a-form-item>
<a-form-item label="成本价" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="成本价仅用于商品页展示">
<a-form-item
label="成本价"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
extra="成本价仅用于商品页展示"
>
<a-input-number :min="0.01" :precision="2" v-decorator="['cost_price']" />
<span class="ml-10"></span>
</a-form-item>
@ -363,9 +370,12 @@
v-decorator="['serviceIds']"
placeholder="请选择服务与承诺"
>
<a-select-option v-for="(item, index) in formData.serviceList" :key="index" :value="item.service_id">{{
item.name
}}</a-select-option>
<a-select-option
v-for="(item, index) in formData.serviceList"
:key="index"
:value="item.service_id"
>{{ item.name }}</a-select-option
>
</a-select>
<div class="form-item-help">
<router-link target="_blank" :to="{ path: '/goods/service/index' }">去新增</router-link>
@ -398,24 +408,29 @@
<span>{{ province.name }}</span>
<template v-if="province.citys.length">
<span>(</span>
<span
class="city-name"
v-for="(city, cidx) in province.citys"
:key="cidx"
>{{ city.name }}{{ province.citys.length > cidx + 1 ? '、' : '' }}</span
<span class="city-name" v-for="(city, cidx) in province.citys" :key="cidx"
>{{ city.name }}{{ province.citys.length > cidx + 1 ? '、' : '' }}</span
>
<span>)</span>
</template>
<span>{{ ' ' }}</span>
</span>
</p>
<p class="operation" style="text-align: right;">
<p class="operation" style="text-align: right">
<a href="javascript:void(0);" class="edit" @click="handleEdit(index, item)">编辑</a>
<a href="javascript:void(0);" style="margin-left: 6px;" class="delete" @click="handleDelete(index)">删除</a>
<a
href="javascript:void(0);"
style="margin-left: 6px"
class="delete"
@click="handleDelete(index)"
>删除</a
>
</p>
</template>
</a-table>
<a-button icon="environment" v-if="ruleList.length == 0" @click="handleAdd">点击添加销售区域</a-button>
<a-button icon="environment" v-if="ruleList.length == 0" @click="handleAdd"
>点击添加销售区域</a-button
>
</a-form-item>
</div>
<div v-show="$module('market-points')">
@ -543,7 +558,7 @@
</div>
</div>
</a-form>
<AreasModal ref="AreasModal" @handleSubmit="handleAreaSubmit" :loading="isBtnLoading"/>
<AreasModal ref="AreasModal" @handleSubmit="handleAreaSubmit" :loading="isBtnLoading" />
</a-spin>
</a-card>
</a-modal>
@ -560,7 +575,7 @@ import { AreasModal } from '@/components/Modal'
const defaultItem = {
key: 0,
region: [],
region_text: []
region_text: [],
}
export default {
components: {
@ -570,12 +585,12 @@ export default {
Ueditor,
InputNumberGroup,
MultiSpec,
AreasModal
AreasModal,
},
props: {
//
},
data () {
data() {
return {
categoryList: [],
//
@ -608,15 +623,15 @@ export default {
title: '销售区域',
dataIndex: 'region_text',
width: '400px',
scopedSlots: { customRender: 'region_text' }
}
scopedSlots: { customRender: 'region_text' },
},
],
//
citysCount: null
citysCount: null,
}
},
methods: {
initData (goodsId) {
initData(goodsId) {
GoodsModel.formData.goods = {}
this.visible = true
// ID
@ -640,7 +655,7 @@ export default {
},
//
onForceUpdate (bool = false) {
onForceUpdate(bool = false) {
this.$forceUpdate()
// booltrue $forceUpdate,
// $forceUpdate, v-decoratorform.getFieldValue
@ -651,12 +666,12 @@ export default {
},
// tab
handleTabs (key) {
handleTabs(key) {
this.tabKey = key
},
//
onReloadCategoryList () {
onReloadCategoryList() {
this.isLoading = true
GoodsModel.getCategoryList().then(() => {
this.isLoading = false
@ -664,7 +679,7 @@ export default {
},
//
onReloadServiceList () {
onReloadServiceList() {
this.isLoading = true
GoodsModel.getServiceList().then(() => {
this.isLoading = false
@ -672,24 +687,24 @@ export default {
},
//
onReloadDeliveryList () {
onReloadDeliveryList() {
this.isLoading = true
GoodsModel.getDeliveryList().then(() => {
this.isLoading = false
})
},
//
handleCancel () {
handleCancel() {
this.visible = false
this.form.resetFields()
},
//
handleSubmit (e) {
handleSubmit(e) {
e.preventDefault()
//
const {
form: { validateFields },
ruleList
ruleList,
} = this
validateFields((errors, values) => {
// tab
@ -718,7 +733,7 @@ export default {
},
// tab
onTargetTabError (errors) {
onTargetTabError(errors) {
// tabKey
//
const tabsFieldsMap = [
@ -731,11 +746,11 @@ export default {
'is_ind_delivery_type',
'delivery_type',
'is_brand',
'is_in_store'
'is_in_store',
],
['spec_type', 'goods_price', 'is_restrict', 'restrict_total', 'restrict_single', 'cost_price'],
['content'],
['alone_grade_equity', 'first_money', 'second_money', 'third_money']
['alone_grade_equity', 'first_money', 'second_money', 'third_money'],
]
const field = Object.keys(errors).shift()
for (const key in tabsFieldsMap) {
@ -747,14 +762,14 @@ export default {
},
// api
onFormSubmit (values) {
onFormSubmit(values) {
this.isLoading = true
this.isBtnLoading = true
GoodsApi.edit({ goodsId: this.goodsId, form: values })
.then((result) => {
//
this.$message.success(result.message, 1.5)
this.$emit('refresh');
this.$emit('refresh')
setTimeout(() => {
this.handleCancel()
}, 500)
@ -765,7 +780,7 @@ export default {
.finally(() => (this.isLoading = false))
},
//
handleAdd () {
handleAdd() {
const index = this.ruleList.length
const newItem = { ...defaultItem, key: index }
// id(id)
@ -779,7 +794,7 @@ export default {
},
//
handleEdit (index, item) {
handleEdit(index, item) {
// id(id)
const excludedCityIds = this.getExcludedCityIds()
//
@ -787,9 +802,9 @@ export default {
},
//
handleAreaSubmit (result) {
handleAreaSubmit(result) {
const {
custom: { scene, item }
custom: { scene, item },
} = result
item.region = result.selectedCityIds
item.region_text = result.selectedText
@ -799,7 +814,7 @@ export default {
},
// id(id)
getExcludedCityIds () {
getExcludedCityIds() {
const excludedCityIds = []
this.ruleList.forEach((item) => {
item.region.forEach((cityId) => {
@ -810,21 +825,21 @@ export default {
},
//
handleAreasModal (scene, index, item, excludedCityIds) {
handleAreasModal(scene, index, item, excludedCityIds) {
this.$refs.AreasModal.handle({ scene, index, item }, item.region, excludedCityIds)
},
//
handleDelete (index) {
handleDelete(index) {
const app = this
const modal = this.$confirm({
title: '您确定要删除该记录吗?',
onOk () {
onOk() {
app.ruleList.splice(index, 1)
modal.destroy()
}
},
})
}
}
}
},
},
}
</script>

Loading…
Cancel
Save