File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "axios" : " ^0.18.0" ,
1313 "elasticsearch" : " ^15.2.0" ,
14+ "js-file-download" : " ^0.4.4" ,
1415 "vue" : " ^2.5.17" ,
1516 "vue-session" : " ^1.0.0" ,
1617 "vuetify" : " ^1.0.19" ,
Original file line number Diff line number Diff line change 77 <h1 class =" headline font-weight-bold mb-5" >{{현재거래처}} 견적서</h1 >
88 </v-flex >
99 <v-spacer ></v-spacer >
10+ <v-btn :loading =" saveLoading" icon @click =" saveAsExcel()" >
11+ <v-icon >vertical_align_bottom</v-icon >
12+ </v-btn >
1013 <v-btn icon @click =" print()" >
1114 <v-icon >print</v-icon >
1215 </v-btn >
159162</template >
160163
161164<script >
165+ import download from " js-file-download" ;
166+
162167export default {
163168 name: " Quotation" ,
169+ data () {
170+ return {
171+ saveLoading: false
172+ };
173+ },
164174 methods: {
165175 print () {
166176 window .print ();
177+ },
178+ saveAsExcel () {
179+ const ec2URL =
180+ " http://ec2-13-125-38-231.ap-northeast-2.compute.amazonaws.com/excel" ;
181+
182+ let quotationPointer = this ;
183+ this .toggleLoader ();
184+ this .$http ({
185+ method: " post" ,
186+ url: ec2URL,
187+ data: {
188+ 분류: Object .keys (this .$store .getters .selected ),
189+ 비용: this .$store .getters .calculateFee
190+ },
191+ responseType: " arraybuffer"
192+ })
193+ .then (function (response ) {
194+ download (
195+ response .data ,
196+ " 견적서.xlsx" ,
197+ " application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
198+ );
199+ quotationPointer .toggleLoader ();
200+ })
201+ .catch (function () {
202+ quotationPointer .toggleLoader ();
203+ quotationPointer .$noticeEventBus .$emit (
204+ " raiseNotice" ,
205+ " 견적서 다운로드에 실패했습니다. 네트워크를 확인해주세요."
206+ );
207+ });
208+ },
209+ toggleLoader () {
210+ this .saveLoading = ! this .saveLoading ;
167211 }
168212 },
169213 computed: {
You can’t perform that action at this time.
0 commit comments