| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | > |
| | | <el-form :model="form" ref="form" :rules="rules"> |
| | | <div style="font-size: 18px;font-weight: bold;">åºæ¬ä¿¡æ¯</div> |
| | | <el-form-item label="åååç§°" prop="name"> |
| | | <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-option |
| | | v-for="item in brandList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="ååç±»å«" prop="categoryId"> |
| | | <!-- @change="changeCategory(form.categoryId)" --> |
| | | <el-select v-model="form.categoryId" placeholder="è¯·éæ©ï¼åé"> |
| | | <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="name1" prop="attrFirstIds" v-if="name1"> |
| | | <el-select v-model="form.attrFirstIds" multiple placeholder="è¯·éæ©ï¼æ¯æå¤é"> |
| | | <el-option |
| | | v-for="item in form.attrFirstList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item :label="name2" prop="attrSecodIds" v-if="name2"> |
| | | <el-select v-model="form.attrSecodIds" multiple placeholder="è¯·éæ©ï¼æ¯æå¤é"> |
| | | <el-option |
| | | v-for="item in form.attrSecodList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </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> |
| | | <el-form-item label="å
¥æä»·ï¼å
ï¼" prop="price"> |
| | | <el-input v-model="form.price" @input="priceCHANEG(form.price, 2)" type="number" placeholder="建议å½å
¥æ´æ°ï¼åä½å
" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="åå主å¾"> |
| | | <el-upload |
| | | :action="action" |
| | | :file-list="form.ztList" |
| | | :data="{ folder: 'projects' }" |
| | | list-type="picture-card" |
| | | :limit="1" |
| | | :on-success="fileSuccess" |
| | | :on-exceed="exceed" |
| | | :on-remove="handleRemove"> |
| | | <i class="el-icon-plus"></i> |
| | | <div slot="tip" class="el-upload__tip">åªè½ä¸ä¼ å¾çæ ¼å¼ï¼pngæ ¼å¼ï¼å»ºè®®å°ºå¯¸140*140px</div> |
| | | </el-upload> |
| | | </el-form-item> |
| | | <el-form-item label="ååå¾ç"> |
| | | <el-upload |
| | | :action="action" |
| | | :file-list="form.files" |
| | | :multiple="true" |
| | | :data="{ folder: 'projects' }" |
| | | list-type="picture-card" |
| | | :on-success="fileSuccess1" |
| | | :on-remove="handleRemove1"> |
| | | <i class="el-icon-plus"></i> |
| | | <div slot="tip" class="el-upload__tip">åªè½ä¸ä¼ å¾çæ ¼å¼ï¼pngæ ¼å¼ï¼å»ºè®®å°ºå¯¸600*600px</div> |
| | | </el-upload> |
| | | </el-form-item> |
| | | <GlobalWindow |
| | | :title="title" |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | width="800px" |
| | | > |
| | | <el-form :model="form" ref="form" label-width="120px" :rules="rules"> |
| | | <div style="font-size: 18px;font-weight: bold;">åºæ¬ä¿¡æ¯</div> |
| | | <el-form-item label="åååç§°" prop="name"> |
| | | <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-option |
| | | v-for="item in brandList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="ååç±»å«" prop="categoryId"> |
| | | <!-- @change="changeCategory(form.categoryId)" --> |
| | | <el-select v-model="form.categoryId" placeholder="è¯·éæ©ï¼åé"> |
| | | <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="name1" prop="attrFirstIds" v-if="name1"> |
| | | <el-select v-model="form.attrFirstIds" multiple placeholder="è¯·éæ©ï¼æ¯æå¤é"> |
| | | <el-option |
| | | v-for="item in form.attrFirstList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item :label="name2" prop="attrSecodIds" v-if="name2"> |
| | | <el-select v-model="form.attrSecodIds" multiple placeholder="è¯·éæ©ï¼æ¯æå¤é"> |
| | | <el-option |
| | | v-for="item in form.attrSecodList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </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> |
| | | <el-form-item label="å
¥æä»·ï¼å
ï¼" prop="price"> |
| | | <el-input v-model="form.price" @input="priceCHANEG(form.price, 2)" type="number" placeholder="建议å½å
¥æ´æ°ï¼åä½å
" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="åå主å¾"> |
| | | <el-upload |
| | | :action="action" |
| | | :file-list="form.ztList" |
| | | :data="{ folder: 'goods_img' }" |
| | | list-type="picture-card" |
| | | :limit="1" |
| | | :on-success="fileSuccess" |
| | | :on-exceed="exceed" |
| | | :on-remove="handleRemove"> |
| | | <i class="el-icon-plus"></i> |
| | | <div slot="tip" class="el-upload__tip">åªè½ä¸ä¼ å¾çæ ¼å¼ï¼pngæ ¼å¼ï¼å»ºè®®å°ºå¯¸140*140px</div> |
| | | </el-upload> |
| | | </el-form-item> |
| | | <el-form-item label="ååå¾ç"> |
| | | <el-upload |
| | | :action="action" |
| | | :file-list="form.files" |
| | | :multiple="true" |
| | | :data="{ folder: 'goods_img' }" |
| | | list-type="picture-card" |
| | | :on-success="fileSuccess1" |
| | | :on-remove="handleRemove1"> |
| | | <i class="el-icon-plus"></i> |
| | | <div slot="tip" class="el-upload__tip">åªè½ä¸ä¼ å¾çæ ¼å¼ï¼pngæ ¼å¼ï¼å»ºè®®å°ºå¯¸600*600px</div> |
| | | </el-upload> |
| | | </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> |
| | | </el-form> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | 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' |
| | | export default { |
| | | name: 'OperaGoodsWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | action: process.env.VUE_APP_API_PREFIX + '/public/uploadLocal', |
| | | name1: '', |
| | | name2: '', |
| | | // è¡¨åæ°æ® |
| | | form: { |
| | | id: null, |
| | | name: '', |
| | | categoryId: '', |
| | | brandId: '', |
| | | zdPrice: '', |
| | | price: '', |
| | | attrFirstIds: [], |
| | | attrFirstNames: '', |
| | | attrSecodIds: [], |
| | | attrSecodNames: '', |
| | | imgurl: '', |
| | | multifileList: [], |
| | | files: [], |
| | | ztList: [], |
| | | goodsParamList: [], |
| | | attrFirstList: [], |
| | | attrSecodList: [] |
| | | }, |
| | | // éªè¯è§å |
| | | rules: { |
| | | name: [ |
| | | { required: true, message: 'ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ], |
| | | categoryId: [ |
| | | { required: true, message: 'è¯·éæ©', trigger: 'change' } |
| | | ], |
| | | brandId: [ |
| | | { required: true, message: 'è¯·éæ©', trigger: 'change' } |
| | | ], |
| | | zdPrice: [ |
| | | { required: true, message: 'ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ], |
| | | price: [ |
| | | { required: true, message: 'ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ] |
| | | }, |
| | | options: [], |
| | | categoryList: [], |
| | | brandList: [] |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | api: '/business/goods', |
| | | 'field.id': 'id' |
| | | }) |
| | | this.getbrand() |
| | | this.getcategory() |
| | | }, |
| | | watch: { |
| | | 'form.categoryId': { |
| | | immediate: true, |
| | | handler(news, old) { |
| | | if (news) { |
| | | this.name1 = '' |
| | | this.name2 = '' |
| | | if (old) { |
| | | this.form.attrFirstIds = [] |
| | | this.form.attrSecodIds = [] |
| | | this.form.goodsParamList = [] |
| | | } |
| | | this.categoryList.forEach(item => { |
| | | if (item.id === news) { |
| | | this.name1 = item.attrFirst |
| | | this.name2 = item.attrSecond |
| | | this.form.attrFirstList = item.attrFirstList.length > 0 ? item.attrFirstList : [] |
| | | this.form.attrSecodList = item.attrSecondList.length > 0 ? item.attrSecondList : [] |
| | | this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList)) |
| | | this.form.goodsParamList.forEach(item => { |
| | | item.pramaId = item.id |
| | | }) |
| | | console.log(this.form.goodsParamList) |
| | | } |
| | | }) |
| | | this.getcategory(1) |
| | | } |
| | | } |
| | | </template> |
| | | </el-form> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { brand } from '@/api/system/common.js' |
| | | import { findListForGoodsId, create, updateById, companyCreate, companyUpdateById } from '@/api/business/goods.js' |
| | | export default { |
| | | name: 'OperaGoodsWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | action: process.env.VUE_APP_API_PREFIX + '/public/upload', |
| | | name1: '', |
| | | name2: '', |
| | | // è¡¨åæ°æ® |
| | | form: { |
| | | id: null, |
| | | name: '', |
| | | categoryId: '', |
| | | brandId: '', |
| | | zdPrice: '', |
| | | price: '', |
| | | attrFirstIds: [], |
| | | attrFirstNames: '', |
| | | attrSecodIds: [], |
| | | attrSecodNames: '', |
| | | imgurl: '', |
| | | multifileList: [], |
| | | files: [], |
| | | ztList: [], |
| | | goodsParamList: [], |
| | | attrFirstList: [], |
| | | attrSecodList: [] |
| | | }, |
| | | visible: { |
| | | handler(news, old) { |
| | | if (!news) { |
| | | this.name1 = '' |
| | | this.name2 = '' |
| | | this.form = { |
| | | id: null, |
| | | name: '', |
| | | categoryId: '', |
| | | brandId: '', |
| | | zdPrice: '', |
| | | price: '', |
| | | attrFirstIds: [], |
| | | attrFirstNames: '', |
| | | attrSecodIds: [], |
| | | attrSecodNames: '', |
| | | imgurl: '', |
| | | multifileList: [], |
| | | files: [], |
| | | ztList: [], |
| | | goodsParamList: [], |
| | | attrFirstList: [], |
| | | attrSecodList: [] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | priceCHANEG(val, type) { |
| | | if (!/^[1-9]+[0-9]*$/.test(val)) { |
| | | this.$message.warning('åªè½è¾å
¥æ£æ´æ°') |
| | | if (type === 1) { |
| | | this.form.zdPrice = '' |
| | | } else { |
| | | this.form.price = '' |
| | | } |
| | | } |
| | | // éªè¯è§å |
| | | rules: { |
| | | name: [ |
| | | { required: true, message: 'ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ], |
| | | categoryId: [ |
| | | { required: true, message: 'è¯·éæ©', trigger: 'change' } |
| | | ], |
| | | brandId: [ |
| | | { required: true, message: 'è¯·éæ©', trigger: 'change' } |
| | | ], |
| | | zdPrice: [ |
| | | { required: true, message: 'ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ], |
| | | price: [ |
| | | { required: true, message: 'ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ] |
| | | }, |
| | | confirm() { |
| | | this.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | if (this.form.attrFirstIds.length > 0) { |
| | | let arr = [] |
| | | this.form.attrFirstIds.forEach(element => { |
| | | this.form.attrFirstList.forEach(item => { |
| | | if (element === item.id) { |
| | | arr.push(item.name) |
| | | } |
| | | }) |
| | | }) |
| | | this.form.attrFirstNames = arr.join(',') |
| | | this.form.attrFirstIds = this.form.attrFirstIds.join(',') |
| | | } else { |
| | | this.form.attrFirstNames = '' |
| | | this.form.attrFirstIds = '' |
| | | } |
| | | if (this.form.attrSecodIds.length > 0) { |
| | | let arr = [] |
| | | this.form.attrSecodIds.forEach(element => { |
| | | this.form.attrSecodList.forEach(item => { |
| | | if (element === item.id) { |
| | | arr.push(item.name) |
| | | } |
| | | }) |
| | | }) |
| | | this.form.attrSecodNames = arr.join(',') |
| | | this.form.attrSecodIds = this.form.attrSecodIds.join(',') |
| | | } else { |
| | | this.form.attrSecodNames = '' |
| | | this.form.attrSecodIds = '' |
| | | } |
| | | if (!this.form.id) { |
| | | create(this.form) |
| | | .then(() => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('æ°å»ºæå') |
| | | this.$emit('success') |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking = false |
| | | }) |
| | | } else { |
| | | updateById(this.form) |
| | | .then(() => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('ç¼è¾æå') |
| | | this.$emit('success') |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking = false |
| | | }) |
| | | } |
| | | } else { |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | exceed() { |
| | | this.$message.warning({ |
| | | message: 'åªè½ä¸ä¼ ä¸ä¸ªå¾æ ' |
| | | }) |
| | | }, |
| | | fileSuccess1(response, file, fileList) { |
| | | this.form.files = fileList |
| | | this.form.multifileList.push({ fileurl: response.data.imgaddr, name: response.data.imgname, url: response.data.url }) |
| | | }, |
| | | handleRemove1(file, fileList) { |
| | | this.form.files = fileList |
| | | this.form.multifileList = fileList |
| | | }, |
| | | fileSuccess(response) { |
| | | this.form.ztList.push({ imgaddr: response.data.imgaddr, url: response.data.url }) |
| | | this.form.imgurl = response.data.imgaddr |
| | | }, |
| | | handleRemove() { |
| | | this.form.ztList = [] |
| | | this.form.imgurl = '' |
| | | }, |
| | | getbrand() { |
| | | brand({}) |
| | | .then(res => { |
| | | this.brandList = res |
| | | }) |
| | | }, |
| | | getcategory(type) { |
| | | findListForGoodsId(this.form.id || '') |
| | | .then(res => { |
| | | this.categoryList = res |
| | | 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 |
| | | }) |
| | | console.log(this.form.goodsParamList) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | options: [], |
| | | categoryList: [], |
| | | brandList: [] |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | api: '/business/goods', |
| | | 'field.id': 'id' |
| | | }) |
| | | this.getbrand() |
| | | this.getcategory() |
| | | }, |
| | | watch: { |
| | | 'form.categoryId': { |
| | | immediate: true, |
| | | handler(news, old) { |
| | | if (news) { |
| | | this.name1 = '' |
| | | this.name2 = '' |
| | | if (old) { |
| | | this.form.attrFirstIds = [] |
| | | this.form.attrSecodIds = [] |
| | | this.form.goodsParamList = [] |
| | | } |
| | | this.categoryList.forEach(item => { |
| | | if (item.id === news) { |
| | | this.name1 = item.attrFirst |
| | | this.name2 = item.attrSecond |
| | | this.form.attrFirstList = item.attrFirstList.length > 0 ? item.attrFirstList : [] |
| | | this.form.attrSecodList = item.attrSecondList.length > 0 ? item.attrSecondList : [] |
| | | this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList)) |
| | | this.form.goodsParamList.forEach(item => { |
| | | item.pramaId = item.id |
| | | }) |
| | | console.log(this.form.goodsParamList) |
| | | } |
| | | }) |
| | | this.getcategory(1) |
| | | } |
| | | } |
| | | }, |
| | | visible: { |
| | | handler(news, old) { |
| | | if (!news) { |
| | | this.name1 = '' |
| | | this.name2 = '' |
| | | this.form = { |
| | | id: null, |
| | | name: '', |
| | | categoryId: '', |
| | | brandId: '', |
| | | zdPrice: '', |
| | | price: '', |
| | | attrFirstIds: [], |
| | | attrFirstNames: '', |
| | | attrSecodIds: [], |
| | | attrSecodNames: '', |
| | | imgurl: '', |
| | | multifileList: [], |
| | | files: [], |
| | | ztList: [], |
| | | goodsParamList: [], |
| | | attrFirstList: [], |
| | | attrSecodList: [] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | priceCHANEG(val, type) { |
| | | if (!/^[1-9]+[0-9]*$/.test(val)) { |
| | | this.$message.warning('åªè½è¾å
¥æ£æ´æ°') |
| | | if (type === 1) { |
| | | this.form.zdPrice = '' |
| | | } else { |
| | | this.form.price = '' |
| | | } |
| | | } |
| | | }, |
| | | confirm() { |
| | | this.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | if (this.form.attrFirstIds.length > 0) { |
| | | let arr = [] |
| | | this.form.attrFirstIds.forEach(element => { |
| | | this.form.attrFirstList.forEach(item => { |
| | | if (element === item.id) { |
| | | arr.push(item.name) |
| | | } |
| | | }) |
| | | }) |
| | | this.form.attrFirstNames = arr.join(',') |
| | | this.form.attrFirstIds = this.form.attrFirstIds.join(',') |
| | | } else { |
| | | this.form.attrFirstNames = '' |
| | | this.form.attrFirstIds = '' |
| | | } |
| | | if (this.form.attrSecodIds.length > 0) { |
| | | let arr = [] |
| | | this.form.attrSecodIds.forEach(element => { |
| | | this.form.attrSecodList.forEach(item => { |
| | | if (element === item.id) { |
| | | arr.push(item.name) |
| | | } |
| | | }) |
| | | }) |
| | | this.form.attrSecodNames = arr.join(',') |
| | | this.form.attrSecodIds = this.form.attrSecodIds.join(',') |
| | | } else { |
| | | this.form.attrSecodNames = '' |
| | | this.form.attrSecodIds = '' |
| | | } |
| | | if (!this.form.id) { |
| | | companyCreate({...this.form, type: 0}) |
| | | .then(() => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('æ°å»ºæå') |
| | | this.$emit('success') |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking = false |
| | | }) |
| | | } else { |
| | | companyUpdateById({...this.form, type: 0}) |
| | | .then(() => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('ç¼è¾æå') |
| | | this.$emit('success') |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking = false |
| | | }) |
| | | } |
| | | } else { |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | exceed() { |
| | | this.$message.warning({ |
| | | message: 'åªè½ä¸ä¼ ä¸ä¸ªå¾æ ' |
| | | }) |
| | | }, |
| | | fileSuccess1(response, file, fileList) { |
| | | this.form.files = fileList |
| | | this.form.multifileList.push({ fileurl: response.data.imgaddr, name: response.data.imgname, url: response.data.url }) |
| | | }, |
| | | handleRemove1(file, fileList) { |
| | | this.form.files = fileList |
| | | this.form.multifileList = fileList |
| | | }, |
| | | fileSuccess(response) { |
| | | this.form.ztList.push({ imgaddr: response.data.imgaddr, url: response.data.url }) |
| | | this.form.imgurl = response.data.imgaddr |
| | | }, |
| | | handleRemove() { |
| | | this.form.ztList = [] |
| | | this.form.imgurl = '' |
| | | }, |
| | | getbrand() { |
| | | brand({}) |
| | | .then(res => { |
| | | this.brandList = res |
| | | }) |
| | | }, |
| | | getcategory(type) { |
| | | findListForGoodsId(this.form.id || '') |
| | | .then(res => { |
| | | this.categoryList = res |
| | | 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 |
| | | }) |
| | | console.log(this.form.goodsParamList) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | ::v-deep .el-form-item__content { |
| | | .el-input { |
| | | width: 400px; |
| | | } |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow :title="title" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm"> |
| | | <el-form :model="form" ref="form" :rules="rules"> |
| | | <el-form-item label="ååç±»å«" prop="categoryId"> |
| | | <el-select v-model="form.categoryId" placeholder="è¯·éæ©"> |
| | | <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="ååèå´" prop="type"> |
| | | <el-radio-group v-model="form.type"> |
| | | <el-radio :label="0">å
¨é¨</el-radio> |
| | | <el-radio :label="1">é¨å</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="å ä»·ç³»æ°" prop="rate"> |
| | | <el-input v-model="form.rate" placeholder="å¹³å°éè´ä»·*å ä»·ç³»æ°ï¼ä½ä¸ºåèåºæä»·ï¼å»ºè®®è¾å
¥å¤§äº1çæ°å" v-trim /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <!-- 鿩平å°åå --> |
| | | <selectProductItem ref="selectProductItem" @result="result" /> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import selectProductItem from '@/components/business/selectProductItem' |
| | | import { baseCategoryList } from '@/api/business/category.js' |
| | | import { createPlat } from '@/api/business/goods' |
| | | |
| | | export default { |
| | | name: 'OperaBrandWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow, selectProductItem }, |
| | | data() { |
| | | return { |
| | | categoryList: [], |
| | | // è¡¨åæ°æ® |
| | | form: { |
| | | categoryId: '', |
| | | type: 0, |
| | | rate: '' |
| | | }, |
| | | // éªè¯è§å |
| | | rules: { |
| | | categoryId: [ |
| | | { required: true, message: 'ååç±»å«ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ], |
| | | type: [ |
| | | { required: true, message: 'ååèå´ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ], |
| | | rate: [ |
| | | { required: true, message: 'å ä»·ç³»æ°ä¸è½ä¸ºç©º', trigger: 'blur' } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | this.config({ |
| | | api: '/business/anchor', |
| | | 'field.id': 'id' |
| | | }) |
| | | }, |
| | | methods: { |
| | | result() { |
| | | // this.$emit('success') |
| | | this.$emit('result') |
| | | this.visible = false |
| | | }, |
| | | confirm() { |
| | | this.$refs.form.validate((valid) => { |
| | | if (!valid) return |
| | | // æ°å»º |
| | | if (this.form.type == 0) { |
| | | this.isWorking = true |
| | | createPlat({ |
| | | categoryId: this.form.categoryId, |
| | | rate: this.form.rate, |
| | | type: this.form.type |
| | | }).then(res => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('æä½æå') |
| | | // this.$emit('success') |
| | | this.$emit('result') |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking = false |
| | | }) |
| | | } else { |
| | | this.$refs.selectProductItem.open('鿩平å°åå', this.form) |
| | | } |
| | | }) |
| | | }, |
| | | /** |
| | | * æå¼çªå£ |
| | | * @title çªå£æ é¢ |
| | | * @target ç¼è¾ç对象 |
| | | */ |
| | | open (title, target) { |
| | | this.title = title |
| | | this.visible = true |
| | | // è·ååç±»å表 |
| | | baseCategoryList({ type: 1 }) |
| | | .then(res => { |
| | | this.categoryList = res |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow :title="title" width="70%" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm"> |
| | | <div class="head"> |
| | | <el-form :inline="true" :model="form" class="demo-form-inline"> |
| | | <el-form-item label="åååç§°" prop="name"> |
| | | <el-input v-model="form.name" placeholder="请è¾å
¥åååç§°"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ç±»å«" prop="categoryId"> |
| | | <el-select v-model="form.categoryId" disabled placeholder="è¯·éæ©"> |
| | | <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> |
| | | <el-button type="primary" @click="getList">æ¥è¯¢</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <div class="tab"> |
| | | <el-table |
| | | :data="tableData" |
| | | stripe |
| | | border |
| | | @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="id" label="ååID" min-width="100px"></el-table-column> |
| | | <el-table-column prop="name" label="åååç§°/åå·" show-overflow-tooltip min-width="200px"> |
| | | <template slot-scope="{row}"> |
| | | <div style="display: flex; align-items: center;"> |
| | | <div style="width: 70px; height: 70px; flex-shrink: 0;"> |
| | | <el-image |
| | | v-if="row.imgurl" |
| | | style="width: 70px; height: 70px" |
| | | :src="row.fullImgUrl" |
| | | fit="cover"></el-image> |
| | | </div> |
| | | {{ row.name }} |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="brandName" label="åç" show-overflow-tooltip min-width="100px"></el-table-column> |
| | | <el-table-column prop="categoryName" label="ç±»å«" show-overflow-tooltip min-width="100px"></el-table-column> |
| | | <el-table-column prop="zdPrice" label="æå¯¼ä»·ï¼å
ï¼" show-overflow-tooltip min-width="100px"></el-table-column> |
| | | <el-table-column prop="price" label="éè´ä»·ï¼å
ï¼" show-overflow-tooltip min-width="100px"></el-table-column> |
| | | <el-table-column label="å
¥æä»·ï¼å
ï¼" show-overflow-tooltip min-width="100px"> |
| | | <template slot-scope="{row}"> |
| | | <el-input v-model="row.purchasePrice" placeholder="请è¾å
¥"></el-input> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | :current-page="page" |
| | | :page-sizes="[10, 20, 30]" |
| | | :page-size="pageSize" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="total"> |
| | | </el-pagination> |
| | | </div> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { baseCategoryList } from '@/api/business/category.js' |
| | | import { pageT } from '@/api/business/goods' |
| | | import { createPlat } from '@/api/business/goods' |
| | | |
| | | export default { |
| | | name: 'OperaBrandWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | data() { |
| | | return { |
| | | // è¡¨åæ°æ® |
| | | form: { |
| | | categoryId: '', |
| | | type: 0, |
| | | rate: '', |
| | | name: '', |
| | | goodsParamList: [] |
| | | }, |
| | | pageSize: 10, |
| | | page: 1, |
| | | total: 0, |
| | | tableData: [], |
| | | categoryList: [] |
| | | } |
| | | }, |
| | | created() { |
| | | this.config({ |
| | | api: '/business/anchor', |
| | | 'field.id': 'id' |
| | | }) |
| | | }, |
| | | methods: { |
| | | getList() { |
| | | pageT({ |
| | | capacity: this.pageSize, |
| | | model: { |
| | | categoryId: this.form.categoryId, |
| | | name: this.form.name |
| | | }, |
| | | page: this.page |
| | | }).then(res => { |
| | | res.records.forEach(item => { |
| | | item.purchasePrice = item.price * this.form.rate |
| | | }) |
| | | this.tableData = res.records |
| | | this.total = res.total |
| | | }) |
| | | }, |
| | | handleCurrentChange(e) { |
| | | this.page = e |
| | | this.getList() |
| | | }, |
| | | handleSizeChange(e) { |
| | | this.pageSize = e |
| | | this.getList() |
| | | }, |
| | | handleSelectionChange(e) { |
| | | let arr = [] |
| | | e.forEach(item => { |
| | | arr.push({ goodsId: item.id, price: item.purchasePrice }) |
| | | }) |
| | | this.form.goodsParamList = arr |
| | | console.log(arr) |
| | | }, |
| | | confirm() { |
| | | // è°ç¨æ°å»ºæ¥å£ |
| | | this.isWorking = true |
| | | createPlat({ |
| | | categoryId: this.form.categoryId, |
| | | goodsParamList: this.form.goodsParamList, |
| | | rate: this.form.rate, |
| | | type: this.form.type |
| | | }).then(res => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('æä½æå') |
| | | // this.$emit('success') |
| | | this.$emit('result') |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking = false |
| | | }) |
| | | }, |
| | | /** |
| | | * æå¼çªå£ |
| | | * @title çªå£æ é¢ |
| | | * @target ç¼è¾ç对象 |
| | | */ |
| | | open(title, target) { |
| | | this.title = title |
| | | this.visible = true |
| | | this.form.categoryId = target.categoryId |
| | | this.form.rate = Number(target.rate) |
| | | this.form.type = target.type |
| | | // è·ååç±»å表 |
| | | baseCategoryList({}) |
| | | .then(res => { |
| | | this.categoryList = res |
| | | }) |
| | | this.getList() |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .head { |
| | | width: 100%; |
| | | |
| | | } |
| | | </style> |
| | |
| | | |
| | | <template> |
| | | <TableLayout :permissions="['business:goods:query']"> |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> |
| | | <el-form-item label="åååç§°" prop="name"> |
| | | <el-input v-model="searchForm.name" placeholder="请è¾å
¥åååç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ååID" prop="id"> |
| | | <el-input v-model="searchForm.id" placeholder="请è¾å
¥ååID" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ç±»å«" prop="categoryId"> |
| | | <el-select v-model="searchForm.categoryId" clearable placeholder="è¯·éæ©"> |
| | | <el-option |
| | | v-for="item in categoryList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.categoryId" placeholder="请è¾å
¥æå±åç±»ç¼ç " @keypress.enter.native="search"></el-input> --> |
| | | </el-form-item> |
| | | <el-form-item label="åç" prop="brandId"> |
| | | <el-select v-model="searchForm.brandId" clearable placeholder="è¯·éæ©"> |
| | | <el-option |
| | | v-for="item in brandList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.brandId" placeholder="请è¾å
¥æå±åçç¼ç " @keypress.enter.native="search"></el-input> --> |
| | | </el-form-item> |
| | | <el-form-item label="ç¶æ" prop="status"> |
| | | <el-select v-model="searchForm.status" clearable placeholder="è¯·éæ©"> |
| | | <el-option |
| | | v-for="item in statusList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.status" placeholder="请è¾å
¥ç¶æ 0å¯ç¨ 1ç¦ç¨" @keypress.enter.native="search"></el-input> --> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">æç´¢</el-button> |
| | | |
| | | <el-button @click="reset">éç½®</el-button> |
| | | </section> |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <ul class="toolbar" v-permissions="['business:goods:create', 'business:goods:delete']"> |
| | | <li><el-button type="primary" @click="$refs.operaGoodsWindow.open('æ°å»ºåå')" icon="el-icon-plus" v-permissions="['business:goods:create']">æ°å»º</el-button></li> |
| | | <el-button type="primary" :loading="isWorking.export" v-permissions="['business:goods:exportExcel']" @click="importFile">导å
¥</el-button> |
| | | <el-button type="primary" :loading="isWorking.export" @click="downloadFile">ä¸è½½æ¨¡æ¿</el-button> |
| | | <!-- <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:goods:delete']">å é¤</el-button></li> --> |
| | | </ul> |
| | | <el-table |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | | border |
| | | :header-cell-style="rowStyle" |
| | | :cell-style="rowStyle" |
| | | > |
| | | <el-table-column prop="id" label="ååID" min-width="100px"></el-table-column> |
| | | <el-table-column prop="name" label="åååç§°/åå·" min-width="200px"> |
| | | <template slot-scope="{row}"> |
| | | <div style="display: flex; align-items: center;"> |
| | | <div style="width: 70px; height: 70px; flex-shrink: 0;"> |
| | | <el-image |
| | | v-if="row.imgurl" |
| | | style="width: 70px; height: 70px" |
| | | :src="row.prefixUrl + row.imgurl" |
| | | :preview-src-list="[row.prefixUrl + row.imgurl]" |
| | | fit="cover"></el-image> |
| | | </div> |
| | | {{ row.name }} |
| | | <TableLayout :permissions="['business:goods:query']"> |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> |
| | | <el-form-item label="åååç§°" prop="name"> |
| | | <el-input v-model="searchForm.name" placeholder="请è¾å
¥åååç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ååID" prop="id"> |
| | | <el-input v-model="searchForm.id" placeholder="请è¾å
¥ååID" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ç±»å«" prop="categoryId"> |
| | | <el-select v-model="searchForm.categoryId" clearable placeholder="è¯·éæ©"> |
| | | <el-option v-for="item in categoryList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.categoryId" placeholder="请è¾å
¥æå±åç±»ç¼ç " @keypress.enter.native="search"></el-input> --> |
| | | </el-form-item> |
| | | <el-form-item label="åç" prop="brandId"> |
| | | <el-select v-model="searchForm.brandId" clearable placeholder="è¯·éæ©"> |
| | | <el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.brandId" placeholder="请è¾å
¥æå±åçç¼ç " @keypress.enter.native="search"></el-input> --> |
| | | </el-form-item> |
| | | <el-form-item label="ç¶æ" prop="status"> |
| | | <el-select v-model="searchForm.status" clearable placeholder="è¯·éæ©"> |
| | | <el-option v-for="item in statusList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.status" placeholder="请è¾å
¥ç¶æ 0å¯ç¨ 1ç¦ç¨" @keypress.enter.native="search"></el-input> --> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">æç´¢</el-button> |
| | | <el-button @click="reset">éç½®</el-button> |
| | | </section> |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <ul class="toolbar" v-permissions="['business:goods:create', 'business:goods:delete']"> |
| | | <li><el-button type="primary" @click="$refs.operaGoodsWindow.open('æ°å»ºåå')" icon="el-icon-plus" |
| | | v-permissions="['business:goods:create']">æ°å»º</el-button></li> |
| | | <!-- <el-button type="primary" :loading="isWorking.export" |
| | | @click="$refs.selectProduct.open('鿩平å°åå')">鿩平å°åå</el-button> --> |
| | | <el-button type="primary" :loading="isWorking.export" v-permissions="['business:goods:exportExcel']" |
| | | @click="importFile">导å
¥</el-button> |
| | | <el-button type="primary" :loading="isWorking.export" @click="downloadFile">ä¸è½½æ¨¡æ¿</el-button> |
| | | |
| | | <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(0)">æ¹é䏿¶</el-button> |
| | | <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(1)">æ¹é䏿¶</el-button> |
| | | <!-- <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:goods:delete']">å é¤</el-button></li> --> |
| | | </ul> |
| | | <el-table v-loading="isWorking.search" :data="tableData.list" stripe border :header-cell-style="rowStyle" |
| | | :cell-style="rowStyle" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="id" label="ååID" min-width="100px"></el-table-column> |
| | | <el-table-column prop="name" label="åååç§°/åå·" min-width="200px"> |
| | | <template slot-scope="{row}"> |
| | | <div style="display: flex; align-items: center;"> |
| | | <div style="width: 70px; height: 70px; flex-shrink: 0;"> |
| | | <el-image v-if="row.imgurl" style="width: 70px; height: 70px" :src="row.prefixUrl + row.imgurl" |
| | | :preview-src-list="[row.prefixUrl + row.imgurl]" fit="cover"></el-image> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="brandName" label="åç" min-width="100px"></el-table-column> |
| | | <el-table-column prop="categoryName" label="ç±»å«" min-width="100px"></el-table-column> |
| | | <el-table-column prop="attrFirstNames" label="屿§1" min-width="100px"></el-table-column> |
| | | <el-table-column prop="attrSecodNames" label="屿§2" min-width="100px"></el-table-column> |
| | | <el-table-column prop="zdPrice" label="æå¯¼ä»·ï¼å
ï¼" min-width="100px"></el-table-column> |
| | | <el-table-column prop="price" label="å
¥æä»·ï¼å
ï¼" min-width="100px"></el-table-column> |
| | | <el-table-column prop="createDate" label="å建æ¶é´" min-width="100px"></el-table-column> |
| | | <el-table-column prop="status" label="ç¶æ" min-width="100px"> |
| | | <template slot-scope="{row}"> |
| | | <el-switch |
| | | v-model="row.status" |
| | | @change="changeStatus(row)" |
| | | active-color="#13ce66" |
| | | inactive-color="#ff4949" |
| | | :active-value="0" |
| | | :inactive-value="1"> |
| | | </el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="containPermissions(['business:goods:update', 'business:goods:delete'])" |
| | | label="æä½" |
| | | min-width="120" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="edit(row.id)" icon="el-icon-edit" v-permissions="['business:goods:update']">ç¼è¾</el-button> |
| | | <el-button type="text" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:goods:delete']">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <input type="file" ref="upload" style="display: none;" @change="uplaodFile" /> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" |
| | | > |
| | | </pagination> |
| | | </template> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <OperaGoodsWindow ref="operaGoodsWindow" @success="handlePageChange"/> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaGoodsWindow from '@/components/business/OperaGoodsWindow' |
| | | import { brand, category, importExcel } from '@/api/system/common.js' |
| | | import { updateDisableById, queryById, exportDoc } from '@/api/business/goods.js' |
| | | export default { |
| | | name: 'Goods', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaGoodsWindow }, |
| | | data () { |
| | | return { |
| | | // æç´¢ |
| | | searchForm: { |
| | | id: '', |
| | | name: '', |
| | | status: '', |
| | | categoryId: '', |
| | | brandId: '' |
| | | }, |
| | | categoryList: [], |
| | | brandList: [], |
| | | statusList: [ |
| | | { name: 'å¯ç¨', id: 0 }, |
| | | { name: 'ç¦ç¨', id: 1 } |
| | | ] |
| | | {{ row.name }} |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="brandName" label="åç" min-width="100px"></el-table-column> |
| | | <el-table-column prop="categoryName" label="ç±»å«" min-width="100px"></el-table-column> |
| | | <el-table-column prop="baseZdPrice" label="æå¯¼ä»·ï¼å
ï¼" min-width="100px"></el-table-column> |
| | | <el-table-column prop="basePrice" label="éè´ä»·(å
)" min-width="100px"></el-table-column> |
| | | <el-table-column prop="price" label="å
¥æä»·ï¼å
ï¼" min-width="100px"></el-table-column> |
| | | <el-table-column prop="createDate" label="å建æ¶é´" min-width="100px"></el-table-column> |
| | | <el-table-column prop="status" label="ç¶æ" min-width="100px"> |
| | | <template slot-scope="{row}"> |
| | | <el-switch v-model="row.status" @change="changeStatus(row)" active-color="#13ce66" inactive-color="#ff4949" |
| | | :active-value="0" :inactive-value="1"> |
| | | </el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column v-if="containPermissions(['business:goods:update', 'business:goods:delete'])" label="æä½" |
| | | min-width="120" fixed="right"> |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="edit(row.id)" icon="el-icon-edit" |
| | | v-permissions="['business:goods:update']">ç¼è¾</el-button> |
| | | <el-button type="text" @click="deleteById(row)" icon="el-icon-delete" |
| | | v-permissions="['business:goods:delete']">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <input type="file" ref="upload" style="display: none;" @change="uplaodFile" /> |
| | | <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination"> |
| | | </pagination> |
| | | </template> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <OperaGoodsWindow ref="operaGoodsWindow" @success="handlePageChange" /> |
| | | <!-- 鿩平å°åå --> |
| | | <selectProduct ref="selectProduct" @success="handlePageChange" @result="search" /> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaGoodsWindow from '@/components/business/OperaGoodsWindow' |
| | | import selectProduct from '@/components/business/selectProduct' |
| | | import { brand, category, importExcel } from '@/api/system/common.js' |
| | | import { updateDisableById, queryById, exportDoc, batchUpdateDisableById } from '@/api/business/goods.js' |
| | | export default { |
| | | name: 'Goods', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaGoodsWindow, selectProduct }, |
| | | data() { |
| | | return { |
| | | // æç´¢ |
| | | searchForm: { |
| | | id: '', |
| | | name: '', |
| | | status: '', |
| | | categoryId: '', |
| | | brandId: '' |
| | | }, |
| | | ids: '', |
| | | categoryList: [], |
| | | brandList: [], |
| | | statusList: [ |
| | | { name: 'å¯ç¨', id: 0 }, |
| | | { name: 'ç¦ç¨', id: 1 } |
| | | ] |
| | | } |
| | | }, |
| | | created() { |
| | | this.config({ |
| | | module: 'åå', |
| | | api: '/business/goods', |
| | | 'field.id': 'id', |
| | | 'field.main': 'name' |
| | | }) |
| | | this.search() |
| | | this.getbrand() |
| | | this.getcategory() |
| | | }, |
| | | methods: { |
| | | handleSelectionChange(e) { |
| | | let arr = e.map(item => item.id) |
| | | this.ids = arr.join(',') |
| | | console.log(this.ids) |
| | | }, |
| | | // æ¹éä¸ä¸æ¶ |
| | | bulkOperation(type) { |
| | | if (!this.ids) { |
| | | this.$message.warning({ message: 'è³å°éæ©ä¸é¡¹å
容' }) |
| | | return |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: 'åå', |
| | | api: '/business/goods', |
| | | 'field.id': 'id', |
| | | 'field.main': 'name' |
| | | batchUpdateDisableById({ |
| | | ids: this.ids, |
| | | status: type |
| | | }).then(res => { |
| | | this.$message.success({ message: res }) |
| | | this.search() |
| | | }) |
| | | this.search() |
| | | this.getbrand() |
| | | this.getcategory() |
| | | }, |
| | | methods: { |
| | | downloadFile() { |
| | | // window.open(`${process.env.VUE_APP_API_PREFIX}/business/goods/export`) |
| | | exportDoc({}) |
| | | .then(response => { |
| | | this.download(response) |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | }, |
| | | rowStyle() { |
| | | return "text-align:center"; |
| | | }, |
| | | importFile() { |
| | | this.$refs.upload.click() |
| | | }, |
| | | uplaodFile(e) { |
| | | const FORMDATE = new FormData() |
| | | FORMDATE.append('file', e.target.files[0]) |
| | | // è¯·æ±æ¥å£ |
| | | importExcel(FORMDATE) |
| | | .then(res => { |
| | | console.log(res) |
| | | this.search() |
| | | }) |
| | | .catch ((err) => { |
| | | this.$message.error(err.message) |
| | | }) |
| | | this.$refs.upload.value = null |
| | | }, |
| | | edit(id) { |
| | | queryById(id) |
| | | .then(res => { |
| | | let obj = { |
| | | id: res.id, |
| | | name: res.name, |
| | | categoryId: res.categoryId, |
| | | brandId: res.brandId, |
| | | zdPrice: res.zdPrice, |
| | | price: res.price, |
| | | attrFirstIds: res.attrFirstIds ? this.turnNum(res.attrFirstIds.split(',')) : [], |
| | | attrFirstNames: res.attrFirstNames, |
| | | attrSecodIds: res.attrSecodIds ? this.turnNum(res.attrSecodIds.split(',')) : [], |
| | | attrSecodNames: res.attrSecodNames, |
| | | imgurl: res.imgurl, |
| | | multifileList: [], |
| | | files: [], |
| | | ztList: res.imgurl ? [{ url: res.prefixUrl + res.imgurl }] : [], |
| | | pzList: [], |
| | | attrFirstList: [], |
| | | attrSecodList: [] |
| | | } |
| | | if (res.multifileList.length > 0) { |
| | | res.multifileList.forEach(item => { |
| | | obj.multifileList.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl }) |
| | | obj.files.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl }) |
| | | }) |
| | | } |
| | | this.$refs.operaGoodsWindow.open('ç¼è¾åå', obj) |
| | | }) |
| | | }, |
| | | changeStatus(item) { |
| | | updateDisableById({ |
| | | id: item.id, |
| | | status: item.status |
| | | }).then(res => { |
| | | this.$tip.apiSuccess('æ´æ°æå') |
| | | }).finally(() => { |
| | | // this.search() |
| | | downloadFile() { |
| | | exportDoc({}) |
| | | .then(response => { |
| | | this.download(response) |
| | | }) |
| | | }, |
| | | turnNum (nums) { |
| | | for(let i=0;i<nums.length;i++){ |
| | | nums[i] = parseInt(nums[i]) |
| | | } |
| | | return nums; |
| | | }, |
| | | getbrand() { |
| | | brand({}) |
| | | .then(res => { |
| | | this.brandList = res |
| | | }) |
| | | }, |
| | | getcategory() { |
| | | category({}) |
| | | .then(res => { |
| | | this.categoryList = res |
| | | }) |
| | | } |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | }, |
| | | rowStyle() { |
| | | return "text-align:center"; |
| | | }, |
| | | importFile() { |
| | | this.$refs.upload.click() |
| | | }, |
| | | uplaodFile(e) { |
| | | const FORMDATE = new FormData() |
| | | FORMDATE.append('file', e.target.files[0]) |
| | | // è¯·æ±æ¥å£ |
| | | importExcel(FORMDATE) |
| | | .then(res => { |
| | | console.log(res) |
| | | this.search() |
| | | }) |
| | | .catch((err) => { |
| | | this.$message.error(err.message) |
| | | }) |
| | | this.$refs.upload.value = null |
| | | }, |
| | | edit(id) { |
| | | queryById(id) |
| | | .then(res => { |
| | | let obj = { |
| | | id: res.id, |
| | | name: res.name, |
| | | categoryId: res.categoryId, |
| | | brandId: res.brandId, |
| | | zdPrice: res.zdPrice, |
| | | price: res.price, |
| | | attrFirstIds: res.attrFirstIds ? this.turnNum(res.attrFirstIds.split(',')) : [], |
| | | attrFirstNames: res.attrFirstNames, |
| | | attrSecodIds: res.attrSecodIds ? this.turnNum(res.attrSecodIds.split(',')) : [], |
| | | attrSecodNames: res.attrSecodNames, |
| | | imgurl: res.imgurl, |
| | | multifileList: [], |
| | | files: [], |
| | | ztList: res.imgurl ? [{ url: res.prefixUrl + res.imgurl }] : [], |
| | | pzList: [], |
| | | attrFirstList: [], |
| | | attrSecodList: [] |
| | | } |
| | | if (res.multifileList.length > 0) { |
| | | res.multifileList.forEach(item => { |
| | | obj.multifileList.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl }) |
| | | obj.files.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl }) |
| | | }) |
| | | } |
| | | this.$refs.operaGoodsWindow.open('ç¼è¾åå', obj) |
| | | }) |
| | | }, |
| | | changeStatus(item) { |
| | | updateDisableById({ |
| | | id: item.id, |
| | | status: item.status |
| | | }).then(res => { |
| | | this.$tip.apiSuccess('æ´æ°æå') |
| | | }).finally(() => { |
| | | // this.search() |
| | | }) |
| | | }, |
| | | turnNum(nums) { |
| | | for (let i = 0; i < nums.length; i++) { |
| | | nums[i] = parseInt(nums[i]) |
| | | } |
| | | return nums; |
| | | }, |
| | | getbrand() { |
| | | brand({}) |
| | | .then(res => { |
| | | this.brandList = res |
| | | }) |
| | | }, |
| | | getcategory() { |
| | | category({}) |
| | | .then(res => { |
| | | this.categoryList = res |
| | | }) |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | } |
| | | </script> |