| <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.platCateId},${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 { list } 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.split(',')[1], | 
|               rate: this.form.rate, | 
|               type: this.form.type | 
|             }).then(res => { | 
|               this.$tip.apiSuccess(res) | 
|               this.$emit('success') | 
|               this.$emit('result') | 
|               this.visible = false | 
|               this.isWorking = false | 
|             }) | 
|             .catch(e => { | 
|               this.$tip.apiFailed(e) | 
|               this.visible = false | 
|               this.isWorking = false | 
|             }) | 
|           } else { | 
|             this.$refs.selectProductItem.open('选择平台商品', this.form) | 
|           } | 
|         }) | 
|       }, | 
|       /** | 
|        * 打开窗口 | 
|        * @title 窗口标题 | 
|        * @target 编辑的对象 | 
|        */ | 
|       open (title, target) { | 
|         this.title = title | 
|         this.visible = true | 
|         this.form.categoryId = '' | 
|         this.form.type = 0 | 
|         this.form.rate = '' | 
|         // 获取分类列表 | 
|         list({ type: 1 }) | 
|           .then(res => { | 
|             this.categoryList = res | 
|           }) | 
|       } | 
|     } | 
|   } | 
| </script> | 
|      |