|
@@ -270,41 +270,46 @@ export default {
|
|
|
cancelButtonText: "取消",
|
|
|
type: "warning",
|
|
|
})
|
|
|
- .then(() => {
|
|
|
- // 删除操作
|
|
|
- if (id) {
|
|
|
- this.selectionDataList.push(id);
|
|
|
- }
|
|
|
- if (this.selectionDataList.length <= 0) {
|
|
|
- return;
|
|
|
+ .then(() => {
|
|
|
+ // 删除操作
|
|
|
+ if (id) {
|
|
|
+ this.selectionDataList.push(id);
|
|
|
+ }
|
|
|
+ if (this.selectionDataList.length <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl("/management/pigsty/delete"),
|
|
|
+ method: "post",
|
|
|
+ data: this.$http.adornData(this.selectionDataList, false),
|
|
|
+ }).then((result) => {
|
|
|
+ console.log(result);
|
|
|
+ if (result.data.code === 0) {
|
|
|
+ this.$message({
|
|
|
+ message: "成功删除猪舍",
|
|
|
+ type: "success",
|
|
|
+ duration: 1000,
|
|
|
+ })
|
|
|
+ // pageIndex修正
|
|
|
+ this.totalPage -= this.selectionDataList.length
|
|
|
+ let pages = Math.ceil(this.totalPage / this.pageSize)
|
|
|
+ this.pageIndex = this.pageIndex > pages? pages: this.pageIndex
|
|
|
+ this.pageIndex = this.pageIndex < 1? pages: this.pageIndex
|
|
|
+ } else {
|
|
|
+ // this.$message.error('删除失败:' + result.data.msg)
|
|
|
+ this.$confirm(result.data.msg, '删除失败', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ console.log('猪舍编号输入不合法')
|
|
|
+ }).catch(() => {})
|
|
|
}
|
|
|
- this.$http({
|
|
|
- url: this.$http.adornUrl("/management/pigsty/delete"),
|
|
|
- method: "post",
|
|
|
- data: this.$http.adornData(this.selectionDataList, false),
|
|
|
- }).then((result) => {
|
|
|
- console.log(result);
|
|
|
- if (result.data.code === 0) {
|
|
|
- this.$message({
|
|
|
- message: "成功删除猪舍",
|
|
|
- type: "success",
|
|
|
- duration: 1000,
|
|
|
- });
|
|
|
- } else {
|
|
|
- // this.$message.error('删除失败:' + result.data.msg)
|
|
|
- this.$confirm(result.data.msg, '删除失败', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- console.log('猪舍编号输入不合法')
|
|
|
- }).catch(() => {})
|
|
|
- }
|
|
|
- this.resetForm();
|
|
|
- this.selectionDataList = [];
|
|
|
- });
|
|
|
- })
|
|
|
- .catch(() => {});
|
|
|
+ this.resetForm();
|
|
|
+ this.selectionDataList = [];
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
},
|
|
|
formSubmit() {
|
|
|
if (this.form.id) {
|
|
@@ -337,6 +342,23 @@ export default {
|
|
|
duration: 1000,
|
|
|
})
|
|
|
} else {
|
|
|
+ if (result.data.code === 600) {
|
|
|
+ let msg = result.data.msg.split('-')
|
|
|
+ let pasture = ''
|
|
|
+ for (let item of this.pastureList) {
|
|
|
+ if (this.form.pastureId === item.id) {
|
|
|
+ pasture = item.name
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$message({
|
|
|
+ message: `${pasture}中猪舍编号 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
|
|
|
+ type: "error",
|
|
|
+ duration: 1000,
|
|
|
+ dangerouslyUseHTMLString: true
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
this.$message.error("修改猪舍信息失败");
|
|
|
}
|
|
|
})
|
|
@@ -369,6 +391,23 @@ export default {
|
|
|
duration: 1000,
|
|
|
});
|
|
|
} else {
|
|
|
+ if (result.data.code === 600) {
|
|
|
+ let msg = result.data.msg.split('-')
|
|
|
+ let pasture = ''
|
|
|
+ for (let item of this.pastureList) {
|
|
|
+ if (this.form.pastureId === item.id) {
|
|
|
+ pasture = item.name
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$message({
|
|
|
+ message: `${pasture}中猪舍编号 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
|
|
|
+ type: "error",
|
|
|
+ duration: 1000,
|
|
|
+ dangerouslyUseHTMLString: true
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
this.$message.error("添加猪舍失败");
|
|
|
}
|
|
|
})
|