浏览代码

update bomTech edit

docs_0727
lb 1年前
父节点
当前提交
5f1acde7c0
共有 4 个文件被更改,包括 218 次插入76 次删除
  1. +1
    -1
      src/components/BaseListTable.vue
  2. +160
    -10
      src/views/modules/pms/bomTechAndFiring/components/edit.vue
  3. +1
    -1
      src/views/modules/pms/bomTechAndFiring/config.js
  4. +56
    -64
      src/views/modules/pms/bomTechAndFiring/index.vue

+ 1
- 1
src/components/BaseListTable.vue 查看文件

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


+ 160
- 10
src/views/modules/pms/bomTechAndFiring/components/edit.vue 查看文件

@@ -5,21 +5,171 @@
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>
import { ref } from "vue";

export default {
name: "BomTechAndFiringEdit",
components: {},
props: {},
data() {
return {}
name: "BomTechAndFiringEdit",
components: {},
props: {},
data() {
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>

<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>

+ 1
- 1
src/views/modules/pms/bomTechAndFiring/config.js 查看文件

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


+ 56
- 64
src/views/modules/pms/bomTechAndFiring/index.vue 查看文件

@@ -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;


正在加载...
取消
保存