<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      v-model:page="page"
      v-model="form"
      ref="crud"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template #menu="{ row }">
        <el-button type="text" @click="assignFn(row)">转派</el-button>
        <el-button type="text" @click="handleFn(row)">处理</el-button>
      </template>
    </avue-crud>
    <!-- 处理 -->
    <taskHandleDialog
      v-if="isHandleShow"
      :showDialog="isHandleShow"
      @closeDialog="closeDialog"
      :rowItem="rowItem"
    ></taskHandleDialog>
    <!-- 转派 -->
    <assignDaialog
      v-if="isAssignShow"
      :showDialog="isAssignShow"
      @closeDialog="closeDialog"
    ></assignDaialog>
  </basic-container>
</template>
<script>
import { status } from 'nprogress';
import taskHandleDialog from './components/taskHandleDialog.vue';
import assignDaialog from './components/assignDaialog.vue';
import { getList, taskComplete } from '@/api/productionManagement/WIPChange.js';
export default {
  components: {
    taskHandleDialog,
    assignDaialog,
  },
  data() {
    return {
      page: {},
      data: [],
      form: {},
      option: {
        tip: false,
        height: 'auto',
        calcHeight: 32,
        columnSort: true,
        // simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: false,
        viewBtn: false,
        delBtn: false,
        addBtn: false,
        editBtn: false,
        editBtnText: '修改',
        viewBtnText: '详情',
        addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        labelWidth: '200px',
        dialogWidth: 600,
        menuWidth: 120,
        dialogClickModal: false,
        searchEnter: true,
        filterBtn: true,
        searchShowBtn: false,
        excelBtn: true,
        showOverflowTooltip: true,
        align: 'center',
        searchLabelPosition: 'left',
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: 'left',
        gridBtn: false,
        searchMenuPosition: 'right',
        column: [
          {
            label: '物料号',
            prop: 'partCode',
            search: true,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '物料名称',
            prop: 'partName',
            search: true,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '镀种',
            prop: 'plate',
            search: true,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '批次号',
            prop: 'batchNo',
            search: false,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '流程卡号',
            prop: 'cardNo',
            search: false,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '版本',
            prop: 'version',
            search: true,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: 'PDM发布时间',
            prop: 'pdmCreateTime',
            search: false,
            sortable: true,
            filter: true,
            width: 140,
          },
          {
            label: '工艺路线详情',
            prop: 'wayDetails',
            search: false,
            sortable: true,
            filter: true,
            width: 140,
          },
          {
            label: '在制品意见',
            prop: 'wipTake',
            search: false,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '更改单号',
            prop: 'changeNo',
            search: true,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '调度员',
            prop: 'searchCode',
            search: true,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '完成时间',
            prop: 'craftTime',
            search: false,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '任务时间',
            prop: 'taskTime',
            search: false,
            sortable: true,
            filter: true,
            width: 120,
          },
          {
            label: '状态',
            prop: 'status',
            search: true,
            sortable: true,
            filter: true,
            width: 120,
            type: 'select',
            dicData: [
              {
                label: '待处理',
                value: 1,
              },
              {
                label: '已处理',
                value: 2,
              },
            ],
          },
        ],
      },
      isHandleShow: false,
      isAssignShow: false,
      rowItem:{}
    };
  },
  mounted() {},
  methods: {
    assignFn(row) {
      this.isAssignShow = true;
    },
    handleFn(row) {
      this.rowItem = row
      this.isHandleShow = true;
    },
    closeDialog() {
      this.isHandleShow = false;
      this.isAssignShow = false;
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        this.data = res.data.data.records;
        this.loading = false;
        this.page.total = res.data.data.total;
        this.selectionClear();
      });
    },
  },
};
</script>
<style lang="scss" scoped></style>
