main^2
fanfan 6 months ago
parent 9f59bac136
commit c0811b12c6
  1. 32
      src/views/dataCenter/goods/Index.vue
  2. 114
      src/views/dataCenter/goods/modules/Update.vue

@ -346,7 +346,7 @@
<a @click="handleDelete([item.goods_id])">删除</a>
</div>
</s-table>
<Update ref="UpdateRef" />
<Update ref="UpdateRef" @refresh="refreshParentMethod" />
</a-card>
</template>
<script>
@ -364,26 +364,26 @@ Vue.use(DatePicker)
const columns = [
{
title: '商品ID',
width: '100px',
width: '90px',
dataIndex: 'goods_id',
sorter: true,
},
{
title: '商品',
dataIndex: 'goods_name',
width: '320px',
width: '300px',
scopedSlots: { customRender: 'goods_name' },
},
{
title: '成本价',
width: '120px',
width: '100px',
dataIndex: 'cost_price_min',
scopedSlots: { customRender: 'cost_price_min' },
sorter: true,
},
{
title: '前台价',
width: '100px',
width: '95px',
dataIndex: 'goods_price_min',
scopedSlots: { customRender: 'goods_price_min' },
sorter: true,
@ -396,7 +396,7 @@ const columns = [
},
{
title: '利润率',
width: '110px',
width: '95px',
dataIndex: 'profit_rate',
sorter: true,
scopedSlots: { customRender: 'profit_rate' },
@ -416,14 +416,14 @@ const columns = [
},
{
title: '商品池',
width: '100px',
width: '95px',
dataIndex: 'is_pool',
sorter: true,
scopedSlots: { customRender: 'is_pool' },
},
{
title: '状态',
width: '60px',
width: '50px',
dataIndex: 'is_sale',
scopedSlots: { customRender: 'is_sale' },
},
@ -433,6 +433,12 @@ const columns = [
dataIndex: 'create_time',
sorter: true,
},
{
title: '最后更新时间',
width: '150px',
dataIndex: 'update_time',
sorter: true,
},
{
title: '操作',
dataIndex: 'action',
@ -733,6 +739,9 @@ export default {
this.rate = ''
}
},
refreshParentMethod() {
this.handleRefresh(true)
},
//
async handleEdit(id) {
//
@ -1025,7 +1034,7 @@ export default {
},
}
</script>
<style lang="less">
<style lang="less">
.overlayName .ant-tooltip-inner {
background-color: rgba(0, 0, 0, 0.7) !important;
width: 350px;
@ -1033,7 +1042,6 @@ export default {
}
</style>
<style lang="less" scoped>
/deep/.ant-card-body {
padding: 22px 18px;
}
@ -1055,6 +1063,10 @@ export default {
/deep/.el-picker-panel__sidebar {
width: 85px;
}
.ant-table .actions a {
padding: 20px 4px;
margin: 0;
}
// tab
.tab-list {
margin-right: 20px;

@ -170,7 +170,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" :precision="2" v-decorator="['cost_price']" />
<span class="ml-10"></span>
</a-form-item>
@ -206,7 +211,6 @@
<span class="ml-10">千克 (Kg)</span>
</a-form-item>
</div>
</div>
<!-- 商品详情 -->
<div class="tab-pane" v-show="tabKey == 2">
@ -276,11 +280,8 @@
<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>
@ -293,7 +294,9 @@
</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>
@ -439,7 +442,7 @@ import Region from '@/common/model/Region'
const defaultItem = {
key: 0,
region: [],
region_text: []
region_text: [],
}
export default {
name: 'Update',
@ -451,9 +454,9 @@ export default {
InputNumberGroup,
MultiSpec,
AreasModal,
Region
Region,
},
data () {
data() {
return {
//
tabKey: 0,
@ -484,37 +487,37 @@ export default {
title: '销售区域',
dataIndex: 'region_text',
width: '400px',
scopedSlots: { customRender: 'region_text' }
}
scopedSlots: { customRender: 'region_text' },
},
],
//
citysCount: null
citysCount: null,
}
},
beforeDestroy () {
beforeDestroy() {
//
GoodsModel.formData.goods = {}
},
methods: {
showEdit (goodsId) {
showEdit(goodsId) {
// ID
this.goodsId = goodsId
this.initData()
this.getDataList()
//
Region.getCitysCount().then((count) => {
this.citysCount = count
})
this.visible = true
},
//
handleCancel () {
this.visible = true
this.goodsId = goodsId
this.initData()
this.getDataList()
//
Region.getCitysCount().then((count) => {
this.citysCount = count
})
},
//
handleCancel() {
this.visible = false
this.form.resetFields()
},
//
initData (goodsId) {
initData(goodsId) {
// form
this.isLoading = true
GoodsModel.getFromData(this.goodsId).then(() => {
@ -535,7 +538,7 @@ export default {
},
//
onForceUpdate (bool = false) {
onForceUpdate(bool = false) {
this.$forceUpdate()
// booltrue $forceUpdate,
// $forceUpdate, v-decoratorform.getFieldValue
@ -546,12 +549,12 @@ export default {
},
// tab
handleTabs (key) {
handleTabs(key) {
this.tabKey = key
},
//
onReloadCategoryList () {
onReloadCategoryList() {
this.isLoading = true
GoodsModel.getCategoryList().then(() => {
this.isLoading = false
@ -559,7 +562,7 @@ export default {
},
//
onReloadServiceList () {
onReloadServiceList() {
this.isLoading = true
GoodsModel.getServiceList().then(() => {
this.isLoading = false
@ -567,25 +570,25 @@ export default {
},
//
onReloadDeliveryList () {
onReloadDeliveryList() {
this.isLoading = true
GoodsModel.getDeliveryList().then(() => {
this.isLoading = false
})
},
//
getDataList () {
getDataList() {
return GoodsApi.list().then((result) => {
this.checkList = result.data.list.data
})
},
//
handleSubmit (e) {
handleSubmit(e) {
e.preventDefault()
//
const {
form: { validateFields },
ruleList
ruleList,
} = this
validateFields((errors, values) => {
// tab
@ -609,13 +612,12 @@ export default {
// api
values.rules = ruleList
this.onFormSubmit(values)
this.handleCancel()
return true
})
},
// tab
onTargetTabError (errors) {
onTargetTabError(errors) {
// tabKey
//
const tabsFieldsMap = [
@ -628,11 +630,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) {
@ -644,17 +646,17 @@ 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)
// //
// setTimeout(() => {
// this.$router.push('./index')
// }, 1500)
this.$emit('refresh')
setTimeout(() => {
this.handleCancel()
}, 500)
})
.catch(() => {
this.isBtnLoading = false
@ -663,7 +665,7 @@ export default {
},
//
handleAdd () {
handleAdd() {
const index = this.ruleList.length
const newItem = { ...defaultItem, key: index }
// id(id)
@ -677,7 +679,7 @@ export default {
},
//
handleEdit (index, item) {
handleEdit(index, item) {
// id(id)
const excludedCityIds = this.getExcludedCityIds()
//
@ -685,9 +687,9 @@ export default {
},
//
handleAreaSubmit (result) {
handleAreaSubmit(result) {
const {
custom: { scene, item }
custom: { scene, item },
} = result
item.region = result.selectedCityIds
item.region_text = result.selectedText
@ -697,7 +699,7 @@ export default {
},
// id(id)
getExcludedCityIds () {
getExcludedCityIds() {
const excludedCityIds = []
this.ruleList.forEach((item) => {
item.region.forEach((cityId) => {
@ -709,22 +711,22 @@ 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>
<style lang="less" scoped>

Loading…
Cancel
Save