<!--
 * @Author: zwq
 * @Date: 2022-08-22 15:53:16
 * @LastEditors: zwq
 * @LastEditTime: 2023-03-09 11:04:11
 * @Description: 
-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__user">
      <search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
      <base-table
        :table-props="tableProps"
        :page="listQuery.page"
        :limit="listQuery.limit"
        :table-data="tableData"
      >
        <method-btn
          v-if="tableBtn.length"
          slot="handleBtn"
          :width="120"
          label="操作"
          :method-list="tableBtn"
          @clickBtn="handleClick"
        />
      </base-table>
      <pagination
        :limit.sync="listQuery.limit"
        :page.sync="listQuery.page"
        :total="listQuery.total"
        @pagination="getDataList"
      />
      <!-- 弹窗, 新增 / 修改 -->
      <base-dialog
        :dialogTitle="addOrEditTitle"
        :dialogVisible="addOrUpdateVisible"
        @cancel="handleCancel"
        @confirm="handleConfirm"
        :before-close="handleCancel"
      >
        <add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
      </base-dialog>
    </div>
  </el-card>
</template>

<script>
import AddOrUpdate from "./components/mtTaskInfo-add";
import detInfoBtn from './detInfoBtn'
import basicPage from "@/mixins/basic-page";
import codeFilter from "@/filters/code-filter";

const tableProps = [
  {
    prop: "createTime",
    label: "添加时间",
  },
  {
    prop: "num",
    label: "数量",
  },
  {
    prop: "prodectCode",
    label: "产品编码",
  },
  {
    prop: "specModel",
    label: "型号",
  },
  {
    prop: "source",
    label: "来源",
  },
  {
    prop: "status",
    label: "状态",
    filter: codeFilter("detStatus"),
  },
  {
    prop: "taskCode",
    label: "任务编码",
  },
  {
    prop: "taskType",
    label: "任务类型",
    filter: codeFilter("taskType"),
  },
  {
    prop: "unit",
    label: "单位",
  },
  {
    prop: "detInfo",
    label: "子任务",
    subcomponent: detInfoBtn,
  },
  // {
  //   prop: "remarks",
  //   label: "描述",
  // },
];
const tableBtn = [
  {
    type: "edit",
    btnName: "编辑",
  },
  {
    type: "run",
    btnName: "执行",
  },
  {
    type: "delete",
    btnName: "删除",
  },
];

export default {
  mixins: [basicPage],
  data() {
    return {
      urlOptions: {
        getDataListURL: "/code/mtTaskInfo/page",
        deleteURL: "/code/mtTaskInfo",
        statusUrl: "/code/mtTaskInfo/status",
        exportUrl: "/code/mtTaskInfo/export",
      },
      tableProps,
      tableBtn,
      tableData: [],
      formConfig: [
        {
          type: "input",
          label: "产品编码",
          placeholder: "产品编码",
          param: "prodectCode",
        },
        {
          type: "button",
          btnName: "查询",
          name: "search",
          color: "primary",
        },
        {
          type: "button",
          btnName: "新增",
          name: "add",
          color: "primary",
          plain: true,
        },
        {
          type: "button",
          btnName: "导出",
          name: "export",
          color: "primary",
          plain: true,
        },
      ],
    };
  },
  components: {
    AddOrUpdate,
  },
  methods: {
    //search-bar点击
    buttonClick(val) {
      switch (val.btnName) {
        case "search":
          this.listQuery.name = val.name;
          this.listQuery.prodectCode = val.prodectCode;
          this.listQuery.page = 1;
          this.getDataList();
          break;
        case "add":
          this.addOrEditTitle = "新增";
          this.addOrUpdateVisible = true;
          this.addOrUpdateHandle();
          break;
        case "export":
          this.exportHandle("出入库");
          break;
        default:
          console.log(val);
      }
    },
    btnFun(val){
      console.log('run')
      console.log(val)
    }
  },
};
</script>
