import { defineComponent, ref, reactive } from 'vue'
import styles from './index.module.css'
import axios from 'axios'
import {
Table,
TableCell,
TableRow,
TableHead,
TableBody,
Button,
Loader,
Input,
InputSearch
} from '@fe/ozi'
import { item, order} from './constants'
interface tPostingJson {
order_id: number;
number: string;
order_state_id: number;
items: {
id: number;
item_id: number;
quantity: number;
}[];
isPaid:boolean;
}
export default defineComponent({
setup() {
const isLoading = ref(false)
const postingJson: tPostingJson[] = reactive([])
const sendRequest = async () => {
try {
isLoading.value = true;
console.log('Данные для отправки:', order);
const response = await axios.post('https://oms-js-service-orderkraken-stg.ozonru.me/v2/order/create', order);
const newPosting = {
order_id: response.data.data.order_id,
number: response.data.data.number,
order_state_id: response.data.data.order_state_id,
items: response.data.data.items,
isPaid:false
};
try {
const pay = await axios.post('https://oms-js-service-orderkraken-stg.ozonru.me/api/order-paid', {"order_number": newPosting.number});
console.log('Успешный ответ (order-paid):', pay.data);
newPosting.isPaid = true
} catch (payError) {
console.error('Ошибка (order-paid):', payError);
}
console.log('Успешный ответ (order create):', response.data);
postingJson.push(newPosting);
isLoading.value = false;
console.log('postingJson:', postingJson);
} catch (error) {
console.error('Ошибка (order create):', error);
isLoading.value = false;
}
};
return () => (
<div class={styles.page}>
<div class={styles.buttonBox}>
<Button class={styles.createButton} size={400} whenClick={sendRequest}>создать постинг моно день в день</Button>
<Input
class={styles.buttonInput}
label={'Item'}
placeholder={'Введи item id'}
whenChange={(value)=>{item.value = value; console.log(item)}}
/>
</div>
<Table>
<TableHead>
<TableRow>
<TableCell bottomBorder class={styles.headerCell}>
<Button
class={styles.headerButton}
style={'display: inline-grid;'}
size={400}
variant={'ghost'}
>
Номер постинга
</Button>
</TableCell>
<TableCell bottomBorder leftBorder class={styles.headerCell}>
<Button
class={styles.headerButton}
style={'display: inline-grid;'}
size={400}
variant={'ghost'}
>
Orderid
</Button>
</TableCell>
<TableCell leftBorder bottomBorder class={styles.headerCell}>
<Button
class={styles.headerButton}
style={'display: inline-grid;'}
size={400}
variant={'ghost'}
>
Cutoff при создании
</Button>
</TableCell>
<TableCell bottomBorder leftBorder class={styles.headerCell}>
<Button
class={styles.headerButton}
style={'display: inline-grid;'}
size={400}
variant={'ghost'}
>
Айтем
</Button>
</TableCell>
<TableCell bottomBorder leftBorder class={styles.headerCell}>
<Button
class={styles.headerButton}
style={'display: inline-grid;'}
size={400}
variant={'ghost'}
>
Количество
</Button>
</TableCell>
<TableCell bottomBorder leftBorder class={styles.headerCell}>
<Button
class={styles.headerButton}
style={'display: inline-grid;'}
size={400}
variant={'ghost'}
>
Оплачено
</Button>
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{isLoading.value ? (
<TableRow class={styles.loaderRow}>
<Loader class={styles.loader} />
</TableRow>
) : (
postingJson.map(posting => (
<TableRow key={posting.order_id}>
<TableCell leftBorder>{posting.number}</TableCell>
<TableCell leftBorder>{posting.order_id}</TableCell>
<TableCell leftBorder>{order.virtual_postings[0].shipment_date}</TableCell>
<TableCell leftBorder>{posting.items[0].item_id}</TableCell>
<TableCell leftBorder>{posting.items[0].quantity}</TableCell>
<TableCell leftBorder>{posting.isPaid ? 'Да' : 'Нет'}</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
</div>
)
},
})
import { addressMap, clientId, clientLoyaltyStateId, deliveryAttributes, getDeliveryTimeForDayToDay } from "./posting-info";
import { ref, computed } from 'vue'
export const item = ref('0')
export const order = computed(() => ({
'client_id': clientId,
'client_loyalty_state_id': clientLoyaltyStateId,
'client_legal': false,
'payment_type_id': 3,
'payment_type_prepay': true,
'payment_type_online': true,
'seller_id': undefined,
'address': undefined,
'address_map': addressMap,
'delivery_attributes': deliveryAttributes,
'delivery_price': 300,
'comment': 'From supply chain QA - comment',
'client_tariff_zone_id': 16780,
'client_delivery_variant_id': 11469,
'delivery_variant_id': 11469,
'client_delivery_variant': 'From supply chain QA - delivery',
'delivery_choice_id': 1,
'client_account_payment': 0,
'client_exit_date': getDeliveryTimeForDayToDay(),
'mart_id': 1,
'ip': '192.168.0.1',
'is_cross_dock': false,
'is_gift_order': false,
'is_today_delivery': false,
'merchant_id': 667,
'application': 'desktop',
'tags': [],
'items': [{
'item_id': item.value,
'marketplace_seller_id': 120,
'marketplace_seller_price': 300,
'price': 300,
'quantity': 1,
'score_to_add': 0,
'attributes': [],
'client_score_value': 0,
'discount': 0,
'installment_price': 0,
'is_cross_dock': false,
'is_fresh': false,
'is_rewards_expiration': false,
'item_discount_amount': 0,
'src_price': 0,
'weight': '500'
}],
'is_test': false,
'uuid': '1c61f340-bb08-4662-9503-043d18bd42da',
'virtual_postings': [{
'posting_suggested_number': 1,
'address': 'key_1',
'physical_store_id': '12856',
'shipment_date': getDeliveryTimeForDayToDay(),
'min_delivery_date': getDeliveryTimeForDayToDay(),
'max_delivery_date': getDeliveryTimeForDayToDay(),
'time_slot_id': '111',
'delivery_payment_for_time_slot': 0,
'is_user_choice': true,
'items': [{
'item_id': item.value,
'quantity': 1,
'item_availability_id': 1,
'weight': '500',
'width': '31',
'length': '32',
'height': '33',
'delivery_schema': 'Retail',
'marketplace_seller_id': 120
}],
'is_simulated': false,
'special_flags': undefined,
'first_mile_type': undefined,
'seller_warehouse_id': '18978815247000',
'shipping_provider_id': 1461294009000,
'marketplace_seller_id': 120,
'delivery_price': 300,
'rezon_delivery_variant_id': '67517',
'clearing_delivery_variant_id': '22534442431000',
'delivery_schema': 'Retail',
'delivery_type': 'courier',
'dropoff_point_id': undefined,
'external_drop_point_id': undefined,
'delivery_variant_name': 'Текстовое название доставки',
'delivery_restrictions': {'max_price': 100, 'max_weight': 100},
'border_type': undefined,
'additional_info': [{'code': 'IsExpress', 'value': '1'}, {'code': 'department', 'value': 'Supermarket'}, {'code': 'HasPackage', 'value': '0'}],
'pickup_point_id': undefined,
'tpl_integration_type': 'Ozon'
}],
'marketing_client_order_marketing_actions': [],
'client_order_external_spp_address_info': [],
'client_order_external_tarrification_info': [],
'additional_info': [{'code': 'ozonPreOrder', 'value': 'c9737375-1f20-474c-9e43-a3d3e7c6dff8'}, {'code': 'IsExpress', 'value': '1'}, {'code': 'Department', 'value': 'Supermarket'}],
'marketing_addition_info': []
}))