import { edit, add, detail } from "@/api/wms/inter-order"; import { saveWmsMessages } from "@/api/wms/message"; submitForm() { this.goodsType = this.$refs.goodsType.item; this.form.goodOrderItems = this.goodsType.goodList; console.log(this.form.goodOrderItems); this.loadingbut = true; this.$refs.form.validate((valid) => { if (valid) { add(this.form).then(res => { this.$message.success("保存成功!"); this.loadingbut = false; this.back(); }); } } 执行完add后,在执行一下saveWmsMessages,我该怎么改
时间: 2024-02-14 11:12:01 浏览: 48
您可以在 add 方法的回调函数中加入 saveWmsMessages 的调用,代码如下:
```
add(this.form).then(res => {
this.$message.success("保存成功!");
this.loadingbut = false;
this.back();
saveWmsMessages().then(res => {
// 执行成功的操作
}).catch(err => {
// 执行失败的操作
});
});
```
这样当 add 方法执行成功后,会立即执行 saveWmsMessages 方法。请注意,在 saveWmsMessages 方法中,您需要根据具体情况来处理执行成功和失败后的操作。
相关问题
This dependency was not found: * @/api/wms/category in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/system/category/index.vue?vue&type=script&lang=js& To install it, you can run: npm install --save @/api/wms/category This dependency was not found: * @/api/wms/category in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/system/category/index.vue?vue&type=script&lang=js& To install it, you can run: npm install --save @/api/wms/category
This error message indicates that the dependency "@/api/wms/category" could not be found. It seems that you need to install this dependency in order to resolve the issue.
To install the missing dependency, you can run the following command in your terminal:
```
npm install --save @/api/wms/category
```
This command will install the "@/api/wms/category" package and save it as a dependency in your project's package.json file. Once the installation is complete, you should be able to resolve the dependency and resolve the error.
这是api: export const latest = data => { return axios.post("/wms/inter/order/latestInterOrder", data); }; 这是前端代码: <el-dialog :visible.sync="showInterOrderDialog"></el-dialog> 这是前端script: import { latest } from "@/api/wms/inter-order"; data() { return { }; }, mounted() { this.showInterOrderDialog = false; latest().then(response => { const interOrder = response.data; this.lastInterOrderId = interOrder.id; }).catch(error => { console.error("报错信息:", error); }); this.pollLatestInterOrder(); }, methods: { newMessage() { this.$message({ showClose: true, message: "有新货物入库!" }); }, async pollLatestInterOrder() { }, }, 登录之后,怎么将前端的userId传递给后端接口
可以在调用 latest 接口的时候,将 userId 作为参数传递给后端接口。修改 latest 函数如下:
```
export const latest = (userId, data) => {
return axios.post(`/wms/inter/order/latestInterOrder?userId=${userId}`, data);
};
```
然后在 mounted 方法中调用 latest 函数时,将 userId 传递给它:
```
mounted() {
this.showInterOrderDialog = false;
const userId = this.$store.state.user.id;
latest(userId).then(response => {
const interOrder = response.data;
this.lastInterOrderId = interOrder.id;
}).catch(error => {
console.error("报错信息:", error);
});
this.pollLatestInterOrder();
},
```
这样后端接口就可以拿到前端传递过来的 userId 参数了。
阅读全文