MES基础档案

This commit is contained in:
xielue 2023-06-03 22:13:55 +08:00
parent fa69689738
commit 65662498d1
11 changed files with 2124 additions and 309 deletions

View File

@ -52,6 +52,7 @@ export default {
actions: { // api
getList: `${BASE_URL}/api/web/listdata` //
},
actionParams:null,
modalVisible: false, //
lastKey: '', //
modelName: '', //
@ -151,6 +152,9 @@ export default {
if (params.dataUrl) {
this.actions.getList = params.dataUrl;
}
if(params.actionParams){
this.actionParams = params.actionParams;
}
}
if (params.dataType == "string") {
@ -179,7 +183,10 @@ export default {
},
getData(key) { //
var params = {}; //
var params = Object.assign({},this.actionParams ||{}) //
params.page = this.tablePage.currentPage; //
params.limit = this.tablePage.pageSize; //
params.order_bys = []; //
@ -197,6 +204,7 @@ export default {
});
}
}
return this.$mk.getPagedData({
url: this.actions.getList,
data: params

View File

@ -1,23 +1,42 @@
<template>
<div class="page-body">
<vxe-form :data="options.formOptions.data" ref="xForm" :title-width="options.formOptions.titleWidth"
:title-align="options.formOptions.titleAlign" :rules="options.formOptions.rules" :items="options.formOptions.items"
titleColon>
<template #sort_id="{}">
<vxe-pulldown style="width:100%" ref="pulldownParent" transfer>
<template #default>
<vxe-input v-model="sortName" suffix-icon="vxe-icon-search" placeholder="选择分类" @keyup="pulldownKeyupEvent"
@focus="pulldownFocusEvent" @suffix-click="pulldownSuffixClick"></vxe-input>
<a-tabs v-model="tabKey" hide-add>
<a-tab-pane key="1" tab="基础信息">
<vxe-form :data="options.formOptions.data" ref="xForm" :title-width="options.formOptions.titleWidth"
:title-align="options.formOptions.titleAlign" :rules="options.formOptions.rules"
:items="options.formOptions.items" titleColon>
<template #sort_id="{}">
<vxe-pulldown style="width:100%" ref="pulldownParent" transfer>
<template #default>
<vxe-input v-model="sortName" suffix-icon="vxe-icon-search" placeholder="选择分类" @keyup="pulldownKeyupEvent"
@focus="pulldownFocusEvent" @suffix-click="pulldownSuffixClick"></vxe-input>
</template>
<template #dropdown>
<div class="my-dropdown">
<vxe-grid ref="gridParent" v-bind="gridParentOptions" @cell-click="pulldownCellClickEvent">
</vxe-grid>
</div>
</template>
</vxe-pulldown>
</template>
<template #dropdown>
<div class="my-dropdown">
<vxe-grid ref="gridParent" v-bind="gridParentOptions" @cell-click="pulldownCellClickEvent">
</vxe-grid>
</div>
</template>
</vxe-pulldown>
</template>
</vxe-form>
</vxe-form>
</a-tab-pane>
<a-tab-pane key="2" tab="料品属性">
<vxe-form :data="options.formOptions2.data" ref="xForm2" :title-width="options.formOptions2.titleWidth"
:title-align="options.formOptions2.titleAlign" :rules="options.formOptions2.rules"
:items="options.formOptions2.items" titleColon>
</vxe-form>
</a-tab-pane>
</a-tabs>
<div class="footerbar">
<a-button type="primary" @click="ok">确定</a-button>
@ -45,12 +64,14 @@ export default {
data() {
let pageData = {
let pageData = {
actions: {
list: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/sort/list`,
},
tabKey: '1',
sortName: '',
custom_attribute_value: [],
attributes: [],
gridParentOptions: {
height: 400,
id: 'datagrid_router_parent_1',
@ -103,7 +124,7 @@ export default {
},
options: {}
};
pageData.gridParentOptions = Object.assign({}, this.$mk.config.defaults.gridOptions, pageData.gridParentOptions);
return pageData;
},
@ -163,6 +184,9 @@ export default {
MesMaterialsImportExcel: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/import/excel`, // EXCEL
// =============================== End ===============================
productAttribute: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/get/productAttribute`
},
keyName: 'id',
@ -196,18 +220,154 @@ export default {
{ field: 'name', title: '名称', span: 12, itemRender: { name: '$input' } },
{ title: '分类', span: 12, slots: { default: 'sort_id' } },
{ field: 'spec', title: '规格型号', span: 12, itemRender: { name: '$input' } },
{ field: 'size', title: '尺寸', span: 12, itemRender: { name: '$input' } },
{ field: 'color', title: '颜色', span: 12, itemRender: { name: '$input' } },
{ field: 'face', title: '花面', span: 12, itemRender: { name: '$input' } },
{ field: 'molding', title: '成型方式', span: 12, itemRender: { name: '$input' } },
{ field: 'production_type', title: '布产方式', span: 12, itemRender: { name: '$input' } },
{ field: 'size', title: '尺寸', span: 12, itemRender: { name: '$input' } },
{
title: '颜色', span: 12,
field: 'color',
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "string",
valueField: "name",
textField: "name",
listdataFieldName: 'MesEnumValue',
actionParams:{
search_rules_enum: [
{
column:"code",
mode:"=",
value:"3"
}
]
},
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
}
}
}
},
{
title: '花面', span: 12,
field: 'face',
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "string",
valueField: "name",
textField: "name",
listdataFieldName: 'MesEnumValue',
actionParams:{
search_rules_enum: [
{
column:"code",
mode:"=",
value:"4"
}
]
},
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
}
}
}
},
{
title: '成型方式', span: 12,
field: 'molding',
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "string",
valueField: "name",
textField: "name",
listdataFieldName: 'MesEnumValue',
actionParams:{
search_rules_enum: [
{
column:"code",
mode:"=",
value:"1"
}
]
},
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
}
}
}
},
{
title: '布产方式', span: 12,
field: 'production_type',
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "string",
valueField: "name",
textField: "name",
listdataFieldName: 'MesEnumValue',
actionParams:{
search_rules_enum: [
{
column:"code",
mode:"=",
value:"2"
}
]
},
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
}
}
}
},
{ field: 'theoretical_load', title: '理论装车量', span: 12, itemRender: { name: '$input' } },
{ field: 'soil', title: '土质', span: 12, itemRender: { name: '$input' } },
{ field: 'unit', title: '单位', span: 12, itemRender: { name: '$input' } },
{
title: '土质', span: 12,
field: 'soil',
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "string",
valueField: "name",
textField: "name",
listdataFieldName: 'MesEnumValue',
actionParams:{
search_rules_enum: [
{
column:"code",
mode:"=",
value:"5"
}
]
},
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
}
}
}
},
{
title: '单位', span: 12,
field: 'unit',
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "string",
valueField: "name",
textField: "name",
listdataFieldName: 'MesUnit',
dataUrl: `${BASE_URL.BASE_URL}/MesUnit/v1/mes/unit/list`
}
}
}
},
]
},
//
@ -215,6 +375,26 @@ export default {
],
formOptions2Done: false,
formOptions2: {
data: {
},
//
titleWidth: 150,
//
titleAlign: 'right',
//
rules: {
},
//
items: [
]
},
};
@ -232,7 +412,95 @@ export default {
this.options = pageData;
},
attributeDataInit(){
this.$mk.post({
url: this.options.actions.productAttribute,
loading: "加载中..."
}).then(a => {
let getOptions = (id) => {
let options = [];
a.data.field.forEach(fieldItem => {
if (fieldItem.attribute_id.toString() == id.toString()) {
options.push({
value: fieldItem.id.toString(),
label: fieldItem.name
})
}
})
return options
}
this.attributes = a.data.attribute;
let formData = {};
a.data.attribute.forEach(item => {
let formItem = { field: '', title: '', span: 12, itemRender: {} };
formItem.field = "attr" + item.id;
formItem.title = item.name;
//:1.,2.,3.,4.,5.,6.,7.
if (item.typeName == "2") {
formItem.itemRender.props = { type: "nubmer" };
formItem.itemRender.name = "$input";
formData[formItem.field] = 0;
}
else if (item.typeName == "3" ||
item.typeName == "4" ||
item.typeName == "5") {
formItem.itemRender.name = "$input";
formItem.itemRender.props = { type: "date" };
formData[formItem.field] = '';
}
else if (item.typeName == "6") {
formItem.itemRender.name = "$select";
formItem.itemRender.options = getOptions(item.id);
if (!formItem.itemRender.options.length) {
return;
}
formData[formItem.field] = formItem.itemRender.options[0].value;
}
else if (item.typeName == "7") {
formItem.itemRender.name = "$switch";
formItem.itemRender.props = { openLabel: '是', openValue: "true", closeValue: "false", closeLabel: '否' };
formData[formItem.field] = '1';
} else {
formItem.itemRender.name = "$input";
formData[formItem.field] = '';
}
let ov = this.getOldAttributeValue(item.id);
if(ov !== null){
formData[formItem.field] = ov;
}
this.options.formOptions2.items.push(formItem);
})
this.options.formOptions2.data = formData;
this.options.formOptions2Done = true;
this.$forceUpdate();
}).catch((a) => {
this.$mk.error(a.data.msg);
});
},
dataInit() {
// id
let dataId = this.getDataId();
// id
@ -257,13 +525,16 @@ export default {
if (a.data[detailDataFieldName].update_time) {
a.data[detailDataFieldName].update_time = new Date(a.data[detailDataFieldName].update_time * 1000);
}
if(a.data[detailDataFieldName].mes_materials_sort){
this.sortName = a.data[detailDataFieldName].mes_materials_sort.name;
}
if (a.data[detailDataFieldName].mes_materials_sort) {
this.sortName = a.data[detailDataFieldName].mes_materials_sort.name;
}
this.options.formOptions.data = a.data[detailDataFieldName];
this.custom_attribute_value = a.data[detailDataFieldName].custom_attribute_value || [];
this.attributeDataInit();
this.$forceUpdate()
}).catch((a) => {
this.$mk.error(a.data.msg);
@ -272,15 +543,26 @@ if(a.data[detailDataFieldName].mes_materials_sort){
this.options.isEdit = true;
this.$forceUpdate()
} else {
// id
this.addModeItems.forEach(item => {
this.options.formOptions.items.push(item);
})
} else{
this.attributeDataInit();
}
},
getOldAttributeValue(attribute_id) {
for(let i =0;i<this.custom_attribute_value.length;i++){
if(this.custom_attribute_value[i].attribute_id.toString() == attribute_id.toString()){
return this.custom_attribute_value[i].value;
}
}
return null;
},
getAttributeValue(attribute_id) {
return this.options.formOptions2.data["attr" + attribute_id.toString()];
},
// id
getDataId() {
let dataId = this.dataId;
@ -292,7 +574,11 @@ if(a.data[detailDataFieldName].mes_materials_sort){
}
return dataId;
},
getDataId_BigInt() {
let dataId = this.getDataId();
return this.$mk.toBigInt(dataId);
},
//
back() {
this.isEdit = this.options.isEdit;
@ -327,6 +613,44 @@ if(a.data[detailDataFieldName].mes_materials_sort){
if (this.isEdit) {
// postdata = { MesUnit: postdata }
}
postdata.custom_attribute_value = [];
let findOldAttribute = (id) => {
let attrs = this.custom_attribute_value.filter(a => a.attribute_id.toString() == id.toString());
if (attrs.length) {
return attrs[0]
}
return null;
}
this.attributes.forEach(item => {
let v = this.getAttributeValue(item.id);
let old = findOldAttribute(item.id);
if (old != null) {
old.value = v;
old.e_value = v;
postdata.custom_attribute_value.push(old);
} else {
let newItem = {
attribute_id: item.id,
"value": v,
"e_value": v
};
if (this.isEdit) {
newItem.product_id = this.getDataId_BigInt();
}
postdata.custom_attribute_value.push(newItem)
}
})
console.log(postdata)
//
this.$mk.formatFormData({ data: postdata, rules: this.options.formOptions.items });
@ -376,14 +700,14 @@ if(a.data[detailDataFieldName].mes_materials_sort){
this.$refs.pulldownParent.togglePanel()
},
pulldownCellClickEvent({ row }) {
if(row.children && row.children.length){
return;
}
this.options.formOptions.data.sort_id = row.id;
if (row.children && row.children.length) {
return;
}
this.options.formOptions.data.sort_id = row.id;
this.sortName = row.name;
this.$refs.pulldownParent.hidePanel()
},
},
//

View File

@ -106,16 +106,16 @@ export default {
{ field: 'spec', title: '规格型号' },
{ field: 'size', title: '尺寸' },
{ field: 'color', title: '颜色' },
{ field: 'face', title: '花面', },
{ field: 'molding', title: '成型方式' },
{ field: 'production_type', title: '布产方式' },
{ field: 'spec', title: '规格型号' , width: 150},
{ field: 'size', title: '尺寸', width: 150 },
{ field: 'color', title: '颜色', width: 150 },
{ field: 'face', title: '花面', width: 150 },
{ field: 'molding', title: '成型方式' , width: 150},
{ field: 'production_type', title: '布产方式' , width: 150},
{ field: 'theoretical_load', title: '理论装车量' },
{ field: 'soil', title: '土质' },
{ field: 'unit', title: '单位' },
{ field: 'theoretical_load', title: '理论装车量', width: 150 },
{ field: 'soil', title: '土质', width: 150 },
{ field: 'unit', title: '单位', width: 150 },
{ field: 'create_time', formatter: 'formatDate', width: 160, sortable: true, title: '创建时间', showHeaderOverflow: true }, //
{ field: 'update_time', formatter: 'formatDate', width: 160, sortable: true, title: '更新时间', showHeaderOverflow: true }, //

View File

@ -189,16 +189,16 @@ export default {
{ field: 'spec', title: '规格型号' },
{ field: 'size', title: '尺寸' },
{ field: 'color', title: '颜色' },
{ field: 'face', title: '花面', },
{ field: 'molding', title: '成型方式' },
{ field: 'production_type', title: '布产方式' },
{ field: 'spec', title: '规格型号' , width: 150 },
{ field: 'size', title: '尺寸' , width: 150},
{ field: 'color', title: '颜色' , width: 150},
{ field: 'face', title: '花面' , width: 150 },
{ field: 'molding', title: '成型方式' , width: 150 },
{ field: 'production_type', title: '布产方式' , width: 150 },
{ field: 'theoretical_load', title: '理论装车量' },
{ field: 'soil', title: '土质' },
{ field: 'unit', title: '单位' },
{ field: 'theoretical_load', title: '理论装车量' , width: 150 },
{ field: 'soil', title: '土质' , width: 150 },
{ field: 'unit', title: '单位' , width: 150 },
{ field: 'create_time', formatter: 'formatDate', width: 160, sortable: true, title: '创建时间', showHeaderOverflow: true }, //
{ field: 'update_time', formatter: 'formatDate', width: 160, sortable: true, title: '更新时间', showHeaderOverflow: true }, //
@ -522,6 +522,7 @@ export default {
.right {
flex-grow: 1;
height: 100%;
width: calc(100% - 300px);
}
.treepanel {

View File

@ -157,7 +157,25 @@ export default {
//
items: [
{ field: 'name', title: '工序名称', span: 12, itemRender: { name: '$input' } },
// { field: 'title', title: '', span: 12, itemRender: { name: '$input' } },
{
title: '工序分类', span: 12,
field: 'mes_processes_sort',
dataRule: {
fromField: "id",
saveField: "sort_id" // fromFieldsaveField
},
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "object",
valueField: "id",
textField: "name",
listdataFieldName: 'MesProcessesSort',
dataUrl: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/list`
}
}
}
},
{ field: 'code', title: '工序编码', span: 12, itemRender: { name: '$input' } },
{ field: 'desc', title: '工序描述', span: 12, itemRender: { name: '$input' } },
{ field: 'remark', title: '工序备注', span: 12, itemRender: { name: '$input' } },

View File

@ -1,10 +1,43 @@
<template>
<basic-page-list :desc="desc" @importData="pageImport" :options="pageOptions"></basic-page-list>
<div class="wrapper">
<div class="left">
<div class="treepanel" :style="'height:' + tableHeight + 'px'">
<div class="treepanel-header">
<a @click.stop="treeAdd(row)" title="新增">
<a-icon type="plus-circle" />
</a>
<a @click.stop="treeEdit(row)" title="编辑">
<a-icon type="edit" />
</a>
<a @click.stop="treeDelete(row)" title="删除">
<a-icon type="delete" />
</a>
</div>
<div class="treepanel-content">
<a-tree v-if="!treeLoading" show-line :tree-data="treeData" :default-expand-all="true" :block-node="true"
@select="onTreeSelect" :default-selected-keys="selectedKeys">
<a-icon slot="switcherIcon" type="down" />
</a-tree>
</div>
</div>
</div>
<div class="right">
<basic-page-list ref="listPage" :desc="desc" @importData="pageImport" :options="pageOptions"></basic-page-list>
</div>
</div>
</template>
<script>
import BASE_URL from '@/services/mes/api.js';
let childrenFieldName = 'children';
import { toArrayTree } from "xe-utils"
const settings = require('../../basic/settings.js');
export default {
@ -14,7 +47,30 @@ export default {
},
data() {
return {
pageOptions: {}
pageOptions: {},
modelName: "",
actions: {
treedata: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/list`,
delete: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/batchDelete`,
listdata: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`,
save: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/batchHandle`,
},
tipTimes: 0,
detailsData: [
],
sourceDetailsData: [
],
treeData: [],
treeLoading: true,
deletedDetailsData: [
],
selectedKeys: [],
selectedKey: null,
tableHeight: 500
};
},
//
@ -29,6 +85,14 @@ export default {
//
created() {
this.optionsInit();
this.$nextTick(() => {
this.tableHeight = this.$mk.getWindowSize().height - 320;
this.treeInit();
});
},
//
methods: {
@ -142,7 +206,8 @@ export default {
//
searchRules: [
{ key: "name", mode: "like" },
{ key: "code", mode: "like" }
{ key: "code", mode: "like" },
{ key: "sort_id", mode: "in" },
],
//
searchFormItems: [ //
@ -176,7 +241,10 @@ export default {
//{ field: 'process_segment_id', sortable: true, title: 'id', width: 250 }, // id
//{ field: 'title', sortable: true, title: '', width: 250 }, //
{ field: 'code', sortable: true, title: '工序编码', width: 250 }, //
{ field: 'name', sortable: true, title: '工序名称', width: 250 }, //
{ field: 'name', sortable: true, title: '工序名称', width: 250 },
{ field: 'mes_processes_sort', formatter: 'formatRef', params: { dataType: "object", textField: "name" }, title: '工序分类', width: 250 },
{ field: 'desc', sortable: true, title: '工序描述', width: 250 }, //
{ field: 'remark', sortable: true, title: '工序备注', width: 250 }, //
@ -205,12 +273,348 @@ export default {
this.pageOptions = pageData;
},
treeInit() {
this.treeLoading = true;
this.$mk.post({
url: this.actions.treedata,
loading: "加载中...",
data: {
"page": 1,
"limit": 10000,
"end_time": 0,
"start_time": 0,
"order_bys": [
],
"search_rules": [
]
}
}).then(r => {
let treedata = {
title: "工序分类",
key: "root"
};
let at = toArrayTree(r.data.MesProcessesSort, { parentKey: "parent_id" });
console.log(at);
treedata[childrenFieldName] = at;
function formatTreedata(d) {
if (d.id) {
d.key = d.id.toString();
} else {
d.key = "root";
}
if (d.name) {
d.title = d.name;
}
if (d[childrenFieldName] && d[childrenFieldName].length) {
d[childrenFieldName].forEach(item => formatTreedata(item))
}
}
treedata[childrenFieldName].forEach(item => formatTreedata(item))
this.treeData = [treedata];
this.treeLoading = false;
});
},
treeAdd() {
this.$mk.dialog.open({
page: () => import("./treeEdit"),
title: "新增-分类",
dataId: 0,
callback: ({ success }) => {
success && this.treeInit();
}
})
},
treeEdit() {
if (!this.selectedKey || this.selectedKey == "root") {
this.$mk.error("请先选择分类");
return;
}
let node = this.findTreeNode(this.selectedKey);
this.$mk.dialog.open({
page: () => import("./treeEdit"),
title: "编辑-分类",
dataId: node.id,
callback: ({ success }) => {
success && this.treeInit();
}
})
},
treeDelete() {
if (!this.selectedKey || this.selectedKey == "root") {
this.$mk.error("请先选择分类");
return;
}
let node = this.findTreeNode(this.selectedKey);
let ids = [
node.id
]; // id
if (!ids.length) { //
this.$mk.error("请选择行"); //
return;
}
this.$mk.confirm('您确定要删除吗?').then(type => { //
if (type == 'confirm') { //
this.$mk.post({
url: this.actions.delete, //
loading: "删除中...", //
data: {
ids: ids // id
},
useBigInt: true
}).then(() => { //
this.$mk.success("删除成功"); //
this.treeInit(); //
}).catch((a) => { //
this.$mk.error(a.data.msg); //
});
}
});
},
getDataId() {
let dataId = this.dataId;
if (this.$route.params.id) {
dataId = this.$route.params.id;
}
return dataId;
},
onTreeSelect(selectedKeys) {
if (selectedKeys && selectedKeys[0]) {
this.selectedKey = selectedKeys[0];
this.loadData(selectedKeys[0]);
}
},
findTreeNode(key) {
var find = (items) => {
for (let i = 0; i < items.length; i++) {
if (items[i].key == key) {
return items[i];
}
if (items[i][childrenFieldName] && items[i][childrenFieldName].length) {
var xx = find(items[i][childrenFieldName]);
if (xx) {
return xx;
}
}
}
};
return find(this.treeData);
},
reloadData() {
if (this.selectedKey) {
this.loadData(this.selectedKey);
}
},
getAllChildrenIds(items) {
let ids = [];
let eachItems = (arr) => {
arr.forEach(item => {
if (item.children && item.children.length) {
eachItems(item.children);
} else {
ids.push(item.id);
}
})
};
eachItems(items);
return ids;
},
loadData(key) {
if (key && key != "root") {
var node = this.findTreeNode(key);
if (node.children && node.children.length) {
var ids = this.getAllChildrenIds(node.children);
this.$refs.listPage.onSearch({
sort_id: [node.id, ...ids].join(',')
})
} else {
this.$refs.listPage.onSearch({
sort_id: node.id
})
}
}else{
this.$refs.listPage.onSearch(null);
}
},
findSourceInfo(idStr) {
for (var i = 0; i < this.sourceDetailsData.length; i++) {
let o = this.sourceDetailsData[i];
if (o.id.toString() == idStr) {
return o;
}
}
},
ok() {
let save = () => {
if (!this.selectedKey || this.selectedKey == "root") {
this.$mk.error("请先选择料品分类");
return;
}
let node = this.findTreeNode(this.selectedKey);
let ds = JSON.parse(JSON.stringify(this.detailsData));
var postdata = {
insertList: [],
updateList: [],
deleteList: this.deletedDetailsData
};
ds.forEach(item => {
delete item._X_ROW_KEY;
item.enum_id = node.id;
if (item.id && item.id != "0") {
let source = this.findSourceInfo(item.id);
item.id = source.id;
postdata.updateList.push(item);
} else {
postdata.insertList.push(item);
}
})
this.$mk.post({
url: this.actions.save,
loading: "保存中...",
data: postdata,
useBigInt: true
}).then(a => {
if (a.code == "200") {
this.$mk.success("保存成功");
this.reloadData();
} else {
this.$mk.error(a.message);
}
}).catch((a) => {
this.$mk.error(a.data.msg);
});
};
save();
},
back() {
},
cancel() {
this.back();
},
pageAdd(row) {
const $table = this.$refs.xTable
const record = {
}
if (row) {
this.detailsData.splice($table.getRowSeq(row), 0, record);
} else {
this.detailsData.push(record)
}
},
pageDelete(row) {
const $table = this.$refs.xTable;
if (row.id) {
this.deletedDetailsData.push(row.id)
}
this.detailsData.splice($table.getRowSeq(row) - 1, 1);
},
},
//
watch: {
}
};
</script>
</script>
<style>
.page-body {
background: white;
padding: 8px;
}
/* 左侧固定宽度 200px右侧自适应 */
.wrapper {
display: flex;
}
.left {
width: 200px;
height: 100%;
}
.right {
flex-grow: 1;
height: 100%;
width: calc(100% - 300px);
}
.treepanel {
width: calc(100% - 10px);
background: white;
margin-right: 10px;
border: 1px solid #ccc;
}
.treepanel-content {
padding: 7px;
}
.treepanel-header {
width: 100%;
background: #F8F8F9;
border-bottom: 1px solid #ccc;
height: 32px;
line-height: 32px;
margin: 0;
font-size: 14px;
color: #606266;
}
.treepanel-header .anticon {
margin-left: 5px;
cursor: pointer;
}
.toolbarbtns .ant-btn {
margin-right: 10px;
}
.toolbarbtns {
margin-bottom: 5px;
}
</style>

View File

@ -0,0 +1,150 @@
<template>
<div class="page-body">
<vxe-form :data="formOptions.data" ref="xForm" :title-width="formOptions.titleWidth"
:title-align="formOptions.titleAlign" :rules="formOptions.rules" :items="formOptions.items" titleColon>
</vxe-form>
<div class="footerbar">
<a-button type="primary" @click="ok">确定</a-button>
<a-button @click="cancel">取消</a-button>
</div>
</div>
</template>
<script>
import BASE_URL from '@/services/base/api.js';
export default {
props: {
dataId: {
}
},
data() {
//
var pageData = {
actions: {
create: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/create`,
update: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/update`,
get: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/detail`,
list: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/list`,
},
formOptions: {
data: {
"name": "",
"e_name": ""
},
titleWidth: 150,
titleAlign: 'right',
rules: {
name: [
{ required: true, message: '请输入名称' }
],
e_name: [
{ required: true, message: '请输入名称(英文)' }
]
},
items: [
{ field: 'name', title: '名称', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入名称' } } },
{ field: 'e_name', title: '名称(英文)', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入名称(英文)' } } },
{ field: 'code', title: '编号', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入编号' } } },
]
}
};
pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);
return pageData;
},
created() {
if (this.dataId) {
this.$mk.post({
url: this.actions.get,
loading: "加载中...",
data: {
id: this.dataId
},
useBigInt: true
}).then(a => {
this.formOptions.data = a.data.mes_processes_sort;
this.parentNameInit() ;
}).catch((a) => {
this.$mk.error(a.data.msg);
});
}
},
//
methods: {
loadData() {
},
ok() {
let save = () => {
let action = !this.dataId ? this.actions.create : this.actions.update;
let postdata = Object.assign({ id: this.dataId }, this.formOptions.data);
this.$mk.post({
url: action,
loading: "保存中...",
data: postdata,
useBigInt: true
}).then(() => {
this.$mk.success("保存成功");
this.$emit("callback", { success: true });
}).catch((a) => {
this.$mk.error(a.data.msg);
});
};
this.$refs.xForm.validate((a) => {
let count = 0;
if (a) {
for (let name in a) {
a[name];
count++;
}
}
if (count > 0) {
this.$mk.error(`存在${count}项错误,请检查`);
}
else {
save();
}
});
},
cancel() {
this.$emit("callback", {});
},
},
//
watch: {
}
};
</script>
<style></style>

View File

@ -1,13 +1,57 @@
<template>
<basic-page-edit :desc="desc" :dataId="getDataId()" :options="pageOptions"></basic-page-edit>
<div class="page-body">
<vxe-form :data="formOptions.data" ref="xForm" :title-width="formOptions.titleWidth"
:title-align="formOptions.titleAlign" :rules="formOptions.rules" :items="formOptions.items" titleColon>
</vxe-form>
<vxe-table v-if="formOptions.data.typeName == '6'" border show-overflow keep-source ref="xTable"
:height="table1Height" :data="detailsData" @pulldownSelected="onPulldownSelected" @popupSelected="onPopupSelected"
:export-config="{}" @edit-closed="afterEditEvent" @edit-actived="beforeEditEvent"
:edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: beforeEditMethod }">
<vxe-column width="60">
<template #default="{ row }">
<div class="oplinks2">
<a @click.stop="pageAdd(row)" title="新增">
<a-icon class="icon" type="plus-circle" />
</a>
<a @click.stop="pageDelete(row)" title="删除">
<a-icon class="icon" type="delete" />
</a>
</div>
</template>
</vxe-column>
<vxe-column field="name" title="属性选项" width="120" :edit-render="{ name: '$input', props: {} }">
</vxe-column>
<vxe-column field="code" title="编码" width="120" :edit-render="{ name: '$input', props: {} }">
</vxe-column>
<vxe-column field="e_name" title="属性选项(英文)" width="120" :edit-render="{ name: '$input', props: {} }">
</vxe-column>
<vxe-column field="description" title="描述" width="120" :edit-render="{ name: '$input', props: {} }">
</vxe-column>
</vxe-table>
<div class="mk-toolbar" v-if="isEdit">
</div>
<div class="footerbar">
<a-button type="primary" @click="ok">确定</a-button>
<a-button @click="cancel">取消</a-button>
</div>
</div>
</template>
<script>
import BASE_URL from '@/services/mes/api.js';
const settings = require('../../basic/settings.js');
export default {
name: 'BathroomPartsUpdate',
i18n: require('./i18n'),
components: {},
props: {
@ -17,13 +61,126 @@ export default {
},
dataId: {
}
},
data() {
return {
pageOptions: {}
//let _this = this;
//
var pageData = {
//
currentConfigName: "",
// ID
currentBeid: 0,
uploadDefaultImg: null,
detailDataFieldName: "attribute",
actions: {
get: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/detail`,
create: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/create`,
update: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/update`,
detailsData: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/field/list`,
saveDetails: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/field/batchHandle`,
},
keyName: 'id',
//
isEdit: false,
//
formOptions: {
data: {
name: '',
typeName: '1'
},
//
titleWidth: 140,
//
titleAlign: 'right',
//
rules: {
name: [
{ required: true, message: '请输入属性名称' }
],
category: [
{ required: true, message: '请选择分类' }
]
},
//
items: [
{ field: 'name', title: '属性名称', span: 8, itemRender: { name: '$input' } },
{ field: 'e_name', title: '属性名称(英文)', span: 8, itemRender: { name: '$input' } },
{ field: 'code', title: '编码', span: 8, itemRender: { name: '$input' } },
{
title: '分类', span: 8,
field: 'category',
dataRule: {
fromField: "id",
saveField: "category_id" // fromFieldsaveField
},
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "object",
valueField: "id",
textField: "name",
listdataFieldName: 'Category',
dataUrl: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/list`
}
}
}
},
{ field: 'typeName', title: '属性类型', span: 8, itemRender: { name: '$select', props: { options: settings.options_attribute_types } } },
]
},
//
addModeItems: [
],
table1Height: 400,
detailsSourceData: [
],
detailsData: [
],
deletedDetailsData: [
],
editorMaterials: {
dataType: "object",
valueField: "id",
textField: "name",
listdataFieldName: 'MesMaterials',
dataUrl: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/list`
},
editorWarehouse: {
dataType: "object",
valueField: "id",
textField: "warehouse_name",
listdataFieldName: 'MesWarehouse',
searchFieldNames: ['warehouse_name'],
columns: [ //
{ field: 'warehouse_name', title: '名称' }, //
{ field: 'code', title: '编码' } //
],
dataUrl: `${BASE_URL.BASE_URL}/MesWarehouse/v1/mes/warehouse/list`
},
};
//
pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);
return pageData;
},
computed: {
@ -35,8 +192,50 @@ export default {
created() {
this.optionsInit();
this.dataInit();
// id
let dataId = this.getDataId();
// id
if (dataId) {
this.$mk.post({
url: this.actions.get,
loading: "加载中...",
data: { id: this.$mk.toBigInt(dataId) },
useBigInt: true
}).then(a => {
// =============================== Start ===============================
if (a.data[this.detailDataFieldName].create_time) {
a.data[this.detailDataFieldName].create_time = new Date(a.data[this.detailDataFieldName].create_time * 1000);
}
if (a.data[this.detailDataFieldName].update_time) {
a.data[this.detailDataFieldName].update_time = new Date(a.data[this.detailDataFieldName].update_time * 1000);
}
// =============================== End ===============================
this.formOptions.data = a.data[this.detailDataFieldName];
}).catch((a) => {
this.$mk.error(a.data.msg);
});
this.isEdit = true;
this.detailsDataLoad(dataId);
} else {
// id
this.addModeItems.forEach(item => {
this.formOptions.items.push(item);
})
this.detailsDataInit();
}
this.heightInit();
},
//
@ -44,178 +243,50 @@ export default {
optionsInit() {
//
var pageData = {
//
currentConfigName: "",
// ID
currentBeid: 0,
detailsDataLoad(id) {
addPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeAdd",
editPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeUpdate/",
listPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeList",
uploadDefaultImg: null,
detailDataFieldName: "mes_product_custom_attribute",
actions: {
// =============================== Start ===============================
MesProductCustomAttributeList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/list`, //
MesProductCustomAttributeDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/detail`, //
MesProductCustomAttributeCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/create`, //
MesProductCustomAttributeUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/update`, //
MesProductCustomAttributeDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/detele`, //
MesProductCustomAttributeBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchDelete`, //
MesProductCustomAttributeBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchUpdate`, //
MesProductCustomAttributeBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchCreate`, //
MesProductCustomAttributeExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/export/excel`, // EXCEL
MesProductCustomAttributeImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/import/excel`, // EXCEL
ProductCustomAttributeList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/list`, //
ProductCustomAttributeDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/detail`, //
ProductCustomAttributeCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/create`, //
ProductCustomAttributeUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/update`, //
ProductCustomAttributeDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/detele`, //
ProductCustomAttributeBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchDelete`, //
ProductCustomAttributeBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchUpdate`, //
ProductCustomAttributeBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchCreate`, //
ProductCustomAttributeExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/export/excel`, // EXCEL
ProductCustomAttributeImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/import/excel`, // EXCEL
ProductCustomAttributeFieldList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/list`, //
ProductCustomAttributeFieldDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/detail`, //
ProductCustomAttributeFieldCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/create`, //
ProductCustomAttributeFieldUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/update`, //
ProductCustomAttributeFieldDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/detele`, //
ProductCustomAttributeFieldBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchDelete`, //
ProductCustomAttributeFieldBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchUpdate`, //
ProductCustomAttributeFieldBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchCreate`, //
ProductCustomAttributeFieldExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/export/excel`, // EXCEL
ProductCustomAttributeFieldImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/import/excel`, // EXCEL
ProductCustomAttributeValueList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/list`, //
ProductCustomAttributeValueDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/detail`, //
ProductCustomAttributeValueCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/create`, //
ProductCustomAttributeValueUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/update`, //
ProductCustomAttributeValueDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/detele`, //
ProductCustomAttributeValueBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchDelete`, //
ProductCustomAttributeValueBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchUpdate`, //
ProductCustomAttributeValueBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchCreate`, //
ProductCustomAttributeValueExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/export/excel`, // EXCEL
ProductCustomAttributeValueImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/import/excel`, // EXCEL
// =============================== End ===============================
},
keyName: 'id',
//
isEdit: false,
//
formOptions: {
data: {
// =============================== Start ===============================
id: 0,
code: "",
title: "",
name: "",
description: "",
create_uid: 0,
update_uid: 0,
create_time: new Date(2100, 1, 1).getTime() / 10000,
update_time: new Date(2100, 1, 1).getTime() / 10000,
// =============================== End ===============================
},
//
titleWidth: 160,
//
titleAlign: 'right',
//
rules: {
// =============================== Start ===============================
name: [
{ required: true, message: '请输入属性分类英文名称' }
]
// =============================== End ===============================
},
//
items: [
// =============================== Start ===============================
{ field: 'name', title: '属性名称', span: 24, itemRender: { name: '$input' } },
{ field: 'title', title: '分类名称', span: 24, itemRender: { name: '$input' } },
{ field: 'code', title: '编码', span: 24, itemRender: { name: '$input' } },
{ field: 'description', title: '属性分类描述', span: 12, itemRender: { name: '$input' } },
// =============================== End ===============================
this.$mk.post({
url: this.actions.detailsData,
loading: "加载中...",
data: {
"page": 1,
"limit": 10000,
"start_time": 0,
"end_time": 0,
"search_rules": [
{
column: "attribute_id", //
mode: "=", //
value: id.toString()
}
],
"order_bys": [
]
},
//
addModeItems: [
useBigInt: true
}).then(a => {
],
this.detailsSourceData = a.data.Field || [];
this.detailsData = JSON.parse(JSON.stringify(a.data.Field || []));
};
pageData.actions.get = pageData.actions.MesProductCustomAttributeDetail;
pageData.actions.create = pageData.actions.MesProductCustomAttributeCreate;
pageData.actions.update = pageData.actions.MesProductCustomAttributeUpdate;
//
pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);
this.pageOptions = pageData;
this.detailsDataInit();
});
},
dataInit() {
// id
let dataId = this.getDataId();
// id
if (dataId) {
const json = `{"id":${dataId}}`;
this.$mk.post({
url: this.pageOptions.actions.get,
loading: "加载中...",
data: json,
config: {
headers: {
'Content-Type': 'application/json'
}
}
}).then(a => {
heightInit() {
let detailDataFieldName = this.pageOptions.detailDataFieldName;
this.$nextTick(() => {
let h = this.$mk.getWindowSize().height - this.$mk.getOffsetTop(this.$refs.xTable.$el) - 380;
if (a.data[detailDataFieldName].create_time) {
a.data[detailDataFieldName].create_time = new Date(a.data[detailDataFieldName].create_time * 1000);
}
if (a.data[detailDataFieldName].update_time) {
a.data[detailDataFieldName].update_time = new Date(a.data[detailDataFieldName].update_time * 1000);
}
this.pageOptions.formOptions.data = a.data[detailDataFieldName];
this.$forceUpdate()
}).catch((a) => {
this.$mk.error(a.data.msg);
});
this.pageOptions.isEdit = true;
this.$forceUpdate()
} else {
// id
this.addModeItems.forEach(item => {
this.pageOptions.formOptions.items.push(item);
})
this.table1Height = h;
});
},
detailsDataInit() {
for (let i = this.detailsData.length; i < 10; i++) {
this.detailsData.push({});
}
},
// id
getDataId() {
let dataId = this.dataId;
@ -226,7 +297,240 @@ export default {
dataId = 0;
}
return dataId;
}
},
getDataId_BigInt() {
let dataId = this.getDataId();
return this.$mk.toBigInt(dataId);
},
//
back() {
//
if (!this.isEdit) {
this.$closePage({
closeRoute: "/MesProductCustomAttribute/MesProductCustomAttributeAdd"
});
} else {
//
this.$closePage({
closeRoute: "/MesProductCustomAttribute/MesProductCustomAttributeUpdate"
});
}
//
this.$openPage('/MesProductCustomAttribute/MesProductCustomAttributeList')
},
//
ok() {
let saveDetails = (dataId) => {
dataId = dataId || this.getDataId_BigInt();
let ds = [];
this.detailsData.forEach(item => {
if (item.name) {
let o = Object.assign({}, item);
if (item.id) {
o.id = this.$mk.toBigInt(item.id);
}
ds.push(o);
}
});
console.log(this.formOptions.data)
var postdata = {
insertList: [],
updateList: [],
deleteList: this.deletedDetailsData
};
ds.forEach(item => {
delete item._X_ROW_KEY;
item.attribute_id = dataId;
if(this.formOptions.data.category_id){
item.category_id = this.formOptions.data.category_id;
}else if(this.formOptions.data.category && this.formOptions.data.category.id){
item.category_id = this.formOptions.data.category.id;
}
if (item.id) {
postdata.updateList.push(item);
} else {
postdata.insertList.push(item);
}
})
this.$mk.post({
url: this.actions.saveDetails,
data: postdata,
useBigInt: true
}).then(a => {
if (a.code == "200") {
this.$mk.success("保存成功");
if (!this.isEdit) { //
this.back();
}
} else {
this.$mk.error(a.msg || a.message);
}
}).catch((a) => {
this.$mk.error(a.msg || a.data.msg);
});
};
let save = () => {
//
let action = !this.isEdit ? this.actions.create : this.actions.update;
// id id
let postdata = Object.assign({}, this.formOptions.data);
//
if (this.isEdit) {
// postdata = { BathroomParts: postdata }
}
//
this.$mk.formatFormData({ data: postdata, rules: this.formOptions.items });
//
this.$mk.post({
url: action,
loading: "保存中...",
data: postdata,
useBigInt: true,
}).then((a) => { //
if (a.code == "200") {
saveDetails(a.data.id);
} else {
this.$mk.error(a.msg || a.message);
}
}).catch((a) => {
this.$mk.error(a.msg || a.data.msg );
});
};
//
this.$mk.validateForm({ form: this.$refs.xForm }).then(() => { //
save(); //
}).catch(count => { //
this.$mk.error(`存在${count}项错误,请检查`);
});
},
//
cancel() {
this.back();
},
pageAdd(row) {
const $table = this.$refs.xTable
const record = {
}
if (row) {
this.detailsData.splice($table.getRowSeq(row), 0, record);
} else {
this.detailsData.push(record)
}
},
pageDelete(row) {
const $table = this.$refs.xTable;
if (row.id) {
this.deletedDetailsData.push(this.$mk.toBigInt(row.id))
}
this.detailsData.splice($table.getRowSeq(row) - 1, 1);
},
beforeEditMethod({ column, row }) {
if (row.SourceTableID && column.field != "Quantity") {
return false;
}
return true;
},
afterEditEvent({ column, row }) {
if (column.field == "Quantity" || column.field == "Price") {
row.Amount = parseInt(row.Quantity || 0) * parseFloat(row.Price || 0);
}
if (column.field == "specification") {
row.specification = this.specification;
}
},
beforeEditEvent({ column, row }) {
if (row.SourceTableID && column.field != "Quantity") {
return false;
}
if (column.field == "specification") {
this.specification = row.specification;
}
},
onPulldownSelected({ row, name, params }) {
if (name == 'ag_inventory') {
this.updateToGrid(row, this.detailsData[params.$rowIndex]);
setTimeout(() => {
this.$refs.xTable.clearEdit();
}, 50);
}
},
onPopupSelected({ rows, name, params }) {
console.log(rows, name, params);
if (name == 'ag_inventory') {
for (let i = params.$rowIndex, ri = 0; i < params.$rowIndex + rows.length; i++, ri++) {
if (i == this.detailsData.length) {
let newrow = {
};
this.detailsData.push(newrow);
}
let inv = rows[ri];
this.updateToGrid(inv, this.detailsData[i]);
}
setTimeout(() => {
this.$refs.xTable.clearEdit();
}, 50);
}
},
},
//
watch: {
@ -235,4 +539,44 @@ export default {
};
</script>
<style scoped lang="less">
.page-body {
padding: 30px;
background: @base-bg-color;
}
.formtabs .ant-tabs-tabpane {
/* background: white; */
padding: 12px;
}
.gridPanel {
height: calc(100vh - 600px);
}
.footerbar {
padding-left: 10px;
}
.imagePanel {
cursor: pointer;
padding: 10px;
width: 100px;
img {
width: 80px;
height: 80px;
}
}
.oplinks2 svg {
width: 18px;
height: 18px;
}
.oplinks2 i {
margin-left: 5px;
}
</style>

View File

@ -1,19 +1,75 @@
<template>
<basic-page-list :desc="desc" :options="pageOptions"></basic-page-list>
<div class="wrapper">
<div class="left">
<div class="treepanel" :style="'height:' + tableHeight + 'px'">
<div class="treepanel-header">
<a @click.stop="treeAdd(row)" title="新增">
<a-icon type="plus-circle" />
</a>
<a @click.stop="treeEdit(row)" title="编辑">
<a-icon type="edit" />
</a>
<a @click.stop="treeDelete(row)" title="删除">
<a-icon type="delete" />
</a>
</div>
<div class="treepanel-content">
<a-tree v-if="!treeLoading" show-line :tree-data="treeData" :default-expand-all="true" :block-node="true"
@select="onTreeSelect" :default-selected-keys="selectedKeys">
<a-icon slot="switcherIcon" type="down" />
</a-tree>
</div>
</div>
</div>
<div class="right">
<basic-page-list ref="listPage" :desc="desc" @importData="pageImport" :options="pageOptions"></basic-page-list>
</div>
</div>
</template>
<script>
import BASE_URL from '@/services/mes/api.js';
let childrenFieldName = 'children';
import { toArrayTree } from "xe-utils"
export default {
i18n: require("./i18n"),
export default {
i18n: require("./i18n"),
props: {
},
data() {
return {
pageOptions: {}
pageOptions: {},
modelName: "",
actions: {
treedata: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/list`,
delete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/batchDelete`,
listdata: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/list`,
save: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/batchHandle`,
},
tipTimes: 0,
detailsData: [
],
sourceDetailsData: [
],
treeData: [],
treeLoading: true,
deletedDetailsData: [
],
selectedKeys: [],
selectedKey: null,
tableHeight: 500
};
},
//
@ -28,69 +84,82 @@ export default {
//
created() {
this.optionsInit();
this.$nextTick(() => {
this.tableHeight = this.$mk.getWindowSize().height - 320;
this.treeInit();
});
},
//
methods: {
pageImport({ data }) {
let rows = [];
data.forEach(item => {
let row = {};
this.pageOptions.exportColumns.forEach(col => {
if (col.title in item) {
let v = item[col.title];
if(col.options){
col.options.forEach(op=>{
if(op.label == v){
row[col.field] = op.value;
}
})
}else{
row[col.field] = v;
}
}
})
rows.push(row);
});
this.$mk.post({
url: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/batchCreate`,
loading: "导入中...",
data: {
"list": rows
},
useBigInt: true
}).then((a) => { //
this.$mk.success(a.data.msg || "导入成功"); //
this.$refs.xGrid.commitProxy('query') //
}).catch((a) => { //
this.$mk.error(a.data.msg); //
});
},
optionsInit() {
//
var pageData = { //
keyName: 'id', //
listFieldName: 'MesProductCustomAttribute',
listFieldName: 'Attribute',
//exportFileTitle :"",
//enabledExport: true,
//enabledImport: true,
//enabledImportTemplate: true,
exportColumns: [
{ title: '编码',field:"code" },
{ title: '名称',field:"name" }
],
addPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeAdd",
editPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeUpdate/",
//
actions: { // Api
// =============================== Start ===============================
MesProductCustomAttributeList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/list`, //
MesProductCustomAttributeDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/detail`, //
MesProductCustomAttributeCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/create`, //
MesProductCustomAttributeUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/update`, //
MesProductCustomAttributeDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/detele`, //
MesProductCustomAttributeBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchDelete`, //
MesProductCustomAttributeBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchUpdate`, //
MesProductCustomAttributeBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchCreate`, //
MesProductCustomAttributeExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/export/excel`, // EXCEL
MesProductCustomAttributeImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/import/excel`, // EXCEL
ProductCustomAttributeList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/list`, //
ProductCustomAttributeDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/detail`, //
ProductCustomAttributeCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/create`, //
ProductCustomAttributeUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/update`, //
ProductCustomAttributeDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/detele`, //
ProductCustomAttributeBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchDelete`, //
ProductCustomAttributeBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchUpdate`, //
ProductCustomAttributeBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchCreate`, //
ProductCustomAttributeExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/export/excel`, // EXCEL
ProductCustomAttributeImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/import/excel`, // EXCEL
ProductCustomAttributeFieldList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/list`, //
ProductCustomAttributeFieldDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/detail`, //
ProductCustomAttributeFieldCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/create`, //
ProductCustomAttributeFieldUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/update`, //
ProductCustomAttributeFieldDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/detele`, //
ProductCustomAttributeFieldBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchDelete`, //
ProductCustomAttributeFieldBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchUpdate`, //
ProductCustomAttributeFieldBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchCreate`, //
ProductCustomAttributeFieldExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/export/excel`, // EXCEL
ProductCustomAttributeFieldImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/import/excel`, // EXCEL
ProductCustomAttributeValueList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/list`, //
ProductCustomAttributeValueDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/detail`, //
ProductCustomAttributeValueCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/create`, //
ProductCustomAttributeValueUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/update`, //
ProductCustomAttributeValueDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/detele`, //
ProductCustomAttributeValueBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchDelete`, //
ProductCustomAttributeValueBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchUpdate`, //
ProductCustomAttributeValueBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchCreate`, //
ProductCustomAttributeValueExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/export/excel`, // EXCEL
ProductCustomAttributeValueImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/import/excel`, // EXCEL
//
actions: { // Api
getList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/list`,
delete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/batchDelete`,
},
// =============================== End ===============================
},
start_time: 0, //
end_time: 0, //
start_time: 0, //
end_time: 0, //
//
@ -101,7 +170,10 @@ export default {
//
searchRules: [
{ key: "title", mode: "like" },
{ key: "desc", mode: "like" }
{ key: "desc", mode: "like" },
{ key: "category_id", mode: "in" },
],
//
searchFormItems: [ //
@ -123,44 +195,379 @@ export default {
stripe: true, //
id: 'datagrid_1', //
//
columns: [
{ type: 'checkbox', width: 50 }, //
{ type: 'seq', width: 30 }, //
//
columns: [
{ type: 'checkbox', width: 50 }, //
{ type: 'seq', width: 30 }, //
{ title: '操作', slots: { default: 'op' }, width: 120 },
{ title: '操作', slots: { default: 'op' }, width: 120 },
// =============================== Start ===============================
{ field: 'code', sortable: true, title: '编码', width: 250 }, //
{ field: 'title', sortable: true, title: '分类名称', width: 250 }, //
{ field: 'name', sortable: true, title: '属性名称', width: 250 }, //
{ field: 'description', sortable: true, title: '属性分类描述', width: 250 }, //
{ field: 'code', sortable: true, title: '编码', width: 250 }, //
{ field: 'name', sortable: true, title: '属性名称', width: 250 },
{ field: 'category', formatter: 'formatRef', params: { dataType: "object", textField: "name" }, title: '属性分类', width: 250 },
{ field: 'create_time', formatter: 'formatDate', width: 160, sortable: true, title: '创建时间', showHeaderOverflow: true }, //
{ field: 'update_time', formatter: 'formatDate', width: 160, sortable: true, title: '更新时间', showHeaderOverflow: true }, //
// =============================== Start ===============================
]
]
}
};
pageData.actions.getList = pageData.actions.MesProductCustomAttributeList;
pageData.actions.delete = pageData.actions.MesProductCustomAttributeBatchDelete;
pageData.gridOptions = Object.assign({}, this.$mk.config.defaults.gridOptions, pageData.gridOptions); //
this.pageOptions = pageData;
},
treeInit() {
this.treeLoading = true;
this.$mk.post({
url: this.actions.treedata,
loading: "加载中...",
data: {
"page": 1,
"limit": 10000,
"end_time": 0,
"start_time": 0,
"order_bys": [
],
"search_rules": [
]
}
}).then(r => {
let treedata = {
title: "属性分类",
key: "root"
};
let at = toArrayTree(r.data.Category, { parentKey: "parent_id" });
console.log(at);
treedata[childrenFieldName] = at;
function formatTreedata(d) {
if (d.id) {
d.key = d.id.toString();
} else {
d.key = "root";
}
if (d.name) {
d.title = d.name;
}
if (d[childrenFieldName] && d[childrenFieldName].length) {
d[childrenFieldName].forEach(item => formatTreedata(item))
}
}
treedata[childrenFieldName].forEach(item => formatTreedata(item))
this.treeData = [treedata];
this.treeLoading = false;
});
},
treeAdd() {
this.$mk.dialog.open({
page: () => import("./treeEdit"),
title: "新增-分类",
dataId: 0,
callback: ({ success }) => {
success && this.treeInit();
}
})
},
treeEdit() {
if (!this.selectedKey || this.selectedKey == "root") {
this.$mk.error("请先选择分类");
return;
}
let node = this.findTreeNode(this.selectedKey);
this.$mk.dialog.open({
page: () => import("./treeEdit"),
title: "编辑-分类",
dataId: node.id,
callback: ({ success }) => {
success && this.treeInit();
}
})
},
treeDelete() {
if (!this.selectedKey || this.selectedKey == "root") {
this.$mk.error("请先选择分类");
return;
}
let node = this.findTreeNode(this.selectedKey);
let ids = [
node.id
]; // id
if (!ids.length) { //
this.$mk.error("请选择行"); //
return;
}
this.$mk.confirm('您确定要删除吗?').then(type => { //
if (type == 'confirm') { //
this.$mk.post({
url: this.actions.delete, //
loading: "删除中...", //
data: {
ids: ids // id
},
useBigInt: true
}).then(() => { //
this.$mk.success("删除成功"); //
this.treeInit(); //
}).catch((a) => { //
this.$mk.error(a.data.msg); //
});
}
});
},
getDataId() {
let dataId = this.dataId;
if (this.$route.params.id) {
dataId = this.$route.params.id;
}
return dataId;
},
onTreeSelect(selectedKeys) {
if (selectedKeys && selectedKeys[0]) {
this.selectedKey = selectedKeys[0];
this.loadData(selectedKeys[0]);
}
},
findTreeNode(key) {
var find = (items) => {
for (let i = 0; i < items.length; i++) {
if (items[i].key == key) {
return items[i];
}
if (items[i][childrenFieldName] && items[i][childrenFieldName].length) {
var xx = find(items[i][childrenFieldName]);
if (xx) {
return xx;
}
}
}
};
return find(this.treeData);
},
reloadData() {
if (this.selectedKey) {
this.loadData(this.selectedKey);
}
},
getAllChildrenIds(items) {
let ids = [];
let eachItems = (arr) => {
arr.forEach(item => {
if (item.children && item.children.length) {
eachItems(item.children);
} else {
ids.push(item.id);
}
})
};
eachItems(items);
return ids;
},
loadData(key) {
if (key && key != "root") {
var node = this.findTreeNode(key);
if (node.children && node.children.length) {
var ids = this.getAllChildrenIds(node.children);
this.$refs.listPage.onSearch({
category_id: [node.id, ...ids].join(',')
})
} else {
this.$refs.listPage.onSearch({
category_id: node.id
})
}
}else{
this.$refs.listPage.onSearch(null);
}
},
findSourceInfo(idStr) {
for (var i = 0; i < this.sourceDetailsData.length; i++) {
let o = this.sourceDetailsData[i];
if (o.id.toString() == idStr) {
return o;
}
}
},
ok() {
let save = () => {
if (!this.selectedKey || this.selectedKey == "root") {
this.$mk.error("请先选择料品分类");
return;
}
let node = this.findTreeNode(this.selectedKey);
let ds = JSON.parse(JSON.stringify(this.detailsData));
var postdata = {
insertList: [],
updateList: [],
deleteList: this.deletedDetailsData
};
ds.forEach(item => {
delete item._X_ROW_KEY;
item.enum_id = node.id;
if (item.id && item.id != "0") {
let source = this.findSourceInfo(item.id);
item.id = source.id;
postdata.updateList.push(item);
} else {
postdata.insertList.push(item);
}
})
this.$mk.post({
url: this.actions.save,
loading: "保存中...",
data: postdata,
useBigInt: true
}).then(a => {
if (a.code == "200") {
this.$mk.success("保存成功");
this.reloadData();
} else {
this.$mk.error(a.message);
}
}).catch((a) => {
this.$mk.error(a.data.msg);
});
};
save();
},
back() {
},
cancel() {
this.back();
},
pageAdd(row) {
const $table = this.$refs.xTable
const record = {
}
if (row) {
this.detailsData.splice($table.getRowSeq(row), 0, record);
} else {
this.detailsData.push(record)
}
},
pageDelete(row) {
const $table = this.$refs.xTable;
if (row.id) {
this.deletedDetailsData.push(row.id)
}
this.detailsData.splice($table.getRowSeq(row) - 1, 1);
},
},
//
watch: {
}
};
</script>
</script>
<style>
.page-body {
background: white;
padding: 8px;
}
/* 左侧固定宽度 200px右侧自适应 */
.wrapper {
display: flex;
}
.left {
width: 200px;
height: 100%;
}
.right {
flex-grow: 1;
height: 100%;
width: calc(100% - 300px);
}
.treepanel {
width: calc(100% - 10px);
background: white;
margin-right: 10px;
border: 1px solid #ccc;
}
.treepanel-content {
padding: 7px;
}
.treepanel-header {
width: 100%;
background: #F8F8F9;
border-bottom: 1px solid #ccc;
height: 32px;
line-height: 32px;
margin: 0;
font-size: 14px;
color: #606266;
}
.treepanel-header .anticon {
margin-left: 5px;
cursor: pointer;
}
.toolbarbtns .ant-btn {
margin-right: 10px;
}
.toolbarbtns {
margin-bottom: 5px;
}
</style>

View File

@ -0,0 +1,150 @@
<template>
<div class="page-body">
<vxe-form :data="formOptions.data" ref="xForm" :title-width="formOptions.titleWidth"
:title-align="formOptions.titleAlign" :rules="formOptions.rules" :items="formOptions.items" titleColon>
</vxe-form>
<div class="footerbar">
<a-button type="primary" @click="ok">确定</a-button>
<a-button @click="cancel">取消</a-button>
</div>
</div>
</template>
<script>
import BASE_URL from '@/services/base/api.js';
export default {
props: {
dataId: {
}
},
data() {
//
var pageData = {
actions: {
create: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/create`,
update: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/update`,
get: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/detail`,
list: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/list`,
},
formOptions: {
data: {
"name": "",
"e_name": ""
},
titleWidth: 150,
titleAlign: 'right',
rules: {
name: [
{ required: true, message: '请输入名称' }
],
e_name: [
{ required: true, message: '请输入名称(英文)' }
]
},
items: [
{ field: 'name', title: '名称', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入名称' } } },
{ field: 'e_name', title: '名称(英文)', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入名称(英文)' } } },
{ field: 'code', title: '编号', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入编号' } } },
]
}
};
pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);
return pageData;
},
created() {
if (this.dataId) {
this.$mk.post({
url: this.actions.get,
loading: "加载中...",
data: {
id: this.dataId
},
useBigInt: true
}).then(a => {
this.formOptions.data = a.data.mes_processes_sort;
this.parentNameInit() ;
}).catch((a) => {
this.$mk.error(a.data.msg);
});
}
},
//
methods: {
loadData() {
},
ok() {
let save = () => {
let action = !this.dataId ? this.actions.create : this.actions.update;
let postdata = Object.assign({ id: this.dataId }, this.formOptions.data);
this.$mk.post({
url: action,
loading: "保存中...",
data: postdata,
useBigInt: true
}).then(() => {
this.$mk.success("保存成功");
this.$emit("callback", { success: true });
}).catch((a) => {
this.$mk.error(a.data.msg);
});
};
this.$refs.xForm.validate((a) => {
let count = 0;
if (a) {
for (let name in a) {
a[name];
count++;
}
}
if (count > 0) {
this.$mk.error(`存在${count}项错误,请检查`);
}
else {
save();
}
});
},
cancel() {
this.$emit("callback", {});
},
},
//
watch: {
}
};
</script>
<style></style>

View File

@ -53,7 +53,16 @@ var config = {
{value:6,label:'待返工'}
],
//属性类型:1.文本,2.数字,3.日期,4.时间,5.日期时间,6.单选,7.布尔
options_attribute_types:[
{value:"1",label:'文本'} ,
{value:"2",label:'数字'} ,
{value:"3",label:'日期'} ,
{value:"4",label:'时间'} ,
{value:"5",label:'日期时间'} ,
{value:"6",label:'单选'} ,
{value:"7",label:'布尔'} ,
],
}
module.exports = config