middleground_code_v2/src/views/masterDataOptions/dataOrigin/index.vue

1143 lines
32 KiB
Vue
Raw Normal View History

2024-03-26 11:18:19 +08:00
<script src="configData.js"></script>
<template>
<div class="wrap">
<div class="btn">
<div class="chunk">
<el-button
icon="el-icon-back"
@click="
$router.replace({ path: '/integrationOption/masterDataOptions' })
"
>返回
</el-button
>
</div>
<div class="chunk">
<el-button
icon="el-icon-first-aid-kit"
type="primary"
@click="saveHandle"
:loading="saveLoading"
>保存
</el-button
>
</div>
</div>
<div class="main">
<div class="left" v-loading="mainLoading">
<div class="title">
数据表
</div>
<div class="receipts">
<div class="label">单据规则:</div>
<div class="receiptsList" @click="openReceiptsHandle">
<template v-if="!receiptsShowTableData.length">点击选择单据规则</template>
<template v-else>
<div class="receiptsItem" v-for="(item,index) in receiptsShowTableData">{{ item.dbValue }}</div>
</template>
</div>
</div>
<div class="mainTable">
<BaseTable
ref="mainTable"
:tableData="mainTableData"
:tabLoading="mainTabLoading"
:tableColumn="mainTableColumn"
:border="false"
:funData="mainFunData"
tableHeight="25vh"
:highlightCurrent="true"
@radioChange="mainOnClick"
@onFunc="mainOnFunc"
>
<template #dbType="{row}">
{{ row.dbType === '1' ? '主表' : '子表' }}
</template>
</BaseTable>
<div class="mainAddRow">
<el-link
type="primary"
@click="addMainAddRow"
:underline="false"
>+ 添加
</el-link
>
</div>
</div>
<div class="title">
表字段
</div>
<div class="activedTable">
<BaseTable
ref="activedTable"
:tableData="activedTableData"
:tabLoading="activedTabLoading"
:tableColumn="activedTableColumn"
:border="false"
:funData="activedFunData"
tableHeight="30vh"
:highlightCurrent="true"
@radioChange="activedOnClick"
@onFunc="activedOnFunc"
>
<template #filedType="{row}">
{{ dataTypeDist[row.filedType] }}
</template>
</BaseTable>
<div class="mainAddRow" v-if="mainActivedRow">
<el-link
type="primary"
@click="activedAddRow"
:underline="false"
>+ 添加
</el-link
>
</div>
</div>
</div v-loading=>
<div class="right">
<template v-if="activedTableRow">
<div class="btn">
<el-button
type="primary"
@click="activedRowSaveHandle"
>暂存
</el-button>
</div>
<div class="title">
表字段
</div>
<div class="optionForm">
<baseNewForm
ref="optionForm"
:spanNumber="24"
:isFunBtn="false"
:formRow="optionFormRow"
:ruleForm="optionRuleForm"
:labelPosition="'left'"
@onSelect="selectChangeHanlde"
@inputBlur="optionFormInputBlur"
@onSubmit="optionOnSubmit"
>
2024-03-26 11:18:19 +08:00
</baseNewForm>
<baseNewForm
ref="typeOptionForm"
:spanNumber="24"
:isFunBtn="false"
:formRow="typeOptionFormRow"
:ruleForm="typeOptionRuleForm"
:labelPosition="'left'"
@onSelect="typeSelectChangeHanlde"
@onSubmit="typeOptionOnSubmit"
>
2024-03-26 11:18:19 +08:00
</baseNewForm>
<baseNewForm
ref="propertyForm"
:spanNumber="24"
:isFunBtn="false"
:formRow="propertyFormRow"
:ruleForm="propertyRuleForm"
:labelPosition="'left'"
@onSubmit="propertyOnSubmit"
>
2024-03-26 11:18:19 +08:00
</baseNewForm>
</div>
<div class="smtitle">
可选控间属性
</div>
<div class="checkBoxList">
<el-checkbox-group v-model="propertyActiveList" @change="propertyActiveListChangeHanlde">
<el-checkbox v-for="(item,index) in propertyList" :label="item.id" :key="item.id">{{
item.label
}}
</el-checkbox>
</el-checkbox-group>
</div>
</template>
<template v-else-if="mainActivedRow">
<div class="btn">
<el-button
type="primary"
@click="mainActivedRowSaveHandle"
>暂存
</el-button>
</div>
<div class="title">
数据表
</div>
<div class="optionForm">
<baseNewForm
ref="mainOptionForm"
:spanNumber="24"
:isFunBtn="false"
:formRow="mainOptionRow"
:ruleForm="mainOptionForm"
:labelPosition="'left'"
@onSubmit="mainOptionOnSubmit"
>
2024-03-26 11:18:19 +08:00
</baseNewForm>
</div>
</template>
</div>
</div>
<baseDialog v-model="receiptsShow" width="50%" @confirm="receiptsConfirm">
<div class="receiptsTable">
<BaseTable
ref="receiptsTable"
:showIndex="true"
:tableData="receiptsTableData"
:tableColumn="receiptsTableColumn"
:border="false"
:funData="receiptsFunData"
tableHeight="30vh"
@onFunc="receiptsOnFunc"
>
2024-03-26 11:18:19 +08:00
<template #dbType="{row}">
<el-select v-model="row['dbType']" placeholder="请选择"
@change="(val)=>ruleTypeSeleceChangHandle(val,row)"
>
2024-03-26 11:18:19 +08:00
<el-option
v-for="item in ruleTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
2024-03-26 11:18:19 +08:00
</el-option>
</el-select>
</template>
<template #dbValue="{row}">
<div v-if="!row['dbType']">请选择格式类型</div>
<div v-else-if="row['dbType'] === '1'">{{ row.dbValue }}</div>
<div v-else-if="row['dbType'] === '2'">
<el-input v-model="row.dbValue"></el-input>
</div>
<div v-else-if="row['dbType'] === '3'">
<el-select v-model="row.dbValue" placeholder="请选择">
<el-option
v-for="item in dateOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
2024-03-26 11:18:19 +08:00
</el-option>
</el-select>
</div>
<div v-else-if="row['dbType'] === '4'">
<el-input v-model="row.dbValue" @input="(val)=>integerNumber(val,row)"></el-input>
</div>
</template>
</BaseTable>
<div class="receiptsAddRow">
<el-link
type="primary"
@click="receiptsAddRow"
:underline="false"
>+ 添加
</el-link
>
</div>
</div>
</baseDialog>
</div>
</template>
<script>
import BaseTable from '@/views/intergrationTask/compoments/baseTable.vue'
import configData from './configData'
import { getApiModuleApi } from '@/api/apiChunks/index.js'
import baseNewForm from '../compoments/baseNewForm'
import { deepClone } from '@/utils/index.js'
import baseDialog from '@/views/integrationOption/compoments/baseDialog'
2024-03-26 11:18:19 +08:00
export default {
data() {
return {
saveLoading: false,
mainLoading: false,
//options表
optionFormRow: configData.optionFormRow,
//数据表option表
mainOptionRow: configData.mainOptionRow,
//type选中后的表
typeOptionFormRow: [],
propertyFormRow: [],//可选属性表表格(渲染)
mainTableData: [],//主表数据
activedTableData: [],//子表数据(单击主表后赋值)
mainTabLoading: false,//主表loading
activedTabLoading: false,//选中表loading
optionRuleForm: {},//表字段options数据
mainOptionForm: {},//数据表数据
typeOptionRuleForm: {},//表字段根据type数据
propertyRuleForm: {},//可选属性表数据
mainTableColumn: [
{ title: '英文名', id: 'dbName' },
{ title: '表类型', id: 'dbType' },
{ title: '表说明', id: 'remark' }
2024-03-26 11:18:19 +08:00
],
mainActivedRow: false, // 数据表选中行暂存
activedTableRow: false, //子表选中行暂存
activedTableColumn: [
{ title: '中文名', id: 'chName' },
{ title: '英文名', id: 'enName' },
{ title: '字段类型', id: 'filedType' },
{ title: '长度', id: 'filedLength' }
2024-03-26 11:18:19 +08:00
],//子表行数据
mainFunData: [
{
text: '删除',
color: 'red'
2024-03-26 11:18:19 +08:00
}
],//主表操作兰
activedFunData: [
{
text: '删除',
color: 'red'
2024-03-26 11:18:19 +08:00
}
],//子表操作栏
propertyActiveList: [],//可选属性选中列表v-model)
propertyList: [
{
label: '大于',
id: 'up'
2024-03-26 11:18:19 +08:00
}, {
label: '小于',
id: 'low'
2024-03-26 11:18:19 +08:00
},
{
label: '正则',
id: 'pattern'
2024-03-26 11:18:19 +08:00
},
{ label: '正则提示', id: 'message' }
2024-03-26 11:18:19 +08:00
],//可选属性列表
//radiolist属性数字字典
propertyDist: {
up: {
type: 'select',
id: 'up',
title: '大于',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
},
low: {
type: 'select',
id: 'low',
title: '小于',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
},
pattern: {
type: 'input',
id: 'pattern',
title: '正则',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16
2024-03-26 11:18:19 +08:00
},
message: {
type: 'input',
id: 'message',
title: '正则提示',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16
2024-03-26 11:18:19 +08:00
}
},
//可选属性表数据字典
typeDist: {
select: [
{
type: 'select',
id: 'service',
title: '服务名称',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
},
{
type: 'select',
id: 'label',
title: 'label',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
}, {
type: 'input',
id: 'value',
title: 'value',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: true,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
}
],
radio: [
{
type: 'select',
id: 'service',
title: '服务名称',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
},
{
type: 'select',
id: 'label',
title: 'label',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
}, {
type: 'input',
id: 'value',
title: 'value',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: true,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
}
],
treeselect: [
{
type: 'select',
id: 'service',
title: '服务名称',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
},
{
type: 'select',
id: 'label',
title: 'label',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
}, {
type: 'input',
id: 'value',
title: 'value',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: true,
required: false,
fontSize: 16,
options: []
2024-03-26 11:18:19 +08:00
},
{
type: 'select',
id: 'upId',
title: 'upId',
2024-03-26 11:18:19 +08:00
row: 24,
disabled: false,
required: true,
fontSize: 16,
options: []
}
]
2024-03-26 11:18:19 +08:00
},
serviceOptions: [],
labelOptions: [],
//单据规则相关
receiptsShow: false,//单据规则dialog
receiptsTableData: [{}],//表单数据
receiptsFunData: [
{
text: '删除',
color: 'red'
2024-03-26 11:18:19 +08:00
}
],
receiptsTableColumn: [
{
title: '类型',
id: 'dbType'
2024-03-26 11:18:19 +08:00
},
{
title: '格式规则',
id: 'dbValue'
2024-03-26 11:18:19 +08:00
}
],
ruleTypeOptions: [
{
label: '连接符号',
value: '1'
2024-03-26 11:18:19 +08:00
}, {
label: '字符串',
value: '2'
2024-03-26 11:18:19 +08:00
}, {
label: '日期',
value: '3'
2024-03-26 11:18:19 +08:00
}, {
label: '流水号',
value: '4'
}
2024-03-26 11:18:19 +08:00
],
dateOptions: [
{
label: 'yyyy-MM-dd',
value: 'yyyy-MM-dd'
2024-03-26 11:18:19 +08:00
}, {
label: 'yyyyMMdd',
value: 'yyyyMMdd'
2024-03-26 11:18:19 +08:00
}, {
label: 'yyyy-MM-dd HH:mm:ss',
value: 'yyyy-MM-dd HH:mm:ss'
2024-03-26 11:18:19 +08:00
}, {
label: 'yyyyMMddHHmmss',
value: 'yyyyMMddHHmmss'
2024-03-26 11:18:19 +08:00
}, {
label: 'yyyyMMddHHmmssSSS',
value: 'yyyyMMddHHmmssSSS'
}
2024-03-26 11:18:19 +08:00
],
receiptsShowTableData: [],
//数据类型字段
dataTypeDist: {}
}
2024-03-26 11:18:19 +08:00
},
methods: {
// 下拉初始化
async initSelect() {
//数据类型下拉
const type = await getApiModuleApi({
tl: 'generalServiceImpl',
as: 'dictionaryshop',
dj: 'selectDictionaryshop'
}, { tab_name: 'mdm', column_name: 'mdm_filed_type' })
2024-03-26 11:18:19 +08:00
this.optionFormRow[2].elCol[0].options = []
type.attribute.forEach(item => {
//创造数据字段给表单插槽显示(字段类型)
this.$set(this.dataTypeDist, item.column_value, item.column_content)
this.optionFormRow[2].elCol[0].options.push({
label: item.column_content,
id: item.column_value
})
})
//服务名下拉
const service = await getApiModuleApi({
tl: 'mdmService',
as: 'mdmService',
dj: 'queryMdmModuleServer'
}, { remark: '' })
2024-03-26 11:18:19 +08:00
service.attribute.forEach(item => {
this.serviceOptions.push({
id: item.dbName,
label: item.remark
})
})
},
//数据源初始化
async init() {
this.mainLoading = true
const res = await getApiModuleApi({
tl: 'mdmService',
as: 'mdmService',
dj: 'queryMdmModuleDb'
}, { id: this.$route.query.id })
2024-03-26 11:18:19 +08:00
this.mainTableData = []
this.receiptsShowTableData = res.attribute.mdmTableCodeRuleEntityList
if (res.attribute.mainMdmModuleDb.id) {
this.mainTableData.push({ ...res.attribute.mainMdmModuleDb })
2024-03-26 11:18:19 +08:00
} else {
let tempObj = { dbType: '1', sublistMdmModuleDbFileds: [{}] }
2024-03-26 11:18:19 +08:00
this.mainTableData.push(tempObj)
}
res.attribute.sublistMdmModuleDb.forEach(item => {
if (item.id) {
this.mainTableData.push({ ...item })
2024-03-26 11:18:19 +08:00
}
})
this.mainLoading = false
},
//流水号添加行
receiptsAddRow() {
this.receiptsTableData.push({})
},
//流水号修改事件
integerNumber(val, row) {
row['dbValue'] = row['dbValue'].replace(/[^\d]/g, '')
2024-03-26 11:18:19 +08:00
},
//单据规则相关
openReceiptsHandle() {
this.receiptsTableData = deepClone(this.receiptsShowTableData)
this.receiptsShow = true
},
//单据规则下拉改变事件
ruleTypeSeleceChangHandle(val, row) {
this.$set(row, 'dbValue', '')
2024-03-26 11:18:19 +08:00
if (val === '1') {
row['dbValue'] = '-'
}
},
//表字段下拉触发根据type类型动态对表
selectChangeHanlde(val, index, indexRow, row, init = false) {
if (row.id === 'type') {
this.typeOptionFormRow = []
if (!init) {
this.typeOptionRuleForm = {
value: 'id'
2024-03-26 11:18:19 +08:00
}
}
if (val && this.typeDist[val]) {
this.typeDist[val].forEach(item => {
// 如果是服务名称则将请求下来的服务名用上
if (item.id === 'service') {
item.options = deepClone(this.serviceOptions)
}
let tempObj = {
elCol: [
{
...item
}
]
}
this.typeOptionFormRow.push(tempObj)
})
}
}
},
//type表下拉触发目的是为了服务名称下拉后拿到label
async typeSelectChangeHanlde(val, index, indexRow, row, initFlag = false) {
if (row.id === 'service') {
if (val) {
const res = await getApiModuleApi({
tl: 'mdmService',
as: 'mdmService',
dj: 'queryMdmModuleServerFiled'
}, { dbName: val })
2024-03-26 11:18:19 +08:00
this.labelOptions = []
res.attribute.forEach(item => {
this.labelOptions.push({
id: item.enName,
label: item.chName
})
})
} else {
this.labelOptions = []
}
this.typeOptionFormRow.forEach(item => {
if (item.elCol[0].id === 'label' || item.elCol[0].id === 'upId') {
if (!initFlag) {
this.$set(this.typeOptionRuleForm, item.elCol[0].id, '')
2024-03-26 11:18:19 +08:00
}
item.elCol[0].options = deepClone(this.labelOptions)
}
})
}
},
//数据表主表暂存方法
mainActivedRowSaveHandle() {
//验证后跳转到mainOptionOnSubmit
this.$refs.mainOptionForm.submitForm()
},
//数据副表暂存方法(){
activedRowSaveHandle() {
//检测重名
let flag = this.activedTableData.some(item => {
if (item['enName'] === this.optionRuleForm['enName'] && item.index != this.optionRuleForm.index) {
this.$vmNews('英文名不允许重复', 'warning')
2024-03-26 11:18:19 +08:00
return true
} else {
return false
}
})
if (flag) return
2024-03-26 11:18:19 +08:00
this.$refs.optionForm.submitForm()
},
//主表验证通过
mainOptionOnSubmit() {
let disabledWords = ['id', 'document_rule', 'document_rule_num', 'sorts', 'create_user_id', 'create_time', 'modify_user_id', 'modify_time', 'sts', 'org_id']
if (disabledWords.includes(this.mainOptionForm.dbName)) {
this.$vmNews(`暂存失败,英文名${this.mainOptionForm.dbName}不合法。`)
return
}
//检测重名
let flag = this.mainTableData.some(item => {
if (item['dbName'] === this.mainOptionForm['dbName'] && item.index != this.mainOptionForm.index) {
this.$vmNews('英文名不允许重复', 'warning')
2024-03-26 11:18:19 +08:00
return true
} else {
return false
}
})
if (flag) return
2024-03-26 11:18:19 +08:00
// 将表值赋值给mainActivedRow
this.$set(this.mainActivedRow, 'dbName', this.mainOptionForm['dbName'])
this.$set(this.mainActivedRow, 'remark', this.mainOptionForm['remark'])
//重新将当前选中主表赋值给activedTableData (不给的话会丢失掉对象)
// this.activedTableData = this.mainActivedRow.sublistMdmModuleDbFileds
// 这里的代码是取消选中号 需要再给上
// this.$refs.mainTable.setCurrent({index: -1})
// this.mainActivedRow = false
},
// 可选属性表变更方法
propertyActiveListChangeHanlde(val) {
this.propertyFormRow = []
// 消除表单里被取消的值
Object.keys(this.propertyRuleForm).forEach(item => {
if (!val.includes(item)) {
this.$delete(this.propertyRuleForm, item)
}
})
if (val === 'up' || val === 'low') {
this.activedTableData.forEach(item => {
tempOptions.push({ label: item.id, chName: item.enName })
2024-03-26 11:18:19 +08:00
})
}
// 通过字典找到值的类型渲染在表单上
val.forEach(item => {
let tempOptions = []
if (item === 'up' || item === 'low') {
this.activedTableData.some(ele => {
if (this.activedTableRow.id === ele.id) return false
ele.mdmModuleDbFiledsRules.forEach(ele02 => {
if (ele02.ruleValue === 'datepick') {
tempOptions.push({ label: ele.chName, id: ele.enName })
2024-03-26 11:18:19 +08:00
}
})
})
}
let tempObj = {
elCol: [
{
...this.propertyDist[item],
options: tempOptions
}
]
}
this.propertyFormRow.push(tempObj)
2024-03-26 11:18:19 +08:00
})
},
// 表格行点击
mainOnClick(val) {
if (val.index === -1) return
this.activedTableRow = false
this.mainActivedRow = val
this.activedTableData = []
this.$nextTick(() => {
this.$refs.mainOptionForm.resetForm()
this.mainOptionForm = deepClone(val)
this.activedTableData = val.sublistMdmModuleDbFileds
})
},
activedOnClick(val) {
this.activedTableRow = val
//清空type带出来的ruleForm
this.typeOptionFormRow = []
this.typeOptionRuleForm = {
value: 'id'
2024-03-26 11:18:19 +08:00
}
this.propertyFormRow = []
this.propertyRuleForm = {}
this.propertyActiveList = []
let propertyRuleForm = []
let optionRuleForm = []
let typeOptionRuleForm = []
console.log(val)
this.$nextTick(() => {
// 重置表单
this.$refs.optionForm.resetForm()
this.optionRuleForm = deepClone(val)
console.log(this.optionRuleForm, 'this.optionRuleForm')
let dom = document.querySelector('.optionForm')
2024-03-26 11:18:19 +08:00
dom.scrollTo({
top: 0,
behavior: 'smooth'
2024-03-26 11:18:19 +08:00
})
if (!val.mdmModuleDbFiledsRules) return
val.mdmModuleDbFiledsRules.forEach(item => {
if (item.ruleCode === 'required' || item.ruleCode === 'disabled') {
console.log(typeof item.ruleValue)
if (!item.ruleValue) {
this.$set(this[item.formName], item.ruleCode, false)
} else if (typeof item.ruleValue === 'boolean') {
this.$set(this[item.formName], item.ruleCode, item.ruleValue)
} else {
this.$set(this[item.formName], item.ruleCode, JSON.parse(item.ruleValue))
}
} else {
this.$set(this[item.formName], item.ruleCode, item.ruleValue)
}
if (item.formName === 'propertyRuleForm') {
propertyRuleForm.push(item.ruleCode)
}
})
if (this.typeOptionRuleForm.service) {
this.typeSelectChangeHanlde(this.typeOptionRuleForm.service, '', '', { id: 'service' }, true)
2024-03-26 11:18:19 +08:00
}
this.selectChangeHanlde(this.optionRuleForm.type, '', '', { id: 'type' }, true)
2024-03-26 11:18:19 +08:00
this.propertyActiveList = propertyRuleForm
this.propertyActiveListChangeHanlde(this.propertyActiveList)
})
},
//配置项表通过
optionOnSubmit() {
this.$refs.typeOptionForm.submitForm()
},
//type表通过
typeOptionOnSubmit() {
this.$refs.propertyForm.submitForm()
},
//可选属性表通过校验
propertyOnSubmit() {
//开始暂存
let tempDist = {
title: true,
row: true,
type: true,
required: true,
disabled: true,
width: true
2024-03-26 11:18:19 +08:00
}
let tempArr = []
let disabledWords = ['id', 'document_rule', 'document_rule_num', 'sorts', 'create_user_id', 'create_time', 'modify_user_id', 'modify_time', 'sts', 'org_id']
if (disabledWords.includes(this.optionRuleForm.enName)) {
this.$vmNews(`暂存失败,英文名${this.optionRuleForm.enName}不合法。`)
return
}
if (this.optionRuleForm.type === 'datepick' || this.optionRuleForm.type === 'daterange') {
if (this.optionRuleForm.filedType != 4) {
this.$vmNews('字段类型与数据类型不合法,请选择日期类型', 'warning')
2024-03-26 11:18:19 +08:00
return
}
}
if (this.optionRuleForm.filedType == 4) {
if (this.optionRuleForm.type !== 'datepick' && this.optionRuleForm.type !== 'daterange') {
this.$vmNews('字段类型与数据类型不合法', 'warning')
2024-03-26 11:18:19 +08:00
return
}
}
this.$set(this.activedTableRow, 'chName', this.optionRuleForm.chName)
this.$set(this.activedTableRow, 'enName', this.optionRuleForm.enName)
this.$set(this.activedTableRow, 'filedType', this.optionRuleForm.filedType)
this.$set(this.activedTableRow, 'filedLength', this.optionRuleForm.filedLength)
this.optionFormRow.forEach(item => {
if (tempDist[item.elCol[0].id]) {
tempArr.push({
ruleName: item.elCol[0].title,
ruleCode: item.elCol[0].id,
ruleValue: this.optionRuleForm[item.elCol[0].id],
ruleType: 2,
formName: 'optionRuleForm'
2024-03-26 11:18:19 +08:00
})
}
})
this.typeOptionFormRow.forEach(item => {
tempArr.push({
ruleName: item.elCol[0].title,
ruleCode: item.elCol[0].id,
ruleValue: this.typeOptionRuleForm[item.elCol[0].id],
ruleType: 2,
formName: 'typeOptionRuleForm'
2024-03-26 11:18:19 +08:00
})
})
this.propertyFormRow.forEach(item => {
tempArr.push({
ruleName: item.elCol[0].title,
ruleCode: item.elCol[0].id,
ruleValue: this.propertyRuleForm[item.elCol[0].id],
ruleType: 2,
formName: 'propertyRuleForm'
2024-03-26 11:18:19 +08:00
})
})
this.activedTableRow.mdmModuleDbFiledsRules = tempArr
},
// 保存
async saveHandle() {
//判断认证规则
if (!this.receiptsShowTableData.length) {
this.$vmNews('单据规则不能为空', 'warning')
2024-03-26 11:18:19 +08:00
return
}
let flag = this.mainTableData.some((mainItem, index) => {
2024-03-26 11:18:19 +08:00
if (!mainItem.dbName) {
this.$vmNews(`数据表第${index + 1}行的英文名不能为空`, 'warning')
2024-03-26 11:18:19 +08:00
return true
}
return mainItem.sublistMdmModuleDbFileds.some((item, index02) => {
if (!item.chName) {
this.$vmNews(`数据表第${index + 1}行表中的${index02 + 1}行表字段数据填写不全`, 'warning')
return true
2024-03-26 11:18:19 +08:00
}
})
})
if (flag) return
2024-03-26 11:18:19 +08:00
this.saveLoading = true
let params = {
id: this.$route.query.id,
mainMdmModuleDb: this.mainTableData[0],
sublistMdmModuleDb: [],
mdmTableCodeRuleEntityList: this.receiptsShowTableData
2024-03-26 11:18:19 +08:00
}
this.mainTableData.forEach((item, index) => {
if (index > 0) {
params.sublistMdmModuleDb.push(item)
}
})
const res = await getApiModuleApi({
tl: 'mdmService',
as: 'mdmService',
dj: 'saveMdmModuleDb'
2024-03-26 11:18:19 +08:00
}, params)
if (res.status === '200') {
this.$vmNews('保存成功!', 'success')
2024-03-26 11:18:19 +08:00
this.init()
}
this.saveLoading = false
},
// 主表按钮
mainOnFunc(row, item) {
if (!row.newFlag) {
this.$vmNews('此行不允许删除', 'warning')
2024-03-26 11:18:19 +08:00
return
}
this.$confirm('确定删除?')
2024-03-26 11:18:19 +08:00
.then((_) => {
this.mainTableData.splice(row.index, 1)
})
.catch((_) => {
})
2024-03-26 11:18:19 +08:00
},
//选中表按钮
activedOnFunc(row) {
if (!row.newFlag) {
this.$vmNews('此行不允许删除', 'warning')
2024-03-26 11:18:19 +08:00
return
}
this.$confirm('确定删除?')
2024-03-26 11:18:19 +08:00
.then((_) => {
this.activedTableData.splice(row.index, 1)
})
.catch((_) => {
})
2024-03-26 11:18:19 +08:00
},
//规则表格删除
receiptsOnFunc(row) {
this.receiptsTableData.splice(row.index, 1)
},
//规则表提交
receiptsConfirm() {
let type = false
let flag = this.receiptsTableData.some((item, index) => {
if (!item.dbType || !item.dbValue) {
this.$vmNews(`请选择${index + 1}行的类型并填写或选择规则`, 'warning')
2024-03-26 11:18:19 +08:00
return true
} else if (item.dbType === '4' && index + 1 !== this.receiptsTableData.length) {
type = true
this.$vmNews(`流水号只允许在最后一行`, 'warning')
2024-03-26 11:18:19 +08:00
return true
} else if (item.dbType === '4') {
type = true
}
})
if (!type) {
this.$vmNews(`请添加流水号`, 'warning')
return
2024-03-26 11:18:19 +08:00
}
if (flag) return
this.receiptsShow = false
this.receiptsShowTableData = deepClone(this.receiptsTableData)
},
//主表添加按钮
addMainAddRow() {
this.mainTableData.push({
'dbName': ``,
'dbType': '2',
'remark': '',
sublistMdmModuleDbFileds: [],
newFlag: true
})
2024-03-26 11:18:19 +08:00
},
//选中表添加按钮
activedAddRow() {
this.activedTableData.push({ newFlag: true, disabled: false, required: false })
2024-03-26 11:18:19 +08:00
},
//表单输入框失焦事件(为了让中文名称可以给显示名)
optionFormInputBlur(id, row) {
if (id === 'chName' && !row.title) {
this.$set(row, 'title', row['chName'])
}
}
},
components: {
baseNewForm,
BaseTable,
baseDialog
},
created() {
this.initSelect()
this.init()
this.$emit('flashActive', 1)
2024-03-26 11:18:19 +08:00
},
watch: {},
computed: {
labelOptionsAuto() {
return this.labelOptions
}
}
}
2024-03-26 11:18:19 +08:00
</script>
<style scoped lang="scss">
::v-deep .el-button {
border-radius: 16px;
}
::v-deep .el-form-item {
display: block !important;
}
.wrap {
background-color: #fbfbfb;
width: 100%;
position: relative;
> .btn {
display: flex;
justify-content: flex-end;
> .chunk {
margin-left: 10px;
}
}
> .main {
margin-top: 10px;
display: flex;
> .left {
flex: 0.75;
height: 85vh;
margin-right: 10px;
background-color: #fff;
border-radius: 8px;
padding: 0 15px;
overflow: auto;
> .title {
color: #000;
font-weight: 600;
margin: 20px 0;
}
> .receipts {
display: flex;
align-items: center;
.receiptsList {
text-align: center;
cursor: pointer;
margin-left: 20px;
padding: 20px;
background-color: #fafafa;
display: flex;
align-items: center;
.receiptsItem {
margin-right: 10px;
}
}
}
.mainTable {
margin-top: 30px;
.mainAddRow {
margin-top: 30px;
border: 1px dotted #ccc;
text-align: center;
height: 50px;
line-height: 50px;
}
}
.activedTable {
margin-top: 30px;
.mainAddRow {
margin-top: 30px;
border: 1px dotted #ccc;
text-align: center;
height: 50px;
line-height: 50px;
}
}
}
> .right {
flex: 0.25;
height: 85vh;
background-color: #fff;
border-radius: 8px;
padding: 0 10px;
overflow-y: auto;
> .btn {
margin-top: 10px;
display: flex;
justify-content: flex-end;
}
> .title {
color: #000;
font-weight: 600;
padding: 20px 0;
border-bottom: 1px solid #EBEBEB;
}
.optionForm {
margin: 30px 0;
height: 50vh;
overflow-y: auto;
}
> .smtitle {
color: #000;
font-weight: 600;
padding: 20px 0;
border-top: 1px solid #EBEBEB;
}
}
}
}
.receiptsAddRow {
margin-top: 30px;
border: 1px dotted #ccc;
text-align: center;
height: 50px;
line-height: 50px;
}
</style>