This commit is contained in:
Viet An
2026-07-04 13:46:14 +07:00
parent b06907097c
commit b6766ba7d0
19 changed files with 397 additions and 680 deletions

View File

@@ -88,7 +88,7 @@
</span>
</button>
<span
class="tooltiptext has-background-orange-soft has-text-orange-bold"
class="tooltiptext"
style="top: 110%; bottom: unset; min-width: max-content; left: -45px"
>
Nhập dữ liệu
@@ -110,7 +110,7 @@
</span>
</button>
<span
class="tooltiptext has-background-orange-soft has-text-orange-bold"
class="tooltiptext"
style="top: 110%; bottom: unset; min-width: max-content; left: -45px"
>
Thêm mới
@@ -129,7 +129,7 @@
</span>
</button>
<span
class="tooltiptext has-background-orange-soft has-text-orange-bold"
class="tooltiptext"
style="top: 110%; bottom: unset; min-width: max-content; left: -45px"
>
Xuất Excel
@@ -148,7 +148,7 @@
</span>
</button>
<span
class="tooltiptext has-background-orange-soft has-text-orange-bold"
class="tooltiptext"
style="top: 110%; bottom: unset; min-width: max-content; left: -45px"
>
Làm mới
@@ -170,6 +170,8 @@
</template>
<script>
import { isEmpty } from "es-toolkit/compat";
export default {
setup() {
const store = useStore();
@@ -231,10 +233,10 @@ export default {
this.checkTimeopt();
if (!this.enableTime) return this.$emit("option");
let found = this.$findapi(this.api);
found.commit = undefined;
const apiConfig = this.$findapi(this.api);
apiConfig.commit = undefined;
let filter = this.$copy(this.filter);
const filter = this.$copy(this.filter);
if (filter) {
// dynamic parameter
for (const [key, value] of Object.entries(filter)) {
@@ -244,35 +246,35 @@ export default {
}
}
if (found.params.filter) {
if (apiConfig.params.filter) {
if (!filter) filter = {};
for (const [key, value] of Object.entries(found.params.filter)) {
for (const [key, value] of Object.entries(apiConfig.params.filter)) {
filter[key] = value;
}
}
this.options.map((v) => {
let f = filter ? this.$copy(filter) : {};
const f = filter ? this.$copy(filter) : {};
f["create_time__date__gte"] = this.$dayjs().subtract(v.code, "day").format("YYYY-MM-DD");
v.filter = f;
});
this.$emit("option", this.$find(this.options, { code: this.current }));
let f = {};
this.options.map((v) => {
f[v.code] = {
type: "Count",
field: "create_time__date",
filter: v.filter,
};
});
let params = { summary: "aggregate", distinct_values: f };
found.params = params;
const distinct_values = Object.fromEntries(
this.options.map(({ code, filter }) => [
code,
{
type: "Count",
field: "create_time__date",
filter,
},
]),
);
apiConfig.params = { summary: "aggregate", distinct_values };
try {
let rs = await this.$getapi([found]);
const rs = await this.$getapi([apiConfig]);
for (const [key, value] of Object.entries(rs[0].data.rows)) {
const found = this.$find(this.options, { code: Number(key) });
if (found) {
@@ -429,21 +431,22 @@ export default {
},
checkTimeopt() {
if (this.timeopt > 0) {
let obj = this.$find(this.options, {
if (typeof this.timeopt === "number" && this.timeopt > 0) {
const defaultOption = this.$find(this.options, {
code: this.$parseNum(this.timeopt),
});
if (obj) this.current = obj.code;
if (defaultOption) this.current = defaultOption.code;
}
if (this.timeopt ? this.$empty(this.timeopt.disable) : true) return;
if (this.timeopt.disable.indexOf("add") >= 0) this.enableAdd = false;
if (this.timeopt.disable.indexOf("time") >= 0) this.enableTime = false;
if (!this.timeopt) return;
if (this.timeopt.time) {
let obj = this.$find(this.options, {
let defaultOption = this.$find(this.options, {
code: this.$parseNum(this.timeopt.time),
});
if (obj) this.current = obj.code;
if (defaultOption) this.current = defaultOption.code;
}
if (isEmpty(this.timeopt.disable)) return;
if (this.timeopt.disable.indexOf("add") >= 0) this.enableAdd = false;
if (this.timeopt.disable.indexOf("time") >= 0) this.enableTime = false;
},
},
};