空管耐用品库存管理前端
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.

295 lines
7.5 KiB

5 months ago
<template>
<div>
<basic-container>
<!-- <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form" :page.sync="page"
:permission="permissionList" @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 slot-scope="scope" slot="menu">
<el-button type="text" size="small" @click.stop="handleReturn(scope.row)">查看
</el-button>
<el-button type="text" size="small" @click.stop="handleReturn(scope.row)">编辑
</el-button>
</template>
</avue-crud> -->
4 months ago
<avue-crud
:option="option"
v-model="form"
:data="data"
@row-del="rowDel" @on-load="onLoad"
:table-loading="loading"
@row-update="rowUpdate"
@row-save="rowSave"
@search-change="searchChange"
@search-reset="searchReset"
:page.sync="page"
></avue-crud>
5 months ago
</basic-container>
</div>
</template>
<script>
import { mapGetters } from "vuex";
import { getList, add, remove, update, getCode } from "@/api/materials/list";
5 months ago
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0
},
option: {
height: 'auto',
calcHeight: 30,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
selection: true,
viewBtn: true,
dialogClickModal: false,
menu: true,
selection: false,
printBtn: false,
refreshBtn: false,
gridBtn: false,
gridBackgroundImage: false,
gridSpan: false,
filterBtn: false,
columnBtn: false,
column: [
{
label: "物资名称",
4 months ago
prop: "materialName",
5 months ago
search: true,
},
{
4 months ago
label: "规格/型号",
4 months ago
prop: "model",
5 months ago
},
{
label: "类别",
prop: "materialCode",
4 months ago
type: 'select',
dicData: [],
4 months ago
props: {
label: 'label',
value: 'value'
},
// formatter: (row, value, label, column) => {
// // 根据value值返回对应的label
// const typeMap = {
// 1: '易耗品',
// 2: '耐用品'
// };
// return typeMap[value] || value;
// },
dataType: 'string'
5 months ago
},
{
label: "单位",
4 months ago
prop: "unit",
5 months ago
},
]
},
data: [],
dialogLogVisible: false,
activeName: 'first',
tableData: [],
ckTable: [
{ str1: '3', str2: '2025-04-09', str3: '部门一' },
{ str1: '37', str2: '2025-04-03', str3: '部门一' }
],
rkTable: [
{ str1: '5', str2: '2025-03-19', str3: '部门二' },
{ str1: '12', str2: '2025-03-19', str3: '部门二' },
],
bfTable: [
{ str1: '9', str2: '2025-03-19', str3: '部门三' },
{ str1: '19', str2: '2025-03-19', str3: '部门三' },
],
};
},
computed: {
...mapGetters(["userInfo", "permission"]),
permissionList() {
return {
addBtn: false,
viewBtn: false,
delBtn: false,
editBtn: false
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(",");
}
},
mounted() {
this.tableData = this.ckTable
this.fetchMaterialCode()
5 months ago
},
methods: {
fetchMaterialCode() {
getCode().then(res => {
const dicData = res.data.result.map(item => ({
label: item.name,
value: item.code
}));
console.log('materialCode字典数据:', dicData);
const targetColumn = this.option.column.find(col => col.prop === 'materialCode');
if (targetColumn) {
targetColumn.dicData = dicData;
}
}).catch(error => {
console.error('获取materialCode字典数据失败:', error);
this.$message.error('加载类别数据失败,请刷新重试');
});
},
5 months ago
handleLog() {
this.dialogLogVisible = true
},
handleTabClick(tab, event) {
console.log(tab, event);
if (this.activeName == 'first') {
this.tableData = this.ckTable
}
if (this.activeName == 'second') {
this.tableData = this.rkTable
}
if (this.activeName == 'third') {
this.tableData = this.bfTable
}
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
4 months ago
//新增
5 months ago
rowSave(row, done, loading) {
4 months ago
add(row).then(() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
done();
}, error => {
window.console.log(error);
loading();
});
5 months ago
},
4 months ago
//修改
rowUpdate(row, index, done, loading) {
update(row).then(() => {
this.onLoad(this.page)
this.$message({
type: "success",
message: "操作成功!"
})
done(row)
},error => {
window.console.log(error);
loading();
})
},
//删除
rowDel(row, index, done) {
5 months ago
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
4 months ago
return remove(row.id.toString());
5 months ago
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
4 months ago
done();
})
.catch(action => {
if (action !== 'cancel') {
this.$message({
type: "error",
message: "操作失败"
});
}
5 months ago
});
},
onLoad(page, params = {}) {
this.loading = true;
4 months ago
// this.data.push({
// no: '00100001',
// name: '物资1',
// xh: '1',
// lb: '易耗品',
// unit: '11',
// number: '1',
// dj: '11',
// pice: '11'
// }, {
// no: '00100002',
// name: '物资2',
// xh: '2',
// lb: '耐用品',
// unit: '22',
// number: '2',
// dj: '11',
// pice: '22'
// })
this.loading = false
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
// const data = res.data.data;
this.data = res.data.result.list;
4 months ago
this.loading = false
this.page.total = res.data.result.total;
4 months ago
// this.selectionClear();
});
5 months ago
this.loading = false
}
}
};
</script>