update 上料模块里的单位展示

This commit is contained in:
lb 2023-03-02 14:39:19 +08:00
parent 5b871f27f5
commit 59034e7caa
10 changed files with 172 additions and 103 deletions

View File

@ -50,7 +50,7 @@ import BaseListTable from "@/components/BaseListTable.vue";
import BaseSearchForm from "@/components/BaseSearchForm.vue"; import BaseSearchForm from "@/components/BaseSearchForm.vue";
import DialogWithMenu from "@/components/DialogWithMenu.vue"; import DialogWithMenu from "@/components/DialogWithMenu.vue";
import DialogJustForm from "@/components/DialogJustForm.vue"; import DialogJustForm from "@/components/DialogJustForm.vue";
import moment from 'moment' import moment from "moment";
const DIALOG_WITH_MENU = "DialogWithMenu"; const DIALOG_WITH_MENU = "DialogWithMenu";
const DIALOG_JUST_FORM = "DialogJustForm"; const DIALOG_JUST_FORM = "DialogJustForm";
@ -62,8 +62,8 @@ export default {
tableConfig: { tableConfig: {
type: Object, type: Object,
default: () => ({ default: () => ({
/** 列配置, 即 props **/ columnConfig: [], /** 列配置, 即 props **/ column: [],
/** 表格整体配置 */ tableConfig: undefined, /** 表格整体配置 */ table: undefined,
}), }),
}, },
headConfig: { headConfig: {
@ -151,14 +151,14 @@ export default {
if (res.code === 0) { if (res.code === 0) {
// page : // page :
if ("list" in res.data) { if ("list" in res.data) {
// real env: /** 破碎记录的特殊需求:数据要结合单位 material + materialUnitDictValue */
this.dataList = res.data.list.map((item) => { if ("attachDictValue" in this.tableConfig.column) {
return { this.dataList = res.data.list.map((row) => {
...item, this.tableConfig.column.attachDictValue(row, "unit", "qty", "materialUnitDictValue");
id: item._id ?? item.id, return row;
}; });
// } } else this.dataList = res.data.list;
});
this.totalPage = res.data.total; this.totalPage = res.data.total;
} else if ("records" in res.data) { } else if ("records" in res.data) {
this.dataList = res.data.records.map((item) => ({ this.dataList = res.data.records.map((item) => ({
@ -185,7 +185,7 @@ export default {
type: "error", type: "error",
duration: 2000, duration: 2000,
}); });
this.tableLoading = false this.tableLoading = false;
}); });
// } // }
}, },
@ -313,14 +313,14 @@ export default {
const params = {}; const params = {};
/** 处理 payload 里的数据 */ /** 处理 payload 里的数据 */
if (typeof payload === 'object') { if (typeof payload === "object") {
// BaseSearchForm // BaseSearchForm
Object.assign(params, payload) Object.assign(params, payload);
if ('timerange' in params && !!params.timerange) { if ("timerange" in params && !!params.timerange) {
const [startTime, endTime] = params['timerange'] const [startTime, endTime] = params["timerange"];
delete params.timerange delete params.timerange;
params.startTime = moment(startTime).format('YYYY-MM-DD HH:mm:ss') params.startTime = moment(startTime).format("YYYY-MM-DD HH:mm:ss");
params.endTime = moment(endTime).format('YYYY-MM-DD HH:mm:ss') params.endTime = moment(endTime).format("YYYY-MM-DD HH:mm:ss");
} }
} }

View File

@ -90,16 +90,9 @@ export default function () {
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入混料程序编码" }, elparams: { placeholder: "请输入混料程序编码" },
}, },
],
[
{
forceDisabled: true,
prop: 'bomCode',
label: '当前配方'
},
{ {
select: true, select: true,
label: "选择新配方", label: "配方",
prop: "bomId", prop: "bomId",
options: [], options: [],
refreshOptionsAfterConfirm: true, refreshOptionsAfterConfirm: true,
@ -107,6 +100,13 @@ export default function () {
fetchData: (techId = -1) => this.$http.get("/pms/bom/listUnR", { params: { wsId: 1, externalCode: '', key: '', techId } }), fetchData: (techId = -1) => this.$http.get("/pms/bom/listUnR", { params: { wsId: 1, externalCode: '', key: '', techId } }),
}, },
], ],
// [
// {
// forceDisabled: true,
// prop: 'bomCode',
// label: '当前配方'
// },
// ],
[{ textarea: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], [{ textarea: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
], ],
operations: [ operations: [
@ -124,9 +124,9 @@ export default function () {
{ prop: "name", label: "参数名称", isEditField: true }, { prop: "name", label: "参数名称", isEditField: true },
{ prop: "code", label: "参数编码", isEditField: true }, { prop: "code", label: "参数编码", isEditField: true },
// { prop: "specifications", label: "规格", isEditField: true }, // { prop: "specifications", label: "规格", isEditField: true },
{ prop: "value", label: "设定值", isEditField: true }, { prop: "value", label: "参数值", isEditField: true },
{ prop: "valueFloor", label: "值下限", isEditField: true }, { prop: "valueFloor", label: "参数值下限", isEditField: true },
{ prop: "valueTop", label: "值上限", isEditField: true }, { prop: "valueTop", label: "参数值上限", isEditField: true },
{ prop: "description", label: "描述", isEditField: true }, { prop: "description", label: "描述", isEditField: true },
{ {
prop: "operations", prop: "operations",
@ -161,7 +161,7 @@ export default function () {
label: "参数编码", label: "参数编码",
prop: "code", prop: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入描述" }, elparams: { placeholder: "请输入参数编码" },
}, },
], ],
[ [

View File

@ -1,13 +1,13 @@
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent"; import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
import switchBtn from "@/components/noTemplateComponents/switchBtn"; import switchBtn from "@/components/noTemplateComponents/switchBtn";
import request from "@/utils/request"; import request from "@/utils/request";
import { timeFilter } from '@/utils/filters' import { timeFilter, dictFilter } from '@/utils/filters'
export default function () { export default function () {
const tableProps = [ const tableProps = [
{ type: 'index', label: '序号' }, { type: 'index', label: '序号' },
// { prop: "createTime", label: "添加时间", filter: timeFilter }, { prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "updateTime", label: "上料时间", filter: timeFilter }, // { prop: "updateTime", label: "上料时间", filter: timeFilter },
{ prop: "materialName", label: "原料" }, { prop: "materialName", label: "原料" },
// { prop: "material", label: "原料编码" }, // { prop: "material", label: "原料编码" },
{ prop: "qty", label: "上料量" }, { prop: "qty", label: "上料量" },
@ -29,6 +29,32 @@ export default function () {
}, },
]; ];
/**
* 数据字典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 = [ const headFormFields = [
{ {
prop: 'material', prop: 'material',

View File

@ -90,16 +90,9 @@ export default function () {
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入烧制工艺编码" }, elparams: { placeholder: "请输入烧制工艺编码" },
}, },
],
[
{
forceDisabled: true,
prop: 'bomCode',
label: '当前配方'
},
{ {
select: true, select: true,
label: "选择新配方", label: "配方",
prop: "bomId", prop: "bomId",
options: [], options: [],
refreshOptionsAfterConfirm: true, refreshOptionsAfterConfirm: true,
@ -107,6 +100,13 @@ export default function () {
fetchData: (techId = -1) => this.$http.get("/pms/bom/listUnR", { params: { wsId: 3, externalCode: '', key: '', techId } }), fetchData: (techId = -1) => this.$http.get("/pms/bom/listUnR", { params: { wsId: 3, externalCode: '', key: '', techId } }),
}, },
], ],
// [
// {
// forceDisabled: true,
// prop: 'bomCode',
// label: '当前配方'
// },
// ],
[{ textarea: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], [{ textarea: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
], ],
operations: [ operations: [
@ -124,9 +124,9 @@ export default function () {
{ prop: "name", label: "参数名称", isEditField: true }, { prop: "name", label: "参数名称", isEditField: true },
{ prop: "code", label: "参数编码", isEditField: true }, { prop: "code", label: "参数编码", isEditField: true },
// { prop: "specifications", label: "规格", isEditField: true }, // { prop: "specifications", label: "规格", isEditField: true },
{ prop: "value", label: "设定值", isEditField: true }, { prop: "value", label: "参数值", isEditField: true },
{ prop: "valueFloor", label: "值下限", isEditField: true }, { prop: "valueFloor", label: "参数值下限", isEditField: true },
{ prop: "valueTop", label: "值上限", isEditField: true }, { prop: "valueTop", label: "参数值上限", isEditField: true },
{ prop: "description", label: "描述", isEditField: true }, { prop: "description", label: "描述", isEditField: true },
{ {
prop: "operations", prop: "operations",
@ -161,7 +161,7 @@ export default function () {
label: "参数编码", label: "参数编码",
prop: "code", prop: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入描述" }, elparams: { placeholder: "请输入参数编码" },
}, },
], ],
[ [

View File

@ -17,7 +17,7 @@
<div style="display: flex; flex-direction: column; min-width: 128px; justify-content: space-between"> <div style="display: flex; flex-direction: column; min-width: 128px; justify-content: space-between">
<div style="font-size: 1.125em; line-height: 2.5; text-align: right">{{ material }}</div> <div style="font-size: 1.125em; line-height: 2.5; text-align: right">{{ material }}</div>
<div style="font-size: 1.5em; line-height: 1.25; text-align: right; font-weight: bold"> <div style="font-size: 1.5em; line-height: 1.25; text-align: right; font-weight: bold">
{{ qty }} <span style="color: #777; font-weight: normal; font-size: 1rem">存量</span> {{ qty }} <span style="color: #777; font-weight: normal; font-size: 1rem">{{ computedUnit }}</span>
</div> </div>
<div class="btn-group" style="text-align: right"> <div class="btn-group" style="text-align: right">
@ -29,6 +29,8 @@
</template> </template>
<script> <script>
import { dictFilter } from "@/utils/filters";
export default { export default {
name: "StorageBox", name: "StorageBox",
props: { props: {
@ -52,9 +54,21 @@ export default {
type: String, type: String,
default: "-", default: "-",
}, },
unitValue: {
type: String,
default: null
}
}, },
data() { data() {
return {}; return {
unitList: dictFilter("unit"),
};
},
computed: {
computedUnit() {
if (!this.unitValue) return '存量'
return this.unitList(this.unitValue)+' 存量'
},
}, },
created() {}, created() {},
mounted() {}, mounted() {},

View File

@ -30,6 +30,7 @@
color="#8899ff" color="#8899ff"
:material="st.material ?? '默认物料'" :material="st.material ?? '默认物料'"
:total="2" :total="2"
:unit-value="st.unitDictValue"
/> />
</div> </div>
</div> </div>
@ -45,9 +46,9 @@
padding-left: 16px; padding-left: 16px;
top: 10px; top: 10px;
left: -16px; left: -16px;
" "
> >
中间仓 中间仓
</h3> </h3>
<div class="middle-list" style="padding: 12px 0; display: flex; flex-wrap: wrap"> <div class="middle-list" style="padding: 12px 0; display: flex; flex-wrap: wrap">
<storage-box <storage-box
@ -58,11 +59,12 @@
color="#99aa11" color="#99aa11"
:material="st.material ?? '默认物料'" :material="st.material ?? '默认物料'"
:total="2" :total="2"
/> :unit-value="st.unitDictValue"
/>
</div>
</div> </div>
</div> <div class="unknown-storage" v-if="unknownStorage.length">
<div class="unknown-storage" v-if="unknownStorage.length"> <h3
<h3
class="" class=""
style=" style="
position: relative; position: relative;
@ -73,19 +75,20 @@
padding-left: 16px; padding-left: 16px;
top: 10px; top: 10px;
left: -16px; left: -16px;
" "
> >
未知仓 未知仓
</h3> </h3>
<div class="unknown-list" style="padding: 12px 0; display: flex; flex-wrap: wrap"> <div class="unknown-list" style="padding: 12px 0; display: flex; flex-wrap: wrap">
<storage-box <storage-box
v-for="(st, index) in unknownStorage" v-for="(st, index) in unknownStorage"
:key="index" :key="index"
:qty="st.qty ?? 0" :qty="st.qty ?? 0"
color="#3388ff" color="#3388ff"
:storage="st.name" :storage="st.name"
:material="st.material ?? '默认物料'" :material="st.material ?? '默认物料'"
:total="2" :total="2"
:unit-value="st.unitDictValue"
/> />
</div> </div>
</div> </div>

View File

@ -2,7 +2,7 @@ import TableOperaionComponent from "@/components/noTemplateComponents/operationC
import switchBtn from "@/components/noTemplateComponents/switchBtn"; import switchBtn from "@/components/noTemplateComponents/switchBtn";
import QuillRichInput from "@/components/noTemplateComponents/richInput"; import QuillRichInput from "@/components/noTemplateComponents/richInput";
import request from "@/utils/request"; import request from "@/utils/request";
import { timeFilter } from "@/utils/filters"; import { timeFilter, dictFilter } from "@/utils/filters";
export default function () { export default function () {
const tableProps = [ const tableProps = [
@ -30,6 +30,32 @@ export default function () {
}, },
]; ];
/**
* 数据字典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 = [ const headFormFields = [
{ {
prop: "materialId", prop: "materialId",

View File

@ -87,16 +87,9 @@ export default function () {
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入工艺编码" }, elparams: { placeholder: "请输入工艺编码" },
}, },
],
[
{
forceDisabled: true,
prop: 'shapeCode',
label: '当前砖型'
},
{ {
select: true, select: true,
label: "选择新砖型", label: "砖型",
prop: "shapeId", prop: "shapeId",
options: [], options: [],
refreshOptionsAfterConfirm: true, refreshOptionsAfterConfirm: true,
@ -105,6 +98,13 @@ export default function () {
fetchData: (techId = -1) => this.$http.get("/pms/shape/listUnR", { params: { wsId: 5, externalCode: '', key: '', techId } }), fetchData: (techId = -1) => this.$http.get("/pms/shape/listUnR", { params: { wsId: 5, externalCode: '', key: '', techId } }),
}, },
], ],
// [
// {
// forceDisabled: true,
// prop: 'shapeCode',
// label: '当前砖型'
// },
// ],
// { // {
// select: true, // select: true,
// label: "砖型", // label: "砖型",
@ -129,11 +129,11 @@ export default function () {
// { prop: "createTime", label: "添加时间", filter: timeFilter }, // { prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "name", label: "参数名称", isEditField: true }, { prop: "name", label: "参数名称", isEditField: true },
{ prop: "code", label: "参数编码", isEditField: true }, { prop: "code", label: "参数编码", isEditField: true },
{ prop: "specifications", label: "规格", isEditField: true }, // { prop: "specifications", label: "规格", isEditField: true },
{ prop: "value", label: "参数值", isEditField: true },
{ prop: "valueFloor", label: "参数值下限", isEditField: true },
{ prop: "valueTop", label: "参数值上限", isEditField: true },
{ prop: "description", label: "描述", isEditField: true }, { prop: "description", label: "描述", isEditField: true },
{ prop: "value", label: "设定值", isEditField: true },
{ prop: "valueFloor", label: "值下限", isEditField: true },
{ prop: "valueTop", label: "值上限", isEditField: true },
{ {
prop: "operations", prop: "operations",
name: "操作", name: "操作",
@ -167,7 +167,7 @@ export default function () {
label: "参数编码", label: "参数编码",
prop: "code", prop: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入描述" }, elparams: { placeholder: "请输入参数编码" },
}, },
], ],
[ [

View File

@ -87,16 +87,9 @@ export default function () {
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入混料程序编码" }, elparams: { placeholder: "请输入混料程序编码" },
}, },
],
[
{
forceDisabled: true,
prop: 'shapeCode',
label: '当前砖型'
},
{ {
select: true, select: true,
label: "选择新砖型", label: "砖型",
prop: "shapeId", prop: "shapeId",
options: [], options: [],
refreshOptionsAfterConfirm: true, refreshOptionsAfterConfirm: true,
@ -104,6 +97,13 @@ export default function () {
fetchData: (techId = -1) => this.$http.get("/pms/shape/listUnR", { params: { wsId: 2, externalCode: '', key: '', techId } }), fetchData: (techId = -1) => this.$http.get("/pms/shape/listUnR", { params: { wsId: 2, externalCode: '', key: '', techId } }),
}, },
], ],
// [
// {
// forceDisabled: true,
// prop: 'shapeCode',
// label: '当前砖型'
// },
// ],
// { // {
// select: true, // select: true,
// label: "砖型", // label: "砖型",
@ -128,11 +128,11 @@ export default function () {
// { prop: "createTime", label: "添加时间", filter: timeFilter }, // { prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "name", label: "参数名称", isEditField: true }, { prop: "name", label: "参数名称", isEditField: true },
{ prop: "code", label: "参数编码", isEditField: true }, { prop: "code", label: "参数编码", isEditField: true },
{ prop: "specifications", label: "规格", isEditField: true }, // { prop: "specifications", label: "规格", isEditField: true },
{ prop: "value", label: "参数值", isEditField: true },
{ prop: "valueFloor", label: "参数值下限", isEditField: true },
{ prop: "valueTop", label: "参数值上限", isEditField: true },
{ prop: "description", label: "描述", isEditField: true }, { prop: "description", label: "描述", isEditField: true },
{ prop: "value", label: "设定值", isEditField: true },
{ prop: "valueFloor", label: "值下限", isEditField: true },
{ prop: "valueTop", label: "值上限", isEditField: true },
{ {
prop: "operations", prop: "operations",
name: "操作", name: "操作",
@ -166,7 +166,7 @@ export default function () {
label: "参数编码", label: "参数编码",
prop: "code", prop: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入描述" }, elparams: { placeholder: "请输入参数编码" },
}, },
], ],
[ [

View File

@ -87,16 +87,9 @@ export default function () {
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入混料程序编码" }, elparams: { placeholder: "请输入混料程序编码" },
}, },
],
[
{
forceDisabled: true,
prop: 'shapeCode',
label: '当前砖型'
},
{ {
select: true, select: true,
label: "选择新砖型", label: "砖型",
prop: "shapeId", prop: "shapeId",
options: [], options: [],
refreshOptionsAfterConfirm: true, refreshOptionsAfterConfirm: true,
@ -105,6 +98,13 @@ export default function () {
fetchData: (techId = -1) => this.$http.get("/pms/shape/listUnR", { params: { wsId: 4, externalCode: '', key: '', techId } }), fetchData: (techId = -1) => this.$http.get("/pms/shape/listUnR", { params: { wsId: 4, externalCode: '', key: '', techId } }),
}, },
], ],
// [
// {
// forceDisabled: true,
// prop: 'shapeCode',
// label: '当前砖型'
// },
// ],
// { // {
// select: true, // select: true,
// label: "砖型", // label: "砖型",
@ -129,11 +129,11 @@ export default function () {
// { prop: "createTime", label: "添加时间", filter: timeFilter }, // { prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "name", label: "参数名称", isEditField: true }, { prop: "name", label: "参数名称", isEditField: true },
{ prop: "code", label: "参数编码", isEditField: true }, { prop: "code", label: "参数编码", isEditField: true },
{ prop: "specifications", label: "规格", isEditField: true }, // { prop: "specifications", label: "规格", isEditField: true },
{ prop: "value", label: "参数设定值", isEditField: true },
{ prop: "valueFloor", label: "参数值下限", isEditField: true },
{ prop: "valueTop", label: "参数值上限", isEditField: true },
{ prop: "description", label: "描述", isEditField: true }, { prop: "description", label: "描述", isEditField: true },
{ prop: "value", label: "设定值", isEditField: true },
{ prop: "valueFloor", label: "值下限", isEditField: true },
{ prop: "valueTop", label: "值上限", isEditField: true },
{ {
prop: "operations", prop: "operations",
name: "操作", name: "操作",
@ -167,7 +167,7 @@ export default function () {
label: "参数编码", label: "参数编码",
prop: "code", prop: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入描述" }, elparams: { placeholder: "请输入参数编码" },
}, },
], ],
[ [