
后台返回的数据:

| active-text | switch 打开时的文字描述 | string | — | — |
| inactive-text | switch 关闭时的文字描述 | string | — | — |
| active-value | switch 打开时的值 | boolean / string / number | — | true |
| inactive-value | switch 关闭时的值 | boolean / string / number | — | false |
| active-color | switch 打开时的背景色 | string | — | #409EFF |
| inactive-color | switch 关闭时的背景色 | string | — | #C0CCDA |
- <el-table-column header-align="center" align="center" label="状态" prop="state">
- <template slot-scope="scope">
- <el-switch
- v-model="scope.row.state"
- active-text="打开"
- inactive-text="关闭"
- :inactive-value="0"
- :active-value="1"
- active-color="#1890ff"
- inactive-color="#c0c0c0"
- @change="addOrUpdateHandle('stateDesc',scope.row)"
- >el-switch>
- template>
- el-table-column>
- //修改状态
- if (type == "stateDesc") {
- let status = item.stateDesc == 1 ? "打开" : "关闭";
- this.$confirm(`是否${status}?`, "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- post("/xxxx/event/project/state", {
- id: item.id, //后台要的参数
- state: item.state //后台要的参数
- }).then(res => {
- console.log(res, "状态");
- this.projectlist(); //重新加载列表
- });
- })
- .catch(() => {});
- }