1212 lines
34 KiB
Vue
1212 lines
34 KiB
Vue
<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"
|
||
:disabled="sonFormDisabled"
|
||
>
|
||
</baseNewForm>
|
||
<baseNewForm
|
||
ref="typeOptionForm"
|
||
:spanNumber="24"
|
||
:isFunBtn="false"
|
||
:formRow="typeOptionFormRow"
|
||
:ruleForm="typeOptionRuleForm"
|
||
:labelPosition="'left'"
|
||
@onSelect="typeSelectChangeHanlde"
|
||
@onSubmit="typeOptionOnSubmit"
|
||
:disabled="sonFormDisabled"
|
||
>
|
||
</baseNewForm>
|
||
<baseNewForm
|
||
ref="propertyForm"
|
||
:spanNumber="24"
|
||
:isFunBtn="false"
|
||
:formRow="propertyFormRow"
|
||
:ruleForm="propertyRuleForm"
|
||
:labelPosition="'left'"
|
||
@onSubmit="propertyOnSubmit"
|
||
:disabled="sonFormDisabled"
|
||
|
||
>
|
||
</baseNewForm>
|
||
</div>
|
||
<div class="smtitle">
|
||
可选控间属性
|
||
</div>
|
||
<div class="checkBoxList">
|
||
<el-checkbox-group :disabled="sonFormDisabled" 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"
|
||
>
|
||
</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"
|
||
>
|
||
<template #dbType="{row}">
|
||
<el-select v-model="row['dbType']" placeholder="请选择"
|
||
@change="(val)=>ruleTypeSeleceChangHandle(val,row)"
|
||
>
|
||
<el-option
|
||
v-for="item in ruleTypeOptions"
|
||
:key="item.value"
|
||
:label="item.label"
|
||
:value="item.value"
|
||
>
|
||
</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"
|
||
>
|
||
</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'
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
sonFormDisabled: false,
|
||
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' }
|
||
],
|
||
mainActivedRow: false, // 数据表选中行暂存
|
||
activedTableRow: false, //子表选中行暂存
|
||
activedTableColumn: [
|
||
{ title: '中文名', id: 'chName' },
|
||
{ title: '英文名', id: 'enName' },
|
||
{ title: '字段类型', id: 'filedType' },
|
||
{ title: '长度', id: 'filedLength' }
|
||
],//子表行数据
|
||
mainFunData: [
|
||
{
|
||
text: '删除',
|
||
color: 'red'
|
||
}
|
||
],//主表操作兰
|
||
activedFunData: [
|
||
{
|
||
text: '删除',
|
||
color: 'red'
|
||
}
|
||
],//子表操作栏
|
||
propertyActiveList: [],//可选属性选中列表(v-model)
|
||
propertyList: [
|
||
{
|
||
label: '大于',
|
||
id: 'up'
|
||
}, {
|
||
label: '小于',
|
||
id: 'low'
|
||
},
|
||
{
|
||
label: '正则',
|
||
id: 'pattern'
|
||
},
|
||
{ label: '正则提示', id: 'message' }
|
||
],//可选属性列表
|
||
//radiolist属性数字字典
|
||
propertyDist: {
|
||
up: {
|
||
type: 'select',
|
||
id: 'up',
|
||
title: '大于',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
},
|
||
low: {
|
||
type: 'select',
|
||
id: 'low',
|
||
title: '小于',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
},
|
||
pattern: {
|
||
type: 'input',
|
||
id: 'pattern',
|
||
title: '正则',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16
|
||
},
|
||
message: {
|
||
type: 'input',
|
||
id: 'message',
|
||
title: '正则提示',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16
|
||
}
|
||
},
|
||
//可选属性表数据字典
|
||
typeDist: {
|
||
select: [
|
||
{
|
||
type: 'select',
|
||
id: 'service',
|
||
title: '服务名称',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
},
|
||
{
|
||
type: 'select',
|
||
id: 'label',
|
||
title: 'label',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
}, {
|
||
type: 'input',
|
||
id: 'value',
|
||
title: 'value',
|
||
row: 24,
|
||
disabled: true,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
}
|
||
],
|
||
radio: [
|
||
{
|
||
type: 'select',
|
||
id: 'service',
|
||
title: '服务名称',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
},
|
||
{
|
||
type: 'select',
|
||
id: 'label',
|
||
title: 'label',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
}, {
|
||
type: 'input',
|
||
id: 'value',
|
||
title: 'value',
|
||
row: 24,
|
||
disabled: true,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
}
|
||
],
|
||
treeselect: [
|
||
{
|
||
type: 'select',
|
||
id: 'service',
|
||
title: '服务名称',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
},
|
||
{
|
||
type: 'select',
|
||
id: 'label',
|
||
title: 'label',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
}, {
|
||
type: 'input',
|
||
id: 'value',
|
||
title: 'value',
|
||
row: 24,
|
||
disabled: true,
|
||
required: false,
|
||
fontSize: 16,
|
||
options: []
|
||
},
|
||
{
|
||
type: 'select',
|
||
id: 'upId',
|
||
title: 'upId',
|
||
row: 24,
|
||
disabled: false,
|
||
required: true,
|
||
fontSize: 16,
|
||
options: []
|
||
}
|
||
]
|
||
},
|
||
serviceOptions: [],
|
||
labelOptions: [],
|
||
//单据规则相关
|
||
receiptsShow: false,//单据规则dialog
|
||
receiptsTableData: [{}],//表单数据
|
||
receiptsFunData: [
|
||
{
|
||
text: '删除',
|
||
color: 'red'
|
||
}
|
||
],
|
||
receiptsTableColumn: [
|
||
{
|
||
title: '类型',
|
||
id: 'dbType'
|
||
},
|
||
{
|
||
title: '格式规则',
|
||
id: 'dbValue'
|
||
}
|
||
],
|
||
ruleTypeOptions: [
|
||
{
|
||
label: '连接符号',
|
||
value: '1'
|
||
}, {
|
||
label: '字符串',
|
||
value: '2'
|
||
}, {
|
||
label: '日期',
|
||
value: '3'
|
||
}, {
|
||
label: '流水号',
|
||
value: '4'
|
||
}
|
||
],
|
||
dateOptions: [
|
||
{
|
||
label: 'yyyy-MM-dd',
|
||
value: 'yyyy-MM-dd'
|
||
}, {
|
||
label: 'yyyyMMdd',
|
||
value: 'yyyyMMdd'
|
||
}, {
|
||
label: 'yyyy-MM-dd HH:mm:ss',
|
||
value: 'yyyy-MM-dd HH:mm:ss'
|
||
}, {
|
||
label: 'yyyyMMddHHmmss',
|
||
value: 'yyyyMMddHHmmss'
|
||
}, {
|
||
label: 'yyyyMMddHHmmssSSS',
|
||
value: 'yyyyMMddHHmmssSSS'
|
||
}
|
||
],
|
||
receiptsShowTableData: [],
|
||
//数据类型字段
|
||
dataTypeDist: {}
|
||
}
|
||
},
|
||
methods: {
|
||
// 下拉初始化
|
||
async initSelect() {
|
||
//数据类型下拉
|
||
const type = await getApiModuleApi({
|
||
tl: 'generalServiceImpl',
|
||
as: 'dictionaryshop',
|
||
dj: 'selectDictionaryshop'
|
||
}, { tab_name: 'mdm', column_name: 'mdm_filed_type' })
|
||
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: '' })
|
||
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 })
|
||
this.mainTableData = []
|
||
this.receiptsShowTableData = res.attribute.mdmTableCodeRuleEntityList
|
||
if (res.attribute.mainMdmModuleDb.id) {
|
||
this.mainTableData.push({ ...res.attribute.mainMdmModuleDb })
|
||
} else {
|
||
console.log(123)
|
||
let tempObj = {
|
||
dbType: '1', sublistMdmModuleDbFileds: [{
|
||
'index': 0,
|
||
'chName': '数据状态',
|
||
'enName': 'dataStatus',
|
||
'filedType': '3',
|
||
'filedLength': '1',
|
||
'mdmModuleDbFiledsRules': [
|
||
{
|
||
'ruleName': '显示名',
|
||
'ruleCode': 'title',
|
||
'ruleValue': '数据状态',
|
||
'ruleType': 2,
|
||
'formName': 'optionRuleForm'
|
||
},
|
||
{
|
||
'ruleName': '宽度',
|
||
'ruleCode': 'row',
|
||
'ruleValue': '12',
|
||
'ruleType': 2,
|
||
'formName': 'optionRuleForm'
|
||
},
|
||
{
|
||
'ruleName': '单元格宽度',
|
||
'ruleCode': 'width',
|
||
'ruleType': 2,
|
||
'formName': 'optionRuleForm'
|
||
},
|
||
{
|
||
'ruleName': '数据类型',
|
||
'ruleCode': 'type',
|
||
'ruleValue': 'input',
|
||
'ruleType': 2,
|
||
'formName': 'optionRuleForm'
|
||
},
|
||
{
|
||
'ruleName': '必填',
|
||
'ruleCode': 'required',
|
||
'ruleType': 2,
|
||
'formName': 'optionRuleForm'
|
||
},
|
||
{
|
||
'ruleName': '禁止修改',
|
||
'ruleCode': 'disabled',
|
||
'ruleValue': true,
|
||
'ruleType': 2,
|
||
'formName': 'optionRuleForm'
|
||
}
|
||
]
|
||
}]
|
||
}
|
||
this.mainTableData.push(tempObj)
|
||
}
|
||
res.attribute.sublistMdmModuleDb.forEach(item => {
|
||
if (item.id) {
|
||
this.mainTableData.push({ ...item })
|
||
}
|
||
})
|
||
this.mainLoading = false
|
||
},
|
||
//流水号添加行
|
||
receiptsAddRow() {
|
||
this.receiptsTableData.push({})
|
||
},
|
||
//流水号修改事件
|
||
integerNumber(val, row) {
|
||
row['dbValue'] = row['dbValue'].replace(/[^\d]/g, '')
|
||
},
|
||
//单据规则相关
|
||
openReceiptsHandle() {
|
||
this.receiptsTableData = deepClone(this.receiptsShowTableData)
|
||
this.receiptsShow = true
|
||
|
||
},
|
||
//单据规则下拉改变事件
|
||
ruleTypeSeleceChangHandle(val, row) {
|
||
this.$set(row, 'dbValue', '')
|
||
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'
|
||
}
|
||
}
|
||
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 })
|
||
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, '')
|
||
}
|
||
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')
|
||
return true
|
||
} else {
|
||
return false
|
||
}
|
||
})
|
||
if (flag) return
|
||
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')
|
||
return true
|
||
} else {
|
||
return false
|
||
}
|
||
})
|
||
if (flag) return
|
||
// 将表值赋值给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 })
|
||
})
|
||
}
|
||
|
||
// 通过字典找到值的类型渲染在表单上
|
||
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 })
|
||
}
|
||
})
|
||
})
|
||
}
|
||
let tempObj = {
|
||
elCol: [
|
||
{
|
||
...this.propertyDist[item],
|
||
options: tempOptions
|
||
}
|
||
]
|
||
}
|
||
this.propertyFormRow.push(tempObj)
|
||
})
|
||
|
||
},
|
||
// 上方表格行点击
|
||
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) {
|
||
//若英文名称为dataStatus 且是主表 则禁止输出
|
||
|
||
if (val.enName === 'dataStatus' && this.mainActivedRow.dbType == 1) {
|
||
this.sonFormDisabled = true
|
||
} else {
|
||
this.sonFormDisabled = false
|
||
}
|
||
this.activedTableRow = val
|
||
//清空type带出来的ruleForm
|
||
this.typeOptionFormRow = []
|
||
this.typeOptionRuleForm = {
|
||
value: 'id'
|
||
}
|
||
this.propertyFormRow = []
|
||
this.propertyRuleForm = {}
|
||
this.propertyActiveList = []
|
||
let propertyRuleForm = []
|
||
let optionRuleForm = []
|
||
let typeOptionRuleForm = []
|
||
|
||
this.$nextTick(() => {
|
||
// 重置表单
|
||
this.$refs.optionForm.resetForm()
|
||
this.optionRuleForm = deepClone(val)
|
||
console.log(this.optionRuleForm, 'this.optionRuleForm')
|
||
let dom = document.querySelector('.optionForm')
|
||
dom.scrollTo({
|
||
top: 0,
|
||
behavior: 'smooth'
|
||
})
|
||
//表单规则处理
|
||
if (!val.mdmModuleDbFiledsRules) return
|
||
val.mdmModuleDbFiledsRules.forEach(item => {
|
||
if (item.ruleCode === 'required' || item.ruleCode === 'disabled') {
|
||
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)
|
||
}
|
||
this.selectChangeHanlde(this.optionRuleForm.type, '', '', { id: 'type' }, true)
|
||
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
|
||
}
|
||
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')
|
||
return
|
||
}
|
||
}
|
||
if (this.optionRuleForm.filedType == 4) {
|
||
if (this.optionRuleForm.type !== 'datepick' && this.optionRuleForm.type !== 'daterange') {
|
||
this.$vmNews('字段类型与数据类型不合法', 'warning')
|
||
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'
|
||
})
|
||
}
|
||
})
|
||
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'
|
||
})
|
||
})
|
||
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'
|
||
})
|
||
})
|
||
this.activedTableRow.mdmModuleDbFiledsRules = tempArr
|
||
},
|
||
// 保存
|
||
async saveHandle() {
|
||
console.log(this.mainTableData)
|
||
//判断认证规则
|
||
if (!this.receiptsShowTableData.length) {
|
||
this.$vmNews('单据规则不能为空', 'warning')
|
||
return
|
||
}
|
||
let flag = this.mainTableData.some((mainItem, index) => {
|
||
if (!mainItem.dbName) {
|
||
this.$vmNews(`数据表第${index + 1}行的英文名不能为空`, 'warning')
|
||
return true
|
||
}
|
||
return mainItem.sublistMdmModuleDbFileds.some((item, index02) => {
|
||
if (!item.chName) {
|
||
this.$vmNews(`数据表第${index + 1}行表中的${index02 + 1}行表字段数据填写不全`, 'warning')
|
||
return true
|
||
|
||
}
|
||
})
|
||
})
|
||
if (flag) return
|
||
this.saveLoading = true
|
||
let params = {
|
||
id: this.$route.query.id,
|
||
mainMdmModuleDb: this.mainTableData[0],
|
||
sublistMdmModuleDb: [],
|
||
mdmTableCodeRuleEntityList: this.receiptsShowTableData
|
||
}
|
||
this.mainTableData.forEach((item, index) => {
|
||
if (index > 0) {
|
||
params.sublistMdmModuleDb.push(item)
|
||
}
|
||
})
|
||
const res = await getApiModuleApi({
|
||
tl: 'mdmService',
|
||
as: 'mdmService',
|
||
dj: 'saveMdmModuleDb'
|
||
}, params)
|
||
if (res.status === '200') {
|
||
this.$vmNews('保存成功!', 'success')
|
||
this.init()
|
||
}
|
||
this.saveLoading = false
|
||
},
|
||
// 主表按钮
|
||
mainOnFunc(row, item) {
|
||
if (!row.newFlag) {
|
||
this.$vmNews('此行不允许删除', 'warning')
|
||
return
|
||
}
|
||
this.$confirm('确定删除?')
|
||
.then((_) => {
|
||
this.mainTableData.splice(row.index, 1)
|
||
})
|
||
.catch((_) => {
|
||
})
|
||
},
|
||
//选中表按钮
|
||
activedOnFunc(row) {
|
||
if (!row.newFlag) {
|
||
this.$vmNews('此行不允许删除', 'warning')
|
||
return
|
||
}
|
||
this.$confirm('确定删除?')
|
||
.then((_) => {
|
||
this.activedTableData.splice(row.index, 1)
|
||
})
|
||
.catch((_) => {
|
||
})
|
||
},
|
||
//规则表格删除
|
||
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')
|
||
return true
|
||
} else if (item.dbType === '4' && index + 1 !== this.receiptsTableData.length) {
|
||
type = true
|
||
this.$vmNews(`流水号只允许在最后一行`, 'warning')
|
||
return true
|
||
} else if (item.dbType === '4') {
|
||
type = true
|
||
}
|
||
})
|
||
if (!type) {
|
||
this.$vmNews(`请添加流水号`, 'warning')
|
||
return
|
||
}
|
||
if (flag) return
|
||
|
||
this.receiptsShow = false
|
||
this.receiptsShowTableData = deepClone(this.receiptsTableData)
|
||
|
||
},
|
||
//主表添加按钮
|
||
addMainAddRow() {
|
||
this.mainTableData.push({
|
||
'dbName': ``,
|
||
'dbType': '2',
|
||
'remark': '',
|
||
sublistMdmModuleDbFileds: [],
|
||
newFlag: true
|
||
})
|
||
},
|
||
//选中表添加按钮
|
||
activedAddRow() {
|
||
this.activedTableData.push({ newFlag: true, disabled: false, required: false })
|
||
},
|
||
//表单输入框失焦事件(为了让中文名称可以给显示名)
|
||
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)
|
||
},
|
||
watch: {},
|
||
computed: {
|
||
labelOptionsAuto() {
|
||
return this.labelOptions
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
::v-deep .el-button {
|
||
border-radius: 4px;
|
||
}
|
||
|
||
::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;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
</style>
|
||
<style>
|
||
.receiptsAddRow {
|
||
margin-top: 30px;
|
||
border: 1px dotted #ccc;
|
||
text-align: center;
|
||
height: 50px;
|
||
line-height: 50px;
|
||
}
|
||
</style>
|