refactor component: Consultant-ques
| | |
| | | </el-button> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Emit, Prop} from 'vue-property-decorator'; |
| | | |
| | | import { consultantQuestions } from '~/shared/const/consult-questions'; |
| | | |
| | | @Component |
| | | export default class ConsultantQues extends Vue{ |
| | | |
| | | showDialog = false; |
| | | other = ''; |
| | | otherQuestion = ''; |
| | | @Prop({ default: () => []}) |
| | | selectedQuestions!: string[]; |
| | | |
| | | @Prop({ default: () => []}) selectedQuestions!: string[]; |
| | | other : string = ''; |
| | | otherQuestion : string = ''; |
| | | |
| | | get questionList(): any[] { |
| | | return this.defaultQuestionList.map((question) => { |
| | | const isSeleted = (quesName: string): boolean => this.selectedQuestions.some((question) => question === quesName); |
| | | if (isSeleted(question.name)) { |
| | | question.selected = true; |
| | | questionList: ConsultQuestionWithSelect[] = []; |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | mounted() { |
| | | const isSelected = (quesName: string): boolean => this.selectedQuestions.some((question) => question === quesName); |
| | | this.questionList = consultantQuestions.map((consultQuestion) => { |
| | | return { |
| | | name: consultQuestion, |
| | | selected: isSelected(consultQuestion) |
| | | } |
| | | return question; |
| | | } |
| | | ); |
| | | }) |
| | | } |
| | | |
| | | defaultQuestionList = [ |
| | | { |
| | | name:'å¥åº·èä¿é', |
| | | selected:false |
| | | }, |
| | | { |
| | | name:'å女æè²', |
| | | selected:false |
| | | }, |
| | | { |
| | | name:'è³ç¢è¦å', |
| | | selected:false |
| | | }, |
| | | { |
| | | name:'æ¨æ´»éä¼', |
| | | selected:false |
| | | }, |
| | | { |
| | | name:'ä¿å®å¥æª¢/è¦å', |
| | | selected:false |
| | | }, |
| | | { |
| | | name:'åç´
ä¿å®', |
| | | selected:false |
| | | } |
| | | ]; |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | @Emit('change') |
| | | selectQuestion(questionIndex: number): any[] { |
| | |
| | | return this.questionList; |
| | | } |
| | | |
| | | } |
| | | |
| | | interface ConsultQuestionWithSelect { |
| | | name : string; |
| | | selected: boolean; |
| | | } |
| | | </script> |
| | | <style lang="scss"> |
| | |
| | | .pam-tags{ |
| | | display:flex; |
| | | flex-wrap:wrap; |
| | | |
| | | } |
| | | .tags{ |
| | | margin-right: 10px; |
¤ñ¹ï·sÀÉ®× |
| | |
| | | export const consultantQuestions = ['å¥åº·èä¿é', 'å女æè²', 'è³ç¢è¦å', 'æ¨æ´»éä¼', 'ä¿å®å¥æª¢/è¦å', 'åç´
ä¿å®']; |