選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

restaurantMenuItem.vue 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div>
  3. <div class="container">
  4. <div class="container">
  5. <div class="row">
  6. <div class="col-md-12 col-lg-8">
  7. <div class="title-box-d">
  8. <br />
  9. <h1 class="title-d" style="text-align:left; font-size: 250%">Menu Item</h1>
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="container" v-if="!showOption">
  16. <div class="row" style="text-align:left">
  17. <div class="col-md-6" style="margin-bottom: 1em">
  18. <label>Category</label>
  19. <div class="input-group-prepend">
  20. <span class="input-group-text">
  21. <eva-icon name="credit-card-outline" fill="#24aae1"></eva-icon>
  22. </span>
  23. <select class="form-control" v-model="menuItem.category">
  24. <option v-for="(cat, i) in categories" :key="i">
  25. {{
  26. cat.description
  27. }}
  28. </option>
  29. </select>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="row" style="text-align:left">
  34. <div class="col-md-6" style="margin-bottom: 1em">
  35. <label>Name</label>
  36. <div class="input-group-prepend">
  37. <span class="input-group-text">
  38. <eva-icon name="credit-card-outline" fill="#24aae1"></eva-icon>
  39. </span>
  40. <input class="form-control" type="text" v-model="menuItem.name" />
  41. </div>
  42. </div>
  43. </div>
  44. <div class="row" style="text-align:left">
  45. <div class="col-md-6" style="margin-bottom: 1em">
  46. <label>Description</label>
  47. <div class="input-group-prepend">
  48. <span class="input-group-text">
  49. <eva-icon name="credit-card-outline" fill="#24aae1"></eva-icon>
  50. </span>
  51. <input class="form-control" type="text" v-model="menuItem.description" />
  52. </div>
  53. </div>
  54. </div>
  55. <div class="row" style="text-align:left">
  56. <div class="col-md-6" style="margin-bottom: 1em">
  57. <label>Price</label>
  58. <div class="input-group-prepend">
  59. <span class="input-group-text">
  60. <eva-icon name="credit-card-outline" fill="#24aae1"></eva-icon>
  61. </span>
  62. <input class="form-control" type="number" v-model="menuItem.price" />
  63. </div>
  64. </div>
  65. </div>
  66. <div v-if="!menuItem.image" class="row" style="text-align:left">
  67. <div class="col-md-6" style="margin-bottom: 1em">
  68. <label>Image</label>
  69. <div class="input-group-prepend">
  70. <image-uploader
  71. :preview="true"
  72. :className="['fileinput', { 'fileinput--loaded': hasImage }]"
  73. capture="environment"
  74. :debug="1"
  75. doNotResize="gif"
  76. :autoRotate="true"
  77. outputFormat="verbose"
  78. @input="setImage"
  79. >
  80. <label for="fileInput" slot="upload-label">
  81. <figure>
  82. <path
  83. class="path1"
  84. d="M9.5 19c0 3.59 2.91 6.5 6.5 6.5s6.5-2.91 6.5-6.5-2.91-6.5-6.5-6.5-6.5 2.91-6.5 6.5zM30 8h-7c-0.5-2-1-4-3-4h-8c-2 0-2.5 2-3 4h-7c-1.1 0-2 0.9-2 2v18c0 1.1 0.9 2 2 2h28c1.1 0 2-0.9 2-2v-18c0-1.1-0.9-2-2-2zM16 27.875c-4.902 0-8.875-3.973-8.875-8.875s3.973-8.875 8.875-8.875c4.902 0 8.875 3.973 8.875 8.875s-3.973 8.875-8.875 8.875zM30 14h-4v-2h4v2z"
  85. ></path>
  86. </figure>
  87. </label>
  88. </image-uploader>
  89. </div>
  90. </div>
  91. </div>
  92. <div v-else class="row" style="text-align:left">
  93. <div class="col-md-6" style="margin-bottom: 1em">
  94. <img :src="menuItem.image" style="height:100px; width:100px; object-fit: cover;" />
  95. <br />
  96. <span class="input-group-text" align="center" style="width:100px" @click="removeImage()">
  97. <eva-icon name="trash-2-outline" fill="#24aae1"></eva-icon>Delete
  98. </span>
  99. </div>
  100. </div>
  101. <div class="row" style="text-align:left" v-if="1 === 2">
  102. <div class="col-md-12" style="margin-bottom: 1em">
  103. <div class="custom-control custom-switch">
  104. <label>Override Options</label>
  105. <input
  106. style="margin-left: 1px"
  107. type="checkbox"
  108. class="custom-control-input"
  109. id="thCloseSwitch"
  110. :checked="menuItem.overrideOptions"
  111. @change="selectionChanged"
  112. />
  113. <label
  114. class="custom-control-label"
  115. for="thCloseSwitch"
  116. style="margin-left: 40px"
  117. >{{menuItem.overrideOptions ? 'Yes - This will override any menu options set on the category' : 'No - This will append category options to the below options'}}</label>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="row" style="text-align:left" v-if="1 === 2">
  122. <div class="col-md-12" style="margin-bottomL 1em">
  123. <label>Options</label>
  124. <ListView
  125. :items="menuItem.options"
  126. @onEdit="OptionEdit"
  127. @onDelete="OptionDelete"
  128. @onNew="OptionNew"
  129. />
  130. </div>
  131. </div>
  132. <div class="row"></div>
  133. <div class="row">
  134. <div class="col-md-12" style="margin-bottomL 1em">
  135. <div class="row offset-md-5">
  136. <div class="col-md-2">
  137. <button @click="Save()" class="btn btn-b-n" type="button" data-dismiss="modal">Save</button>
  138. </div>
  139. <div class="col-md-2">
  140. <button @click="Close()" class="btn btn-b-n" type="button" data-dismiss="modal">Close</button>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. <div v-if="wait" id="preloader"></div>
  146. </div>
  147. <div v-else class="containers">
  148. <ItemOption @Close="CloseOptions" :menuOption="CurrentOption" />
  149. </div>
  150. </div>
  151. </template>
  152. <script>
  153. import { mapState, mapActions } from "vuex";
  154. import Log from "../../assets/Log";
  155. import ImageUploader from "vue-image-upload-resize";
  156. import ListView from "../shared/listView";
  157. import ItemOption from "./restaurantMenuItemOptions";
  158. export default {
  159. name: "MenuItem",
  160. components: {
  161. ImageUploader,
  162. ListView,
  163. ItemOption
  164. },
  165. data() {
  166. return {
  167. wait: false,
  168. hasImage: false,
  169. restaurantId: Log.restaurantId(),
  170. showOption: false,
  171. menuOption: {}
  172. };
  173. },
  174. methods: {
  175. ...mapActions("menuCategories", ["getCategories"]),
  176. ...mapActions("menu", ["getMenuItem", "insertMenuItem", "updateMenuItem"]),
  177. Save() {
  178. //this.wait = true;
  179. this.menuItem.restaurantId = this.restaurantId;
  180. if (this.menuItem.category !== "") {
  181. var category = this.categories.find(
  182. c => c.description === this.menuItem.category
  183. );
  184. this.menuItem.categoryId = category.id;
  185. }
  186. console.log(JSON.stringify(this.menuItem));
  187. this.insertMenuItem(this.menuItem).then(fulfilled => {
  188. this.$router.push("/RestaurantMenu");
  189. });
  190. },
  191. Close() {
  192. this.$router.push("/RestaurantMenu");
  193. },
  194. setImage: function(output) {
  195. this.hasImage = true;
  196. this.menuItem.image = output.dataUrl;
  197. },
  198. removeImage() {
  199. this.hasImage = false;
  200. this.menuItem.image = null;
  201. },
  202. selectionChanged() {
  203. this.menuItem.overrideOptions = !this.menuItem.overrideOptions;
  204. },
  205. OptionNew() {
  206. //new
  207. this.menuOption = {};
  208. this.menuOption.options = [];
  209. this.showOption = true;
  210. },
  211. OptionEdit(item) {
  212. //edit
  213. },
  214. OptionDelete(item) {
  215. //delete
  216. },
  217. CloseOptions(item) {
  218. if (item) {
  219. this.showOption = false;
  220. }
  221. }
  222. },
  223. computed: {
  224. ...mapState("menuCategories", ["categories"]),
  225. ...mapState("menu", ["menuItem"]),
  226. CurrentOption() {
  227. return this.menuOption;
  228. }
  229. },
  230. mounted() {
  231. this.wait = true;
  232. this.getCategories(this.restaurantId);
  233. this.getMenuItem(this.$route.params.itemid);
  234. this.wait = false;
  235. }
  236. };
  237. </script>