|
|
@@ -917,53 +917,72 @@
|
|
|
});
|
|
|
},
|
|
|
/* 表格数据源 */
|
|
|
+ hasCurrentCategory() {
|
|
|
+ return (
|
|
|
+ this.currentId !== undefined &&
|
|
|
+ this.currentId !== null &&
|
|
|
+ this.currentId !== ''
|
|
|
+ );
|
|
|
+ },
|
|
|
+ getCategoryParams(params = {}) {
|
|
|
+ return {
|
|
|
+ ...params,
|
|
|
+ categoryLevelId: this.currentId
|
|
|
+ };
|
|
|
+ },
|
|
|
async datasource({ page, limit, where, order }) {
|
|
|
this.currentPage = page;
|
|
|
- let labs = getMaterialList({
|
|
|
+ if (!this.hasCurrentCategory()) {
|
|
|
+ return {
|
|
|
+ pageNum: page,
|
|
|
+ current: page,
|
|
|
+ size: limit,
|
|
|
+ count: 0,
|
|
|
+ list: []
|
|
|
+ };
|
|
|
+ }
|
|
|
+ const params = this.getCategoryParams({
|
|
|
pageNum: page,
|
|
|
size: limit,
|
|
|
...this.sort,
|
|
|
- ...where,
|
|
|
- categoryLevelId: this.currentId
|
|
|
+ ...where
|
|
|
});
|
|
|
- this.whereData = {
|
|
|
- pageNum: page,
|
|
|
- size: limit,
|
|
|
- ...this.sort,
|
|
|
- ...where,
|
|
|
- categoryLevelId: this.currentId
|
|
|
- };
|
|
|
- let a = await labs;
|
|
|
-
|
|
|
- return labs;
|
|
|
+ this.whereData = params;
|
|
|
+ return getMaterialList(params);
|
|
|
},
|
|
|
/* 刷新表格 */
|
|
|
reload(where) {
|
|
|
- let labs = {
|
|
|
- page: 1,
|
|
|
- where: where,
|
|
|
- categoryLevelId: this.currentId
|
|
|
- };
|
|
|
- this.whereData = labs;
|
|
|
- this.$refs.table.reload({
|
|
|
+ if (!this.hasCurrentCategory()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let labs = this.getCategoryParams({
|
|
|
page: 1,
|
|
|
- where: where,
|
|
|
- categoryLevelId: this.currentId
|
|
|
+ where: where
|
|
|
});
|
|
|
+ this.whereData = labs;
|
|
|
+ this.$refs.table.reload(
|
|
|
+ this.getCategoryParams({
|
|
|
+ page: 1,
|
|
|
+ where: where
|
|
|
+ })
|
|
|
+ );
|
|
|
},
|
|
|
/* 刷新表格 */
|
|
|
reloadNew(where) {
|
|
|
- let labs = {
|
|
|
+ if (!this.hasCurrentCategory()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let labs = this.getCategoryParams({
|
|
|
page: 1,
|
|
|
- where: where,
|
|
|
- categoryLevelId: this.currentId
|
|
|
- };
|
|
|
- this.whereData = labs;
|
|
|
- this.$refs.table.reload({
|
|
|
- page: this.currentPage,
|
|
|
- where: where,
|
|
|
- categoryLevelId: this.currentId
|
|
|
+ where: where
|
|
|
});
|
|
|
+ this.whereData = labs;
|
|
|
+ this.$refs.table.reload(
|
|
|
+ this.getCategoryParams({
|
|
|
+ page: this.currentPage,
|
|
|
+ where: where
|
|
|
+ })
|
|
|
+ );
|
|
|
},
|
|
|
getFieldModel() {
|
|
|
fieldModel({ relevance: 't_main_category' }).then((res) => {
|
|
|
@@ -1186,7 +1205,9 @@
|
|
|
watch: {
|
|
|
// 监听物料组id变化
|
|
|
currentId() {
|
|
|
- this.reload();
|
|
|
+ if (this.hasCurrentCategory()) {
|
|
|
+ this.reload();
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
$route: {
|