profile.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import type { FormInstance, FormRules } from 'element-plus'
  4. import { getCategoryListApi, getDictListApi } from '~/api/model/common'
  5. import { getUserProfileApi, updateUserInfoApi } from '~/api/model/user'
  6. const params = ref<any>({
  7. email: '',
  8. country_dictText: '',
  9. companyType_dictText: '',
  10. companyName: '',
  11. companyAddress: '',
  12. website: '',
  13. annualPurchaseAmount: undefined,
  14. firstName: '',
  15. lastName: '',
  16. mobile: '',
  17. mobileAreaCode: '+86',
  18. })
  19. const countryList = ref()
  20. const categoryList = ref()
  21. const mobileAreaCodeList = ref()
  22. const businessTypesList = ref()
  23. const annualPurchaseAmountList = ref()
  24. const companySizeList = ref()
  25. const ruleFormRef = ref<FormInstance>()
  26. const rules = ref<FormRules>({
  27. email: [
  28. {
  29. required: true,
  30. message: 'Username must be filled in',
  31. trigger: 'blur',
  32. },
  33. ],
  34. country: [
  35. {
  36. required: true,
  37. message: 'Country must be selected',
  38. trigger: 'change',
  39. },
  40. ],
  41. companyName: [
  42. {
  43. required: true,
  44. message: 'CompanyName must be filled in',
  45. trigger: 'blur',
  46. },
  47. ],
  48. companyAddress: [
  49. {
  50. required: true,
  51. message: 'companyAddress must be filled in',
  52. trigger: 'blur',
  53. },
  54. ],
  55. companyType: [
  56. {
  57. required: true,
  58. message: 'CompanyType must be selected',
  59. trigger: 'change',
  60. },
  61. ],
  62. annualPurchaseAmount: [
  63. {
  64. required: true,
  65. message: 'annualPurchaseAmount must be filled in',
  66. trigger: 'blur',
  67. },
  68. ],
  69. companySize: [
  70. {
  71. required: true,
  72. message: 'CompanySize must be selected',
  73. trigger: 'blur',
  74. },
  75. ],
  76. firstName: [
  77. {
  78. required: true,
  79. message: 'firstName must be filled in',
  80. trigger: 'blur',
  81. },
  82. ],
  83. lastName: [
  84. {
  85. required: true,
  86. message: 'lastName must be filled in',
  87. trigger: 'blur',
  88. },
  89. ],
  90. mobile: [
  91. {
  92. required: true,
  93. message: 'mobile must be filled in',
  94. trigger: 'blur',
  95. },
  96. ],
  97. mobileAreaCode: [
  98. {
  99. required: true,
  100. message: 'mobileAreaCode must be filled in',
  101. trigger: 'blur',
  102. },
  103. ],
  104. })
  105. async function getMobileAreaCodeList() {
  106. const list = await getDictListApi('A064')
  107. mobileAreaCodeList.value = list
  108. }
  109. async function getCountryList() {
  110. const list = await getDictListApi('A070')
  111. countryList.value = list
  112. }
  113. async function getBusinessTypesList() {
  114. const list = await getDictListApi('A071')
  115. businessTypesList.value = list
  116. }
  117. async function getAnnualPurchaseAmountList() {
  118. const list = await getDictListApi('A072')
  119. annualPurchaseAmountList.value = list
  120. }
  121. async function getCompanySizeList() {
  122. const list = await getDictListApi('company_size')
  123. companySizeList.value = list
  124. }
  125. async function getCategoryList() {
  126. const list = await getCategoryListApi({
  127. all: false,
  128. })
  129. categoryList.value = list
  130. }
  131. async function submitForm(formEl: FormInstance | undefined) {
  132. if (!formEl)
  133. return
  134. await formEl.validate((valid, fields) => {
  135. if (valid) {
  136. updateUserInfoApi(params.value)
  137. ElMessage.success('Your updated profile has been submitted successfully')
  138. }
  139. else { console.log('error submit!', fields) }
  140. })
  141. }
  142. async function getUserProfile() {
  143. try {
  144. const data = await getUserProfileApi()
  145. params.value = {
  146. ...data,
  147. purchaseCategory: data.purchaseCategory.split(','),
  148. }
  149. console.log('params.value', params.value)
  150. }
  151. catch (error) {
  152. console.log(error)
  153. }
  154. }
  155. async function getData() {
  156. await getCountryList()
  157. await getCategoryList()
  158. await getBusinessTypesList()
  159. await getCompanySizeList()
  160. await getAnnualPurchaseAmountList()
  161. await getMobileAreaCodeList()
  162. await getUserProfile()
  163. }
  164. getData()
  165. </script>
  166. <template>
  167. <div class="w-500px ">
  168. <el-form
  169. ref="ruleFormRef"
  170. :model="params"
  171. :rules="rules"
  172. label-width="auto"
  173. size="default"
  174. status-icon
  175. >
  176. <el-form-item
  177. label="User Name"
  178. class="custom-form-item"
  179. prop="email"
  180. >
  181. <el-input
  182. v-model="params.email" :disabled="true"
  183. placeholder="Company name"
  184. class="h-50px"
  185. />
  186. </el-form-item>
  187. <el-form-item label="Country/Region" prop="country" class="custom-form-item">
  188. <!-- <el-select v-model="params.country" placeholder="Country">
  189. <el-option
  190. v-for="(item, index) in countryList"
  191. :key="index"
  192. class="!h-50px"
  193. :label="item.label"
  194. :value="item.value"
  195. />
  196. </el-select> -->
  197. <el-input
  198. v-model="params.country_dictText"
  199. placeholder="Country/Region"
  200. :disabled="true"
  201. class="h-50px"
  202. />
  203. </el-form-item>
  204. <el-form-item
  205. label="Company Type&Name"
  206. prop="companyType"
  207. class="custom-form-item flex "
  208. >
  209. <!-- <el-select v-model="params.companyType" placeholder="Business Types">
  210. <el-option
  211. v-for="(item, index) in businessTypesList"
  212. :key="index"
  213. class="!h-50px"
  214. :label="item.label"
  215. :value="item.value"
  216. />
  217. </el-select> -->
  218. <!-- <el-input
  219. v-model="params.companyName"
  220. placeholder="Company name"
  221. class="h-50px"
  222. /> -->
  223. <el-input
  224. v-model="params.companyType_dictText"
  225. placeholder="Company Types"
  226. :disabled="true"
  227. class="h-50px flex-grow-3 mr-10px !w-unset"
  228. />
  229. <el-input
  230. v-model="params.companyName"
  231. placeholder="company name"
  232. :disabled="true"
  233. class="h-50px flex-grow-2 !w-unset"
  234. />
  235. </el-form-item>
  236. <el-form-item
  237. label="Company Address"
  238. prop="companyAddress"
  239. class="custom-form-item"
  240. >
  241. <el-input
  242. v-model="params.companyAddress"
  243. type="textarea"
  244. placeholder="companyAddress"
  245. class="h-100px"
  246. />
  247. </el-form-item>
  248. <el-form-item
  249. label="Company Website"
  250. prop="website"
  251. class="custom-form-item"
  252. >
  253. <el-input
  254. v-model="params.website"
  255. placeholder="website"
  256. class="h-50px"
  257. />
  258. </el-form-item>
  259. <div class="flex">
  260. <el-form-item
  261. label="Name"
  262. prop="firstName"
  263. class="custom-form-item !w-unset flex-grow-3"
  264. >
  265. <el-input
  266. v-model="params.firstName"
  267. placeholder="firstName"
  268. class="h-50px"
  269. />
  270. </el-form-item>
  271. <el-form-item
  272. label=" "
  273. prop="lastName"
  274. class="custom-form-item !w-unset flex-grow-1 ml-10px"
  275. >
  276. <el-input
  277. v-model="params.lastName"
  278. placeholder="lastName"
  279. class="h-50px flex-1"
  280. />
  281. </el-form-item>
  282. </div>
  283. <el-form-item
  284. label="Category"
  285. prop="purchaseCategory"
  286. class="custom-form-item"
  287. >
  288. <el-select v-model="params.purchaseCategory" placeholder="Category" multiple>
  289. <el-option
  290. v-for="(item, index) in categoryList"
  291. :key="index"
  292. class="!h-50px !lh-50px"
  293. :label="item.title"
  294. :value="item.key"
  295. />
  296. </el-select>
  297. </el-form-item>
  298. <el-form-item
  299. label="Annual sourcing budget"
  300. prop="annualPurchaseAmount"
  301. class="custom-form-item"
  302. >
  303. <el-select
  304. v-model="params.annualPurchaseAmount"
  305. placeholder="Annual sourcing budget"
  306. >
  307. <el-option
  308. v-for="(item, index) in annualPurchaseAmountList"
  309. :key="index"
  310. class="!h-50px"
  311. :label="item.label"
  312. :value="item.value"
  313. />
  314. </el-select>
  315. </el-form-item>
  316. <el-form-item
  317. label="company size"
  318. prop="companySize"
  319. class="custom-form-item"
  320. >
  321. <el-select
  322. v-model="params.companySize"
  323. placeholder="company size"
  324. >
  325. <el-option
  326. v-for="(item, index) in companySizeList"
  327. :key="index"
  328. class="!h-50px !lh-50px"
  329. :label="item.label"
  330. :value="item.value"
  331. />
  332. </el-select>
  333. </el-form-item>
  334. <div class="flex">
  335. <el-form-item
  336. label="Mobile Number"
  337. class="custom-form-item"
  338. prop="mobile"
  339. >
  340. <el-input v-model="params.mobile" placeholder="Mobile Number" class="h-50px">
  341. <template #prepend>
  342. <el-select v-model="params.mobileAreaCode" class="!h-50px" placeholder="Select" style="width: 120px">
  343. <el-option
  344. v-for="(item, index) in mobileAreaCodeList"
  345. :key="index"
  346. :value="item.value"
  347. :label="`${item.value} ${item.label}`"
  348. >
  349. {{ item.value }} {{ item.label }}
  350. </el-option>
  351. </el-select>
  352. </template>
  353. </el-input>
  354. </el-form-item>
  355. </div>
  356. <el-form-item class="form-footer mt-25px">
  357. <el-button
  358. class="!bg-#C58C64 !text-#fff !ml-0 !w-100% !h-50px !text-18px !fw-500 !b-rd-6px"
  359. @click="submitForm(ruleFormRef)"
  360. >
  361. Save
  362. </el-button>
  363. </el-form-item>
  364. </el-form>
  365. </div>
  366. </template>
  367. <style lang="less" scoped>
  368. :deep(.custom-form-item) {
  369. width: 100%;
  370. margin-bottom: 22px;
  371. display: block !important;
  372. .el-select__wrapper {
  373. height: 50px !important;
  374. }
  375. .el-form-item__label-wrap {
  376. margin-left: unset !important;
  377. .el-form-item__label {
  378. margin-bottom: 5px;
  379. font-size: 16px !important;
  380. color: #5b463e !important;
  381. }
  382. }
  383. .el-form-item__content{
  384. .el-textarea {
  385. .el-textarea__inner{
  386. height: 100px !important;
  387. }
  388. }
  389. }
  390. .el-checkbox {
  391. .el-checkbox__input {
  392. &.is-checked {
  393. .el-checkbox__inner {
  394. color: #CC9879 !important;
  395. background-color: #CC9879 !important;
  396. border: 1px solid #CC9879 !important;
  397. }
  398. }
  399. .el-checkbox__inner {
  400. &:hover {
  401. border-color: #CC9879 !important;
  402. }
  403. }
  404. }
  405. &.is-checked {
  406. .el-checkbox__label {
  407. color: #CC9879 !important;
  408. }
  409. }
  410. }
  411. }
  412. ::v-deep(.form-footer) {
  413. .el-form-item__content {
  414. display: flex;
  415. justify-content: space-between;
  416. }
  417. }
  418. </style>