table index & delete array item

https://www.iviewui.com/components/table#ZDYLMB


编辑 row =
{
"keyword": "",
"value": "",
"description": "",
"index": 3,
"operate": [
"edit",
"save",
"cancel"
],
"isEdit": false,
"_index": 2,
"_rowKey": 49
} 3

demo


<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="author" content="xgqfrms">
<meta name="generator" content="VS code">
<title>vue & iview</title>
<!-- libs -->
<link rel="stylesheet" href="./ivew-3.3.3/iview.css">
<script src="./ivew-3.3.3/vue-2.6.10/vue.min.js"></script>
<script src="./ivew-3.3.3/iview.min.js"></script>
<!-- css -->
<style lang="css">
.audit-common-lable{
width: 120px;
display: inline-block;
text-align: left;
margin: 5px;
}
.audit-common-lable-long{
width: 60px;
display: inline-block;
text-align: right;
}
.audit-common-lable::after,
.audit-common-lable-long::after{
display: inline-block;
content: ":";
width: 0;
border: 1px;
margin: 2px;
}
</style>
</head>
<body>
<section>
<div id="app">
<template>
<i-row>
<i-col span="24" push="1" style="margin: 5px;">
<span class="audit-common-lable-long">请求方式</span>
<i-switch
style="width: 57px"
size="large"
@on-change="onSwitchChange"
v-model="isGet">
<span slot="open">GET</span>
<span slot="close">POST</span>
</i-switch>
</i-col>
</i-row>
</template>
<template>
<i-row>
<i-col span="24" push="1" style="margin: 5px;">
<span class="audit-common-lable-long">URL</span>
<i-input
v-model="url"
placeholder="请输入 URL"
style="width: 300px"
prefix="md-link"
/>
</i-col>
</i-row>
</template>
<template>
<i-row>
<i-col span="24" push="1" style="margin: 5px;">
<span class="audit-common-lable-long">授权方式</span>
<i-select
aria-placeholder="授权方式"
placeholder="请选择授权方式"
style="width: 200px"
v-model="authorization"
@on-change="onChangeSelect(`authorization`)"
:filterable="false"
:clearable="false">
<i-option
v-for="(item, i) in authorizations"
:value="item.value"
:key="i">
{{item.title}}
</i-option>
</i-select>
</i-col>
</i-row>
</template>
<template>
<i-row v-if="authorization==='auth'">
<i-col span="24" push="1" style="margin: 5px;">
<span class="audit-common-lable-long">Username</span>
<i-input
v-model="url"
placeholder="请输入 Username"
style="width: 300px"
prefix="md-contact"
/>
</i-col>
<i-col span="24" push="1" style="margin: 5px;">
<span class="audit-common-lable-long">Password</span>
<i-input
v-model="url"
placeholder="请输入 Password"
style="width: 300px"
prefix="md-lock"
/>
</i-col>
</i-row>
</template>
<template>
<i-row v-if="authorization==='token'">
<i-col span="24" push="1" style="margin: 5px;">
<span class="audit-common-lable-long">Token</span>
<i-input
v-model="url"
placeholder="请输入 Token!"
style="width: 300px"
prefix="md-lock"
/>
</i-col>
</i-row>
</template>
<template v-if="isGet">
<i-row>
<i-col span="18" push="1" style="margin: 5px;">
<span class="audit-common-lable">GET 参数列表</span>
<i-button
@click="addGetParams"
size="small">
+ 添加
</i-button>
<!-- :maxHeight="maxGetHeight" -->
<i-table
style="margin: 5px; max-height: 300px; overflow-y: auto;"
:columns="colsGET"
:data="dataGET">
</i-table>
</i-col>
</i-row>
</template>
<template v-else>
<i-row>
<i-col span="23" push="1" style="margin: 5px;">
<span class="audit-common-lable">POST 参数方式</span>
<i-switch
style="width: 57px"
size="large"
@on-change="onSwitchRadioChange"
v-model="isJSON">
<span slot="open">form data</span>
<span slot="close">JSON</span>
</i-switch>
</i-col>
<i-col span="23" push="1" style="margin: 5px;" v-if="isJSON">
<span class="audit-common-lable">参数类型(form data)</span>
<i-table
style="margin: 5px;"
:columns="colsPOST"
:data="dataPOST">
</i-table>
</i-col>
<i-col span="6" push="1" style="margin: 5px;" v-else>
<span class="audit-common-lable">参数类型(JSON)</span>
<i-input
style="margin: 5px; width: 500px;"
placeholder="请输入 JSON String"
v-model="jsonString"
:rows="8"
type="textarea">
</i-input>
</i-col>
</i-row>
</template>
<template>
<i-row>
<i-col span="24" push="1" style="margin: 5px;"></i-col>
<i-col span="2" push="1" style="margin: 5px;">
<i-button
@click="showSave"
size="small"
type="warning">
保存
</i-button>
</i-col>
<i-col span="2" push="0" style="margin: 5px;">
<i-button
:disabled="!isSaved"
@click="showExecute "
size="small"
type="primary">
执行
</i-button>
</i-col>
</i-row>
<Modal
v-model="saveModal.visible"
title="确定保存">
<span></span>
<div slot="footer">
<i-button
type="error"
size="large"
:loading="saveModal.loading"
@click="cancelSave">
取消
</i-button>
<i-button
type="success"
size="large"
:loading="saveModal.loading"
@click="resureSave">
确定
</i-button>
</div>
</Modal>
<Modal
v-model="executeModal.visible"
@on-ok="resureExecute"
@on-cancel="cancelExecute"
title="确定执行">
<!-- 确定执行 -->
</Modal>
</template>
</div>
</section>
<!-- js -->
<script>
let vueApp = new Vue({
el: "#app",
data: {
saveModal: {
visible: false,
loading: false,
},
executeModal: {
visible: false,
loading: false,
},
isGet: true,
colsGET: [
{
title: "index",
key: "index",
},
{
title: "params.index",
key: "index",
width: 200,
render: (h, params) => {
return h("div", [
h("span", params.index),
]);
}
},
{
title: "key",
key: "keyword",
render: (h, params) => {
let {
isEdit,
keyword,
} = params.row;
if (isEdit) {
return h("div", [
h("input", {
attrs: {
value: keyword,
placeholder: "请输入 keyword",
},
on: {
change: (e) => {
let value = e.target.value;
// console.log(`e =`, e);
// console.log(`e.target =`, e.target);
console.log(`input value =`, value);
vueApp.updateTempGet(`keyword`, value);
},
}
}, ""),
]);
} else {
return h("div", [
h("span", keyword),
]);
}
}
},
{
title: "value",
key: "value",
render: (h, params) => {
let {
isEdit,
value,
} = params.row;
if (isEdit) {
return h("div", [
h("input", {
attrs: {
value: value,
placeholder: "请输入 value",
},
on: {
change: (e) => {
let value = e.target.value;
vueApp.updateTempGet(`value`, value);
},
}
}, ""),
]);
} else {
return h("div", [
h("span", value),
]);
}
}
},
{
title: "desc",
key: "description",
render: (h, params) => {
let {
isEdit,
description: desc,
} = params.row;
if (isEdit) {
return h("div", [
h("input", {
attrs: {
value: desc,
placeholder: "请输入描述信息",
},
on: {
change: (e) => {
let value = e.target.value;
vueApp.updateTempGet(`description`, value);
},
}
}, ""),
]);
} else {
return h("div", [
h("span", desc),
]);
}
}
},
{
title: "操作",
key: "operate",
render: (h, params) => {
let that = this;
let isEdit = params.row.isEdit;
let edit = params.row.operate[0];
let save = params.row.operate[1];
if (isEdit) {
return h("div", [
h("Icon", {
props: {
name: "person"
}
}),
h("a", {
on: {
click: () => {
vueApp.clickSave(params.index);
},
},
}, save),
]);
} else {
return h("div", [
h("a", {
on: {
click: () => {
console.log(`编辑 row =\n`, JSON.stringify(params.row, null, 4), params.row.index);
// that.clickEdit(params.row.index);
vueApp.clickEdit(params.row.index);
// that.vueApp.clickEdit(params.row.index);
// that.vueApp.methods.clickEdit(params.row.index);
},
// click: that.clickEdit(params.row.index),
},
}, edit),
h("a", {
on: {
click: () => {
vueApp.clickDelete(params.index);
// vueApp.clickDelete(params.row._index);
// vueApp.clickDelete(params.row.index);
},
},
}, "删除"),
]);
}
},
},
],
dataGET: [
{
index: 0,
keyword: "a",
value: "1",
description: "a=1",
operate: ["edit", "save", "cancel"],
isEdit: false,
},
{
index: 1,
keyword: "b",
value: "2",
description: "b=1",
operate: ["edit", "save", "cancel"],
isEdit: false,
},
],
colsPOST: [],
dataPOST: [],
authorizations: [
{
title: "No Auth",
value: "no",
},
{
title: "Basic Auth",
value: "auth",
},
{
title: "Bearer Token",
value: "token",
},
],
url: "",
authorization: "no",
isJSON: true,
postType: "form",
jsonString: "",
isSaved: false,
maxGetHeight: 300,
tempGet: {
keyword: "",
value: "",
description: "",
},
tempGetInit: {
keyword: "",
value: "",
description: "",
// index: null,
// operate: ["edit", "save"],
// isEdit: false,
},
},
methods: {
updateTempGet(type = ``, value = ``) {
if(type) {
this.tempGet[type] = value;
}
},
addGetParams() {
let index = this.dataGET.length;
this.dataGET.push({
keyword: "",
value: "",
description: "",
index,
operate: ["edit", "save", "cancel"],
isEdit: false,
});
},
showSave() {
this.saveModal.visible = true;
},
showExecute() {
this.executeModal.visible = true;
},
resureSave() {
this.saveModal.visible = false;
this.isSaved = true;
},
cancelSave() {
this.saveModal.visible = false;
this.isSaved = false;
},
resureExecute() {
this.executeModal.visible = false;
},
cancelExecute() {
this.executeModal.visible = false;
},
onSwitchChange() {
// this.isGet = !this.isGet;
console.log(`value =`, this.isGet);
},
onSwitchRadioChange() {
let value = this.isJSON;
console.log(`isJSON value =`, value);
if (value) {
this.postType = "json";
} else {
this.postType = "form";
}
console.log(`postType = `, this.postType);
},
onChangeSelect (type = ``) {
let value = this[type];
// this.$Message.info(value);
},
onChangeRadio (type = ``) {
let value = this[type];
this.$Message.info(value);
},
onChangeRadioGroup (type = ``) {
let value = this[type];
this.$Message.info(value);
},
clickSave(index = ``) {
if (index !== ``) {
// console.log(`table index =`, index);
this.dataGET[index].isEdit = false;
// temp
let {
keyword,
value,
description,
} = this.tempGet;
this.dataGET[index] = {
keyword,
value,
description,
index: index,
operate: ["edit", "save"],
isEdit: false,
};
}
},
clickEdit(index = ``) {
if (index !== ``) {
// console.log(`table index =`, index);
this.dataGET[index].isEdit = true;
let {
keyword,
value,
description,
} = this.dataGET[index];
this.tempGet = {
keyword,
value,
description,
};
console.log(`tempGet =`, JSON.stringify(this.tempGet, null, 4));
}
},
clickDelete(index = ``) {
if (index !== ``) {
// slice
this.dataGET.splice(index, 1);
this.tempGet = this.tempGetInit;
let newData = this.dataGET || [];
// console.log(`newData =`, JSON.stringify(newData, null, 4));
this.updateDataGETIndex(newData);
}
},
// id ??? index
updateDataGETIndex(data = []) {
let result = [];
result = data.map((item, i) => {
console.log(`item =`, JSON.stringify(item, null, 4));
let obj = Object.assign({}, item, {
index: i,
});
console.log(`obj =`, JSON.stringify(obj, null, 4));
return obj;
});
return result;
},
},
mounted() {
//
},
});
</script>
</body>
</html>

table index & delete array item的更多相关文章

  1. Truncate table、Delete与Drop table的区别

    Truncate table.Delete与Drop table的区别 TRUNCATE TABLE 在功能上与不带 WHERE 子句的 DELETE 语句相同:二者均删除表中的全部行.但 TRUNC ...

  2. SQL中truncate table和delete的区别

    truncate table table_name delete from table_name drop table table_name truncate table在功能上与不带where子句的 ...

  3. Can’t delete list item in Sharepoint2013

         Today,I have meet a very strange error.When I attempt to delete a item from a list,I recieve an ...

  4. truncate table 和delete

    delete table 和 truncate table 使用delete语句删除数据的一般语法格式: delete [from] {table_name.view_name} [where< ...

  5. TRUNCATE TABLE 与 DELETE table 区别

    语法 TRUNCATE TABLE name;参数  TRUNCATE TABLE 在功能上与不带 WHERE 子句的 DELETE 语句相同:二者均删除表中的全部行. TRUNCATE TABLE ...

  6. Mysql中truncate table和delete语句的区别

    Mysql中的truncate table和delete语句都可以删除表里面所有数据,但是在一些情况下有些不同! 例子: truncate table gag; (1)truncate table删除 ...

  7. oracle impdp时卡死Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX

    今天在用impdp导入时,Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX卡在建索引的过程一直不动,也不报错,重试了好几遍还是这样. 后来恍 ...

  8. 小程序重置index,重置item

    重置index,重置item <block wx:for="{{index_data.banner_list}}" wx:for-index="idx" ...

  9. truncate table和delete table 的区别

    truncate table和不带 where 的 detele 功能一样,都是删除表中的所有数据. 但TRUNCATE TABLE 速度更快,占用的日志更少,这是因为 TRUNCATE TABLE ...

随机推荐

  1. dbms_redefinition方式普通表改造分区表

    --创建一张普通表t_wjq1SEIANG@seiang11g>create table t_wjq1 as select object_id,object_name,created from ...

  2. Linux系统学习之Linux账号管理

    一.基本介绍 Linux用户分为三类,即普通用户.根用户.系统用户. 普通用户指的是所有使用Linux系统的真实用户. 根用户就是root用户,权限最大,它的ID为0,也被称为超级用户,root用户拥 ...

  3. Git-命令行-使用 Tag 标记你的代码

    前言 正文开始之前,我想我们需要弄明白几个问题: 1.tag 是什么? 2.使用tag 的好处? 3.tag 和 branch 的区别以及使用场景? tag 是什么? tag , 翻译过来是标签的意思 ...

  4. Spring Cloud 分布式链路跟踪 Sleuth + Zipkin + Elasticsearch【Finchley 版】

    随着业务越来越复杂,系统也随之进行各种拆分,特别是随着微服务架构的兴起,看似一个简单的应用,后台可能很多服务在支撑:一个请求可能需要多个服务的调用:当请求迟缓或不可用时,无法得知是哪个微服务引起的,这 ...

  5. 任务调度工具Quartz入门笔记

    一,导包 1)官网下载:http://www.quartz-scheduler.org/downloads/ 2)Maven <dependency> <groupId>org ...

  6. Nginx+keepalived高可用配置实战(内附彩蛋)

    1.整体架构图如下 2.环境准备 今天所配置的是keepalived+nginx 的负载均衡 下载keepalived软件 [root@LB01 tools]# wget http://www.kee ...

  7. 分享一个公众号h5裂变吸粉源码工具

    这次我是分享我本人制作的一个恶搞程序,说白了就是一个公众号裂变吸粉工具,市面上有很多引流方法,例如最常见的就是色流,哈哈,今天我跟大家分享的方法是有趣的,好玩的,恶搞的.这个程序上线一天已经收获了61 ...

  8. 深入理解Redis Cluster

    Redis Cluster采用虚拟槽分区,所有的key根据哈希函数映射到0~16383槽内,计算公式: slot = CRC16(key) & 16383 每个节点负责维护一部分槽以及槽所映射 ...

  9. win2016 配置IIS 和mysql5.7 迁移数据表的两个小坑

    今天配置一整天,就IIS都装了一整天,都是没办法安装.net3.5的问题. 最后解决办法:https://help.aliyun.com/knowledge_detail/38203.html?spm ...

  10. LINQ基本概念及误区

    LINQ基本概念: LINQ全名Language Integrated Query(语言集成查询),它允许我们通过C#(或VB)语言,以操作内存数据的方式,查询数据库. LINQ的由来: 传统上,对数 ...