Lines 4-13
Link Here
|
4 |
<KohaTable |
4 |
<KohaTable |
5 |
ref="table" |
5 |
ref="table" |
6 |
v-bind="tableOptions" |
6 |
v-bind="tableOptions" |
7 |
@show="doShow" |
7 |
@addToBasket="addToBasket" |
8 |
@edit="doEdit" |
8 |
@closeBasket="closeBasket" |
9 |
@delete="doDelete" |
9 |
@uncertainPrices="uncertainPrices" |
10 |
@select="doSelect" |
|
|
11 |
></KohaTable> |
10 |
></KohaTable> |
12 |
</div> |
11 |
</div> |
13 |
<div v-else class="alert alert-info"> |
12 |
<div v-else class="alert alert-info"> |
Lines 23-28
import KohaTable from "../KohaTable.vue"
Link Here
|
23 |
|
22 |
|
24 |
export default { |
23 |
export default { |
25 |
setup() { |
24 |
setup() { |
|
|
25 |
const patronToHTML = $patron_to_html |
26 |
const formatDate = $date |
27 |
|
26 |
const vendorStore = inject("vendorStore") |
28 |
const vendorStore = inject("vendorStore") |
27 |
const { vendors } = storeToRefs(vendorStore) |
29 |
const { vendors } = storeToRefs(vendorStore) |
28 |
|
30 |
|
Lines 36-41
export default {
Link Here
|
36 |
setConfirmationDialog, |
38 |
setConfirmationDialog, |
37 |
setMessage, |
39 |
setMessage, |
38 |
escape_str, |
40 |
escape_str, |
|
|
41 |
patronToHTML, |
42 |
formatDate, |
39 |
} |
43 |
} |
40 |
}, |
44 |
}, |
41 |
data() { |
45 |
data() { |
Lines 44-122
export default {
Link Here
|
44 |
initialized: false, |
48 |
initialized: false, |
45 |
tableOptions: { |
49 |
tableOptions: { |
46 |
columns: this.getTableColumns(), |
50 |
columns: this.getTableColumns(), |
|
|
51 |
options: { embed: "orders,creator,basket_group" }, |
47 |
url: () => this.tableURL(), |
52 |
url: () => this.tableURL(), |
48 |
add_filters: true, |
53 |
add_filters: true, |
49 |
// filters_options: { |
|
|
50 |
// 1: [ |
51 |
// { _id: 0, _str: this.$__("Inactive") }, |
52 |
// { _id: 1, _str: this.$__("Active") }, |
53 |
// ], |
54 |
// ...(this.map_av_dt_filter("vendor_types").length && { |
55 |
// 2: () => this.map_av_dt_filter("vendor_types"), |
56 |
// }), |
57 |
// }, |
58 |
actions: { |
54 |
actions: { |
59 |
"-1": ["edit", "delete"], |
55 |
"-1": [ |
|
|
56 |
{ |
57 |
addToBasket: { |
58 |
text: this.$__("Add to basket"), |
59 |
icon: "fa fa-plus", |
60 |
}, |
61 |
}, |
62 |
{ |
63 |
closeBasket: { |
64 |
text: this.$__("Close basket"), |
65 |
icon: "fa fa-close", |
66 |
should_display: row => |
67 |
row.orders.length > 0 && !row.standing, |
68 |
}, |
69 |
}, |
70 |
{ |
71 |
uncertainPrices: { |
72 |
text: this.$__("Uncertain prices"), |
73 |
icon: "fa fa-question", |
74 |
should_display: row => |
75 |
row.orders.filter(o => o.uncertain_price) |
76 |
.length > 0, |
77 |
}, |
78 |
}, |
79 |
], |
60 |
}, |
80 |
}, |
61 |
}, |
81 |
}, |
62 |
before_route_entered: false, |
|
|
63 |
building_table: false, |
64 |
} |
82 |
} |
65 |
}, |
83 |
}, |
66 |
methods: { |
84 |
methods: { |
67 |
doShow({ id }, dt, event) { |
85 |
addToBasket({ agreement_id }, dt, event) { |
68 |
event.preventDefault() |
86 |
event.preventDefault() |
69 |
this.$router.push({ |
|
|
70 |
name: "VendorShow", |
71 |
params: { vendor_id: id }, |
72 |
}) |
73 |
}, |
74 |
doEdit({ id }, dt, event) { |
75 |
this.$router.push({ |
76 |
name: "VendorFormAddEdit", |
77 |
params: { vendor_id: id }, |
78 |
}) |
79 |
}, |
80 |
doDelete(vendor, dt, event) { |
81 |
this.setConfirmationDialog( |
82 |
{ |
83 |
title: this.$__( |
84 |
"Are you sure you want to remove this vendor?" |
85 |
), |
86 |
message: vendor.name, |
87 |
accept_label: this.$__("Yes, delete"), |
88 |
cancel_label: this.$__("No, do not delete"), |
89 |
}, |
90 |
() => { |
91 |
const client = APIClient.acquisition |
92 |
client.vendors.delete(vendor.id).then( |
93 |
success => { |
94 |
this.setMessage( |
95 |
this.$__("Vendor %s deleted").format( |
96 |
vendor.name |
97 |
), |
98 |
true |
99 |
) |
100 |
dt.draw() |
101 |
}, |
102 |
error => {} |
103 |
) |
104 |
} |
105 |
) |
106 |
}, |
107 |
doSelect(vendor, dt, event) { |
108 |
this.$emit("select-vendor", vendor.id) |
109 |
this.$emit("close") |
110 |
}, |
87 |
}, |
111 |
tableURL() { |
88 |
tableURL() { |
112 |
let url = |
89 |
let url = |
113 |
"/api/v1/acquisitions/baskets?q=" + |
90 |
"/api/v1/acquisitions/baskets?q=" + |
114 |
JSON.stringify({ vendor_id: this.vendorId }) |
91 |
JSON.stringify({ "me.vendor_id": this.vendorId }) |
115 |
return url |
92 |
return url |
116 |
}, |
93 |
}, |
117 |
getTableColumns() { |
94 |
getTableColumns() { |
118 |
const escape_str = this.escape_str |
95 |
const escape_str = this.escape_str |
119 |
const get_lib_from_av = this.get_lib_from_av |
96 |
const patronToHTML = this.patronToHTML |
|
|
97 |
const formatDate = this.formatDate |
120 |
|
98 |
|
121 |
return [ |
99 |
return [ |
122 |
{ |
100 |
{ |
Lines 126-132
export default {
Link Here
|
126 |
orderable: true, |
104 |
orderable: true, |
127 |
render(data, type, row, meta) { |
105 |
render(data, type, row, meta) { |
128 |
return ( |
106 |
return ( |
129 |
'<a href="/cgi-bin/koha/acqui/basket.pl?basket_id=' + |
107 |
'<a href="/cgi-bin/koha/acqui/basket.pl?basketno=' + |
130 |
row.basket_id + |
108 |
row.basket_id + |
131 |
'" class="show">' + |
109 |
'" class="show">' + |
132 |
escape_str(`${row.name} (#${row.basket_id})`) + |
110 |
escape_str(`${row.name} (#${row.basket_id})`) + |
Lines 137-195
export default {
Link Here
|
137 |
{ |
115 |
{ |
138 |
title: __("Item count"), |
116 |
title: __("Item count"), |
139 |
data: "name", |
117 |
data: "name", |
140 |
searchable: true, |
118 |
searchable: false, |
141 |
orderable: true, |
119 |
orderable: true, |
|
|
120 |
|
142 |
render(data, type, row, meta) { |
121 |
render(data, type, row, meta) { |
143 |
return escape_str(row.name) |
122 |
let count = row.orders.length |
|
|
123 |
const cancelledOrders = row.orders.filter( |
124 |
o => o.status == "cancelled" |
125 |
).length |
126 |
if (cancelledOrders) { |
127 |
count += |
128 |
" (" + cancelledOrders + _(" cancelled") + ")" |
129 |
} |
130 |
return count |
144 |
}, |
131 |
}, |
145 |
}, |
132 |
}, |
146 |
{ |
133 |
{ |
147 |
title: __("Bibliographic record count"), |
134 |
title: __("Bibliographic record count"), |
148 |
data: "name", |
135 |
data: "name", |
149 |
searchable: true, |
136 |
searchable: false, |
150 |
orderable: true, |
137 |
orderable: true, |
151 |
render(data, type, row, meta) { |
138 |
render(data, type, row, meta) { |
152 |
return escape_str(row.name) |
139 |
const recordCount = row.orders.reduce( |
|
|
140 |
(acc, order) => { |
141 |
if ( |
142 |
!acc.cancelledBibs.includes( |
143 |
order.biblio_id |
144 |
) && |
145 |
order.status == "cancelled" |
146 |
) { |
147 |
acc.cancelledBibs.push(order.biblio_id) |
148 |
} |
149 |
if (acc.bibNumbers.includes(order.biblio_id)) { |
150 |
return acc |
151 |
} |
152 |
acc.bibNumbers.push(order.biblio_id) |
153 |
return acc |
154 |
}, |
155 |
{ |
156 |
bibNumbers: [], |
157 |
cancelledBibs: [], |
158 |
} |
159 |
) |
160 |
let count = recordCount.bibNumbers.length |
161 |
if (recordCount.cancelledBibs.length) { |
162 |
count += |
163 |
" (" + |
164 |
recordCount.cancelledBibs.length + |
165 |
_(" cancelled") + |
166 |
")" |
167 |
} |
168 |
return count |
153 |
}, |
169 |
}, |
154 |
}, |
170 |
}, |
155 |
{ |
171 |
{ |
156 |
title: __("Items expected"), |
172 |
title: __("Items expected"), |
157 |
data: "name", |
173 |
data: "name", |
158 |
searchable: true, |
174 |
searchable: false, |
159 |
orderable: true, |
175 |
orderable: true, |
160 |
render(data, type, row, meta) { |
176 |
render(data, type, row, meta) { |
161 |
return escape_str(row.name) |
177 |
return row.orders.filter( |
|
|
178 |
o => !o.date_received && !o.cancellation_date |
179 |
).length |
162 |
}, |
180 |
}, |
163 |
}, |
181 |
}, |
164 |
{ |
182 |
{ |
165 |
title: __("Created by"), |
183 |
title: __("Created by"), |
166 |
data: "creator_id", |
184 |
data: "creator_id", |
167 |
searchable: true, |
185 |
searchable: false, |
168 |
orderable: true, |
186 |
orderable: true, |
|
|
187 |
render(data, type, row, meta) { |
188 |
return patronToHTML(row.creator) |
189 |
}, |
169 |
}, |
190 |
}, |
170 |
{ |
191 |
{ |
171 |
title: __("Date"), |
192 |
title: __("Date"), |
172 |
data: "creation_date", |
193 |
data: "creation_date", |
173 |
searchable: true, |
194 |
searchable: false, |
174 |
orderable: true, |
195 |
orderable: true, |
|
|
196 |
render(data, type, row, meta) { |
197 |
return formatDate(row.creation_date) |
198 |
}, |
175 |
}, |
199 |
}, |
176 |
{ |
200 |
{ |
177 |
title: __("Basket group"), |
201 |
title: __("Basket group"), |
178 |
data: "basket_group_id", |
202 |
data: "basket_group_id", |
179 |
searchable: true, |
203 |
searchable: false, |
180 |
orderable: true, |
204 |
orderable: true, |
|
|
205 |
render(data, type, row, meta) { |
206 |
return row.basket_group ? row.basket_group.name : "" |
207 |
}, |
181 |
}, |
208 |
}, |
182 |
{ |
209 |
{ |
183 |
title: __("Internal note"), |
210 |
title: __("Internal note"), |
184 |
data: "note", |
211 |
data: "note", |
185 |
searchable: true, |
212 |
searchable: false, |
186 |
orderable: true, |
213 |
orderable: true, |
187 |
}, |
214 |
}, |
188 |
{ |
215 |
{ |
189 |
title: __("Close"), |
216 |
title: __("Closed"), |
190 |
data: "close_date", |
217 |
data: "close_date", |
191 |
searchable: true, |
218 |
searchable: false, |
192 |
orderable: true, |
219 |
orderable: true, |
|
|
220 |
render(data, type, row, meta) { |
221 |
return formatDate(row.close_date) |
222 |
}, |
193 |
}, |
223 |
}, |
194 |
] |
224 |
] |
195 |
}, |
225 |
}, |