| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="商品类别" prop="categoryId"> |
| | | <!-- @change="changeCategory(form.categoryId)" --> |
| | | <el-select v-model="form.categoryId" filterable placeholder="请选择,单选"> |
| | | <el-select v-model="form.categoryId" filterable placeholder="请选择一级类别" @change="onCategoryChange"> |
| | | <el-option |
| | | v-for="item in categoryList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <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"> |
| | |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { brand } from '@/api/system/common.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, |
| | |
| | | id: null, |
| | | name: '', |
| | | categoryId: '', |
| | | subCategoryId: '', |
| | | brandId: '', |
| | | zdPrice: '', |
| | | price: '', |
| | |
| | | }, |
| | | options: [], |
| | | categoryList: [], |
| | | subCategoryList: [], |
| | | brandList: [] |
| | | } |
| | | }, |
| | |
| | | id: null, |
| | | name: '', |
| | | categoryId: '', |
| | | subCategoryId: '', |
| | | brandId: '', |
| | | zdPrice: '', |
| | | price: '', |
| | |
| | | } |
| | | }, |
| | | 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('只能输入正整数') |
| | |
| | | this.form.attrSecodIds = '' |
| | | } |
| | | if (!this.form.id) { |
| | | companyCreate({...this.form, type: 0}) |
| | | const payload = this.buildSubmitPayload() |
| | | companyCreate(payload) |
| | | .then(() => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('新建成功') |
| | |
| | | this.isWorking = false |
| | | }) |
| | | } else { |
| | | companyUpdateById({...this.form, type: 0}) |
| | | companyUpdateById(this.buildSubmitPayload()) |
| | | .then(() => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('编辑成功') |
| | |
| | | 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 }) |
| | |
| | | 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) |
| | | } |
| | | }) |
| | | } |