From 3ac279c9df7181c9f21d35a689a321b990b87b22 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 08 六月 2026 17:42:33 +0800
Subject: [PATCH] aaa
---
company_admin/src/components/business/OperaGoodsWindow.vue | 115 +++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 94 insertions(+), 21 deletions(-)
diff --git a/company_admin/src/components/business/OperaGoodsWindow.vue b/company_admin/src/components/business/OperaGoodsWindow.vue
index e22ce7f..3c9b085 100644
--- a/company_admin/src/components/business/OperaGoodsWindow.vue
+++ b/company_admin/src/components/business/OperaGoodsWindow.vue
@@ -11,7 +11,7 @@
<el-input v-model="form.name" maxlength="50" placeholder="璇疯緭鍏ュ晢鍝佸悕绉帮紝涓嶈秴杩�50涓瓧" v-trim/>
</el-form-item>
<el-form-item label="鍟嗗搧鍝佺墝" prop="brandId">
- <el-select v-model="form.brandId" placeholder="璇烽�夋嫨锛屽崟閫�">
+ <el-select v-model="form.brandId" filterable placeholder="璇烽�夋嫨锛屽崟閫�">
<el-option
v-for="item in brandList"
:key="item.id"
@@ -21,8 +21,7 @@
</el-select>
</el-form-item>
<el-form-item label="鍟嗗搧绫诲埆" prop="categoryId">
- <!-- @change="changeCategory(form.categoryId)" -->
- <el-select v-model="form.categoryId" placeholder="璇烽�夋嫨锛屽崟閫�">
+ <el-select v-model="form.categoryId" filterable placeholder="璇烽�夋嫨涓�绾х被鍒�" @change="onCategoryChange">
<el-option
v-for="item in categoryList"
:key="item.id"
@@ -31,7 +30,17 @@
</el-option>
</el-select>
</el-form-item>
- <el-form-item :label="name1" prop="attrFirstIds" v-if="name1">
+ <el-form-item label="浜岀骇绫诲埆">
+ <el-select v-model="form.subCategoryId" clearable filterable placeholder="鍙�夛紝璇烽�夋嫨浜岀骇绫诲埆">
+ <el-option
+ v-for="item in subCategoryList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <!-- <el-form-item :label="name1" prop="attrFirstIds" v-if="name1">
<el-select v-model="form.attrFirstIds" multiple placeholder="璇烽�夋嫨锛屾敮鎸佸閫�">
<el-option
v-for="item in form.attrFirstList"
@@ -50,7 +59,7 @@
:value="item.id">
</el-option>
</el-select>
- </el-form-item>
+ </el-form-item> -->
<el-form-item label="鎸囧浠凤紙鍏冿級" prop="zdPrice">
<el-input v-model="form.zdPrice" @input="priceCHANEG(form.zdPrice, 1)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓" v-trim/>
</el-form-item>
@@ -61,7 +70,7 @@
<el-upload
:action="action"
:file-list="form.ztList"
- :data="{ folder: 'projects' }"
+ :data="{ folder: 'goods_img' }"
list-type="picture-card"
:limit="1"
:on-success="fileSuccess"
@@ -76,7 +85,7 @@
:action="action"
:file-list="form.files"
:multiple="true"
- :data="{ folder: 'projects' }"
+ :data="{ folder: 'goods_img' }"
list-type="picture-card"
:on-success="fileSuccess1"
:on-remove="handleRemove1">
@@ -84,10 +93,12 @@
<div slot="tip" class="el-upload__tip">鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�600*600px</div>
</el-upload>
</el-form-item>
- <div style="font-size: 18px;font-weight: bold;">鍙傛暟灞炴�у�奸厤缃� <span style="font-size: 13px; font-weight: 500;">鎸夐渶閰嶇疆褰撳墠鍟嗗搧鐨勪骇鍝佸弬鏁板�硷紝鍗曚釜鍙傛暟鍊间笉瓒呰繃30涓瓧</span></div>
- <el-form-item :label="item.name" v-for="(item, index) in form.goodsParamList" :key="index">
- <el-input v-model="item.val" maxlength="30" type="text" placeholder="璇疯緭鍏�" v-trim/>
- </el-form-item>
+ <template v-if="form.goodsParamList && form.goodsParamList.length > 0">
+ <div style="font-size: 18px;font-weight: bold;">鍙傛暟灞炴�у�奸厤缃� <span style="font-size: 13px; font-weight: 500;">鎸夐渶閰嶇疆褰撳墠鍟嗗搧鐨勪骇鍝佸弬鏁板�硷紝鍗曚釜鍙傛暟鍊间笉瓒呰繃30涓瓧</span></div>
+ <el-form-item :label="item.name" v-for="(item, index) in form.goodsParamList" :key="index">
+ <el-input v-model="item.val" maxlength="30" type="text" placeholder="璇疯緭鍏�" v-trim/>
+ </el-form-item>
+ </template>
</el-form>
</GlobalWindow>
</template>
@@ -96,14 +107,15 @@
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { brand } from '@/api/system/common.js'
- import { findListForGoodsId, create, updateById } from '@/api/business/goods.js'
+ import { findListForGoodsId, create, updateById, companyCreate, companyUpdateById } from '@/api/business/goods.js'
+ import { fetchChildren } from '@/api/business/category.js'
export default {
name: 'OperaGoodsWindow',
extends: BaseOpera,
components: { GlobalWindow },
data () {
return {
- action: process.env.VUE_APP_API_PREFIX + '/public/uploadLocal',
+ action: process.env.VUE_APP_API_PREFIX + '/public/upload',
name1: '',
name2: '',
// 琛ㄥ崟鏁版嵁
@@ -111,6 +123,7 @@
id: null,
name: '',
categoryId: '',
+ subCategoryId: '',
brandId: '',
zdPrice: '',
price: '',
@@ -146,6 +159,7 @@
},
options: [],
categoryList: [],
+ subCategoryList: [],
brandList: []
}
},
@@ -195,6 +209,7 @@
id: null,
name: '',
categoryId: '',
+ subCategoryId: '',
brandId: '',
zdPrice: '',
price: '',
@@ -215,6 +230,45 @@
}
},
methods: {
+ open (title, target) {
+ this.title = title
+ this.visible = true
+ if (target == null) {
+ this.$nextTick(() => {
+ this.$refs.form.resetFields()
+ this.form[this.configData['field.id']] = null
+ this.subCategoryList = []
+ })
+ return
+ }
+ this.$nextTick(() => {
+ for (const key in this.form) {
+ this.form[key] = target[key]
+ }
+ this.loadSubCategoryOptions()
+ })
+ },
+ buildSubmitPayload () {
+ const payload = { ...this.form, type: 0 }
+ if (payload.subCategoryId === '' || payload.subCategoryId == null) {
+ payload.subCategoryId = null
+ } else {
+ payload.subCategoryId = Number(payload.subCategoryId)
+ }
+ return payload
+ },
+ loadSubCategoryOptions () {
+ if (!this.form.categoryId) {
+ this.subCategoryList = []
+ return
+ }
+ fetchChildren(this.form.categoryId).then(res => {
+ this.subCategoryList = res || []
+ if (this.form.subCategoryId !== '' && this.form.subCategoryId != null) {
+ this.form.subCategoryId = Number(this.form.subCategoryId)
+ }
+ })
+ },
priceCHANEG(val, type) {
if (!/^[1-9]+[0-9]*$/.test(val)) {
this.$message.warning('鍙兘杈撳叆姝f暣鏁�')
@@ -259,7 +313,8 @@
this.form.attrSecodIds = ''
}
if (!this.form.id) {
- create(this.form)
+ const payload = this.buildSubmitPayload()
+ companyCreate(payload)
.then(() => {
this.visible = false
this.$tip.apiSuccess('鏂板缓鎴愬姛')
@@ -272,7 +327,7 @@
this.isWorking = false
})
} else {
- updateById(this.form)
+ companyUpdateById(this.buildSubmitPayload())
.then(() => {
this.visible = false
this.$tip.apiSuccess('缂栬緫鎴愬姛')
@@ -295,13 +350,22 @@
message: '鍙兘涓婁紶涓�涓浘鏍�'
})
},
+ initMuitlFiles (fileList) {
+ const list = [];
+ fileList.forEach(rawFile => {
+ list.push({ fileurl: rawFile.response.data.imgaddr, name: rawFile.response.data.imgname, url: rawFile.response.data.url })
+ });
+ return list;
+ },
fileSuccess1(response, file, fileList) {
this.form.files = fileList
- this.form.multifileList.push({ fileurl: response.data.imgaddr, name: response.data.imgname, url: response.data.url })
+ // this.form.multifileList.push({ fileurl: response.data.imgaddr, name: response.data.imgname, url: response.data.url })
+ this.form.multifileList=this.initMuitlFiles(fileList);
},
handleRemove1(file, fileList) {
this.form.files = fileList
- this.form.multifileList = fileList
+ // this.form.multifileList = fileList
+ this.form.multifileList=this.initMuitlFiles(fileList);
},
fileSuccess(response) {
this.form.ztList.push({ imgaddr: response.data.imgaddr, url: response.data.url })
@@ -317,18 +381,27 @@
this.brandList = res
})
},
+ onCategoryChange (val) {
+ this.form.subCategoryId = ''
+ this.subCategoryList = []
+ if (val) {
+ fetchChildren(val).then(res => {
+ this.subCategoryList = res || []
+ })
+ }
+ },
getcategory(type) {
findListForGoodsId(this.form.id || '')
.then(res => {
- this.categoryList = res
+ this.categoryList = (res || []).filter(item => !item.parentId)
+ this.loadSubCategoryOptions()
if (type === 1) {
this.categoryList.forEach(item => {
if (item.id === this.form.categoryId) {
this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList))
- this.form.goodsParamList.forEach(item => {
- item.pramaId = item.id
+ this.form.goodsParamList.forEach(p => {
+ p.pramaId = p.id
})
- console.log(this.form.goodsParamList)
}
})
}
--
Gitblit v1.9.3