Skip to content

Commit 181c1ed

Browse files
authored
Merge pull request #82 from kiworkshop/feat/save-as-excel
[ADD] 견적서를 엑셀 파일로 다운로드 받는 기능을 추가하였습니다.
2 parents 90c8eab + ee60b63 commit 181c1ed

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

patent-calculator/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

patent-calculator/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
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",

patent-calculator/src/components/Quotation.vue

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
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>
@@ -159,11 +162,52 @@
159162
</template>
160163

161164
<script>
165+
import download from "js-file-download";
166+
162167
export 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: {

0 commit comments

Comments
 (0)