/* Minification failed. Returning unminified contents.
(1,1): run-time error CSS1019: Unexpected token, found '$'
(1,2): run-time error CSS1019: Unexpected token, found '('
(1,12): run-time error CSS1031: Expected selector, found '('
(1,12): run-time error CSS1025: Expected comma or open brace, found '('
(304,2): run-time error CSS1019: Unexpected token, found ')'
 */
$(function () {

    var preitem = JSON.parse(sessionStorage.getItem("entry")) || {};
    sessionStorage.removeItem("entry");
    twarranty.vuemodel = new Vue({
        el: '#my-app',
        data: {
            firstName: preitem.firstName || '',
            lastName: preitem.lastName || '',
            address: preitem.address || '',
            tel: preitem.tel || '',
            makerCd: preitem.makerCd || '',
            warrantyCd: preitem.warrantyCd || '',
            makerName: preitem.makerName || '',
            modelNumber: preitem.modelNumber || '',
            productName: preitem.productName || '',
            serialNumber: preitem.serialNumber || '',
            purchasPrice: preitem.purchasPrice || '',
            warrantyFee: preitem.warrantyFee || '',
            warrantyStartDate: preitem.warrantyStartDate || '',
            dealerCode: preitem.dealerCode || '',
            dealerName: preitem.dealerName || '',
            staffName: preitem.staffName || '',
            dealerTel: preitem.dealerTel || '',
            dealerFax: preitem.dealerFax || '',
            makerCdOptions: [
                { text: '東芝：1', value: '1' },
                { text: 'パナソニック：2', value: '2' },
                { text: 'シャープ：3', value: '3' },
                { text: 'ソニー：4', value: '4' },
                { text: '日立：5', value: '5' },
                { text: '三菱電機：6', value: '6' },
                { text: '三菱重工：7', value: '7' },
                { text: '富士通ゼネラル：8', value: '8' },
                { text: 'ダイキン：9', value: '9' },
                { text: 'コロナ：10', value: '10' },
                { text: '象印：11', value: '11' },
                { text: 'タイガー：12', value: '12' },
                //{ text: 'ユーイング：13', value: '13' },
                { text: 'エレクトロラックス：14', value: '14' },
                { text: 'アイリスオーヤマ：15', value: '15' },
                { text: '富士通：16', value: '16' },
                { text: 'NEC：17', value: '17' },
                { text: 'Apple(パソコン)：18', value: '18' },
                { text: 'ハイアールアジア(アクア)：19', value: '19' },
                { text: 'ダイナブック：20', value: '20' },
                { text: 'TVS REGZA：21', value: '21' }
            ],
            warrantyCdOptions: [
                { text: 'A1', value: 'A1' },
                { text: 'A2', value: 'A2' },
                { text: 'A3', value: 'A3' },
                { text: 'A4', value: 'A4' },
                { text: 'A5', value: 'A5' },
                { text: 'B1', value: 'B1' },
                { text: 'B2', value: 'B2' },
                { text: 'C2', value: 'C2' },
                { text: 'D1', value: 'D1' },
                { text: 'D2', value: 'D2' },
                { text: 'D3', value: 'D3' },
                { text: 'E1', value: 'E1' },
                { text: 'E2', value: 'E2' },
                { text: 'E3', value: 'E3' },
                { text: 'F1', value: 'F1' },
                { text: 'G1', value: 'G1' },
                { text: 'H1', value: 'H1' },
                { text: 'H2', value: 'H2' },
                { text: 'J1', value: 'J1' },
                { text: 'K1', value: 'K1' },
                { text: 'M1', value: 'M1' },
                { text: 'M2', value: 'M2' },
                { text: 'K2', value: 'K2' },
                { text: 'L1', value: 'L1' },
                { text: 'L2', value: 'L2' }
            ],
            productNameOptions: [
                { text: '24V型以下液晶テレビ(リモコン保証対象)', value: '24V型以下液晶テレビ(リモコン保証対象)' },
                { text: '25-34V型液晶テレビ(リモコン保証対象)', value: '25-34V型液晶テレビ(リモコン保証対象)' },
                { text: '35-44V型液晶テレビ(リモコン保証対象)', value: '35-44V型液晶テレビ(リモコン保証対象)' },
                { text: '45-54V型液晶テレビ(リモコン保証対象)', value: '45-54V型液晶テレビ(リモコン保証対象)' },
                { text: '55V型以上液晶テレビ(リモコン保証対象)', value: '55V型以上液晶テレビ(リモコン保証対象)' },
                { text: 'DVDプレイヤー ポータブル含む(リモコン保証対象)', value: 'DVDプレイヤー ポータブル含む(リモコン保証対象)' },
                { text: 'DVDレコーダー(リモコン保証対象)', value: 'DVDレコーダー(リモコン保証対象)' },
                { text: 'パソコン(タブレット除く)', value: 'パソコン(タブレット除く)' },
                { text: '冷蔵庫(5年保証)', value: '冷蔵庫(5年保証)' },
                { text: 'オーブンレンジ・電子レンジ', value: 'オーブンレンジ・電子レンジ' },
                { text: 'ジャー炊飯器', value: 'ジャー炊飯器' },
                { text: 'ドラム式洗濯機', value: 'ドラム式洗濯機' },
                { text: 'ドラム式洗濯機(7年)', value: 'ドラム式洗濯機(7年)' },
                { text: '全自動洗濯機、全自動乾燥洗濯機、二槽式洗濯機', value: '全自動洗濯機、全自動乾燥洗濯機、二槽式洗濯機' },
                { text: '全自動洗濯機、全自動乾燥洗濯機、二槽式洗濯機(7年)', value: '全自動洗濯機、全自動乾燥洗濯機、二槽式洗濯機(7年)' },
                { text: '衣類乾燥機', value: '衣類乾燥機' },
                { text: '温水便座(後付けタイプ)', value: '温水便座(後付けタイプ)' },
                { text: 'クリーナー ロボット含む(クリーナーヘッド保証対象)', value: 'クリーナー ロボット含む(クリーナーヘッド保証対象)' },
                { text: '空気洗浄機', value: '空気洗浄機' },
                { text: '除湿器', value: '除湿器' },
                { text: 'ルームエアコン(リモコン保証対象)(5年保証)', value: 'ルームエアコン(リモコン保証対象)(5年保証)' },
                { text: 'ビルトインIHクッキングヒーター(5年保証)', value: 'ビルトインIHクッキングヒーター(5年保証)' },
                { text: 'ビルトインIHクッキングヒーター(10年保証)', value: 'ビルトインIHクッキングヒーター(10年保証)' },
                { text: '冷蔵庫(10年保証)', value: '冷蔵庫(10年保証)' },
                { text: 'ルームエアコン(リモコン保証対象)(10年保証)', value: 'ルームエアコン(リモコン保証対象)(10年保証)' }
            ],
            warrantyFeeOptions: [
                { text: '3,960', value: '3960' },
                { text: '7,040', value: '7040' },
                { text: '26,840', value: '26840' },
                { text: '68,860', value: '68860' },
                { text: '6,600', value: '6600' },
                { text: '8,690', value: '8690' },
                { text: '14,300', value: '14300' },
                { text: '5,280', value: '5280' },
                { text: '5,830', value: '5830' },
                { text: '3,960', value: '3960' },
                { text: '11,220', value: '11220' },
                { text: '4,180', value: '4180' },
                { text: '9,020', value: '9020' },
                { text: '3,080', value: '3080' },
                { text: '3,850', value: '3850' },
                { text: '3,520', value: '3520' },
                { text: '5,280', value: '5280' },
                { text: '6,050', value: '6050' },
                { text: '20,460', value: '20460' },
                { text: '6,820', value: '6820' },
                { text: '10,450', value: '10450' },
                { text: '25,800', value: '25800' },
                { text: '12,650', value: '12650' }
            ],
        },
        mounted: function () {
            twarranty.vuemodel = this;
        },
        methods: {
            doSubmit: async function (event) {
                this.$validator.validateAll()
                    .then((result) => {
                        if (result) {
                            // 二重クリック防止
                            twarranty.loading(true);

                            // パラメータ
                            var item = JSON.parse(JSON.stringify(twarranty.vuemodel.$data));
                            sessionStorage.setItem("entry", JSON.stringify(item));
                            $('#form')
                                .attr("action", twarranty.urls.confirm)
                                .attr("method", "post")
                                .submit();
                        }
                    }
                    );
            },
            changeMakerCd: function () {
                twarranty.vuemodel.$data.makerName = this.getMakerName(twarranty.vuemodel.$data.makerCd);
            },
            getMakerName: function (makerCd) {
                switch (makerCd) {
                    case '1': return '東芝';
                    case '2': return 'パナソニック';
                    case '3': return 'シャープ';
                    case '4': return 'ソニー';
                    case '5': return '日立';
                    case '6': return '三菱電機';
                    case '7': return '三菱重工';
                    case '8': return '富士通ゼネラル';
                    case '9': return 'ダイキン';
                    case '10': return 'コロナ';
                    case '11': return '象印';
                    case '12': return 'タイガー';
                    //case '13': return 'ユーイング';
                    case '14': return 'エレクトロラックス';
                    case '15': return 'アイリスオーヤマ';
                    case '16': return '富士通';
                    case '17': return 'NEC';
                    case '18': return 'Apple(パソコン)';
                    case '19': return 'ハイアールアジア(アクア)';
                    case '20': return 'ダイナブック';
                    case '21': return 'TVS REGZA';
                    default: return '';
                }
            },
            changeWarrantyCd: function () {
                twarranty.vuemodel.$data.productName = this.getProductName(twarranty.vuemodel.$data.warrantyCd);
                twarranty.vuemodel.$data.warrantyFee = this.getWarrantyFee(twarranty.vuemodel.$data.warrantyCd);
            },
            changeProductName: function () {
                twarranty.vuemodel.$data.warrantyCd = this.getWarrantyCd(twarranty.vuemodel.$data.productName);
                twarranty.vuemodel.$data.warrantyFee = this.getWarrantyFee(twarranty.vuemodel.$data.warrantyCd);
            },
            getWarrantyCd: function (productName) {
                switch (productName) {
                    case '24V型以下液晶テレビ(リモコン保証対象)': return 'A1';
                    case '25-34V型液晶テレビ(リモコン保証対象)': return 'A2';
                    case '35-44V型液晶テレビ(リモコン保証対象)': return 'A3';
                    case '45-54V型液晶テレビ(リモコン保証対象)': return 'A4';
                    case '55V型以上液晶テレビ(リモコン保証対象)': return 'A5';
                    case 'DVDプレイヤー ポータブル含む(リモコン保証対象)': return 'B1';
                    case 'DVDレコーダー(リモコン保証対象)': return 'B2';
                    case 'パソコン(タブレット除く)': return 'C2';
                    case '冷蔵庫(5年保証)': return 'D1';
                    case 'オーブンレンジ・電子レンジ': return 'D2';
                    case 'ジャー炊飯器': return 'D3';
                    case 'ドラム式洗濯機': return 'E1';
                    case '全自動洗濯機、全自動乾燥洗濯機、二槽式洗濯機': return 'E2';
                    case '衣類乾燥機': return 'E3';
                    case '温水便座(後付けタイプ)': return 'F1';
                    case 'クリーナー ロボット含む(クリーナーヘッド保証対象)': return 'G1';
                    case '空気洗浄機': return 'H1';
                    case '除湿器': return 'H2';
                    case 'ルームエアコン(リモコン保証対象)(5年保証)': return 'J1';
                    case 'ビルトインIHクッキングヒーター(5年保証)': return 'K1';
                    case 'ドラム式洗濯機(7年)': return 'M1';
                    case '全自動洗濯機、全自動乾燥洗濯機、二槽式洗濯機(7年)': return 'M2';
                    case 'ビルトインIHクッキングヒーター(10年保証)': return 'K2';
                    case '冷蔵庫(10年保証)': return 'L1';
                    case 'ルームエアコン(リモコン保証対象)(10年保証)': return 'L2';
                    default: return '';
                }
            },
            getProductName: function (warrantyCd) {
                switch (warrantyCd) {
                    case 'A1': return '24V型以下液晶テレビ(リモコン保証対象)';
                    case 'A2': return '25-34V型液晶テレビ(リモコン保証対象)';
                    case 'A3': return '35-44V型液晶テレビ(リモコン保証対象)';
                    case 'A4': return '45-54V型液晶テレビ(リモコン保証対象)';
                    case 'A5': return '55V型以上液晶テレビ(リモコン保証対象)';
                    case 'B1': return 'DVDプレイヤー ポータブル含む(リモコン保証対象)';
                    case 'B2': return 'DVDレコーダー(リモコン保証対象)';
                    case 'C2': return 'パソコン(タブレット除く)';
                    case 'D1': return '冷蔵庫(5年保証)';
                    case 'D2': return 'オーブンレンジ・電子レンジ';
                    case 'D3': return 'ジャー炊飯器';
                    case 'E1': return 'ドラム式洗濯機';
                    case 'E2': return '全自動洗濯機、全自動乾燥洗濯機、二槽式洗濯機';
                    case 'E3': return '衣類乾燥機';
                    case 'F1': return '温水便座(後付けタイプ)';
                    case 'G1': return 'クリーナー ロボット含む(クリーナーヘッド保証対象)';
                    case 'H1': return '空気洗浄機';
                    case 'H2': return '除湿器';
                    case 'J1': return 'ルームエアコン(リモコン保証対象)(5年保証)';
                    case 'K1': return 'ビルトインIHクッキングヒーター(5年保証)';
                    case 'M1': return 'ドラム式洗濯機(7年)';
                    case 'M2': return '全自動洗濯機、全自動乾燥洗濯機、二槽式洗濯機(7年)';
                    case 'K2': return 'ビルトインIHクッキングヒーター(10年保証)';
                    case 'L1': return '冷蔵庫(10年保証)';
                    case 'L2': return 'ルームエアコン(リモコン保証対象)(10年保証)';
                    default: return '';
                }
            },
            getWarrantyFee: function (warrantyCd) {
                switch (warrantyCd) {
                    case 'A1': return '3960';
                    case 'A2': return '7040';
                    case 'A3': return '26840';
                    case 'A4': return '68860';
                    case 'A5': return '68860';
                    case 'B1': return '6600';
                    case 'B2': return '8690';
                    case 'C2': return '14300';
                    case 'D1': return '5280';
                    case 'D2': return '5830';
                    case 'D3': return '3960';
                    case 'E1': return '11220';
                    case 'E2': return '4180';
                    case 'E3': return '9020';
                    case 'F1': return '3080';
                    case 'G1': return '3850';
                    case 'H1': return '3520';
                    case 'H2': return '3520';
                    case 'J1': return '5280';
                    case 'K1': return '6050';
                    case 'M1': return '20460';
                    case 'M2': return '6820';
                    case 'K2': return '10450';
                    case 'L1': return '25800';
                    case 'L2': return '12650';
                    default: return '';
                }

            },

        }
    });

    $('#warrantyStartDate').datetimepicker({
        minDate: moment().subtract(1, 'months'),
        format: 'YYYY/MM/DD',
        icons: {
            time: "fa fa-clock-o",
            date: "fa fa-calendar",
            up: "fa fa-chevron-up",
            down: "fa fa-chevron-down",
            previous: 'fa fa-chevron-left',
            next: 'fa fa-chevron-right',
            today: 'fa fa-screenshot',
            clear: 'fa fa-trash',
            close: 'fa fa-remove'
        }
    }).on('dp.change', function (e) {
        twarranty.vuemodel.$data.warrantyStartDate = $(this).val();
    });

    $('#purchasPrice').mousewheel(function (eo, delta, deltaX, deltaY) {
        eo.preventDefault();
    });
});
