<template>
  <el-dialog
    :title="title"
    append-to-body
    :modelValue="openShow"
    width="30%"
    @close="closeDialog"
    fullscreen
  >
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      v-model="form"
      v-model:search="query"
      v-model:page="page"
      ref="crud"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >

    </avue-crud>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="closeDialog">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script>
import { getYieldOrderList } from '@/api/productionSchedulingPlan/scheduling';
export default {
  props: {
    showDialog: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: '提示',
    },
    showType: {
      type: String,
      default: '',
    },
    rowData: {
      type: Object,
      default: () => {},
    },
    showAll: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      openShow: false,
      form: {},
      selectionList: [],
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        columnSort: true,
        height: 'auto',
        tip: false,
        calcHeight: 32,
        simplePage: false,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        editBtn: false,
        viewBtn: false,
        delBtn: false,
        editBtnText: '修改',
        labelWidth: 120,
        menuWidth: 80,
        dialogWidth: 900,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: false,
        filterBtn: true,
        searchShowBtn: false,
        excelBtn: true,
        showOverflowTooltip: true,
        addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        gridBtn: false,
        searchLabelPosition: 'left',
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: 'left',
        gridBtn: false,
        searchMenuPosition: 'right',
        align: 'center',
        header: false,
        menu: false,
        column: [
          {
            label: '作业中心',
            prop: 'workCenterId',
            search: false,
            sortable: true,
            span: 12,
            width: 160,
            type: 'select',
            filterable: true,
            dicUrl: '/blade-scheduling/workCenter/findList',
            props: {
              label: 'wcName',
              value: 'id',
            },
          },
           {
            label: '订单同步时间',
            prop: 'cycledate',
            search: false,
            sortable: true,
            span: 12,
            hide: true,
            type: 'date',
            searchRange: true,
            searchLabelWidth:100,
            startPlaceholder: '开始时间',
            endPlaceholder: '结束时间',
            format: 'YYYY-MM-DD',
            valueFormat: 'YYYY-MM-DD',
          },
          {
            label: '调度员',
            prop: 'dispatcher',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '生产单号',
            prop: 'yoCode',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
            display: false,
          },
          {
            label: '计划单号',
            prop: 'ypCode',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
            display: false,
          },
          {
            label: '订单优先级',
            prop: 'priorityApsStr',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
            display: false,
          },
          {
            label: '零件号',
            prop: 'partCode',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '零件名称',
            prop: 'partName',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '产品型号',
            prop: 'productType',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '批次号',
            prop: 'batchNo',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '流程卡号',
            prop: 'cardNo',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
            display: false,
          },
          {
            label: '流转编码',
            prop: 'roamNo',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '镀种',
            prop: 'plate',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '生产标识',
            prop: 'productIdent',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '生产数量',
            prop: 'ypQty',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '面积(d㎡)',
            prop: 'ypArea',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '需求交期',
            prop: 'demandDate',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },

          {
            label: '计划下达时间',
            prop: 'releaseDate',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
          {
            label: '订单接收时间',
            prop: 'startTim',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },

          {
            label: '备注',
            prop: 'memo',
            search: false,
            sortable: true,
            width: 150,
            span: 12,
          },
        ],
      },

      data: [],
    };
  },
  mounted() {
    this.openShow = this.showDialog;
    if(this.showAll=='all'){
      this.option.column[0].search = true;
      this.option.column[1].search = true;
      this.option.header=true
      // this.option.column[0].search = true;

    }
    this.query.workCenterId = this.rowData.workCenterId;
    this.onLoad(this.page, this.query);
  },
  methods: {
    closeDialog() {
      this.openShow = false;
      this.$emit('closeDialog');
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },

    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    handleChange(file, fileList) {
      // proxy.$Export.xlsx(file.raw).then((data) => {
      //     data.value = data.results;
      // });
      this.$message({
        type: 'success',
        message: '操作成功!',
      });
    },

    onLoad(page, params = {}) {
      this.loading = true;
      this.data = [];
      if (!!params.cycledate) {
        this.query.startTime = params.cycledate[0];
        this.query.endTime = params.cycledate[1];
      }

      getYieldOrderList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query, { status: this.showType })
      ).then(res => {
        this.data = res.data.data.records;
        this.loading = false;
        this.page.total = res.data.data.total;
      });
    },
  },
};
</script>
<style lang="scss" scoped></style>
