<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="型号全称" prop="typeName">
        <el-input
          v-model="queryParams.typeName"
          placeholder="请输入型号全称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="产品名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编码" prop="materialCode">
        <el-input
          v-model="queryParams.materialCode"
          placeholder="请输入物料编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:pcRigidChain:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:pcRigidChain:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:pcRigidChain:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:pcRigidChain:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="pcRigidChainList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="id" v-if="true"/>
      <el-table-column label="类型" align="center" prop="type" />
      <el-table-column label="型号全称" align="center" prop="typeName" />
      <el-table-column label="产品id" align="center" prop="productId" />
      <el-table-column label="产品名称" align="center" prop="productName" />
      <el-table-column label="轴向" align="center" prop="axialDirection" />
      <el-table-column label="箱体" align="center" prop="box" />
      <el-table-column label="行程" align="center" prop="journey" />
      <el-table-column label="标记号" align="center" prop="lableNumber" />
      <el-table-column label="L1" align="center" prop="lOne" />
      <el-table-column label="L2" align="center" prop="lTwo" />
      <el-table-column label="L3" align="center" prop="lThree" />
      <el-table-column label="总重量" align="center" prop="sumWeight" />
      <el-table-column label="链条自重" align="center" prop="chainWeight" />
      <el-table-column label="动载荷" align="center" prop="dynamicLoad" />
      <el-table-column label="静载荷" align="center" prop="deadLoad" />
      <el-table-column label="每转上升高度" align="center" prop="riseInHeightPerRevolution" />
      <el-table-column label="速度" align="center" prop="speed" />
      <el-table-column label="系统效率" align="center" prop="efficiency" />
      <el-table-column label="链条节距" align="center" prop="chainPitch" />
      <el-table-column label="节圆半径" align="center" prop="pitchRadius" />
      <el-table-column label="最低高度" align="center" prop="minimumAltitude" />
      <el-table-column label="一米链条自重" align="center" prop="singleMeterChainWeight" />
      <el-table-column label="驱动箱重量" align="center" prop="drivingBoxWeight" />
      <el-table-column label="链箱重量" align="center" prop="chainBoxWeight" />
      <el-table-column label="单价" align="center" prop="univalence" />
      <el-table-column label="图片" align="center" prop="picture" />
      <el-table-column label="部件id集合" align="center" prop="partId" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="备用字段1" align="center" prop="sparedOne" />
      <el-table-column label="备用字段2" align="center" prop="sparedTwo" />
      <el-table-column label="备用字段3" align="center" prop="sparedThree" />
      <el-table-column label="备用字段4" align="center" prop="sparedFour" />
      <el-table-column label="行程" align="center" prop="vOne" />
      <el-table-column label="设备总长" align="center" prop="vTwo" />
      <el-table-column label="地脚位置1" align="center" prop="vThree" />
      <el-table-column label="地脚位置2" align="center" prop="vFour" />
      <el-table-column label="箱体装配长度" align="center" prop="vFive" />
      <el-table-column label="箱体地脚位置1" align="center" prop="vSix" />
      <el-table-column label="箱体地脚位置2" align="center" prop="vSeven" />
      <el-table-column label="铝箱长度1" align="center" prop="vEight" />
      <el-table-column label="铝箱长度2" align="center" prop="vNine" />
      <el-table-column label="导向条长度1" align="center" prop="vTen" />
      <el-table-column label="导向条长度1数量" align="center" prop="vEleven" />
      <el-table-column label="导向条长度2" align="center" prop="vTwelve" />
      <el-table-column label="导向条长度2数量" align="center" prop="vThirteen" />
      <el-table-column label="导向条长度3" align="center" prop="vFourteen" />
      <el-table-column label="导向条长度3数量" align="center" prop="vFifteen" />
      <el-table-column label="孔位总长1" align="center" prop="vSixteen" />
      <el-table-column label="间隔数量1" align="center" prop="vSeveteen" />
      <el-table-column label="孔位总长2" align="center" prop="vEighteen" />
      <el-table-column label="间隔数量2" align="center" prop="vNineteen" />
      <el-table-column label="铆钉数量" align="center" prop="vTwenty" />
      <el-table-column label="v21" align="center" prop="vTwentyOne" />
      <el-table-column label="v22" align="center" prop="vTwentyTwo" />
      <el-table-column label="v23" align="center" prop="vTwentyThree" />
      <el-table-column label="v24" align="center" prop="vTwentyFour" />
      <el-table-column label="v25" align="center" prop="vTwentyFive" />
      <el-table-column label="26" align="center" prop="vTwentySix" />
      <el-table-column label="v27" align="center" prop="vTwentySeven" />
      <el-table-column label="v28" align="center" prop="vTwentyEight" />
      <el-table-column label="v29" align="center" prop="vTwentyNine" />
      <el-table-column label="v30" align="center" prop="vThirty" />
      <el-table-column label="v31" align="center" prop="vThirtyOne" />
      <el-table-column label="v32" align="center" prop="vThirtyTwo" />
      <el-table-column label="v33" align="center" prop="vThirtyThree" />
      <el-table-column label="v34" align="center" prop="vThirtyFour" />
      <el-table-column label="v35" align="center" prop="vThirtyFive" />
      <el-table-column label="v36" align="center" prop="vThirtySix" />
      <el-table-column label="v37" align="center" prop="vThirtySeven" />
      <el-table-column label="v38" align="center" prop="vThirtyEight" />
      <el-table-column label="v39" align="center" prop="vThirtyNine" />
      <el-table-column label="v40" align="center" prop="vForty" />
      <el-table-column label="X1" align="center" prop="vFortyOne" />
      <el-table-column label="X2" align="center" prop="vFortyTwo" />
      <el-table-column label="X3" align="center" prop="vFortyThree" />
      <el-table-column label="X4" align="center" prop="vFortyFour" />
      <el-table-column label="X5" align="center" prop="vFortyFive" />
      <el-table-column label="X6" align="center" prop="vFortySix" />
      <el-table-column label="X7" align="center" prop="vFortySeven" />
      <el-table-column label="X8" align="center" prop="vFortyEight" />
      <el-table-column label="X9" align="center" prop="vFortyNine" />
      <el-table-column label="X10" align="center" prop="vFifty" />
      <el-table-column label="X11" align="center" prop="vFiftyOne" />
      <el-table-column label="X12" align="center" prop="vFiftyTwo" />
      <el-table-column label="X13" align="center" prop="vFiftyThree" />
      <el-table-column label="重量" align="center" prop="gOne" />
      <el-table-column label="重量" align="center" prop="gTwo" />
      <el-table-column label="重量" align="center" prop="gThree" />
      <el-table-column label="重量" align="center" prop="gFour" />
      <el-table-column label="重量" align="center" prop="gFive" />
      <el-table-column label="重量" align="center" prop="gSix" />
      <el-table-column label="重量" align="center" prop="gSeven" />
      <el-table-column label="重量" align="center" prop="gEight" />
      <el-table-column label="重量" align="center" prop="gNine" />
      <el-table-column label="重量" align="center" prop="gTen" />
      <el-table-column label="重量" align="center" prop="gEleven" />
      <el-table-column label="重量" align="center" prop="gTwelve" />
      <el-table-column label="重量" align="center" prop="gThirteen" />
      <el-table-column label="重量" align="center" prop="gFourteen" />
      <el-table-column label="重量" align="center" prop="gFifteen" />
      <el-table-column label="重量" align="center" prop="gSixteen" />
      <el-table-column label="重量" align="center" prop="gSeveteen" />
      <el-table-column label="重量" align="center" prop="gEighteen" />
      <el-table-column label="重量" align="center" prop="gNineteen" />
      <el-table-column label="重量" align="center" prop="gTwenty" />
      <el-table-column label="物料编码" align="center" prop="materialCode" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:pcRigidChain:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:pcRigidChain:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改销齿链型号管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="型号全称" prop="typeName">
          <el-input v-model="form.typeName" placeholder="请输入型号全称" />
        </el-form-item>
        <el-form-item label="产品id" prop="productId">
          <el-input v-model="form.productId" placeholder="请输入产品id" />
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入产品名称" />
        </el-form-item>

        <el-form-item label="物料编码" prop="materialCode">
          <el-input v-model="form.materialCode" placeholder="请输入物料编码" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRigidChain, getRigidChain, delRigidChain, addRigidChain, updateRigidChain } from "@/api/system/pcRigidChain";

export default {
  name: "RigidChain",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 销齿链型号管理表格数据
      pcRigidChainList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type: undefined,
        typeName: undefined,
        productId: undefined,
        productName: undefined,
        axialDirection: undefined,
        box: undefined,
        journey: undefined,
        lableNumber: undefined,
        lOne: undefined,
        lTwo: undefined,
        lThree: undefined,
        sumWeight: undefined,
        chainWeight: undefined,
        dynamicLoad: undefined,
        deadLoad: undefined,
        riseInHeightPerRevolution: undefined,
        speed: undefined,
        efficiency: undefined,
        chainPitch: undefined,
        pitchRadius: undefined,
        minimumAltitude: undefined,
        singleMeterChainWeight: undefined,
        drivingBoxWeight: undefined,
        chainBoxWeight: undefined,
        univalence: undefined,
        picture: undefined,
        partId: undefined,
        sparedOne: undefined,
        sparedTwo: undefined,
        sparedThree: undefined,
        sparedFour: undefined,
        vOne: undefined,
        vTwo: undefined,
        vThree: undefined,
        vFour: undefined,
        vFive: undefined,
        vSix: undefined,
        vSeven: undefined,
        vEight: undefined,
        vNine: undefined,
        vTen: undefined,
        vEleven: undefined,
        vTwelve: undefined,
        vThirteen: undefined,
        vFourteen: undefined,
        vFifteen: undefined,
        vSixteen: undefined,
        vSeveteen: undefined,
        vEighteen: undefined,
        vNineteen: undefined,
        vTwenty: undefined,
        vTwentyOne: undefined,
        vTwentyTwo: undefined,
        vTwentyThree: undefined,
        vTwentyFour: undefined,
        vTwentyFive: undefined,
        vTwentySix: undefined,
        vTwentySeven: undefined,
        vTwentyEight: undefined,
        vTwentyNine: undefined,
        vThirty: undefined,
        vThirtyOne: undefined,
        vThirtyTwo: undefined,
        vThirtyThree: undefined,
        vThirtyFour: undefined,
        vThirtyFive: undefined,
        vThirtySix: undefined,
        vThirtySeven: undefined,
        vThirtyEight: undefined,
        vThirtyNine: undefined,
        vForty: undefined,
        vFortyOne: undefined,
        vFortyTwo: undefined,
        vFortyThree: undefined,
        vFortyFour: undefined,
        vFortyFive: undefined,
        vFortySix: undefined,
        vFortySeven: undefined,
        vFortyEight: undefined,
        vFortyNine: undefined,
        vFifty: undefined,
        vFiftyOne: undefined,
        vFiftyTwo: undefined,
        vFiftyThree: undefined,
        gOne: undefined,
        gTwo: undefined,
        gThree: undefined,
        gFour: undefined,
        gFive: undefined,
        gSix: undefined,
        gSeven: undefined,
        gEight: undefined,
        gNine: undefined,
        gTen: undefined,
        gEleven: undefined,
        gTwelve: undefined,
        gThirteen: undefined,
        gFourteen: undefined,
        gFifteen: undefined,
        gSixteen: undefined,
        gSeveteen: undefined,
        gEighteen: undefined,
        gNineteen: undefined,
        gTwenty: undefined,
        materialCode: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: "主键不能为空", trigger: "blur" }
        ],
        type: [
          { required: true, message: "类型不能为空", trigger: "change" }
        ],
        typeName: [
          { required: true, message: "型号全称不能为空", trigger: "blur" }
        ],
        productId: [
          { required: true, message: "产品id不能为空", trigger: "blur" }
        ],
        productName: [
          { required: true, message: "产品名称不能为空", trigger: "blur" }
        ],
       
        materialCode: [
          { required: true, message: "物料编码不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询销齿链型号管理列表 */
    getList() {
      this.loading = true;
      listRigidChain(this.queryParams).then(response => {
        this.pcRigidChainList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        createTime: undefined,
        type: undefined,
        typeName: undefined,
        productId: undefined,
        productName: undefined,
        axialDirection: undefined,
        box: undefined,
        journey: undefined,
        lableNumber: undefined,
        lOne: undefined,
        lTwo: undefined,
        lThree: undefined,
        sumWeight: undefined,
        chainWeight: undefined,
        dynamicLoad: undefined,
        deadLoad: undefined,
        riseInHeightPerRevolution: undefined,
        speed: undefined,
        efficiency: undefined,
        chainPitch: undefined,
        pitchRadius: undefined,
        minimumAltitude: undefined,
        singleMeterChainWeight: undefined,
        drivingBoxWeight: undefined,
        chainBoxWeight: undefined,
        univalence: undefined,
        picture: undefined,
        partId: undefined,
        remark: undefined,
        sparedOne: undefined,
        sparedTwo: undefined,
        sparedThree: undefined,
        sparedFour: undefined,
        delFlag: undefined,
        vOne: undefined,
        vTwo: undefined,
        vThree: undefined,
        vFour: undefined,
        vFive: undefined,
        vSix: undefined,
        vSeven: undefined,
        vEight: undefined,
        vNine: undefined,
        vTen: undefined,
        vEleven: undefined,
        vTwelve: undefined,
        vThirteen: undefined,
        vFourteen: undefined,
        vFifteen: undefined,
        vSixteen: undefined,
        vSeveteen: undefined,
        vEighteen: undefined,
        vNineteen: undefined,
        vTwenty: undefined,
        vTwentyOne: undefined,
        vTwentyTwo: undefined,
        vTwentyThree: undefined,
        vTwentyFour: undefined,
        vTwentyFive: undefined,
        vTwentySix: undefined,
        vTwentySeven: undefined,
        vTwentyEight: undefined,
        vTwentyNine: undefined,
        vThirty: undefined,
        vThirtyOne: undefined,
        vThirtyTwo: undefined,
        vThirtyThree: undefined,
        vThirtyFour: undefined,
        vThirtyFive: undefined,
        vThirtySix: undefined,
        vThirtySeven: undefined,
        vThirtyEight: undefined,
        vThirtyNine: undefined,
        vForty: undefined,
        vFortyOne: undefined,
        vFortyTwo: undefined,
        vFortyThree: undefined,
        vFortyFour: undefined,
        vFortyFive: undefined,
        vFortySix: undefined,
        vFortySeven: undefined,
        vFortyEight: undefined,
        vFortyNine: undefined,
        vFifty: undefined,
        vFiftyOne: undefined,
        vFiftyTwo: undefined,
        vFiftyThree: undefined,
        gOne: undefined,
        gTwo: undefined,
        gThree: undefined,
        gFour: undefined,
        gFive: undefined,
        gSix: undefined,
        gSeven: undefined,
        gEight: undefined,
        gNine: undefined,
        gTen: undefined,
        gEleven: undefined,
        gTwelve: undefined,
        gThirteen: undefined,
        gFourteen: undefined,
        gFifteen: undefined,
        gSixteen: undefined,
        gSeveteen: undefined,
        gEighteen: undefined,
        gNineteen: undefined,
        gTwenty: undefined,
        materialCode: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加销齿链型号管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids
      getRigidChain(id).then(response => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改销齿链型号管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateRigidChain(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          } else {
            addRigidChain(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除销齿链型号管理编号为"' + ids + '"的数据项？').then(() => {
        this.loading = true;
        return delRigidChain(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/pcRigidChain/export', {
        ...this.queryParams
      }, `pcRigidChain_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
