<template>
    <div class="mainContentBox">
        <avue-crud
                ref="crudRef"
                v-model:search="search"
                v-model="form"
                :data="data"
                :option="option"
                v-model:page="page"
                @row-save="createRow"
                @row-update="updateRow"
                @row-del="deleteRow"
                @selection-change="selectionChange"
        >
            <template #menu-left="{ size }">
                <el-button
                        :disabled="toDeleteIds.length < 1"
                        type="danger"
                        icon="el-icon-delete"
                        :size="size"
                        @click="multipleDelete">删除</el-button>
            </template>
        </avue-crud>
    </div>
</template>
<script setup>
    import { ref, getCurrentInstance } from "vue";
    import { useCrud } from "@/hooks/userCrud";
    import ButtonPermKeys from "@/common/configs/buttonPermission";

    import { useCommonStoreHook } from "@/store";
    const { isShowTable, tableType } = toRefs(useCommonStoreHook());
    const test = () => {
        isShowTable.value = true;
        tableType.value = tableType.value == 1 ? 2 : 1;
    };

    // 传入一个url，后面不带/
    const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
            useCrud({
                src: "/api/v1/plan/order",
            });
    const { dataList, createRow, updateRow, deleteRow } = Methords; //增删改查
    const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
    const { checkBtnPerm } = Utils; //按钮权限等工具

    const crudRef = ref(null); //crudRef.value 获取avue-crud对象

    // 设置表格列或者其他自定义的option
    option.value = Object.assign(option.value, {
        selection: true,
        column: [
                {
                    label: "主键",
                    prop: "id",
                    search: false,
                },
                {
                    label: "创建日期",
                    prop: "created",
                    search: false,
                },
                {
                    label: "创建人",
                    prop: "creator",
                    search: false,
                },
                {
                    label: "更新日期",
                    prop: "updated",
                    search: false,
                },
                {
                    label: "更新人",
                    prop: "updator",
                    search: false,
                },
                {
                    label: "组织id",
                    prop: "orgId",
                    search: false,
                },
                {
                    label: "部门id",
                    prop: "deptId",
                    search: false,
                },
                {
                    label: "版本号",
                    prop: "version",
                    search: false,
                    precision: 1,
                },
                {
                    label: "基础工序名称",
                    prop: "operationName",
                    search: true,
                },
                {
                    label: "工序编码",
                    prop: "operationCode",
                    search: false,
                },
                {
                    label: "基础工序号",
                    prop: "operationOp",
                    search: true,
                },
                {
                    label: "基础工序描述",
                    prop: "operationDesc",
                    search: false,
                },
                {
                    label: "标准工时",
                    prop: "standardWorktime",
                    search: false,
                },
                {
                    label: "工位类型",
                    prop: "stanType",
                    search: false,
                },
                {
                    label: "技能要求",
                    prop: "skillAsk",
                    search: false,
                },
                {
                    label: "工段",
                    prop: "workSection",
                    search: false,
                },
                {
                    label: "工序类型",
                    prop: "operationType",
                    search: true,
                },
                {
                    label: "机时",
                    prop: "timeingNum",
                    search: false,
                },
                {
                    label: "是否外协",
                    prop: "externalCooperation",
                    search: false,
                },
                {
                    label: "加工要求",
                    prop: "processAsk",
                    search: false,
                },
                {
                    label: "准备工时(人工工时)",
                    prop: "preparationTime",
                    search: false,
                },
                {
                    label: "是否自检",
                    prop: "selfCheck",
                    search: false,
                },
                {
                    label: "是否巡检",
                    prop: "inspection",
                    search: false,
                },
                {
                    label: "是否首检",
                    prop: "firstCheck",
                    search: false,
                },
                {
                    label: "是否委外",
                    prop: "outsourcing",
                    search: false,
                },
                {
                    label: "是否禁用",
                    prop: "enabled",
                    search: false,
                },
                {
                    label: "是否可跳过",
                    prop: "skipped",
                    search: false,
                },
                {
                    label: "坐标X",
                    prop: "x",
                    search: false,
                },
                {
                    label: "坐标Y",
                    prop: "y",
                    search: false,
                },
                {
                    label: "删除标识",
                    prop: "deleted",
                    search: false,
                },
                {
                    label: "是否分批",
                    prop: "batch",
                    search: false,
                },
                {
                    label: "是否合批",
                    prop: "merge",
                    search: false,
                },
                {
                    label: "是否工艺数量",
                    prop: "common",
                    search: false,
                },
                {
                    label: "分批数量",
                    prop: "batchNum",
                    search: false,
                },
                {
                    label: "合批数量",
                    prop: "mergeNum",
                    search: false,
                },
                {
                    label: "后置时间",
                    prop: "forceTime",
                    search: false,
                },
                {
                    label: "外协时间",
                    prop: "outTime",
                    search: false,
                },
        ],
    });

    onMounted(() => {
        dataList();
    });
</script>
