You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							409 lines
						
					
					
						
							12 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							409 lines
						
					
					
						
							12 KiB
						
					
					
				
								<template>
							 | 
						|
								  <div class="box">
							 | 
						|
								    <div style="width: 200%">
							 | 
						|
								      <el-card>
							 | 
						|
								        <el-row style="margin-top: 20px">
							 | 
						|
								          <el-col :span="4">
							 | 
						|
								            <el-input
							 | 
						|
								              v-model="pages.Filter"
							 | 
						|
								              @clear="getlist"
							 | 
						|
								              clearable
							 | 
						|
								            ></el-input>
							 | 
						|
								          </el-col>
							 | 
						|
								          <el-col :span="4">
							 | 
						|
								            <el-button type="primary" style="margin-left: 5%" @click="getlist"
							 | 
						|
								              >查询</el-button
							 | 
						|
								            >
							 | 
						|
								          </el-col>
							 | 
						|
								        </el-row>
							 | 
						|
								        <el-table
							 | 
						|
								          :data="tableData"
							 | 
						|
								          style="width: 100%; height: 500px"
							 | 
						|
								          row-key="id"
							 | 
						|
								          class="el-table__body-wrapper tbody"
							 | 
						|
								          @row-click="rowick"
							 | 
						|
								          highlight-current-row
							 | 
						|
								        >
							 | 
						|
								          <el-table-column prop="id" label="编号" width="300">
							 | 
						|
								          </el-table-column>
							 | 
						|
								          <el-table-column prop="displayName" label="名称" width="">
							 | 
						|
								          </el-table-column>
							 | 
						|
								          <el-table-column prop="creatorName" label="创建者" width="">
							 | 
						|
								          </el-table-column>
							 | 
						|
								          <el-table-column prop="creationTime" label="创建时间" width="200">
							 | 
						|
								            <template slot-scope="scope">
							 | 
						|
								              {{ scope.row.creationTime | dateFormat }}
							 | 
						|
								            </template>
							 | 
						|
								          </el-table-column>
							 | 
						|
								          <el-table-column prop="lastModifierName" label="修改者" width="">
							 | 
						|
								          </el-table-column>
							 | 
						|
								
							 | 
						|
								          <el-table-column
							 | 
						|
								            prop="lastModificationTime"
							 | 
						|
								            label="修改时间"
							 | 
						|
								            width="200"
							 | 
						|
								          >
							 | 
						|
								            <template slot-scope="scope">
							 | 
						|
								              {{ scope.row.lastModificationTime | dateFormat }}
							 | 
						|
								            </template>
							 | 
						|
								          </el-table-column>
							 | 
						|
								          <el-table-column label="操作">
							 | 
						|
								            <template>
							 | 
						|
								              <el-tag
							 | 
						|
								                class="move"
							 | 
						|
								                style="cursor: move; margin-left: 15px"
							 | 
						|
								                draggable="true"
							 | 
						|
								              >
							 | 
						|
								                <i
							 | 
						|
								                  class="el-icon-d-caret"
							 | 
						|
								                  style="width: 1rem; height: 1rem"
							 | 
						|
								                ></i>
							 | 
						|
								              </el-tag>
							 | 
						|
								            </template>
							 | 
						|
								          </el-table-column>
							 | 
						|
								        </el-table>
							 | 
						|
								        <!-- 新增或者编辑弹框 -->
							 | 
						|
								        <el-dialog
							 | 
						|
								          :title="title == 1 ? '新增' : '编辑'"
							 | 
						|
								          :visible.sync="dialogVisible"
							 | 
						|
								          width="75%"
							 | 
						|
								        >
							 | 
						|
								          <el-form ref="form" :model="form" label-width="80px" :rules="rules">
							 | 
						|
								            <el-row>
							 | 
						|
								              <el-col :span="8">
							 | 
						|
								                <el-form-item label="编号" prop="displayName">
							 | 
						|
								                  <el-input v-model="form.id" disabled></el-input>
							 | 
						|
								                </el-form-item>
							 | 
						|
								              </el-col>
							 | 
						|
								              <el-col :span="5">
							 | 
						|
								                <el-form-item label="名称" prop="displayName">
							 | 
						|
								                  <el-input
							 | 
						|
								                    v-model="form.displayName"
							 | 
						|
								                    ref="refinput"
							 | 
						|
								                  ></el-input>
							 | 
						|
								                </el-form-item>
							 | 
						|
								              </el-col>
							 | 
						|
								              <el-col :span="6">
							 | 
						|
								                <el-color-picker
							 | 
						|
								                  v-model="form.containerColor"
							 | 
						|
								                  @change="colorchange"
							 | 
						|
								                ></el-color-picker>
							 | 
						|
								                <el-form-item
							 | 
						|
								                  label="颜色"
							 | 
						|
								                  prop="containerColor"
							 | 
						|
								                  style="width: 90%; margin-top: -40px"
							 | 
						|
								                >
							 | 
						|
								                  <el-input v-model="form.containerColor"></el-input>
							 | 
						|
								                </el-form-item>
							 | 
						|
								              </el-col>
							 | 
						|
								              <el-col :span="5">
							 | 
						|
								                <el-form-item label="容器名称" prop="containerColorName">
							 | 
						|
								                  <el-input v-model="form.containerColorName"></el-input>
							 | 
						|
								                </el-form-item>
							 | 
						|
								              </el-col>
							 | 
						|
								              <div style="margin-top: 70px"><el-divider></el-divider></div>
							 | 
						|
								              <el-col :span="4" style="margin-left: 15px">
							 | 
						|
								                <el-form-item label="创建者">
							 | 
						|
								                  <el-input
							 | 
						|
								                    v-model="form.creatorName"
							 | 
						|
								                    disabled
							 | 
						|
								                    style="width: 110%"
							 | 
						|
								                  ></el-input>
							 | 
						|
								                </el-form-item>
							 | 
						|
								              </el-col>
							 | 
						|
								              <el-col :span="6">
							 | 
						|
								                <el-form-item label="创建时间">
							 | 
						|
								                  <el-input
							 | 
						|
								                    :value="form.creationTime | dateFormat"
							 | 
						|
								                    disabled
							 | 
						|
								                    style="width: 95%"
							 | 
						|
								                  ></el-input>
							 | 
						|
								                </el-form-item>
							 | 
						|
								              </el-col>
							 | 
						|
								              <el-col :span="4">
							 | 
						|
								                <el-form-item label="修改者">
							 | 
						|
								                  <el-input
							 | 
						|
								                    v-model="form.lastModifierName"
							 | 
						|
								                    disabled
							 | 
						|
								                    style="width: 110%"
							 | 
						|
								                  ></el-input>
							 | 
						|
								                </el-form-item>
							 | 
						|
								              </el-col>
							 | 
						|
								              <el-col :span="6">
							 | 
						|
								                <el-form-item label="修改时间">
							 | 
						|
								                  <el-input
							 | 
						|
								                    :value="form.lastModificationTime | dateFormat"
							 | 
						|
								                    disabled
							 | 
						|
								                    style="width: 95%"
							 | 
						|
								                  ></el-input>
							 | 
						|
								                </el-form-item>
							 | 
						|
								              </el-col>
							 | 
						|
								            </el-row>
							 | 
						|
								          </el-form>
							 | 
						|
								          <span slot="footer" class="dialog-footer">
							 | 
						|
								            <el-button @click="dialogVisible = false">取 消</el-button>
							 | 
						|
								            <el-button type="primary" @click="addoredit">确 定</el-button>
							 | 
						|
								          </span>
							 | 
						|
								        </el-dialog>
							 | 
						|
								      </el-card>
							 | 
						|
								    </div>
							 | 
						|
								    <!-- //ann按钮区域 -->
							 | 
						|
								    <div style="margin-left: 10px; margin-top: 7%">
							 | 
						|
								      <el-button type="primary" @click="add">新增</el-button>
							 | 
						|
								      <el-button
							 | 
						|
								        type="primary"
							 | 
						|
								        @click="editpopup"
							 | 
						|
								        style="margin-left: 0; margin-top: 10px"
							 | 
						|
								        >编辑</el-button
							 | 
						|
								      >
							 | 
						|
								      <div>
							 | 
						|
								        <div style="margin-top: 10px">
							 | 
						|
								          <el-button type="danger" @click="delsrts">删除</el-button>
							 | 
						|
								        </div>
							 | 
						|
								        <div style="margin-top: 10px">
							 | 
						|
								          <el-button type="primary" @click="topping">置顶</el-button>
							 | 
						|
								        </div>
							 | 
						|
								        <div style="margin-top: 10px">
							 | 
						|
								          <el-button type="primary" @click="toppings">置底</el-button>
							 | 
						|
								        </div>
							 | 
						|
								        <div style="margin-top: 10px">
							 | 
						|
								          <el-button type="primary" :disabled="isshow" @click="assertion"
							 | 
						|
								            >排序</el-button
							 | 
						|
								          >
							 | 
						|
								        </div>
							 | 
						|
								        <div style="margin-top: 5px">
							 | 
						|
								          <el-button type="primary" :disabled="isshow" @click="cancellation"
							 | 
						|
								            >取消</el-button
							 | 
						|
								          >
							 | 
						|
								        </div>
							 | 
						|
								      </div>
							 | 
						|
								    </div>
							 | 
						|
								  </div>
							 | 
						|
								</template>
							 | 
						|
								<script>
							 | 
						|
								import Sortable from "sortablejs";
							 | 
						|
								import {
							 | 
						|
								  containerlist,
							 | 
						|
								  newlyspecimen,
							 | 
						|
								  Containerid,
							 | 
						|
								  specimenediting,
							 | 
						|
								  detecontainer,
							 | 
						|
								  specimentopbottom,
							 | 
						|
								  specimensort,
							 | 
						|
								} from "../../request/systemapi";
							 | 
						|
								export default {
							 | 
						|
								  data() {
							 | 
						|
								    return {
							 | 
						|
								      isshow: true,
							 | 
						|
								      rules: {
							 | 
						|
								        displayName: [
							 | 
						|
								          { required: true, message: "请输入名称", trigger: "blur" },
							 | 
						|
								        ],
							 | 
						|
								        containerColorName: [
							 | 
						|
								          { required: true, message: "请输入容器名称", trigger: "blur" },
							 | 
						|
								        ],
							 | 
						|
								        containerColor: [
							 | 
						|
								          { required: true, message: "请输入容器颜色", trigger: "blur" },
							 | 
						|
								        ],
							 | 
						|
								      },
							 | 
						|
								      pages: {
							 | 
						|
								        Filter: "",
							 | 
						|
								        SkipCount: 0,
							 | 
						|
								        MaxResultCount: 100,
							 | 
						|
								        Sorting: "displayOrder desc",
							 | 
						|
								      },
							 | 
						|
								      tableData: [],
							 | 
						|
								      initTableData: [],
							 | 
						|
								      title: 1,
							 | 
						|
								      dialogVisible: false,
							 | 
						|
								      form: {
							 | 
						|
								        displayName: "",
							 | 
						|
								        containerColorName: "",
							 | 
						|
								        containerColor: "",
							 | 
						|
								      },
							 | 
						|
								    };
							 | 
						|
								  },
							 | 
						|
								  created() {
							 | 
						|
								    this.getlist();
							 | 
						|
								  },
							 | 
						|
								  mounted() {
							 | 
						|
								    this.rowDrop();
							 | 
						|
								  },
							 | 
						|
								  methods: {
							 | 
						|
								    colorchange(v) {
							 | 
						|
								      this.form.containerColor = parseInt(v)
							 | 
						|
								      console.log(this.form.containerColor);
							 | 
						|
								    },
							 | 
						|
								    //取消排序
							 | 
						|
								    cancellation() {
							 | 
						|
								      this.$message.info("取消操作");
							 | 
						|
								      this.isshow = true;
							 | 
						|
								      this.getlist();
							 | 
						|
								    },
							 | 
						|
								    //确定拖拽
							 | 
						|
								    assertion() {
							 | 
						|
								      const result = [];
							 | 
						|
								      this.tableData.forEach((item, index) => {
							 | 
						|
								        // index 从0开始的, displayOrder从大到小排
							 | 
						|
								        console.log(item.id);
							 | 
						|
								        // const currentDisplayOrder = this.tableData.length -1
							 | 
						|
								        const currentDisplayOrder = this.initTableData[index].displayOrder;
							 | 
						|
								        if (item.displayOrder != currentDisplayOrder) {
							 | 
						|
								          // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
							 | 
						|
								          result.push({ id: item.id, displayOrder: currentDisplayOrder });
							 | 
						|
								        }
							 | 
						|
								      });
							 | 
						|
								      specimensort({ itemList: result }).then((res) => {
							 | 
						|
								        this.$message.success("操作成功");
							 | 
						|
								        this.isshow = true;
							 | 
						|
								        this.getlist();
							 | 
						|
								      });
							 | 
						|
								    },
							 | 
						|
								    //初始化
							 | 
						|
								    rowDrop() {
							 | 
						|
								      this.$nextTick(() => {
							 | 
						|
								        const tbody = document.querySelector(".el-table__body-wrapper tbody");
							 | 
						|
								        const _this = this;
							 | 
						|
								        Sortable.create(tbody, {
							 | 
						|
								          handle: ".move",
							 | 
						|
								          animation: 300,
							 | 
						|
								
							 | 
						|
								          onEnd({ newIndex, oldIndex }) {
							 | 
						|
								            _this.isshow = false;
							 | 
						|
								            const currRow = _this.tableData.splice(oldIndex, 1)[0];
							 | 
						|
								            _this.tableData.splice(newIndex, 0, currRow);
							 | 
						|
								            _this.tableData.map((item, index) => {
							 | 
						|
								              if (index == newIndex && index == oldIndex) {
							 | 
						|
								                // console.log(item, "新数据");
							 | 
						|
								              } else if (index == oldIndex) {
							 | 
						|
								              } else if (index == newIndex) {
							 | 
						|
								              }
							 | 
						|
								            });
							 | 
						|
								            console.log(_this.tableData.map((item) => item.displayOrder));
							 | 
						|
								          },
							 | 
						|
								        });
							 | 
						|
								      });
							 | 
						|
								    },
							 | 
						|
								    //置低
							 | 
						|
								    toppings() {
							 | 
						|
								      if (this.form.id == undefined) {
							 | 
						|
								        this.$message.success("请点击选择操作的数据");
							 | 
						|
								      } else {
							 | 
						|
								        specimentopbottom(this.form.id, 2).then((res) => {
							 | 
						|
								          this.$message.success("操作成功");
							 | 
						|
								          this.getlist();
							 | 
						|
								        });
							 | 
						|
								      }
							 | 
						|
								    },
							 | 
						|
								    //置顶
							 | 
						|
								    topping() {
							 | 
						|
								      if (this.form.id == undefined) {
							 | 
						|
								        this.$message.warning("请点击选择操作的数据");
							 | 
						|
								      } else {
							 | 
						|
								        specimentopbottom(this.form.id, 1).then((res) => {
							 | 
						|
								          this.$message.success("操作成功");
							 | 
						|
								          this.getlist();
							 | 
						|
								        });
							 | 
						|
								      }
							 | 
						|
								    },
							 | 
						|
								    //删除
							 | 
						|
								    delsrts() {
							 | 
						|
								      if (this.form.id == undefined) {
							 | 
						|
								        this.$message.warning("请选择删除的数据");
							 | 
						|
								      } else {
							 | 
						|
								        this.$confirm("是否确认删除,是否继续?", "提示", {
							 | 
						|
								          confirmButtonText: "确定",
							 | 
						|
								          cancelButtonText: "取消",
							 | 
						|
								          type: "warning",
							 | 
						|
								        })
							 | 
						|
								          .then(() => {
							 | 
						|
								            detecontainer(this.form.id).then((res) => {
							 | 
						|
								              this.$message.success("删除成功");
							 | 
						|
								              this.getlist();
							 | 
						|
								              this.form = {};
							 | 
						|
								            });
							 | 
						|
								          })
							 | 
						|
								          .catch(() => {});
							 | 
						|
								        // detecontainer(this.form.id).then((res) => {
							 | 
						|
								        //   this.$message.success("删除成功");
							 | 
						|
								        //   this.form = {};
							 | 
						|
								        //   this.getlist();
							 | 
						|
								        // });
							 | 
						|
								      }
							 | 
						|
								    },
							 | 
						|
								    //编辑弹框
							 | 
						|
								    editpopup() {
							 | 
						|
								      if (this.form.id == undefined) {
							 | 
						|
								        this.$message.warning("请点击选择操作的数据");
							 | 
						|
								      } else {
							 | 
						|
								        this.dialogVisible = true;
							 | 
						|
								        this.title = 2;
							 | 
						|
								        Containerid(this.form.id).then((res) => {
							 | 
						|
								          console.log(res);
							 | 
						|
								          this.form = res.data;
							 | 
						|
								        });
							 | 
						|
								      }
							 | 
						|
								    },
							 | 
						|
								    //点击列表通过id查询
							 | 
						|
								    rowick(row) {
							 | 
						|
								      Containerid(row.id).then((res) => {
							 | 
						|
								        console.log(res);
							 | 
						|
								        this.form = res.data;
							 | 
						|
								      });
							 | 
						|
								      console.log(row);
							 | 
						|
								    },
							 | 
						|
								    //确定新增或者编辑
							 | 
						|
								    addoredit() {
							 | 
						|
								      this.$refs.form.validate((v) => {
							 | 
						|
								        if (v) {
							 | 
						|
								          if (this.title == 1) {
							 | 
						|
								            newlyspecimen({
							 | 
						|
								              displayName: this.form.displayName,
							 | 
						|
								              containerColorName: this.form.containerColorName,
							 | 
						|
								              containerColor: Number(this.form.containerColor),
							 | 
						|
								            }).then((res) => {
							 | 
						|
								              this.$message.success("新增成功");
							 | 
						|
								              this.getlist();
							 | 
						|
								              this.dialogVisible = false;
							 | 
						|
								            });
							 | 
						|
								          } else if (this.title == 2) {
							 | 
						|
								            specimenediting(this.form.id, {
							 | 
						|
								              displayName: this.form.displayName,
							 | 
						|
								              containerColorName: this.form.containerColorName,
							 | 
						|
								              containerColor: Number(this.form.containerColor),
							 | 
						|
								            }).then((res) => {
							 | 
						|
								              this.$message.success("修改成功");
							 | 
						|
								              this.getlist();
							 | 
						|
								              this.dialogVisible = false;
							 | 
						|
								            });
							 | 
						|
								          }
							 | 
						|
								        }
							 | 
						|
								      });
							 | 
						|
								    },
							 | 
						|
								    //新增弹框
							 | 
						|
								    add() {
							 | 
						|
								      this.title = 1;
							 | 
						|
								      this.dialogVisible = true;
							 | 
						|
								      this.form = {};
							 | 
						|
								      this.$nextTick(() => {
							 | 
						|
								        this.$refs.refinput.focus();
							 | 
						|
								      });
							 | 
						|
								    },
							 | 
						|
								    getlist() {
							 | 
						|
								      containerlist(this.pages).then((res) => {
							 | 
						|
								        this.initTableData = [...res.data.items];
							 | 
						|
								        this.tableData = res.data.items;
							 | 
						|
								        console.log(res);
							 | 
						|
								      });
							 | 
						|
								    },
							 | 
						|
								  },
							 | 
						|
								};
							 | 
						|
								</script>
							 | 
						|
								<style lang="scss" scoped>
							 | 
						|
								::v-deep .el-input.is-disabled .el-input__inner {
							 | 
						|
								  width: 88%;
							 | 
						|
								}
							 | 
						|
								.box {
							 | 
						|
								  display: flex;
							 | 
						|
								}
							 | 
						|
								</style>
							 |