From 685c66d19b661b8b4a56013096cdd19582acbf91 Mon Sep 17 00:00:00 2001 From: wanghousheng Date: Sun, 21 Apr 2024 21:35:00 +0800 Subject: [PATCH] 1 --- src/views/goods/Create.vue | 66 ++++++++++++++++--------------- src/views/server/Index.vue | 4 +- src/views/server/modules/Add.vue | 28 ++++++------- src/views/server/modules/Edit.vue | 36 ++++++++--------- 4 files changed, 68 insertions(+), 66 deletions(-) diff --git a/src/views/goods/Create.vue b/src/views/goods/Create.vue index acb767c..b5fde0f 100644 --- a/src/views/goods/Create.vue +++ b/src/views/goods/Create.vue @@ -36,7 +36,6 @@ :dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" :treeData="formData.categoryList" treeCheckable - treeCheckStrictly allowClear v-decorator="['categorys', { rules: [{ required: true, message: '请至少选择1个商品分类' }] }]" > @@ -158,7 +157,7 @@ v-for="(item, index) in formData.deliveryList" :key="index" :value="item.delivery_id" - >{{ item.name }}{{ item.name }}
@@ -377,8 +376,11 @@ {{ province.name }} @@ -534,7 +536,7 @@ import { AreasModal } from '@/components/Modal' const defaultItem = { key: 0, region: [], - region_text: [], + region_text: [] } export default { components: { @@ -544,9 +546,9 @@ export default { Ueditor, InputNumberGroup, MultiSpec, - AreasModal, + AreasModal }, - data() { + data () { return { // 默认的标签索引 tabKey: 0, @@ -570,15 +572,15 @@ export default { title: '销售区域', dataIndex: 'region_text', width: '400px', - scopedSlots: { customRender: 'region_text' }, - }, + scopedSlots: { customRender: 'region_text' } + } ], // 城市总数 - citysCount: null, + citysCount: null } }, // 初始化数据 - created() { + created () { this.isLoading = true // 获取form所需的数据 GoodsModel.getFromData().then(() => { @@ -587,7 +589,7 @@ export default { }, methods: { // 手动强制更新页面 - onForceUpdate(bool = false) { + onForceUpdate (bool = false) { this.$forceUpdate() // bool为true时再执行一次 $forceUpdate, 特殊情况下需执行两次,原因如下: // 第一次执行 $forceUpdate时, 新元素绑定v-decorator无法获取到form.getFieldValue @@ -598,12 +600,12 @@ export default { }, // 切换tab选项卡 - handleTabs(key) { + handleTabs (key) { this.tabKey = key }, // 刷新分类列表 - onReloadCategoryList() { + onReloadCategoryList () { this.isLoading = true GoodsModel.getCategoryList().then(() => { this.isLoading = false @@ -611,7 +613,7 @@ export default { }, // 刷新服务与承诺列表 - onReloadServiceList() { + onReloadServiceList () { this.isLoading = true GoodsModel.getServiceList().then(() => { this.isLoading = false @@ -619,7 +621,7 @@ export default { }, // 刷新配送模板列表 - onReloadDeliveryList() { + onReloadDeliveryList () { this.isLoading = true GoodsModel.getDeliveryList().then(() => { this.isLoading = false @@ -627,12 +629,12 @@ export default { }, // 确认按钮 - handleSubmit(e) { + handleSubmit (e) { e.preventDefault() // 表单验证 const { form: { validateFields }, - ruleList, + ruleList } = this validateFields((errors, values) => { // 定位到错误的tab选项卡 @@ -661,14 +663,14 @@ export default { }, // 定位到错误的tab选项卡 - onTargetTabError(errors) { + onTargetTabError (errors) { // 表单字段与tabKey对应关系 // 只需要必填字段就可 const tabsFieldsMap = [ ['goods_type', 'goods_name', 'categorys', 'imagesIds', 'delivery_id', 'is_ind_delivery_type', 'delivery_type'], ['spec_type', 'goods_price', 'is_restrict', 'restrict_total', 'restrict_single'], ['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) { @@ -680,7 +682,7 @@ export default { }, // 提交到后端api - onFormSubmit(values) { + onFormSubmit (values) { this.isLoading = true this.isBtnLoading = true GoodsApi.add({ form: values }) @@ -698,7 +700,7 @@ export default { .finally(() => (this.isLoading = false)) }, // 新增记录 - handleAdd() { + handleAdd () { const index = this.ruleList.length const newItem = { ...defaultItem, key: index } // 排除的城市id集(已存在的城市id集) @@ -712,7 +714,7 @@ export default { }, // 编辑记录 - handleEdit(index, item) { + handleEdit (index, item) { // 排除的城市id集(已存在的城市id集) const excludedCityIds = this.getExcludedCityIds() // 显示选择地区对话框 @@ -720,9 +722,9 @@ export default { }, // 选择地区后的回调 - handleAreaSubmit(result) { + handleAreaSubmit (result) { const { - custom: { scene, item }, + custom: { scene, item } } = result item.region = result.selectedCityIds item.region_text = result.selectedText @@ -732,7 +734,7 @@ export default { }, // 排除的城市id集(已存在的城市id集) - getExcludedCityIds() { + getExcludedCityIds () { const excludedCityIds = [] this.ruleList.forEach((item) => { item.region.forEach((cityId) => { @@ -743,22 +745,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() - }, + } }) - }, - }, + } + } }