update 完成订单

This commit is contained in:
lb 2023-04-10 14:52:00 +08:00
parent 9ce0241a4c
commit 0caaab8df3
8 changed files with 1412 additions and 36 deletions

View File

@ -0,0 +1,155 @@
<template>
<el-dialog
class="dialog-with-menu"
style="padding: 40px"
:fullscreen="fullscreen"
:visible="visible"
@close="handleClose"
:destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? true"
>
<!-- <el-button type="text" icon="el-icon-close" style="position: absolute; z-index: 100; top: 0; right: 18px" @click="handleClose">关闭</el-button> -->
<el-tabs v-model="activeTab" type="card" @tab-click="handleTabClick">
<el-tab-pane name="sub" label="子订单进度">
<SubOrderDetail v-if="order !== null" :order="order" />
</el-tab-pane>
<el-tab-pane name="car" label="窑车详情">
<CarDetail v-if="order !== null" :order-id="order.id" />
</el-tab-pane>
<el-tab-pane name="tray" label="托盘详情">
<TrayDetail />
</el-tab-pane>
<el-tab-pane name="order" label="订单详情">
<OrderDetail ref="order-detail-tag" :configs="configs" />
</el-tab-pane>
</el-tabs>
<!--
<div style="width: 100%; height: 76px; position: absolute; z-index: 100; bottom: 0; text-align: right;">
<el-button type="" plain @click="handleClose" style="margin-right: 18px; margin-top: 18px;">关闭</el-button>
</div> -->
<!-- footer -->
<div slot="footer" style="">
<!-- <template v-for="(operate, index) in configs.form.operations">
<el-button v-if="showButton(operate)" :key="'operation_' + index" :type="operate.type" @click="handleBtnClick(operate)">{{
operate.label
}}</el-button>
</template> -->
<el-button @click="handleClose">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import CarDetail from "./tabs/carDetail.vue";
import OrderDetail from "./tabs/orderDetail.vue";
import SubOrderDetail from "./tabs/subOrderDetail.vue";
import TrayDetail from "./tabs/trayDetail.vue";
export default {
name: "DialogWithMenu--OrderVersion",
components: { CarDetail, OrderDetail, SubOrderDetail, TrayDetail },
props: {
configs: {
type: Object,
default: () => null,
},
fullscreen: {
type: Boolean,
default: false,
},
},
inject: ["urls"],
data() {
return {
detailMode: false,
visible: false,
activeTab: "sub",
order: null,
carLayoutKey: 0,
};
},
methods: {
handleTabClick(tab, event) {
console.log("handle tab click", tab, event);
switch (tab.label) {
case "子订单进度":
break;
case "窑车详情":
this.carLayoutKey = Math.random();
break;
case "托盘详情":
break;
case "订单详情":
break;
}
},
/** init **/
init(order, detailMode) {
console.log("init menu dialog,", order);
this.order = order;
this.detailMode = detailMode ?? false;
this.visible = true;
this.$nextTick(() => {
this.$refs["order-detail-tag"].init(this.order.id, this.detailMode);
});
},
handleClose() {
this.visible = false;
setTimeout(() => {
this.$emit("destroy-dialog");
// this.resetForm();
// this.$emit("update:dialogVisible", false);
}, 200);
},
},
};
</script>
<style scoped>
.dialog-with-menu >>> .el-dialog__body {
padding-top: 40px !important;
padding-bottom: 40px !important;
/* padding-top: 0 !important;
padding-bottom: 0 !important;
padding-left: 0 !important;
padding-right: 0 !important;
height: 100%; */
}
.el-select,
.el-cascader,
.el-date-editor {
width: 100% !important;
}
.dialog-with-menu >>> .el-dialog__header {
padding: 0;
/* background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), white); */
}
.dialog-with-menu >>> .el-dialog__body {
height: calc(100% - 72px);
}
.dialog-with-menu >>> .el-tabs__content {
height: calc(100% - 32px);
overflow-y: auto;
padding-right: 12px;
}
.dialog-with-menu >>> .el-tabs {
height: 100%;
}
.h0 {
height: 0;
width: 0;
}
</style>

View File

@ -0,0 +1,338 @@
<!-- 表格页加上搜索条件 -->
<template>
<div class="list-view-with-head">
<!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> -->
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
<BaseListTable v-loading="tableLoading" :table-config="tableConfig.table" :column-config="tableConfig.column"
:table-data="dataList" @operate-event="handleOperate" :current-page="page" :current-size="size"
:refresh-layout-key="refreshLayoutKey" />
<el-pagination class="mt-5 flex justify-end" @size-change="handleSizeChange" @current-change="handlePageChange"
:current-page.sync="page" :page-sizes="[1, 5, 10, 20, 50, 100]" :page-size="size" :total="totalPage"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<DialogWithMenu ref="edit-dialog" v-if="!!dialogConfigs && dialogType === DIALOG_WITH_MENU"
:dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" />
</div>
</template>
<script>
import BaseListTable from "@/components/BaseListTable.vue";
import BaseSearchForm from "@/components/BaseSearchForm.vue";
import DialogWithMenu from "../../order/components/DialogWithMenu.vue";
import moment from "moment";
const DIALOG_WITH_MENU = "DialogWithMenu";
const DIALOG_JUST_FORM = "DialogJustForm";
const DIALOG_CARPAYLOAD = "DialogCarPayload";
export default {
name: "ListViewWithHead",
components: { BaseSearchForm, BaseListTable, DialogWithMenu },
props: {
tableConfig: {
type: Object,
default: () => ({
/** 列配置, 即 props **/ column: [],
/** 表格整体配置 */ table: undefined,
}),
},
headConfig: {
type: Object,
default: () => ({}),
},
/** 请求page接口的时候有些字段是必填的没有会报500把相关字段名传入这个prop: */
listQueryExtra: {
type: Array,
default: () => ["key"],
},
attachListQueryExtra: {
// listQueryExtra
type: String,
default: "",
},
initDataWhenLoad: { type: Boolean, default: true },
/** dialog configs 或许可以从 tableConfig 计算出来 computed... */
dialogConfigs: {
type: Object,
default: () => null,
},
carPayloadDialogConfigs: {
type: Object,
default: () => null,
},
triggerUpdate: {
type: String,
default: "",
},
},
computed: {
dialogType() {
return this.dialogConfigs.menu ? DIALOG_WITH_MENU : DIALOG_JUST_FORM;
},
},
activated() {
this.refreshLayoutKey = this.layoutTable();
},
watch: {
triggerUpdate(val, oldVal) {
if (val && val !== oldVal) {
// get list
this.page = 1;
this.size = 20;
this.getList();
}
},
},
data() {
return {
DIALOG_WITH_MENU,
DIALOG_JUST_FORM,
DIALOG_CARPAYLOAD,
dialogVisible: false,
carPayloadDialogVisible: false,
topBtnConfig: null,
totalPage: 100,
page: 1,
size: 20, // 20
dataList: [],
tableLoading: false,
refreshLayoutKey: null,
};
},
inject: ["urls"],
mounted() {
this.initDataWhenLoad && this.getList();
},
methods: {
/** 获取 列表数据 */
getList(queryParams) {
this.tableLoading = true;
const params = queryParams
? { ...queryParams, page: this.page, limit: this.size }
: {
page: this.page,
limit: this.size,
};
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.$http[this.urls.pageIsPostApi ? "post" : "get"](
this.urls.page,
this.urls.pageIsPostApi
? {
...params,
}
: {
params,
}
)
.then(({ data: res }) => {
if (res.code === 0) {
if ("list" in res.data) {
/** 破碎记录的特殊需求:数据要结合单位 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.totalPage = res.data.total;
} else {
this.dataList.splice(0);
this.totalPage = 0;
}
} else {
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 2000,
});
}
this.tableLoading = false;
})
.catch((err) => {
this.$message({
message: `${err}`,
type: "error",
duration: 2000,
});
this.tableLoading = false;
});
// }
},
layoutTable() {
return Math.random();
},
/** 处理 表格操作 */
handleOperate({ type, data }) {
switch (type) {
case "delete": {
// prompt
const deleteConfig = data.head?.options?.find((item) => item.name === "delete");
let promptName = data.name ?? data.id;
if (deleteConfig && "promptField" in deleteConfig) {
promptName = data[deleteConfig.promptField];
}
//
return this.$confirm(`确定要删除记录 "${promptName}" 吗?`, "提示", {
confirmButtonText: "确认",
cancelButtonText: "我再想想",
type: "warning",
})
.then(() => {
this.$http({
url: this.urls.base,
method: "DELETE",
data: [`${data.id}`],
}).then(({ data: res }) => {
if (res.code === 0) {
this.$message.success("删除成功!");
this.page = 1;
this.size = 10;
this.getList();
} else {
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 1500,
});
}
});
})
.catch((err) => { });
}
case "edit": {
this.openDialog(data); /** data is ==> id */
break;
}
case "view":
case "view-endorder":
case "view-ongoing": {
this.openDialog(data, true);
break;
}
}
},
handleBtnClick({ btnName, payload }) {
console.log("[search] form handleBtnClick", btnName, payload);
switch (btnName) {
case "新增":
this.openDialog();
break;
case "手动添加": {
this.openDialog();
return;
}
case "查询": {
const params = {};
if (typeof payload === "object") {
// BaseSearchForm
Object.assign(params, payload);
if ("timerange" in params) {
if (!!params.timerange) {
const [startTime, endTime] = params["timerange"];
params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
}
delete params.timerange;
}
}
/** 处理 listQueryExtra 里的数据 */
this.listQueryExtra?.map((cond) => {
if (typeof cond === "string") {
if (!!payload[cond]) {
params[cond] = payload[cond];
} else {
params[cond] = "";
}
} else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => {
params[key] = cond[key];
});
}
});
console.log("查询", params);
this.getList(params);
break;
}
case "同步":
case "全部同步":
this.$http.post(this.urls.syncUrl).then(({ data: res }) => {
console.log('全部同步', res)
if (res.code === 0) {
this.$message({ message: '同步成功', type: 'success' })
this.getList();
}
});
break;
}
},
/** 导航器的操作 */
handleSizeChange(val) {
// val
this.page = 1;
this.size = val;
this.getList();
},
handlePageChange(val) {
// val
this.getList();
},
/** 打开对话框 */
openDialog(row_id, detail_mode, tag_info) {
this.dialogVisible = true;
let extraParams = null;
if (this.attachListQueryExtra && this.listQueryExtra.length) {
this.listQueryExtra.forEach((item) => {
let found = item[this.attachListQueryExtra];
if (found !== null && found !== undefined) extraParams = item;
});
}
this.$nextTick(() => {
console.log(`[edit-dialog] extraParams: ${extraParams}`);
this.$refs["edit-dialog"].init(/** some args... */ row_id, detail_mode, tag_info, extraParams);
});
},
},
};
</script>
<style scoped>
.list-view-with-head {
background: white;
/* height: 100%; */
min-height: inherit;
border-radius: 6px;
padding: 16px;
box-shadow: 0 0 1.125px 0.125px rgba(0, 0, 0, 0.125);
}
</style>

View File

@ -0,0 +1,124 @@
<template>
<div class="table-pagi" style="">
<BaseListTable
:key="Math.random()"
v-loading="tableLoading"
:table-config="tableConfig.table"
:column-config="tableConfig.column"
:table-data="dataList"
@operate-event="handleOperate"
:refresh-layout-key="refreshLayoutKey"
/>
<el-pagination
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="listQuery.page"
:page-sizes="[1, 5, 10, 20]"
:page-size="listQuery.limit"
:total="totalPage"
layout="total, prev, pager, next, jumper"
></el-pagination>
</div>
</template>
<script>
import BaseListTable from "@/components/BaseListTable.vue";
export default {
name: "TablePaginationComp",
components: { BaseListTable },
props: {
tableConfig: {
type: Object,
default: () => null,
},
extraQueryFields: {
type: Object,
default: () => null,
},
urls: {
type: Object,
default: () => ({
page: "",
base: "",
}),
},
pageIsPost: {
type: Boolean,
default: false,
},
},
data() {
return {
tableLoading: false,
dataList: [],
listQuery: {
limit: 20,
page: 1,
},
totalPage: 0,
refreshLayoutKey: 0,
};
},
mounted() {
this.getAList();
},
methods: {
handleOperate({ type, data }) {
console.log("payload", type, data);
},
handleSizeChange(newSize) {
this.listQuery.page = 1;
this.listQuery.limit = newSize;
// this.getAList(Object.assign({}, this.listQuery, this.extraQueryFields));
this.getAList();
},
handlePageChange(newPage) {
// this.getAList(Object.assign({}, this.listQuery, this.extraQueryFields));
this.getAList();
},
getAList(payload) {
this.tableLoading = true;
const data = payload ?? {
...this.listQuery,
...this.extraQueryFields,
};
console.log("getAlist", data, this.pageIsPost);
return this.$http({
url: this.urls.page ?? this.urls.base + "/page",
method: this.pageIsPost ? "POST" : "GET",
data: this.pageIsPost
? data
: {
params: data,
},
}).then(({ data: res }) => {
if (res.code === 0) {
if ("list" in res.data) {
this.dataList = res.data.list;
this.totalPage = res.data.total;
} else {
this.dataList.splice(0);
this.totalPage = 0;
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 1500,
});
}
}
this.tableLoading = false;
});
},
},
};
</script>
<style scoped></style>

View File

@ -0,0 +1,224 @@
<template>
<div class="car-detail">
<BaseListTable
key="car-history-list"
v-loading="tableLoading"
:table-config="null"
:column-config="tableConfig"
:table-data="dataList"
@operate-event="handleOperate"
:refresh-layout-key="refreshLayoutKey"
/>
<el-pagination
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="listQuery.page"
:page-sizes="[1, 5, 10, 20]"
:page-size="listQuery.limit"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
<!-- <DialogCarPayload
ref="car-payload-dialog"
v-if="!!carPayloadDialogConfigs"
:dialog-visible.sync="carPayloadDialogVisible"
:configs="carPayloadDialogConfigs"
/> -->
<!-- @refreshDataList="getList" -->
</div>
</template>
<script>
import BaseListTable from "@/components/BaseListTable.vue";
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
// import StateSelect from '@/components/StateSelect.vue';
import { timeFilter } from "@/utils/filters";
import DialogCarPayload from "@/components/DialogCarPayload.vue";
export default {
name: "CarDetailTag",
components: { BaseListTable, DialogCarPayload },
props: {
orderId: {
type: String,
default: null,
},
},
data() {
return {
dataList: [],
tableConfig: [
{ type: "index", label: "序号" },
// { prop: "createTime", label: "", filter: timeFilter },
{ prop: "code", label: "窑车号" },
{ prop: "stateDictValue", label: "状态" }, // , subcomponent: StateSelect },
// { prop: "stateDictValue", label: "", filter: v => (v !== null && v !== undefined) ? ['', '', '', ''][v] : '-' }, // subcomponent
// { prop: "orderCode", label: "" },
{ prop: "posCode", label: "位置" },
{ prop: "startTime", label: "开始时间", filter: timeFilter },
{ prop: "endTime", label: "结束时间", filter: timeFilter },
// {
// prop: "operations",
// name: "",
// fixed: "right",
// width: 90,
// subcomponent: TableOperaionComponent,
// options: [
// { name: "to-car-payload", label: "", icon: "document" },
// { name: "delete", label: "", icon: "delete", emitFull: true, promptField: "code" },
// ],
// },
],
refreshLayoutKey: null,
tableLoading: false,
listQuery: {
limit: 20,
page: 1,
},
totalPage: 0,
carPayloadDialogVisible: false,
carPayloadDialogConfigs: {
dialogWidth: "70%",
carPayloadDialog: true,
clickModalToClose: true,
tableConfig: {
table: null,
column: [
//
{ width: 56, type: "index", label: "序号" },
{ prop: "orderCode", label: "订单号" },
{ width: 80, prop: "orderCate", label: "订单子号" },
{ prop: "bomCode", label: "配方" },
{ prop: "shapeCode", label: "砖型" },
{ width: 80, prop: "qty", label: "订单数量" },
{ width: 72, prop: "goodqty", label: "合格数" },
{ width: 72, prop: "badqty", label: "废砖数" },
],
},
},
};
},
watch: {
orderId: {
handler: function (val) {
if (val) {
console.log("get car list based on orderId: ", val);
this.getAList(val);
}
},
immediate: true,
},
},
methods: {
handleOperate({ type, data }) {
switch (type) {
case "delete": {
// prompt
const deleteConfig = data.head?.options?.find((item) => item.name === "delete");
let promptName = data.name ?? data.id;
if (deleteConfig && "promptField" in deleteConfig) {
promptName = data[deleteConfig.promptField];
}
//
return this.$confirm(`确定要删除记录 "${promptName}" 吗?`, "提示", {
confirmButtonText: "确认",
cancelButtonText: "我再想想",
type: "warning",
})
.then(() => {
// this.$http.delete(this.urls.base + `/${data}`).then((res) => {
this.$http({
url: this.urls.base,
method: "DELETE",
data: data.id,
// data: [`${data.id}`],
headers: {
"Content-Type": "application/json",
},
}).then(({ data: res }) => {
if (res.code === 0) {
this.$message.success("删除成功!");
this.page = 1;
this.size = 10;
this.getList();
} else {
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 1500,
});
}
});
})
.catch((err) => {});
}
case "to-car-history": {
return this.$router.push({
name: "pms-carHistory",
query: {
code: data.code,
},
});
}
case "to-car-payload": {
// open dialog instead of redirect to a new page
this.openCarPayloadDialog(data);
}
}
},
openCarPayloadDialog(id) {
this.carPayloadDialogVisible = true;
this.$nextTick(() => {
this.$refs["car-payload-dialog"].init(id);
});
},
getAList(orderId) {
console.log("geting car list, ", orderId);
if (!orderId) orderId = this.orderId;
this.tableLoading = true;
this.$http.post("/pms/carHandle/pageHis", { ...this.listQuery, orderId }).then(({ data: res }) => {
if (res.code === 0 && res.data) {
if ("list" in res.data) {
this.dataList = res.data.list;
this.totalPage = res.data.total;
} else console.log("没有res.data.list属性");
} else {
this.dataList.splice(0);
this.totalPage = 0;
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 1500,
});
}
this.refreshLayoutKey = this.layoutTable();
this.tableLoading = false;
});
},
layoutTable() {
return Math.random();
},
/** 导航器的操作 */
handleSizeChange(newSize) {
this.listQuery.page = 1;
this.listQuery.limit = newSize;
this.getAList();
},
handlePageChange(newPage) {
this.getAList();
},
},
};
</script>
<style scoped></style>

View File

@ -0,0 +1,335 @@
<template>
<div class="order-detail">
<el-form ref="dataForm" :model="dataForm" v-loading="loadingStatus" style="padding: 0 40px">
<el-row v-for="(row, rowIndex) in configs.form.rows" :key="'row_' + rowIndex" :gutter="20">
<el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length" :class="{ h0: col.hidden }">
<!-- 通过多个 col === null 可以控制更灵活的 span 大小 -->
<el-form-item v-if="col !== null" :label="col.label" :prop="col.prop" :rules="col.rules || null">
<el-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="detailMode" v-bind="col.elparams" />
<el-cascader
v-if="col.cascader"
v-model="dataForm[col.prop]"
:options="col.options"
:disabled="detailMode"
v-bind="col.elparams"
></el-cascader>
<el-select v-if="col.select" v-model="dataForm[col.prop]" clearable :disabled="detailMode" v-bind="col.elparams">
<el-option v-for="(opt, optIdx) in col.options" :key="'option_' + optIdx" :label="opt.label" :value="opt.value" />
</el-select>
<el-switch
v-if="col.switch"
v-model="dataForm[col.prop]"
:active-value="col.activeValue ?? 1"
:inactive-value="col.activeValue ?? 0"
@change="handleSwitchChange"
:disabled="detailMode"
/>
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" />
<el-date-picker v-if="col.datetime" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" />
<div class="" v-if="col.component" style="margin: 42px 0 0">
<!-- 下面这个 component 几乎是为 富文本 quill 定制的了... TODO后续可能会根据业务需求创建新的版本 -->
<component
:is="col.component"
:key="'component_' + col.prop"
@update:modelValue="handleComponentModelUpdate(col.prop, $event)"
:modelValue="dataForm[col.prop] ?? ''"
:mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'"
v-bind="col.bind"
/>
</div>
<!-- add more... -->
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
</template>
<script>
// import textOnlyComponent from "@/components/noTemplateComponents/textOnlyComponent.js";
import moment from "moment";
import { pick as __pick } from "@/utils/filters";
export default {
name: "OrderDetailTag",
props: {
configs: {
type: Object,
default: () => ({
clickModalToClose: true,
forms: null,
}),
},
},
inject: ["urls"],
data() {
const dataForm = {};
const watchList = [];
const cachedList = {};
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
dataForm[col.prop] = col.default ?? null;
if (col.fetchData)
col.fetchData().then(({ data: res }) => {
if (res.code === 0 && res.data.list) {
if ("injectTo" in col) {
//
cachedList[col.prop] = res.data.list;
}
this.$set(
col,
"options",
res.data.list.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} else {
col.options.splice(0);
}
});
else if (col.fetchTreeData) {
// parentId 0
col.fetchTreeData().then(({ data: res }) => {
// console.log("[DialogJustForm fetchTreeData -->]", res.data);
if (res.code === 0 && res.data) {
if ("list" in res.data) {
this.$set(col, "options", res.data.list);
} else if (Array.isArray(res.data)) {
this.$set(col, "options", res.data);
}
} else {
col.options.splice(0);
}
});
}
});
});
return {
loadingStatus: false,
detailMode: false,
dataForm,
watchList,
cachedList,
};
},
mounted() {
/** 处理 injectTo 选项 */
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
if ("injectTo" in col && Array.isArray(col.injectTo)) {
col.injectTo.map((item) => {
const unwatch = this.$watch(
() => this.dataForm[col.prop],
(newVal) => {
const chosenObject = this.cachedList[col.prop]?.find((i) => i.id === newVal);
if (chosenObject) {
this.$set(this.dataForm, item[0], chosenObject[item[1]]);
}
},
{
immediate: false,
}
);
this.watchList.push(unwatch);
});
}
});
});
},
methods: {
/** utitilities */
showButton(operate) {
const notDetailMode = !this.detailMode;
const showAlways = operate.showAlways ?? false;
const editMode = operate.showOnEdit && this.dataForm.id;
const addMode = !operate.showOnEdit && !this.dataForm.id;
const permission = operate.permission ? this.$hasPermission(operate.permission) : true;
return notDetailMode && (showAlways || ((editMode || addMode) && permission));
},
resetForm(excludeId = false, immediate = false) {
setTimeout(
() => {
Object.keys(this.dataForm).forEach((key) => {
if (excludeId && key === "id") return;
this.dataForm[key] = null;
});
this.$refs.dataForm.clearValidate();
this.$emit("dialog-closed"); //
this.watchList.map((unwatch) => unwatch());
this.cachedList = {};
},
immediate ? 0 : 200
);
},
handleComponentModelUpdate(propName, { subject, payload: { data } }) {
this.dataForm[propName] = JSON.stringify(data);
},
addOrUpdate(method = "POST") {
if ("parentId" in this.dataForm) {
// parentId cascader ["xxx"]xxx
const lastItem = this.dataForm.parentId.length - 1;
this.dataForm.parentId = this.dataForm.parentId[lastItem];
}
this.$refs.dataForm.validate((passed, result) => {
if (passed) {
this.loadingStatus = true;
let httpPayload = null;
/** 针对有文件上传选项的弹窗提供特殊的 payload */
if (this.dataForm.files) {
httpPayload = {
...this.dataForm,
fileIds: this.dataForm.files.map((file) => file.id),
};
} else {
httpPayload = this.dataForm;
}
/** 针对时间段设置 payload */
if ("startTime" in this.dataForm && "endTime" in this.dataForm) {
const { startTime, endTime } = this.dataForm;
httpPayload = {
...httpPayload,
startTime: startTime ? moment(startTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
endTime: endTime ? moment(endTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
};
}
// /** payload */
// if ("updateTime" in this.dataForm) {
// const { updateTime } = this.dataForm;
// httpPayload = {
// ...httpPayload,
// updateTime: updateTime ? moment(updateTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
// };
// }
/** 针对时间段设置 payload */
if ("deliveryTime" in this.dataForm) {
const { deliveryTime } = this.dataForm;
httpPayload = {
...httpPayload,
deliveryTime: deliveryTime ? moment(deliveryTime).format("YYYY-MM-DDTHH:mm:ss") : null,
};
}
/** 发送 */
return this.$http({
url: this.urls.base,
method,
data: httpPayload,
})
.then(({ data: res }) => {
// console.log("[add&update] res is: ", res);
this.loadingStatus = false;
if (res.code === 0) {
this.$message.success(method === "POST" ? "添加成功" : "更新成功");
this.$emit("refreshDataList");
if (method === "POST") this.handleClose();
} else {
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 2000,
});
}
})
.catch((errMsg) => {
this.$message.error("参数错误:" + errMsg);
if (this.loadingStatus) this.loadingStatus = false;
});
} else {
this.$message.error("请核查字段信息");
}
});
},
handleBtnClick(payload) {
if ("name" in payload) {
switch (payload.name) {
case "cancel":
this.handleClose();
break;
case "reset":
this.resetForm(true, true); // true means exclude id, immediate execution
break;
case "add":
case "update":
this.addOrUpdate(payload.name === "add" ? "POST" : "PUT");
break;
}
} else {
console.log("[x] 不是这么用的! 缺少name属性");
}
},
init(orderId, detailMode) {
if (this.$refs.dataForm) {
this.$refs.dataForm.clearValidate();
}
this.detailMode = detailMode ?? false;
this.$nextTick(() => {
this.dataForm.id = orderId || null;
if (this.dataForm.id) {
//
this.loadingStatus = true;
//
this.$http
.get(this.urls.base + `/${this.dataForm.id}`)
.then(({ data: res }) => {
if (res && res.code === 0) {
this.dataForm = __pick(res.data, Object.keys(this.dataForm));
/** 格式化文件上传列表 */
if (Array.isArray(this.dataForm.files)) {
this.dataForm.files = this.dataForm.files.map((file) => ({
id: file.id,
name: file.fileUrl.split("/").pop(),
typeCode: file.typeCode,
url: file.fileUrl,
}));
}
} else {
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 1500,
});
}
this.loadingStatus = false;
})
.catch((err) => {
this.loadingStatus = false;
this.$message({
message: `${err}`,
type: "error",
duration: 1500,
});
});
} else {
//
this.loadingStatus = false;
}
});
},
},
};
</script>
<style scoped>
.el-select,
.el-cascader,
.el-date-editor {
width: 100% !important;
}
</style>

View File

@ -0,0 +1,175 @@
<template>
<div class="suborder-detail">
<el-row :gutter="20">
<el-col style="margin-bottom: 12px">
<!-- 混料订单 -->
<TablePagi v-if="order !== null" :extra-query-fields="{ code: order.code, cate: order.cate }"
:urls="{ page: '/pms/blenderOrder/pageView' }" :page-is-post="true" :table-config="{
table: null,
column: blenderTableProps,
}" />
</el-col>
<el-col style="margin-bottom: 12px">
<!-- 压制订单 -->
<TablePagi v-if="order !== null" :extra-query-fields="{ code: order.code, cate: order.cate }"
:urls="{ page: '/pms/pressOrder/pageView' }" :page-is-post="true" :table-config="{
table: null,
column: pressTableProps,
}" />
</el-col>
</el-row>
<el-row :gutter="20">
<el-col style="margin-bottom: 12px">
<!-- 窑炉订单 -->
<TablePagi v-if="order !== null" :extra-query-fields="{ code: order.code, cate: order.cate }"
:urls="{ page: '/pms/kilnOrder/pageView' }" :page-is-post="true" :table-config="{
table: null,
column: kilnTableProps,
}" />
</el-col>
<el-col style="margin-bottom: 12px">
<!-- 检测包装订单 -->
<TablePagi v-if="order !== null" :extra-query-fields="{ code: order.code, cate: order.cate }"
:urls="{ page: '/pms/qualityPackOrder/pageView' }" :page-is-post="true" :table-config="{
table: null,
column: detectionTableProps,
}" />
</el-col>
</el-row>
</div>
</template>
<script>
import TablePagi from "../TablePagi.vue";
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
const percentComponent = {
name: "PercentComponent",
props: {
injectData: {
type: Object,
default: () => ({})
}
},
data() {
return {
}
},
methods: {
},
render: function (h) {
const value = this.injectData[this.injectData.head.prop]
return h(
'div',
{
style: {
padding: '0 10px',
background: value > 0 && value <= 100 ? '#ffd400' : (value > 100 ? '#6797ff' : 'unset'),
color: value > 100 ? 'white' : 'unset'
}
},
value !== null && value !== undefined ? value + " %" : "-"
)
}
}
export default {
name: "SuborderDetailTag",
components: { TablePagi },
props: {
order: {
type: Object,
default: () => null,
},
},
inject: ["urls"],
data() {
return {
//
blenderTableProps: [
{ width: 200, prop: "code", label: "混料订单号" },
{ width: 350, prop: "percent", label: "进度", className: 'no-padding-class', subcomponent: percentComponent }, // filter: (val) => (val !== null && val !== undefined ? val + " %" : "-") },
{
width: 575,
prop: "statusDictValue",
label: "订单状态",
filter: (val) => (val !== null && val !== undefined ? ["等待", "确认", "生产", "暂停", "结束", "接受", "拒绝"][val] : "-"),
},
{ prop: "qty", label: "混料总量 [kg]" },
{
prop: "operations",
name: "操作",
fixed: "right",
width: 200,
subcomponent: TableOperaionComponent,
options: [
{ name: "edit", label: "编辑", emitFull: true, icon: "edit-outline" },
{ name: "view-batch", label: "查看批次", color: "#ff8000", toRouter: "pms-blenderBatch", icon: "document-copy" }, // pms-blenderBatch
{ name: "detach", label: "下发", color: "#099", icon: "bottom-right" },
],
},
],
refreshLayoutKey1: "",
//
pressTableProps: [
{ width: 200, prop: "code", label: "压制订单号" },
{ width: 350, prop: "percent", label: "进度", filter: (val) => (val !== null && val !== undefined ? val + " %" : "-") },
{
prop: "statusDictValue",
label: "订单状态",
filter: (val) => (val !== null && val !== undefined ? ["等待", "确认", "生产", "暂停", "结束", "接受", "拒绝"][val] : "-"),
},
{ prop: "qty", label: "生产量" },
{ prop: "qtyComplete", label: "完成量" },
{ prop: "goodqty", label: "合格数量" },
{ prop: "badqty", label: "不合格数量" },
{
prop: "operations",
name: "操作",
fixed: "right",
width: 200,
subcomponent: TableOperaionComponent,
options: [{ name: "detach", label: "下发", icon: "bottom-right" }], // , url: '/pms/trans/pressDeli' }]
},
],
refreshLayoutKey2: "",
//
kilnTableProps: [
{ width: 200, prop: "code", label: "烧成订单号" },
{ width: 350, prop: "percent", label: "进度", filter: (val) => (val !== null && val !== undefined ? val + " %" : "-") },
{ prop: "qty", label: "生产量" },
{ prop: "qtyComplete", label: "完成量" },
],
refreshLayoutKey3: "",
//
detectionTableProps: [
{ width: 200, prop: "code", label: "检测包装订单号" },
{ width: 350, prop: "percent", label: "进度", filter: (val) => (val !== null && val !== undefined ? val + " %" : "-") },
{ prop: "qty1", label: "检测量" },
{ prop: "qty1Complete", label: "完成量" },
{ prop: "goodqty1", label: "检测合格量" },
{ prop: "badqty1", label: "检测不合格量" },
],
refreshLayoutKey4: "",
};
},
created() { },
mounted() { },
methods: {
init(/** 参数 */) {
// Promise.all(
//
//
//
//
// )
},
},
};
</script>
<style scoped></style>

View File

@ -0,0 +1,20 @@
<template>
<div class="tray-detail">
托盘详情
</div>
</template>
<script>
export default {
name: "TrayDetailTag",
props: {},
data() {
return {};
},
created() {},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@ -8,52 +8,59 @@ import { getDictDataList } from '@/utils';
export default function () {
const tableProps = [
{ type: "index", label: "序号" },
{ prop: "code", label: "流水号" },
{ prop: "carCode", label: "窑车号" },
{ prop: "orderCode", label: "订单号" },
{ prop: "realQty", label: "数量" },
{ prop: "typeDictValue", label: "类型", filter: dictFilter('pallet_type') },
{ prop: "stifling", label: "熏蒸", },
{ prop: "printTime", label: "打印时间", filter: timeFilter },
{ prop: "createTime", label: "添加时间", filter: timeFilter },
{ width: 60, type: "index", label: "序号", fixed: true },
{ width: 120, prop: "code", label: "订单号", fixed: "left" },
{ width: 60, prop: "cate", label: "子号" },
{ width: 60, prop: "statusDictValue", label: "状态", filter: dictFilter("order_status") },
{ width: 120, prop: "planStartTime", label: "计划开始时间", filter: timeFilter },
{ width: 120, prop: "startTime", label: "开始时间", filter: timeFilter },
{ width: 60, prop: "prodqty", label: "数量" },
{ width: 100, prop: "productCode", label: "物料" },
{ width: 100, prop: "shapeCode", label: "砖型" },
{ width: 120, prop: "brand", label: "牌号" },
{ width: 60, prop: "ai", label: "版本" },
{ width: 65, prop: "addon", label: "addon" },
{ width: 200, prop: "shortDesc", label: "物料号销售文本" },
{ width: 100, prop: "bomCode", label: "配方编码" },
{ width: 80, prop: "pressCode", label: "压机号" },
{ width: 80, prop: "blenderCode", label: "混料机号" },
{ width: 80, prop: "kilnCode", label: "隧道窑号" },
{ width: 120, prop: "ktmp", label: "烧成温度" },
{ width: 120, prop: "tt", label: "烧成时间" },
{ width: 120, prop: "yieldqty", label: "已生产数量" },
{ width: 120, prop: "soqty", label: "销售订单数" },
{ width: 200, prop: "saleNo", label: "销售订单号" },
{ width: 200, prop: "saleOrderItem", label: "销售订单item号" },
{ width: 200, prop: "packTechCode", label: "包装工艺代码" },
{ width: 120, prop: "specifications", label: "生产订单类型" },
{ width: 120, prop: "deliveryTime", label: "销售时间" },
{ width: 120, prop: "customerCode", label: "客户" },
{ width: 120, prop: "pcsKilnCar", label: "托盘码放砖数" },
{ width: 120, prop: "remark", label: "备注" },
{ width: 120, prop: "createTime", label: "添加时间", filter: timeFilter },
{
prop: "operations",
name: "操作",
fixed: "right",
width: 90,
subcomponent: TableOperaionComponent,
options: [
{ name: "print", label: "打印", icon: "printer" },
{ name: "view-car-record", label: "窑车记录", emitField: 'hisId', icon: "shopping-cart-1" },
],
},
options: [{ name: 'view-ongoing', label: '查看详情', icon: 'view', emitFull: true }],
width: 90,
}
];
const headFormFields = [
{
prop: "carId",
label: "窑车号",
select: [],
fn: () => this.$http.get("/pms/car/page", { params: { page: 1, limit: 999 } }),
bind: {
placeholder: "请选择窑车号",
filterable: true
},
prop: "",
label: "已完成订单",
},
{
prop: "orderId",
label: "订单号",
fieldOptionLabel: 'code',
// fieldOptionValue: 'id',
select: [],
fn: () => this.$http.post("/pms/order/pageView", { page: 1, limit: 999 }),
bind: {
placeholder: "请选择订单号",
filterable: true
},
prop: "code",
input: true,
bind: { placeholder: "请输入订单号" },
},
{
// 查询
button: {
type: "primary",
name: "查询",
@ -156,11 +163,9 @@ export default function () {
fields: headFormFields, // 名称是由 BaseSearchForm.vue 组件固定的
},
urls: {
base: '/pms/carHistory',
payload: '/pms/carHandle', // hisId 查询 载砖详情
page: "/pms/pallet/pageView",
base: '/pms/order',
page: "/pms/order/pageEnd",
pageIsPostApi: true,
printLog: '/pms/pallet/print', // post
},
};
}