|
|
@@ -27,23 +27,22 @@ |
|
|
|
:page-sizes="[10, 20, 50, 100]" |
|
|
|
:total="totalPage" |
|
|
|
layout="total, sizes, prev, pager, next, jumper"></el-pagination> |
|
|
|
|
|
|
|
<edit ref="edit" v-if="editVisible" @destroy="handleDestroy('edit', $event)" /> |
|
|
|
<detail ref="detail" v-if="detailVisible" @destroy="handleDestroy('detail')" /> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import initConfig from "./config"; |
|
|
|
// import ListViewWithHead from "@/views/atomViews/ListViewWithHead.vue"; |
|
|
|
import BaseListTable from "@/components/BaseListTable.vue"; |
|
|
|
import BaseSearchForm from "@/components/BaseSearchForm.vue"; |
|
|
|
import edit from "./components/edit.vue"; |
|
|
|
import detail from "./components/detail.vue"; |
|
|
|
|
|
|
|
export default { |
|
|
|
name: "BomTechAndFiringView", |
|
|
|
components: { BaseListTable, BaseSearchForm }, |
|
|
|
provide() { |
|
|
|
return { |
|
|
|
urls: this.allUrls, |
|
|
|
}; |
|
|
|
}, |
|
|
|
components: { BaseListTable, BaseSearchForm, edit, detail }, |
|
|
|
data() { |
|
|
|
const { tableConfig, headFormConfigs, urls, dialogConfigs } = initConfig.call(this); |
|
|
|
return { |
|
|
@@ -55,7 +54,11 @@ export default { |
|
|
|
page: 1, |
|
|
|
size: 20, |
|
|
|
totalPage: 0, |
|
|
|
urls, |
|
|
|
tableLoading: false, |
|
|
|
refreshLayoutKey: null, |
|
|
|
editVisible: false, |
|
|
|
detailVisible: false, |
|
|
|
}; |
|
|
|
}, |
|
|
|
created() {}, |
|
|
@@ -63,8 +66,11 @@ export default { |
|
|
|
// 更新页面默认 size |
|
|
|
const size = "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20; |
|
|
|
this.size = size; |
|
|
|
|
|
|
|
this.initDataWhenLoad && this.getList(); |
|
|
|
this.getList(); |
|
|
|
// this.initDataWhenLoad && this.getList(); |
|
|
|
}, |
|
|
|
activated() { |
|
|
|
this.refreshLayoutKey = this.layoutTable(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
/** 获取 列表数据 */ |
|
|
@@ -76,58 +82,20 @@ export default { |
|
|
|
: { |
|
|
|
page: this.page, |
|
|
|
limit: this.size, |
|
|
|
key: "", |
|
|
|
tech: "", |
|
|
|
}; |
|
|
|
|
|
|
|
if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { |
|
|
|
this.listQueryExtra.map((nameOrObj) => { |
|
|
|
if (typeof nameOrObj === "string") params[nameOrObj] = ""; |
|
|
|
else if (typeof nameOrObj === "object") { |
|
|
|
Object.keys(nameOrObj).forEach((key) => { |
|
|
|
params[key] = nameOrObj[key]; |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
this.cachedSearchCondition = Object.assign({}, params); |
|
|
|
} |
|
|
|
|
|
|
|
this.$http[this.urls.pageIsPostApi ? "post" : "get"]( |
|
|
|
this.urls.page, |
|
|
|
this.urls.pageIsPostApi |
|
|
|
? { |
|
|
|
...params, |
|
|
|
} |
|
|
|
: { |
|
|
|
params, |
|
|
|
} |
|
|
|
) |
|
|
|
this.$http |
|
|
|
.get(this.urls.page, { |
|
|
|
params, |
|
|
|
}) |
|
|
|
.then(({ data: res }) => { |
|
|
|
console.log("[http response] res is: ", res); |
|
|
|
|
|
|
|
if (res.code === 0) { |
|
|
|
// page 场景: |
|
|
|
if ("list" in res.data) { |
|
|
|
// if (res.data.list.length == 0 && res.data.total != 0) { |
|
|
|
// // refresh list |
|
|
|
// if (this.page > 1) { |
|
|
|
// this.page -= 1 |
|
|
|
// this.getList() |
|
|
|
// return |
|
|
|
// } else return |
|
|
|
// } |
|
|
|
/** 破碎记录的特殊需求:数据要结合单位 material + materialUnitDictValue */ |
|
|
|
if ("attachDictValue" in this.tableConfig.column) { |
|
|
|
this.dataList = res.data.list.map((row) => { |
|
|
|
this.tableConfig.column.attachDictValue(row, "unit", "qty", "materialUnitDictValue"); |
|
|
|
return row; |
|
|
|
}); |
|
|
|
} else this.dataList = res.data.list; |
|
|
|
|
|
|
|
this.totalPage = res.data.total; |
|
|
|
} else if ("records" in res.data) { |
|
|
|
this.dataList = res.data.records.map((item) => ({ |
|
|
|
...item, |
|
|
|
id: item._id ?? item.id, |
|
|
|
})); |
|
|
|
this.dataList = res.data.list; |
|
|
|
this.totalPage = res.data.total; |
|
|
|
} else if (Array.isArray(res.data)) { |
|
|
|
this.dataList = res.data; |
|
|
@@ -152,7 +120,6 @@ export default { |
|
|
|
}); |
|
|
|
this.tableLoading = false; |
|
|
|
}); |
|
|
|
// } |
|
|
|
}, |
|
|
|
|
|
|
|
layoutTable() { |
|
|
@@ -162,18 +129,27 @@ export default { |
|
|
|
handleBtnClick({ btnName, payload }) { |
|
|
|
console.log("[search] form handleBtnClick", btnName, payload); |
|
|
|
switch (btnName) { |
|
|
|
case "新增": |
|
|
|
this.openDialog(); |
|
|
|
case "查询": |
|
|
|
this.getList({ ...payload }); |
|
|
|
break; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleDestroy(type, refresh) { |
|
|
|
console.log("[handleDestroy] ", type); |
|
|
|
switch (type) { |
|
|
|
case "edit": |
|
|
|
this.editVisible = false; |
|
|
|
if (refresh) { |
|
|
|
this.getList(); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "导入": |
|
|
|
this.openUploadDialog(); |
|
|
|
case "detail": |
|
|
|
this.detailVisible = false; |
|
|
|
break; |
|
|
|
case "手动添加": { |
|
|
|
this.openDialog(); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleOperate({ type, data }) { |
|
|
|
console.log("payload", type, data); |
|
|
|
switch (type) { |
|
|
@@ -222,11 +198,27 @@ export default { |
|
|
|
} |
|
|
|
case "edit": { |
|
|
|
console.log("[edit] ", data); |
|
|
|
this.openDialog(data); /** data is ==> id */ |
|
|
|
this.editVisible = true; |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.edit.init({ |
|
|
|
id: data.bomTechId, |
|
|
|
bomId: data.id, |
|
|
|
techId: data.techId, |
|
|
|
}); |
|
|
|
}); |
|
|
|
break; |
|
|
|
} |
|
|
|
case "detail": { |
|
|
|
console.log("[detail] ", data); |
|
|
|
this.detailVisible = true; |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.detail.init(data); |
|
|
|
}); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleSizeChange(val) { |
|
|
|
// val 是新值 |
|
|
|
this.page = 1; |
|
|
|