ShopCompleteInfo.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. <template>
  2. <div class="complete-info">
  3. <q-banner class="banner complete-info-top-banner">
  4. {{ mainTitle }}
  5. </q-banner>
  6. <q-card class="complete-info-steps-card">
  7. <div class="complete-info-step">
  8. <svg xmlns="http://www.w3.org/2000/svg"
  9. width="17.053"
  10. height="19.866"
  11. viewBox="0 0 17.053 19.866">
  12. <g id="Paper"
  13. transform="translate(0 0)">
  14. <path id="Combined_Shape"
  15. data-name="Combined Shape"
  16. d="M4.475,19.866A4.585,4.585,0,0,1,0,15.188V4.491A4.606,4.606,0,0,1,4.57.012h6.271a.758.758,0,0,1,.265,0h.131a.755.755,0,0,1,.541.23l5.065,5.277a.753.753,0,0,1,.209.519V15.2A4.615,4.615,0,0,1,12.6,19.865H4.475ZM1.5,4.509V15.2a3.091,3.091,0,0,0,3.009,3.162h8.064a3.109,3.109,0,0,0,2.979-3.155V6.984h-2.01a3.332,3.332,0,0,1-3.318-3.325V1.512H4.572A3.089,3.089,0,0,0,1.5,4.509Zm10.224-.85a1.828,1.828,0,0,0,1.82,1.824H14.73L11.724,2.353ZM5.387,14.108a.75.75,0,0,1,0-1.5h5.4a.75.75,0,0,1,0,1.5Zm0-3.752a.75.75,0,0,1,0-1.5H8.743a.75.75,0,0,1,0,1.5Z"
  17. transform="translate(0.001 0)"
  18. fill="#5b7a5f" />
  19. </g>
  20. </svg>
  21. <span class="title">
  22. {{ step1Title }}
  23. <svg xmlns="http://www.w3.org/2000/svg"
  24. width="15"
  25. height="15"
  26. viewBox="0 0 15 15">
  27. <g id="Group_11510"
  28. data-name="Group 11510"
  29. transform="translate(-1215 -335)">
  30. <circle id="Ellipse_819"
  31. data-name="Ellipse 819"
  32. cx="7.5"
  33. cy="7.5"
  34. r="7.5"
  35. transform="translate(1215 335)"
  36. fill="#19cb99" />
  37. <path id="Path"
  38. d="M8.615,1.5l-4.75,4.75a.881.881,0,0,1-1.23,0L.255,3.875A.877.877,0,0,1,1.5,2.635l1.75,1.75L7.375.255A.877.877,0,0,1,8.615,1.5"
  39. transform="translate(1218 339)"
  40. fill="#f6f6f6" />
  41. </g>
  42. </svg>
  43. </span>
  44. </div>
  45. <div class="complete-info-step">
  46. <svg xmlns="http://www.w3.org/2000/svg"
  47. width="15.84"
  48. height="19.87"
  49. viewBox="0 0 15.84 19.87">
  50. <g id="Profile"
  51. transform="translate(0 0)">
  52. <path id="Combined_Shape"
  53. data-name="Combined Shape"
  54. d="M0,16.174c0-3.3,4.521-3.677,7.921-3.677,1.958,0,7.919,0,7.919,3.7,0,3.295-4.52,3.677-7.919,3.677C5.962,19.87,0,19.87,0,16.174Zm1.5,0c0,1.458,2.16,2.2,6.421,2.2s6.419-.733,6.419-2.177S12.18,14,7.921,14,1.5,14.729,1.5,16.174Zm6.389-5.555A5.31,5.31,0,0,1,7.921,0a5.31,5.31,0,0,1,0,10.619ZM4.038,5.31A3.873,3.873,0,0,0,7.892,9.192l.029.715V9.192A3.882,3.882,0,1,0,4.038,5.31Z"
  55. transform="translate(0 0)"
  56. fill="#212121" />
  57. </g>
  58. </svg>
  59. <span class="title">
  60. تکمیل اطلاعات
  61. </span>
  62. </div>
  63. <div class="complete-info-step">
  64. <svg xmlns="http://www.w3.org/2000/svg"
  65. width="20.639"
  66. height="19.173"
  67. viewBox="0 0 20.639 19.173">
  68. <g id="Wallet"
  69. transform="translate(0)">
  70. <path id="Combined_Shape"
  71. data-name="Combined Shape"
  72. d="M6,19.173a6,6,0,0,1-6-6V6A6,6,0,0,1,6,0h8.645a6,6,0,0,1,6,6v7.178a6,6,0,0,1-6,6ZM1.5,6v7.178a4.5,4.5,0,0,0,4.5,4.5h8.645a4.5,4.5,0,0,0,4.5-4.5V12.9h-3.3a3.441,3.441,0,1,1,0-6.881h3.3V6a4.5,4.5,0,0,0-4.5-4.5H6A4.5,4.5,0,0,0,1.5,6ZM13.9,9.455a1.945,1.945,0,0,0,1.942,1.94h3.3V7.513h-3.3A1.946,1.946,0,0,0,13.9,9.455Zm2.088.688a.75.75,0,0,1,0-1.5H16.3a.75.75,0,0,1,0,1.5ZM5.286,6.038a.75.75,0,0,1,0-1.5h5.4a.75.75,0,1,1,0,1.5Z"
  73. transform="translate(0 0)"
  74. fill="#bcbcbc" />
  75. </g>
  76. </svg>
  77. <span class="title">
  78. پرداخت
  79. </span>
  80. </div>
  81. </q-card>
  82. <q-tab-panels v-model="panel"
  83. animated
  84. class="panels">
  85. <q-tab-panel name="userInfo">
  86. <q-banner class="banner complete-info-form-banner">
  87. تکمیل اطلاعات
  88. </q-banner>
  89. <q-card class="complete-info-form-card">
  90. <entity-edit v-if="mounted"
  91. ref="entityEdit"
  92. v-model:value="inputs"
  93. title="اطلاعات کاربری"
  94. :api="api"
  95. :entity-id-key="entityIdKey"
  96. :entity-param-key="entityParamKey"
  97. :show-route-name="showRouteName"
  98. :show-close-button="false"
  99. :show-edit-button="false"
  100. :show-expand-button="false"
  101. :show-save-button="false"
  102. :show-reload-button="false"
  103. :redirect-after-edit="false"
  104. :after-load-input-data="afterLoadInputData" />
  105. </q-card>
  106. <div class="flex justify-end section-edit-btn">
  107. <q-btn color="primary"
  108. @click="editEntity">
  109. تایید و ادامه
  110. <svg xmlns="http://www.w3.org/2000/svg"
  111. width="18.387"
  112. height="11.502"
  113. viewBox="0 0 18.387 11.502">
  114. <path id="Combined_Shape"
  115. data-name="Combined Shape"
  116. d="M-9.338,11.408a.748.748,0,0,0,.388-.656V6.5h8.2A.751.751,0,0,0,0,5.75.75.75,0,0,0-.75,5h-8.2V.75A.751.751,0,0,0-9.338.093.769.769,0,0,0-9.7,0a.735.735,0,0,0-.4.115l-7.938,5a.747.747,0,0,0-.35.635.742.742,0,0,0,.35.634l7.938,5a.751.751,0,0,0,.4.116A.746.746,0,0,0-9.338,11.408ZM-10.45,9.392l-5.78-3.641,5.78-3.642Z"
  117. transform="translate(18.387)"
  118. fill="#fff" />
  119. </svg>
  120. </q-btn>
  121. </div>
  122. </q-tab-panel>
  123. <q-tab-panel name="eventTest">
  124. <q-banner class="banner complete-info-form-banner">
  125. پرسشنامه
  126. </q-banner>
  127. <show-event-test v-if="!eventTestAnswerBook.loading"
  128. :answer-book-id="eventTestAnswerBook.id" />
  129. <div v-else>
  130. کمی صبر کنید...
  131. </div>
  132. </q-tab-panel>
  133. </q-tab-panels>
  134. </div>
  135. </template>
  136. <script>
  137. import { EntityEdit } from 'quasar-crud'
  138. import Enums from 'src/assets/Enums/Enums.js'
  139. import { Invoice } from 'src/models/Invoice.js'
  140. import { mixinAuth } from 'src/mixin/Mixins.js'
  141. import ShamsiDate from 'src/assets/ShamsiDate.js'
  142. import { APIGateway } from 'src/api/APIGateway.js'
  143. import { Classroom } from 'src/models/Classroom.js'
  144. import { AnswerBook } from 'src/models/AnswerBook.js'
  145. import { FormBuilderAssist } from 'quasar-form-builder'
  146. import ShowEventTest from './components/ShowEventTest.vue'
  147. import { Provinces, Cities, getCitiesOfProvince } from 'src/assets/js/IranianCities.js'
  148. export default {
  149. name: 'ShopCompleteInfo',
  150. components: { EntityEdit, ShowEventTest },
  151. mixins: [mixinAuth],
  152. data: () => ({
  153. mounted: false,
  154. inputDataLoaded: false,
  155. panel: 'userInfo',
  156. step: false,
  157. rulesAccept: false,
  158. rulesDialog: false,
  159. loading: true,
  160. classroom: new Classroom(),
  161. invoice: new Invoice(),
  162. eventTestAnswerBook: new AnswerBook(),
  163. api: APIGateway.user.APIAdresses.current,
  164. entityIdKey: 'id',
  165. entityParamKey: 'id',
  166. showRouteName: 'UserPanel.ShopPaymentFromWallet',
  167. inputs: [
  168. { type: 'separator', name: 'space', label: 'اطلاعات ضروری', col: 'col-12' },
  169. { type: 'input', name: 'email', label: 'ایمیل', responseKey: 'email', placeholder: ' ', disable: true, col: ' col-md-3 col-12' },
  170. { type: 'input', name: 'mobile_number', label: 'تلفن همراه', responseKey: 'mobile_number', placeholder: ' ', disable: true, col: ' col-md-3 col-12' },
  171. { type: 'optionGroupRadio', name: 'is_valid_national_code', label: 'اتباع خارجی', responseKey: 'is_valid_national_code', options: [{ label: 'نیستم', value: true }, { label: 'هستم', value: false }], value: true, className: 'require', col: 'col-md-3 col-12' },
  172. { type: 'input', name: 'national_code', label: 'کدملی/کد اتباع غیر ایرانی', responseKey: 'national_code', placeholder: ' ', className: 'require', col: ' col-md-3 col-12' },
  173. { type: 'separator', name: 'space', label: 'اطلاعات پروفایل', col: 'col-12' },
  174. { type: 'file', name: 'picture', label: 'عکس پروفایل', responseKey: 'picture', placeholder: ' ', col: ' col-md-3 col-12' },
  175. { type: 'separator', name: 'space', size: '0', col: 'col-12' },
  176. { type: 'input', name: 'firstname', label: 'نام', responseKey: 'firstname', placeholder: ' ', className: 'require', col: ' col-md-3 col-12' },
  177. { type: 'input', name: 'lastname', label: 'نام خانوادگی', responseKey: 'lastname', placeholder: ' ', className: 'require', col: ' col-md-3 col-12' },
  178. {
  179. type: 'select',
  180. name: 'gender',
  181. responseKey: 'gender',
  182. placeholder: ' ',
  183. options: Enums.genders,
  184. value: null,
  185. className: 'require',
  186. label: 'جنسیت',
  187. col: ' col-md-3 col-12'
  188. },
  189. { type: 'date', name: 'birthdate', outsideLabel: 'تولد', responseKey: 'birthdate', className: 'require', col: ' col-md-3 col-12' },
  190. {
  191. type: 'select',
  192. name: 'marital_status',
  193. responseKey: 'marital_status',
  194. placeholder: ' ',
  195. options: Enums.maritalStatuses,
  196. value: null,
  197. className: 'require',
  198. label: 'وضعیت تاهل',
  199. col: ' col-md-3 col-12'
  200. },
  201. { type: 'input', name: 'on_call_mobile_number', label: 'تلفن همراه جهت تماس', responseKey: 'on_call_mobile_number', placeholder: ' ', className: 'require', col: ' col-md-3 col-12' },
  202. { type: 'input', name: 'on_social_network_mobile_number', label: 'تلفن همراه جهت شبکه های اجتماعی', responseKey: 'on_social_network_mobile_number', placeholder: ' ', className: 'require', col: ' col-md-3 col-12' },
  203. { type: 'input', name: 'phone_number', label: 'تلفن منزل', responseKey: 'phone_number', placeholder: 'با کد شهر وارد شود', className: 'require', col: ' col-md-3 col-12' },
  204. {
  205. type: 'select',
  206. name: 'last_academic_degree',
  207. responseKey: 'last_academic_degree',
  208. placeholder: ' ',
  209. options: Enums.academicDegree,
  210. value: null,
  211. className: 'require',
  212. label: 'آخرین مقطع تحصیلی',
  213. col: ' col-md-3 col-12'
  214. },
  215. { type: 'input', name: 'last_academic_degree_field', label: 'رشته تحصیلی', responseKey: 'last_academic_degree_field', placeholder: ' ', className: 'require', col: ' col-md-3 col-12' },
  216. { type: 'input', name: 'last_academy_name', label: 'نام دانشگاه یا حوزه تحصیلی', responseKey: 'last_academy_name', placeholder: ' ', className: 'require', col: ' col-md-3 col-12' },
  217. {
  218. type: 'select',
  219. name: 'educational_status',
  220. responseKey: 'educational_status',
  221. placeholder: ' ',
  222. options: Enums.educationalStatus,
  223. value: null,
  224. className: 'require',
  225. label: 'وضعیت تحصیلی',
  226. col: ' col-md-3 col-12'
  227. },
  228. { type: 'checkbox', name: 'is_abroad_birth_address', placeholder: ' ', label: 'محل تولد خارج از کشور است؟', responseKey: 'is_abroad_birth_address', className: 'require', col: 'col-12' },
  229. { type: 'input', name: 'birth_country', label: 'کشور محل تولد', responseKey: 'birth_country', placeholder: ' ', className: 'require', col: 'col-md-4 col-12' },
  230. {
  231. type: 'select',
  232. name: 'birth_province',
  233. options: Provinces,
  234. optionLabel: 'name',
  235. optionValue: 'name',
  236. createNewValue: true,
  237. newValueMode: 'add-unique',
  238. label: 'استان محل تولد',
  239. responseKey: 'birth_province',
  240. placeholder: ' ',
  241. className: 'require',
  242. col: 'col-md-4 col-12'
  243. },
  244. {
  245. type: 'select',
  246. name: 'birth_city',
  247. options: Cities,
  248. optionLabel: 'name',
  249. optionValue: 'name',
  250. createNewValue: true,
  251. newValueMode: 'add-unique',
  252. label: 'شهر محل تولد',
  253. responseKey: 'birth_city',
  254. placeholder: ' ',
  255. className: 'require',
  256. col: 'col-md-4 col-12'
  257. },
  258. { type: 'checkbox', name: 'is_abroad_living_address', placeholder: ' ', label: 'محل زندگی فعلی خارج از کشور است؟', responseKey: 'is_abroad_living_address', className: 'require', col: 'col-12' },
  259. { type: 'input', name: 'living_country', label: 'کشور محل زندگی فعلی', responseKey: 'living_country', placeholder: ' ', className: 'require', col: 'col-md-4 col-12' },
  260. {
  261. type: 'select',
  262. name: 'living_province',
  263. options: Provinces,
  264. optionLabel: 'name',
  265. optionValue: 'name',
  266. createNewValue: true,
  267. newValueMode: 'add-unique',
  268. label: 'استان محل زندگی فعلی',
  269. responseKey: 'living_province',
  270. placeholder: ' ',
  271. className: 'require',
  272. col: 'col-md-4 col-12'
  273. },
  274. {
  275. type: 'select',
  276. name: 'living_city',
  277. options: Cities,
  278. optionLabel: 'name',
  279. optionValue: 'name',
  280. createNewValue: true,
  281. newValueMode: 'add-unique',
  282. label: 'شهر محل زندگی فعلی',
  283. responseKey: 'living_city',
  284. placeholder: ' ',
  285. className: 'require',
  286. col: 'col-md-4 col-12'
  287. },
  288. { type: 'input', name: 'living_postal_code', label: 'کد پستی محل زندگی', responseKey: 'living_postal_code', placeholder: ' ', className: 'require', col: ' col-md-3 col-12' },
  289. { type: 'input', name: 'living_address', label: 'آدرس پستی محل زندگی', responseKey: 'living_address', placeholder: ' ', className: 'require', col: 'col-md-9 col-12' },
  290. { type: 'hidden', name: 'id', responseKey: 'id' }
  291. ]
  292. }),
  293. computed: {
  294. isAbroadBirthAddress () {
  295. return FormBuilderAssist.getInputsByName(this.inputs, 'is_abroad_birth_address').value
  296. },
  297. isAbroadLivingAddress () {
  298. return FormBuilderAssist.getInputsByName(this.inputs, 'is_abroad_living_address').value
  299. },
  300. mainTitle () {
  301. if (this.$route.query.source === 'event') {
  302. return 'ثبت نام در رویداد'
  303. } else {
  304. return 'ثبت نام در دوره آموزشی'
  305. }
  306. },
  307. step1Title () {
  308. if (this.$route.query.source === 'event') {
  309. return 'مشاهده جزییات و قوانین رویداد'
  310. } else {
  311. return 'مشاهده جزییات و قوانین دوره'
  312. }
  313. },
  314. selectedBirthProvince () {
  315. return FormBuilderAssist.getInputsByName(this.inputs, 'birth_province').value
  316. },
  317. selectedLivingProvince () {
  318. return FormBuilderAssist.getInputsByName(this.inputs, 'living_province').value
  319. }
  320. },
  321. watch: {
  322. isAbroadBirthAddress: {
  323. immediate: true,
  324. handler (newValue) {
  325. this.$nextTick(() => {
  326. if (!newValue) {
  327. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_country', 'value', 'ایران')
  328. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_country', 'readonly', true)
  329. if (this.inputDataLoaded) {
  330. // province
  331. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_province', 'type', 'select')
  332. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_province', 'disable', false)
  333. // FormBuilderAssist.setAttributeByName(this.inputs, 'birth_province', 'value', null)
  334. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_province', 'options', Provinces)
  335. // city
  336. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'type', 'select')
  337. // FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'disable', true)
  338. // FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'value', null)
  339. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'options', getCitiesOfProvince(this.selectedBirthProvince))
  340. }
  341. } else {
  342. // FormBuilderAssist.setAttributeByName(this.inputs, 'birth_country', 'value', null)
  343. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_country', 'readonly', false)
  344. if (this.inputDataLoaded) {
  345. // province
  346. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_province', 'type', 'input')
  347. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_province', 'disable', false)
  348. // city
  349. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'type', 'input')
  350. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'disable', false)
  351. // FormBuilderAssist.setAttributeByName(this.inputs, 'birth_province', 'value', null)
  352. // FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'value', null)
  353. }
  354. }
  355. })
  356. }
  357. },
  358. isAbroadLivingAddress: {
  359. immediate: true,
  360. handler (newValue) {
  361. this.$nextTick(() => {
  362. if (!newValue) {
  363. FormBuilderAssist.setAttributeByName(this.inputs, 'living_country', 'value', 'ایران')
  364. FormBuilderAssist.setAttributeByName(this.inputs, 'living_country', 'readonly', true)
  365. if (this.inputDataLoaded) {
  366. // province
  367. FormBuilderAssist.setAttributeByName(this.inputs, 'living_province', 'type', 'select')
  368. FormBuilderAssist.setAttributeByName(this.inputs, 'living_province', 'disable', false)
  369. // FormBuilderAssist.setAttributeByName(this.inputs, 'living_province', 'value', null)
  370. FormBuilderAssist.setAttributeByName(this.inputs, 'living_province', 'options', Provinces)
  371. // city
  372. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'type', 'select')
  373. // FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'disable', true)
  374. // FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'value', null)
  375. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'options', getCitiesOfProvince(this.selectedLivingProvince))
  376. }
  377. } else {
  378. // FormBuilderAssist.setAttributeByName(this.inputs, 'living_country', 'value', null)
  379. FormBuilderAssist.setAttributeByName(this.inputs, 'living_country', 'readonly', false)
  380. if (this.inputDataLoaded) {
  381. // province
  382. FormBuilderAssist.setAttributeByName(this.inputs, 'living_province', 'type', 'input')
  383. FormBuilderAssist.setAttributeByName(this.inputs, 'living_province', 'disable', false)
  384. // city
  385. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'type', 'input')
  386. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'disable', false)
  387. // FormBuilderAssist.setAttributeByName(this.inputs, 'living_province', 'value', null)
  388. // FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'value', null)
  389. }
  390. }
  391. })
  392. }
  393. },
  394. selectedBirthProvince (newValue) {
  395. if (this.isAbroadBirthAddress) {
  396. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'type', 'input')
  397. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'disable', false)
  398. return
  399. }
  400. if (!newValue) {
  401. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'disable', true)
  402. if (this.inputDataLoaded) {
  403. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'value', null)
  404. }
  405. return
  406. }
  407. const filteredCities = getCitiesOfProvince(this.selectedBirthProvince)
  408. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'options', filteredCities)
  409. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'disable', false)
  410. if (this.inputDataLoaded) {
  411. FormBuilderAssist.setAttributeByName(this.inputs, 'birth_city', 'value', null)
  412. }
  413. },
  414. selectedLivingProvince (newValue) {
  415. if (this.isAbroadBirthAddress) {
  416. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'type', 'input')
  417. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'disable', false)
  418. return
  419. }
  420. if (!newValue) {
  421. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'disable', true)
  422. if (this.inputDataLoaded) {
  423. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'value', null)
  424. }
  425. return
  426. }
  427. const filteredCities = getCitiesOfProvince(this.selectedLivingProvince)
  428. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'options', filteredCities)
  429. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'disable', false)
  430. if (this.inputDataLoaded) {
  431. FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'value', null)
  432. }
  433. }
  434. },
  435. mounted () {
  436. this.loadClassroomFromStore()
  437. if (this.$route.query.source === 'event') {
  438. this.getEventTest()
  439. }
  440. this.mounted = true
  441. this.$bus.on('event-confirmation-step-test-sent-answer-sending', () => {
  442. })
  443. this.$bus.on('event-confirmation-step-test-sent-answer-success', () => {
  444. this.successSentTest()
  445. })
  446. this.$bus.on('event-confirmation-step-test-sent-answer-failed', () => {
  447. this.sentTestFailed()
  448. })
  449. },
  450. methods: {
  451. getEventTest () {
  452. if (this.classroom.tests && this.classroom.tests.length === 0) {
  453. return
  454. }
  455. this.getEventTestAnswerBook(this.classroom.tests[0])
  456. },
  457. getEventTestAnswerBook (eventTestId) {
  458. this.eventTestAnswerBook.loading = true
  459. APIGateway.answerBook.getOrCreate(this.user.id, eventTestId)
  460. .then((answerBook) => {
  461. this.eventTestAnswerBook = new AnswerBook(answerBook)
  462. this.eventTestAnswerBook.loading = false
  463. })
  464. .catch(() => {
  465. this.eventTestAnswerBook.loading = false
  466. })
  467. },
  468. loadClassroomFromStore () {
  469. this.classroom = this.$store.getters['Shop/onRegisterClassroom']
  470. },
  471. sentTestFailed () {
  472. this.panel = 'userInfo'
  473. },
  474. successSentTest () {
  475. this.editEntity()
  476. },
  477. editEntity () {
  478. if (this.eventTestAnswerBook.id && this.panel !== 'eventTest') {
  479. this.panel = 'eventTest'
  480. return
  481. }
  482. this.panel = 'userInfo'
  483. this.$nextTick(() => {
  484. this.$refs.entityEdit.editEntity(false)
  485. .then(() => {
  486. if (this.$route.query.type === 'register') {
  487. this.createInvoiceForClassroomOrRegisterEvent()
  488. } else {
  489. this.$router.push({ name: 'UserPanel.ShopPaymentFromWallet', query: this.$route.query })
  490. }
  491. })
  492. .catch(() => {})
  493. })
  494. },
  495. createInvoiceForClassroomOrRegisterEvent () {
  496. this.register()
  497. .then((data) => {
  498. if (data === 'Invoice') {
  499. this.$router.push({ name: 'UserPanel.ShopPaymentFromWallet', query: this.$route.query })
  500. }
  501. })
  502. .catch(() => {})
  503. },
  504. register () {
  505. return new Promise((resolve, reject) => {
  506. this.invoice.loading = true
  507. APIGateway.classroom.register(this.classroom.id)
  508. .then((data) => {
  509. if (data.type === 'Invoice') {
  510. this.invoice = new Invoice(data.model)
  511. this.invoice.loading = false
  512. this.$store.commit('Shop/updateRegisterClassroomInvoice', this.invoice)
  513. this.$q.notify({
  514. message: 'صورت حساب شما ایجاد شد',
  515. type: 'positive'
  516. })
  517. resolve('Invoice')
  518. } else if (data.type === 'Registration') {
  519. this.$q.notify({
  520. message: 'ثبت نام شما با موفقیت انجام شد.',
  521. type: 'positive'
  522. })
  523. const eventRegistrationId = data.model.classroom_info.id
  524. if (this.$route.query.source === 'event') {
  525. this.$router.push({ name: 'UserPanel.Profile.EventInfo', params: { id: eventRegistrationId } })
  526. } else {
  527. this.$router.push({ name: 'UserPanel.Profile.ClassroomInfo', params: { id: eventRegistrationId } })
  528. }
  529. }
  530. })
  531. .catch(() => {
  532. this.invoice.loading = false
  533. reject()
  534. })
  535. })
  536. },
  537. createInvoice () {
  538. return new Promise((resolve, reject) => {
  539. this.invoice.loading = true
  540. APIGateway.classroom.createInvoice(this.classroom.id)
  541. .then((invoice) => {
  542. this.invoice = new Invoice(invoice)
  543. this.invoice.loading = false
  544. this.$store.commit('Shop/updateRegisterClassroomInvoice', this.invoice)
  545. this.$q.notify({
  546. message: 'صورت حساب شما ایجاد شد',
  547. type: 'positive'
  548. })
  549. resolve(this.invoice)
  550. })
  551. .catch(() => {
  552. this.invoice.loading = false
  553. reject()
  554. })
  555. })
  556. },
  557. afterLoadInputData () {
  558. this.checkNationalCode()
  559. this.$nextTick(() => {
  560. this.inputDataLoaded = true
  561. })
  562. },
  563. checkNationalCode () {
  564. if (FormBuilderAssist.getInputsByName(this.inputs, 'national_code')?.value) {
  565. FormBuilderAssist.setAttributeByName(this.inputs, 'national_code', 'readonly', true)
  566. }
  567. },
  568. openRulesDialog () {
  569. this.rulesDialog = true
  570. },
  571. getHoldingType (type) {
  572. const target = (new Classroom()).holding_typeEnums.find(item => item.value === type)
  573. if (target) {
  574. return target.label
  575. }
  576. return '-'
  577. },
  578. getTime (time) {
  579. return ShamsiDate.getDateTime(time)
  580. },
  581. getTerm (classroom) {
  582. if (!classroom.beginning_registration_period) {
  583. return '-'
  584. }
  585. return ShamsiDate.getTerm(classroom.beginning_registration_period)
  586. }
  587. }
  588. }
  589. </script>
  590. <style scoped lang="scss">
  591. .complete-info {
  592. .complete-info-top-banner {
  593. margin-top: 50px;
  594. margin-bottom: 42px;
  595. }
  596. .complete-info-steps-card {
  597. background-color: #F5F5F5;
  598. padding: 35px 0;
  599. border-radius: 8px;
  600. display: flex;
  601. flex-flow: row;
  602. justify-content: center;
  603. margin-bottom: 44px;
  604. .complete-info-step {
  605. display: flex;
  606. flex-flow: row;
  607. position: relative;
  608. width: 20%;
  609. &:first-child {
  610. .title {
  611. color: #5B7A5F;
  612. }
  613. }
  614. &:after {
  615. content: ' ';
  616. position: absolute;
  617. left: 0;
  618. top: 10px;
  619. width: 95%;
  620. border-top: dotted 2px #5B7A5F;
  621. z-index: 1;
  622. }
  623. &:last-child {
  624. &:after {
  625. width: 0;
  626. }
  627. .title {
  628. color: #BCBCBC;
  629. }
  630. }
  631. .title {
  632. position: relative;
  633. background-color: #F5F5F5;
  634. z-index: 2;
  635. padding-right: 20px;
  636. }
  637. svg {
  638. width: 17px;
  639. position: relative;
  640. background-color: #F5F5F5;
  641. z-index: 2;
  642. padding-right: 8px;
  643. }
  644. }
  645. }
  646. .complete-info-form-banner {
  647. margin-bottom: 26px;
  648. }
  649. .complete-info-form-card {
  650. background-color: #F5F5F5;
  651. padding: 50px 30px;
  652. border-radius: 8px;
  653. &:deep {
  654. .q-card.entity-edit {
  655. background: transparent;
  656. .q-toolbar,
  657. & > .q-separator {
  658. display: none;
  659. }
  660. }
  661. }
  662. }
  663. :deep(.panels) {
  664. background: transparent;
  665. }
  666. .section-edit-btn {
  667. margin-top: 50px;
  668. margin-bottom: 77px;
  669. }
  670. }
  671. </style>