<template>
  <div class="testdiv">
    <!-- 查询条件 -->
    <div class="divborder newSearchDiv" style="margin: 0px">
      <div class="filter">
        <label>产品名称：</label>
        <Input class="searchInput" v-model="productName" />
      </div>
      <div class="filter">
        <label>图纸号：</label>
        <Input class="searchInput" v-model="drawNo" />
      </div>
      <div class="filter">
        <label>工单号：</label>
        <Input class="searchInput" v-model="jobNo" />
      </div>
      <div class="filter">
        <label>订单号：</label>
        <Input class="searchInput" v-model="orderNo" />
      </div>
      <!-- 次级搜索条件--隐藏 -->
      <div v-if="!morecondition">
        <div class="filter">
          <label>订单状态：</label>
          <Select class="searchSelect" v-model="orderStatus" clearable>
            <Option :value="1">未下发</Option>
            <Option :value="2">未排产</Option>
            <Option :value="3">已派工</Option>
            <Option :value="4">生产中</Option>
            <Option :value="5">已完工</Option>
            <Option :value="6">已终止</Option>
          </Select>
        </div>
        <div class="filter">
          <label>添加时间：</label>
          <DatePicker
            type="daterange"
            :value="addTime"
            class="searchInput middleWidth"
            @on-change="addTimeChange"
          ></DatePicker>
        </div>
        <div class="filter">
          <label>交期范围：</label>
          <DatePicker
            type="daterange"
            :value="deliveryDateRange"
            class="searchInput middleWidth"
            @on-change="deliveryDateRangeChange"
          ></DatePicker>
        </div>
        <div class="filter">
          <label>是否延期：</label>
          <Select class="searchSelect" v-model="isDelay">
            <Option :value="0">全部</Option>
            <Option :value="1">是</Option>
            <Option :value="2">否</Option>
          </Select>
        </div>
      </div>
      <!-- 按钮组 -->
      <div class="searchBtn">
        <Button
          type="primary"
          class="twoWord"
          icon="ios-search"
          @click="search(true)"
          >查询</Button
        >
        <Button
          type="success"
          class="twoWord"
          icon="md-add-circle"
          @click="add()"
          >添加</Button
        >
        <Button
          type="error"
          class="twoWord intervalRight"
          icon="md-close-circle"
          @click="del()"
          >删除</Button
        >
        <Button
          type="warning"
          class="fourWord"
          icon="ios-create-outline"
          @click="orderChange()"
          >订单变更</Button
        >
        <Button
          type="warning"
          class="fourWord"
          icon="ios-create-outline"
          @click="planIssue()"
          >计划下发</Button
        >
        <Button
          type="primary"
          class="fourWord"
          icon="md-download"
          @click="loadExcel()"
          >下载模板</Button
        >
        <Upload
          class="upload"
          name="excel-file"
          :action="action"
          :headers="headers"
          :show-upload-list="false"
          :format="['xlsx']"
          :on-format-error="handleFormatError"
          :on-success="handleSuccess"
          :on-error="handleError"
        >
          <Button type="primary" class="fourWord" icon="md-cloud-upload">
            导入Excel
          </Button>
        </Upload>
      </div>
      <!-- 展开次级搜索条件按钮组件 -->
      <MoreConbtn
        @getCon="morecondition = !morecondition"
        :morecondition="morecondition"
      ></MoreConbtn>
    </div>
    <!-- 数据展示 -->
    <div class="divborder newTableDiv">
      <Table
        class="tableClass"
        @on-current-change="handleRowChange"
        highlight-row
        :data="tableData"
        :columns="tableColumns"
      ></Table>
      <div class="pageDiv">
        <div class="pageDirection">
          <Page
            :current.sync="page"
            :total="total"
            :page-size="pagesize"
            @on-change="changePage"
            show-total
            show-elevator
            show-sizer
            @on-page-size-change="handlePageSize"
            :page-size-opts="[10, 20, 30, 40, 100]"
          ></Page>
        </div>
      </div>
    </div>
    <!-- 弹出框 -->
    <Modal
      class="newModalClass"
      v-model="showModal"
      :styles="{ width: '600px' }"
    >
      <p slot="header">
        <span v-if="type == 1">添加计划</span>
        <span v-if="type == 2">订单变更</span>
      </p>
      <div class="modal_body">
        <div>
          <div class="filter">
            <label>
              <i>*</i>
              产品名称：
            </label>
            <Select
              class="searchSelect"
              v-model="addobj.productid"
              label-in-value
              :disabled="type == 1 ? false : true"
              :on-change="productChange()"
            >
              <Option
                v-for="item in productList"
                :value="item.id"
                :key="item.id"
                >{{ item.name }}</Option
              >
            </Select>
          </div>
          <div class="filter">
            <label>产品编号：</label>
            <Input class="searchInput" v-model="addobj.productno" disabled />
          </div>
          <div class="filter">
            <label>产品图号：</label>
            <Input class="searchInput" v-model="addobj.drawno" disabled />
          </div>
          <div class="filter">
            <label>
              <i>*</i>
              工单类型：
            </label>
            <Select
              class="searchSelect"
              v-model="addobj.work_type"
              :disabled="type == 2 ? true : false"
            >
              <Option :value="1">成品</Option>
              <Option :value="2">新品</Option>
              <Option :value="3">调试</Option>
              <Option :value="4">返工</Option>
            </Select>
          </div>
          <div class="filter">
            <label>
              <i>*</i>
              工单号：
            </label>
            <Input
              class="searchInput"
              v-model="addobj.worknum"
              :disabled="type == 2 ? true : false"
            />
          </div>
          <div class="filter">
            <label>
              <i>*</i>
              订单号：
            </label>
            <Input class="searchInput" v-model="addobj.ordernum" />
          </div>
          <div class="filter">
            <label>
              <i>*</i>
              订单数量：
            </label>
            <Input
              class="searchInput"
              :disabled="type == 2 ? true : false"
              v-model="addobj.order_quantity"
              onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
              @on-change="orderNumChange"
            />
          </div>
          <div class="filter">
            <label>
              <i>*</i>
              工单数量：
            </label>
            <Input
              class="searchInput"
              :disabled="type == 2 ? true : false"
              v-model="addobj.install_quantity"
              onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
              @on-change="workOrderNumChange"
            />
          </div>
          <div class="filter">
            <label>
              <i>*</i>
              交货期：
            </label>
            <DatePicker
              class="searchInput"
              :disabled="type == 2 ? true : false"
              v-model="addobj.deliverydate"
              type="date"
            ></DatePicker>
          </div>
        </div>
        <div class="description">
          说 明：订单数量为订单交付数量，工单数量为需要实际生产的数量。
        </div>
      </div>
      <div slot="footer">
        <Button size="large" @click="showModal = false">取消</Button>
        <Button
          v-if="type == 1"
          size="large"
          type="primary"
          @click="saveData(1)"
          :loading="isLoading"
          >添加</Button
        >
        <Button
          v-if="type == 2"
          size="large"
          type="primary"
          @click="saveData(2)"
          >修改</Button
        >
      </div>
    </Modal>
    <!-- 弹出框 -->
    <Modal
      class="newModalClass"
      v-model="modalShow"
      :styles="{ width: '600px' }"
    >
      <p slot="header">
        <span>下发计划</span>
      </p>
      <div class="modal_body">
        <div>
          <div class="filter">
            <label>
              <i>*</i>
              计划开始：
            </label>
            <DatePicker
              class="searchInput"
              v-model="startDate"
              type="date"
            ></DatePicker>
          </div>
        </div>
        <div>
          <div class="filter">
            <label>
              <i>*</i>
              计划结束：
            </label>
            <DatePicker
              class="searchInput"
              v-model="endDate"
              type="date"
            ></DatePicker>
          </div>
        </div>
      </div>
      <div slot="footer">
        <Button size="large" @click="modalShow = false">取消</Button>
        <Button type="primary" size="large" @click="confirmPlanIssue()"
          >确认下发</Button
        >
      </div>
    </Modal>
  </div>
</template>

<script>
import moment from "moment";

export default {
  inject: ["inittip"],
  data() {
    return {
      // 是否在加载中
      isLoading: false,
      // 是否收起次级搜索条件
      morecondition: false,
      // 产品名称
      productName: "",
      // 图纸号
      drawNo: "",
      // 工单号
      jobNo: "",
      // 订单号
      orderNo: "",
      // 订单状态
      orderStatus: "",
      // 添加时间
      addTime: [],
      // 交期范围
      deliveryDateRange: [],
      // 是否延期
      isDelay: "",
      // 表格数据
      tableData: [],
      // 表格列字段
      tableColumns: [
        {
          type: "sort",
          title: this.$t(1008),
          render: (h, params) => {
            return h(
              "span",
              params.index + (this.page - 1) * this.pagesize + 1
            );
          },
          width: 75,
        },
        {
          title: this.$t(300038),
          key: "ordernumber",
        },
        {
          title: this.$t(900337),
          key: "code",
        },
        {
          title: this.$t(100088),
          key: "product_name",
        },
        {
          title: this.$t(100089),
          key: "product_code",
        },
        {
          title: this.$t(900934),
          align: "center",
          render: (h, params) => {
            let type, bg;
            switch (params.row.workordertype) {
              case 1:
                type = "成品";
                bg = "#2CC377";
                break;
              case 2:
                type = "新品";
                bg = "#2D8CF0";
                break;
              case 3:
                type = "调试";
                bg = "#FF9900";
                break;
              case 4:
                type = "返工";
                bg = "#ED4014";
                break;
            }
            return h(
              "div",
              {
                style: {
                  backgroundColor: bg,
                  color: "#fff",
                  width: "100%",
                  height: "36px",
                  lineHeight: "36px",
                  textAlign: "center",
                },
              },
              type
            );
          },
        },
        {
          title: this.$t(500099),
          key: "quantity",
        },
        {
          title: this.$t(5500136),
          key: "install_count",
        },
        {
          title: this.$t(500030),
          key: "create_time",
        },
        {
          title: this.$t(900932),
          key: "delivery_time",
        },
        {
          title: this.$t(200002),
          align: "center",
          render: (h, params) => {
            let status, bg;
            switch (params.row.status) {
              case 1:
                status = "未下发";
                bg = "#FFB539";
                break;
              case 2:
                status = "未排产";
                bg = "#FF9900";
                break;
              case 3:
                status = "已派工";
                bg = "#FF5E31";
                break;
              case 4:
                status = "生产中";
                bg = "#2D8CF0";
                break;
              case 5:
                status = "已完工";
                bg = "#2CC377";
                break;
              case 6:
                status = "已终止";
                bg = "#ED4014";
                break;
            }
            return h(
              "div",
              {
                style: {
                  backgroundColor: bg,
                  color: "#fff",
                  width: "100%",
                  height: "36px",
                  lineHeight: "36px",
                  textAlign: "center",
                },
              },
              status
            );
          },
        },
        {
          title: this.$t(444424),
          align: "center",
          render: (h, params) => {
            let deliveryTime = params.row.delivery_time;
            let now = moment(new Date().getTime()).format("YYYY-MM-DD");
            if (now > deliveryTime) {
              return h("div", {}, "是");
            } else {
              return h("div", {}, "否");
            }
          },
        },
        {
          title: this.$t(900931),
          key: "source",
          align: "center",
          render: (h, params) => {
            let source;
            switch (params.row.source) {
              case 1:
                source = "手动添加";
                break;
              case 2:
                source = "Excel导入";
                break;
              case 3:
                source = "ERP对接";
                break;
            }
            return h("div", {}, source);
          },
        },
      ],
      // 返回的数据总数
      total: 0,
      // 页码
      page: 1,
      // 页距
      pagesize: 10,
      // 是否展示弹出框
      showModal: false,
      // 当前选中行
      row: {},
      // type 为 1 是添加操作 type 为 2 是修改操作
      type: 0,
      // 弹出框中表单对象
      addobj: {},
      // 可选产品下拉列表
      productList: [],
      // 下发计划弹框是否弹出
      modalShow: false,
      // 下发计划开始日期
      startDate: "",
      // 下发计划结束日期
      endDate: "",
    };
  },
  computed: {
    // 文件导入接口
    action() {
      let publicPath = this.axios.publicPath;
      return publicPath + "cnc/upload/submit?templateName=ProductionPlan";
    },
    // 请求头
    headers() {
      return {
        token: localStorage.getItem("token"),
        timestamp: localStorage.getItem("timestamp"),
        nonce: localStorage.getItem("nonce"),
        sign: localStorage.getItem("sign"),
      };
    },
  },
  mounted() {
    const _this = this;
    _this.search();
    _this.tableColumns = _this.$time.initTableTitle(_this.tableColumns);
  },
  methods: {
    // 鉴定订单数量变化
    orderNumChange(v) {
      const _this = this;
      console.log(_this.addobj.order_quantity < 0);
      if (_this.addobj.order_quantity < 0) {
        _this.addobj.order_quantity = 0;
      }
    },
    // 鉴定工单数量变化
    workOrderNumChange(v) {
      const _this = this;
      console.log(_this.addobj.install_quantity);
      if (_this.addobj.install_quantity < 0) {
        _this.addobj.install_quantity = 0;
      }
    },
    // 监听添加时间变化
    addTimeChange(v) {
      console.log(v);
      this.addTime = v;
    },
    // 监听交期范围变化
    deliveryDateRangeChange(v) {
      console.log(v);
      this.deliveryDateRange = v;
    },
    // 计划下发
    planIssue() {
      const _this = this;
      let { row } = this;
      if (JSON.stringify(row) == "{}") {
        _this.$Message.error(_this.$t(1043));
        return false;
      }
      _this.startDate = "";
      _this.endDate = "";
      // 弹出弹框
      this.modalShow = true;
    },
    // 确认计划下发
    confirmPlanIssue() {
      const _this = this;
      let { $t } = this;

      // 表单必填项验证
      if (!_this.startDate) {
        _this.$Message.error(_this.$t(444425));
        return false;
      }
      if (!_this.endDate) {
        _this.$Message.error(_this.$t(444426));
        return false;
      }

      if (
        moment(_this.startDate).format("YYYY-MM-DD") >
        moment(_this.endDate).format("YYYY-MM-DD")
      ) {
        _this.$Message.error(_this.$t(444448));
        return false;
      }

      if (
        moment(_this.endDate).format("YYYY-MM-DD") > _this.row.delivery_time
      ) {
        _this.$Modal.confirm({
          title: $t(444436),
          width: 480,
          okText: $t(900552),
          onOk: () => {
            // 组装请求参数
            let params = {
              id: _this.row.id,
              planstart: moment(_this.startDate.getTime()).format("YYYY-MM-DD"),
              planend: moment(_this.endDate.getTime()).format("YYYY-MM-DD"),
            };
            _this.axios
              .request({
                url: "cnc/ProductPlanDispatch/PlanDistribution",
                params,
                method: "get",
              })
              .then((res) => {
                let result = res.data;
                if (result.ret == 1) {
                  _this.$Message.success(_this.$t(result.msg));
                  _this.modalShow = false;
                  _this.search();
                } else {
                  _this.$Message.error(_this.$t(result.msg));
                }
              });
          },
        });
      } else {
        // 组装请求参数
        let params = {
          id: _this.row.id,
          planstart: moment(_this.startDate.getTime()).format("YYYY-MM-DD"),
          planend: moment(_this.endDate.getTime()).format("YYYY-MM-DD"),
        };
        _this.axios
          .request({
            url: "cnc/ProductPlanDispatch/PlanDistribution",
            params,
            method: "get",
          })
          .then((res) => {
            let result = res.data;
            if (result.ret == 1) {
              _this.modalShow = false;
              _this.$Message.success(_this.$t(result.msg));
              _this.search();
            } else {
              _this.$Message.error(_this.$t(result.msg));
            }
          });
      }
    },
    // 下载模板
    loadExcel() {
      const _this = this;
      let params = {
        name: "ProductionPlan",
      };
      _this.axios
        .request({
          url: "config/download/GetTemplate",
          params,
          method: "get",
        })
        .then((res) => {
          let result = res.data;
          if (result.ret == 1) {
            location.href = _this.axios.publicPath + result.data;
          } else {
            _this.$Message.error(_this.$t(result.msg));
          }
        });
    },
    // 文件格式验证失败时的钩子
    handleFormatError(file) {
      const { $t } = this;
      this.$Message.error($t(950396) + file.name + $t(950397));
    },
    // 文件上传成功时的钩子
    handleSuccess(res) {
      const _this = this;
      if (res.ret == 1) {
        _this.$Message.success(_this.$t(950398));
        _this.page = 1;
        _this.pagesize = 10;
        _this.search();
      } else {
        if (res.msg.toString().indexOf(",") != -1) {
          _this.inittip(res.msg);
        } else {
          _this.$Message.error(_this.$t(res.msg));
        }
      }
    },
    // 文件上传失败时的钩子
    handleError() {
      this.$Message.error(this.$t(2010006));
    },
    // 监听选中表格行
    handleRowChange(currentRow) {
      console.log(currentRow);
      this.row = currentRow;
    },
    // 跳转页数
    changePage(v) {
      this.row = {};
      this.page = v;
      this.search();
    },
    // 修改页距
    handlePageSize(v) {
      this.row = {};
      // this.page = 1;
      this.pagesize = v;
      this.search();
    },
    // 搜索
    search(isInit) {
      const _this = this;
      if (isInit) {
        _this.page = 1;
        _this.pagesize = 10;
      }
      // 解构赋值
      let {
        page,
        pagesize,
        productName,
        drawNo,
        jobNo,
        orderNo,
        orderStatus,
        addTime,
        deliveryDateRange,
        isDelay,
      } = this;
      let params = {
        page,
        pagesize,
        product_name: productName,
        draw_number: drawNo,
        ordernumber: orderNo,
        code: jobNo,
        status: orderStatus,
        startTime: addTime[0] ? addTime[0] : "",
        endTime: addTime[1] ? addTime[1] : "",
        isdelay: isDelay,
        deliverystart: deliveryDateRange[0] ? deliveryDateRange[0] : "",
        deliveryend: deliveryDateRange[1] ? deliveryDateRange[1] : "",
      };
      _this.axios
        .request({
          url: "cnc/ProductionPlanManagement/GetPlanList",
          params,
          method: "get",
        })
        .then((res) => {
          let result = res.data;
          if (result.ret == 1) {
            _this.tableData = [];
            if (Array.isArray(result.data) && result.data.length) {
              _this.initTableData(result.data);
            }
            _this.total = result.total;
          } else {
            _this.$Message.error(_this.$t(result.msg));
          }
        });
    },
    // 对返回的数据进行处理
    initTableData(tableList) {
      const _this = this;
      let tableData = [];
      if (!Array.isArray(tableList) || !tableList) {
        return false;
      }
      tableList.forEach((item) => {
        tableData.push({
          // ID
          id: item.id,
          // 产品ID
          product_id: item.product_id,
          // 产品名称
          product_name: item.product_name,
          // 产品编号
          product_code: item.product_code,
          // 图纸号
          draw_number: item.draw_number,
          // 工单类型
          workordertype: item.workordertype,
          // 工单号
          code: item.code,
          // 订单号
          ordernumber: item.ordernumber,
          // 工单数量
          install_count: item.install_count,
          // 订单数量
          quantity: item.quantity,
          // 添加时间
          create_time: item.create_time_str,
          // 交付时间
          delivery_time: item.delivery_time_str,
          // 工单状态
          status: item.status,
          // 来源 手动添加 or Excel导入 or ERP对接
          source: item.source,
          // 批次数
          batch: item.batch,
          // 剩余天数
          leaveDays: item.leaveDays,
          // 已排产数量
          has_schedule: item.has_schedule,
          // 未排产数量
          un_schedule: item.un_schedule,
        });
      });
      _this.tableData = tableData;
    },
    // 监听添加按钮
    add() {
      const _this = this;
      // 设置 type 为 1 表示是添加操作
      _this.type = 1;
      // 弹出框显示
      _this.showModal = true;
      // 清空添加对象
      _this.addobj = {};
      // 获取产品下拉列表
      _this.getProductList();
    },
    // 获取产品下拉列表
    getProductList() {
      const _this = this;
      _this.axios
        .request({
          url: "/config/ProjectProduct/GetProducts",
          methods: "get",
        })
        .then((res) => {
          let result = res.data;
          if (result.ret == 1) {
            _this.productList = [];
            if (Array.isArray(result.data) && result.data.length) {
              _this.productList = result.data;
            }
          } else {
            _this.$Message.error(_this.$t(result.msg));
          }
        });
    },
    // 在产品下拉列表中选定一个产品
    productChange() {
      const _this = this;
      let { productList } = this;
      let productId = _this.addobj.productid;
      if (productList.length && Array.isArray(productList)) {
        productList.forEach(function (item) {
          if (item.id == productId) {
            _this.addobj.productno = item.code;
            _this.addobj.drawno = item.drawingcode;
          }
        });
      }
    },
    // 订单变更
    orderChange() {
      const _this = this;
      let { row } = this;
      // 如果当前没有选中某一行，则跳出函数
      if (JSON.stringify(row) == "{}") {
        _this.$Message.error(_this.$t(1043));
        return false;
      }
      let params = {
        id: row.id,
      };
      _this.axios
        .request({
          url: "cnc/ProductChange/GetDate",
          params,
          method: "get",
        })
        .then((res) => {
          let result = res.data;
          if (result.ret == 1) {
            // 获取产品下拉列表
            _this.getProductList();
            // 弹出框显示
            _this.showModal = true;
            // type 为 2 表示修改
            _this.type = 2;

            _this.addobj.productid = row.product_id;
            _this.addobj.drawno = row.draw_number;
            _this.addobj.productno = row.product_code;
            _this.addobj.ordernum = row.ordernumber;
            _this.addobj.worknum = row.code;
            _this.addobj.install_quantity = row.install_count;
            _this.addobj.order_quantity = row.quantity;
            _this.addobj.deliverydate = row.delivery_time;
            _this.addobj.work_type = row.workordertype;
          } else {
            _this.$Message.error(_this.$t(result.msg));
          }
        });
    },
    // 保存弹框数据
    saveData(type) {
      const _this = this;
      let row = _this.addobj;
      let { $t } = this;
      // 必填项表单验证
      if (!row.productid) {
        _this.$Message.error($t(444437));
        return false;
      }
      if (!row.work_type) {
        _this.$Message.error($t(444438));
        return false;
      }
      if (!row.worknum) {
        _this.$Message.error($t(444439));
        return false;
      }
      if (!row.ordernum) {
        _this.$Message.error($t(444440));
        return false;
      }
      if (!row.order_quantity) {
        _this.$Message.error($t(444441));
        return false;
      }
      if (row.order_quantity == 0) {
        _this.$Message.error($t(444445));
        return false;
      }
      if (!row.install_quantity) {
        _this.$Message.error($t(444442));
        return false;
      }
      if (row.install_quantity == 0) {
        _this.$Message.error($t(444446));
        return false;
      }
      if (!row.deliverydate) {
        _this.$Message.error($t(444443));
        return false;
      }

      // type 为 1 添加 type 为 2 修改
      if (type == 1) {
        _this.isLoading = true;
        // 组装请求参数
        let data = {
          produceid: row.productid,
          drawnumber: row.drawno,
          code: row.worknum,
          quantity: row.order_quantity,
          install_count: row.install_quantity,
          deliverytime: moment(row.deliverydate).format("YYYY-MM-DD"),
          product_code: row.productno,
          ordernumber: row.ordernum,
          workordertype: row.work_type,
        };
        _this.axios
          .request({
            url: "cnc/ProductionPlanManagement/AddProduceplan",
            data,
            method: "post",
          })
          .then((res) => {
            let result = res.data;
            if (result.ret == 1) {
              _this.isLoading = false;
              _this.showModal = false;
              _this.$Message.success(_this.$t(result.msg));
              _this.page = 1;
              _this.pagesize = 10;
              _this.search();
            } else {
              _this.isLoading = false;
              _this.$Message.error(_this.$t(result.msg));
            }
          });
      } else if (type == 2) {
        let data = {
          id: _this.row.id,
          product_name: _this.row.product_name,
          product_code: row.productno,
          draw_number: row.drawno,
          workordertype: row.work_type,
          code: row.worknum,
          ordernumber: row.ordernum,
          quantity: row.order_quantity,
          install_count: row.install_quantity,
          delivery_time: moment(row.deliverydate).format("YYYY-MM-DD"),
        };
        _this.axios
          .request({
            url: "cnc/ProductChange/EditOrdeChange",
            data,
            method: "post",
          })
          .then((res) => {
            let result = res.data;
            if (result.ret == 1) {
              _this.showModal = false;
              _this.$Message.success(_this.$t(result.msg));
              _this.search();
            } else {
              _this.$Message.error(_this.$t(result.msg));
            }
          });
      }
    },
    // 监听删除事件
    del() {
      const _this = this;
      if (JSON.stringify(this.row) == "{}") {
        _this.$Message.error(_this.$t(1043));
        return false;
      } else {
        _this.$Modal.confirm({
          title: this.$t(1018),
          content: "",
          width: "290px",
          closable: true,
          okText: this.$t(1004),
          onOk: () => {
            let params = { id: _this.row.id };
            _this.axios
              .request({
                url: "cnc/ProductionPlanManagement/DeleteProduceplan",
                params,
                method: "get",
              })
              .then((res) => {
                let result = res.data;
                if (result.ret == 1) {
                  _this.$Message.success(this.$t(1058));
                  _this.page = 1;
                  _this.pagesize = 10;
                  _this.search();
                } else {
                  _this.$Message.error(this.$t(result.msg));
                }
              });
          },
        });
      }
    },
  },
};
</script>
<style scoped>
.upload {
  display: inline-block;
}

.description {
  color: #02baf6;
  margin-top: 12px;
  padding-left: 50px;
  font-size: 10px;
}
</style>
