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.
230 lines
6.2 KiB
230 lines
6.2 KiB
9 months ago
|
import { ref } from 'vue';
|
||
|
import { http } from '/nerv-lib/util';
|
||
|
import { origanizemanage } from '/@/api/origanizemanage';
|
||
|
export const formConfig = (disabled) => {
|
||
|
return ref([
|
||
|
{
|
||
|
field: 'field111',
|
||
|
component: 'NsChildForm',
|
||
|
componentProps: {
|
||
|
schemas: [
|
||
|
{
|
||
|
label: '排放源',
|
||
|
field: 'accountNo',
|
||
|
component: 'NsInput',
|
||
|
componentProps: {
|
||
|
placeholder: '请输入排放源',
|
||
|
maxLength: 20,
|
||
|
disabled,
|
||
|
},
|
||
|
rules: [
|
||
|
{
|
||
|
required: true,
|
||
|
message: '请输入排放源',
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
field: 'userStatus',
|
||
|
label: '排放气体',
|
||
|
component: 'NsSelect',
|
||
|
componentProps: {
|
||
|
allowClear: true,
|
||
|
placeholder: '请选择排放气体',
|
||
|
options: [
|
||
|
{
|
||
|
label: '正常',
|
||
|
value: 0,
|
||
|
},
|
||
|
{
|
||
|
label: '冻结',
|
||
|
value: 1,
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
rules: [
|
||
|
{
|
||
|
required: true,
|
||
|
message: '请选择排放气体',
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
field: 'userStatus',
|
||
|
label: '排放环节',
|
||
|
component: 'NsSelect',
|
||
|
componentProps: {
|
||
|
allowClear: true,
|
||
|
placeholder: '请选择排放环节',
|
||
|
options: [
|
||
|
{
|
||
|
label: '正常',
|
||
|
value: 0,
|
||
|
},
|
||
|
{
|
||
|
label: '冻结',
|
||
|
value: 1,
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
label: '排放因子',
|
||
|
field: 'accountNo',
|
||
|
component: 'NsInput',
|
||
|
componentProps: {
|
||
|
placeholder: '请输入排放因子值',
|
||
|
maxLength: 20,
|
||
|
disabled,
|
||
|
},
|
||
|
rules: [
|
||
|
{
|
||
|
required: true,
|
||
|
message: '请输入排放因子值',
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
field: 'userStatus',
|
||
|
label: '碳排前缀',
|
||
|
component: 'NsSelect',
|
||
|
componentProps: {
|
||
|
allowClear: true,
|
||
|
placeholder: '请选择碳排前缀',
|
||
|
options: [
|
||
|
{
|
||
|
label: '正常',
|
||
|
value: 0,
|
||
|
},
|
||
|
{
|
||
|
label: '冻结',
|
||
|
value: 1,
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
rules: [
|
||
|
{
|
||
|
required: true,
|
||
|
message: '请选择碳排前缀',
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
label: '碳排后缀',
|
||
|
field: 'accountNo',
|
||
|
component: 'NsInput',
|
||
|
componentProps: {
|
||
|
placeholder: '请输入碳排后缀',
|
||
|
maxLength: 20,
|
||
|
disabled,
|
||
|
},
|
||
|
rules: [
|
||
|
{
|
||
|
required: true,
|
||
|
message: '请输入碳排后缀',
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
label: '已引用数',
|
||
|
field: 'accountNo',
|
||
|
component: 'NsInput',
|
||
|
componentProps: {
|
||
|
disabled: true,
|
||
|
maxLength: 20,
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
label: '参考文献',
|
||
|
field: 'accountNo',
|
||
|
component: 'NsTextarea',
|
||
|
componentProps: {
|
||
|
placeholder: '请输入参考文献',
|
||
|
maxLength: 20,
|
||
|
disabled,
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
},
|
||
|
]);
|
||
|
};
|
||
|
const options = ref([]);
|
||
|
|
||
|
const getUserPerList = (transform, params = {}) => {
|
||
|
return http.post(origanizemanage.queryUserPerList, { ...params }).then((res) => {
|
||
|
return res.data?.map((item) => {
|
||
|
item = { ...item, ...transform(item) };
|
||
|
return item;
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
export const formConfig2 = (casData: any) => {
|
||
|
return ref([
|
||
|
{
|
||
|
field: 'information',
|
||
|
component: 'NsCascader',
|
||
|
componentProps: {
|
||
|
placeholder: '请选择',
|
||
|
displayRender: ({ labels, selectedOptions }: any) => {
|
||
|
console.log(labels, selectedOptions);
|
||
|
|
||
|
casData.value = selectedOptions.map(({ label, value }) => {
|
||
|
return { label, value };
|
||
|
});
|
||
|
return labels.join('/');
|
||
|
},
|
||
|
loadData: (selectedOptions, options) => {
|
||
|
console.log(selectedOptions, options, 'selectedOptions, options');
|
||
|
|
||
|
const targetOption = selectedOptions[selectedOptions.length - 1];
|
||
|
let transForm, params;
|
||
|
// load options lazily
|
||
|
if (!selectedOptions.length) {
|
||
|
transForm = (data) => {
|
||
|
data['label'] = data.orgName;
|
||
|
data['value'] = data.orgId;
|
||
|
data['isLeaf'] = false;
|
||
|
data['level'] = 1;
|
||
|
return data;
|
||
|
};
|
||
|
getUserPerList(transForm).then((res) => {
|
||
|
options.value = [...res];
|
||
|
});
|
||
|
}
|
||
|
const id = targetOption?.value;
|
||
|
const level = targetOption?.level;
|
||
|
if (targetOption) {
|
||
|
targetOption.loading = true;
|
||
|
}
|
||
|
|
||
|
if (level === 1) {
|
||
|
transForm = (data) => {
|
||
|
data['label'] = data.deptName;
|
||
|
data['value'] = data.deptId;
|
||
|
data['isLeaf'] = false;
|
||
|
data['level'] = 2;
|
||
|
return data;
|
||
|
};
|
||
|
params = { orgId: id };
|
||
|
} else if (level === 2) {
|
||
|
transForm = (data) => {
|
||
|
data['label'] = data.roleName;
|
||
|
data['value'] = data.roleId;
|
||
|
data['level'] = 3;
|
||
|
return data;
|
||
|
};
|
||
|
params = { deptId: id };
|
||
|
}
|
||
|
if (targetOption) {
|
||
|
getUserPerList(transForm, { ...params }).then((res) => {
|
||
|
targetOption.loading = false;
|
||
|
targetOption.children = [...res];
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
]);
|
||
|
};
|