push
This commit is contained in:
477
lib/saas/view/config/config.vue
Normal file
477
lib/saas/view/config/config.vue
Normal file
@@ -0,0 +1,477 @@
|
||||
<!-- @format -->
|
||||
|
||||
<template>
|
||||
<a-spin :spinning="spinning">
|
||||
<div class="ns-skeleton">
|
||||
<ns-page-header class="ns-page-header">
|
||||
<template #title>
|
||||
<div class="title" @click="onBack()">
|
||||
<ns-icon name="left" /> <div class="text">配置</div>
|
||||
</div>
|
||||
</template>
|
||||
</ns-page-header>
|
||||
<div class="ns-config">
|
||||
<div v-for="(configGroup, index) in getConfig" :key="index">
|
||||
<a-descriptions style="height: 46px" :style="{ 'margin-top': index ? '16px' : '0px' }">
|
||||
<template #title>
|
||||
<div class="descriptions-title config-name">
|
||||
<span>{{ configGroup.name }}</span>
|
||||
<div class="titleFloor"></div>
|
||||
<ns-button
|
||||
v-if="paramsValue?.deviceName"
|
||||
style="float: right"
|
||||
type="primary"
|
||||
@click="updateSubmit(paramsValue)"
|
||||
:disabled="!paramsValue"
|
||||
>保存</ns-button
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</a-descriptions>
|
||||
<NsBasicTable
|
||||
ref="dataRef"
|
||||
:data-source="configGroup.getBindValues"
|
||||
:columns="configGroup.columns"
|
||||
:pagination="false"
|
||||
:rowKey="configGroup.getBindValues.key">
|
||||
<template #bodyCell="{ record, column, text }">
|
||||
<template v-if="column.dataIndex == 'expectedValue'">
|
||||
<!-- //文本编辑 -->
|
||||
<div
|
||||
class="editable-cell"
|
||||
v-if="configGroup.getBindValues[record.key - 1].childDataType === 'TEXT'">
|
||||
<!-- 日期组件 -->
|
||||
<div v-if="configGroup.getBindValues[record.key - 1].sign == 'timeRange'">
|
||||
<configDate
|
||||
v-model:timeValue="configGroup.getBindValues[record.key - 1]"
|
||||
:index="index"
|
||||
:listKey="record.key"
|
||||
:text="text"
|
||||
@changeDate="changeData" />
|
||||
</div>
|
||||
<!-- 普通文本 -->
|
||||
<div v-else>
|
||||
<configInput
|
||||
v-model:configValue="configGroup.getBindValues[record.key - 1]"
|
||||
:index="index"
|
||||
:listKey="record.key"
|
||||
@changeInput="changeData" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 枚举 -->
|
||||
<div
|
||||
v-else-if="
|
||||
configGroup.getBindValues[record.key - 1].childDataType == 'ENUM' ||
|
||||
configGroup.getBindValues[record.key - 1].list?.[0].dataType == 'ENUM'
|
||||
">
|
||||
<configEnum
|
||||
v-model:configValue="configGroup.getBindValues[record.key - 1]"
|
||||
:index="index"
|
||||
:listKey="record.key"
|
||||
@changeEnum="changeData" />
|
||||
</div>
|
||||
<!-- 开关 -->
|
||||
<div v-else-if="configGroup.getBindValues[record.key - 1].childDataType == 'BOOL'">
|
||||
<configSwitch
|
||||
v-model:configValue="configGroup.getBindValues[record.key - 1]"
|
||||
:index="index"
|
||||
:listKey="record.key"
|
||||
@changeSwitch="changeData" />
|
||||
</div>
|
||||
<!-- 校验float/int/double -->
|
||||
<div
|
||||
v-else-if="
|
||||
configGroup.getBindValues[record.key - 1].childDataType == 'FLOAT' ||
|
||||
'INT' ||
|
||||
'DOUBLE'
|
||||
">
|
||||
<configInput
|
||||
v-model:configValue="configGroup.getBindValues[record.key - 1]"
|
||||
:index="index"
|
||||
:listKey="record.key"
|
||||
@changeInput="changeData" />
|
||||
</div>
|
||||
<!-- else -->
|
||||
<div v-else> </div>
|
||||
</template>
|
||||
</template>
|
||||
</NsBasicTable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, ref, watch, PropType, UnwrapRef, reactive } from 'vue';
|
||||
import { http } from '/nerv-lib/util/http';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import configDate from './configDate.vue';
|
||||
import configInput from './configInput.vue';
|
||||
import configEnum from './configEnum.vue';
|
||||
import configSwitch from './configSwitch.vue';
|
||||
import { Handle } from '@antv/x6/lib/addon/common';
|
||||
|
||||
export interface DetailItem {
|
||||
label: string;
|
||||
name: string;
|
||||
value?: string;
|
||||
format?: Function;
|
||||
type?: string; // 现支持image
|
||||
}
|
||||
export interface ConfigGroup {
|
||||
title: string;
|
||||
items: Array<DetailItem>;
|
||||
}
|
||||
export interface ComponentValueItem {
|
||||
configValue: object | string;
|
||||
key: number;
|
||||
index: number;
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'NsViewConfig',
|
||||
props: {
|
||||
config: {
|
||||
type: Array as unknown as PropType<ConfigGroup>,
|
||||
default: () => [],
|
||||
},
|
||||
api: {
|
||||
type: String,
|
||||
},
|
||||
updateApi: {
|
||||
type: String,
|
||||
},
|
||||
params: {
|
||||
type: Object,
|
||||
},
|
||||
columns: {
|
||||
type: Array,
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line vue/order-in-components
|
||||
components: {
|
||||
ExclamationCircleOutlined,
|
||||
configDate,
|
||||
configInput,
|
||||
configEnum,
|
||||
configSwitch,
|
||||
},
|
||||
setup(props) {
|
||||
const checked = ref<boolean>(true);
|
||||
const tableData = ref([]);
|
||||
const router = useRouter();
|
||||
const dataRef = ref([]);
|
||||
const spinning = ref(false);
|
||||
let hasTypeEight = ref();
|
||||
let paramsValue = ref();
|
||||
//接收子组件传过来的数据并处理
|
||||
const changeData = (value: ComponentValueItem) => {
|
||||
console.log(value);
|
||||
getConfig.value[value.index].getBindValues[value.key - 1].expectedValue = value.configValue;
|
||||
if (getConfig.value[value.index].getBindValues[value.key - 1].configItemList) {
|
||||
hasTypeEight.value = true;
|
||||
getConfig.value[value.index].getBindValues[value.key - 1].configItemList.value =
|
||||
value.configValue;
|
||||
} else {
|
||||
hasTypeEight.value = false;
|
||||
getConfig.value[value.index].getBindValues[value.key - 1].itemList.value =
|
||||
value.configValue;
|
||||
}
|
||||
|
||||
updateConfig(value.index, hasTypeEight.value);
|
||||
};
|
||||
function request() {
|
||||
const { query } = router.currentRoute.value;
|
||||
http.get(props.api, query).then((res) => {
|
||||
dataRef.value = res.data;
|
||||
});
|
||||
}
|
||||
request();
|
||||
//所有类型修改后数据提交
|
||||
const updateConfig = (index: number, isTrue) => {
|
||||
///api/objs/Device/ConfigUpdate
|
||||
console.log(index);
|
||||
console.log(getConfig.value[index].getBindValues);
|
||||
let configItemList = [];
|
||||
let itemList = [];
|
||||
for (const iterator of getConfig.value[index].getBindValues) {
|
||||
configItemList.push(iterator.configItemList);
|
||||
itemList.push(iterator.itemList);
|
||||
}
|
||||
|
||||
let params = {};
|
||||
if (isTrue) {
|
||||
params = {
|
||||
deviceName: props.params.deviceName,
|
||||
itemStructList: [
|
||||
{
|
||||
configItemList: configItemList,
|
||||
structIdentifier: getConfig.value[index].identifier,
|
||||
},
|
||||
],
|
||||
uuid: props.params.uuid,
|
||||
};
|
||||
paramsValue.value = params;
|
||||
return;
|
||||
} else {
|
||||
params = {
|
||||
deviceName: props.params.deviceName,
|
||||
itemList: itemList,
|
||||
uuid: props.params.uuid,
|
||||
};
|
||||
}
|
||||
updateSubmit(params);
|
||||
|
||||
// http.post(props.updateApi, params).then((res) => {
|
||||
// if (res.code == '200') {
|
||||
// spinning.value = true;
|
||||
// message.success('操作成功');
|
||||
// getConfig;
|
||||
// setTimeout(() => {
|
||||
// request();
|
||||
// spinning.value = false;
|
||||
// }, 3000);
|
||||
// }
|
||||
// });
|
||||
|
||||
return 1;
|
||||
};
|
||||
const updateSubmit = (params) => {
|
||||
http.post(props.updateApi, params).then((res) => {
|
||||
if (res.code == '200') {
|
||||
spinning.value = true;
|
||||
message.success('操作成功');
|
||||
getConfig;
|
||||
setTimeout(() => {
|
||||
request();
|
||||
spinning.value = false;
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//处理后端传过来的数据
|
||||
const getConfig = computed(() => {
|
||||
if (dataRef.value) {
|
||||
return dataRef.value.map((item) => {
|
||||
if (!item.dataSpecsList) {
|
||||
item.dataSpecsList = item.dataSpecs;
|
||||
}
|
||||
let bindValues = JSON.parse(item.dataSpecsList);
|
||||
if (item.dataType == 4) {
|
||||
bindValues = [{ list: bindValues, remark: item.remark, childName: item.name }];
|
||||
}
|
||||
if (!Array.isArray(bindValues)) {
|
||||
bindValues = [
|
||||
{ childSpecsDTO: bindValues, remark: item.remark, childName: item.name },
|
||||
];
|
||||
}
|
||||
let i = 1;
|
||||
|
||||
for (const iterator of bindValues) {
|
||||
if (
|
||||
iterator.childDataType == 'INT' ||
|
||||
iterator.childDataType == 'BOOL' ||
|
||||
iterator.childDataType == 'ENUM'
|
||||
) {
|
||||
if (item.dataType == 8) {
|
||||
iterator.expectedValue = parseInt(iterator.configValue);
|
||||
} else {
|
||||
iterator.expectedValue = parseInt(item.expectedValue);
|
||||
}
|
||||
} else {
|
||||
if (item.dataType == 8) {
|
||||
iterator.expectedValue = iterator.configValue;
|
||||
} else {
|
||||
iterator.expectedValue = item.expectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.dataType == 8) {
|
||||
let demo = {
|
||||
identifier: iterator.identifier,
|
||||
value: iterator.expectedValue,
|
||||
};
|
||||
iterator.configItemList = demo;
|
||||
} else {
|
||||
let demoCopy = {
|
||||
identifier: item.identifier,
|
||||
value: iterator.expectedValue,
|
||||
};
|
||||
iterator.itemList = demoCopy;
|
||||
}
|
||||
|
||||
iterator.key = i + '';
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return {
|
||||
// title: group.title,
|
||||
name: item.name,
|
||||
identifier: item.identifier,
|
||||
getBindValues: bindValues,
|
||||
columns: props.columns,
|
||||
};
|
||||
});
|
||||
}
|
||||
return [];
|
||||
});
|
||||
return {
|
||||
getConfig,
|
||||
tableData,
|
||||
checked,
|
||||
updateConfig,
|
||||
changeData,
|
||||
spinning,
|
||||
paramsValue,
|
||||
updateSubmit,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
onBack() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-skeleton-paragraph) {
|
||||
display: inline;
|
||||
// display: flex;
|
||||
// flex-wrap: wrap;
|
||||
}
|
||||
|
||||
:deep(.ant-skeleton-paragraph li:nth-child(n)) {
|
||||
float: left;
|
||||
display: inline;
|
||||
margin-right: 130px;
|
||||
margin-top: 16px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
:deep(.ant-skeleton-paragraph li:nth-child(3n + 1)) {
|
||||
clear: both;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
:deep(.ant-skeleton-content) {
|
||||
padding: 0px 8px 10px 10px;
|
||||
}
|
||||
|
||||
.ns-detail {
|
||||
padding: 0px 8px 10px 10px;
|
||||
}
|
||||
|
||||
:deep(.ant-table) {
|
||||
border: 1px solid #ededed;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
:deep(.editable-cell-input-wrapper input) {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
:deep(.ant-modal-content) {
|
||||
border: 1px solid #dcdfe2;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.config-input {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.config-name {
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
margin: 16px 0;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.config-message {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.config-message span svg {
|
||||
color: red;
|
||||
}
|
||||
.ns-config {
|
||||
padding: 16px;
|
||||
border-top: 16px solid #e5ebf0;
|
||||
div:first-child {
|
||||
.config-name {
|
||||
margin-top: 0px;
|
||||
}
|
||||
}
|
||||
:deep(.ns-basic-table) {
|
||||
padding-top: 0px;
|
||||
}
|
||||
}
|
||||
// .ns-skeleton .ns-page-header {
|
||||
// margin-bottom: 0 !important;
|
||||
// }
|
||||
|
||||
.ns-view {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
background: #e5ebf0;
|
||||
}
|
||||
:deep(.ant-spin-nested-loading) {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
:deep(.ant-spin-container) {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
:deep(.ant-divider) {
|
||||
display: none;
|
||||
}
|
||||
.ns-page-header {
|
||||
margin-bottom: 0 !important;
|
||||
padding: 7px 16px !important;
|
||||
width: calc(100% + 32px);
|
||||
margin-left: -16px;
|
||||
.title {
|
||||
cursor: pointer;
|
||||
font-size: 18px !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.text {
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.config-name {
|
||||
// span:after {
|
||||
// content: '';
|
||||
// width: 75px;
|
||||
// height: 7px;
|
||||
// display: block;
|
||||
// background: linear-gradient(90deg, @primary-color 0%, #fff 82.67%);
|
||||
// margin-left: 2px;
|
||||
// margin-top: -7px;
|
||||
// }
|
||||
}
|
||||
.ns-add-form {
|
||||
border-top: 16px solid #e5ebf0;
|
||||
padding: 16px 21px;
|
||||
background: #fff;
|
||||
height: calc(100% - 47px);
|
||||
:deep(.ns-form) {
|
||||
.ns-form-item .ns-form-body .ns-child-form-title {
|
||||
padding-top: 0;
|
||||
}
|
||||
&:after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
:deep(.ns-form.ns-vertical-form) {
|
||||
padding-top: 16px !important;
|
||||
}
|
||||
</style>
|
||||
207
lib/saas/view/config/configDate.vue
Normal file
207
lib/saas/view/config/configDate.vue
Normal file
@@ -0,0 +1,207 @@
|
||||
<!-- @format -->
|
||||
|
||||
<template>
|
||||
<span style="color: #37abc4; cursor: pointer" class="config-input" @click="editTime()">
|
||||
{{ timeValue.expectedValue || '-' }}
|
||||
</span>
|
||||
<a-modal
|
||||
v-model:visible="visibleTime"
|
||||
title="选择"
|
||||
@ok="changeDate"
|
||||
:mask="false"
|
||||
style="top: 150px">
|
||||
<div class="modal-time-picker">
|
||||
<a-time-picker
|
||||
format="HH:mm"
|
||||
v-model:value="startTimeValue"
|
||||
valueFormat="HH:mm"
|
||||
:allowClear="false"
|
||||
v-model:open="startOpen"
|
||||
@change="_onChange"
|
||||
:disabledHours="startDisabledHours"
|
||||
:disabledMinutes="startDisabledMinutes" />~
|
||||
<a-time-picker
|
||||
format="HH:mm"
|
||||
valueFormat="HH:mm"
|
||||
v-model:value="endTimeValue"
|
||||
:allowClear="false"
|
||||
v-model:open="endOpen"
|
||||
@change="_onChange"
|
||||
:disabledHours="endDisabledHours"
|
||||
:disabledMinutes="endDisabledMinutes" />
|
||||
</div>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import moment from 'moment';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
timeValue: {
|
||||
type: Object,
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
},
|
||||
listKey: {
|
||||
type: String,
|
||||
},
|
||||
// text: {
|
||||
// type: String,
|
||||
// default: '',
|
||||
// },
|
||||
},
|
||||
emits: ['changeDate', 'blur'],
|
||||
setup(props, ctx) {
|
||||
const startOpen = ref(false);
|
||||
const endOpen = ref(false);
|
||||
const time = props.timeValue.expectedValue.split('-');
|
||||
let startTimeValue = ref(time[0]);
|
||||
let startTimeValue1 = moment(time[0], 'HH:mm');
|
||||
let endTimeValue = ref(time[1]);
|
||||
let endTimeValue1 = moment(time[1], 'HH:mm');
|
||||
const visibleTime = ref<boolean>(false);
|
||||
let timeValue = ref('');
|
||||
const editTime = () => {
|
||||
visibleTime.value = true;
|
||||
};
|
||||
const changeDate = () => {
|
||||
visibleTime.value = false;
|
||||
let value = {
|
||||
configValue: timeValue.value,
|
||||
index: props.index,
|
||||
key: props.listKey,
|
||||
};
|
||||
ctx.emit('changeDate', value);
|
||||
// console.log(timeValue.value);
|
||||
};
|
||||
const handleClose = () => {
|
||||
startOpen.value = false;
|
||||
endOpen.value = false;
|
||||
};
|
||||
const _onChange = () => {
|
||||
// console.log('change', startTimeValue.value, endTimeValue.value);
|
||||
timeValue.value = startTimeValue.value + '-' + endTimeValue.value;
|
||||
|
||||
return;
|
||||
let start: string = startTimeValue.value._d.toString();
|
||||
let end: string = endTimeValue.value._d.toString();
|
||||
let startTime = start.split(' ');
|
||||
let endTime = end.split(' ');
|
||||
startTimeValue.value = startTime[4].split(':')[0] + ':' + startTime[4].split(':')[1];
|
||||
endTimeValue.value = endTime[4].split(':')[0] + ':' + endTime[4].split(':')[1];
|
||||
timeValue.value = startTimeValue.value + '-' + endTimeValue.value;
|
||||
};
|
||||
const startDisabledHours = () => {
|
||||
let disHours = [];
|
||||
let starthours: Number;
|
||||
if (endTimeValue.value == undefined) {
|
||||
let time = endTimeValue.value.split(':');
|
||||
starthours = time[0];
|
||||
} else {
|
||||
let time = endTimeValue.value;
|
||||
starthours = time.split(':')[0];
|
||||
}
|
||||
for (let i = 24; i > starthours; i--) {
|
||||
disHours.push(i);
|
||||
}
|
||||
return disHours;
|
||||
};
|
||||
const endDisabledHours = () => {
|
||||
let disHours = [];
|
||||
let endhours: Number;
|
||||
if (startTimeValue.value == undefined) {
|
||||
let time = startTimeValue.value.split(':');
|
||||
endhours = time[0];
|
||||
} else {
|
||||
let time = startTimeValue.value;
|
||||
endhours = time.split(':')[0];
|
||||
}
|
||||
for (let i = 0; i < endhours; i++) {
|
||||
disHours.push(i);
|
||||
}
|
||||
return disHours;
|
||||
};
|
||||
const startDisabledMinutes = (selectedHour: any) => {
|
||||
let time: Number[] = [];
|
||||
let endhours: Number;
|
||||
let endMinutes: Number;
|
||||
let disminutes = [];
|
||||
if (endTimeValue.value == undefined) {
|
||||
time = startTimeValue.value.split(':');
|
||||
endhours = time[0];
|
||||
endMinutes = time[1];
|
||||
if (selectedHour == endhours) {
|
||||
for (var i = 59; i > endMinutes; i--) {
|
||||
disminutes.push(i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
time = endTimeValue.value.split(':');
|
||||
endhours = time[0];
|
||||
endMinutes = time[1];
|
||||
if (selectedHour == endhours) {
|
||||
for (var i = 59; i > endMinutes; i--) {
|
||||
disminutes.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return disminutes;
|
||||
};
|
||||
const endDisabledMinutes = (selectedHour: any) => {
|
||||
let time: Number[] = [];
|
||||
let endhours: Number;
|
||||
let endMinutes: Number;
|
||||
let disminutes = [];
|
||||
if (startTimeValue.value == undefined) {
|
||||
time = startTimeValue.value.split(':');
|
||||
endhours = time[0];
|
||||
endMinutes = time[1];
|
||||
if (selectedHour == endhours) {
|
||||
for (var i = 0; i < endMinutes; i++) {
|
||||
disminutes.push(i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
time = startTimeValue.value.split(':');
|
||||
endhours = time[0];
|
||||
endMinutes = time[1];
|
||||
if (selectedHour == endhours) {
|
||||
for (var i = 0; i < endMinutes; i++) {
|
||||
disminutes.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return disminutes;
|
||||
};
|
||||
return {
|
||||
editTime,
|
||||
time,
|
||||
_onChange,
|
||||
startDisabledHours,
|
||||
endDisabledHours,
|
||||
startDisabledMinutes,
|
||||
endDisabledMinutes,
|
||||
visibleTime,
|
||||
endOpen,
|
||||
startOpen,
|
||||
startTimeValue,
|
||||
endTimeValue,
|
||||
startTimeValue1,
|
||||
endTimeValue1,
|
||||
changeDate,
|
||||
handleClose,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
.modal-time-picker {
|
||||
margin-left: 50px;
|
||||
}
|
||||
|
||||
:deep(.ant-time-picker) {
|
||||
width: 150px;
|
||||
}
|
||||
</style>
|
||||
100
lib/saas/view/config/configEnum.vue
Normal file
100
lib/saas/view/config/configEnum.vue
Normal file
@@ -0,0 +1,100 @@
|
||||
<!-- @format -->
|
||||
|
||||
<template>
|
||||
<span @click="editEnum()" style="color: #37abc4; cursor: pointer">
|
||||
{{ configValue.expectedValue ? configValue.expectedValue : '-' }}
|
||||
</span>
|
||||
<a-modal v-model:visible="visible" title="选择" @ok="handleOk" :mask="false" style="top: 20px">
|
||||
<a-table
|
||||
:row-selection="rowSelection"
|
||||
:columns="modalColumns"
|
||||
:data-source="tableData"
|
||||
:pagination="false"
|
||||
rowKey="value" />
|
||||
</a-modal>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref } from 'vue';
|
||||
export interface EnumData {
|
||||
dataType: string;
|
||||
name: string;
|
||||
value: number | string;
|
||||
}
|
||||
export default defineComponent({
|
||||
props: {
|
||||
configValue: {
|
||||
type: Object,
|
||||
},
|
||||
// enumTableConfig: {
|
||||
// type: Object,
|
||||
// },
|
||||
index: {
|
||||
type: Number,
|
||||
},
|
||||
listKey: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
emits: ['changeEnum', 'blur'],
|
||||
setup(props, ctx) {
|
||||
// console.log(props.configValue);
|
||||
const visible = ref<Boolean>(false);
|
||||
let tableData = ref([]);
|
||||
let choseData = ref();
|
||||
//枚举弹窗表格-列配置
|
||||
const modalColumns = [
|
||||
{
|
||||
title: '功能项',
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
dataIndex: 'value',
|
||||
},
|
||||
];
|
||||
//编辑-选择弹窗
|
||||
const editEnum = () => {
|
||||
tableData.value = props.configValue.childSpecsDTOList
|
||||
? props.configValue.childSpecsDTOList
|
||||
: props.configValue.list;
|
||||
rowSelection.value.selectedRowKeys = [Number(props.configValue.expectedValue)];
|
||||
|
||||
visible.value = true;
|
||||
};
|
||||
//关闭选择弹窗
|
||||
const handleOk = (e: MouseEvent) => {
|
||||
visible.value = false;
|
||||
let value = {
|
||||
configValue: choseData.value,
|
||||
index: props.index,
|
||||
key: props.listKey,
|
||||
};
|
||||
ctx.emit('changeEnum', value);
|
||||
};
|
||||
//选择弹窗-单选数据
|
||||
const rowSelection = ref({
|
||||
type: 'radio',
|
||||
selectedRowKeys: [],
|
||||
// getCheckboxProps(record) {
|
||||
// return {
|
||||
// defaultChecked: record.value == props.configValue.expectedValue, // 配置默认勾选的列
|
||||
// };
|
||||
// },
|
||||
// selectedRowKeys:getConfig.value[index1.value].getBindValues[index2.value - 1]
|
||||
onChange: (selectedRowKeys, selectedRows: EnumData[]) => {
|
||||
rowSelection.value.selectedRowKeys = selectedRowKeys;
|
||||
choseData.value = selectedRows[0].value;
|
||||
},
|
||||
});
|
||||
return {
|
||||
editEnum,
|
||||
handleOk,
|
||||
visible,
|
||||
modalColumns,
|
||||
tableData,
|
||||
rowSelection,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style scoped></style>
|
||||
186
lib/saas/view/config/configInput.vue
Normal file
186
lib/saas/view/config/configInput.vue
Normal file
@@ -0,0 +1,186 @@
|
||||
<!-- @format -->
|
||||
|
||||
<template>
|
||||
<div v-if="editableData" class="editable-cell-input-wrapper">
|
||||
<a-input
|
||||
:title="editableData.expectedValue"
|
||||
v-model:value="editableData.expectedValue"
|
||||
@pressEnter="save()" />
|
||||
<CheckOutlined :style="{ color: '#37abc4', margin: '0 5px' }" @click="save()" />
|
||||
<CloseCircleOutlined :style="{ color: '#37abc4' }" @click="clear()" />
|
||||
<br />
|
||||
<span v-if="editableData.message" class="config-message">
|
||||
<CloseCircleFilled :style="{ color: 'red' }" />{{ editableData.message }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-else class="editable-cell-text-wrapper">
|
||||
<span class="config-input">{{ configValue.expectedValue }}</span>
|
||||
<EditOutlined :style="{ color: '#37abc4' }" @click="edit()" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import {
|
||||
CheckOutlined,
|
||||
EditOutlined,
|
||||
CloseCircleOutlined,
|
||||
CloseCircleFilled,
|
||||
} from '@ant-design/icons-vue';
|
||||
export interface DataItem {
|
||||
childName: string;
|
||||
remark: string;
|
||||
configValue: string;
|
||||
expectedValue: string;
|
||||
key: string;
|
||||
message: string;
|
||||
rulesData: object;
|
||||
}
|
||||
export default defineComponent({
|
||||
components: {
|
||||
CheckOutlined,
|
||||
EditOutlined,
|
||||
CloseCircleOutlined,
|
||||
CloseCircleFilled,
|
||||
},
|
||||
props: {
|
||||
configValue: {
|
||||
type: Object,
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
},
|
||||
listKey: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
emits: ['changeInput', 'blur'],
|
||||
setup(props, ctx) {
|
||||
let editableData = ref();
|
||||
let ifShow = ref<boolean>(false);
|
||||
//输入框编辑
|
||||
const edit = () => {
|
||||
// console.log('edit');
|
||||
editableData.value = cloneDeep(props.configValue);
|
||||
ifShow.value = true;
|
||||
console.log(editableData.value);
|
||||
};
|
||||
//输入框保存
|
||||
const save = () => {
|
||||
// console.log('save');
|
||||
let dataType = editableData.value.childSpecsDTO;
|
||||
validatorRules();
|
||||
if (validatorRules()) {
|
||||
let value = {
|
||||
configValue: editableData.value.expectedValue,
|
||||
index: props.index,
|
||||
key: props.listKey,
|
||||
};
|
||||
if (dataType.dataType == 'INT') {
|
||||
value.configValue = parseInt(value.configValue);
|
||||
}
|
||||
ctx.emit('changeInput', value);
|
||||
editableData.value = '';
|
||||
} else {
|
||||
}
|
||||
};
|
||||
//校验规则
|
||||
const validatorRules = () => {
|
||||
// console.log('校验规则');
|
||||
let rulesData = editableData.value.childSpecsDTO;
|
||||
let value = editableData.value.expectedValue;
|
||||
// console.log(rulesData);
|
||||
// console.log(value);
|
||||
if (rulesData['min'] && rulesData['max']) {
|
||||
}
|
||||
const min = parseInt(rulesData['min']);
|
||||
const max = parseInt(rulesData['max']);
|
||||
// if (value == '') {
|
||||
// editableData.value.message = '不可以为空';
|
||||
// return false;
|
||||
// }
|
||||
if (rulesData.dataType == 'TEXT') {
|
||||
if (value.length > rulesData.length) {
|
||||
editableData.value.message = '字符串长度最大不超过' + rulesData.length;
|
||||
// console.log('字符串长度最大不超过' + rulesData.length);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (rulesData.dataType == 'DOUBLE') {
|
||||
value = value + '';
|
||||
if (value.length > 100) {
|
||||
editableData.value.message = 'double类型支持最大位数为100';
|
||||
return false;
|
||||
}
|
||||
if (!/^(-)?[0-9]+\.?([0-9]{0,16})?$/.test(value)) {
|
||||
editableData.value.message = '双精度有效位为16';
|
||||
return false;
|
||||
}
|
||||
if (value > max || value < min) {
|
||||
editableData.value.message = ''.concat(`取值范围:${min} ~ ${max}`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (rulesData.dataType == 'FLOAT') {
|
||||
if (!/^(-)?[0-9]+\.?([0-9]{0,7})?$/.test(value)) {
|
||||
editableData.value.message = '单精度有效位为7';
|
||||
return false;
|
||||
}
|
||||
if (value > max || value < min) {
|
||||
editableData.value.message = ''.concat(`取值范围:${min} ~ ${max}`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (rulesData.dataType == 'INT') {
|
||||
value = value.toString();
|
||||
value = value.split('.');
|
||||
if (value.length <= 1) {
|
||||
value = parseInt(value);
|
||||
if (typeof value === 'number' && value % 1 === 0) {
|
||||
if (value < min || value > max) {
|
||||
editableData.value.message = `取值范围:${min} ~ ${max}`;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
editableData.value.message = '请输入正确的整数类型';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
editableData.value.message = '请输入正确的整数类型';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
//关闭输入框内容
|
||||
const clear = () => {
|
||||
editableData.value = '';
|
||||
};
|
||||
return {
|
||||
save,
|
||||
clear,
|
||||
edit,
|
||||
editableData,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
:deep(.editable-cell-input-wrapper input) {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.config-message {
|
||||
color: red;
|
||||
}
|
||||
.editable-cell-text-wrapper {
|
||||
width: 70%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
71
lib/saas/view/config/configSwitch.vue
Normal file
71
lib/saas/view/config/configSwitch.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<!-- @format -->
|
||||
|
||||
<template>
|
||||
<div class="switchAlign">
|
||||
<a-switch
|
||||
v-model:checked="checked"
|
||||
:checkedValue="1"
|
||||
:unCheckedValue="0"
|
||||
@click="changeBool()" />
|
||||
<span v-if="configValue.expectedValue == 1 ? true : false">开</span>
|
||||
<span v-else>关</span>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, createVNode } from 'vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
export default defineComponent({
|
||||
components: {
|
||||
ExclamationCircleOutlined,
|
||||
},
|
||||
props: {
|
||||
configValue: {
|
||||
type: Object,
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
},
|
||||
listKey: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
emits: ['changeSwitch', 'blur'],
|
||||
setup(props, ctx) {
|
||||
let checked = ref<Boolean>(props.configValue.expectedValue);
|
||||
//改变开关状态
|
||||
const changeBool = () => {
|
||||
// console.log('changeBool');
|
||||
Modal.confirm({
|
||||
title: '警告',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: '确定要将进行此项操作?',
|
||||
onOk() {
|
||||
let value = {
|
||||
configValue: checked.value,
|
||||
index: props.index,
|
||||
key: props.listKey,
|
||||
};
|
||||
ctx.emit('changeSwitch', value);
|
||||
},
|
||||
onCancel() {
|
||||
checked.value = props.configValue.expectedValue;
|
||||
},
|
||||
});
|
||||
};
|
||||
return {
|
||||
changeBool,
|
||||
checked,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.switchAlign {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
span {
|
||||
padding-left: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
31
lib/saas/view/config/defaultSettings.js
Normal file
31
lib/saas/view/config/defaultSettings.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 项目默认配置项
|
||||
* primaryColor - 默认主题色, 如果修改颜色不生效,请清理 localStorage
|
||||
* navTheme - sidebar theme ['dark', 'light'] 两种主题
|
||||
* colorWeak - 色盲模式
|
||||
* layout - 整体布局方式 ['sidemenu', 'topmenu'] 两种布局
|
||||
* fixedHeader - 固定 Header : boolean
|
||||
* fixSiderbar - 固定左侧菜单栏 : boolean
|
||||
* contentWidth - 内容区布局: 流式 | 固定
|
||||
*
|
||||
* storageOptions: {} - Vue-ls 插件配置项 (localStorage/sessionStorage)
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
export default {
|
||||
navTheme: 'dark', // theme for nav menu
|
||||
primaryColor: '#52C41A', // primary color of ant design
|
||||
layout: 'sidemenu', // nav menu position: `sidemenu` or `topmenu`
|
||||
contentWidth: 'Fluid', // layout of content: `Fluid` or `Fixed`, only works when layout is topmenu
|
||||
fixedHeader: false, // sticky header
|
||||
fixSiderbar: false, // sticky siderbar
|
||||
colorWeak: false,
|
||||
menu: {
|
||||
locale: true,
|
||||
},
|
||||
title: 'Ant Design Pro',
|
||||
pwa: false,
|
||||
iconfontUrl: '',
|
||||
production: process.env.NODE_ENV === 'production' && process.env.VUE_APP_PREVIEW !== 'true',
|
||||
};
|
||||
Reference in New Issue
Block a user