<template>
|
<div class="versionType">
|
<!-- title + '组件' -->
|
<el-dialog
|
:title="'编辑下拉框>' + title"
|
:visible.sync="isvisible"
|
:width="dialogWidth"
|
:before-close="handleClose"
|
append-to-body
|
custom-class="iframe-dialog"
|
>
|
<div class="drawerContent">
|
<el-table
|
v-if="isTableShow"
|
:header-cell-style="{ background: '#f1f3f8', color: '#000009' }"
|
ref="multipleTable"
|
:data="BomTableData"
|
tooltip-effect="dark"
|
height="460"
|
>
|
<el-table-column prop="unit" label="类别">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.name"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="createdAt" label="设为默认">
|
<template slot-scope="scope">
|
<el-switch @change="switchChange(scope, scope.row.isDefault)" v-model="scope.row.isDefault"></el-switch>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="100">
|
<template slot-scope="scope">
|
<!-- <i class="el-icon-top" id="iconStyle"></i>
|
<i class="el-icon-bottom" id="iconStyle"></i> -->
|
<i class="el-icon-delete" id="iconStyle" @click="handleDelete(scope.row.id)"></i>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-button @click="handleAdd()" type="text" class="margin_top_15px margin_left_20px">新增下拉框</el-button>
|
</div>
|
<div slot="footer">
|
<!-- <el-button
|
@click="handleAdd()"
|
style="margin-left: 16px; color: #fff; background-color: #ee790c"
|
>新增</el-button
|
> -->
|
<el-button @click="handleClose">取消</el-button
|
><el-button
|
type="primary"
|
@click="handleConfirmSave()"
|
style="margin-left: 16px; color: #fff; background-color: #2a78fb"
|
>确定</el-button
|
>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
export default {
|
name: "VersionType",
|
mixins: [],
|
components: {},
|
props: {
|
title: {
|
type: String,
|
default: "版本类型"
|
},
|
editRow: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
},
|
workList: {
|
type: Array
|
}
|
},
|
computed: {},
|
data() {
|
return {
|
dialogWidth: "30%",
|
isvisible: false,
|
isTableShow: true,
|
BomTableData: [1]
|
}
|
},
|
created() {},
|
watch: {
|
editDialogVisible(newVal) {
|
if (newVal) {
|
this.BomTableData = this.workList
|
}
|
},
|
workList(newVal) {
|
console.log(newVal)
|
this.BomTableData = this.workList
|
}
|
},
|
mounted() {},
|
methods: {
|
handleAdd() {
|
this.BomTableData.push({ name: "", isDefault: false })
|
},
|
handleDelete(id) {
|
this.BomTableData = this.BomTableData.filter((i) => {
|
return i.id != id
|
})
|
},
|
|
switchChange(scope, val) {
|
let arr = []
|
for (let i in this.BomTableData) {
|
if (this.BomTableData[i].isDefault) {
|
arr.push(i)
|
}
|
}
|
if (arr.length > 1) {
|
this.$message({
|
message: "只能设一个为默认",
|
type: "warning"
|
})
|
scope.row.isDefault = !val
|
}
|
},
|
handleConfirmSave() {
|
let arr = []
|
for (let i in this.BomTableData) {
|
if (this.BomTableData[i].isDefault) {
|
arr.push(i)
|
}
|
}
|
if (arr.length > 1) {
|
this.$message({
|
message: "只能设一个为默认",
|
type: "warning"
|
})
|
} else {
|
this.$emit("handleConfirmSave", this.BomTableData)
|
this.isvisible = false
|
}
|
},
|
handleClose() {
|
this.isvisible = false
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
::v-deep {
|
.iframe-dialog .el-dialog__body {
|
}
|
.el-dialog__footer {
|
height: 55px;
|
line-height: 55px;
|
background-color: #f5f5f5;
|
padding: 0px 20px 0;
|
text-align: right;
|
box-sizing: border-box;
|
border-top: 1px solid #dadee5;
|
}
|
}
|
::v-deep .el-dialog__body {
|
padding-bottom: 10px !important;
|
}
|
</style>
|