|
@@ -30,7 +30,9 @@
|
|
|
<template slot-scope="scope">
|
|
|
<div v-if="editData.currentEditIndex !== scope.$index">
|
|
|
<span style="margin-right: 8px">
|
|
|
- {{ scope.row.sort || "" }}
|
|
|
+ {{ scope.row.indexNum }}
|
|
|
+ <!-- {{ scope.$index + 1 }} -->
|
|
|
+ <!-- {{ scope.row.sort || "" }} -->
|
|
|
</span>
|
|
|
<svg-icon
|
|
|
icon-class="edit"
|
|
@@ -39,7 +41,7 @@
|
|
|
</div>
|
|
|
<el-input
|
|
|
v-else
|
|
|
- v-model="scope.row.sort"
|
|
|
+ v-model="scope.row.indexNum"
|
|
|
size="mini"
|
|
|
style="width: 60px"
|
|
|
type="number"
|
|
@@ -309,17 +311,17 @@
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
-change,
|
|
|
-channels,
|
|
|
-classEdit,
|
|
|
-classRemove,
|
|
|
-classSubmit,
|
|
|
-detail,
|
|
|
-dev,
|
|
|
-edit,
|
|
|
-list,
|
|
|
-remove,
|
|
|
-submit,
|
|
|
+ change,
|
|
|
+ channels,
|
|
|
+ classEdit,
|
|
|
+ classRemove,
|
|
|
+ classSubmit,
|
|
|
+ detail,
|
|
|
+ dev,
|
|
|
+ edit,
|
|
|
+ list,
|
|
|
+ remove,
|
|
|
+ submit,
|
|
|
} from "@/api/operation/channels";
|
|
|
|
|
|
import { dialogCallBack } from "@/utils/DialogUtil";
|
|
@@ -400,7 +402,11 @@ export default {
|
|
|
this.loading = true;
|
|
|
list().then((res) => {
|
|
|
if (res.code === 0) {
|
|
|
- this.tableData = res.data;
|
|
|
+ var data = res.data;
|
|
|
+ for (var i = 0; i < data.length; i++) {
|
|
|
+ data[i].indexNum = i + 1;
|
|
|
+ }
|
|
|
+ this.tableData = data;
|
|
|
this.loading = false;
|
|
|
}
|
|
|
});
|
|
@@ -424,7 +430,7 @@ export default {
|
|
|
// 点击编辑图标显示输入框
|
|
|
handleEditClick(row, index) {
|
|
|
this.editData.currentEditIndex = index;
|
|
|
- this.editData.currentEditSort = row.sort;
|
|
|
+ this.editData.currentEditSort = row.indexNum;
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.numberInput.focus();
|
|
|
});
|
|
@@ -432,16 +438,16 @@ export default {
|
|
|
|
|
|
// 输入框失去焦点时隐藏
|
|
|
onNumberBlur(row, index) {
|
|
|
- var newSort = row.sort;
|
|
|
+ var newSort = row.indexNum;
|
|
|
|
|
|
if (newSort === "") {
|
|
|
- row.sort = this.editData.currentEditSort;
|
|
|
+ row.indexNum = this.editData.currentEditSort;
|
|
|
this.$message.warning("序号不能为空");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (newSort <= 0) {
|
|
|
- row.sort = this.editData.currentEditSort;
|
|
|
+ row.indexNum = this.editData.currentEditSort;
|
|
|
this.$message.warning("序号必须大于0");
|
|
|
return;
|
|
|
}
|
|
@@ -451,9 +457,23 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ ///删除第index个元素
|
|
|
+
|
|
|
+ this.tableData.splice(index, 1);
|
|
|
+ this.tableData.splice(newSort - 1, 0, row);
|
|
|
+
|
|
|
+ for (var i = 0; i < this.tableData.length; i++) {
|
|
|
+ this.tableData[i].indexNum = i + 1;
|
|
|
+ }
|
|
|
this.editData.currentEditIndex = -1;
|
|
|
|
|
|
+ // channeledit(this.dialogForm).then((res) => {
|
|
|
+ // if (res.code === 0) {
|
|
|
+ // this.$message.success("编辑成功!");
|
|
|
+ // this.getList();
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+
|
|
|
// 检查序号是否重复
|
|
|
// const isDuplicate = this.tableData.some(
|
|
|
// (item, i) => i !== index && item.sortIndex === newSort
|