|
@@ -1,18 +1,18 @@
|
|
|
import List from "@/components/AssetsList";
|
|
|
+import { useResource } from "@/modules/resource";
|
|
|
import { PromotionController } from "@/modules/resource/controllers/PromotionController";
|
|
|
+import { useAuth } from "@queenjs-modules/auth";
|
|
|
import { defineUI } from "queenjs";
|
|
|
-import { onMounted } from "vue";
|
|
|
+import { computed, onMounted, reactive } from "vue";
|
|
|
import { any } from "vue-types";
|
|
|
-import Header from "./Header";
|
|
|
import Filter from "./CategoryFilter";
|
|
|
+import Header from "./Header";
|
|
|
import PromotionItem from "./PromotionItem";
|
|
|
-import { useAuth } from "@queenjs-modules/auth";
|
|
|
|
|
|
export default defineUI({
|
|
|
props: {
|
|
|
Controller: any<PromotionController>().isRequired,
|
|
|
},
|
|
|
-
|
|
|
slots: {
|
|
|
Header,
|
|
|
Filter,
|
|
@@ -20,6 +20,23 @@ export default defineUI({
|
|
|
},
|
|
|
setup(props, { slots }) {
|
|
|
const auth = useAuth();
|
|
|
+ const resource = useResource();
|
|
|
+
|
|
|
+ const state = reactive({
|
|
|
+ categoryList: computed(() => {
|
|
|
+ const categories = resource.controls.categoryCtrl.state.categories;
|
|
|
+ const currCate: any = categories.find((e: any) => {
|
|
|
+ return e.value == "template";
|
|
|
+ });
|
|
|
+ if (!currCate) return [];
|
|
|
+ const r = currCate.children.find((e: any) => e.name == "平台");
|
|
|
+ return r?.children || [];
|
|
|
+ }),
|
|
|
+ pcCategoryId: computed(() => {
|
|
|
+ const item: any = state.categoryList.find((e: any) => e.value == "PC");
|
|
|
+ return item.id;
|
|
|
+ }),
|
|
|
+ });
|
|
|
|
|
|
const FilterChange = (query: any) => {
|
|
|
const ctrlQuery = props.Controller.ListCtrl.state.query || {};
|
|
@@ -29,6 +46,14 @@ export default defineUI({
|
|
|
};
|
|
|
props.Controller.ListCtrl.loadPage(1);
|
|
|
};
|
|
|
+
|
|
|
+ function isPcDesign(record: any) {
|
|
|
+ let res = false;
|
|
|
+ const categories: any[] = record.categories || [];
|
|
|
+ if (categories.includes(state.pcCategoryId)) res = true;
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
props.Controller.ListCtrl.state.query = {};
|
|
|
props.Controller.ListCtrl.loadPage(1);
|
|
@@ -37,6 +62,7 @@ export default defineUI({
|
|
|
return () => {
|
|
|
//@ts-ignore
|
|
|
const isSys = (auth.store.userInfo.roles || []).indexOf("system") > -1;
|
|
|
+
|
|
|
return (
|
|
|
<div>
|
|
|
<slots.Header onAdd={props.Controller.createPromotion} />
|
|
@@ -50,15 +76,19 @@ export default defineUI({
|
|
|
class="my-30px"
|
|
|
columns={5}
|
|
|
control={props.Controller.ListCtrl}
|
|
|
- item={(record: any) => (
|
|
|
- <PromotionItem
|
|
|
- record={record}
|
|
|
- onMenu={(name) => {
|
|
|
- props.Controller.onMenuClick(name, record, isSys);
|
|
|
- }}
|
|
|
- onEdit={(record) => props.Controller.onEdit(record)}
|
|
|
- />
|
|
|
- )}
|
|
|
+ item={(record: any) => {
|
|
|
+ const isPc = isPcDesign(record);
|
|
|
+ return (
|
|
|
+ <PromotionItem
|
|
|
+ isPc={isPc}
|
|
|
+ record={record}
|
|
|
+ onMenu={(name) => {
|
|
|
+ props.Controller.onMenuClick(name, record, isSys);
|
|
|
+ }}
|
|
|
+ onEdit={(record) => props.Controller.onEdit(record)}
|
|
|
+ />
|
|
|
+ );
|
|
|
+ }}
|
|
|
/>
|
|
|
</div>
|
|
|
);
|