|
@@ -67,23 +67,20 @@
|
|
|
<script>
|
|
<script>
|
|
|
import { listAllWorkshop } from "@/api/mes/md/workshop";
|
|
import { listAllWorkshop } from "@/api/mes/md/workshop";
|
|
|
import { getIsWorkareaList } from "@/api/mes/wa/workarea";
|
|
import { getIsWorkareaList } from "@/api/mes/wa/workarea";
|
|
|
-import {selectIsSopById} from "@/api/mes/sop/sopindex"
|
|
|
|
|
-import { mapActions, mapGetters } from 'vuex';
|
|
|
|
|
|
|
+import { selectIsSopById } from "@/api/mes/sop/sopindex";
|
|
|
|
|
+import { mapActions, mapGetters } from "vuex";
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
props: {
|
|
props: {
|
|
|
sopProps: {
|
|
sopProps: {
|
|
|
- type: Object,
|
|
|
|
|
- default: function () {
|
|
|
|
|
- return {};
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ type: Array,
|
|
|
|
|
+ default: () => [],
|
|
|
|
|
+ },
|
|
|
|
|
+ jobProps: {
|
|
|
|
|
+ type: Array,
|
|
|
|
|
+ default: () => [],
|
|
|
},
|
|
},
|
|
|
- jobProps:{
|
|
|
|
|
- type:Array,
|
|
|
|
|
- default:()=>[]
|
|
|
|
|
- }
|
|
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
form: {
|
|
form: {
|
|
@@ -104,48 +101,56 @@ export default {
|
|
|
watch: {
|
|
watch: {
|
|
|
// 监听父组件传递的数据
|
|
// 监听父组件传递的数据
|
|
|
sopProps: {
|
|
sopProps: {
|
|
|
- handler(newValue) {
|
|
|
|
|
- this.form.workShop = newValue.workshopId;
|
|
|
|
|
- this.form.producLine = newValue.workareaId;
|
|
|
|
|
|
|
+ handler(newVal, oldVal) {
|
|
|
|
|
+ console.log("sopProps 发生变化", newVal);
|
|
|
|
|
+ this.form.workShop = newVal[0].workshopId;
|
|
|
|
|
+ this.form.producLine = newVal[0].workareaId;
|
|
|
|
|
+ // 确保 handleselect 完成后再调用 handleselectProductLine
|
|
|
|
|
+ this.handleselect(newVal[0].workshopId)
|
|
|
|
|
+ .then(() => {
|
|
|
|
|
+ this.handleselectProductLine(newVal[0].workareaId);
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error) => {
|
|
|
|
|
+ console.error("处理车间下拉失败", error);
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
|
|
+ immediate: true, // 立即执行一次,确保在组件初始化时也能捕获到 jobProps 的值
|
|
|
},
|
|
},
|
|
|
jobProps: {
|
|
jobProps: {
|
|
|
handler(newVal, oldVal) {
|
|
handler(newVal, oldVal) {
|
|
|
- console.log('jobProps 发生变化', newVal, oldVal);
|
|
|
|
|
|
|
+ console.log("jobProps 发生变化", newVal, oldVal);
|
|
|
// 在这里处理 jobProps 变化后的逻辑
|
|
// 在这里处理 jobProps 变化后的逻辑
|
|
|
- this.form.workShop=newVal[0].workshopId
|
|
|
|
|
- this.form.producLine=newVal[0].workareaId
|
|
|
|
|
- // this.handleselect(newVal[0].workshopId)
|
|
|
|
|
- // this.handleselectProductLine(newVal[0].workareaId)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ this.form.workShop = newVal[0].workshopId;
|
|
|
|
|
+ this.form.producLine = newVal[0].workareaId;
|
|
|
// 确保 handleselect 完成后再调用 handleselectProductLine
|
|
// 确保 handleselect 完成后再调用 handleselectProductLine
|
|
|
- this.handleselect(newVal[0].workshopId).then(() => {
|
|
|
|
|
- this.handleselectProductLine(newVal[0].workareaId);
|
|
|
|
|
- }).catch((error) => {
|
|
|
|
|
- console.error('处理车间下拉失败', error);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.handleselect(newVal[0].workshopId)
|
|
|
|
|
+ .then(() => {
|
|
|
|
|
+ this.handleselectProductLine(newVal[0].workareaId);
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error) => {
|
|
|
|
|
+ console.error("处理车间下拉失败", error);
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- // 这里是为了拿到sop模板里默认的隔离点选中的数据
|
|
|
|
|
- selectIsSopById(newVal[0].sopId).then(res => {
|
|
|
|
|
- console.log(res,'sop')
|
|
|
|
|
- const selectSopPoints=res.data.pointDetailVOList.map((item)=>{
|
|
|
|
|
- return item.pointId
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // 这里是为了拿到sop模板里默认的隔离点选中的数据
|
|
|
|
|
+ selectIsSopById(newVal[0].sopId).then((res) => {
|
|
|
|
|
+ console.log(res, "sop");
|
|
|
|
|
+ const selectSopPoints = res.data.pointDetailVOList.map((item) => {
|
|
|
|
|
+ return item.pointId;
|
|
|
|
|
+ });
|
|
|
// 调用 Vuex action 来存储 selectSopPoints
|
|
// 调用 Vuex action 来存储 selectSopPoints
|
|
|
- this.setSelectSopPoints(selectSopPoints)
|
|
|
|
|
- console.log(selectSopPoints,'sop_selectePoints')
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ this.setSelectSopPoints(selectSopPoints);
|
|
|
|
|
+ console.log(selectSopPoints, "sop_selectePoints");
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
- immediate: true // 立即执行一次,确保在组件初始化时也能捕获到 jobProps 的值
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ immediate: true, // 立即执行一次,确保在组件初始化时也能捕获到 jobProps 的值
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
this.getworkshopList();
|
|
this.getworkshopList();
|
|
|
-
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
- ...mapActions(['setSelectSopPoints']),//这里是为了调用 存储数据的方法
|
|
|
|
|
|
|
+ ...mapActions(["setSelectSopPoints"]), //这里是为了调用 存储数据的方法
|
|
|
// 获取车间列表
|
|
// 获取车间列表
|
|
|
getworkshopList() {
|
|
getworkshopList() {
|
|
|
listAllWorkshop().then((response) => {
|
|
listAllWorkshop().then((response) => {
|
|
@@ -159,26 +164,27 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 单选车间下拉
|
|
|
|
|
// 单选车间下拉
|
|
// 单选车间下拉
|
|
|
handleselect(value) {
|
|
handleselect(value) {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
- getIsWorkareaList(value).then((response) => {
|
|
|
|
|
- this.producLineOptions = response.data.map((item) => {
|
|
|
|
|
- return {
|
|
|
|
|
- label: item.workareaName,
|
|
|
|
|
- value: item.workareaId,
|
|
|
|
|
- key: item.workareaCode,
|
|
|
|
|
- map: item.map,
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ getIsWorkareaList(value)
|
|
|
|
|
+ .then((response) => {
|
|
|
|
|
+ this.producLineOptions = response.data.map((item) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ label: item.workareaName,
|
|
|
|
|
+ value: item.workareaId,
|
|
|
|
|
+ key: item.workareaCode,
|
|
|
|
|
+ map: item.map,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- console.log(this.producLineOptions, 'this.producLineOptions');
|
|
|
|
|
- resolve(); // 异步操作成功后 resolve
|
|
|
|
|
- }).catch((error) => {
|
|
|
|
|
- console.error('获取生产线下拉列表失败', error);
|
|
|
|
|
- reject(error); // 异步操作失败后 reject
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ console.log(this.producLineOptions, "this.producLineOptions");
|
|
|
|
|
+ resolve(); // 异步操作成功后 resolve
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error) => {
|
|
|
|
|
+ console.error("获取生产线下拉列表失败", error);
|
|
|
|
|
+ reject(error); // 异步操作失败后 reject
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
// 生产线下拉
|
|
// 生产线下拉
|
|
@@ -193,6 +199,7 @@ export default {
|
|
|
});
|
|
});
|
|
|
console.log(selectworkShop, selectedOption, "workshop-components");
|
|
console.log(selectworkShop, selectedOption, "workshop-components");
|
|
|
// 触发自定义事件,传递 selectedOption[0] 数据给父组件
|
|
// 触发自定义事件,传递 selectedOption[0] 数据给父组件
|
|
|
|
|
+ console.log(selectedOption, "selectedOption[0]", this.producLineOptions);
|
|
|
this.$emit("product-line-selected", selectedOption[0]);
|
|
this.$emit("product-line-selected", selectedOption[0]);
|
|
|
this.$emit("work-shop-selected", selectworkShop[0]);
|
|
this.$emit("work-shop-selected", selectworkShop[0]);
|
|
|
},
|
|
},
|