|
@@ -2,6 +2,7 @@ import { PageListController } from "@queenjs/controllers";
|
|
|
import { ResourceModule } from ".";
|
|
|
import { ComponentController } from "./controllers/ComponentController";
|
|
|
import { MaterialController } from "./controllers/MaterialController";
|
|
|
+import { queenApi } from "queenjs";
|
|
|
|
|
|
export const helper = ResourceModule.helper({
|
|
|
createFileName(fileName: string, dir: string) {
|
|
@@ -15,42 +16,54 @@ export const helper = ResourceModule.helper({
|
|
|
},
|
|
|
|
|
|
createCompController() {
|
|
|
- const ctrl= new ComponentController();
|
|
|
+ const ctrl = new ComponentController();
|
|
|
ctrl.ListCtrl = new PageListController(this.config?.httpConfig);
|
|
|
- ctrl.ListCtrl.setCrudPrefix("/frame")
|
|
|
+ ctrl.ListCtrl.setCrudPrefix("/frame");
|
|
|
ctrl.createComp = this.actions.createComp;
|
|
|
ctrl.onMenuClick = async (name, record) => {
|
|
|
- if(name == "delete") {
|
|
|
- await this.actions.deletePromotion(record);
|
|
|
- ctrl.ListCtrl.fresh();
|
|
|
+ if (name == "delete") {
|
|
|
+ await this.actions.deletePromotion(record);
|
|
|
+ ctrl.ListCtrl.fresh();
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
return ctrl;
|
|
|
},
|
|
|
|
|
|
createSourceController() {
|
|
|
- const {controls, actions} = this;
|
|
|
-
|
|
|
- const ctrl = new MaterialController();
|
|
|
- ctrl.imageCtrl = controls.materialImageListCtrl;
|
|
|
- ctrl.vidoeCtrl = controls.materialVideoListCtrl;
|
|
|
- ctrl.taskCtrl = controls.renderTaskListCtrl;
|
|
|
- ctrl.tplCtrl = controls.matTempListCtrl;
|
|
|
-
|
|
|
- ctrl.onBtnClick = async function (name: string) {
|
|
|
- if (name == "upload") {
|
|
|
- const uploaded = await actions.uploadMaterial();
|
|
|
- ctrl.switchTab(uploaded.fileType, false);
|
|
|
- ctrl.getCurrControl().loadPage(1);
|
|
|
- return;
|
|
|
- }
|
|
|
- ctrl.showDialog(name);
|
|
|
- };
|
|
|
- ctrl.onItemClick = function (name, record) {
|
|
|
- if (name == "delete") return actions.deleteMaterial(record);
|
|
|
- return actions.downloadMaterial(record);
|
|
|
- };
|
|
|
- return ctrl
|
|
|
- }
|
|
|
+ const { controls, actions } = this;
|
|
|
+
|
|
|
+ const ctrl = new MaterialController();
|
|
|
+ ctrl.imageCtrl = controls.materialImageListCtrl;
|
|
|
+ ctrl.vidoeCtrl = controls.materialVideoListCtrl;
|
|
|
+ ctrl.taskCtrl = controls.renderTaskListCtrl;
|
|
|
+ ctrl.tplCtrl = controls.matTempListCtrl;
|
|
|
+
|
|
|
+ ctrl.onBtnClick = async function (name: string) {
|
|
|
+ if (name == "upload") {
|
|
|
+ const uploaded = await actions.uploadMaterial();
|
|
|
+ ctrl.switchTab(uploaded.fileType, false);
|
|
|
+ ctrl.getCurrControl().loadPage(1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ctrl.showDialog(name);
|
|
|
+ };
|
|
|
+ ctrl.onItemClick = function (name, record) {
|
|
|
+ if (name == "delete") return actions.deleteMaterial(record);
|
|
|
+ return actions.downloadMaterial(record);
|
|
|
+ };
|
|
|
+ return ctrl;
|
|
|
+ },
|
|
|
+
|
|
|
+ async uploadResource(accept = "image/*") {
|
|
|
+ const [blob] = await queenApi.selectFile({ accept });
|
|
|
+ const data = await this.controls.uploader.uploadFile(blob, "queenshow");
|
|
|
+
|
|
|
+ const souceObj = {
|
|
|
+ file: data,
|
|
|
+ fileType: blob.type.split("/")[0],
|
|
|
+ from: "upload",
|
|
|
+ };
|
|
|
+ return souceObj;
|
|
|
+ },
|
|
|
});
|