add 混料压制合并
This commit is contained in:
parent
f5bab979c9
commit
ebfbc895bb
@ -0,0 +1,451 @@
|
|||||||
|
<!-- 表格页加上搜索条件 -->
|
||||||
|
<template>
|
||||||
|
<div class="list-view-with-head">
|
||||||
|
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
|
||||||
|
|
||||||
|
<div class="blender">
|
||||||
|
<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="[10, 20, 50, 100]"
|
||||||
|
:page-size="size"
|
||||||
|
:total="totalPage"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="press" style="margin-top: 24px">
|
||||||
|
<BaseListTable
|
||||||
|
v-loading="pressTableLoading"
|
||||||
|
:table-config="pressTableConfig.table"
|
||||||
|
:column-config="pressTableConfig.column"
|
||||||
|
:table-data="pressDataList"
|
||||||
|
@operate-event="handleOperatePress"
|
||||||
|
:current-page="pressPage"
|
||||||
|
:current-size="pressSize"
|
||||||
|
:refresh-layout-key="refreshLayoutKeyPress" />
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
class="mt-5 flex justify-end"
|
||||||
|
@size-change="handlePressSizeChange"
|
||||||
|
@current-change="handlePressPageChange"
|
||||||
|
:current-page.sync="pressPage"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
:page-size="pressSize"
|
||||||
|
:total="totalPagePress"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DialogJustForm
|
||||||
|
ref="edit-dialog"
|
||||||
|
v-if="!!dialogConfigs"
|
||||||
|
:dialog-visible.sync="dialogVisible"
|
||||||
|
:configs="dialogConfigs"
|
||||||
|
@refreshDataList="getList" />
|
||||||
|
<!-- :bom-code="dialogBomCode" -->
|
||||||
|
|
||||||
|
<Overlay v-if="overlayVisible" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import BaseListTable from "@/components/BaseListTable.vue";
|
||||||
|
import BaseSearchForm from "@/components/BaseSearchForm.vue";
|
||||||
|
import DialogJustForm from "./edit-dialog.vue";
|
||||||
|
import Overlay from "@/components/Overlay.vue";
|
||||||
|
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "ListViewWithHead",
|
||||||
|
components: { BaseSearchForm, BaseListTable, DialogJustForm, Overlay },
|
||||||
|
props: {
|
||||||
|
tableConfig: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({
|
||||||
|
/** 列配置, 即 props **/ column: [],
|
||||||
|
/** 表格整体配置 */ table: undefined,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
pressTableConfig: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({
|
||||||
|
/** 列配置, 即 props **/ column: [],
|
||||||
|
/** 表格整体配置 */ table: undefined,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
headConfig: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
/** 请求page接口的时候有些字段是必填的,没有会报500,把相关字段名传入这个prop: */
|
||||||
|
listQueryExtra: {
|
||||||
|
type: Array,
|
||||||
|
default: () => ["key"],
|
||||||
|
},
|
||||||
|
initDataWhenLoad: { type: Boolean, default: true },
|
||||||
|
/** dialog configs 或许可以从 tableConfig 计算出来 computed... */
|
||||||
|
dialogConfigs: {
|
||||||
|
type: Object,
|
||||||
|
default: () => null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
activated() {
|
||||||
|
this.refreshLayoutKey = this.layoutTable();
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
topBtnConfig: null,
|
||||||
|
totalPage: 100,
|
||||||
|
page: 1,
|
||||||
|
size: 20, // 默认20
|
||||||
|
dataList: [],
|
||||||
|
totalPagePress: 100,
|
||||||
|
pressPage: 1,
|
||||||
|
pressSize: 20, // 默认20
|
||||||
|
pressDataList: [],
|
||||||
|
tableLoading: false,
|
||||||
|
refreshLayoutKey: null,
|
||||||
|
pressTableLoading: false,
|
||||||
|
refreshLayoutKeyPress: null,
|
||||||
|
dialogBomCode: "",
|
||||||
|
overlayVisible: false,
|
||||||
|
cachedSearchCondition: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
inject: ["urls"],
|
||||||
|
mounted() {
|
||||||
|
this.initDataWhenLoad && this.getList();
|
||||||
|
this.initDataWhenLoad && this.getList(null, "press");
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 获取 列表数据 */
|
||||||
|
getList(queryParams, type = "blender") {
|
||||||
|
if (!type || type === "blender") this.tableLoading = true;
|
||||||
|
if (type === "press") this.pressTableLoading = true;
|
||||||
|
|
||||||
|
let page = type === "blender" ? this.page : this.pressPage;
|
||||||
|
let size = type === "blender" ? this.size : this.pressSize;
|
||||||
|
|
||||||
|
const params = queryParams
|
||||||
|
? { ...queryParams, page, limit: size }
|
||||||
|
: {
|
||||||
|
page,
|
||||||
|
limit: 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];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = type === "blender" ? this.urls.page : this.urls.pressPage;
|
||||||
|
|
||||||
|
this.$http[this.urls.pageIsPostApi ? "post" : "get"](
|
||||||
|
url,
|
||||||
|
this.urls.pageIsPostApi
|
||||||
|
? {
|
||||||
|
...params,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
params,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(({ data: res }) => {
|
||||||
|
console.log("[http response] res is: ", res);
|
||||||
|
|
||||||
|
if (res.code === 0) {
|
||||||
|
// page 场景:
|
||||||
|
if ("list" in res.data) {
|
||||||
|
if (type === "blender") {
|
||||||
|
this.dataList = res.data.list;
|
||||||
|
this.totalPage = res.data.total;
|
||||||
|
} else if (type === "press") {
|
||||||
|
this.pressDataList = res.data.list;
|
||||||
|
this.totalPagePress = res.data.total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$message({
|
||||||
|
message: `${res.code}: ${res.msg}`,
|
||||||
|
type: "error",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (type === "blender") this.tableLoading = false;
|
||||||
|
else this.pressTableLoading = false;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
this.$message({
|
||||||
|
message: `${err}`,
|
||||||
|
type: "error",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
if (type === "blender") this.tableLoading = false;
|
||||||
|
else this.pressTableLoading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
layoutTable() {
|
||||||
|
return Math.random();
|
||||||
|
},
|
||||||
|
|
||||||
|
handleOperatePress({ type, data, toRouter }) {
|
||||||
|
console.log("payload", type, data);
|
||||||
|
switch (type) {
|
||||||
|
case "detach": {
|
||||||
|
// 下发订单
|
||||||
|
this.$confirm(
|
||||||
|
`确定下发订单吗?`,
|
||||||
|
"提示",
|
||||||
|
{
|
||||||
|
confirmButtonText: "确认",
|
||||||
|
cancelButtonText: "我再想想",
|
||||||
|
type: "warning",
|
||||||
|
}
|
||||||
|
).then(() => {
|
||||||
|
this.overlayVisible = true;
|
||||||
|
return this.$http
|
||||||
|
.post(this.urls.pressDetach, data /* { id: data } */, { headers: { "Content-Type": "application/json" } })
|
||||||
|
.then(({ data: res }) => {
|
||||||
|
if (res.code === 0) {
|
||||||
|
this.$message({
|
||||||
|
message: `下发成功`,
|
||||||
|
type: "success",
|
||||||
|
duration: 1500,
|
||||||
|
onClose: () => {
|
||||||
|
this.getList(this.cachedSearchCondition, 'press');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$message({
|
||||||
|
message: `${res.code}: ${res.msg}`,
|
||||||
|
type: "error",
|
||||||
|
duration: 1500,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.overlayVisible = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 处理 表格操作 */
|
||||||
|
handleOperate({ type, data, toRouter }) {
|
||||||
|
console.log("payload", type, data);
|
||||||
|
// 编辑、删除、跳转路由、打开弹窗(动态component)都可以在配置里加上 url
|
||||||
|
// payload: { type: string, data: string | number | object }
|
||||||
|
switch (type) {
|
||||||
|
case "delete": {
|
||||||
|
// 确认是否删除
|
||||||
|
return this.$confirm(`确定要删除记录 "${data.name ?? data.id}" 吗?`, "提示", {
|
||||||
|
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}`],
|
||||||
|
}).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-detail-action": {
|
||||||
|
this.openDialog(data, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "view-batch": {
|
||||||
|
this.$router.push({
|
||||||
|
name: toRouter,
|
||||||
|
query: {
|
||||||
|
id: data, // 混料订单id
|
||||||
|
},
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "detach":
|
||||||
|
case "pause-blender":
|
||||||
|
case "start-blender": {
|
||||||
|
// 下发订单
|
||||||
|
this.$confirm(
|
||||||
|
`确定${type === "detach" ? "下发" : type === "pause-blender" ? "暂停" : "开始"}该订单吗?`,
|
||||||
|
"提示",
|
||||||
|
{
|
||||||
|
confirmButtonText: "确认",
|
||||||
|
cancelButtonText: "我再想想",
|
||||||
|
type: "warning",
|
||||||
|
}
|
||||||
|
).then(() => {
|
||||||
|
this.overlayVisible = true;
|
||||||
|
const realUrl =
|
||||||
|
type === "detach"
|
||||||
|
? this.urls.detach
|
||||||
|
: type === "pause-blender"
|
||||||
|
? this.urls.pauseBlender
|
||||||
|
: this.urls.startBlender;
|
||||||
|
return this.$http
|
||||||
|
.post(realUrl, data /* { id: data } */, { headers: { "Content-Type": "application/json" } })
|
||||||
|
.then(({ data: res }) => {
|
||||||
|
if (res.code === 0) {
|
||||||
|
this.$message({
|
||||||
|
message: `${type === "detach" ? "下发" : type === "pause-blender" ? "暂停" : "开始"}成功`,
|
||||||
|
type: "success",
|
||||||
|
duration: 1500,
|
||||||
|
onClose: () => {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$message({
|
||||||
|
message: `${res.code}: ${res.msg}`,
|
||||||
|
type: "error",
|
||||||
|
duration: 1500,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.overlayVisible = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleBtnClick({ btnName, payload }) {
|
||||||
|
console.log("[search] form handleBtnClick", btnName, payload);
|
||||||
|
switch (btnName) {
|
||||||
|
case "新增":
|
||||||
|
this.openDialog();
|
||||||
|
break;
|
||||||
|
case "查询": {
|
||||||
|
/** 处理 payload 里的数据 */
|
||||||
|
if (typeof payload === "object") {
|
||||||
|
// BaseSearchForm 给这个组件传递了数据
|
||||||
|
Object.assign(this.cachedSearchCondition, payload);
|
||||||
|
if ("timerange" in payload) {
|
||||||
|
if (!!payload.timerange) {
|
||||||
|
const [startTime, endTime] = payload["timerange"];
|
||||||
|
this.cachedSearchCondition.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
|
||||||
|
this.cachedSearchCondition.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
|
||||||
|
} else {
|
||||||
|
delete this.cachedSearchCondition.startTime;
|
||||||
|
delete this.cachedSearchCondition.endTime;
|
||||||
|
}
|
||||||
|
delete this.cachedSearchCondition.timerange;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理 listQueryExtra 里的数据 */
|
||||||
|
this.listQueryExtra?.map((cond) => {
|
||||||
|
if (typeof cond === "string") {
|
||||||
|
if (!!payload[cond]) {
|
||||||
|
this.cachedSearchCondition[cond] = payload[cond];
|
||||||
|
} else {
|
||||||
|
this.cachedSearchCondition[cond] = "";
|
||||||
|
}
|
||||||
|
} else if (typeof cond === "object") {
|
||||||
|
Object.keys(cond).forEach((key) => {
|
||||||
|
this.cachedSearchCondition[key] = cond[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log("查询", this.cachedSearchCondition);
|
||||||
|
this.getList(this.cachedSearchCondition);
|
||||||
|
this.getList(this.cachedSearchCondition, 'press');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 导航器的操作 */
|
||||||
|
handleSizeChange(val) {
|
||||||
|
// val 是新值
|
||||||
|
this.page = 1;
|
||||||
|
this.size = val;
|
||||||
|
this.getList(this.cachedSearchCondition);
|
||||||
|
},
|
||||||
|
|
||||||
|
handlePageChange(val) {
|
||||||
|
// val 是新值
|
||||||
|
this.getList(this.cachedSearchCondition);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 导航器的操作 */
|
||||||
|
handlePressSizeChange(val) {
|
||||||
|
// val 是新值
|
||||||
|
this.pressPage = 1;
|
||||||
|
this.pressSize = val;
|
||||||
|
this.getList(this.cachedSearchCondition, "press");
|
||||||
|
},
|
||||||
|
|
||||||
|
handlePressPageChange(val) {
|
||||||
|
// val 是新值
|
||||||
|
this.getList(this.cachedSearchCondition, "press");
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 打开对话框 */
|
||||||
|
openDialog(row_data) {
|
||||||
|
this.dialogVisible = true;
|
||||||
|
|
||||||
|
// if ("bomCode" in row_data) {
|
||||||
|
// const { bomCode } = row_data;
|
||||||
|
// this.dialogBomCode = bomCode;
|
||||||
|
// }
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs["edit-dialog"].init(row_data);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</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>
|
370
src/views/modules/pms/blenderPress/components/edit-dialog.vue
Normal file
370
src/views/modules/pms/blenderPress/components/edit-dialog.vue
Normal file
@ -0,0 +1,370 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
class="dialog-just-form"
|
||||||
|
:visible="dialogVisible"
|
||||||
|
@close="handleClose"
|
||||||
|
:destroy-on-close="false"
|
||||||
|
:close-on-click-modal="configs.clickModalToClose ?? true"
|
||||||
|
>
|
||||||
|
<!-- title -->
|
||||||
|
<div slot="title" class="dialog-title">
|
||||||
|
<h1 class="">
|
||||||
|
{{ detailMode ? "查看详情" : dataForm.id ? "编辑" : "新增" }}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- form -->
|
||||||
|
<el-form ref="dataForm" :model="dataForm" v-loading="loadingStatus">
|
||||||
|
<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">
|
||||||
|
<!-- 通过多个 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 || col.forceDisabled"
|
||||||
|
v-model="dataForm[col.prop]"
|
||||||
|
clearable
|
||||||
|
:disabled="detailMode || col.forceDisabled"
|
||||||
|
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"
|
||||||
|
@change="handleSelectChange(col, $event)"
|
||||||
|
>
|
||||||
|
<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'"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<!-- add more... -->
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- footer -->
|
||||||
|
<div slot="footer">
|
||||||
|
<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="handleBtnClick({ name: 'cancel' })">取消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { pick as __pick } from "@/utils/filters";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "DialogJustForm",
|
||||||
|
components: {},
|
||||||
|
props: {
|
||||||
|
configs: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({
|
||||||
|
clickModalToClose: true,
|
||||||
|
forms: null,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
dialogVisible: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
// 特殊需求
|
||||||
|
// bomCode: {
|
||||||
|
// type: String,
|
||||||
|
// default: "x",
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
inject: ["urls"],
|
||||||
|
data() {
|
||||||
|
const dataForm = {};
|
||||||
|
const delayList = [];
|
||||||
|
|
||||||
|
this.configs.form.rows.forEach((row) => {
|
||||||
|
row.forEach((col) => {
|
||||||
|
dataForm[col.prop] = col.default ?? null;
|
||||||
|
|
||||||
|
if (col.fetchData && typeof col.fetchData === "function") {
|
||||||
|
if (col.delayRequest) delayList.push(col);
|
||||||
|
// let doRequest = null;
|
||||||
|
// if (col.fetchData.length) {
|
||||||
|
// console.log(`this.bomCode '${this.bomCode}'`);
|
||||||
|
// // 如果有参数
|
||||||
|
// doRequest = col.fetchData.bind(this.bomCode);
|
||||||
|
// } else doRequest = col.fetchData;
|
||||||
|
else
|
||||||
|
col.fetchData().then(({ data: res }) => {
|
||||||
|
if (res.code === 0) {
|
||||||
|
if ("list" in res.data) {
|
||||||
|
this.$set(
|
||||||
|
col,
|
||||||
|
"options",
|
||||||
|
res.data.list.map((i) => ({
|
||||||
|
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
|
||||||
|
value: col.optionValue ? i[col.optionValue] : i.id,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
} else if (Array.isArray(res.data)) {
|
||||||
|
this.$set(
|
||||||
|
col,
|
||||||
|
"options",
|
||||||
|
res.data.map((i) => ({
|
||||||
|
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
|
||||||
|
value: col.optionValue ? i[col.optionValue] : i.id,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log("请检查返回的数据类型");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
col.options.splice(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
loadingStatus: false,
|
||||||
|
dataForm,
|
||||||
|
detailMode: false,
|
||||||
|
baseDialogConfig: null,
|
||||||
|
delayList,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
uploadHeaders() {
|
||||||
|
return {
|
||||||
|
token: Cookies.get("token") || "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleFilelistUpdate(newFilelist) {
|
||||||
|
// TODO: 直接访问 .files 可能不太合适
|
||||||
|
this.dataForm.files = newFilelist.map((file) => ({
|
||||||
|
id: file.id,
|
||||||
|
name: file.name,
|
||||||
|
url: file.url,
|
||||||
|
typeCode: file.typeCode,
|
||||||
|
}));
|
||||||
|
// 更新请求
|
||||||
|
if ("id" in this.dataForm && this.dataForm.id !== null && this.dataForm.id !== undefined) this.addOrUpdate("PUT");
|
||||||
|
else
|
||||||
|
this.$notify({
|
||||||
|
title: "等待保存",
|
||||||
|
message: "已添加文件,请手动点击保存!",
|
||||||
|
type: "warning",
|
||||||
|
duration: 2500,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 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;
|
||||||
|
});
|
||||||
|
console.log("[DialogJustForm resetForm()] clearing form...");
|
||||||
|
this.$refs.dataForm.clearValidate();
|
||||||
|
this.$emit("dialog-closed"); // 触发父组件销毁自己
|
||||||
|
},
|
||||||
|
immediate ? 0 : 200
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
init(row) {
|
||||||
|
this.loadingStatus = true;
|
||||||
|
// id 和 混料机 ID 混料订单号 和 配方id
|
||||||
|
const { id, code, blender, bomId } = row;
|
||||||
|
|
||||||
|
// console.log(" { id, code, blender } = row;", row);
|
||||||
|
|
||||||
|
if (this.$refs.dataForm) {
|
||||||
|
this.$refs.dataForm.clearValidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.delayList.forEach((col) => {
|
||||||
|
// console.log("delay fetch", col);
|
||||||
|
// 需要延迟获取异步数据的 col 配置
|
||||||
|
if (col.fetchDataParam in row) {
|
||||||
|
// console.log("delay row ", row, row[col.fetchDataParam]);
|
||||||
|
col.fetchData(row[col.fetchDataParam]).then(({ data: res }) => {
|
||||||
|
if (res.code === 0) {
|
||||||
|
if ("list" in res.data) {
|
||||||
|
this.$set(
|
||||||
|
col,
|
||||||
|
"options",
|
||||||
|
res.data.list.map((i) => ({
|
||||||
|
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
|
||||||
|
value: col.optionValue ? i[col.optionValue] : i.id,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
} else if (Array.isArray(res.data)) {
|
||||||
|
this.$set(
|
||||||
|
col,
|
||||||
|
"options",
|
||||||
|
res.data.map((i) => ({
|
||||||
|
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
|
||||||
|
value: col.optionValue ? i[col.optionValue] : i.id,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log("请检查返回的数据类型");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
col.options.splice(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loadingStatus = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.detailMode = false;
|
||||||
|
|
||||||
|
this.dataForm.id = id || null;
|
||||||
|
this.dataForm.blender = blender;
|
||||||
|
this.dataForm.code = code;
|
||||||
|
this.dataForm.bomId = bomId;
|
||||||
|
if (!this.delayList.length) this.loadingStatus = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** handlers */
|
||||||
|
handleSelectChange(col, eventValue) {
|
||||||
|
// console.log("[dialog] select change: ", col, eventValue);
|
||||||
|
this.$forceUpdate();
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSwitchChange(val) {
|
||||||
|
console.log("[dialog] switch change: ", val, this.dataForm);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleComponentModelUpdate(propName, { subject, payload: { data } }) {
|
||||||
|
this.dataForm[propName] = JSON.stringify(data);
|
||||||
|
console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]);
|
||||||
|
},
|
||||||
|
|
||||||
|
addOrUpdate(method = "POST") {
|
||||||
|
this.$refs.dataForm.validate((passed, result) => {
|
||||||
|
if (passed) {
|
||||||
|
this.loadingStatus = true;
|
||||||
|
|
||||||
|
const { id, blender, bomId } = this.dataForm;
|
||||||
|
|
||||||
|
return this.$http
|
||||||
|
.get(this.urls.changeBlender, { params: { id, blender, bomId } })
|
||||||
|
.then(({ data: res }) => {
|
||||||
|
this.loadingStatus = false;
|
||||||
|
if (res.code === 0) {
|
||||||
|
this.$message.success("更新成功");
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
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) {
|
||||||
|
console.log("btn click payload: ", payload);
|
||||||
|
|
||||||
|
if ("name" in payload) {
|
||||||
|
switch (payload.name) {
|
||||||
|
case "cancel":
|
||||||
|
this.handleClose();
|
||||||
|
break;
|
||||||
|
case "update":
|
||||||
|
this.addOrUpdate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("[x] 不是这么用的! 缺少name属性");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleUploadChange(file, fileList) {
|
||||||
|
console.log("[Upload] handleUploadChange...", file, fileList);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleClose() {
|
||||||
|
this.resetForm();
|
||||||
|
this.$emit("update:dialogVisible", false);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.dialog-just-form >>> .el-dialog__body {
|
||||||
|
/* padding-top: 16px !important;
|
||||||
|
padding-bottom: 16px !important; */
|
||||||
|
padding-top: 0 !important;
|
||||||
|
padding-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-select,
|
||||||
|
.el-cascader,
|
||||||
|
.el-date-editor {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-just-form >>> .el-dialog__header {
|
||||||
|
padding: 10px 20px 10px;
|
||||||
|
/* background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), white); */
|
||||||
|
}
|
||||||
|
</style>
|
179
src/views/modules/pms/blenderPress/config.js
Normal file
179
src/views/modules/pms/blenderPress/config.js
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
|
||||||
|
// import TableTextComponent from "@/components/noTemplateComponents/detailComponent";
|
||||||
|
// import StatusComponent from "@/components/noTemplateComponents/statusComponent";
|
||||||
|
import { timeFilter } from "@/utils/filters";
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
const tableProps = [
|
||||||
|
{ type: "index", label: "序号" },
|
||||||
|
{ width: 160, prop: "orderCode", label: "主订单号" },
|
||||||
|
{ width: 60, prop: "orderCate", label: "子号" },
|
||||||
|
{ width: 160, prop: "code", label: "混料订单号" },
|
||||||
|
{ width: 60, prop: "percent", label: "进度", filter: (val) => (val !== null && val !== undefined ? val + " %" : "-") },
|
||||||
|
{
|
||||||
|
prop: "statusDictValue",
|
||||||
|
label: "订单状态",
|
||||||
|
filter: (val) => (val !== null && val !== undefined ? ["等待", "确认", "生产", "暂停", "结束", "接受", "拒绝"][val] : "-"),
|
||||||
|
},
|
||||||
|
{ prop: "bomCode", label: "配方" },
|
||||||
|
{ width: 120, prop: "qty", label: "混料总量 [kg]" },
|
||||||
|
{ width: 120, prop: "comqty", label: "已完成量 [kg]" },
|
||||||
|
{ width: 60, prop: "ai", label: "版本" },
|
||||||
|
{ prop: "blenderCode", label: "混料机" },
|
||||||
|
{ width: 160, prop: "", label: "添加时间", filter: timeFilter },
|
||||||
|
{
|
||||||
|
prop: "operations",
|
||||||
|
name: "操作",
|
||||||
|
fixed: "right",
|
||||||
|
width: 180,
|
||||||
|
subcomponent: TableOperaionComponent,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "edit", label: "编辑", emitFull: true, icon: 'edit-outline', enable: injectData => {
|
||||||
|
const v = injectData.statusDictValue
|
||||||
|
if (v && +v === 1) return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ name: "view-batch", label: "查看批次", color: "#ff8000", toRouter: 'pms-blenderBatch', icon: 'document-copy' }, // 路由跳转至 pms-blenderBatch
|
||||||
|
{ name: "pause-blender", label: "暂停", color: "#f10000", icon: 'video-pause' },
|
||||||
|
{ name: "start-blender", label: "开始", color: "#0b58ff", icon: 'video-play' },
|
||||||
|
{ name: "detach", label: "下发", color: "#099", icon: 'bottom-right' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const pressTableProps = [
|
||||||
|
{ type: "index", label: "序号" },
|
||||||
|
{ width: 160, prop: "orderCode", label: "主订单号" },
|
||||||
|
{ width: 60, prop: "orderCate", label: "子号" },
|
||||||
|
{ width: 160, prop: "code", label: "压制订单号" },
|
||||||
|
{ width: 60, prop: "percent", label: "进度", filter: (val) => (val !== null && val !== undefined ? val + " %" : "-") },
|
||||||
|
{ prop: "statusDictValue", label: "订单状态", filter: (val) => (val !== null && val !== undefined ? ["等待", "确认", "生产", "暂停", "结束", "接受", "拒绝"][val] : "-"), },
|
||||||
|
{ prop: "startTime", label: "开始时间" },
|
||||||
|
{ width: 100, prop: "shapeCode", label: "砖型" },
|
||||||
|
{ prop: "pressCode", label: "压机" },
|
||||||
|
{ width: 80, prop: "qty", label: "生产量" },
|
||||||
|
{ prop: "qtyComplete", label: "完成量" },
|
||||||
|
{ prop: "goodqty", label: "合格数量" },
|
||||||
|
{ width: 120, prop: "badqty", label: "不合格数量" },
|
||||||
|
{ width: 160, prop: "createTime", label: "添加时间", filter: timeFilter },
|
||||||
|
{
|
||||||
|
prop: "operations",
|
||||||
|
name: "操作",
|
||||||
|
fixed: "right",
|
||||||
|
width: 80,
|
||||||
|
subcomponent: TableOperaionComponent,
|
||||||
|
options: [{ name: 'detach', label: '下发', icon: 'bottom-right' }]
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
const headFormFields = [
|
||||||
|
{
|
||||||
|
prop: "code",
|
||||||
|
label: "主订单号",
|
||||||
|
input: true,
|
||||||
|
default: { value: "" },
|
||||||
|
bind: {
|
||||||
|
placeholder: "请输入主订单号查询",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: "cate",
|
||||||
|
label: "主订单子号",
|
||||||
|
input: true,
|
||||||
|
default: { value: "" },
|
||||||
|
bind: {
|
||||||
|
placeholder: "请输入主订单子号查询",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
button: {
|
||||||
|
type: "primary",
|
||||||
|
name: "查询",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// button: {
|
||||||
|
// type: "plain",
|
||||||
|
// name: "新增",
|
||||||
|
// permission: "pms:blenderStep:save",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
];
|
||||||
|
|
||||||
|
const dialogConfigs = {
|
||||||
|
form: {
|
||||||
|
rows: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
forceDisabled: true,
|
||||||
|
prop: 'code',
|
||||||
|
label: '混料订单号'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
select: true,
|
||||||
|
label: "配方",
|
||||||
|
prop: "bomId",
|
||||||
|
options: [],
|
||||||
|
optionLabelProp: 'code',
|
||||||
|
/** ====== */
|
||||||
|
fetchData: (bomCode) => this.$http.get('/pms/bom/pageVersion', { params: { key: bomCode, limit: 999, page: 1 } }),
|
||||||
|
fetchDataParam: 'bomCode',
|
||||||
|
delayRequest: true,
|
||||||
|
/** ====== */
|
||||||
|
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||||
|
elparams: { clearable: true, filterable: true, placeholder: "请选择配方" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
select: true,
|
||||||
|
label: "混料机",
|
||||||
|
prop: "blender",
|
||||||
|
options: [],
|
||||||
|
optionLabelProp: 'code',
|
||||||
|
fetchData: () => this.$http.get('/pms/equipment/list', { params: { workSequenceName: '混料工序' } }),
|
||||||
|
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||||
|
elparams: { clearable: true, filterable: true, placeholder: "请选择混料机" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
operations: [
|
||||||
|
{ name: "add", label: "保存", type: "primary", permission: "", showOnEdit: false },
|
||||||
|
{ name: "update", label: "更新", type: "primary", permission: "", showOnEdit: true },
|
||||||
|
// { name: "reset", label: "重置", type: "warning", showAlways: true },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
dialogConfigs,
|
||||||
|
tableConfig: {
|
||||||
|
table: null,
|
||||||
|
column: tableProps,
|
||||||
|
},
|
||||||
|
pressTableConfig: {
|
||||||
|
table: null,
|
||||||
|
column: pressTableProps,
|
||||||
|
},
|
||||||
|
headFormConfigs: {
|
||||||
|
rules: null, // 名称是由 BaseSearchForm.vue 组件固定的
|
||||||
|
fields: headFormFields, // 名称是由 BaseSearchForm.vue 组件固定的
|
||||||
|
},
|
||||||
|
urls: {
|
||||||
|
// base: "/pms/equipmentTech",
|
||||||
|
page: "/pms/blenderOrder/pageView",
|
||||||
|
detach: "/pms/trans/blenderDeli",
|
||||||
|
pauseBlender: "/pms/trans/blenderPause",
|
||||||
|
startBlender: "/pms/trans/blenderStart",
|
||||||
|
pageIsPostApi: true, // 使用post接口来获取page数据,极少用,目前基本上只有工艺管理模块里在用
|
||||||
|
changeBlender: '/pms/order/changeBlender',
|
||||||
|
pressPage: "/pms/pressOrder/pageView",
|
||||||
|
pressDetach: "/pms/trans/pressDeli",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
40
src/views/modules/pms/blenderPress/index.vue
Normal file
40
src/views/modules/pms/blenderPress/index.vue
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<ListViewWithHead
|
||||||
|
key="blender-order"
|
||||||
|
:table-config="tableConfig"
|
||||||
|
:press-table-config="pressTableConfig"
|
||||||
|
:head-config="headFormConfigs"
|
||||||
|
:dialog-configs="dialogConfigs"
|
||||||
|
:list-query-extra="[]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import initConfig from "./config";
|
||||||
|
import ListViewWithHead from "./components/ListViewWithHead.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "BlenderPressView",
|
||||||
|
components: { ListViewWithHead },
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
urls: this.allUrls,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
const { tableConfig, pressTableConfig, headFormConfigs, urls, dialogConfigs } = initConfig.call(this);
|
||||||
|
return {
|
||||||
|
tableConfig,
|
||||||
|
pressTableConfig,
|
||||||
|
headFormConfigs,
|
||||||
|
allUrls: urls,
|
||||||
|
dialogConfigs,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {},
|
||||||
|
mounted() {},
|
||||||
|
methods: {},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
Loading…
Reference in New Issue
Block a user