123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- <!-- @format -->
- <script lang="ts" setup>
- import type { FormInstance, FormRules } from 'element-plus'
- import { getCategoryListApi, getDictListApi } from '~/api/model/common'
- import { getUserProfileApi, updateUserInfoApi } from '~/api/model/user'
- const params = ref<any>({
- email: '',
- country_dictText: '',
- companyType_dictText: '',
- companyName: '',
- companyAddress: '',
- website: '',
- annualPurchaseAmount: undefined,
- firstName: '',
- lastName: '',
- mobile: '',
- mobileAreaCode: '+86',
- })
- const countryList = ref()
- const categoryList = ref()
- const mobileAreaCodeList = ref()
- const businessTypesList = ref()
- const annualPurchaseAmountList = ref()
- const companySizeList = ref()
- const ruleFormRef = ref<FormInstance>()
- const rules = ref<FormRules>({
- email: [
- {
- required: true,
- message: 'Username must be filled in',
- trigger: 'blur',
- },
- ],
- country: [
- {
- required: true,
- message: 'Country must be selected',
- trigger: 'change',
- },
- ],
- companyName: [
- {
- required: true,
- message: 'CompanyName must be filled in',
- trigger: 'blur',
- },
- ],
- companyAddress: [
- {
- required: true,
- message: 'companyAddress must be filled in',
- trigger: 'blur',
- },
- ],
- companyType: [
- {
- required: true,
- message: 'CompanyType must be selected',
- trigger: 'change',
- },
- ],
- annualPurchaseAmount: [
- {
- required: true,
- message: 'annualPurchaseAmount must be filled in',
- trigger: 'blur',
- },
- ],
- companySize: [
- {
- required: true,
- message: 'CompanySize must be selected',
- trigger: 'blur',
- },
- ],
- firstName: [
- {
- required: true,
- message: 'firstName must be filled in',
- trigger: 'blur',
- },
- ],
- lastName: [
- {
- required: true,
- message: 'lastName must be filled in',
- trigger: 'blur',
- },
- ],
- mobile: [
- {
- required: true,
- message: 'mobile must be filled in',
- trigger: 'blur',
- },
- ],
- mobileAreaCode: [
- {
- required: true,
- message: 'mobileAreaCode must be filled in',
- trigger: 'blur',
- },
- ],
- })
- async function getMobileAreaCodeList() {
- const list = await getDictListApi('A064')
- mobileAreaCodeList.value = list
- }
- async function getCountryList() {
- const list = await getDictListApi('A070')
- countryList.value = list
- }
- async function getBusinessTypesList() {
- const list = await getDictListApi('A071')
- businessTypesList.value = list
- }
- async function getAnnualPurchaseAmountList() {
- const list = await getDictListApi('A072')
- annualPurchaseAmountList.value = list
- }
- async function getCompanySizeList() {
- const list = await getDictListApi('company_size')
- companySizeList.value = list
- }
- async function getCategoryList() {
- const list = await getCategoryListApi({
- all: false,
- })
- categoryList.value = list
- }
- async function submitForm(formEl: FormInstance | undefined) {
- if (!formEl)
- return
- await formEl.validate((valid, fields) => {
- if (valid) {
- updateUserInfoApi(params.value)
- ElMessage.success('Your updated profile has been submitted successfully')
- }
- else { console.log('error submit!', fields) }
- })
- }
- async function getUserProfile() {
- try {
- const data = await getUserProfileApi()
- params.value = {
- ...data,
- purchaseCategory: data.purchaseCategory.split(','),
- }
- console.log('params.value', params.value)
- }
- catch (error) {
- console.log(error)
- }
- }
- async function getData() {
- await getCountryList()
- await getCategoryList()
- await getBusinessTypesList()
- await getCompanySizeList()
- await getAnnualPurchaseAmountList()
- await getMobileAreaCodeList()
- await getUserProfile()
- }
- getData()
- </script>
- <template>
- <div class="w-500px ">
- <el-form
- ref="ruleFormRef"
- :model="params"
- :rules="rules"
- label-width="auto"
- size="default"
- status-icon
- >
- <el-form-item
- label="User Name"
- class="custom-form-item"
- prop="email"
- >
- <el-input
- v-model="params.email" :disabled="true"
- placeholder="Company name"
- class="h-50px"
- />
- </el-form-item>
- <el-form-item label="Country/Region" prop="country" class="custom-form-item">
- <!-- <el-select v-model="params.country" placeholder="Country">
- <el-option
- v-for="(item, index) in countryList"
- :key="index"
- class="!h-50px"
- :label="item.label"
- :value="item.value"
- />
- </el-select> -->
- <el-input
- v-model="params.country_dictText"
- placeholder="Country/Region"
- :disabled="true"
- class="h-50px"
- />
- </el-form-item>
- <el-form-item
- label="Company Type&Name"
- prop="companyType"
- class="custom-form-item flex "
- >
- <!-- <el-select v-model="params.companyType" placeholder="Business Types">
- <el-option
- v-for="(item, index) in businessTypesList"
- :key="index"
- class="!h-50px"
- :label="item.label"
- :value="item.value"
- />
- </el-select> -->
- <!-- <el-input
- v-model="params.companyName"
- placeholder="Company name"
- class="h-50px"
- /> -->
- <el-input
- v-model="params.companyType_dictText"
- placeholder="Company Types"
- :disabled="true"
- class="h-50px flex-grow-3 mr-10px !w-unset"
- />
- <el-input
- v-model="params.companyName"
- placeholder="company name"
- :disabled="true"
- class="h-50px flex-grow-2 !w-unset"
- />
- </el-form-item>
- <el-form-item
- label="Company Address"
- prop="companyAddress"
- class="custom-form-item"
- >
- <el-input
- v-model="params.companyAddress"
- type="textarea"
- placeholder="companyAddress"
- class="h-100px"
- />
- </el-form-item>
- <el-form-item
- label="Company Website"
- prop="website"
- class="custom-form-item"
- >
- <el-input
- v-model="params.website"
- placeholder="website"
- class="h-50px"
- />
- </el-form-item>
- <div class="flex">
- <el-form-item
- label="Name"
- prop="firstName"
- class="custom-form-item !w-unset flex-grow-3"
- >
- <el-input
- v-model="params.firstName"
- placeholder="firstName"
- class="h-50px"
- />
- </el-form-item>
- <el-form-item
- label=" "
- prop="lastName"
- class="custom-form-item !w-unset flex-grow-1 ml-10px"
- >
- <el-input
- v-model="params.lastName"
- placeholder="lastName"
- class="h-50px flex-1"
- />
- </el-form-item>
- </div>
- <el-form-item
- label="Category"
- prop="purchaseCategory"
- class="custom-form-item"
- >
- <el-select v-model="params.purchaseCategory" placeholder="Category" multiple>
- <el-option
- v-for="(item, index) in categoryList"
- :key="index"
- class="!h-50px !lh-50px"
- :label="item.title"
- :value="item.key"
- />
- </el-select>
- </el-form-item>
- <el-form-item
- label="Annual sourcing budget"
- prop="annualPurchaseAmount"
- class="custom-form-item"
- >
- <el-select
- v-model="params.annualPurchaseAmount"
- placeholder="Annual sourcing budget"
- >
- <el-option
- v-for="(item, index) in annualPurchaseAmountList"
- :key="index"
- class="!h-50px"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item
- label="company size"
- prop="companySize"
- class="custom-form-item"
- >
- <el-select
- v-model="params.companySize"
- placeholder="company size"
- >
- <el-option
- v-for="(item, index) in companySizeList"
- :key="index"
- class="!h-50px !lh-50px"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- <div class="flex">
- <el-form-item
- label="Mobile Number"
- class="custom-form-item"
- prop="mobile"
- >
- <el-input v-model="params.mobile" placeholder="Mobile Number" class="h-50px">
- <template #prepend>
- <el-select v-model="params.mobileAreaCode" class="!h-50px" placeholder="Select" style="width: 120px">
- <el-option
- v-for="(item, index) in mobileAreaCodeList"
- :key="index"
- :value="item.value"
- :label="`${item.value} ${item.label}`"
- >
- {{ item.value }} {{ item.label }}
- </el-option>
- </el-select>
- </template>
- </el-input>
- </el-form-item>
- </div>
- <el-form-item class="form-footer mt-25px">
- <el-button
- class="!bg-#C58C64 !text-#fff !ml-0 !w-100% !h-50px !text-18px !fw-500 !b-rd-6px"
- @click="submitForm(ruleFormRef)"
- >
- Save
- </el-button>
- </el-form-item>
- </el-form>
- </div>
- </template>
- <style lang="less" scoped>
- :deep(.custom-form-item) {
- width: 100%;
- margin-bottom: 22px;
- display: block !important;
- .el-select__wrapper {
- height: 50px !important;
- }
- .el-form-item__label-wrap {
- margin-left: unset !important;
- .el-form-item__label {
- margin-bottom: 5px;
- font-size: 16px !important;
- color: #5b463e !important;
- }
- }
- .el-form-item__content{
- .el-textarea {
- .el-textarea__inner{
- height: 100px !important;
- }
- }
- }
- .el-checkbox {
- .el-checkbox__input {
- &.is-checked {
- .el-checkbox__inner {
- color: #CC9879 !important;
- background-color: #CC9879 !important;
- border: 1px solid #CC9879 !important;
- }
- }
- .el-checkbox__inner {
- &:hover {
- border-color: #CC9879 !important;
- }
- }
- }
- &.is-checked {
- .el-checkbox__label {
- color: #CC9879 !important;
- }
- }
- }
- }
- ::v-deep(.form-footer) {
- .el-form-item__content {
- display: flex;
- justify-content: space-between;
- }
- }
- </style>
|