This commit is contained in:
xielue 2023-05-19 17:20:24 +08:00
parent 44c01a848c
commit e6b8b91951
11 changed files with 1077 additions and 117 deletions

View File

@ -2,17 +2,15 @@
<div class="edit-down-table">
<vxe-pulldown class="edit-down-pulldown" ref="xDown" transfer>
<template>
<vxe-input class="edit-down-input" ref="inputx" :type="enalbedPopup ? 'search' : 'input'" v-model="textboxValue"
<vxe-input class="edit-down-input" suffix-icon="vxe-icon-search" ref="inputx" :type="enalbedPopup ? 'search' : 'input'" v-model="textboxValue"
:readonly="readonly" @keyup="keyupEvent" :placeholder="placeholder" @click="clickEvent"
@suffix-click="suffixClick" @search-click="popupEvent"></vxe-input>
@suffix-click="suffixClick" @search-click="popupEvent"></vxe-input>
</template>
<template #dropdown>
<vxe-grid :keyboard-config="{isArrow: true}" auto-resize height="400" ref="xgrid" :row-config="{ isCurrent: true, isHover: true }"
:loading="loading" :pager-config="tablePage" :data="tableData" :columns="tableColumn"
@cell-click="selectEvent" @page-change="pageChangeEvent">
<vxe-grid :keyboard-config="{ isArrow: true }" auto-resize height="400" ref="xgrid"
:row-config="{ isCurrent: true, isHover: true }" :loading="loading" :pager-config="tablePage" :data="tableData"
:columns="tableColumn" @cell-click="selectEvent" @page-change="pageChangeEvent">
</vxe-grid>
</template>
@ -20,7 +18,7 @@
<vxe-modal show-footer class-name="vxe-table--ignore-clear edit-popup-box" title="选择数据" :width="modalWidth"
:height="modalHeight" v-model="modalVisible" @confirm="confirmEvent">
<!-- vxe-modal 有以下属性
<!-- vxe-modal 有以下属性
show-footer 显示底部按钮
width 宽度
height 高度
@ -45,7 +43,7 @@ export default {
props: { //
readonly: Boolean,
params: Object,
value: [Array,String]
value: [Array, String,Object]
},
data() {
return {
@ -73,7 +71,7 @@ export default {
],
modalWidth: 800, //
modalHeight: 600, //
searchFieldNames: ['name', 'code'], //
searchFieldNames: ['name'], //
tablePage: { //
total: 0, //
currentPage: 1, //
@ -85,14 +83,19 @@ export default {
this.load() //
this.heightInit(); //
},
beforeDestroy() {
beforeDestroy() {
},
watch: {
value() {
const { params } = this
if(params.dataType == "string"){
if (params.dataType == "string") {
this.textboxValue = this.value || "";
}
else if (params.dataType == "object") {
if (this.value) {
this.textboxValue = this.getShowValue({ obj: this.value, path: params.textField });
}
}
else if (this.value && this.value[1]) {
this.textboxValue = this.value[1];
} else {
@ -103,6 +106,17 @@ export default {
methods: {
getShowValue({ obj, path }) {
const parts = path.split('.');
let value = obj;
for (let i = 0; i < parts.length; i++) {
const part = parts[i];
if (!value[part]) return null;
value = value[part];
}
return value;
},
heightInit() { //
this.$nextTick(() => { //
@ -128,38 +142,58 @@ export default {
this.enalbedPopup = true; //
this.popupPage = params.popup.page; //
}
if (params.dataUrl) {
this.actions.getList = params.dataUrl;
}
}
if(params.dataType == "string"){
if (params.dataType == "string") {
this.textboxValue = this.value || "";
}
else if (params.dataType == "object") {
if (this.value) {
this.textboxValue = this.getShowValue({ obj: this.value, path: params.textField });
}
}
else if (this.value && this.value[1]) {
this.textboxValue = this.value[1];
} else {
this.textboxValue = "";
}
this.getData().then(data => { //
this.tableData = data //
let f = params.listdataFieldName || "Records";
this.getData().then(data => {
if('Total' in data){
this.tablePage.total = data.Total ;
}else{
this.tablePage.total = data.total ;
}
this.tableData = data[f];
});
},
getData(key) { //
this.lastKey = key; //
let filter = { rules: [], op: 'or' }; //
if (key) { //
for (let i = 0; i < this.searchFieldNames.length; i++) { //
let field = this.searchFieldNames[i]; //
filter.rules.push({ value: key, field: field, op: "like" }); //
var params = {}; //
params.page = this.tablePage.currentPage; //
params.limit = this.tablePage.pageSize; //
params.order_bys = []; //
params.search_rules = []; //
if(key){
key = this.$mk.trim(key);
}
if (key) {
for (let i = 0; i < this.searchFieldNames.length; i++) {
let field = this.searchFieldNames[i];
params.search_rules.push({ //
column: field, //
mode: "like", //
value: "%" + key + "%" //
});
}
}
return this.$mk.post({ //
url: this.actions.getList, //
data: { //
filter: filter, //
model: this.modelName, //
orderby: this.orderBy //
}
return this.$mk.getPagedData({
url: this.actions.getList,
data: params
});
},
clickEvent() { //
@ -173,51 +207,68 @@ export default {
if (this.readonly) {
return;
}
let keyCode = e.$event.keyCode;
if (keyCode == 38 || keyCode == 113|| keyCode == 115) {
let keyCode = e.$event.keyCode;
if (keyCode == 38 || keyCode == 113 || keyCode == 115) {
return;
}
}
if (keyCode == 40) {
this.$refs.xDown.showPanel()
this.$refs.xDown.showPanel()
const grid = this.$refs.xgrid;
console.log(grid)
if(!grid) return;
if (!grid) return;
grid.focus();
let row = grid.getCurrentRecord();
var ds = grid.getTableData();
if (!row) {
grid.setCurrentRow(ds.tableData[0]);
}
return false;
}
if(keyCode == 13){
const grid = this.$refs.xgrid;
if(!grid) return;
if (keyCode == 13) {
const grid = this.$refs.xgrid;
if (!grid) return;
let row = grid.getCurrentRecord();
this.selectEvent({
row : row
row: row
})
return false;
}
const cellValue = this.textboxValue;
if (!cellValue) {
if(params.dataType == "string"){
if (params.dataType == "string") {
this.$emit('input', "");
}else{
if (params.onDataChanged) {
params.onDataChanged({ value: "" })
}
}
else if (params.dataType == "object") {
this.$emit('input', null);
if (params.onDataChanged) {
params.onDataChanged({ value: null })
}
}
else {
this.$emit('input', ["", ""]);
if (params.onDataChanged) {
params.onDataChanged({ value: ["", ""] })
}
}
if (params.onDataChanged) {
params.onDataChanged({ value: ["", ""]})
}
}
this.loading = true //
this.getData(cellValue).then(data => { //
let f = params.listdataFieldName || "Records";
this.getData(cellValue).then(data => {
this.loading = false
this.tableData = data
if('Total' in data){
this.tablePage.total = data.Total ;
}else{
this.tablePage.total = data.total ;
}
this.tableData = data[f];
})
},
suffixClick() { //
@ -227,24 +278,35 @@ export default {
this.tablePage.currentPage = currentPage
this.tablePage.pageSize = pageSize
this.loading = true
const { params } = this
let f = params.listdataFieldName || "Records";
this.getData(this.lastKey).then(data => {
this.loading = false
this.tableData = data
if('Total' in data){
this.tablePage.total = data.Total ;
}else{
this.tablePage.total = data.total ;
}
this.tableData = data[f];
})
},
selectEvent(e) { //
const { params } = this
let textField = params.textField;
this.textboxValue = e.row[textField];
if(params.dataType == "string"){
if (params.dataType == "string") {
this.$emit('input', e.row[textField]);
}
else{
this.$emit('input', [e.row.ID, e.row[textField]]);
}
}
else if (params.dataType == "object") {
this.$emit('input', e.row);
}
else {
this.$emit('input', [e.row.ID, e.row[textField]]);
}
if (params.onDataChanged) {
params.onDataChanged({ value: [e.row.ID, e.row[textField]],data:e.row })
params.onDataChanged({ value: [e.row.ID, e.row[textField]], data: e.row })
}
this.$refs.xDown.hidePanel()
},
@ -258,15 +320,19 @@ export default {
let textField = params.textField;
this.textboxValue = selectedRow[textField];
this.modalVisible = false;
if(params.dataType == "string"){
if (params.dataType == "string") {
this.$emit('input', selectedRow[textField]);
}else{
}
else if (params.dataType == "object") {
this.$emit('input', selectedRow);
}
else {
this.$emit('input', [selectedRow.ID, selectedRow[textField]]);
}
if (params.onDataChanged) {
params.onDataChanged({ value: [selectedRow.ID, selectedRow[textField]],data:selectedRow })
params.onDataChanged({ value: [selectedRow.ID, selectedRow[textField]], data: selectedRow })
}
}
}

View File

@ -32,6 +32,14 @@
import BASE_URL from '@/services/base/api.js'; //
/*
grid 选择数据的组件支持分页
默认将选择的数据以 [id,name] 的方式返回
params.dataType = 'object' 将会以 完整数据返回
params.dataUrl 可以自定义数据请求URL
*/
export default {
name: 'MkGridDataSelector',
props: {
@ -65,7 +73,7 @@ export default {
],
modalWidth: 800,
modalHeight: 600,
searchFieldNames: ['name', 'code'],
searchFieldNames: ['name'],
tablePage: {
total: 0,
currentPage: 1,
@ -117,13 +125,19 @@ export default {
}
}
if (this.row[column.field] && this.row[column.field][1]) {
if(column && column.params && column.params.dataType == "object"){
if(this.row[column.field]){
this.textboxValue = this.row[column.field][column.params.textField];
}
}
else if (this.row[column.field] && this.row[column.field][1]) {
this.textboxValue = this.row[column.field][1];
}
this.getData().then(data => {
this.tablePage.total = data.total;
this.tableData = data[this.listdataFieldName];
});
@ -139,7 +153,9 @@ export default {
params.limit = this.tablePage.pageSize; //
params.order_bys = []; //
params.search_rules = []; //
if(key){
key = this.$mk.trim(key);
}
if (key) {
for (let i = 0; i < this.searchFieldNames.length; i++) {
let field = this.searchFieldNames[i];
@ -236,12 +252,15 @@ export default {
let id = this.getIdValue({row:params.row});
let textField = column.params.textField;
let textField = column.params.textField;
this.textboxValue = params.row[textField];
row[column.field] = [id, params.row[textField]];
console.log(row)
if(column.params && column.params.dataType == 'object'){
row[column.field] = Object.assign({},params.row)
}else{
row[column.field] = [id, params.row[textField]];
}
this.params.$table.$emit("pulldownSelected", { row,selectedData : params.row, column, name: column.params.name, params: this.params });
this.$refs.xDown.hidePanel()
},
@ -252,7 +271,14 @@ export default {
let textField = column.params.textField;
this.textboxValue = params.row[textField];
row[column.field] = [id, params.row[textField]];
if(column.params && column.params.dataType == 'object'){
row[column.field] = Object.assign({},params.row)
}else{
row[column.field] = [id, params.row[textField]];
}
console.log(id)
this.modalVisible = false;
let rows = this.$refs.popup.getConfirmData();
@ -267,7 +293,16 @@ export default {
let id = this.getIdValue({row:selectedRow});
let textField = column.params.textField;
this.textboxValue = selectedRow[textField];
row[column.field] = [id, selectedRow[textField]];
if(column.params && column.params.dataType == 'object'){
row[column.field] = Object.assign({},selectedRow)
}else{
row[column.field] = [id, selectedRow[textField]];
}
this.modalVisible = false;
let rows = this.$refs.popup.getConfirmData();

View File

@ -1,5 +1,6 @@
import modal from './libs/function/modal' // 加载modal
import apis from './libs/function/apis' // 加载apis
import funs from './libs/function/funs' // 加载apis
import uploader from './libs/uploader/uploader' // 加载uploader
import form from './libs/function/form' // 加载form
import config from './config' // 加载config
@ -85,7 +86,11 @@ VXETable.formats.mixin({
formatYesNo({ cellValue }) { // 格式化是否
return cellValue ? '是' : '否'
},
formatRef({ cellValue }) { // 格式化参照
formatRef({ cellValue,column }) { // 格式化参照
if(column && column.params && column.params.dataType == "object" && column.params.textField && typeof(cellValue) == "object"){
return cellValue[column.params.textField];
}
return cellValue && cellValue[1] ? cellValue[1] : ''
},
formatStatus({ cellValue }) { // 格式化状态
@ -125,14 +130,21 @@ VXETable.formats.mixin({
}
return '';
},
formatPercentage({ cellValue }) { // 百分比的形式显示
if(cellValue === 0) return '0%';
if(!cellValue) return '';
return parseFloat(cellValue).toFixed(2) +"%";
},
})
var mk = {
...modal, // modal
...apis,
...apis, //API调用相关的方法
...form,
...funs, //常用的方法
...form, //表单常用的方法
config: config,

View File

@ -4,28 +4,41 @@ export default {
formatFormData: function ({ data, rules }) { // 格式化表单数据
rules.forEach(rule => { // 循环规则
if (!rule.dataRule){
return;
}
if (rule.field in data) { // 如果字段在数据中
let value = data[rule.field]; // 获取值
if (rule.dataRule && rule.dataRule.type == "integer") { // 如果是整数
data[rule.field] = parseInt(value); // 转换为整数
let value = data[rule.field]; // 获取值
if (rule.dataRule.fromField) {
value = value[rule.dataRule.fromField];
}
let saveField = rule.field;
if(rule.dataRule.saveField){
saveField = rule.dataRule.saveField;
}
if (rule.dataRule && rule.dataRule.type == "number") { // 如果是整数
data[rule.field] = parseFloat(value); // 转换为整数
if (rule.dataRule.type == "integer") { // 如果是整数
data[saveField] = parseInt(value); // 转换为整数
}
if (rule.dataRule && rule.dataRule.type == "timestamp") { // 如果是时间戳
data[rule.field] = parseInt(new Date(data[rule.field]).getTime() / 1000); // 转换为时间戳
else if (rule.dataRule.type == "number") { // 如果是整数
data[saveField] = parseFloat(value); // 转换为整数
}
if (rule.dataRule && rule.dataRule.type == "string") { // 如果是字符串
if(data[rule.field] === true){
data[rule.field] = "true";
else if (rule.dataRule.type == "timestamp") { // 如果是时间戳
data[saveField] = parseInt(new Date(value).getTime() / 1000); // 转换为时间戳
}
else if (rule.dataRule.type == "string") { // 如果是字符串
if(data[saveField] === true){
data[saveField] = "true";
}
else if(data[rule.field] === false){
data[rule.field] = "false";
else if(data[saveField] === false){
data[saveField] = "false";
}
else if(data[rule.field]){
data[rule.field] = data[rule.field] + "";
else if(data[saveField]){
data[saveField] = value + "";
}
}
else {
data[saveField] =value ;
}
}
});

View File

@ -0,0 +1,12 @@
import JSONbig from 'json-bigint'
export default {
toBigInt(id) {
return JSONbig.parse(`{"v":${id}}`).v;
},
trim(str) {
return str.replace(/^\s+|\s+$/gm, '');
}
}

View File

@ -0,0 +1,627 @@
<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>
<vxe-table 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="mes_materials" title="子件" width="160" :params="editorMaterials" formatter="formatRef"
:edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>
<vxe-column field="mes_warehouse" title="预出仓库" width="160" :params="editorWarehouse" formatter="formatRef"
:edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>
<vxe-column field="sub_qty" title="需用数量" width="120" :edit-render="{ name: '$input', props: { type: 'integer' } }">
</vxe-column>
<vxe-column field="loss_rate" title="损耗率%" width="120" formatter="formatPercentage"
:edit-render="{ name: '$input', props: { type: 'integer' } }">
</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';
export default {
name: 'BathroomPartsUpdate',
i18n: require('./i18n'),
components: {},
props: {
pageMode: {
type: String,
default: "edit"
},
dataId: {
}
},
data() {
//let _this = this;
//
var pageData = {
//
currentConfigName: "",
// ID
currentBeid: 0,
uploadDefaultImg: null,
detailDataFieldName: "mes_bom",
actions: {
get: `${BASE_URL.BASE_URL}/MesBom/v1/mes/bom/detail`,
create: `${BASE_URL.BASE_URL}/MesBom/v1/mes/bom/create`,
update: `${BASE_URL.BASE_URL}/MesBom/v1/mes/bom/update`,
detailsData: `${BASE_URL.BASE_URL}/MesBom/v1/mes/bom/sub/list`,
saveDetails: `${BASE_URL.BASE_URL}/MesBom/v1/mes/bom/sub/batchHandle`,
},
keyName: 'id',
//
isEdit: false,
//
formOptions: {
data: {
material_id: 0,
warehouse_id: 0,
version: '',
is_default: 0
},
//
titleWidth: 100,
//
titleAlign: 'right',
//
rules: {
mes_materials: [
{ required: true, message: '请输入父件' }
],
version: [
{ required: true, message: '请输入版本号' }
]
},
//
items: [
{
title: '父件', span: 12,
field: 'mes_materials',
dataRule: {
fromField: "id",
saveField: "material_id" // fromFieldsaveField
},
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
dataType: "object",
valueField: "id",
textField: "name",
listdataFieldName: 'MesMaterials',
dataUrl: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/list`
}
}
}
},
{
title: '默认仓库', span: 12,
field: 'mes_warehouse',
dataRule: {
fromField: "id",
saveField: "warehouse_id" // fromFieldsaveField
},
itemRender: {
name: 'MkFormDataSelector', props: {
params: {
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`
}
}
}
},
{ field: 'version', title: '版本号', span: 12, itemRender: { name: '$input' } },
{ field: 'is_default', title: '是否默认', span: 12, itemRender: { name: '$switch', props: { openLabel: '是', openValue: 1, closeValue: 0, closeLabel: '否' } } },
]
},
//
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: {
desc() {
return this.$t('editPageDesc')
}
},
created() {
// 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();
},
//
methods: {
detailsDataLoad(id) {
this.$mk.post({
url: this.actions.detailsData,
loading: "加载中...",
data: {
"page": 1,
"limit": 10000,
"start_time": 0,
"end_time": 0,
"search_rules": [
{
column: "bom_id", //
mode: "=", //
value: id.toString()
}
],
"order_bys": [
]
},
useBigInt: true
}).then(a => {
this.detailsSourceData = a.data.MesBomSub || [];
this.detailsData = JSON.parse(JSON.stringify(a.data.MesBomSub || []));
this.detailsDataInit();
});
},
heightInit() {
this.$nextTick(() => {
let h = this.$mk.getWindowSize().height - this.$mk.getOffsetTop(this.$refs.xTable.$el) - 180;
this.table1Height = h;
});
},
detailsDataInit() {
for (let i = this.detailsData.length; i < 10; i++) {
this.detailsData.push({});
}
},
// id
getDataId() {
let dataId = this.dataId;
if (this.$route.params.id) {
dataId = this.$route.params.id;
}
if (!dataId) {
dataId = 0;
}
return dataId;
},
getDataId_BigInt() {
let dataId = this.getDataId();
return this.$mk.toBigInt(dataId);
},
//
back() {
//
if (!this.isEdit) {
this.$closePage({
closeRoute: "/MesBom/MesBomAdd"
});
} else {
//
this.$closePage({
closeRoute: "/MesBom/MesBomUpdate"
});
}
//
this.$openPage('/MesBom/MesBomList')
},
//
ok() {
let hasDetails = false;
let includeMainMaterials = false;
this.detailsData.forEach(item => {
if (item.mes_materials && item.mes_materials.id) {
hasDetails = true;
if(this.formOptions.data.mes_materials
&& this.formOptions.data.mes_materials.id
&& this.formOptions.data.mes_materials.id.toString() == item.mes_materials.id.toString()){
includeMainMaterials = true;
}
}
});
let saveDetails = (dataId) => {
dataId = dataId || this.getDataId_BigInt();
let ds = [];
this.detailsData.forEach(item => {
if (item.mes_materials && item.mes_materials.id) {
let o = {};
o.material_id = this.$mk.toBigInt(item.mes_materials.id);
if (item.mes_warehouse) {
o.warehouse_id = this.$mk.toBigInt(item.mes_warehouse.id);
} else {
o.warehouse_id = 0;
}
o.sub_qty = parseFloat(item.sub_qty || 0);
o.loss_rate = parseFloat(item.loss_rate || 0);
if (item.id) {
o.id = this.$mk.toBigInt(item.id);
}
ds.push(o);
}
});
console.log(ds);
var postdata = {
insertList: [],
updateList: [],
deleteList: this.deletedDetailsData
};
ds.forEach(item => {
delete item._X_ROW_KEY;
item.bom_id = dataId;
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.message);
}
}).catch((a) => {
this.$mk.error(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.message);
}
});
};
//
this.$mk.validateForm({ form: this.$refs.xForm }).then(() => { //
if(!hasDetails){
this.$mk.error(`子件不能为空`);
}
else if(includeMainMaterials){
this.$mk.error(`子件不能跟父件一样`);
}
else{
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: {
}
};
</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

@ -0,0 +1,120 @@
<template>
<basic-page-list :desc="desc" :options="pageOptions"></basic-page-list>
</template>
<script>
import BASE_URL from '@/services/mes/api.js';
export default {
i18n: require("./i18n"),
props: {
},
data() {
return {
pageOptions: {}
};
},
//
computed: {
//
desc() {
return this.$t("pageDesc");
}
},
//
created() {
this.optionsInit();
},
//
methods: {
optionsInit() {
//
var pageData = { //
keyName: 'id', //
listFieldName: 'MesBom',
addPageUrl: "/MesBom/MesBomAdd",
editPageUrl: "/MesBom/MesBomUpdate/",
//
actions: { // Api
MesBomList: `${BASE_URL.BASE_URL}/MesBom/v1/mes/bom/list`,
MesBomBatchDelete: `${BASE_URL.BASE_URL}/MesBom/v1/mes/bom/batchDelete`
},
start_time: 0, //
end_time: 0, //
//
searchFormData: {
title: '',
desc: '',
},
//
searchRules: [
{ key: "title", mode: "like" },
{ key: "desc", mode: "like" }
],
//
searchFormItems: [ //
{ field: 'title', title: '标题', span: 5, itemRender: { name: '$input', props: { placeholder: '请输入标题' } } },
{ field: 'desc', title: '描述', span: 5, itemRender: { name: '$input', props: { placeholder: '请输入描述' } } },
{ span: 8, slots: { default: 'date' } }, //
{
align: 'right', span: 4, itemRender: { //
name: '$buttons', children: [{ props: { type: 'submit', content: '搜索', status: 'primary' } }, //
{ props: { type: 'reset', content: '重置' } }]
}
}
],
//
gridOptions: { //
height: '100%', // 100%
stripe: true, //
id: 'datagrid_1', //
//
columns: [
{ type: 'checkbox', width: 50 }, //
{ type: 'seq', width: 30 }, //
{ title: '操作', slots: { default: 'op' }, width: 120 },
// =============================== Start ===============================
{ field: 'version', sortable: true, title: 'BOM版本', width: 250 }, // BOM
{ 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.MesBomList;
pageData.actions.delete = pageData.actions.MesBomBatchDelete;
pageData.gridOptions = Object.assign({}, this.$mk.config.defaults.gridOptions, pageData.gridOptions); //
this.pageOptions = pageData;
},
},
watch: {
}
};
</script>

View File

@ -0,0 +1,14 @@
module.exports = {
messages: {
CN: {
pageDesc:'单位管理'
},
HK: {
pageDesc:'单位管理'
},
US: {
pageDesc:'单位管理'
}
}
}

View File

@ -0,0 +1,86 @@
const FunName = 'MesBom';
const FunTitle = '物料清单';
const InvisibleRouters = 'Create,Update,Detail,Delete,BatchDelete,BatchUpdate,BatchCreate,ExportExcel,LogDetail,LogList,Settings,SettingsUpdate,ImportExcel'.split(',')
const InvisibleRouters2 = ''.split(',')
// 视图组件
const view = {
tabs: () => import('@/layouts/tabs'),
blank: () => import('@/layouts/BlankView'),
page: () => import('@/layouts/PageView')
}
// 路由组件注册
const routerMap = {
};
routerMap[FunName]= {
name: FunTitle,
icon: 'idcard',
component: view.blank,
meta: {
},
authority: {
permission: [],
}
};
routerMap[FunName + 'List']= {
name: FunTitle,
icon: 'idcard',
path: `/${FunName}/${FunName}List`,
meta:{
page:{ cacheAble:false}
},
component: () => import(`@/pages/Middle/Mes/MesBom/MesBom/List.vue`),
authority: {
permission: [],
}
};
routerMap[FunName + 'Create']= {
name: FunTitle,
icon: 'idcard',
path: `/${FunName}/${FunName}Add`,
component: () => import(`@/pages/Middle/Mes/MesBom/MesBom/Edit`),
meta: {
invisible: true,
},
authority: {
permission: [],
}
};
routerMap[FunName + 'Update']= {
name: FunTitle,
icon: 'idcard',
path: `/${FunName}/${FunName}Update/:id`,
component: () => import(`@/pages/Middle/Mes/MesBom/MesBom/Edit`),
meta: {
invisible: true,
},
authority: {
permission: [],
}
};
InvisibleRouters.forEach(item => {
let name = FunName + item;
if (!(name in routerMap)) {
routerMap[name] = {
meta: {
invisible: true
}
}
}
})
InvisibleRouters2.forEach(item => {
let name = item;
if (!(name in routerMap)) {
routerMap[name] = {
meta: {
invisible: true
}
}
}
})
export default routerMap

View File

@ -21,32 +21,6 @@ routerMap['basic']= {
permission: [],
}
};
/*
routerMap['basic_materials']= {
name: '基础档案',
icon: 'idcard',
path: `/MesMaterials/MesMaterialsList`,
meta:{
page:{ cacheAble:false}
},
component: () => import(`@/pages/Middle/Mes/MesMaterials/MesMaterials/List`),
authority: {
permission: [],
}
};
routerMap['basic_unit']= {
name: '基础档案',
icon: 'idcard',
path: `/MesUnit/MesUnitList`,
meta:{
page:{ cacheAble:false}
},
component: () => import(`@/pages/Middle/Mes/MesUnit/MesUnit/List`),
authority: {
permission: [],
}
};
*/
export default routerMap

View File

@ -15,6 +15,7 @@ import MesWarehouse from '@/router/Middle/Mes/MesWarehouse/router.map.js'
import MesEnum from '@/router/Middle/Mes/MesEnum/router.map.js'
import MesBom from '@/router/Middle/Mes/MesBom/router.map.js'
import MesUnitRouterMap from '@/router/Middle/Mes/MesUnit/router.map.js'
import basic from '@/router/Middle/Mes/basic/router.map.js'
@ -33,7 +34,7 @@ const routerMap = Object.assign({},
MesStock,
MesWarehouse,
MesEnum,
MesBom,
basic
)