You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
7.5 KiB

1 year ago
<template>
<w-grid
ref="treeGridRef"
:title="$t('engine.st.indepFactorDefine.grid.title')"
dense
:checkbox-selection="false"
:tree="true"
:tree-icon="
(row) => {
if (row.type === 'FOLDER') {
return { name: 'folder', color: 'amber' };
} else if (row.type === 'ORIGINAL') {
return { name: 'bi-file-earmark-text' };
} else if (row.type === 'EXTEND_ARITHMETIC') {
return { name: 'bi-file-earmark-text', color: 'green' };
} else if (row.type === 'EXTEND_DELAY') {
return { name: 'bi-file-earmark-text', color: 'blue' };
} else if (row.type === 'EXTEND_DIFFERENTIAL') {
return { name: 'bi-file-earmark-text', color: 'amber' };
} else {
return { name: 'bi-file-earmark-text' };
}
}
"
:data-url="Environment.apiContextPath('/api/st/scenarioFactorDefine')"
:pageable="false"
:sort-by="['order']"
:toolbar-actions="[
'refresh',
'separator',
'expand',
'separator',
{
name: 'synchronize',
label: $t('synchronize'),
icon: 'bi-repeat',
click: () => {},
},
'separator',
'view',
'separator',
'export',
]"
:columns="[
{ width: 160, name: 'name', label: $t('name') },
{ width: 150, name: 'code', label: $t('code') },
{
width: 100,
name: 'type',
label: $t('type'),
format: (value, row) => {
if (value === 'FOLDER') {
return '';
}
return Formater.enum(Enums.FactorDefineType)(value);
},
},
{ width: 60, name: 'period', label: $t('period'), format: Formater.enum(Enums.Period) },
{ width: 70, name: 'valueType', label: $t('valueType'), format: Formater.enum(Enums.ValueType) },
]"
:editor="{
dialog: {
width: '500px',
},
form: {
colsNum: 1,
fields: [
{
name: 'type',
label: $t('type'),
10 months ago
type: 'w-select',
requiredIf: true,
1 year ago
options: Options.enum(Enums.FactorDefineType),
onChange: (arg) => {
findAllWithoutById(arg.form.getFieldValue('id'));
},
},
{
name: 'code',
label: $t('code'),
10 months ago
type: 'w-text',
requiredIf: true,
1 year ago
showIf: (arg) => {
return arg.form.getFieldValue('type') !== 'FOLDER';
},
},
10 months ago
{ name: 'name', label: $t('name'), type: 'w-text', requiredIf: true },
{ name: 'description', label: $t('description'), type: 'w-text' },
{ name: 'order', label: $t('order'), type: 'w-number' },
1 year ago
{
name: 'period',
label: $t('period'),
10 months ago
requiredIf: true,
type: 'w-select',
1 year ago
options: Options.enum(Enums.Period),
showIf: (arg) => {
return arg.form.getFieldValue('type') !== 'FOLDER';
},
},
{
name: 'valueType',
label: $t('valueType'),
10 months ago
requiredIf: true,
type: 'w-select',
1 year ago
options: Options.enum(Enums.ValueType),
showIf: (arg) => {
return arg.form.getFieldValue('type') !== 'FOLDER';
},
},
{
name: 'formula',
label: $t('engine.st.indepFactorDefine.grid.entity.formula'),
10 months ago
type: 'w-code-mirror',
requiredIf: true,
1 year ago
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_ARITHMETIC';
},
},
{
name: 'delayFactorDefine',
label: $t('engine.st.indepFactorDefine.grid.entity.delayFactorDefine'),
10 months ago
type: 'w-select',
1 year ago
options: factorDefineOptionsRef,
10 months ago
requiredIf: true,
1 year ago
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_DELAY';
},
},
{
name: 'delayIssue',
label: $t('engine.st.indepFactorDefine.grid.entity.delayIssue'),
10 months ago
type: 'w-number',
requiredIf: true,
1 year ago
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_DELAY';
},
},
{
name: 'differentialFactorDefine',
label: $t('engine.st.indepFactorDefine.grid.entity.differentialFactorDefine'),
10 months ago
type: 'w-select',
1 year ago
options: factorDefineOptionsRef,
10 months ago
requiredIf: true,
1 year ago
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_DIFFERENTIAL';
},
},
{
name: 'differentialDegree',
label: $t('engine.st.indepFactorDefine.grid.entity.differentialDegree'),
10 months ago
type: 'w-number',
requiredIf: true,
1 year ago
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_DIFFERENTIAL';
},
},
],
},
}"
:viewer="{
panel: {
columnNum: 1,
fields: [
{ name: 'id', label: $t('id') },
{ name: 'type', label: $t('type') },
{ name: 'period', label: $t('period') },
{ name: 'code', label: $t('code') },
{ name: 'name', label: $t('name') },
{ name: 'description', label: $t('description') },
{ name: 'order', label: $t('order') },
{ name: 'valueType', label: $t('valueType') },
{ name: 'formula', label: $t('engine.st.indepFactorDefine.grid.entity.formula') },
{ name: 'delayFactorDefine', label: $t('engine.st.indepFactorDefine.grid.entity.delayFactorDefine') },
{ name: 'delayIssue', label: $t('engine.st.indepFactorDefine.grid.entity.delayIssue') },
{ name: 'differentialFactorDefine', label: $t('engine.st.indepFactorDefine.grid.entity.differentialFactorDefine') },
{ name: 'differentialDegree', label: $t('engine.st.indepFactorDefine.grid.entity.differentialDegree') },
{ name: 'dataComeFrom', label: $t('dataComeFrom') },
{ name: 'creator', label: $t('creator') },
{ name: 'createDate', label: $t('createDate') },
{ name: 'lastModifier', label: $t('lastModifier') },
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() },
{ name: 'corporationCode', label: $t('corporationCode') },
],
},
}"
@after-editor-open="
(selected) => {
if (selected?.type === 'EXTEND_DELAY' || selected?.type === 'EXTEND_DIFFERENTIAL') {
findAllWithoutById(selected.id);
}
}
"
></w-grid>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { Environment, Formater, Options, EnumTools, axios } from 'platform-core';
const treeGridRef = ref();
const factorDefineOptionsRef = ref([]);
const Enums = await EnumTools.fetch(['io.sc.engine.st.enums.FactorDefineType', 'io.sc.engine.st.enums.Period', 'io.sc.engine.st.enums.ValueType']);
const findAllWithoutById = (id) => {
axios.get(Environment.apiContextPath('/api/st/indepFactorDefine/findAllWithoutById?defineId=' + (id ? id : ''))).then((response) => {
const defines = response?.data;
if (defines) {
const options = [];
for (const define of defines) {
if (define.type !== 'FOLDER') {
options.push({ value: define.id, label: define.name });
}
}
factorDefineOptionsRef.value = options;
}
});
};
</script>