Merge branch 'docs_0727'

This commit is contained in:
lb 2023-08-03 10:00:55 +08:00
當前提交 42a7fb8bc9
共有 24 個文件被更改,包括 4149 次插入791 次删除

查看文件

@ -666,10 +666,23 @@ export default {
}
case "同步":
case "全部同步":
this.$http.post(this.urls.syncUrl).then(({ data: res }) => {
console.log("同步", res);
this.$message({ message: res.msg, type: res.code === 0 ? "success" : "error" });
this.getList();
this.$confirm("是否同步数据?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
this.overlayVisible = true;
this.$http
.post(this.urls.syncUrl)
.then(({ data: res }) => {
console.log("同步", res);
this.$message({ message: res.msg, type: res.code === 0 ? "success" : "error" });
this.getList();
this.overlayVisible = false;
})
.catch((err) => {
this.overlayVisible = false;
});
});
break;
}

查看文件

@ -0,0 +1,717 @@
<template>
<el-dialog
class="dialog-just-form"
:visible="dialogVisible"
@close="handleClose"
:destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? false"
:width="configs.dialogWidth ?? '50%'">
<!-- 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"
v-model="dataForm[col.prop]"
clearable
:disabled="IsNotAvaliable(col)"
v-bind="col.elparams" />
<el-input
v-if="col.forceDisabled && col.eraseOnSubmit"
v-model="shadowDataForm[col.prop]"
disabled
v-bind="col.elparams" />
<el-input
v-if="col.forceDisabled && !col.eraseOnSubmit"
v-model="dataForm[col.prop]"
disabled
v-bind="col.elparams" />
<el-button
type=""
plain
v-if="col.button"
v-bind="col.elparams"
style="width: 100%"
@click="handleButtonClick(col)">
{{ col.label }}
</el-button>
<el-cascader
v-if="col.cascader"
v-model="dataForm[col.prop]"
:options="col.options"
:disabled="IsNotAvaliable(col)"
v-bind="col.elparams"></el-cascader>
<el-select
v-if="col.forceDisabledSelect"
disabled
v-model="dataForm[col.prop]"
clearable
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-select
v-if="col.select"
v-model="dataForm[col.prop]"
clearable
:disabled="IsNotAvaliable(col)"
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">
<span>{{ opt.label }}</span>
<span v-if="col.customLabel" style="display: inline-clock; margin-left: 12px; font-size: 0.9em">
{{ opt[col.customLabel] || "无描述" }}
</span>
</el-option>
</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="IsNotAvaliable(col)"
v-bind="col.elparams" />
<el-date-picker
v-if="col.datetime"
v-model="dataForm[col.prop]"
:disabled="IsNotAvaliable(col)"
v-bind="col.elparams" />
</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";
import moment from "moment";
export default {
name: "DialogJustForm",
components: { },
props: {
configs: {
type: Object,
default: () => ({
clickModalToClose: false,
forms: null,
}),
},
dialogVisible: {
type: Boolean,
default: false,
},
// extraParams: {
// type: Object,
// default: () => ({})
// }
},
inject: ["urls"],
data() {
const dataForm = {};
const shadowDataForm = {};
const savedDatalist = {};
const cachedList = {};
const watchList = [];
const resetFields = [];
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
if (col == null) return;
if (!col.disableOnEdit && !col.forceDisabled && !col.forceDisabledSelect) {
resetFields.push(col.prop);
}
if (!col.eraseOnSubmit && col.prop) dataForm[col.prop] = col.default ?? null;
else shadowDataForm[col.prop] = col.default ?? null;
if ("autoUpdateProp" in col) {
savedDatalist[col.prop] = [];
}
});
});
if (this.configs.extraFields)
this.configs.extraFields.forEach((cnf) => {
dataForm[cnf.prop] = cnf.default ?? null;
});
return {
resetFields,
loadingStatus: false,
dataForm,
shadowDataForm,
savedDatalist,
cachedList,
watchList,
detailMode: false,
editMode: false,
baseDialogConfig: null,
};
},
mounted() {
/** 临时保存所有发出的请求 */
const promiseHistory = {};
const getData = (col, param) => {
console.log("getData: ", col.prop, "/", param ?? "no param!");
// -
promiseHistory[col.prop] = col.fetchData(param).then(({ data: res }) => {
if (res.code === 0) {
if ("list" in res.data) {
console.log(
"SdASD ",
res.data.list.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
[col.customLabel]: i[col.customLabel],
}))
);
// options
this.$set(
col,
"options",
col.customLabel
? res.data.list.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
[col.customLabel]: i[col.customLabel],
}))
: res.data.list.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
//
if ("injectTo" in col || col.cached) {
this.cachedList[col.prop] = res.data.list;
}
//
if ("injectTo" in col) {
console.log("set watcher: ", col.prop);
const valueProp = "optionValue" in col ? col.optionValue : "id";
const unwatch = this.$watch(
() => this.dataForm[col.prop],
(val) => {
console.log("do watcher: ", col.prop);
if (col.disableWatcherOnEdit && this.editMode) return;
if (!val) {
col.injectTo.map((item) => {
this.$set(this.dataForm, item[0], null);
this.$forceUpdate();
});
return;
}
const chosenObject = this.cachedList[col.prop].find((i) => i[valueProp] === val);
if (chosenObject) {
col.injectTo.map((item) => {
this.$set(this.dataForm, item[0], chosenObject[item[1]]);
this.$forceUpdate();
});
} else {
console.log('[x] if ("injectTo" in col) {');
}
},
{
immediate: false,
}
);
this.watchList.push(unwatch);
}
if ("autoUpdateProp" in col) {
this.$set(this.savedDatalist, col.prop, res.data.list);
}
// end branch
} else if (Array.isArray(res.data)) {
// options
this.$set(
col,
"options",
col.customLabel
? res.data.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
[col.customLabel]: i[col.customLabel],
}))
: res.data.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
//
if ("injectTo" in col || col.cached) {
this.cachedList[col.prop] = res.data;
}
//
if ("injectTo" in col && !col.watcher) {
console.log("set watcher: ", col.prop);
const valueProp = "optionValue" in col ? col.optionValue : "id";
const unwatch = this.$watch(
() => this.dataForm[col.prop],
(val) => {
if (col.disableWatcherOnEdit && this.editMode) return;
console.log("do watcher: ", col.prop);
if (!val) {
col.injectTo.map((item) => {
this.$set(this.dataForm, item[0], null);
this.$forceUpdate();
});
return;
}
const chosenObject = this.cachedList[col.prop].find((i) => i[valueProp] === val);
if (chosenObject) {
col.injectTo.map((item) => {
this.$set(this.dataForm, item[0], chosenObject[item[1]]);
this.$forceUpdate();
});
} else {
console.log('[x] if ("injectTo" in col) {');
}
},
{
immediate: false,
}
);
this.$set(col, "watcher", unwatch);
this.watchList.push(unwatch);
}
if ("autoUpdateProp" in col) {
this.$set(this.savedDatalist, col.prop, res.data);
}
}
// end branch
} else {
col.options.splice(0);
}
});
console.log("after getData: ", promiseHistory);
};
/** 处理函数 */
const handleFn = (prevProp, anchorField, anchorValue, targetField, col) => {
console.log("[handleFn]: ", prevProp, anchorField, anchorValue, targetField);
/** 此时 cachedList 已经确保可用了 */
const target = this.cachedList[prevProp].find((i) => i[anchorField] === anchorValue);
const param = target ? target[targetField] : "";
console.log("((( chosenObject )))", target);
getData(col, param);
};
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
if (col == null) return;
if (col.fetchData && typeof col.fetchData === "function" && !col.hasPrev) {
getData(col);
}
});
});
/** 必须要遍历两遍 */
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
if (col == null) return;
if (col.fetchData && typeof col.fetchData === "function" && col.hasPrev) {
console.log("[hasPrev] set watcher: ", col.hasPrev);
// -
const unwatch = this.$watch(
() => this.dataForm[col.hasPrev],
(val) => {
console.log("[hasPrev] do watcher: ", col.hasPrev);
if (!val) {
col.injectTo.map((item) => {
this.$set(this.dataForm, item[0], null);
this.$forceUpdate();
});
return;
}
if (!this.editMode) this.$set(this.dataForm, col.prop, null);
const { search, get } = col.fetchDataParam; // hasPrev
if (!this.cachedList[col.hasPrev]) {
// prev promiseHistory
promiseHistory[col.hasPrev].then(() => {
handleFn(col.hasPrev, search, val, get, col);
});
} else {
handleFn(col.hasPrev, search, val, get, col);
}
},
{
immediate: false,
}
);
this.watchList.push(unwatch);
}
});
});
if (this.configs.extraFields)
this.configs.extraFields.forEach((cnf) => {
if (cnf.listenTo) {
console.log("set watcher for: ", cnf.prop);
const unwatch = this.$watch(
() => this.dataForm[cnf.listenTo.prop],
(carId) => {
console.log("do watcher for: ", cnf.prop);
if (!carId) return;
if (cnf.disableWatcherOnEdit && this.editMode) return;
cnf.listenTo.handler.call(this, this.cachedList[cnf.listenTo.prop], carId);
},
{
immediate: false,
}
);
this.watchList.push(unwatch);
}
});
},
computed: {
uploadHeaders() {
return {
token: Cookies.get("token") || "",
};
},
},
methods: {
IsNotAvaliable(col) {
return this.detailMode || (col.disableOnEdit && this.editMode);
},
/** 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));
},
resetSpecificFields(fields) {
Object.keys(this.dataForm).forEach((key) => {
// console.log(`${key} ${fields}`, key in fields, fields.indexOf(key))
if (fields.indexOf(key) !== -1) {
// console.log(`key ${key} in fields`)
// this.dataForm[key] = null;
this.$set(this.dataForm, key, null);
}
});
console.log("this.dataform", this.dataForm);
},
resetForm(excludeId = false, immediate = false) {
setTimeout(
() => {
Object.keys(this.dataForm).forEach((key) => {
if (excludeId && key === "id") return;
this.dataForm[key] = null;
});
Object.keys(this.shadowDataForm).forEach((key) => {
this.shadowDataForm[key] = null;
});
this.$refs.dataForm.clearValidate();
this.$emit("dialog-closed"); //
},
immediate ? 0 : 200
);
},
/** init **/
init(id, detailMode, tagInfo, extraParams) {
// console.log("[DialogJustForm] init", this.dataForm, id, detailMode);
if (this.$refs.dataForm) {
// console.log("[DialogJustForm] clearing form validation...");
// dialog dataForm [0]
this.$refs.dataForm.clearValidate();
}
this.detailMode = detailMode ?? false;
this.editMode = id ? true : false;
/** 判断 extraParams */
if (extraParams && typeof extraParams === "object") {
for (const [key, value] of Object.entries(extraParams)) {
// console.log("[dialog] dataForm | key | value", this.dataForm, key, value);
this.$set(this.dataForm, key, value);
}
}
this.$nextTick(() => {
this.dataForm.id = id || 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) {
if (res.data) this.dataForm = __pick(res.data, Object.keys(this.dataForm));
else {
this.$message({
message: "后端返回的数据为 null",
type: "error",
duration: 2000,
});
}
/** 格式化文件上传列表 */
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,
}));
}
// console.log("[DialogJustForm] init():", this.dataForm);
} 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;
}
});
},
handleButtonClick(col) {
if (!("onClick" in col)) {
console.log("[handleButtonClick] 配置文件config.js 里没有绑定 onClick");
return;
}
col.onClick.call(this, this.dataForm.id);
},
/** handlers */
handleSelectChange(col, eventValue) {
if ("autoUpdateProp" in col) {
//
// console.log(col.options, eventValue, this.savedDatalist);
const item = this.savedDatalist[col.prop].find((item) => item.id === eventValue);
this.shadowDataForm[col.autoUpdateProp] = item.cate ?? null;
}
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", url) {
if ("parentId" in this.dataForm) {
console.log("[DialogJustForm parentId]", this.dataForm.parentId);
// 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") : null, // 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"),
};
}
/** 发送 */
return this.$http({
// url: this.urls.formUrl ? this.urls.formUrl : this.urls.base,
url: 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();
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 "reset":
this.resetForm(true, true); // true means exclude id, immediate execution
break;
case "resetSpecific":
// qualityInspectionRecord config
console.log("resetFields", this.resetFields);
this.resetSpecificFields(this.resetFields);
break;
case "add":
case "update":
this.addOrUpdate(payload.name === "add" ? "POST" : "PUT");
break;
case "update-bom":
this.addOrUpdate("POST", this.urls.editUrl);
break;
case "add-pos-manually": {
this.addOrUpdate("POST", this.urls.posFormUrl);
break;
}
case "add-car-payload": {
console.log("edit-car-payload", payload);
this.addOrUpdate("POST", this.urls.payloadFormUrl);
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>

查看文件

@ -0,0 +1,430 @@
<!-- 表格页加上搜索条件 -->
<template>
<div class="list-view-with-head" ref="pointer-loading-ref">
<!-- <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"
@select="handleTableSelect"
:refresh-layout-key="refreshLayoutKey" />
<el-pagination
v-if="navigator"
class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-size.sync="size"
:page-sizes="[10, 20, 50, 100]"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<edit ref="edit" v-if="dialogVisible" :blenderOrderId="blenderOrderId" @destroy="handleDestroy('edit', $event)" />
<Overlay v-if="overlayVisible" />
</div>
</template>
<script>
import BaseListTable from "@/components/BaseListTable.vue";
import BaseSearchForm from "@/components/BaseSearchForm.vue";
import DialogJustForm from "./DialogJustForm.vue";
import edit from "./edit.vue";
import Overlay from "@/components/Overlay.vue";
import moment from "moment";
export default {
name: "ListViewWithHead",
components: {
BaseSearchForm,
BaseListTable,
DialogJustForm,
edit,
Overlay,
},
props: {
navigator: {
type: Boolean,
default: true,
},
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;
},
blenderOrderId() {
const item = this.listQueryExtra.find((item) => item.blenderOrderId);
console.log("Find blenderOrderId", item);
return item ? item.blenderOrderId : null;
},
},
activated() {
this.refreshLayoutKey = this.layoutTable();
},
watch: {
page: (val) => {
console.log("page changed:", val);
},
size: (val) => {
console.log("size changed:", val);
},
triggerUpdate(val, oldVal) {
if (val && val !== oldVal) {
// get list
this.page = 1;
this.size = "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20;
this.getList();
}
},
},
data() {
return {
editVisible: false,
dialogVisible: false,
topBtnConfig: null,
totalPage: 0,
page: 1,
size: 20, // 20
dataList: [],
tableLoading: false,
refreshLayoutKey: null,
overlayVisible: false,
cachedSearchCondition: {},
needAttachmentDialog: false,
tableSelectedIds: [],
};
},
inject: ["urls"],
mounted() {
// size
const size = "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20;
this.size = size;
this.initDataWhenLoad && this.getList();
},
methods: {
handleDestroy(type, refresh) {
switch (type) {
case "edit":
this.dialogVisible = false;
if (refresh) {
this.getList();
}
break;
case "detail":
this.dialogVisible = false;
break;
}
},
/** 获取 列表数据 */
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.cachedSearchCondition = Object.assign({}, params);
}
this.$http[this.urls.pageIsPostApi ? "post" : "get"](
this.urls.page,
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) {
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 if (Array.isArray(res.data)) {
this.dataList = res.data;
} 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();
},
handleTableSelect(ids) {
this.tableSelectedIds = [...ids];
},
/** 处理 表格操作 */
handleOperate({ type, data }) {
console.log("payload", type, data);
// component url
// payload: { type: string, data: string | number | object }
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];
}
let hintMsg = `确定要删除记录 "${promptName}" 吗?`;
if (promptName == data.id) {
// promptName data.id ''
hintMsg = "确定删除该记录?";
}
let currenPageListLength = this.dataList.length;
//
return this.$confirm(hintMsg, "提示", {
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 =
// "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20;
if (currenPageListLength == 1) this.page = this.page > 1 ? this.page - 1 : 1;
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-blender-batch-details": {
this.$router.push({
name: "pms-blenderBatchDetails",
query: {
batchId: data,
},
});
break;
}
}
},
handleBtnClick({ btnName, payload }) {
switch (btnName) {
case "批量同步":
this.overlayVisible = true;
this.$http.post(this.urls.syncUrl, this.tableSelectedIds).then(({ data: res }) => {
this.$message({ message: res.msg, type: res.code === 0 ? "success" : "error" });
res.code == 0 && this.getList();
this.overlayVisible = false;
});
break;
case "新增":
this.openDialog();
break;
case "导入":
this.openUploadDialog();
break;
case "手动添加": {
this.openDialog();
return;
}
case "查询": {
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];
});
}
});
this.getList(this.cachedSearchCondition);
break;
}
case "同步":
case "全部同步":
this.$confirm("是否同步数据?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
this.overlayVisible = true;
this.$http
.post(this.urls.syncUrl)
.then(({ data: res }) => {
console.log("同步", res);
this.$message({ message: res.msg, type: res.code === 0 ? "success" : "error" });
this.getList();
this.overlayVisible = false;
})
.catch((err) => {
this.overlayVisible = false;
});
});
break;
}
},
/** 导航器的操作 */
handleSizeChange(val) {
// val
this.page = 1;
this.size = val;
this.getList(this.cachedSearchCondition);
},
handlePageChange(val) {
// val
this.getList(this.cachedSearchCondition);
},
/** 打开对话框 */
openDialog(row_id, detail_mode) {
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["edit"].init(row_id, detail_mode);
});
},
},
};
</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>

查看文件

@ -0,0 +1,225 @@
<!--
filename: edit.vue
author: liubin
date: 2023-07-19 09:00:04
description:
-->
<template>
<el-dialog
class="dialog-just-form"
:visible="dialogVisible"
@close="handleClose"
:close-on-click-modal="false"
width="'50%'">
<!-- title -->
<div slot="title" class="dialog-title">
<h1 class="">{{ dataForm.id ? "编辑" : "新增" }}</h1>
</div>
<!-- form -->
<el-form ref="dataForm" :model="dataForm" :rules="rules" v-loading="loading || detailLoading">
<el-row :gutter="20">
<el-col>
<el-form-item label="批次重量" prop="batchSize">
<el-input v-model="dataForm.batchSize" clearable placeholder="请输入批次重量"></el-input>
</el-form-item>
</el-col>
<el-col v-if="dataForm.id">
<el-form-item label="牌号" prop="bomName">
<el-input v-model="dataForm.bomName" clearable placeholder="请输入牌号"></el-input>
</el-form-item>
</el-col>
<el-col v-if="dataForm.id">
<el-form-item label="版本号" prop="techId">
<el-select
v-model="dataForm.bomVersion"
filterable
clearable
placeholder="请选择版本"
@change="handleBomVersionChange">
<el-option v-for="(bom, index) in bomList" :key="bom.label" :label="bom.label" :value="bom.value">
<div style="display: flex; align-items: center">
<!-- <span style="display: inline-block; width: 150px; overflow: hidden; text-overflow: ellipsis"> -->
{{ bom.label }}
<!-- </span> -->
<!-- <span style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ bom.remark || "无" }}
</span> -->
</div>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<!-- footer -->
<div slot="footer">
<el-button v-if="!dataForm.id" type="primary" @click="handleBtnClick('保存')" :loading="btnLoading">
保存
</el-button>
<el-button v-else type="primary" @click="handleBtnClick('更新')" :loading="btnLoading">更新</el-button>
<el-button @click="handleBtnClick('取消')">取消</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: "BlenderBatchAndBomEdit",
components: {},
props: {
blenderOrderId: {
type: String,
default: null,
},
},
data() {
return {
dialogVisible: false,
loading: false,
detailLoading: false,
dataForm: {
id: null,
batchSize: null,
bomName: null,
bomVersion: null,
},
rules: {
batchSize: [
{ required: true, message: "批次重量不能为空", trigger: "blur" },
{ type: "number", message: "批次重量必须为数字", trigger: "blur", transform: (value) => Number(value) },
],
},
bomList: [],
bomId: null,
btnLoading: false,
};
},
watch: {
blenderOrderId: {
handler(val) {
// console.log("blenderOrderId changed", val);
},
immediate: true,
},
},
methods: {
//
init(id) {
this.dataForm.id = id;
this.getBomList(id);
this.getDetail(id);
this.dialogVisible = true;
},
//
async getDetail(id) {
if (!id) return;
this.detailLoading = true;
const {
data: { data: batch },
} = await this.$http.get(`/pms/blenderBatch/${id}`);
this.dataForm.batchSize = batch.batchSize;
this.dataForm.bomName = batch.bomName;
this.dataForm.bomVersion = batch.bomVersion;
this.bomId = batch.bomId;
this.detailLoading = false;
},
//
async getBomList(id) {
if (!id) return;
this.loading = true;
const { data: res } = await this.$http.post("/pms/blenderBatch/getBoms", {
id,
blenderOrderId: this.blenderOrderId,
});
this.loading = false;
if (res.code == 0) {
this.bomList = res.data.list.map((item) => {
return {
label: item.version,
value: item.version,
id: item.id,
brand: item.code,
};
});
}
},
// version
handleBomVersionChange(version) {
const bom = this.bomList.find((item) => item.value == version);
this.bomId = bom.id;
},
//
handleBtnClick(type) {
switch (type) {
case "保存":
case "更新":
this.$refs.dataForm.validate((valid) => {
if (valid) {
this.btnLoading = true;
this.$http[type == "保存" ? "post" : "put"](
"/pms/blenderBatch",
type == "保存"
? {
batchSize: this.dataForm.batchSize,
blenderOrderId: this.blenderOrderId,
}
: {
id: this.dataForm.id,
blenderOrderId: this.blenderOrderId,
batchSize: this.dataForm.batchSize,
bomId: this.bomId,
}
).then((res) => {
if (res.data.code == 0) {
this.$message.success(type + "成功");
this.handleClose(true);
} else {
this.$message.error(res.data.msg);
}
this.btnLoading = false;
});
}
});
break;
case "取消":
this.handleClose();
break;
default:
break;
}
},
handleClose(refresh = false) {
this.dialogVisible = false;
setTimeout(() => {
this.$emit("destroy", refresh);
}, 500);
},
},
};
</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>

查看文件

@ -7,11 +7,11 @@ export default function () {
const tableProps = [
{ type: "index", label: "序号" },
{ prop: "batchNo", label: "批次编码" },
{ prop: "batchSize", label: "批次重量 [kg]" },
{ width: 108, prop: "batchSize", label: "批次重量 [kg]" },
{ prop: "status", label: "状态" },
// { prop: "startTime", label: "开始时间" },
{ prop: "endTime", label: "结束时间" },
{ prop: "task", label: "任务分类" },
{ prop: "endTime", label: "结束时间", filter: timeFilter },
{ width: 108, prop: "task", label: "任务分类" },
{ prop: "blenderCode", label: "混料机" },
// { width: 120, prop: "orderCate", label: "主订单子号" },
// { width: 160, prop: "code", label: "压制订单号" },
@ -22,10 +22,11 @@ export default function () {
// { prop: "goodqty", label: "合格数量" },
// { width: 120, prop: "badqty", label: "不合格数量" },
// { prop: "remark", label: "备注" },
// { prop: 'version', label: '配方号' },
// { prop: 'status', label: '状态', subcomponent: StatusComponent }, // subcomponent
{ prop: "description", label: "详情", subcomponent: TableTextComponent, actionName: 'view-blender-batch-details' },
{ width: 160, prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "description", label: "详情", subcomponent: TableTextComponent, actionName: "view-blender-batch-details" },
{ prop: "bomName", label: "牌号" },
{ prop: "bomVersion", label: "版本号" },
// { width: 160, prop: "createTime", label: "添加时间", filter: timeFilter },
{
prop: "operations",
name: "操作",
@ -36,17 +37,32 @@ export default function () {
// 只有 injectRow.task 为手动时,才允许编辑
// { name:"edit", label: "编辑", icon: "edit-outline", enable: injectRow => { return 'task' in injectRow && injectRow.task === 'Manual' } },
// { name: 'delete', icon: 'delete', enable: injectRow => { return 'task' in injectRow && injectRow.task === 'Manual' } },
// 只有 injectRow.status 为 waiting 时,才允许编辑
{ name:"edit", label: "编辑", icon: "edit-outline", enable: injectRow => { return 'status' in injectRow && injectRow.status === 'Waiting' } },
{ name: 'delete', icon: 'delete', emitFull: true, promptField: 'batchNo', enable: injectRow => { return 'status' in injectRow && injectRow.status === 'Waiting' } },
]
{
name: "edit",
label: "编辑",
icon: "edit-outline",
enable: (injectRow) => {
return "status" in injectRow && injectRow.status === "Waiting";
},
},
{
name: "delete",
icon: "delete",
emitFull: true,
promptField: "batchNo",
enable: (injectRow) => {
return "status" in injectRow && injectRow.status === "Waiting";
},
},
],
},
];
const headFormFields = [
{
label: '订单批次'
label: "订单批次",
},
{
button: {
@ -78,6 +94,24 @@ export default function () {
elparams: { placeholder: "请输入批次重量" },
},
],
[
{
input: true,
label: "牌号",
prop: "bomName",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入批次重量" },
},
],
[
{
select: [],
label: "版本号",
prop: "bomVersion",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入批次重量" },
},
],
],
operations: [
{ name: "add", label: "保存", type: "primary", permission: "", showOnEdit: false },

查看文件

@ -4,13 +4,13 @@
:head-config="headFormConfigs"
:dialog-configs="dialogConfigs"
:list-query-extra="[{ blenderOrderId: id }]"
attach-list-query-extra="blenderOrderId"
:trigger-update="triggerUpdateKey" />
</template>
<script>
import initConfig from "./config";
import ListViewWithHead from "@/views/atomViews/ListViewWithHead.vue";
// import ListViewWithHead from "@/views/atomViews/ListViewWithHead.vue";
import ListViewWithHead from "./components/ListViewWithHead.vue";
export default {
name: "BlenderBatchView",
@ -23,7 +23,7 @@ export default {
computed: {
// id
id() {
console.log("computed id");
console.log("computed id", this.$route.query.id || "");
return this.$route.query.id || "";
},
refreshPage() {

查看文件

@ -7,11 +7,11 @@ export default function () {
const tableProps = [
{ type: "index", label: "序号" },
// { prop: "kilnCode", label: "窑炉" },
{ width: 160, prop: "orderCode", label: "主订单号" },
{ width: 128, prop: "orderCode", label: "主订单号" },
{ width: 60, prop: "orderCate", label: "子号" },
{ width: 160, prop: "code", label: "混料订单号" },
{ width: 128, prop: "code", label: "混料订单号" },
{
width: 60,
width: 80,
prop: "percent",
label: "进度",
filter: (val) => (val !== null && val !== undefined ? val + " %" : "-"),
@ -25,9 +25,10 @@ export default function () {
// { prop: "startTime", label: "开始时间" },
// { prop: "shapeCode", label: "砖型" },
{ prop: "bomCode", label: "配方" },
{ prop: "bomName", label: "牌号" },
{ width: 60, prop: "ai", label: "版本" },
{ width: 120, prop: "qty", label: "混料总量 [kg]" },
{ width: 120, prop: "comqty", label: "已完成量 [kg]" },
{ width: 60, prop: "ai", label: "版本" },
{ prop: "blenderCode", label: "混料机" },
{ width: 160, prop: "createTime", label: "添加时间", filter: timeFilter },
// { width: 120, prop: "badqty", label: "不合格数量" },

查看文件

@ -11,7 +11,7 @@ export default function () {
// { prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "techCode", label: "烧制曲线" },
{ prop: "description", label: "详情", subcomponent: TableTextComponent, emitFullData: true },
// { prop: "remark", label: "备注" },
{ prop: "techRemark", label: "烧制曲线备注" },
{
prop: "operations",
name: "操作",

查看文件

@ -1,11 +1,11 @@
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
// import switchBtn from "@/components/noTemplateComponents/switchBtn";
import request from "@/utils/request";
import { timeFilter, dictFilter } from '@/utils/filters'
import { timeFilter, dictFilter } from "@/utils/filters";
export default function () {
const tableProps = [
{ type: 'index', label: '序号' },
{ type: "index", label: "序号" },
// { prop: "updateTime", label: "上料时间", filter: timeFilter },
{ prop: "materialName", label: "原料" },
// { prop: "material", label: "原料编码" },
@ -13,9 +13,12 @@ export default function () {
{ prop: "siloName1", label: "上料料仓1" },
{ prop: "siloName2", label: "上料料仓2" },
{ prop: "siloName3", label: "上料料仓3" },
{ prop: 'startTime', label: "开始上料时间", filter: timeFilter },
{ prop: 'endTime', label: "结束上料时间", filter: timeFilter },
{ prop: "statusDictValue", label: "破碎作业", filter: val => ['正常停止', '废除'][val] ?? '-' },
{ prop: "startTime", label: "开始上料时间", filter: timeFilter },
{ prop: "endTime", label: "结束上料时间", filter: timeFilter },
{ prop: "silo1Change", label: "料仓1变化" },
{ prop: "silo2Change", label: "料仓2变化" },
{ prop: "silo3Change", label: "料仓3变化" },
{ prop: "statusDictValue", label: "破碎作业", filter: (val) => ["正常停止", "废除"][val] ?? "-" },
// { prop: "description", label: "描述" },
{ prop: "remark", label: "备注" },
{ prop: "createTime", label: "添加时间", filter: timeFilter },
@ -25,71 +28,73 @@ export default function () {
fixed: "right",
width: 90,
subcomponent: TableOperaionComponent,
options: [{ name: "edit", label: "编辑", icon: "edit-outline" }, { name: "delete", icon: "delete", label: "删除", emitFull: true, permission: "pms:brokeLog:delete" }],
options: [
{ name: "edit", label: "编辑", icon: "edit-outline" },
{ name: "delete", icon: "delete", label: "删除", emitFull: true, permission: "pms:brokeLog:delete" },
],
},
];
/**
/**
* 数据字典hack
* @param {object} row 行数据
* @param {string} dictId 从哪个数据字典映射数据
* @param {string} dataProp 把字典值附加到哪个 prop 字段上
* @param {string} dictProp 哪个prop是字典数据
* @param {string} dictProp 哪个prop是字典数据
**/
let dictList;
tableProps.attachDictValue = (row, dictId, dataProp, dictProp, forceFlushDictList = false) => {
/** 缓存一下 dictList **/
if (!dictList || (dictList && forceFlushDictList)) dictList = dictFilter(dictId)
if (!dictList || (dictList && forceFlushDictList)) dictList = dictFilter(dictId);
if (typeof row === 'object' && dictList) {
const value = dictList(row[dictProp])
const data = row[dataProp]
row[dataProp] = data + ' ' + (value === '-' ? '' : value)
if (typeof row === "object" && dictList) {
const value = dictList(row[dictProp]);
const data = row[dataProp];
row[dataProp] = data + " " + (value === "-" ? "" : value);
} else {
this.$message({
message: 'tableProps.attachDictValue() 出错!',
type: 'error',
duration: 1500
})
message: "tableProps.attachDictValue() 出错!",
type: "error",
duration: 1500,
});
}
}
};
const headFormFields = [
{
prop: 'material',
prop: "material",
label: "按原料搜索",
// input: true,
select: [],
fieldOptionValue: 'name', // 把料仓筛选条件的label改为展示code,而不是展示name
fieldOptionValue: "name", // 把料仓筛选条件的label改为展示code,而不是展示name
default: { value: "" },
fn: () => this.$http.get("/pms/material/page", { params: { page: 1, limit: 999 } }),
bind: {
placeholder: '请输入原料名',
filterable: true
}
placeholder: "请输入原料名",
filterable: true,
},
},
{
prop: 'silo',
prop: "silo",
label: "按料仓搜索",
fieldOptionLabel: 'name', // 把料仓筛选条件的label改为展示code,而不是展示name
fieldOptionLabel: "name", // 把料仓筛选条件的label改为展示code,而不是展示name
select: [],
fn: () => this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: '0' } }),
fn: () => this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "0" } }),
bind: {
placeholder: '请选择料仓',
placeholder: "请选择料仓",
filterable: true,
}
},
},
{
timerange: true,
prop: 'timerange',
prop: "timerange",
label: "时间段",
bind: {
placeholder: '请选择上料时间段',
placeholder: "请选择上料时间段",
type: "datetimerange",
"start-placeholder": "开始时间",
"end-placeholder": "结束时间",
}
},
},
{
button: {
@ -101,11 +106,11 @@ export default function () {
button: {
type: "primary",
name: "新增",
permission: "pms:brokeLog:save"
permission: "pms:brokeLog:save",
},
bind: {
plain: true,
}
},
},
];
@ -124,8 +129,8 @@ export default function () {
options: [],
label: "原料",
prop: "material",
optionValue: 'code',
customLabel: 'description',
optionValue: "code",
customLabel: "description",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
// elparams: { placeholder: "请输入原料名称" },
elparams: { filterable: true, placeholder: "请选择原料" },
@ -136,42 +141,79 @@ export default function () {
input: true,
label: "上料量",
prop: "qty",
rules: [{ required: true, message: "必填项不能为空", trigger: "blur" }, { type: 'number', message: '请输入正确的数字类型', trigger: 'blur', transform: val => Number(val) }],
rules: [
{ required: true, message: "必填项不能为空", trigger: "blur" },
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
],
elparams: { placeholder: "请输入上料量" },
},
{ select: true, label: "破碎作业", prop: "statusDictValue", options: [{ label: '正常停止', value: 0 }, { label: '废除', value: '1' }], elparams: { placeholder: "破碎作业", filterable: true } },
{
select: true,
label: "破碎作业",
prop: "statusDictValue",
options: [
{ label: "正常停止", value: 0 },
{ label: "废除", value: "1" },
],
elparams: { placeholder: "破碎作业", filterable: true },
},
],
[
{
prop: 'silo1',
label: '上料料仓1',
prop: "silo1",
label: "上料料仓1",
select: true,
options: [],
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
fetchData: () => this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: '0' } }),
fetchData: () =>
this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "0" } }),
elparams: { filterable: true, placeholder: "请选择上料料仓1" },
customLabel: 'description',
customLabel: "description",
},
{
prop: 'silo2',
label: '上料料仓2',
prop: "silo2",
label: "上料料仓2",
select: true,
options: [],
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
fetchData: () => this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: '0' } }),
fetchData: () =>
this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "0" } }),
elparams: { filterable: true, placeholder: "请选择上料料仓2" },
customLabel: 'description',
customLabel: "description",
},
{
prop: 'silo3',
label: '上料料仓3',
prop: "silo3",
label: "上料料仓3",
select: true,
options: [],
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
fetchData: () => this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: '0' } }),
fetchData: () =>
this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "0" } }),
elparams: { filterable: true, placeholder: "请选择上料料仓3" },
customLabel: 'description',
customLabel: "description",
},
],
[
{
prop: "silo1Change",
label: "料仓1变化",
input: true,
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请填写料仓1变化" },
},
{
prop: "silo2Change",
label: "料仓2变化",
input: true,
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请填写料仓2变化" },
},
{
prop: "silo3Change",
label: "料仓3变化",
input: true,
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请填写料仓3变化" },
},
],
[
@ -180,18 +222,27 @@ export default function () {
label: "开始上料时间",
prop: "startTime",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择上料时间", type: 'datetime' },
elparams: { placeholder: "请选择上料时间", type: "datetime" },
},
{
datetime: true,
label: "结束上料时间",
prop: "endTime",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择上料结束时间", type: 'datetime' },
elparams: { placeholder: "请选择上料结束时间", type: "datetime" },
},
{ input: true, label: "描述信息", prop: "description", elparams: { placeholder: "描述信息" } },
],
[{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
[
{
forceDisabled: true,
// input: true,
label: "备注",
prop: "remark",
default: "Crushing",
elparams: { placeholder: "备注" },
},
],
],
operations: [
{ name: "add", label: "保存", type: "primary", permission: "pms:brokeLog:save", showOnEdit: false },
@ -215,7 +266,8 @@ export default function () {
},
urls: {
base: "/pms/brokeLog",
page: "/pms/brokeLog/page",
// page: "/pms/brokeLog/page",
page: "/pms/brokeLog/pagebroke",
// subase: '/pms/blenderStepParam',
// subpage: '/pms/blenderStepParam/page',
// more...

查看文件

@ -0,0 +1,276 @@
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
// import switchBtn from "@/components/noTemplateComponents/switchBtn";
import request from "@/utils/request";
import { timeFilter, dictFilter } from "@/utils/filters";
export default function () {
const tableProps = [
{ type: "index", label: "序号" },
// { prop: "updateTime", label: "上料时间", filter: timeFilter },
{ prop: "materialName", label: "原料" },
// { prop: "material", label: "原料编码" },
{ prop: "qty", label: "计划上料量" },
{ prop: "siloName1", label: "上料料仓" },
// { prop: "siloName2", label: "上料料仓2" },
// { prop: "siloName3", label: "上料料仓3" },
{ prop: "startTime", label: "开始上料时间", filter: timeFilter },
{ prop: "endTime", label: "结束上料时间", filter: timeFilter },
{ prop: "silo1Change", label: "料仓变化" },
// { prop: "silo2Change", label: "料仓2变化" },
// { prop: "silo3Change", label: "料仓3变化" },
{ prop: "statusDictValue", label: "破碎作业", filter: (val) => ["正常停止", "废除"][val] ?? "-" },
// { prop: "description", label: "描述" },
{ prop: "remark", label: "备注" },
{ prop: "createTime", label: "添加时间", filter: timeFilter },
{
prop: "operations",
name: "操作",
fixed: "right",
width: 90,
subcomponent: TableOperaionComponent,
options: [
{ name: "edit", label: "编辑", icon: "edit-outline" },
{ name: "delete", icon: "delete", label: "删除", emitFull: true, permission: "pms:brokeLog:delete" },
],
},
];
/**
* 数据字典hack
* @param {object} row 行数据
* @param {string} dictId 从哪个数据字典映射数据
* @param {string} dataProp 把字典值附加到哪个 prop 字段上
* @param {string} dictProp 哪个prop是字典数据
**/
let dictList;
tableProps.attachDictValue = (row, dictId, dataProp, dictProp, forceFlushDictList = false) => {
/** 缓存一下 dictList **/
if (!dictList || (dictList && forceFlushDictList)) dictList = dictFilter(dictId);
if (typeof row === "object" && dictList) {
const value = dictList(row[dictProp]);
const data = row[dataProp];
row[dataProp] = data + " " + (value === "-" ? "" : value);
} else {
this.$message({
message: "tableProps.attachDictValue() 出错!",
type: "error",
duration: 1500,
});
}
};
const headFormFields = [
{
prop: "material",
label: "按原料搜索",
// input: true,
select: [],
fieldOptionValue: "name", // 把料仓筛选条件的label改为展示code,而不是展示name
default: { value: "" },
fn: () => this.$http.get("/pms/material/page", { params: { page: 1, limit: 999 } }),
bind: {
placeholder: "请输入原料名",
filterable: true,
},
},
{
prop: "silo",
label: "按料仓搜索",
fieldOptionLabel: "name", // 把料仓筛选条件的label改为展示code,而不是展示name
select: [],
fn: () => this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "0" } }),
bind: {
placeholder: "请选择料仓",
filterable: true,
},
},
{
timerange: true,
prop: "timerange",
label: "时间段",
bind: {
placeholder: "请选择上料时间段",
type: "datetimerange",
"start-placeholder": "开始时间",
"end-placeholder": "结束时间",
},
},
{
button: {
type: "primary",
name: "查询",
},
},
{
button: {
type: "primary",
name: "新增",
permission: "pms:brokeLog:save",
},
bind: {
plain: true,
},
},
];
/**
* dialog config 有两个版本一个适用于 DialogWithMenu 组件另一个适用于 DialogJustForm 组件
* 适用于 DialogWithMenu 组件的配置示例详见 blenderStep/config.js
* 此为后者的配置:
*/
const dialogJustFormConfigs = {
form: {
rows: [
[
{
// input: true,
select: true,
options: [],
label: "原料",
prop: "material",
optionValue: "code",
customLabel: "description",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
// elparams: { placeholder: "请输入原料名称" },
elparams: { filterable: true, placeholder: "请选择原料" },
fetchData: () => this.$http.get("/pms/material/page", { params: { limit: 999, page: 1 } }),
// rules: { required: true, message: "必填项不能为空", trigger: "change" },
},
{
input: true,
label: "计划上料量",
prop: "qty",
rules: [
{ required: true, message: "必填项不能为空", trigger: "blur" },
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
],
elparams: { placeholder: "请输入计划上料量" },
},
{
select: true,
label: "破碎作业",
prop: "statusDictValue",
options: [
{ label: "正常停止", value: 0 },
{ label: "废除", value: "1" },
],
elparams: { placeholder: "破碎作业", filterable: true },
},
{
prop: "silo1",
label: "上料料仓",
select: true,
options: [],
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
fetchData: () =>
this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "0" } }),
elparams: { filterable: true, placeholder: "请选择上料料仓" },
customLabel: "description",
},
],
// [
// {
// prop: "silo2",
// label: "上料料仓2",
// select: true,
// options: [],
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
// fetchData: () =>
// this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "0" } }),
// elparams: { filterable: true, placeholder: "请选择上料料仓2" },
// customLabel: "description",
// },
// {
// prop: "silo3",
// label: "上料料仓3",
// select: true,
// options: [],
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
// fetchData: () =>
// this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "0" } }),
// elparams: { filterable: true, placeholder: "请选择上料料仓3" },
// customLabel: "description",
// },
// ],
// [
// {
// prop: "silo2Change",
// label: "料仓2变化",
// input: true,
// // rules: { required: true, message: "必填项不能为空", trigger: "blur" },
// elparams: { placeholder: "请填写料仓2变化" },
// },
// {
// prop: "silo3Change",
// label: "料仓3变化",
// input: true,
// // rules: { required: true, message: "必填项不能为空", trigger: "blur" },
// elparams: { placeholder: "请填写料仓3变化" },
// },
// ],
[
{
prop: "silo1Change",
label: "料仓变化",
input: true,
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请填写料仓变化" },
},
{
datetime: true,
label: "开始上料时间",
prop: "startTime",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择上料时间", type: "datetime" },
},
{
datetime: true,
label: "结束上料时间",
prop: "endTime",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择上料结束时间", type: "datetime" },
},
{ input: true, label: "描述信息", prop: "description", elparams: { placeholder: "描述信息" } },
],
[
{
forceDisabled: true,
// input: true,
label: "备注",
prop: "remark",
default: "Handload",
elparams: { placeholder: "备注" },
},
],
],
operations: [
{ name: "add", label: "保存", type: "primary", permission: "pms:brokeLog:save", showOnEdit: false },
{ name: "update", label: "更新", type: "primary", permission: "pms:brokeLog:update", showOnEdit: true },
{ name: "reset", label: "重置", type: "warning", showAlways: true },
// { name: 'cancel', label: '取消', showAlways: true },
],
},
};
// 备注:弹窗弹出的时间和网速有关......
return {
dialogConfigs: dialogJustFormConfigs,
tableConfig: {
table: null, // 此处可省略,el-table 上的配置项
column: tableProps, // el-column-item 上的配置项
},
headFormConfigs: {
rules: null, // 名称是由 BaseSearchForm.vue 组件固定的
fields: headFormFields, // 名称是由 BaseSearchForm.vue 组件固定的
},
urls: {
base: "/pms/brokeLog",
// page: "/pms/brokeLog/page",
page: "/pms/brokeLog/pagehand",
// subase: '/pms/blenderStepParam',
// subpage: '/pms/blenderStepParam/page',
// more...
},
};
}

查看文件

@ -0,0 +1,32 @@
<template>
<ListViewWithHead :table-config="tableConfig" :head-config="headFormConfigs" :dialog-configs="dialogConfigs" />
</template>
<script>
import initConfig from './config';
import ListViewWithHead from '@/views/atomViews/ListViewWithHead.vue';
export default {
name: 'ProductionLineView',
components: { ListViewWithHead },
provide() {
return {
urls: this.allUrls
}
},
data() {
const { tableConfig, headFormConfigs, urls, dialogConfigs } = initConfig.call(this);
return {
tableConfig,
headFormConfigs,
allUrls: urls,
dialogConfigs,
};
},
created() {},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

查看文件

@ -508,7 +508,7 @@ export default {
}
} else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => {
this.cachedSearchCondition[key] = cond[key];
this.cachedSearchCondition[key] = payload[key] ? payload[key] : cond[key];
});
}
});

查看文件

@ -18,7 +18,7 @@ export default function () {
prop: "operations",
name: "操作",
fixed: "right",
width: 150,
width: 180,
subcomponent: TableOperaionComponent,
options: [
{ name: "temperature", label: "烧制温度", },
@ -29,15 +29,24 @@ export default function () {
];
const headFormFields = [
// {
// prop: 'code',
// label: "窑车号",
// input: true,
// default: { value: "" },
// bind: {
// placeholder: '请输入窑车号'
// }
// },
{
input: true,
prop: 'code',
label: "窑车号",
default: { value: "" },
bind: {
placeholder: '请输入窑车号'
}
},
{
input: true,
prop: 'orderCode',
label: "订单号",
default: { value: "" },
bind: {
placeholder: '请输入订单号'
}
},
{
timerange: true,
prop: "timerange",

查看文件

@ -4,10 +4,9 @@
:head-config="headFormConfigs"
:dialog-configs="dialogConfigs"
:car-payload-dialog-configs="carPayloadDialogConfigs"
:listQueryExtra="[{ code }]"
:listQueryExtra="[{ code, orderCode: '' }]"
attach-list-query-data="code"
:trigger-update="triggerUpdateKey"
/>
:trigger-update="triggerUpdateKey" />
</template>
<script>
@ -22,11 +21,11 @@ export default {
urls: this.allUrls,
};
},
computed: {
code() {
return this.$route.query.code || "";
},
},
// computed: {
// code() {
// return this.$route.query.code || "0";
// },
// },
data() {
const { tableConfig, headFormConfigs, carPayloadDialogConfigs, urls, dialogConfigs } = initConfig.call(this);
return {
@ -36,9 +35,12 @@ export default {
allUrls: urls,
dialogConfigs,
triggerUpdateKey: "",
code: "",
};
},
activated() {
console.log("activated", this.$route.query)
this.code = this.$route.query.code || "";
this.triggerUpdateKey = Math.random().toString();
},
};

查看文件

@ -5,8 +5,7 @@
:fullscreen="fullscreen"
:visible="visible"
@close="handleClose"
:destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? false">
@closed="$emit('destroy')">
<div slot="title" style="background: #eee; padding: 8px; text-align: center; border-bottom: 1px solid #ccc">
<el-checkbox-group v-model="activeTab" @change="handleTabClick">
<el-checkbox-button :true-label="1">子订单进度</el-checkbox-button>
@ -21,7 +20,7 @@
<SubOrderDetail v-if="activeTab === 1 && order !== null" :order="order" />
<CarDetail v-if="activeTab === 2 && order !== null" :order-id="order.id" :table-layout="carLayoutKey" />
<TrayDetail v-if="activeTab === 3" />
<OrderDetailWrapper v-if="activeTab === 4" :order="order" :order-detail-configs="configs" />
<OrderDetailWrapper v-if="activeTab === 4" :order="order" />
</transition>
<!-- footer -->
@ -41,10 +40,6 @@ export default {
name: "DialogWithMenu--OrderVersion",
components: { CarDetail, OrderDetailWrapper, SubOrderDetail, TrayDetail },
props: {
configs: {
type: Object,
default: () => null,
},
fullscreen: {
type: Boolean,
default: true,
@ -102,10 +97,6 @@ export default {
handleClose() {
this.visible = false;
setTimeout(() => {
this.$emit("destroy-dialog");
}, 200);
},
},
};

查看文件

@ -26,11 +26,9 @@
<DialogWithMenu
ref="edit-dialog"
v-if="!!dialogConfigs && dialogVisible"
:configs="dialogConfigs"
v-if="dialogVisible"
@refreshDataList="getList"
@destroy-dialog="dialogVisible = false" />
<!-- :dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" /> -->
@destroy="dialogVisible = false" />
</div>
</template>

查看文件

@ -1,7 +1,7 @@
<template>
<div style="height: 100%;">
<el-skeleton v-show="orderNotReady" />
<OrderDetail v-show="!orderNotReady" ref="order-detail-tag" :configs="orderDetailConfigs" @detail-loaded="orderNotReady = false" />
<OrderDetail v-show="!orderNotReady" ref="order-detail-tag" @detail-loaded="orderNotReady = false" />
</div>
</template>
@ -12,10 +12,6 @@ export default {
name: "OrderDetailWrapper",
components: { OrderDetail },
props: {
orderDetailConfigs: {
type: Object,
default: () => null,
},
order: {
type: Object,
default: () => null

查看文件

@ -5,8 +5,7 @@
:fullscreen="fullscreen"
:visible="visible"
@close="handleClose"
:destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? false">
@closed="$emit('destroy')">
<div slot="title" style="background: #eee; padding: 8px; text-align: center; border-bottom: 1px solid #ccc">
<el-checkbox-group v-model="activeTab" @change="handleTabClick">
<el-checkbox-button :true-label="1">子订单进度</el-checkbox-button>
@ -21,7 +20,7 @@
<SubOrderDetail v-if="activeTab === 1 && order !== null" :order="order" />
<CarDetail v-if="activeTab === 2 && order !== null" :order-id="order.id" :table-layout="carLayoutKey" />
<TrayDetail v-if="activeTab === 3" />
<OrderDetailWrapper v-if="activeTab === 4" :order="order" :order-detail-configs="configs" />
<OrderDetailWrapper v-if="activeTab === 4" :order="order" />
</transition>
<!-- footer -->
@ -41,10 +40,6 @@ export default {
name: "DialogWithMenu--OrderVersion",
components: { CarDetail, OrderDetailWrapper, SubOrderDetail, TrayDetail },
props: {
configs: {
type: Object,
default: () => null,
},
fullscreen: {
type: Boolean,
default: true,
@ -102,10 +97,6 @@ export default {
handleClose() {
this.visible = false;
setTimeout(() => {
this.$emit("destroy-dialog");
}, 200);
},
},
};

查看文件

@ -32,13 +32,12 @@
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<DialogJustForm
<OrderEditDialog
modal-append-to-body
ref="order-dialog"
v-if="renderDialog"
fullscreen
:configs="dialogConfig"
@destroy-dialog="renderDialog = false"
@destroy="renderDialog = false"
@refreshDataList="getAList(Object.assign({}, listQuery, extraSearchConditions, params))" />
<DialogWithMenu
@ -46,8 +45,7 @@
ref="menu-dialog"
v-if="renderMenuDialog"
fullscreen
:configs="dialogConfig"
@destroy-dialog="renderMenuDialog = false"
@destroy="renderMenuDialog = false"
@refreshDataList="getAList(Object.assign({}, listQuery, extraSearchConditions, params))" />
<DialogUpload
@ -69,15 +67,16 @@
import BaseListTable from "./BaseListTable.vue";
import BaseSearchForm from "./BaseSearchForm.vue";
import DialogJustForm from "./DialogJustForm.vue";
import DialogWithMenu from "./DialogWithMenu.vue";
import DialogUpload from "@/components/DialogUpload.vue";
import moment from "moment";
import Overlay from "@/components/Overlay.vue";
import OrderEditDialog from "./order--edit.vue";
import DialogWithMenu from "./DialogWithMenu.vue";
// const dictList = JSON.parse(localStorage.getItem("dictList"));
export default {
name: "ListSectionWithHead",
components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm, DialogUpload, Overlay },
components: { OrderEditDialog, BaseSearchForm, DialogWithMenu, BaseListTable, DialogJustForm, DialogUpload, Overlay },
props: {
headConfig: {
type: Object,
@ -86,6 +85,10 @@ export default {
form: null,
}),
},
dialogConfig: {
type: Object,
default: null,
},
tableConfig: {
type: Object,
default: () => ({
@ -93,10 +96,6 @@ export default {
column: null,
}),
},
dialogConfig: {
type: Object,
default: null,
},
pageUrl: {
type: String,
default: "#",
@ -111,11 +110,6 @@ export default {
required: true,
},
},
computed: {
dialogType() {
return this.dialogConfigs.menu ? DIALOG_WITH_MENU : DIALOG_JUST_FORM;
},
},
watch: {
refreshKey(newVal) {
//

查看文件

@ -0,0 +1,901 @@
<template>
<el-dialog
class="order--edit_dialog"
:fullscreen="fullscreen"
:visible="visible"
@close="handleClose"
@closed="$emit('destroy')"
:close-on-click-modal="false"
v-loading="optionsLoading || formLoading">
<div slot="title" class="dialog-title">
<h2 class="">
{{ mode.includes("detail") ? "查看详情" : dataForm.id ? "修改订单" : "新增订单" }}
</h2>
</div>
<!-- form -->
<el-form ref="dataForm" :model="dataForm" size="small">
<InputsArea title="生产订单">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="订单状态" prop="statusDictValue" :rules="null">
<span style="display: block; margin-top: 32px">
{{ ["等待", "确认", "生产", "暂停", "结束", "接受", "拒绝", "已下发"][dataForm.statusDictValue] }}
</span>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="订单号"
prop="code"
:rules="{ required: true, message: '必填项不能为空', trigger: 'blur' }">
<el-input
v-model="dataForm.code"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入订单号' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="订单子号"
prop="cate"
:rules="[
{ required: true, message: '必填项不能为空', trigger: 'blur' },
{
type: 'number',
message: '输入正确的数字类型',
trigger: 'blur',
transform: (val) => Number(val),
},
]">
<el-input
v-model="dataForm.cate"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入订单子号' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="计划开始时间"
prop="planStartTime"
:rules="{ required: true, message: '必填项不能为空', trigger: 'blur' }">
<el-date-picker
v-model="dataForm.planStartTime"
v-bind="{
placeholder: '选择计划开始时间',
type: 'datetime',
'value-format': 'yyyy-MM-ddTHH:mm:ss',
}"
:disabled="mode.includes('detail')"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
</InputsArea>
<InputsArea title="设备与参数">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item
label="压机"
prop="press"
:rules="{ required: true, message: '必填项不能为空', trigger: 'blur' }">
<el-select
v-model="dataForm.press"
filterable
clearable
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '选择压机', filterable: true }">
<el-option
v-for="opt in pressOptions"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value">
<span>{{ opt.label }}</span>
<span
v-if="requestList[0].extraLabel"
style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ opt.code }}
</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="混料机号"
prop="blender"
:rules="{ required: true, message: '必填项不能为空', trigger: 'blur' }">
<el-select
v-model="dataForm.blender"
filterable
clearable
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '选择混料机', filterable: true }">
<el-option
v-for="opt in blenderOptions"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value">
<span>{{ opt.label }}</span>
<span
v-if="requestList[1].extraLabel"
style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ opt.code }}
</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="隧道窑号" prop="kiln" :rules="null">
<el-select
v-model="dataForm.kiln"
filterable
clearable
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '选择隧道窑', filterable: true }">
<el-option
v-for="opt in kilnOptions"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value">
<span>{{ opt.label }}</span>
<span
v-if="requestList[2].extraLabel"
style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ opt.code }}
</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="Add on" prop="sapParam1" :rules="null">
<el-input
v-model="dataForm.sapParam1"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入addon' }"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="配方号" prop="bomId" :rules="null">
<el-select
v-model="dataForm.bomId"
filterable
clearable
:disabled="mode.includes('detail')"
@change="handleBomChange"
v-bind="{ placeholder: '选择配方号', filterable: true }">
<el-option
v-for="opt in bomOptions"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value"
style="display: flex; align-items: center">
<span style="display: inline-block; width: 128px; text-overflow: ellipsis">{{ opt.label }}</span>
<span
v-if="requestList[3].extraLabel"
style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ opt.name }}
</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="牌号" prop="brand" :rules="null">
<span style="display: block; margin-top: 32px">{{ dataForm.brand }}</span>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="版本号" prop="ai" :rules="null">
<!-- <span style="display: block; margin-top: 32px">{{ dataForm.ai }}</span> -->
<el-select
v-model="dataForm.ai"
filterable
clearable
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '请选择版本' }"
@change="handleVersionChange">
<el-option
v-for="opt in versionList"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value">
<span>{{ opt.label }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="包装代码" prop="packTech" :rules="null">
<el-select
v-model="dataForm.packTech"
filterable
clearable
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '选择包装代码', filterable: true }">
<el-option
v-for="opt in packOptions"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value">
<span>{{ opt.label }}</span>
<span
v-if="requestList[4].extraLabel"
style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ opt.code }}
</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="物料" prop="productId" :rules="null">
<el-select
v-model="dataForm.productId"
filterable
clearable
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '选择物料', filterable: true }">
<el-option
v-for="opt in productOptions"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value">
<span>{{ opt.label }}</span>
<span
v-if="requestList[5].extraLabel"
style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ opt.code }}
</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="砖型" prop="shape" :rules="null">
<el-select
v-model="dataForm.shape"
filterable
clearable
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '选择砖型', filterable: true }">
<el-option
v-for="opt in shapeOptions"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value">
<span>{{ opt.label }}</span>
<span
v-if="requestList[6].extraLabel"
style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ opt.code }}
</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="烧成温度"
prop="sapParam6"
:rules="[
{ required: true, message: '必填项不能为空', trigger: 'blur' },
{
type: 'number',
message: '输入正确的数字类型',
trigger: 'blur',
transform: (val) => Number(val),
},
]">
<el-input
v-model="dataForm.sapParam6"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入烧成温度' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="烧成时间 H"
prop="sapParam7"
:rules="[
{ required: true, message: '必填项不能为空', trigger: 'blur' },
{
type: 'number',
message: '输入正确的数字类型',
trigger: 'blur',
transform: (val) => Number(val),
},
]">
<el-input
v-model="dataForm.sapParam7"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入烧成时间' }"></el-input>
</el-form-item>
</el-col>
</el-row>
</InputsArea>
<InputsArea title="其他">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="生产订单类型" prop="specifications" :rules="null">
<el-input
v-model="dataForm.specifications"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入生产订单类型' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="生产订单砖数"
prop="prodqty"
:rules="[
{ required: true, message: '必填项不能为空', trigger: 'blur' },
{
type: 'number',
message: '输入正确的数字类型',
trigger: 'blur',
transform: (val) => Number(val),
},
]">
<el-input
v-model="dataForm.prodqty"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入要求生产的数量' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="已生产数"
prop="yieldqty"
:rules="[
{
type: 'number',
message: '输入正确的数字类型',
trigger: 'blur',
transform: (val) => Number(val),
},
]">
<el-input
v-model="dataForm.yieldqty"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入已经生产的数量' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="托盘码放砖数"
prop="pcsKilnCar"
:rules="[
{ required: true, message: '必填项不能为空', trigger: 'blur' },
{
type: 'number',
message: '输入正确的数字类型',
trigger: 'blur',
transform: (val) => Number(val),
},
]">
<el-input
v-model="dataForm.pcsKilnCar"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入托盘码放砖数' }"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="6">
<el-form-item
label="销售订单号"
prop="saleNo"
:rules="{ required: true, message: '必填项不能为空', trigger: 'blur' }">
<el-input
v-model="dataForm.saleNo"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入销售订单号' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="销售订单item号" prop="saleOrderItem" :rules="null">
<el-input
v-model="dataForm.saleOrderItem"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入销售订单item号' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="销售订单砖数"
prop="soqty"
:rules="[
{ required: true, message: '必填项不能为空', trigger: 'blur' },
{
type: 'number',
message: '输入正确的数字类型',
trigger: 'blur',
transform: (val) => Number(val),
},
]">
<el-input
v-model="dataForm.soqty"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '输入销售订单砖数' }"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item
label="销售时间"
prop="deliveryTime"
:rules="{ required: true, message: '必填项不能为空', trigger: 'blur' }">
<el-date-picker
v-model="dataForm.deliveryTime"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '选择销售时间' }"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="6">
<el-form-item
label="客户"
prop="customerId"
:rules="{ required: true, message: '必填项不能为空', trigger: 'blur' }">
<el-select
v-model="dataForm.customerId"
filterable
clearable
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '选择客户' }">
<el-option
v-for="opt in clientOptions"
:key="opt.label + opt.value"
:label="opt.label"
:value="opt.value">
<span>{{ opt.label }}</span>
<span
v-if="requestList[7].extraLabel"
style="display: inline-block; margin-left: 12px; font-size: 0.9em">
{{ opt.name }}
</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="物料号销售文本" prop="shortDesc" :rules="null">
<span style="display: block; margin-top: 32px">{{ dataForm.shortDesc }}</span>
</el-form-item>
</el-col>
<el-col :span="6"></el-col>
<el-col :span="6"></el-col>
</el-row>
<el-row :gutter="20">
<el-col>
<el-form-item label="备注" prop="remark" :rules="null">
<el-input
v-model="dataForm.remark"
:disabled="mode.includes('detail')"
v-bind="{ placeholder: '备注' }"></el-input>
</el-form-item>
</el-col>
</el-row>
</InputsArea>
</el-form>
<!-- footer -->
<div slot="footer">
<!-- TODO: permission 相关内容 未添加 -->
<el-button v-if="mode.includes('create')" type="primary" @click="handleSave('POST')" :loading="btnLoading">
保存
</el-button>
<el-button v-if="mode.includes('edit')" type="primary" @click="handleSave('PUT')" :loading="btnLoading">
更新
</el-button>
<el-button v-if="mode.includes('reset')" type="warning" @click="handleReset">重置</el-button>
<el-button @click="handleClose">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { pick as __pick } from "@/utils/filters";
// import moment from "moment";
import InputsArea from "./InputsArea.vue";
export default {
name: "DialogJustForm",
components: { InputsArea },
props: {
fullscreen: {
type: Boolean,
default: false,
},
},
inject: ["urls"],
data() {
return {
mode: "#edit#reset",
formLoading: false,
optionsLoading: false,
pressOptions: [], //
blenderOptions: [], //
kilnOptions: [], //
bomOptions: [], //
packOptions: [], //
productOptions: [], //
shapeOptions: [], //
clientOptions: [], //
versionList: [], //
cachedList: {}, //
dataForm: {
statusDictValue: null,
code: null,
cate: null,
planStartTime: null,
press: null,
blender: null,
kiln: null,
sapParam1: null,
bomId: null,
brand: null, //
ai: null, //
packTech: null,
productId: null,
shape: null,
sapParam6: null,
sapParam7: null,
specifications: null,
prodqty: null,
yieldqty: null,
pcsKilnCar: null,
saleNo: null,
saleOrderItem: null,
soqty: null,
deliveryTime: null,
customerId: null,
shortDesc: null,
remark: null,
},
visible: false,
requestList: [
{
url: "/pms/equipment/search",
params: {
equipmentTypeCode: "Press",
},
method: "get",
target: "pressOptions",
label: "code",
},
{
url: "/pms/equipment/search",
params: {
equipmentTypeCode: "Mix",
},
method: "get",
target: "blenderOptions",
label: "code",
},
{
url: "/pms/equipment/search",
params: {
equipmentTypeCode: "Kiln",
},
method: "get",
target: "kilnOptions",
label: "code",
},
{
url: "/pms/bom/page",
params: {
limit: 999,
page: 1,
key: "",
externalCode: "",
},
method: "get",
target: "bomOptions",
label: "code",
extraLabel: "name",
cache: true,
},
{
url: "/pms/equipmentTech/pageView",
params: {
limit: 999,
page: 1,
key: "",
shape: "",
wsId: 5,
},
method: "post",
target: "packOptions",
label: "code",
},
{
url: "/pms/product/page",
params: {
limit: 999,
page: 1,
key: "",
},
method: "get",
target: "productOptions",
label: "code",
},
{
url: "/pms/shape/page",
params: {
limit: 999,
page: 1,
key: "",
},
method: "get",
target: "shapeOptions",
label: "code",
},
{
url: "/pms/customer/page",
params: {
limit: 999,
page: 1,
name: "",
},
method: "get",
target: "clientOptions",
label: "name",
},
],
promiseList: [],
bomId: null,
btnLoading: false,
};
},
methods: {
/**
* 打开弹窗后准备下拉选项数据
* 复用方式
* 1. data 里定义 requestList
* 2. 复制本方法到组件中去
* 3. requestList 参考上面的 data
*/
async prepareSelectOptions() {
this.optionsLoading = true;
this.requestList.forEach((req) => {
this.promiseList.push(async () => {
const { data: res } = await this.$http[req.method](
req.url,
req.method.toLowerCase() == "post" ? req.params : { params: req.params }
);
if (res.code == 0) {
if ("list" in res.data) {
// target
if (req.cache) this.cachedList[req.target.replace(/options/i, "")] = res.data.list;
this[req.target] = res.data.list.map((item) =>
req.extraLabel
? {
[req.extraLabel]: item[req.extraLabel],
label: item[req.label],
value: item.id,
}
: {
label: item[req.label],
value: item.id,
}
);
} else if (Array.isArray(res.data)) {
if (req.cache) this.cachedList[req.target.replace(/options/i, "")] = res.data;
this[req.target] = res.data.map((item) =>
req.extraLabel
? {
[req.extraLabel]: item[req.extraLabel],
label: item[req.label],
value: item.id,
}
: {
label: item[req.label],
value: item.id,
}
);
}
}
});
});
try {
await Promise.all(this.promiseList.map((fn) => fn()));
} catch (err) {
this.$message.error("获取数据失败,请刷新页面重试");
this.optionsLoading = false;
}
this.optionsLoading = false;
},
/**
* 向这种select上的监听事件
* 不自动生成
* 因为每个页面也许有独立的需求链
*/
handleBomChange(bomID) {
console.log("[handleBomChange] val is: ", bomID);
const target = this.cachedList.bom.find((item) => item.id === bomID);
// bomId dataForm
this.bomId = bomID;
this.getBomVersionList(target);
this.$set(this.dataForm, "brand", target.name);
this.$set(this.dataForm, "ai", target.version);
},
async getBomVersionList(bom) {
try {
const { data: res } = await this.$http.get("/pms/bom/pageVersion", { params: { key: bom.code } });
console.log("[bom version list]", res.data.list);
this.versionList = res.data.list.map((item) => ({
label: item.version,
value: item.version,
id: item.id,
}));
} catch (err) {
this.$message.error("获取数据失败,请刷新页面重试");
}
},
/**
* 版本 变化更新 bomList
* @param {*} v
*/
handleVersionChange(v) {
const targetBom = this.versionList.find((item) => item.value === v);
// this.bomId this.dataForm.bomId
this.bomId = targetBom.id;
console.log("[handleVersionChange] new bomID", this.bomId);
},
async init(id, detail_mode) {
this.visible = true;
this.mode = detail_mode ? "#detail" : id ? "#edit#reset" : "#create#reset";
await this.prepareSelectOptions();
if (this.$refs.dataForm) {
this.$refs.dataForm.clearValidate();
}
this.$nextTick(() => {
this.dataForm.id = id || null;
if (this.dataForm.id) {
//
this.formLoading = 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));
} else {
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 1500,
});
}
this.formLoading = false;
})
.catch((err) => {
this.formLoading = false;
this.$message({
message: `${err}`,
type: "error",
duration: 1500,
});
});
} else {
//
this.formLoading = false;
}
});
},
/** handlers */
handleSelectChange(col, eventValue) {
this.$forceUpdate();
},
handleSave(method = "POST") {
this.$refs.dataForm.validate(async (valid) => {
if (valid) {
this.btnLoading = true;
try {
const { data: res } = await this.$http({
url: this.urls.base,
method,
data: {
...this.dataForm,
bomId: this.bomId != null ? this.bomId : this.dataForm.bomId,
brand: null, // BOM ID
ai: null, // BOM ID
},
});
console.log("herer.......", res);
if (res && res.code == 0) {
this.$message.success("添加成功");
this.$emit("refreshDataList");
this.handleClose();
this.btnLoading = false;
} else {
throw new Error("请求出错");
}
} catch (err) {
this.$message.error("参数错误:" + "msg" in err ? err.msg : err);
this.btnLoading = false;
}
}
});
},
handleReset() {
this.bomId = null;
Object.keys(this.dataForm).forEach((k) => {
this.dataForm[k] = null;
});
},
handleClose() {
this.visible = false;
},
},
};
</script>
<style scoped>
.order--edit_dialog >>> .el-dialog {
display: flex;
flex-direction: column;
overflow: hidden;
border-radius: 12px;
}
.order--edit_dialog >>> .el-dialog__header {
padding: 0 20px 0;
/* background: linear-gradient(to bottom, #eee, #ccc, #eee); */
background: #eeec;
border-bottom: 1px solid #dddc;
}
.order--edit_dialog >>> .el-dialog__body {
/* padding-top: 16px !important;
padding-bottom: 16px !important; */
/* transform: scale(0.95); */
padding-top: 24px !important;
padding-bottom: 0 !important;
flex: 1;
overflow-y: auto;
}
.order--edit_dialog >>> .el-dialog__footer {
border-top: 1px solid #dddc;
background-color: #eeec;
padding: 10px 20px;
}
.el-select,
.el-cascader,
.el-date-editor {
width: 100% !important;
}
.h0 {
height: 0;
width: 0;
}
</style>

查看文件

@ -1,7 +1,7 @@
<template>
<div style="height: 100%;">
<el-skeleton v-show="orderNotReady" />
<OrderDetail v-show="!orderNotReady" ref="order-detail-tag" :configs="orderDetailConfigs" @detail-loaded="orderNotReady = false" />
<OrderDetail v-show="!orderNotReady" ref="order-detail-tag" @detail-loaded="orderNotReady = false" />
</div>
</template>
@ -12,10 +12,6 @@ export default {
name: "OrderDetailWrapper",
components: { OrderDetail },
props: {
orderDetailConfigs: {
type: Object,
default: () => null,
},
order: {
type: Object,
default: () => null

查看文件

@ -12,7 +12,7 @@ export default function () {
// { prop: "specifications", label: "规格" },
// { prop: "unitDictValue", label: "单位", filter: dictFilter("unit") },
{ prop: "weight", label: "重量", filter: (val) => (val ? val + " kg" : "-") },
{ prop: "processTime", label: "产线完成单位产品用时", width: 200, filter: (val) => val + " (分钟)" },
// { prop: "processTime", label: "产线完成单位产品用时", width: 200, filter: (val) => val + " (分钟)" },
{ prop: "remark", label: "备注" },
{
prop: "description",
@ -62,8 +62,8 @@ export default function () {
permission: "pms:product:save",
},
bind: {
plain: true
}
plain: true,
},
},
{
button: {
@ -72,8 +72,8 @@ export default function () {
permission: "",
},
bind: {
plain: true
}
plain: true,
},
},
];
@ -106,6 +106,16 @@ export default function () {
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入物料编码" },
},
{
input: true,
label: "重量",
prop: "weight",
rules: [
{ required: true, message: "必填项不能为空", trigger: "blur" },
{ type: "number", message: "请输入数字类型", trigger: "blur", transform: (val) => Number(val) },
],
elparams: { placeholder: "请输入重量" },
},
// { input: true, label: '版本号', prop: 'version', elparams: { placeholder: '请输入版本号' } },
// {
// select: true,
@ -118,7 +128,7 @@ export default function () {
// elparams: { placeholder: "选择一个物料类型" },
// },
],
[
// [
// { input: true, label: '单位平方数', prop: 'code', rules: { required: true, message: '必填项不能为空', trigger: 'blur' }, elparams: { placeholder: '请输入设备名称编码' } },
// {
// select: true,
@ -137,27 +147,17 @@ export default function () {
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
// elparams: { placeholder: "请输入规格" },
// },
{
input: true,
label: "产线完成单位产品用时",
prop: "processTime",
rules: [
{ required: true, message: "必填项不能为空", trigger: "blur" },
{ type: 'number', message: "请输入数字类型", trigger: "blur", transform: val => Number(val) }
],
elparams: { placeholder: "请输入规格" },
},
{
input: true,
label: "重量",
prop: "weight",
rules: [
{ required: true, message: "必填项不能为空", trigger: "blur" },
{ type: 'number', message: "请输入数字类型", trigger: "blur", transform: val => Number(val) }
],
elparams: { placeholder: "请输入重量" },
},
],
// {
// input: true,
// label: "产线完成单位产品用时",
// prop: "processTime",
// rules: [
// { required: true, message: "必填项不能为空", trigger: "blur" },
// { type: 'number', message: "请输入数字类型", trigger: "blur", transform: val => Number(val) }
// ],
// elparams: { placeholder: "请输入规格" },
// },
// ],
[{ textarea: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
],
operations: [
@ -239,7 +239,7 @@ export default function () {
subase: "/pms/productArrt",
subpage: "/pms/productArrt/page",
importUrl: "/pms/product/import",
templateUrl: '/importTemplates/productImport.xlsx'
templateUrl: "/importTemplates/productImport.xlsx",
},
};
}