|
@@ -3,13 +3,32 @@
|
|
|
<el-table
|
|
|
:data="filterList"
|
|
|
style="width: 100%"
|
|
|
+ height="288"
|
|
|
:header-cell-style="{background:'#EBEEF5'}"
|
|
|
>
|
|
|
<el-table-column
|
|
|
fixed
|
|
|
prop="name"
|
|
|
label="过滤器名称"
|
|
|
- />
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-row>
|
|
|
+ <el-col v-if="scope.row.showEdit" :span="8">
|
|
|
+ <el-input
|
|
|
+ v-model="filterList[scope.row.index].name"
|
|
|
+ size="mini"
|
|
|
+ placeholder="请输入过滤器名称"
|
|
|
+ @keyup.enter.native="updateFilter(scope.row)"
|
|
|
+ />
|
|
|
+ </el-col>
|
|
|
+ <el-col v-if="scope.row.showEdit" :span="2"><i class="el-icon-edit" @click.stop="cancel(scope.row)" /></el-col>
|
|
|
+ <el-col v-if="!scope.row.showEdit" :span="8">
|
|
|
+ <span>{{ scope.row.name }}</span>
|
|
|
+ <i class="el-icon-edit" @click.stop="editFilter(scope.row)" />
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column
|
|
|
fixed="right"
|
|
|
align="center"
|
|
@@ -40,15 +59,20 @@
|
|
|
<script>
|
|
|
import {
|
|
|
getFilterList,
|
|
|
- deleteFilter
|
|
|
+ deleteFilter,
|
|
|
+ updateFilter
|
|
|
} from '@/api/defectManage'
|
|
|
+import { deepClone } from '@/utils/global'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
filterList: [],
|
|
|
+ copyFilterList: [],
|
|
|
total: 0,
|
|
|
curIndex: 1,
|
|
|
- pageSize: 5
|
|
|
+ pageSize: 5,
|
|
|
+ showEdit: false,
|
|
|
+ filterName: '' // 当前修改的过滤器名称
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -63,9 +87,21 @@ export default {
|
|
|
const res = await getFilterList(params)
|
|
|
if (res.code === 200) {
|
|
|
this.total = res.total
|
|
|
- this.filterList = res.data
|
|
|
+ this.filterList = res.data.map((item, key) => {
|
|
|
+ item.showEdit = false
|
|
|
+ item.index = key
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ this.copyFilterList = deepClone(this.filterList)
|
|
|
}
|
|
|
},
|
|
|
+ editFilter(e) {
|
|
|
+ this.$set(this.filterList[e.index], 'showEdit', true)
|
|
|
+ },
|
|
|
+ cancel(e) {
|
|
|
+ this.$set(this.filterList[e.index], 'showEdit', false)
|
|
|
+ this.$set(this.filterList[e.index], 'name', this.copyFilterList[e.index].name)
|
|
|
+ },
|
|
|
async deleteFilter(item) {
|
|
|
this.$confirm(`是否删除${item.name}?`, '提示', {
|
|
|
confirmButtonText: '确定',
|
|
@@ -83,6 +119,25 @@ export default {
|
|
|
}
|
|
|
this.getFilterList()
|
|
|
},
|
|
|
+ async updateFilter(e) {
|
|
|
+ if (e.name === null || e.name.replace(/\s+/g, '') === '') {
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '请填写名称',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ const res = await updateFilter({ id: e.id, name: e.name })
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '名称成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.$set(this.filterList[e.index], 'showEdit', false)
|
|
|
+ },
|
|
|
handleSizeChange(e) {
|
|
|
this.pageSize = e
|
|
|
},
|
|
@@ -94,7 +149,7 @@ export default {
|
|
|
}
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|
|
|
-.el-icon-delete {
|
|
|
- color: #F56C6C
|
|
|
+.el-icon-edit {
|
|
|
+ margin-left: 10px;
|
|
|
}
|
|
|
</style>
|