You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

279 lines
8.3 KiB

2 years ago
2 years ago
  1. <template>
  2. <div class="tw-mb-[20px] tw-rounded-[20px] tw-px-[20px] tw-py-[30px] tw-border tw-border-solid tw-border-slate-200">
  3. <div class="element tw-grid tw-grid-cols-1 md:tw-grid-cols-[90px_auto] xl:tw-grid-cols-[90px_auto] tw-gap-[10px]">
  4. <div class="tw-flex tw-items-center">
  5. <label class="tw-font-normal tw-mb-[10px] md:tw-mb-0">
  6. <span>{{ $t("Package")}}</span><span class="required">*</span>
  7. </label>
  8. </div>
  9. <elementSelectNew
  10. :select="{
  11. id: 'Package',
  12. label: 'Package',
  13. required: true,
  14. }"
  15. :isRow="true"
  16. :itemsCenter="true"
  17. :labelWidth="0"
  18. :selectWidth="200"
  19. :selectList="selectPackageList"
  20. :default="formData.package"
  21. :validation="validation.package"
  22. @change="formData.package = $event"
  23. ></elementSelectNew>
  24. </div>
  25. <div class="element tw-grid tw-grid-cols-1 md:tw-grid-cols-[90px_auto_auto_auto] xl:tw-grid-cols-[90px_auto_auto_auto] tw-gap-[10px] tw-mt-[20px]">
  26. <div class="tw-flex tw-items-center">
  27. <label class="tw-font-normal tw-mb-[10px] md:tw-mb-0">
  28. <span>{{ $t("Size (cm)")}}</span><span class="required">*</span>
  29. </label>
  30. </div>
  31. <elementSelectNew
  32. :select="{
  33. id: 'Length',
  34. label: '',
  35. required: true,
  36. }"
  37. :isRow="true"
  38. :itemsCenter="true"
  39. :labelWidth="0"
  40. :selectWidth="200"
  41. :selectList="selectLengthList"
  42. :default="formData.length"
  43. :validation="validation.length"
  44. @change="formData.length = $event"
  45. ></elementSelectNew>
  46. <elementSelectNew
  47. :select="{
  48. id: 'Width',
  49. label: '',
  50. required: true,
  51. }"
  52. :isRow="true"
  53. :itemsCenter="true"
  54. :labelWidth="0"
  55. :selectWidth="200"
  56. :selectList="selectWidthList"
  57. :default="formData.width"
  58. :validation="validation.width"
  59. @change="formData.width = $event"
  60. ></elementSelectNew>
  61. <elementSelectNew
  62. :select="{
  63. id: 'Height',
  64. label: '',
  65. required: true,
  66. }"
  67. :isRow="true"
  68. :itemsCenter="true"
  69. :labelWidth="0"
  70. :selectWidth="200"
  71. :selectList="selectHeightList"
  72. :default="formData.height"
  73. :validation="validation.height"
  74. @change="formData.height = $event"
  75. ></elementSelectNew>
  76. </div>
  77. <div class="element tw-grid tw-grid-cols-1 md:tw-grid-cols-2 xl:tw-grid-cols-2 tw-gap-[10px] tw-mt-[20px]">
  78. <div class="element tw-grid tw-grid-cols-1 md:tw-grid-cols-[90px_auto] xl:tw-grid-cols-[90px_auto] tw-gap-[10px]">
  79. <div class="tw-flex tw-items-center">
  80. <label class="tw-font-normal tw-mb-[10px] md:tw-mb-0">
  81. <span>{{ $t("Weight (kg)")}}</span><span class="required">*</span>
  82. </label>
  83. </div>
  84. <elementInputNew
  85. :input="{
  86. id: 'Weight',
  87. required: true,
  88. type: 'text',
  89. placeholder: '',
  90. }"
  91. :maxlength="11"
  92. :validation="validation.weight"
  93. @change="formData.weight = $event"
  94. ></elementInputNew>
  95. </div>
  96. <div class="element tw-grid tw-grid-cols-1 md:tw-grid-cols-[90px_auto] xl:tw-grid-cols-[90px_auto] tw-gap-[10px]">
  97. <div class="tw-flex tw-items-center">
  98. <label class="tw-font-normal tw-mb-[10px] md:tw-mb-0 tw-ml-[20px]">
  99. <span>{{ $t("Quantity")}}</span><span class="required">*</span>
  100. </label>
  101. </div>
  102. <elementSelectNew
  103. :select="{
  104. id: 'Quantity',
  105. label: 'Quantity',
  106. required: true,
  107. }"
  108. :isRow="true"
  109. :itemsCenter="true"
  110. :labelWidth="0"
  111. :selectWidth="200"
  112. :selectList="selectQuantityList"
  113. :default="formData.quantity"
  114. :validation="validation.quantity"
  115. @change="formData.quantity = $event"
  116. ></elementSelectNew>
  117. </div>
  118. </div>
  119. <div class="tw-border-0 tw-border-b tw-border-solid tw-border-neutrals-200 tw-mt-[20px]"></div>
  120. <div class="group tw-mt-[30px]">
  121. <h3 class="t14 tw-font-bold tw-mb-[20px] md:t16">
  122. {{ $t("Service Type") }}
  123. </h3>
  124. <typeGroup :packages="packages" @type="changeType($event)"></typeGroup>
  125. </div>
  126. </div>
  127. </template>
  128. <script>
  129. import elementSelectNew from "@/components/newComponent/form/ElementSelectNew";
  130. import elementInputNew from "@/components/newComponent/form/ElementInputNew";
  131. import typeGroup from "@/components/service/content/typeGroup.vue";
  132. import is from "is_js";
  133. export default {
  134. components: {
  135. elementSelectNew,
  136. elementInputNew,
  137. typeGroup
  138. },
  139. props: {
  140. selectPackageList: {
  141. type: Array,
  142. },
  143. selectLengthList: {
  144. type: Array,
  145. },
  146. selectWidthList: {
  147. type: Array,
  148. },
  149. selectHeightList: {
  150. type: Array,
  151. },
  152. selectQuantityList: {
  153. type: Array,
  154. },
  155. },
  156. data() {
  157. return {
  158. formData: {
  159. package: "",
  160. length: "",
  161. width: "",
  162. height: "",
  163. weight: "",
  164. quantity: "",
  165. },
  166. validation: {
  167. package: true,
  168. length: true,
  169. width: true,
  170. height: true,
  171. weight: true,
  172. quantity: true,
  173. },
  174. errors: null,
  175. packages: [{
  176. package_id: '1',
  177. name: '嘉義',
  178. is_customize: 1,
  179. choices:[{title: '接機服務',text: 'qweqweq'},{title: '送機服務',text: '13123'}],
  180. plan_title: '接送機服務',
  181. specifications: [{
  182. title: '賓士7人座車',
  183. }]
  184. },{
  185. package_id: '1',
  186. name: '臺南',
  187. is_customize: 1,
  188. choices:[{title: '接機服務',text: 'qweqweq'},{title: '送機服務',text: '13123'}],
  189. plan_title: '接送機服務',
  190. specifications: [{
  191. title: '賓士7人座車',
  192. }]
  193. }],
  194. };
  195. },
  196. methods: {
  197. reset() {
  198. this.formData = {
  199. package: "",
  200. length: "",
  201. width: "",
  202. height: "",
  203. weight: "",
  204. quantity: "",
  205. };
  206. },
  207. save() {
  208. this.validators();
  209. if (this.validators()) {
  210. const patchData = JSON.parse(JSON.stringify(this.formData));
  211. }
  212. },
  213. validators() {
  214. if (is.empty(this.formData.package)) {
  215. this.validation.package = false;
  216. } else {
  217. this.validation.package = true;
  218. }
  219. if (is.empty(this.formData.length || is.not.email(this.formData.length))) {
  220. this.validation.length = false;
  221. } else {
  222. this.validation.length = true;
  223. }
  224. if (is.empty(this.formData.width || is.not.email(this.formData.width))) {
  225. this.validation.width = false;
  226. } else {
  227. this.validation.width = true;
  228. }
  229. if (is.empty(this.formData.height || is.not.email(this.formData.height))) {
  230. this.validation.height = false;
  231. } else {
  232. this.validation.height = true;
  233. }
  234. if (is.empty(this.formData.weight || is.not.email(this.formData.weight))) {
  235. this.validation.weight = false;
  236. } else {
  237. this.validation.weight = true;
  238. }
  239. if (is.empty(this.formData.quantity || is.not.email(this.formData.quantity))) {
  240. this.validation.quantity = false;
  241. } else {
  242. this.validation.quantity = true;
  243. }
  244. this.errors = Object.entries(this.validation).filter(
  245. (e) => e[1] == false
  246. );
  247. if (this.errors.length > 0) {
  248. return false;
  249. } else {
  250. return true;
  251. }
  252. },
  253. changeType(index) {
  254. let vm = this;
  255. vm.activePackage = index;
  256. vm.packageId = vm.content.packages[index].package_id
  257. ? vm.content.packages[index].package_id
  258. : "";
  259. vm.packageName = vm.content.packages[index].name
  260. ? vm.content.packages[index].name
  261. : "";
  262. },
  263. },
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. select {
  268. -moz-appearance: none;
  269. /* Firefox */
  270. -webkit-appearance: none;
  271. /* Safari and Chrome */
  272. appearance: none;
  273. background-image: url("~/assets/svg/down-arrow.svg");
  274. background-size: 9px 6px;
  275. background-position: right 20px center;
  276. background-repeat: no-repeat;
  277. }
  278. </style>