update 更新除涉及dialog之外的所有操作

This commit is contained in:
lb
2023-03-09 15:07:55 +08:00
parent faa1daa343
commit 79ed2d4f6a
6 changed files with 160 additions and 39 deletions

View File

@@ -5,6 +5,7 @@
@close="handleClose"
:destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? true"
:fullscreen="fullscreen"
>
<!-- title -->
<div slot="title" class="dialog-title">
@@ -105,6 +106,10 @@ export default {
type: Boolean,
default: false,
},
fullscreen: {
type: Boolean,
default: false
}
},
inject: ["urls"],
data() {

View File

@@ -26,23 +26,21 @@
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
<DialogJustForm ref="order-dialog" v-if="dialogVisible" />
</section>
</template>
<script>
import BaseListTable from "./BaseListTable.vue";
import BaseSearchForm from "./BaseSearchForm.vue";
import DialogWithMenu from "@/components/DialogWithMenu.vue";
import DialogJustForm from "./DialogJustForm.vue";
import moment from "moment";
const DIALOG_WITH_MENU = "DialogWithMenu";
const DIALOG_JUST_FORM = "DialogJustForm";
const dictList = JSON.parse(localStorage.getItem("dictList"));
export default {
name: "ListSectionWithHead",
components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm },
components: { BaseSearchForm, BaseListTable, DialogJustForm },
props: {
headConfig: {
type: Object,
@@ -71,18 +69,25 @@ export default {
type: Object,
default: () => ({}),
},
refreshKey: {
type: String,
required: true,
},
},
computed: {
dialogType() {
return this.dialogConfigs.menu ? DIALOG_WITH_MENU : DIALOG_JUST_FORM;
},
},
watch: {
refreshKey(newVal) {
// 外部触发更新列表
this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params));
},
},
data() {
return {
refreshLayoutKey: null,
DIALOG_WITH_MENU,
DIALOG_JUST_FORM,
dialogVisible: false,
tableLoading: false,
params: {}, // 由 search form 生成的查询条件
@@ -90,21 +95,6 @@ export default {
limit: 20,
page: 1,
},
conditions: {
ongoing: {
limit: 20,
code: "",
page: 1,
},
pending: {
limit: 20,
page: 1,
},
finished: {
limit: 20,
page: 1,
},
},
dataList: [],
totalPage: 0,
};
@@ -155,9 +145,113 @@ export default {
// 编辑、删除、跳转路由、打开弹窗动态component都可以在配置里加上 url
// payload: { type: string, data: string | number | object }
switch (type) {
// 确认订单
case "confirm-order": {
this.$http
.post("/pms/order/confirm", data, {
headers: {
"Content-Type": "application/json",
},
})
.then(({ data: res }) => {
if (res.code === 0) {
// success
this.$message({
message: "已确认!",
type: "success",
duration: 2000,
onClose: () => {
this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params));
this.$emit("refresh-tables", ["ongoing"]);
},
});
} else {
// failed
throw new Error(res.msg);
}
})
.catch((errMsg) => {
this.$message({
message: errMsg,
type: "error",
duration: 2000,
});
});
break;
}
// 废除订单
case "destroy-order":
// 结束订单
case "end-order": {
this.$http
.post("/pms/order/end", data, {
headers: {
"Content-Type": "application/json",
},
})
.then(({ data: res }) => {
if (res.code === 0) {
// success
this.$message({
message: "已结束订单!",
type: "success",
duration: 2000,
onClose: () => {
this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params));
this.$emit("refresh-tables", ["finished"]);
},
});
} else {
// failed
throw new Error(res.msg);
}
})
.catch((errMsg) => {
this.$message({
message: errMsg,
type: "error",
duration: 2000,
});
});
break;
}
// 上移
case "move-up":
// 下移
case "move-down":
// 移至顶部
case "move-to-top":
// 移至底部
case "move-to-bottom": {
const locationMap = {
"move-up": 1,
"move-down": 2,
"move-to-bottom": 3,
"move-to-top": 0,
};
return this.$http
.get("/pms/order/change", { params: { id: data, location: locationMap[type] } })
.then(({ data: res }) => {
if (res.code === 0) {
// success
this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params));
} else {
// failed
throw new Error(res.msg);
}
})
.catch((errMsg) => {
this.$message({
message: errMsg,
type: "error",
duration: 2000,
});
});
}
case "delete": {
// 确认是否删除
return this.$confirm(`确定要删除 "${data.name}" 吗?`, "提示", {
return this.$confirm(`确定要删除 "${data.code ?? data.id}" 吗?`, "提示", {
confirmButtonText: "确认",
cancelButtonText: "我再想想",
type: "warning",
@@ -165,7 +259,7 @@ export default {
.then(() => {
// this.$http.delete(this.urls.base + `/${data}`).then((res) => {
this.$http({
url: this.urls.base,
url: '/pms/order',
method: "DELETE",
data: [`${data.id}`],
}).then(({ data: res }) => {
@@ -232,7 +326,7 @@ export default {
this.dialogVisible = true;
this.$nextTick(() => {
// this.$refs["edit-dialog"].init(/** some args... */ row_id, detail_mode);
this.$refs["order-dialog"].init(/** some args... */ row_id, detail_mode);
});
},
},