|
|
@@ -0,0 +1,86 @@
|
|
|
+<template>
|
|
|
+ <el-select
|
|
|
+ v-bind="$attrs"
|
|
|
+ :value="value"
|
|
|
+ :disabled="disabled"
|
|
|
+ class="ng-stockist-select"
|
|
|
+ placeholder="Select stockist"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ v-on="$listeners"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="stockist in options"
|
|
|
+ :key="stockist.id"
|
|
|
+ :label="`${stockist.name} (${stockist.id})`"
|
|
|
+ :value="stockist.id"
|
|
|
+ >
|
|
|
+ <span class="ng-stockist-option">
|
|
|
+ <span class="ng-stockist-option-name">{{ stockist.name }}</span>
|
|
|
+ <span class="ng-stockist-option-id">{{ stockist.id }}</span>
|
|
|
+ </span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+const testStockists = {
|
|
|
+ '620699181539139625': [{ id: 'NG48655323', name: 'S4' }],
|
|
|
+ '620699181539139643': [{ id: 'AE28801941', name: 'ZAIDI ASRAF BIN IDRIS' }]
|
|
|
+}
|
|
|
+
|
|
|
+const productionStockists = {
|
|
|
+ '620699181539139625': [
|
|
|
+ { id: 'NG576513886', name: 'Elken Onyx Shop' },
|
|
|
+ { id: 'NG538666436', name: 'Shalom Shop' },
|
|
|
+ { id: 'NG662021398', name: 'Elken Great Achievers' },
|
|
|
+ { id: 'NG87440247', name: 'De Wellness Centre' },
|
|
|
+ { id: 'NG92944313', name: 'Elken JC Solution Centre' }
|
|
|
+ ],
|
|
|
+ '620699181539139643': [{ id: 'AE000000001', name: 'AETOP' }]
|
|
|
+}
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'StockistSelect',
|
|
|
+ inheritAttrs: false,
|
|
|
+ props: {
|
|
|
+ value: { type: String, default: '' },
|
|
|
+ countryId: { type: String, default: '' },
|
|
|
+ disabled: Boolean
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ options() {
|
|
|
+ // Staging also uses NODE_ENV=production, but points to the UAT API.
|
|
|
+ const production = process.env.VUE_APP_BASE_DO_API === 'https://ng-frontend-api.elken.com'
|
|
|
+ const stockists = production ? productionStockists : testStockists
|
|
|
+ return stockists[this.countryId] || []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ countryId(countryId, previousCountryId) {
|
|
|
+ if (previousCountryId && this.value && !this.disabled) this.$emit('input', '')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.ng-stockist-select {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+.ng-stockist-option {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ gap: 12px;
|
|
|
+ max-width: calc(100vw - 72px);
|
|
|
+}
|
|
|
+.ng-stockist-option-name {
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+}
|
|
|
+.ng-stockist-option-id {
|
|
|
+ flex-shrink: 0;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #606266;
|
|
|
+}
|
|
|
+</style>
|