| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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/goods', |
| | | '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> |
| | | |