<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"
      @search-change="searchChange"
      @search-reset="resetChange"
      @size-change="dataList"
      @current-change="dataList"
      @selection-change="selectionChange"
    />
  </div>
</template>
<script setup>
import { ref } from "vue";
import { useCrud } from "@/hooks/userCrud";
import dictDataUtil from "@/common/configs/dictDataUtil";
import { queryStationByLineId } from "@/api/station";
import { getUserList } from "@/api/system/user";
import { useDictionaryStore } from "@/store";
import { getStatistics } from "@/api/order/index";

// 数据字典相关
const { dicts } = useDictionaryStore();

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

const crudRef = ref(null); //crudRef.value 获取avue-crud对象
const stationList = ref([]);
const userList = ref([]);
const charts = shallowRef(null);
onMounted(() => {
  dataList();
});

// 设置表格列或者其他自定义的option
option.value = Object.assign(option.value, {
  searchEnter: true,
  selection: true,
  menu: false,
  menuWidth: 160,
  searchLabelWidth: 120,
  addBtn: false,
  filterBtn: false,
  searchShowBtn: false,
  columnBtn: false,
  gridBtn: false,
  editBtn: false,
  viewBtn: false,
  delBtn: false,
  column: [
    {
      label: "管号",
      prop: "seqNo",
      editDisabled: true,
      search: true,
    },
    {
      label: "工位名称",
      prop: "stationName",
      search: true,
      display: false,
    },
    {
      label: "工位名称",
      hide: true,
      editDisabled: false,
      type: "select",
      dicData: stationList,
      filterable: true,
      prop: "stationId",
      props: { label: "name", value: "id" },
      rules: [
        {
          required: true,
          message: "请选择工位名称",
          trigger: "blur",
        },
      ],
    },
    {
      label: "订单编码",
      prop: "orderCode",
      search: true,
      width: 125,
      editDisabled: true,
    },
    {
      label: "工单编码",
      prop: "workOrderCode",
      search: true,
      width: 125,
      editDisabled: true,
    },
    {
      label: "产线名称",
      prop: "productLineName",
      search: true,
      editDisabled: true,
    },
    {
      label: "工艺路线",
      prop: "routeName",
      editDisabled: true,
    },
    {
      label: "物料编号",
      prop: "materialCode",
      search: true,
      editDisabled: true,
    },
    {
      label: "物料名称",
      prop: "materialName",
      search: true,
      editDisabled: true,
    },
    {
      label: "物料规格",
      prop: "materialModel",
      editDisabled: true,
      search: true,
    },
    {
      label: "当前工序编码",
      prop: "operationCode",
      search: true,
      editDisabled: true,
    },
    {
      label: "当前工序名称",
      prop: "operationName",
      search: true,
      editDisabled: true,
    },
    {
      label: "排序",
      prop: "operationSort",
      editDisabled: true,
      width: 60,
    },
    {
      label: "状态",
      prop: "state",
      type: "select",
      width: 80,
      editDisabled: true,
      dicUrl:
        dictDataUtil.request_url + dictDataUtil.TYPE_CODE.station_task_state,
      props: {
        label: "dictLabel",
        value: "dictValue",
      },
    },
  ],
});
</script>

<style lang="scss" scoped>
:deep(.avue-crud__left) {
  width: 100%;
}

#charts {
  width: 100%;
  height: 300px;
  border: 1px solid #ccc;
}
</style>
