update: change the type

This commit is contained in:
mahyargdz
2025-05-27 16:43:26 +03:30
parent a771f7e199
commit d24481b598
8 changed files with 384 additions and 207 deletions
+27 -4
View File
@@ -45,12 +45,28 @@
<el-table-column prop="full_name" label="نام" width=""> </el-table-column>
<el-table-column prop="mobile_number" label="شماره موبایل" width=""> </el-table-column>
<el-table-column label="نوع نماینده" width="300">
<template slot-scope="scope">
<span v-if="scope.row.representation_type === 'both'">نماینده هر دو نوع لوازم</span>
<span v-if="scope.row.representation_type === 'verity'">نماینده لوازم جانبی کامپیوتر و موبایل</span>
<span v-if="scope.row.representation_type === 'panatech'">نماینده لوازم صوتی تصویری خودرو</span>
<!-- Handle new representation_type format (array) -->
<div v-if="Array.isArray(scope.row.representation_type) && scope.row.representation_type.length > 0">
<span v-if="scope.row.representation_type.includes('mobile_accessories')">محصولات جانبی موبایل</span>
<span v-if="scope.row.representation_type.includes('computer_accessories')"
>، محصولات جانبی کامپیوتر</span
>
<span v-if="scope.row.representation_type.includes('memory_products')">، محصولات حافظه</span>
<span v-if="scope.row.representation_type.includes('car_audio_video')"
>، محصولات صوتی و تصویری خودرو</span
>
<span v-if="scope.row.representation_type.includes('home_products')">، محصولات خانگی</span>
<!-- Handle legacy data -->
<span v-else-if="scope.row.representation_type.includes('both')">نماینده هر دو نوع لوازم (قدیمی)</span>
<span v-else-if="scope.row.representation_type.includes('verity')">
نماینده لوازم جانبی کامپیوتر و موبایل (قدیمی)</span
>
<span v-else-if="scope.row.representation_type.includes('panatech')">
نماینده لوازم صوتی تصویری خودرو (قدیمی)</span
>
</div>
</template>
</el-table-column>
@@ -105,6 +121,13 @@
:description="validation.first_name ? validation.first_name.msg : null"
:class="validation.first_name ? 'err' : null"
/>
<CInput
v-model="registerData.representation_code"
label="کد نماینده"
horizontal
:description="validation.representation_code ? validation.representation_code.msg : null"
:class="validation.representation_code ? 'err' : null"
/>
<CInput
v-model="registerData.last_name"
label="نام خانوادگی"
+36 -13
View File
@@ -13,9 +13,11 @@
<div class="col-12 col-md-4 mb-3">
<el-select v-model="representationType" placeholder="نوع نماینده" style="width: 100%">
<el-option label="همه نمایندگان آسان سرویس" value="all" />
<el-option label="نمایندگان لوازم جانبی کامپیوتر و موبایل" value="verity" />
<el-option label="نمایندگان لوازم صوتی و تصویری خودرو" value="panatech" />
<el-option label="نمایندگانی که هر دو نوع لوازم را پشتیبانی میکنند" value="both" />
<el-option label="محصولات جانبی موبایل" value="mobile_accessories" />
<el-option label="محصولات جانبی کامپیوتر" value="computer_accessories" />
<el-option label="محصولات حافظه" value="memory_products" />
<el-option label="محصولات صوتی و تصویری خودرو" value="car_audio_video" />
<el-option label="محصولات خانگی" value="home_products" />
</el-select>
</div>
<div class="col-12 col-md-4 mb-3">
@@ -67,11 +69,21 @@
<el-table :data="filteredItems" style="width: 100%">
<el-table-column type="index" label="#"> </el-table-column>
<el-table-column label="نوع نماینده" width="">
<template slot-scope="scope">
<span v-if="scope.row.representation_type === 'both'">نماینده هر دو نوع لوازم</span>
<span v-if="scope.row.representation_type === 'verity'">نماینده لوازم جانبی کامپیوتر و موبایل</span>
<span v-if="scope.row.representation_type === 'panatech'">نماینده لوازم صوتی تصویری خودرو</span>
<el-table-column label="نوع نماینده" width="">
<template slot-scope="scope">
<div>
<span v-if="scope.row.representation_type.includes('mobile_accessories')"
>محصولات جانبی موبایل</span
>
<span v-if="scope.row.representation_type.includes('computer_accessories')"
>، محصولات جانبی کامپیوتر</span
>
<span v-if="scope.row.representation_type.includes('memory_products')">، محصولات حافظه</span>
<span v-if="scope.row.representation_type.includes('car_audio_video')"
>، محصولات صوتی و تصویری خودرو</span
>
<span v-if="scope.row.representation_type.includes('home_products')">، محصولات خانگی</span>
</div>
</template>
</el-table-column>
@@ -139,11 +151,22 @@ export default {
computed: {
filteredItems() {
const filterByRepresentationType = this.agents.filter(item => {
if (this.representationType === 'all') return true
else if (this.representationType === 'verity') return item.representation_type === 'verity' || item.representation_type === 'both'
else if (this.representationType === 'panatech') return item.representation_type === 'panatech' || item.representation_type === 'both'
else if (this.representationType === 'both') return item.representation_type === 'both'
else return false
if (this.representationType === 'all') {
return true
} else if (Array.isArray(item.representation_type)) {
return item.representation_type.includes(this.representationType)
} else {
// Handle legacy data where representation_type might be a string
const legacyType = item.representation_type
if (this.representationType === 'mobile_accessories' || this.representationType === 'computer_accessories') {
return legacyType === 'verity' || legacyType === 'both'
} else if (this.representationType === 'car_audio_video') {
return legacyType === 'panatech' || legacyType === 'both'
} else {
return false
}
}
})
const filterByProvinceAndCity = filterByRepresentationType.filter(item => {
// remember order is important (first shoud check city)