Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 67 additions & 9 deletions patent-calculator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions patent-calculator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"axios": "^0.18.0",
"elasticsearch": "^15.2.0",
"vue": "^2.5.17",
"vue-session": "^1.0.0",
"vuetify": "^1.0.19",
Expand Down
18 changes: 9 additions & 9 deletions patent-calculator/src/components/Briefcase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<h1 class="headline font-weight-bold mb-2">상품 관리</h1>
<v-layout row>
<v-flex xs4>
<v-select v-model="search._class" :items="classes" label="분류"></v-select>
<v-select v-model="searchbar.classification" :items="classes" label="분류"></v-select>
</v-flex>
<v-spacer></v-spacer>
<v-flex xs7>
<v-text-field
v-model="search.name"
v-model="searchbar.keywords"
append-icon="search"
label="명칭"
single-line
Expand All @@ -22,7 +22,7 @@
<v-data-table
:headers="headers"
:items="selected"
:search="search.name"
:search="searchbar.keywords"
:rows-per-page-items="rowsPerPageItems"
no-data-text="선택된 지정상품이 없습니다."
class="mt-3"
Expand Down Expand Up @@ -64,7 +64,7 @@
:value="true"
color="error"
icon="warning"
>"{{ search.name }}"을(를) 찾을 수 없습니다.</v-alert>
>"{{ searchbar.keywords }}"을(를) 찾을 수 없습니다.</v-alert>
</v-data-table>
<v-dialog v-model="dialog" width="500">
<v-card>
Expand Down Expand Up @@ -111,9 +111,9 @@ export default {
dialog: false,
productClass: "",
rowsPerPageItems: [10, 25, 100],
search: {
_class: "전체",
name: ""
searchbar: {
classification: "전체",
keywords: ""
},
headers: [
{
Expand Down Expand Up @@ -194,8 +194,8 @@ export default {
},
selected() {
const selected = this.$store.getters.selected;
const classId = this.classes.indexOf(this.search._class);
if (this.search._class === "전체") {
const classId = this.classes.indexOf(this.searchbar.classification);
if (this.searchbar.classification === "전체") {
return Object.values(selected).reduce((acc, val) => {
return acc.concat(Object.values(val));
}, []);
Expand Down
91 changes: 61 additions & 30 deletions patent-calculator/src/components/ProductAdder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
<v-stepper-items class="elevation-0">
<v-stepper-content step="1" class="pt-0">
<v-layout column wrap>
<v-flex v-for="payload in payloads" :key="payload.id" class="my-2">
<v-flex v-for="searchbar in searchbars" :key="searchbar.id" class="my-2">
<v-layout column wrap>
<v-flex>
<v-layout row>
<v-flex xs4 class="ml-2">
<v-select v-model="payload.classString" :items="classes" label="분류"></v-select>
<v-select v-model="searchbar.classification" :items="classes" label="분류"></v-select>
</v-flex>
<v-flex xs8 class="ml-5">
<v-textarea
v-model="payload.searchingProducts"
v-model="searchbar.keywords"
append-icon="search"
placeholder="명칭 (붕산비료, 생물 비료, 도매업)"
auto-grow
Expand All @@ -38,7 +38,7 @@
color="secondary"
flat
slot="activator"
@click="deleteForm(payload.id)"
@click="deleteForm(searchbar.id)"
>
<v-icon>delete</v-icon>
</v-btn>
Expand Down Expand Up @@ -105,16 +105,15 @@ export default {
},
data() {
return {
payloads: [
searchbars: [
{
id: 1,
classString: "",
_class: -1,
searchingProducts: ""
classification: "",
keywords: ""
}
],
curStep: 0,
formCount: 1,
searchbarId: 1,
searchLoading: false
};
},
Expand All @@ -124,27 +123,59 @@ export default {
}
},
methods: {
isNoticed(keyword, checklist) {
return (
Object.keys(checklist).length > 0 &&
checklist.hasOwnProperty(this.trim(keyword))
);
},
trim(keyword) {
return keyword.replace(/\s/g, "");
},
classifyProducts() {
this.searchLoading = true;
for (let i = 0; i < this.payloads.length; i++) {
this.payloads[i]._class = this.classes.indexOf(
this.payloads[i].classString
);
}
const requests = [];
for (let i = 0; i < this.payloads.length; i++) {
for (const searchbar of this.searchbars) {
const classification = this.classes.indexOf(searchbar.classification);
requests.push(
this.$searchManager.search(this.payloads[i]).then(response => {
return response;
this.$searchManager.search(0, searchbar.keywords).then(response => {
const checklist = response.reduce((acc, val) => {
acc[this.trim(val["지정상품(국문)"])] = val;
return acc;
}, {});

const keywords = this.$searchManager.trimKeywords(
searchbar.keywords
);

const noticed = keywords
.filter(keyword => this.isNoticed(keyword, checklist))
.map(keyword => checklist[this.trim(keyword)]);

const unnoticed = keywords
.filter(keyword => !this.isNoticed(keyword, checklist))
.map(keyword => {
return {
id: Math.random(),
NICE분류: classification,
"지정상품(국문)": keyword,
"지정상품(영문)": "",
유사군코드: "",
고시명칭: false
};
});

return { noticed: [...new Set(noticed)], unnoticed: unnoticed };
})
);
}

let productAdderPointer = this;
Promise.all(requests).then(responses => {
let result = { noticed: [], unnoticed: [] };
for (let i = 0; i < responses.length; i++) {
result.noticed = result.noticed.concat(responses[i].noticed);
result.unnoticed = result.unnoticed.concat(responses[i].unnoticed);
for (const response of responses) {
result.noticed = result.noticed.concat(response.noticed);
result.unnoticed = result.unnoticed.concat(response.unnoticed);
}
productAdderPointer.$productTransmissionBus.$emit(
"transmitClassified",
Expand All @@ -155,24 +186,24 @@ export default {
});
},
addProducts() {
this.$submissionAlarmBus.$emit('submitProductsToBriefcase');
this.$submissionAlarmBus.$emit("submitProductsToBriefcase");
},
addForm() {
this.payloads.push({
id: ++this.formCount,
_class: -1,
searchingProducts: ""
this.searchbars.push({
id: ++this.searchbarId,
classificationEdited: -1,
keywords: ""
});
},
deleteForm(payloadId) {
const deletedIndex = this.payloads.findIndex(
payload => payload["id"] == payloadId
deleteForm(searchbarId) {
const deletedIndex = this.searchbars.findIndex(
searchbar => searchbar["id"] == searchbarId
);
this.payloads.splice(deletedIndex, 1);
this.searchbars.splice(deletedIndex, 1);
}
},
mounted() {
this.$submissionAlarmBus.$on('submissionComplete', () => {
this.$submissionAlarmBus.$on("submissionComplete", () => {
this.curStep = 3;
});
},
Expand Down
Loading