update bomTech edit

This commit is contained in:
lb 2023-07-19 14:46:40 +08:00
parent f1e588a716
commit 5f1acde7c0
4 changed files with 219 additions and 77 deletions

View File

@ -109,7 +109,7 @@ export default {
default: 0, default: 0,
}, },
}, },
inject: ["urls"], // inject: ["urls"],
data() { data() {
return { return {
dataList: [], dataList: [],

View File

@ -5,21 +5,171 @@
description: description:
--> -->
<template></template> <template>
<el-dialog
class="dialog-just-form"
:visible="dialogVisible"
@close="handleClose"
:destroy-on-close="false"
:close-on-click-modal="false"
width="'50%'">
<!-- title -->
<div slot="title" class="dialog-title">
<h1 class="">编辑</h1>
</div>
<!-- form -->
<el-form ref="dataForm" :model="dataForm" v-loading="loading">
<el-row :gutter="20">
<el-col>
<el-form-item label="bom" prop="bomId" :rules="rules.bom">
<el-input v-model="dataForm.bomId" clearable disabled></el-input>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="工艺" prop="techId" :rules="rules.tech">
<el-select v-model="dataForm.techId" filterable clearable>
<el-option
v-for="(tech, index) in techList"
:key="index"
:label="tech.label"
:value="tech.value"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<!-- footer -->
<div slot="footer">
<!-- <el-button @click="handleBtnClick('保存')">保存</el-button> -->
<el-button type="primary" @click="handleBtnClick('更新')">更新</el-button>
<el-button @click="handleBtnClick('取消')">取消</el-button>
</div>
</el-dialog>
</template>
<script> <script>
import { ref } from "vue";
export default { export default {
name: "BomTechAndFiringEdit", name: "BomTechAndFiringEdit",
components: {}, components: {},
props: {}, props: {},
data() { data() {
return {} return {
dialogVisible: false,
loading: false,
dataForm: {
id: null,
bomId: null,
techId: null,
},
rules: {
bom: [],
tech: [{ required: true, message: "必填项不能为空", trigger: "blur" }],
},
techList: [],
};
},
computed: {},
mounted() {
this.getTechList().then(() => {
this.dialogVisible = true;
});
},
methods: {
//
init({ id, bomId, techId }) {
this.$set(this.dataForm, "id", id);
this.$set(this.dataForm, "bomId", bomId);
this.$set(this.dataForm, "techId", techId);
}, },
computed: {}, //
methods: {}, async getTechList() {
} const { data: res } = await this.$http.post("/pms/equipmentTech/pageView", {
wsId: 3,
bom: "",
key: "",
limit: 999,
page: 1,
});
if (res.code == 0) {
console.log("res", res);
this.techList = res.data.list.map((item) => {
return {
label: item.code,
value: item.id,
};
});
}
},
//
async push(type = "add") {
if (type == "add") {
} else if (type == "update") {
}
},
//
handleBtnClick(type) {
switch (type) {
// case "":
// this.$refs.dataForm.validate((valid) => {
// if (valid) {
// this.$emit("emit-data", { type: "", data: this.dataForm });
// }
// });
// break;
case "更新":
this.$refs.dataForm.validate((valid) => {
if (valid) {
this.$http.put("/pms/bomTech", this.dataForm).then((res) => {
if (res.data.code == 0) {
this.$message.success("更新成功");
this.handleClose(true);
} else {
this.$message.error(res.data.msg);
}
});
}
});
break;
case "取消":
this.handleClose();
break;
default:
break;
}
},
handleClose(refresh = false) {
this.dialogVisible = false;
setTimeout(() => {
this.$emit("destroy", refresh);
}, 500);
},
},
};
</script> </script>
<style scoped lang="scss"> <style scoped>
.dialog-just-form >>> .el-dialog__body {
/* padding-top: 16px !important;
padding-bottom: 16px !important; */
padding-top: 0 !important;
padding-bottom: 0 !important;
}
.el-select,
.el-cascader,
.el-date-editor {
width: 100% !important;
}
.dialog-just-form >>> .el-dialog__header {
padding: 10px 20px 10px;
/* background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), white); */
}
</style> </style>

View File

@ -19,7 +19,7 @@ export default function () {
width: 90, width: 90,
subcomponent: TableOperaionComponent, subcomponent: TableOperaionComponent,
options: [ options: [
{ name: "edit", label: "编辑", icon: "edit-outline" }, { name: "edit", label: "编辑", icon: "edit-outline", emitFull: true },
// { name: "copy", label: "复制", icon: "copy-document" }, // { name: "copy", label: "复制", icon: "copy-document" },
// { name: "delete", icon: "delete", label: "删除", emitFull: true, permission: "" }, // { name: "delete", icon: "delete", label: "删除", emitFull: true, permission: "" },
], ],

View File

@ -27,23 +27,22 @@
:page-sizes="[10, 20, 50, 100]" :page-sizes="[10, 20, 50, 100]"
:total="totalPage" :total="totalPage"
layout="total, sizes, prev, pager, next, jumper"></el-pagination> 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> </div>
</template> </template>
<script> <script>
import initConfig from "./config"; import initConfig from "./config";
// import ListViewWithHead from "@/views/atomViews/ListViewWithHead.vue";
import BaseListTable from "@/components/BaseListTable.vue"; import BaseListTable from "@/components/BaseListTable.vue";
import BaseSearchForm from "@/components/BaseSearchForm.vue"; import BaseSearchForm from "@/components/BaseSearchForm.vue";
import edit from "./components/edit.vue";
import detail from "./components/detail.vue";
export default { export default {
name: "BomTechAndFiringView", name: "BomTechAndFiringView",
components: { BaseListTable, BaseSearchForm }, components: { BaseListTable, BaseSearchForm, edit, detail },
provide() {
return {
urls: this.allUrls,
};
},
data() { data() {
const { tableConfig, headFormConfigs, urls, dialogConfigs } = initConfig.call(this); const { tableConfig, headFormConfigs, urls, dialogConfigs } = initConfig.call(this);
return { return {
@ -55,7 +54,11 @@ export default {
page: 1, page: 1,
size: 20, size: 20,
totalPage: 0, totalPage: 0,
urls,
tableLoading: false, tableLoading: false,
refreshLayoutKey: null,
editVisible: false,
detailVisible: false,
}; };
}, },
created() {}, created() {},
@ -63,8 +66,11 @@ export default {
// size // size
const size = "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20; const size = "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20;
this.size = size; this.size = size;
this.getList();
this.initDataWhenLoad && this.getList(); // this.initDataWhenLoad && this.getList();
},
activated() {
this.refreshLayoutKey = this.layoutTable();
}, },
methods: { methods: {
/** 获取 列表数据 */ /** 获取 列表数据 */
@ -76,58 +82,20 @@ export default {
: { : {
page: this.page, page: this.page,
limit: this.size, limit: this.size,
key: "",
tech: "",
}; };
if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { this.$http
this.listQueryExtra.map((nameOrObj) => { .get(this.urls.page, {
if (typeof nameOrObj === "string") params[nameOrObj] = ""; params,
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,
}
)
.then(({ data: res }) => { .then(({ data: res }) => {
console.log("[http response] res is: ", res); console.log("[http response] res is: ", res);
if (res.code === 0) { if (res.code === 0) {
// page :
if ("list" in res.data) { if ("list" in res.data) {
// if (res.data.list.length == 0 && res.data.total != 0) { this.dataList = res.data.list;
// // 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.totalPage = res.data.total; this.totalPage = res.data.total;
} else if (Array.isArray(res.data)) { } else if (Array.isArray(res.data)) {
this.dataList = res.data; this.dataList = res.data;
@ -152,7 +120,6 @@ export default {
}); });
this.tableLoading = false; this.tableLoading = false;
}); });
// }
}, },
layoutTable() { layoutTable() {
@ -162,18 +129,27 @@ export default {
handleBtnClick({ btnName, payload }) { handleBtnClick({ btnName, payload }) {
console.log("[search] form handleBtnClick", btnName, payload); console.log("[search] form handleBtnClick", btnName, payload);
switch (btnName) { switch (btnName) {
case "新增": case "查询":
this.openDialog(); this.getList({ ...payload });
break; break;
case "导入":
this.openUploadDialog();
break;
case "手动添加": {
this.openDialog();
return;
}
} }
}, },
handleDestroy(type, refresh) {
console.log("[handleDestroy] ", type);
switch (type) {
case "edit":
this.editVisible = false;
if (refresh) {
this.getList();
}
break;
case "detail":
this.detailVisible = false;
break;
}
},
handleOperate({ type, data }) { handleOperate({ type, data }) {
console.log("payload", type, data); console.log("payload", type, data);
switch (type) { switch (type) {
@ -222,11 +198,27 @@ export default {
} }
case "edit": { case "edit": {
console.log("[edit] ", data); 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; break;
} }
} }
}, },
handleSizeChange(val) { handleSizeChange(val) {
// val // val
this.page = 1; this.page = 1;