Blame view
src/components/questions/diet.vue
6.52 KB
c17e4f0cd
|
1 |
<template> |
a95d2830c
|
2 3 |
<v-flex> <v-card> |
c17e4f0cd
|
4 5 |
<v-spacer></v-spacer> <v-dialog v-model="dialog" max-width="800px"> |
c17e4f0cd
|
6 7 8 9 10 11 12 13 14 |
<v-card> <v-card-title> <span class="headline">{{ formTitle }}</span> <v-spacer></v-spacer> <v-icon @click="close">close</v-icon> </v-card-title> <v-flex> <v-card> <v-card-text> |
a95d2830c
|
15 16 17 18 19 20 21 22 23 24 25 26 27 |
<span> <p> <b>Ana Suggestion:</b> Select Suggestion </p> </span> <h5>Select Category:</h5> <span> <v-btn color="grey darken-2" flat>Suggestion</v-btn> <v-btn color="grey darken-2" flat>Sex</v-btn> <v-btn color="grey darken-2" flat>Health</v-btn> <v-btn color="grey darken-2" flat>Skin & Beauty</v-btn> <v-btn color="grey darken-2" flat>Diet & Ex</v-btn> </span> |
c17e4f0cd
|
28 |
</v-card-text> |
a95d2830c
|
29 |
</v-card> |
c17e4f0cd
|
30 31 |
</v-flex> <v-card-text> |
a95d2830c
|
32 33 34 35 36 37 38 39 40 41 |
<v-container grid-list-md> <v-layout wrap> <v-flex xs12 sm6 md12> <v-textarea solo v-model="AddQuestioncredentials.question" name="input-7-4" label="Type Question" ></v-textarea> </v-flex> |
c17e4f0cd
|
42 43 44 |
</v-layout> </v-container> </v-card-text> |
c17e4f0cd
|
45 |
<v-card-actions> |
a95d2830c
|
46 47 |
<v-spacer></v-spacer> <v-btn dark large @click.native="save">Post Question</v-btn> |
c17e4f0cd
|
48 |
</v-card-actions> |
a95d2830c
|
49 50 |
</v-card> </v-dialog> |
c17e4f0cd
|
51 |
|
a95d2830c
|
52 |
<v-dialog v-model="dialog1" max-width="800px"> |
c17e4f0cd
|
53 |
<v-card> |
a95d2830c
|
54 55 56 57 58 |
<v-card-title> <span class="headline">Edit Question</span> <v-spacer></v-spacer> <v-icon @click="close1">close</v-icon> </v-card-title> |
c17e4f0cd
|
59 |
|
a95d2830c
|
60 61 |
<v-card-text> <v-layout wrap> |
c17e4f0cd
|
62 63 64 65 |
<v-flex xs12 sm6 md12> <v-text-field outline v-model="editedItem.ques" label="Question"></v-text-field> </v-flex> </v-layout> |
a95d2830c
|
66 67 68 69 70 71 72 73 74 75 76 77 |
<span> <p> <b>Ana suggestion:</b> Abnormal Uterine Bleeding <br>Diagnosis 1,Diagnosis 2,Diagnosis 3 <v-btn dark large @click.native="save1" style="position:absolute; top:163px; right:5px;" >Save Edit</v-btn> </p> </span> |
c17e4f0cd
|
78 |
</v-card-text> |
a95d2830c
|
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
</v-card> </v-dialog> <v-data-table :headers="headers" :items="desserts" class="elevation-1" :pagination.sync="pagination" > <template slot="items" slot-scope="props"> <tr v-if="props.index === 0"> <td id="td"> </td> <td> <span style="cursor:pointer" @click="dialog=true"> <v-icon>add</v-icon>Add New Question </span> </td> <td id="td"> </td> <td id="td"> </td> </tr> <tr> <td id="td" class="text-xs-center">{{ props.item.no }}</td> <td id="td">{{ props.item.ques }}</td> <td id="td" class="text-xs-center">{{ props.item.res }}</td> <td class="text-xs-center"> <span> <img style="cursor:pointer; height:18px; " class="mr-5" @click="editItem(props.item)" src="/static/icon/edit1.png" > <img style="cursor:pointer; height:20px; " class="mr-5" @click="deleteItem(props.item)" src="/static/icon/delete1.png" > </span> </td> </tr> </template> </v-data-table> </v-card> |
c17e4f0cd
|
122 |
</v-flex> |
c17e4f0cd
|
123 124 125 126 |
</template> <script> export default { data: () => ({ |
a95d2830c
|
127 |
question: "", |
c17e4f0cd
|
128 129 130 131 132 133 |
AddQuestioncredentials: {}, dialog: false, dialog1: false, isActive: true, newActive: false, pagination: { |
a95d2830c
|
134 |
rowsPerPage: 10 |
c17e4f0cd
|
135 136 137 |
}, headers: [ { |
a95d2830c
|
138 139 140 141 142 143 144 145 146 |
text: "No.", align: "center", sortable: false, value: "name" }, { text: "Posts", value: "posts", sortable: false, align: "center" }, { text: "Responses", value: "responses", |
c17e4f0cd
|
147 |
sortable: false, |
a95d2830c
|
148 |
align: "center" |
c17e4f0cd
|
149 |
}, |
a95d2830c
|
150 |
{ text: "", value: "carbs", sortable: false, align: "center" } |
c17e4f0cd
|
151 152 153 154 |
], desserts: [], editedIndex: -1, editedItem: { |
a95d2830c
|
155 |
question: "" |
c17e4f0cd
|
156 157 158 |
}, defaultItem: { no: 0, |
a95d2830c
|
159 160 |
question: "", res: 0 |
c17e4f0cd
|
161 162 163 164 |
} }), computed: { |
a95d2830c
|
165 166 |
formTitle() { return this.editedIndex === -1 ? "Create New Question" : "Edit Question"; |
c17e4f0cd
|
167 168 169 170 |
} }, watch: { |
a95d2830c
|
171 |
dialog(val) { |
c17e4f0cd
|
172 173 174 |
val || this.close(); } }, |
a95d2830c
|
175 |
created() { |
c17e4f0cd
|
176 177 178 179 |
this.initialize(); }, methods: { |
a95d2830c
|
180 |
initialize() { |
c17e4f0cd
|
181 182 |
this.desserts = [ { |
a95d2830c
|
183 184 185 186 |
no: "1", ques: "questions diet", res: 12 } |
c17e4f0cd
|
187 |
]; |
a95d2830c
|
188 |
}, |
c17e4f0cd
|
189 |
|
a95d2830c
|
190 |
editItem(item) { |
c17e4f0cd
|
191 192 193 194 |
this.editedIndex = this.desserts.indexOf(item); this.editedItem = Object.assign({}, item); this.dialog1 = true; }, |
a95d2830c
|
195 |
deleteItem(item) { |
c17e4f0cd
|
196 |
const index = this.desserts.indexOf(item); |
a95d2830c
|
197 198 |
confirm("Are you sure you want to delete this item?") && this.desserts.splice(index, 1); |
c17e4f0cd
|
199 |
}, |
a95d2830c
|
200 |
close() { |
c17e4f0cd
|
201 202 203 204 205 206 |
this.dialog = false; setTimeout(() => { this.editedItem = Object.assign({}, this.defaultItem); this.editedIndex = -1; }, 300); }, |
a95d2830c
|
207 |
close1() { |
c17e4f0cd
|
208 209 210 211 212 213 |
this.dialog1 = false; setTimeout(() => { this.editedItem = Object.assign({}, this.defaultItem); this.editedIndex = -1; }, 300); }, |
a95d2830c
|
214 215 |
save() { console.log("editedItem", this.editedItem); |
c17e4f0cd
|
216 217 218 219 220 221 222 |
if (this.editedIndex > -1) { Object.assign(this.desserts[this.editedIndex], this.editedItem); } else { this.desserts.push(this.editedItem); } this.close(); }, |
a95d2830c
|
223 224 |
save1() { console.log("editedItem", this.editedItem); |
c17e4f0cd
|
225 226 227 228 229 230 231 |
if (this.editedIndex > -1) { Object.assign(this.desserts[this.editedIndex], this.editedItem); } else { this.desserts.push(this.editedItem); } this.close1(); } |
a95d2830c
|
232 |
} |
c17e4f0cd
|
233 234 235 236 237 238 |
// switchComponent (comp) { // this.$emit('switchComp', comp); // } }; </script> <style> |
a95d2830c
|
239 240 241 242 |
#td { border: 1px solid #dddddd; text-align: left; padding: 8px; |
c17e4f0cd
|
243 244 |
} </style> |