|
|
@@ -0,0 +1,236 @@
|
|
|
+<template>
|
|
|
+ <div class="bmpz-wrap">
|
|
|
+ <div class="btn-wrap">
|
|
|
+ <el-button type="primary" @click="add" size="small">添加</el-button>
|
|
|
+ <el-button type="primary" @click="_delete" size="small">删除</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="table-wrap">
|
|
|
+ <el-table
|
|
|
+ ref="multipleTable"
|
|
|
+ @selection-change="selectionChange"
|
|
|
+ :data="tableData"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column type="selection" width="55"> </el-table-column>
|
|
|
+ <el-table-column prop="date" label="排序" width="100">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <div class="sort-wrap">
|
|
|
+ <i class="el-icon-caret-top" @click="sortTop(row)"></i>
|
|
|
+ <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="type.descp" label="类型" width="130">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-select
|
|
|
+ @change="settype(row, $event)"
|
|
|
+ v-model="row.type.code"
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.type"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="content" label="内容" width="180">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <!-- 固定值 -->
|
|
|
+ <el-input
|
|
|
+ v-if="row.type.code == 3"
|
|
|
+ v-model="row.content"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ ></el-input>
|
|
|
+ <!-- 日期 -->
|
|
|
+ <el-select
|
|
|
+ v-if="row.type.code == 1"
|
|
|
+ v-model="row.content"
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.date"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="length" label="长度">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input
|
|
|
+ v-if="row.type.code == 2"
|
|
|
+ v-model="row.length"
|
|
|
+ placeholder="请输入"
|
|
|
+ ></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="currentId" label="当前流水">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input
|
|
|
+ v-if="row.type.code == 2"
|
|
|
+ v-model="row.currentId"
|
|
|
+ placeholder="请输入"
|
|
|
+ ></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="step" label="步长">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input
|
|
|
+ v-if="row.type.code == 2"
|
|
|
+ v-model="row.step"
|
|
|
+ placeholder="请输入"
|
|
|
+ ></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="address" label="说明"></el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData: [],
|
|
|
+ selectData: [],
|
|
|
+ options: {
|
|
|
+ type: [
|
|
|
+ {
|
|
|
+ value: 1,
|
|
|
+ label: '日期'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 2,
|
|
|
+ label: '流水号'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 3,
|
|
|
+ label: '固定值'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ date: [
|
|
|
+ {
|
|
|
+ value: '年月日',
|
|
|
+ label: '年月日'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '年月日时分秒',
|
|
|
+ label: '年月日时分秒'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '年月日时',
|
|
|
+ label: '年月日时'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '年月',
|
|
|
+ label: '年月'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '年',
|
|
|
+ label: '年'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ selectionChange(selection) {
|
|
|
+ if (selection.length > 1) {
|
|
|
+ this.$refs.multipleTable.clearSelection();
|
|
|
+ this.$refs.multipleTable.toggleRowSelection(selection.pop());
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ settype(row, val) {
|
|
|
+ row.type.descp = this.options.type.find((n) => n.value == val).label;
|
|
|
+ // 重选初始化数据
|
|
|
+ row.content = ''
|
|
|
+ row.length = ''
|
|
|
+ row.currentId = ''
|
|
|
+ row.step = ''
|
|
|
+ row.remark = ''
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取选中值
|
|
|
+ getSelection() {
|
|
|
+ return this.$refs.multipleTable.selection;
|
|
|
+ },
|
|
|
+ _delete() {
|
|
|
+ let selection = this.getSelection();
|
|
|
+ if (selection.length > 0) {
|
|
|
+ let itemIndex = this.tableData.findIndex((n) => {
|
|
|
+ return n.sort == selection[0].sort;
|
|
|
+ });
|
|
|
+ if (itemIndex !== -1) {
|
|
|
+ this.tableData.splice(itemIndex, 1);
|
|
|
+ this.againSort();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ add() {
|
|
|
+ this.tableData.push({
|
|
|
+ type: {
|
|
|
+ code: '',
|
|
|
+ descp: ''
|
|
|
+ },
|
|
|
+ content: '',
|
|
|
+ length: '', // 长度
|
|
|
+ currentId: '', // 当前流水
|
|
|
+ step: '', // 步长
|
|
|
+ remark: '', // 说明
|
|
|
+ sort: this.tableData.length + 1
|
|
|
+ });
|
|
|
+ },
|
|
|
+ sortTop(row) {
|
|
|
+ if (row.sort <= 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let rowN = this.tableData.find((n) => n.sort == row.sort - 1);
|
|
|
+ rowN.sort += 1;
|
|
|
+ row.sort -= 1;
|
|
|
+ this.tableData.sort((a, b) => {
|
|
|
+ return a.sort - b.sort;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ sortBottom(row) {
|
|
|
+ if (row.sort >= this.tableData.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let rowN = this.tableData.find((n) => n.sort == row.sort + 1);
|
|
|
+ rowN.sort -= 1;
|
|
|
+ row.sort += 1;
|
|
|
+ this.tableData.sort((a, b) => {
|
|
|
+ return a.sort - b.sort;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ againSort() {
|
|
|
+ this.tableData.forEach((n, index) => {
|
|
|
+ n.sort = index + 1;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.sort-wrap {
|
|
|
+ i {
|
|
|
+ font-size: 30px;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ .el-icon-caret-top {
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
+ .el-icon-caret-bottom {
|
|
|
+ color: #157a2c;
|
|
|
+ }
|
|
|
+}
|
|
|
+.btn-wrap{
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+</style>
|