139 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			139 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
 | 
						|
// import switchBtn from "@/components/noTemplateComponents/switchBtn";
 | 
						|
import request from "@/utils/request";
 | 
						|
import { timeFilter } from "@/utils/filters";
 | 
						|
 | 
						|
// 报表分类小组件
 | 
						|
const CategoryList = {
 | 
						|
  name: "CategoryList",
 | 
						|
  props: {
 | 
						|
    injectData: {
 | 
						|
      type: Object,
 | 
						|
      required: true,
 | 
						|
      default: () => ({}),
 | 
						|
    },
 | 
						|
  },
 | 
						|
  data() {
 | 
						|
    return { pickedId: null };
 | 
						|
  },
 | 
						|
  mounted() {
 | 
						|
    // console.log(this.injectData)
 | 
						|
    this.pickedId = this.injectData[this.injectData.head.prop];
 | 
						|
  },
 | 
						|
  methods: {
 | 
						|
    handleChange(id) {
 | 
						|
      this.pickedId = id;
 | 
						|
      this.$emit("emit-data", {
 | 
						|
        type: "change-category",
 | 
						|
        data: { id: this.injectData.id, fileName: this.injectData.fileName, name: this.injectData.name, url: this.injectData.url, category: id },
 | 
						|
      });
 | 
						|
    },
 | 
						|
  },
 | 
						|
  render: function (h) {
 | 
						|
    const childOptions = [];
 | 
						|
    this.injectData.head.options?.forEach((item) => {
 | 
						|
      // console.log('【报表分类】', item.value)
 | 
						|
      childOptions.push(h("el-option", { props: { label: item.label, value: item.value } }, null));
 | 
						|
    });
 | 
						|
    return h("el-select", { props: { size: 'mini', value: this.pickedId }, on: { change: this.handleChange } }, childOptions);
 | 
						|
  },
 | 
						|
};
 | 
						|
 | 
						|
export async function fetchCategoryList() {
 | 
						|
  const categoryList = (await this.$http.get("/pms/reportSheetCategory/list"))?.data?.data;
 | 
						|
  if (Array.isArray(categoryList)) {
 | 
						|
    return categoryList;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
export default function () {
 | 
						|
  const tableProps = [
 | 
						|
    { type: "index", label: "序号" },
 | 
						|
    { prop: "createTime", label: "添加时间", width: 180, filter: timeFilter },
 | 
						|
    { prop: "fileName", label: "报表名称" },
 | 
						|
    { prop: "category", label: "报表分类", subcomponent: CategoryList, options: [] },
 | 
						|
    {
 | 
						|
      prop: "operations",
 | 
						|
      name: "操作",
 | 
						|
      fixed: "right",
 | 
						|
      width: 160,
 | 
						|
      subcomponent: TableOperaionComponent,
 | 
						|
      options: [
 | 
						|
        { name: "preview", label: '预览', icon: 'view', emitFull: true, permission: "pms:reportSheet:preview" },
 | 
						|
        { name: "design", label: '设计', icon: 'edit', emitFull: true, permission: "pms:reportSheet:design" },
 | 
						|
        { name: "edit", label: "编辑", icon: "edit-outline", label: '编辑' },
 | 
						|
        { name: "delete", icon: "delete", label: "删除", emitFull: true, permission: "pms:reportSheet:delete" },
 | 
						|
      ],
 | 
						|
    },
 | 
						|
  ];
 | 
						|
 | 
						|
  const headFormFields = [
 | 
						|
    {
 | 
						|
      prop: "name",
 | 
						|
      label: "报表名称",
 | 
						|
      input: true,
 | 
						|
      default: { value: "" },
 | 
						|
      bind: {
 | 
						|
        placeholder: "请输入报表名称",
 | 
						|
      },
 | 
						|
    },
 | 
						|
    {
 | 
						|
      button: {
 | 
						|
        type: "primary",
 | 
						|
        name: "查询",
 | 
						|
      },
 | 
						|
    },
 | 
						|
    // {
 | 
						|
    //   button: {
 | 
						|
    //     type: "primary",
 | 
						|
    //     name: "新增",
 | 
						|
    //     permission: "pms:productionLine:save"
 | 
						|
    //   },
 | 
						|
    //   bind: {
 | 
						|
    //     plain: true,
 | 
						|
    //   }
 | 
						|
    // },
 | 
						|
  ];
 | 
						|
 | 
						|
  const dialogJustFormConfigs = {
 | 
						|
    form: {
 | 
						|
      rows: [
 | 
						|
        [
 | 
						|
          {
 | 
						|
            input: true,
 | 
						|
            label: "报表名称",
 | 
						|
            prop: "fileName",
 | 
						|
            rules: { required: true, message: "必填项不能为空", trigger: "blur" },
 | 
						|
            elparams: { placeholder: "请输入报表名称" },
 | 
						|
          },
 | 
						|
        ],
 | 
						|
      ],
 | 
						|
      operations: [
 | 
						|
        { name: "add", label: "保存", type: "primary", permission: "pms:reportSheet:save", showOnEdit: false },
 | 
						|
        { name: "update", label: "修改", type: "primary", permission: "pms:reportSheet:update", showOnEdit: true },
 | 
						|
        // { name: "reset", label: "重置", type: "warning", showAlways: true },
 | 
						|
        // { name: 'cancel', label: '取消', showAlways: true },
 | 
						|
      ],
 | 
						|
    },
 | 
						|
  };
 | 
						|
 | 
						|
  return {
 | 
						|
    dialogConfigs: dialogJustFormConfigs,
 | 
						|
    tableConfig: {
 | 
						|
      table: null,
 | 
						|
      column: tableProps,
 | 
						|
    },
 | 
						|
    headFormConfigs: {
 | 
						|
      rules: null,
 | 
						|
      fields: headFormFields,
 | 
						|
    },
 | 
						|
    urls: {
 | 
						|
      base: "/pms/reportSheet",
 | 
						|
      page: "/pms/reportSheet/page",
 | 
						|
      // subase: '/pms/blenderStepParam',
 | 
						|
      // subpage: '/pms/blenderStepParam/page',
 | 
						|
      // more...
 | 
						|
    },
 | 
						|
  };
 | 
						|
}
 |