中航光电热表web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
7.3 KiB

7 months ago
<template>
6 months ago
<div>
<avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" :before-open="beforeOpen"
v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
@search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
@current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
<template #menu-left>
<el-button type="primary" @click="handleAdd"> </el-button>
<!-- <el-button type="primary" @click="handleSet">批量设置分类</el-button> -->
</template>
<template #menu="scope">
<el-button type="text" @click="handleEdit(scope.row)">修改</el-button>
<el-button type="text" @click="handleDelete">删除</el-button>
</template>
</avue-crud>
<el-dialog title="项目" append-to-body v-model="showDialog" width="60%">
<div>
<el-button type="primary" @click="insertEvent()">插入一行</el-button>
<el-button plain type="danger" @click="remove">删除选择行</el-button>
<el-button type="primary" @click="handleSave">保存</el-button>
</div>
<div style="margin-top: 20px;">
<el-table :data="tidList" @selection-change="selectionChangeProject" @select="selectChange">
<el-table-column type="selection" width="55px"></el-table-column>
<el-table-column label="编码" prop="oneData">
<template #default="scope">
7 months ago
<el-input v-model="scope.row.oneData"></el-input>
6 months ago
</template>
</el-table-column>
<el-table-column label="名称" prop="twoData">
<template #default="scope">
<el-input v-model="scope.row.twoData"></el-input>
</template>
</el-table-column>
</el-table>
</div>
</el-dialog>
</div>
7 months ago
</template>
<script>
export default {
6 months ago
data() {
return {
loading: false,
data: [],
form: {},
showDialog: false,
tidList: [],
rowId: null, //选中的id
projectArr: [],
deleteTidArr: [], //删除的数据
page: {
7 months ago
pageSize: 10,
currentPage: 1,
total: 0,
},
6 months ago
option: {
7 months ago
tip: false,
align: 'center',
6 months ago
height: 'auto',
searchLabelWidth: 120,
7 months ago
simplePage: true,
searchShow: true,
6 months ago
searchMenuSpan: 12,
7 months ago
searchIcon: true,
searchIndex: 3,
tree: false,
border: true,
selection: false,
viewBtn: false,
6 months ago
editBtn: false,
addBtn: false,
7 months ago
delBtn: false,
editBtnText: '修改',
6 months ago
viewBtnText: '详情',
7 months ago
labelWidth: 120,
// menuWidth: 330,
dialogWidth: 1200,
dialogClickModal: false,
searchEnter: true,
excelBtn: false,
filterBtn: true,
searchShowBtn: false,
excelBtn: true,
index: true,
showOverflowTooltip: true,
6 months ago
searchLabelPosition: 'left',
searchGutter: 24,
searchSpan: 6,
menuAlign: 'left',
gridBtn: false,
searchMenuPosition: 'right',
addBtnIcon: ' ',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
7 months ago
column: [
{
label: '编码',
prop: 'oneData',
addDisplay: false,
editDisplay: false,
span: 24,
6 months ago
search: true,
searchLabelWidth:50,
7 months ago
rules: [
{
required: true,
message: '请输入编码',
trigger: 'click',
},
],
},
{
label: '名称',
prop: 'twoData',
addDisplay: false,
editDisplay: false,
span: 24,
6 months ago
search: true,
searchLabelWidth:50,
7 months ago
rules: [
{
required: true,
message: '请输入名称',
trigger: 'click',
},
],
},
]
}
}
},
6 months ago
mounted() {
7 months ago
},
6 months ago
methods: {
handleAdd() {
7 months ago
this.showDialog = true
this.tidList = []
},
6 months ago
insertEvent() {
const record = { _select: false };
7 months ago
this.tidList.push(record)
},
6 months ago
remove() {
7 months ago
let arr = this.tidList.filter(item => item._select)
6 months ago
if (arr.length != 0) {
7 months ago
this.$confirm('确定将选择数据删除?', {
6 months ago
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
if (this.rowId) {
7 months ago
let deleteData = this.tidList.filter(item => item._select)
this.deleteTidArr = deleteData.filter(item => item.tidId)
}
let deleteArr = this.tidList.filter(item => !item._select)
this.tidList = deleteArr
})
6 months ago
} else {
7 months ago
this.$message.error('请至少选择一条数据进行操作!')
}
},
6 months ago
selectChange(list, row) {
7 months ago
row._select = !row._select
},
6 months ago
handleEdit(row) {
7 months ago
this.rowId = row.amId
this.tidList = [
6 months ago
{ ...row }
7 months ago
]
6 months ago
this.projectArr = [{ ...row }]
7 months ago
this.showDialog = true
},
6 months ago
handleSave() {
if (this.tidList.length == 0) {
this.$message.error('请至少填写一条数据')
} else {
let tmp = this.tidList.find(item => !item.oneData || !item.twoData)
if (tmp) {
this.$message.error('数据请填写完整!')
}
7 months ago
}
},
6 months ago
onLoad() {
7 months ago
this.loading = true
this.data = [
6 months ago
{ amId: 3, oneData: '003', twoData: '泄漏率检测' },
{ amId: 4, oneData: '002', twoData: '外观检测' },
{ amId: 5, oneData: '001', twoData: '厚度检测' },
7 months ago
]
this.loading = false
},
}
}
</script>
6 months ago
<style></style>