add 新增载砖弹窗

Cette révision appartient à :
lb 2023-03-24 10:51:13 +08:00
Parent 5917223e55
révision 05297626a0
4 fichiers modifiés avec 632 ajouts et 24 suppressions

Voir le fichier

@ -344,7 +344,7 @@ export default {
console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]);
},
addOrUpdate(method = "POST") {
addOrUpdate(method = "POST", url) {
if ("parentId" in this.dataForm) {
console.log("[DialogJustForm parentId]", this.dataForm.parentId);
// parentId cascader ["xxx"]xxx
@ -388,7 +388,8 @@ export default {
/** 发送 */
return this.$http({
url: this.urls.formUrl ? this.urls.formUrl : this.urls.base,
// url: this.urls.formUrl ? this.urls.formUrl : this.urls.base,
url: url ?? this.urls.base,
method,
data: httpPayload,
})
@ -432,6 +433,15 @@ export default {
case "update":
this.addOrUpdate(payload.name === "add" ? "POST" : "PUT");
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属性");

Voir le fichier

@ -0,0 +1,540 @@
<!-- 表格页加上搜索条件 -->
<template>
<div class="list-view-with-head">
<!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> -->
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
<BaseListTable
v-loading="tableLoading"
:table-config="tableConfig.table"
:column-config="tableConfig.column"
:table-data="dataList"
@operate-event="handleOperate"
:current-page="page"
:current-size="size"
:refresh-layout-key="refreshLayoutKey"
/>
<el-pagination
class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[1, 5, 10, 20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
<DialogJustForm
ref="edit-dialog"
key="edit-dialog"
v-if="!!dialogConfigs"
:dialog-visible.sync="dialogVisible"
:configs="dialogConfigs"
@refreshDataList="getList"
/>
<DialogJustForm
ref="car-payload-add-dialog"
key="car-payload-add-dialog"
v-if="!!carPayloadAddConfigs"
:dialog-visible.sync="carPayloadAddVisible"
:configs="carPayloadAddConfigs"
@refreshDataList="getList"
/>
<DialogCarPayload
ref="car-payload-dialog"
key="car-payload-dialog"
v-if="!!carPayloadDialogConfigs"
:dialog-visible.sync="carPayloadDialogVisible"
:configs="carPayloadDialogConfigs"
@refreshDataList="getList"
/>
</div>
</template>
<script>
import BaseListTable from "@/components/BaseListTable.vue";
import BaseSearchForm from "@/components/BaseSearchForm.vue";
import DialogWithMenu from "@/components/DialogWithMenu.vue";
import DialogJustForm from "@/components/DialogJustForm.vue";
import DialogCarPayload from "@/components/DialogCarPayload.vue";
import moment from "moment";
const DIALOG_WITH_MENU = "DialogWithMenu";
const DIALOG_JUST_FORM = "DialogJustForm";
const DIALOG_CARPAYLOAD = "DialogCarPayload";
export default {
name: "ListViewWithHead",
components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm, DialogCarPayload },
props: {
tableConfig: {
type: Object,
default: () => ({
/** 列配置, 即 props **/ column: [],
/** 表格整体配置 */ table: undefined,
}),
},
headConfig: {
type: Object,
default: () => ({}),
},
/** 请求page接口的时候有些字段是必填的没有会报500把相关字段名传入这个prop: */
listQueryExtra: {
type: Array,
default: () => ["key"],
},
attachListQueryExtra: {
// listQueryExtra
type: String,
default: "",
},
initDataWhenLoad: { type: Boolean, default: true },
/** dialog configs 或许可以从 tableConfig 计算出来 computed... */
dialogConfigs: {
type: Object,
default: () => null,
},
carPayloadDialogConfigs: {
type: Object,
default: () => null,
},
carPayloadAddConfigs: {
type: Object,
default: () => null,
},
triggerUpdate: {
type: String,
default: "",
},
},
computed: {
dialogType() {
return this.dialogConfigs.menu ? DIALOG_WITH_MENU : DIALOG_JUST_FORM;
},
},
activated() {
console.log("list view with ehad activated..........", this.triggerUpdate);
this.refreshLayoutKey = this.layoutTable();
},
watch: {
triggerUpdate(val, oldVal) {
if (val && val !== oldVal) {
// get list
this.page = 1;
this.size = 20;
this.getList();
}
},
},
data() {
return {
DIALOG_WITH_MENU,
DIALOG_JUST_FORM,
DIALOG_CARPAYLOAD,
dialogVisible: false,
carPayloadDialogVisible: false,
carPayloadAddVisible: false,
topBtnConfig: null,
totalPage: 100,
page: 1,
size: 20, // 20
dataList: [],
tableLoading: false,
refreshLayoutKey: null,
};
},
inject: ["urls"],
mounted() {
this.initDataWhenLoad && this.getList();
},
methods: {
/** 获取 列表数据 */
getList(queryParams) {
this.tableLoading = true;
const params = queryParams
? { ...queryParams, page: this.page, limit: this.size }
: {
page: this.page,
limit: this.size,
};
if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) {
this.listQueryExtra.map((nameOrObj) => {
if (typeof nameOrObj === "string") params[nameOrObj] = "";
else if (typeof nameOrObj === "object") {
Object.keys(nameOrObj).forEach((key) => {
params[key] = nameOrObj[key];
});
}
});
}
this.$http[this.urls.pageIsPostApi ? "post" : "get"](
this.urls.page,
this.urls.pageIsPostApi
? {
...params,
}
: {
params,
}
)
.then(({ data: res }) => {
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 (Array.isArray(res.data)) {
this.dataList = res.data
this.totalPage = null;
} else {
this.dataList.splice(0);
this.totalPage = 0;
}
} else {
this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 2000,
});
}
this.tableLoading = false;
})
.catch((err) => {
this.$message({
message: `${err}`,
type: "error",
duration: 2000,
});
this.tableLoading = false;
});
},
layoutTable() {
return Math.random();
},
/** 处理 表格操作 */
handleOperate({ type, data }) {
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-blender-batch-details": {
// this.$router.push({
// name: "pms-blenderBatchDetails",
// query: {
// batchId: data,
// },
// });
// break;
// }
// case "status": {
// console.log("status", data);
// // TODO:
// const { id, code } = data;
// const queryCondition = { id, code };
// if ("enabled" in data) queryCondition.enabled = data["enabled"];
// if ("status" in data) queryCondition.status = data["status"];
// // id code enabled
// this.$http.put(this.urls.base, queryCondition).then(({ data: res }) => {
// if (res.code === 0) {
// // do nothing
// } else {
// this.$message({
// message: `${res.code}: ${res.msg}`,
// type: "error",
// duration: 1500,
// });
// }
// });
// break;
// }
// case "view-attachment": {
// this.openDialog(data, false, { key: "attachment" });
// break;
// }
// case "view-recipe": {
// this.openDialog(data, true, { key: "attr" });
// break;
// }
// case "to-bom-detail": {
// // console.log('to-bom-detail', data.name)
// //
// return this.$router.push({
// name: "pms-bomDetails",
// query: {
// name: data.name,
// },
// });
// }
// case "copy": {
// return this.$http
// .post(this.urls.copyUrl, data, {
// headers: {
// "Content-Type": "application/json",
// },
// })
// .then(({ data: res }) => {
// if (res.code === 0) {
// this.$message({
// message: "!",
// type: "success",
// duration: 1500,
// });
// this.getList();
// } else {
// this.$message({
// message: `${res.code}: ${res.msg}`,
// type: "error",
// duration: 1500,
// });
// }
// })
// .catch((errMsg) => {
// this.$message({
// message: errMsg,
// type: "error",
// duration: 1500,
// });
// });
// }
// case "change-category": {
// return this.$http.put(this.urls.base, data).then(({ data: res }) => {
// if (res.code === 0) {
// this.$message({
// message: "",
// type: "success",
// duration: 1500,
// onClose: () => {
// this.getList();
// },
// });
// } else {
// this.$message({
// message: `${res.code}: ${res.msg}`,
// type: "error",
// duration: 1500,
// });
// }
// });
// }
// case "preview": {
// console.log("[PREVIEW] data", data);
// // report preview
// return this.$router.push({
// name: "pms-reportPreview",
// query: {
// name: data.name,
// },
// });
// }
// case "design": {
// console.log("[DESIGN] data", data);
// // report design
// return this.$router.push({
// name: "pms-reportDesign",
// query: {
// name: data.name,
// },
// });
// }
// case "detach": {
// return this.$http
// .post(this.urls.detach, 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();
// },
// });
// } else {
// this.$message({
// message: `${res.code}: ${res.msg}`,
// type: "error",
// duration: 1500,
// });
// }
// });
// }
case "to-car-history": {
return this.$router.push({
name: "pms-carHistory",
query: {
code: data.code,
},
});
}
case "to-car-payload": {
// open dialog instead of redirect to a new page
this.openCarPayloadDialog(data);
break;
}
case "edit-payload": {
this.openCarPayloadAddDialog(data);
break;
}
}
},
openCarPayloadDialog(id) {
this.carPayloadDialogVisible = true;
this.$nextTick(() => {
this.$refs["car-payload-dialog"].init(id);
});
},
openCarPayloadAddDialog(id) {
this.carPayloadAddVisible = true;
this.$nextTick(() => {
this.$refs["car-payload-add-dialog"].init(null, null, null, { hisId: id });
});
},
handleBtnClick({ btnName, payload }) {
console.log("[search] form handleBtnClick", btnName, payload);
switch (btnName) {
case "新增":
this.openDialog();
break;
case "手动添加": {
this.openDialog();
return;
}
case "查询": {
const params = {};
if (typeof payload === "object") {
// BaseSearchForm
Object.assign(params, payload);
if ("timerange" in params) {
if (!!params.timerange) {
const [startTime, endTime] = params["timerange"];
params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
}
delete params.timerange;
}
}
/** 处理 listQueryExtra 里的数据 */
this.listQueryExtra?.map((cond) => {
if (typeof cond === "string") {
if (!!payload[cond]) {
params[cond] = payload[cond];
} else {
params[cond] = "";
}
} else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => {
params[key] = cond[key];
});
}
});
console.log("查询", params);
this.getList(params);
break;
}
case "同步":
this.$http.post(this.urls.syncUrl).then(({ data: res }) => {
if (res.code === 0) {
this.getList();
}
});
break;
}
},
/** 导航器的操作 */
handleSizeChange(val) {
// val
this.page = 1;
this.size = val;
this.getList();
},
handlePageChange(val) {
// val
this.getList();
},
/** 打开对话框 */
openDialog(row_id, detail_mode, tag_info) {
this.dialogVisible = true;
let extraParams = null;
if (this.attachListQueryExtra && this.listQueryExtra.length) {
this.listQueryExtra.forEach((item) => {
let found = item[this.attachListQueryExtra];
if (found !== null && found !== undefined) extraParams = item;
});
}
this.$nextTick(() => {
console.log(`[edit-dialog] extraParams: ${extraParams}`);
this.$refs["edit-dialog"].init(/** some args... */ row_id, detail_mode, tag_info, extraParams);
});
},
},
};
</script>
<style scoped>
.list-view-with-head {
background: white;
/* height: 100%; */
min-height: inherit;
border-radius: 6px;
padding: 16px;
box-shadow: 0 0 1.125px 0.125px rgba(0, 0, 0, 0.125);
}
</style>

Voir le fichier

@ -2,6 +2,7 @@ import TableOperaionComponent from "@/components/noTemplateComponents/operationC
import request from "@/utils/request";
import { timeFilter } from '@/utils/filters'
import { getDictDataList } from '@/utils'
export default function () {
const tableProps = [
@ -78,24 +79,14 @@ export default function () {
fetchData: () => this.$http.get('/pms/car/page', { params: { limit: 999, page: 1, code: '' } }),
optionLabel: 'code',
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择窑车" },
elparams: { filterable: true, placeholder: "请选择窑车" },
},
{
select: true,
label: "位置",
prop: "pos",
// options: [
// { id: 0, value: 0 },
// { id: 1, value: 1 },
// { id: 2, value: 2 },
// { id: 3, value: 3 },
// { id: 4, value: 4 },
// { id: 5, value: 5 },
// { id: 6, value: 6 },
// { id: 7, value: 7 },
// ],
options: [],
fetchData: () => this.$http.post('/pms/carHandle/listPos', { limit: 999, page: 1 }),
fetchData: () => this.$http.post('/pms/carHandle/listPos', { limit: 999, page: 1, pos: [1, 7] }),
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择窑车位置" },
},
@ -112,6 +103,7 @@ export default function () {
datetime: true,
label: "结束时间",
prop: "endTime",
default: null,
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择结束时间" },
},
@ -121,10 +113,7 @@ export default function () {
select: true,
label: "窑车状态",
prop: "stateDictValue",
options: [
{ value: 0, label: '正常' },
{ value: 1, label: '报废' }
],
options: getDictDataList('car_state').map(_ => ({ label: _.dictLabel, value: _.dictValue })),
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择窑车状态" },
},
@ -132,9 +121,74 @@ export default function () {
],
],
operations: [
{ name: "add", label: "保存", type: "primary", permission: "pms:car:save", showOnEdit: false },
{ name: "update", label: "更新", type: "primary", permission: "pms:car:update", showOnEdit: true },
{ name: "reset", label: "重置", type: "warning", showAlways: true },
{ name: "add-pos-manually", label: "保存", type: "primary", permission: "", showOnEdit: false },
// { name: "update", label: "更新", type: "primary", permission: "", showOnEdit: true },
// { name: "reset", label: "重置", type: "warning", showAlways: true },
// { name: 'cancel', label: '取消', showAlways: true },
],
},
};
const carPayloadAddConfigs = {
clickModalToClose: true,
form: {
rows: [
[
{
select: true,
prop: "orderId",
label: "订单号",
options: [],
fetchData: () => this.$http.post('/pms/order/pageCom', { limit: 999, page: 1, code: '', type: 1 }),
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { filterable: true, placeholder: "请选择订单" },
},
{
input: true,
label: "窑车载量",
prop: "qty",
rules: [
{ required: true, message: "必填项不能为空", trigger: "blur" },
{ type: 'number', message: "请输入大于0的整数", trigger: "blur", transform: val => Number(val) > 0 && Number.isInteger(Number(val)) && Number(val) },
],
elparams: { placeholder: "请输入窑车载量" },
},
],
// [
// {
// input: true,
// label: "合格砖数",
// prop: "goodqty",
// rules: [
// { required: true, message: "必填项不能为空", trigger: "blur" },
// { type: 'number', message: "请输入正确的数字类型", trigger: "blur", transform: val => Number(val) },
// ],
// elparams: { placeholder: "请输入合格砖数" },
// },
// {
// input: true,
// label: "废砖数",
// prop: "badqty",
// rules: [
// { required: true, message: "必填项不能为空", trigger: "blur" },
// { type: 'number', message: "请输入正确的数字类型", trigger: "blur", transform: val => Number(val) },
// ],
// elparams: { placeholder: "请输入废砖数" },
// },
// ],
// [
// {
// input: true,
// label: "备注",
// prop: "remark",
// elparams: { placeholder: "请输入备注" },
// }
// ],
],
operations: [
{ name: "add-car-payload", label: "保存", type: "primary", permission: "", showOnEdit: false },
// { name: "update", label: "更新", type: "primary", permission: "", showOnEdit: true },
// { name: "reset", label: "重置", type: "warning", showAlways: true },
// { name: 'cancel', label: '取消', showAlways: true },
],
},
@ -164,6 +218,7 @@ export default function () {
return {
carPayloadAddConfigs,
carPayloadDialogConfigs,
dialogConfigs: dialogJustFormConfigs,
tableConfig: {
@ -178,7 +233,8 @@ export default function () {
base: "/pms/carHandle",
page: "/pms/carHandle/pageHis",
pageIsPostApi: true,
formUrl: "/pms/trans/inputCurrent"
posFormUrl: "/pms/trans/inputCurrent",
payloadFormUrl: '/pms/trans/inputDetail', // 载砖详情 url
// subase: '/pms/blenderStepParam',
// subpage: '/pms/blenderStepParam/page',
// more...

Voir le fichier

@ -4,6 +4,7 @@
:head-config="headFormConfigs"
:dialog-configs="dialogConfigs"
:car-payload-dialog-configs="carPayloadDialogConfigs"
:car-payload-add-configs="carPayloadAddConfigs"
:listQueryExtra="[{ pos: [1, 7] }]"
:trigger-update="triggerUpdateKey"
key="pallet"
@ -13,7 +14,7 @@
<script>
import initConfig from "./config";
import ListViewWithHead from "@/views/atomViews/ListViewWithHead.vue";
import ListViewWithHead from "./components/ListViewWithHead.vue";
export default {
name: "PalletizingLineView",
@ -24,8 +25,9 @@ export default {
};
},
data() {
const { tableConfig, headFormConfigs, carPayloadDialogConfigs, urls, dialogConfigs } = initConfig.call(this);
const { tableConfig, headFormConfigs,carPayloadAddConfigs, carPayloadDialogConfigs, urls, dialogConfigs } = initConfig.call(this);
return {
carPayloadAddConfigs,
carPayloadDialogConfigs,
tableConfig,
headFormConfigs,