import { UniversalDataService } from '/js/ApiDataServer/Universal.js';
import { OrderDataService } from '/js/ApiDataServer/Order.js';
import { RESPONSE_STATUS } from '/js/constants.js';
import { Decorator } from '/js/util/dacorator.js';


var vMain = new Vue({
    el: "#content",
    data: function () {
        return {
            orderMainId: -1,
            list: [],
            storeSupplier: ""
        };
    },
    created: async function () {
        this.orderMainId = uj.getParameterByName("oid");
        this.loadData();
        this.storeSupplier = await UniversalDataService.GetContractStoreSupplier();
    },
    methods: {
        async loadData() {
            var v = this;

            var res = await OrderDataService.GetPrint(v.orderMainId);
            if (res.status == RESPONSE_STATUS.OK) {
                v.list = res.data;
                v.list.forEach(function (packingObj) {
                    packingObj.orderObj.details.list.forEach(function (item) {
                        item.startDate = Decorator.ChangeISODateTimeToTwDate(item.startDate);
                    });
                });
            } else {
                var data = res.data;
                alert(data.message);
            }
        }
    }
});