parent
ce1d2785cb
commit
9dbeff6cb0
4 changed files with 353 additions and 309 deletions
@ -1,308 +1,352 @@ |
|||||||
<template> |
<template> |
||||||
<div> |
<div> |
||||||
<avue-crud :height="460" :option="option" v-model:search="search" :table-loading="loading" :data="data" v-model:page="page" :before-open="beforeOpen" |
<avue-crud |
||||||
v-model="form" ref="crud" @row-update="rowUpdate" |
:height="460" |
||||||
@search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange" |
:option="option" |
||||||
@current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"> |
v-model:search="search" |
||||||
<template #menu-left> |
:table-loading="loading" |
||||||
<el-button type="primary" @click="handleAdd">新 增</el-button> |
:data="data" |
||||||
<!-- <el-button type="primary" @click="handleSet">批量设置分类</el-button> --> |
v-model:page="page" |
||||||
|
:before-open="beforeOpen" |
||||||
|
v-model="form" |
||||||
|
ref="crud" |
||||||
|
@row-update="rowUpdate" |
||||||
|
@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, scope.$index)">修改</el-button> |
||||||
|
<el-button type="text" @click="handleDelete(scope.row)">删除</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="code"> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.code"></el-input> |
||||||
</template> |
</template> |
||||||
<template #menu="scope"> |
</el-table-column> |
||||||
<el-button type="text" @click="handleEdit(scope.row,scope.$index)">修改</el-button> |
<el-table-column label="名称" prop="name"> |
||||||
<el-button type="text" @click="handleDelete(scope.row)">删除</el-button> |
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.name"></el-input> |
||||||
</template> |
</template> |
||||||
</avue-crud> |
</el-table-column> |
||||||
<el-dialog title="项目" append-to-body v-model="showDialog" width="60%"> |
<el-table-column label="定额工时" prop="standardWorkMinute"> |
||||||
<div> |
<template #default="scope"> |
||||||
<el-button type="primary" @click="insertEvent()">插入一行</el-button> |
<el-input v-model="scope.row.standardWorkMinute"></el-input> |
||||||
<el-button plain type="danger" @click="remove">删除选择行</el-button> |
</template> |
||||||
<!-- <el-button type="primary" @click="handleSave">保存</el-button> --> |
</el-table-column> |
||||||
</div> |
<el-table-column label="类型" prop="itemType"> |
||||||
<div style="margin-top: 20px;"> |
<template #default="scope"> |
||||||
<el-table :data="tidList" @selection-change="selectionChangeProject" @select="selectChange"> |
<el-select v-model="scope.row.itemType" placeholder="请选择" style="width: 240px"> |
||||||
<el-table-column type="selection" width="55px"></el-table-column> |
<el-option |
||||||
<el-table-column label="编码" prop="code"> |
v-for="item in typeList" |
||||||
<template #default="scope"> |
:key="item.id" |
||||||
<el-input v-model="scope.row.code"></el-input> |
:label="item.dictValue" |
||||||
</template> |
:value="item.dictKey" |
||||||
</el-table-column> |
/> |
||||||
<el-table-column label="名称" prop="name"> |
</el-select> |
||||||
<template #default="scope"> |
</template> |
||||||
<el-input v-model="scope.row.name"></el-input> |
</el-table-column> |
||||||
</template> |
</el-table> |
||||||
</el-table-column> |
</div> |
||||||
<el-table-column label="类型" prop="itemType"> |
<template #footer> |
||||||
<template #default="scope"> |
<span class="dialog-footer"> |
||||||
<el-select v-model="scope.row.itemType" placeholder="请选择" style="width: 240px"> |
<el-button @click="showDialog = false">取 消</el-button> |
||||||
<el-option |
<el-button type="primary" @click="handleSave">确 定</el-button> |
||||||
v-for="item in typeList" |
</span> |
||||||
:key="item.id" |
</template> |
||||||
:label="item.dictValue" |
</el-dialog> |
||||||
:value="item.dictKey" |
</div> |
||||||
/> |
|
||||||
</el-select> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table> |
|
||||||
</div> |
|
||||||
<template #footer> |
|
||||||
<span class="dialog-footer"> |
|
||||||
<el-button @click="showDialog = false">取 消</el-button> |
|
||||||
<el-button type="primary" @click="handleSave">确 定</el-button> |
|
||||||
</span> |
|
||||||
</template> |
|
||||||
</el-dialog> |
|
||||||
</div> |
|
||||||
</template> |
</template> |
||||||
|
|
||||||
<script> |
<script> |
||||||
import {getList,getType,addItem,getDetail,deleteItem,editItem} from '@/api/productionInspection/trialItem' |
import { |
||||||
|
getList, |
||||||
|
getType, |
||||||
|
addItem, |
||||||
|
getDetail, |
||||||
|
deleteItem, |
||||||
|
editItem, |
||||||
|
} from '@/api/productionInspection/trialItem'; |
||||||
export default { |
export default { |
||||||
data() { |
data() { |
||||||
return { |
return { |
||||||
loading: false, |
loading: false, |
||||||
data: [], |
data: [], |
||||||
form: {}, |
form: {}, |
||||||
showDialog: false, |
showDialog: false, |
||||||
tidList: [], |
tidList: [], |
||||||
rowId: null, //选中的id |
rowId: null, //选中的id |
||||||
projectArr: [], |
projectArr: [], |
||||||
deleteTidArr: [], //删除的数据 |
deleteTidArr: [], //删除的数据 |
||||||
page: { |
page: { |
||||||
pageSize: 10, |
pageSize: 10, |
||||||
currentPage: 1, |
currentPage: 1, |
||||||
total: 0, |
total: 0, |
||||||
}, |
}, |
||||||
search:{}, |
search: {}, |
||||||
option: { |
option: { |
||||||
tip: false, |
tip: false, |
||||||
align: 'center', |
align: 'center', |
||||||
height: 'auto', |
height: 'auto', |
||||||
searchLabelWidth: 120, |
searchLabelWidth: 120, |
||||||
simplePage: true, |
simplePage: true, |
||||||
searchShow: true, |
searchShow: true, |
||||||
searchMenuSpan: 6, |
searchMenuSpan: 6, |
||||||
searchIcon: true, |
searchIcon: true, |
||||||
searchIndex: 3, |
searchIndex: 3, |
||||||
tree: false, |
tree: false, |
||||||
border: true, |
border: true, |
||||||
selection: false, |
selection: false, |
||||||
viewBtn: false, |
viewBtn: false, |
||||||
editBtn: false, |
editBtn: false, |
||||||
addBtn: false, |
addBtn: false, |
||||||
delBtn: false, |
delBtn: false, |
||||||
editBtnText: '修改', |
editBtnText: '修改', |
||||||
viewBtnText: '详情', |
viewBtnText: '详情', |
||||||
labelWidth: 120, |
labelWidth: 120, |
||||||
menuWidth: 120, |
menuWidth: 120, |
||||||
dialogWidth: 800, |
dialogWidth: 800, |
||||||
dialogClickModal: false, |
dialogClickModal: false, |
||||||
searchEnter: true, |
searchEnter: true, |
||||||
excelBtn: false, |
excelBtn: false, |
||||||
filterBtn: true, |
filterBtn: true, |
||||||
searchShowBtn: false, |
searchShowBtn: false, |
||||||
excelBtn: true, |
excelBtn: true, |
||||||
index: true, |
index: true, |
||||||
showOverflowTooltip: true, |
showOverflowTooltip: true, |
||||||
searchLabelPosition: 'left', |
searchLabelPosition: 'left', |
||||||
searchGutter: 24, |
searchGutter: 24, |
||||||
searchSpan: 6, |
searchSpan: 6, |
||||||
menuAlign: 'left', |
menuAlign: 'left', |
||||||
gridBtn: false, |
gridBtn: false, |
||||||
searchMenuPosition: 'right', |
searchMenuPosition: 'right', |
||||||
addBtnIcon: ' ', |
addBtnIcon: ' ', |
||||||
viewBtnIcon: ' ', |
viewBtnIcon: ' ', |
||||||
delBtnIcon: ' ', |
delBtnIcon: ' ', |
||||||
editBtnIcon: ' ', |
editBtnIcon: ' ', |
||||||
column: [ |
column: [ |
||||||
{ |
{ |
||||||
label: '编码', |
label: '编码', |
||||||
prop: 'code', |
prop: 'code', |
||||||
addDisplay: false, |
addDisplay: false, |
||||||
// editDisplay: false, |
// editDisplay: false, |
||||||
span: 24, |
span: 24, |
||||||
search: true, |
search: true, |
||||||
searchLabelWidth:50, |
searchLabelWidth: 50, |
||||||
rules: [ |
rules: [ |
||||||
{ |
{ |
||||||
required: true, |
required: true, |
||||||
message: '请输入编码', |
message: '请输入编码', |
||||||
trigger: 'click', |
trigger: 'click', |
||||||
}, |
}, |
||||||
], |
], |
||||||
}, |
}, |
||||||
|
|
||||||
{ |
{ |
||||||
label: '名称', |
label: '名称', |
||||||
prop: 'name', |
prop: 'name', |
||||||
addDisplay: false, |
addDisplay: false, |
||||||
// editDisplay: false, |
// editDisplay: false, |
||||||
span: 24, |
span: 24, |
||||||
search: true, |
search: true, |
||||||
searchLabelWidth:50, |
searchLabelWidth: 50, |
||||||
rules: [ |
rules: [ |
||||||
{ |
{ |
||||||
required: true, |
required: true, |
||||||
message: '请输入名称', |
message: '请输入名称', |
||||||
trigger: 'click', |
trigger: 'click', |
||||||
}, |
}, |
||||||
], |
], |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: '类型', |
label: '类型', |
||||||
prop: 'itemType', |
prop: 'itemType', |
||||||
span: 24, |
span: 24, |
||||||
search: true, |
search: true, |
||||||
searchLabelWidth:50, |
searchLabelWidth: 50, |
||||||
type:"select", |
type: 'select', |
||||||
dicUrl:'/blade-system/dict/dictionary?code=InspectionItem-ItemType', |
dicUrl: '/blade-system/dict/dictionary?code=InspectionItem-ItemType', |
||||||
props: { label: 'dictValue', value: 'dictKey' }, |
props: { label: 'dictValue', value: 'dictKey' }, |
||||||
// dicData:[ |
// dicData:[ |
||||||
// { |
// { |
||||||
// label:'性能检测', |
// label:'性能检测', |
||||||
// value:1 |
// value:1 |
||||||
// }, |
// }, |
||||||
// { |
// { |
||||||
// label:'尺寸检测', |
// label:'尺寸检测', |
||||||
// value:2 |
// value:2 |
||||||
// }, |
// }, |
||||||
// ], |
// ], |
||||||
rules: [ |
rules: [ |
||||||
{ |
{ |
||||||
required: true, |
required: true, |
||||||
message: '请输入名称', |
message: '请输入名称', |
||||||
trigger: 'click', |
trigger: 'click', |
||||||
}, |
}, |
||||||
], |
], |
||||||
}, |
}, |
||||||
] |
{ |
||||||
}, |
label: '额定工时', |
||||||
typeList:[] |
prop: 'standardWorkMinute', |
||||||
|
addDisplay: false, |
||||||
|
// editDisplay: false, |
||||||
|
span: 24, |
||||||
|
search: true, |
||||||
|
searchLabelWidth: 50, |
||||||
|
rules: [ |
||||||
|
{ |
||||||
|
required: true, |
||||||
|
message: '请输入名称', |
||||||
|
trigger: 'click', |
||||||
|
}, |
||||||
|
], |
||||||
|
}, |
||||||
|
], |
||||||
|
}, |
||||||
|
typeList: [], |
||||||
|
}; |
||||||
|
}, |
||||||
|
mounted() { |
||||||
|
this.getTypeList(); |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
getTypeList() { |
||||||
|
getType().then(res => { |
||||||
|
this.typeList = res.data.data; |
||||||
|
}); |
||||||
|
}, |
||||||
|
handleAdd() { |
||||||
|
this.showDialog = true; |
||||||
|
this.tidList = []; |
||||||
|
}, |
||||||
|
insertEvent() { |
||||||
|
const record = { _select: false }; |
||||||
|
this.tidList.push(record); |
||||||
|
}, |
||||||
|
searchChange(params, done) { |
||||||
|
this.page.currentPage = 1; |
||||||
|
this.onLoad(); |
||||||
|
done(); |
||||||
|
}, |
||||||
|
searchReset() { |
||||||
|
this.page.currentPage = 1; |
||||||
|
this.search = {}; |
||||||
|
this.onLoad(); |
||||||
|
}, |
||||||
|
currentChange(currentPage) { |
||||||
|
this.page.currentPage = currentPage; |
||||||
|
}, |
||||||
|
sizeChange(pageSize) { |
||||||
|
this.page.pageSize = pageSize; |
||||||
|
}, |
||||||
|
refreshChange() { |
||||||
|
this.onLoad(); |
||||||
|
}, |
||||||
|
remove() { |
||||||
|
let arr = this.tidList.filter(item => item._select); |
||||||
|
if (arr.length != 0) { |
||||||
|
this.$confirm('确定将选择数据删除?', { |
||||||
|
confirmButtonText: '确定', |
||||||
|
cancelButtonText: '取消', |
||||||
|
type: 'warning', |
||||||
|
}).then(() => { |
||||||
|
if (this.rowId) { |
||||||
|
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; |
||||||
|
}); |
||||||
|
} else { |
||||||
|
this.$message.error('请至少选择一条数据进行操作!'); |
||||||
|
} |
||||||
|
}, |
||||||
|
selectChange(list, row) { |
||||||
|
row._select = !row._select; |
||||||
|
}, |
||||||
|
handleEdit(row, index) { |
||||||
|
getDetail({ id: row.id }).then(res => { |
||||||
|
res.data.data.itemType = res.data.data.itemType + ''; |
||||||
|
this.$refs.crud.rowEdit(res.data.data, index); |
||||||
|
}); |
||||||
|
}, |
||||||
|
rowUpdate(form, index, done, loading) { |
||||||
|
editItem(form).then(res => { |
||||||
|
if (res.data.code == 200) { |
||||||
|
this.$message.success('修改成功'); |
||||||
|
this.onLoad(); |
||||||
|
done(); |
||||||
} |
} |
||||||
|
}); |
||||||
}, |
}, |
||||||
mounted() { |
handleSave() { |
||||||
this.getTypeList() |
if (this.tidList.length == 0) { |
||||||
|
this.$message.error('请至少填写一条数据'); |
||||||
|
} else { |
||||||
|
let tmp = this.tidList.find(item => !item.code || !item.name || !item.itemType); |
||||||
|
if (tmp) { |
||||||
|
this.$message.error('数据请填写完整!'); |
||||||
|
} else { |
||||||
|
addItem(this.tidList).then(res => { |
||||||
|
if (res.data.code == 200) { |
||||||
|
this.$message.success('新增成功'); |
||||||
|
this.showDialog = false; |
||||||
|
this.onLoad(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
}, |
}, |
||||||
methods: { |
handleDelete(row) { |
||||||
getTypeList(){ |
this.$confirm('确定将选择数据删除?', { |
||||||
getType().then(res =>{ |
confirmButtonText: '确定', |
||||||
this.typeList = res.data.data |
cancelButtonText: '取消', |
||||||
}) |
type: 'warning', |
||||||
}, |
}).then(() => { |
||||||
handleAdd() { |
deleteItem({ ids: row.id }).then(res => { |
||||||
this.showDialog = true |
if (res.data.code == 200) { |
||||||
this.tidList = [] |
this.$message.success('删除成功'); |
||||||
}, |
|
||||||
insertEvent() { |
|
||||||
const record = { _select: false }; |
|
||||||
this.tidList.push(record) |
|
||||||
}, |
|
||||||
searchChange(params, done){ |
|
||||||
this.page.currentPage = 1; |
|
||||||
this.onLoad(); |
|
||||||
done(); |
|
||||||
}, |
|
||||||
searchReset(){ |
|
||||||
this.page.currentPage = 1 |
|
||||||
this.search = {} |
|
||||||
this.onLoad() |
|
||||||
}, |
|
||||||
currentChange(currentPage) { |
|
||||||
this.page.currentPage = currentPage; |
|
||||||
}, |
|
||||||
sizeChange(pageSize) { |
|
||||||
this.page.pageSize = pageSize; |
|
||||||
}, |
|
||||||
refreshChange() { |
|
||||||
this.onLoad(); |
this.onLoad(); |
||||||
}, |
} |
||||||
remove() { |
}); |
||||||
let arr = this.tidList.filter(item => item._select) |
}); |
||||||
if (arr.length != 0) { |
}, |
||||||
this.$confirm('确定将选择数据删除?', { |
onLoad() { |
||||||
confirmButtonText: '确定', |
this.loading = true; |
||||||
cancelButtonText: '取消', |
getList({ current: this.page.currentPage, size: this.page.pageSize, ...this.search }).then( |
||||||
type: 'warning', |
res => { |
||||||
}).then(() => { |
this.data = res.data.data.records; |
||||||
if (this.rowId) { |
this.page.total = res.data.data.total; |
||||||
let deleteData = this.tidList.filter(item => item._select) |
this.loading = false; |
||||||
this.deleteTidArr = deleteData.filter(item => item.tidId) |
} |
||||||
} |
); |
||||||
let deleteArr = this.tidList.filter(item => !item._select) |
// this.data = [ |
||||||
this.tidList = deleteArr |
// { amId: 3, code: '003', name: '泄漏率检测' }, |
||||||
}) |
// { amId: 4, code: '002', name: '外观检测' }, |
||||||
} else { |
// { amId: 5, code: '001', name: '厚度检测' }, |
||||||
this.$message.error('请至少选择一条数据进行操作!') |
// ] |
||||||
} |
// this.loading = false |
||||||
}, |
}, |
||||||
selectChange(list, row) { |
}, |
||||||
row._select = !row._select |
}; |
||||||
}, |
|
||||||
handleEdit(row,index) { |
|
||||||
getDetail({id:row.id}).then(res =>{ |
|
||||||
res.data.data.itemType = res.data.data.itemType + '' |
|
||||||
this.$refs.crud.rowEdit(res.data.data, index) |
|
||||||
}) |
|
||||||
}, |
|
||||||
rowUpdate(form, index, done, loading){ |
|
||||||
editItem(form).then(res =>{ |
|
||||||
if(res.data.code == 200){ |
|
||||||
this.$message.success('修改成功') |
|
||||||
this.onLoad() |
|
||||||
done() |
|
||||||
} |
|
||||||
}) |
|
||||||
}, |
|
||||||
handleSave() { |
|
||||||
if (this.tidList.length == 0) { |
|
||||||
this.$message.error('请至少填写一条数据') |
|
||||||
} else { |
|
||||||
let tmp = this.tidList.find(item => !item.code || !item.name || !item.itemType) |
|
||||||
if (tmp) { |
|
||||||
this.$message.error('数据请填写完整!') |
|
||||||
}else{ |
|
||||||
addItem(this.tidList).then(res =>{ |
|
||||||
if(res.data.code == 200){ |
|
||||||
this.$message.success('新增成功') |
|
||||||
this.showDialog = false |
|
||||||
this.onLoad() |
|
||||||
} |
|
||||||
}) |
|
||||||
} |
|
||||||
} |
|
||||||
}, |
|
||||||
handleDelete(row){ |
|
||||||
this.$confirm('确定将选择数据删除?', { |
|
||||||
confirmButtonText: '确定', |
|
||||||
cancelButtonText: '取消', |
|
||||||
type: 'warning', |
|
||||||
}).then(() => { |
|
||||||
deleteItem({ids:row.id}).then(res =>{ |
|
||||||
if(res.data.code == 200){ |
|
||||||
this.$message.success('删除成功') |
|
||||||
this.onLoad() |
|
||||||
} |
|
||||||
}) |
|
||||||
}) |
|
||||||
|
|
||||||
}, |
|
||||||
onLoad() { |
|
||||||
this.loading = true |
|
||||||
getList({current:this.page.currentPage,size:this.page.pageSize,...this.search}).then(res =>{ |
|
||||||
this.data = res.data.data.records |
|
||||||
this.page.total = res.data.data.total |
|
||||||
this.loading = false |
|
||||||
}) |
|
||||||
// this.data = [ |
|
||||||
// { amId: 3, code: '003', name: '泄漏率检测' }, |
|
||||||
// { amId: 4, code: '002', name: '外观检测' }, |
|
||||||
// { amId: 5, code: '001', name: '厚度检测' }, |
|
||||||
// ] |
|
||||||
// this.loading = false |
|
||||||
}, |
|
||||||
} |
|
||||||
} |
|
||||||
</script> |
</script> |
||||||
|
|
||||||
<style></style> |
<style></style> |
||||||
|
|||||||
Loading…
Reference in new issue