| ¶Ô±ÈÐÂÎļþ | 
 |  |  | 
 |  |  | <template> | 
 |  |  |   <GlobalWindow :title="title" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm" width="900px"> | 
 |  |  |     <el-form :model="form" ref="form" label-width="120px" label-suffix="ï¼" :rules="rules" v-loading="isUploading"> | 
 |  |  |       <el-form-item label="ç±»å«åç§°" prop="name"> | 
 |  |  |         <el-input v-model="form.name" placeholder="请è¾å
¥ç±»å«åç§°ï¼ä¸è¶
è¿6个å" maxlength="6" v-trim /> | 
 |  |  |       </el-form-item> | 
 |  |  |       <el-form-item label="徿 " prop="imgurl"> | 
 |  |  |         <UploadAvatarImage :file="{ 'imgurlfull': form.imgfullurl, 'imgurl': form.imgurl }" | 
 |  |  |           :uploadData="{ folder: 'category_img' }" @uploadSuccess="uploadReverseSuccess" @uploadEnd="isUploading = false" | 
 |  |  |           @uploadBegin="isUploading = true" /> | 
 |  |  |         åªè½ä¸ä¼ å¾çæ ¼å¼ï¼pngæ ¼å¼ï¼å»ºè®®å°ºå¯¸120*120px | 
 |  |  |       </el-form-item> | 
 |  |  |       <el-form-item label="å ä»·ç³»æ°" prop="priceRate"> | 
 |  |  |         <!-- <el-input v-model="form.priceRate" placeholder="å¨äº¬ä¸éè´ä»·åºç¡ä¸ï¼å¹³å°çå ä»·ç³»æ°" v-trim /> --> | 
 |  |  |         <el-input-number v-model="form.priceRate" controls-position="right" :min="0.1" :step="0.1"></el-input-number> | 
 |  |  |       </el-form-item> | 
 |  |  |       <el-form-item label="æåºç (ååº)" prop="sortnum"> | 
 |  |  |         <el-input v-model="form.sortnum" type="number" placeholder="请è¾å
¥æåºç ï¼ååºå±ç¤º" v-trim /> | 
 |  |  |       </el-form-item> | 
 |  |  |  | 
 |  |  |     </el-form> | 
 |  |  |     <div class="param-table" > | 
 |  |  |       <div class="title-contant"> | 
 |  |  |         <div class="title">忰屿§é
ç½®</div> | 
 |  |  |         <div class="sub-title">é
ç½®å½åç±»å«ç产ååæ°å</div> | 
 |  |  |       </div> | 
 |  |  |       <el-table :data="form.baseCateParamList" stripe border > | 
 |  |  |         <el-table-column prop="" label="åæ°å"  min-width="200px" align="center"> | 
 |  |  |           <template slot-scope="{row}"> | 
 |  |  |             <el-input v-model="row.name" placeholder="请è¾å
¥åæ°å" v-trim /> | 
 |  |  |           </template> | 
 |  |  |         </el-table-column> | 
 |  |  |         <el-table-column label="æä½" width="100" align="center"> | 
 |  |  |           <template slot-scope="{row, $index}"> | 
 |  |  |             <el-button type="text" style="color: red" | 
 |  |  |               @click="form.baseCateParamList.splice($index, 1)">å é¤</el-button> | 
 |  |  |           </template> | 
 |  |  |         </el-table-column> | 
 |  |  |       </el-table> | 
 |  |  |       <el-button style="color: #2E68EC; margin-top: 10px;" @click="addParam" icon="el-icon-plus">æ°å¢</el-button> | 
 |  |  |     </div> | 
 |  |  |   </GlobalWindow> | 
 |  |  | </template> | 
 |  |  |    | 
 |  |  | <script> | 
 |  |  | import BaseOpera from '@/components/base/BaseOpera' | 
 |  |  | import GlobalWindow from '@/components/common/GlobalWindow' | 
 |  |  | import UploadAvatarImage from '@/components/common/UploadAvatarImage.vue' | 
 |  |  | import { create, updateById } from '@/api/business/category.js' | 
 |  |  | export default { | 
 |  |  |   name: 'OperaCategoryWindow', | 
 |  |  |   extends: BaseOpera, | 
 |  |  |   components: { GlobalWindow, UploadAvatarImage }, | 
 |  |  |   data() { | 
 |  |  |     return { | 
 |  |  |       action: process.env.VUE_APP_API_PREFIX + '/public/upload', | 
 |  |  |       isUploading: false, | 
 |  |  |       // è¡¨åæ°æ® | 
 |  |  |       form: { | 
 |  |  |         id: null, | 
 |  |  |         name: '', | 
 |  |  |         imgurl: '', | 
 |  |  |         imgfullurl: '', | 
 |  |  |         priceRate: '1.2', | 
 |  |  |         sortnum: '', | 
 |  |  |  | 
 |  |  |         // attrFirst: '', | 
 |  |  |         // attrFirst1: '', | 
 |  |  |         baseCateParamList: [], | 
 |  |  |         // attrSecond: '', | 
 |  |  |         // attrSecond1: '', | 
 |  |  |         // attrSecondList: [], | 
 |  |  |  | 
 |  |  |         // parameter: '', | 
 |  |  |         paramList: [] | 
 |  |  |  | 
 |  |  |       }, | 
 |  |  |       // éªè¯è§å | 
 |  |  |       rules: { | 
 |  |  |         name: [ | 
 |  |  |           { required: true, message: 'ä¸è½ä¸ºç©º', trigger: 'blur' } | 
 |  |  |         ] | 
 |  |  |       }, | 
 |  |  |       dialogVisible: false | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   created() { | 
 |  |  |     this.config({ | 
 |  |  |       api: '/business/category', | 
 |  |  |       'field.id': 'id' | 
 |  |  |     }) | 
 |  |  |   }, | 
 |  |  |   methods: { | 
 |  |  |     open(title, target) { | 
 |  |  |       this.title = title | 
 |  |  |       this.visible = true | 
 |  |  |       // æ°å»º | 
 |  |  |       if (target == null) { | 
 |  |  |         this.$nextTick(() => { | 
 |  |  |           this.$refs.form.resetFields() | 
 |  |  |           this.form.imgfullurl = '' | 
 |  |  |           this.form.baseCateParamList = [{name:''}] | 
 |  |  |           this.form.paramList = [{name:''}] | 
 |  |  |           this.form[this.configData['field.id']] = null | 
 |  |  |         }) | 
 |  |  |         return | 
 |  |  |       } | 
 |  |  |       // ç¼è¾ | 
 |  |  |       this.$nextTick(() => { | 
 |  |  |         for (const key in this.form) { | 
 |  |  |           this.form[key] = target[key] | 
 |  |  |         } | 
 |  |  |         this.form.baseCateParamList = this.form.baseCateParamList || [] | 
 |  |  |       }) | 
 |  |  |     }, | 
 |  |  |     addParam () { | 
 |  |  |       this.form.baseCateParamList.push({ name: '' }) | 
 |  |  |     }, | 
 |  |  |     changeInput (type, index) { | 
 |  |  |       if (type === 1) { | 
 |  |  |         if (!this.form.budgetList[index].minamount) return | 
 |  |  |         if (!/^[0-9]*[1-9][0-9]*$/.test(this.form.budgetList[index].minamount)) { | 
 |  |  |           this.$message.warning({ | 
 |  |  |             type: 'warning', | 
 |  |  |             message: 'é¢ç®åªè½è¾å
¥æ£æ´æ°' | 
 |  |  |           }) | 
 |  |  |           this.form.budgetList[index].minamount = '' | 
 |  |  |         } | 
 |  |  |       } else { | 
 |  |  |         if (!this.form.budgetList[index].maxamount) return | 
 |  |  |         if (!/^[0-9]*[1-9][0-9]*$/.test(this.form.budgetList[index].maxamount)) { | 
 |  |  |           this.$message.warning({ | 
 |  |  |             type: 'warning', | 
 |  |  |             message: 'é¢ç®åªè½è¾å
¥æ£æ´æ°' | 
 |  |  |           }) | 
 |  |  |           this.form.budgetList[index].maxamount = '' | 
 |  |  |         } | 
 |  |  |       } | 
 |  |  |     }, | 
 |  |  |  | 
 |  |  |     confirm() { | 
 |  |  |       this.$refs.form.validate((valid) => { | 
 |  |  |         if (valid) { | 
 |  |  |           this.isWorking = true | 
 |  |  |           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; | 
 |  |  |         } | 
 |  |  |       }); | 
 |  |  |     }, | 
 |  |  |     close(index, type) { | 
 |  |  |       if (type === 1) { | 
 |  |  |         this.form.attrFirstList.splice(index, 1) | 
 |  |  |       } else if (type === 2) { | 
 |  |  |         this.form.attrSecondList.splice(index, 1) | 
 |  |  |       } else if (type === 3) { | 
 |  |  |         this.form.paramList.splice(index, 1) | 
 |  |  |       } | 
 |  |  |     }, | 
 |  |  |     confirmVal(type) { | 
 |  |  |       if (type === 1) { | 
 |  |  |         if (!this.form.attrFirst1) return | 
 |  |  |         this.form.attrFirstList.push({ name: this.form.attrFirst1 }) | 
 |  |  |         this.form.attrFirst1 = '' | 
 |  |  |       } else if (type === 2) { | 
 |  |  |         if (!this.form.attrSecond1) return | 
 |  |  |         this.form.attrSecondList.push({ name: this.form.attrSecond1 }) | 
 |  |  |         this.form.attrSecond1 = '' | 
 |  |  |       } else if (type === 3) { | 
 |  |  |         if (!this.form.parameter) return | 
 |  |  |         this.form.paramList.push({ name: this.form.parameter }) | 
 |  |  |         this.form.parameter = '' | 
 |  |  |       } | 
 |  |  |     }, | 
 |  |  |     add() { | 
 |  |  |       this.form.budgetList.push({ minamount: '', maxamount: '' }) | 
 |  |  |     }, | 
 |  |  |     begin() { | 
 |  |  |       this.isUploading = true | 
 |  |  |     }, | 
 |  |  |     end() { | 
 |  |  |       this.isUploading = false | 
 |  |  |     }, | 
 |  |  |     // ä¸ä¼ å¾ç | 
 |  |  |     uploadReverseSuccess(file) { | 
 |  |  |       this.form.imgurl = file.imgurl; | 
 |  |  |       this.form.imgfullurl = file.imgurlfull; | 
 |  |  |     }, | 
 |  |  |     dele(i) { | 
 |  |  |       if (this.form.budgetList.length === 1) return | 
 |  |  |       this.form.budgetList.splice(i, 1) | 
 |  |  |     } | 
 |  |  |   } | 
 |  |  | } | 
 |  |  | </script> | 
 |  |  |  | 
 |  |  | <style lang="scss" scoped> | 
 |  |  | .param-table { | 
 |  |  |   //width: 70%; | 
 |  |  |   margin-top: 40px; | 
 |  |  |  | 
 |  |  |   .title-contant { | 
 |  |  |     display: flex; | 
 |  |  |     align-items: baseline; | 
 |  |  |     margin-bottom: 10px; | 
 |  |  |     .title { | 
 |  |  |       font-weight: 600; | 
 |  |  |       font-size: 20px; | 
 |  |  |       margin-right: 15px; | 
 |  |  |     } | 
 |  |  |     .sub-title { | 
 |  |  |       font-size: 14px; | 
 |  |  |     } | 
 |  |  |   } | 
 |  |  | } | 
 |  |  | ::v-deep .el-form-item__content { | 
 |  |  |   .el-input { | 
 |  |  |     width: 300px; | 
 |  |  |   } | 
 |  |  |   .el-input-number { | 
 |  |  |     text-align: left; | 
 |  |  |     width: 300px; | 
 |  |  |   } | 
 |  |  | } | 
 |  |  | </style> |