From 7ba5457985d2c1d181c897b5866d504c76b12e0b Mon Sep 17 00:00:00 2001 From: fanfan Date: Thu, 23 May 2024 10:38:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/goods/modules/Update.vue | 109 ++++++++++++++++------------- 1 file changed, 62 insertions(+), 47 deletions(-) diff --git a/src/views/goods/modules/Update.vue b/src/views/goods/modules/Update.vue index 302679a..c458adb 100644 --- a/src/views/goods/modules/Update.vue +++ b/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 }}{{ item.name }}
- 新增模板 + 新增模板 刷新
@@ -230,7 +232,12 @@ /> - + @@ -363,9 +370,12 @@ v-decorator="['serviceIds']" placeholder="请选择服务与承诺" > - {{ - item.name - }} + {{ item.name }}
去新增 @@ -398,24 +408,29 @@ {{ province.name }} {{ ' ' }}

-

+

编辑 - 删除 + 删除

- 点击添加销售区域 + 点击添加销售区域
@@ -543,7 +558,7 @@
- + @@ -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() // bool为true时再执行一次 $forceUpdate, 特殊情况下需执行两次,原因如下: // 第一次执行 $forceUpdate时, 新元素绑定v-decorator无法获取到form.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() - } + }, }) - } - } - } + }, + }, +}