123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <template>
- <div class="device-manager-box">
- <NormalTable
- v-if="isRefresh"
- :columns="columns"
- :searchFormSchema="searchFormSchema"
- :list="list"
- :getImportUrl="getImportUrl"
- :getExportUrl="getExportUrl"
- :formSchema="formSchema"
- :deleteById="deleteById"
- :batchDelete="batchDeleteById"
- :saveOrUpdate="saveOrUpdate"
- designScope="device-tabel"
- title="设备列表"
- :showTab="true"
- :deviceType="deviceType"
- />
- </div>
- </template>
- <script lang="ts" name="system-user" setup>
- //ts语法
- import { ref, onMounted, unref } from 'vue'
- import { FormSchema } from '/@/components/Table';
- import NormalTable from '../comment/NormalTable.vue';
- import { searchFormSchema } from './device.data';
- import { list, getImportUrl, getExportUrl, deleteById, batchDeleteById, saveOrUpdate } from './device.api';
- import { getFormSchemaColumns, getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
- import { list as substationList } from '../substationTabel/substation.api';
- import { useRouter } from 'vue-router';
- const { currentRoute } = useRouter()
- const formSchema = ref<FormSchema[]>([])
- const isRefresh = ref(false)
- const deviceType = ref('')
- const columns = ref<any[]>([])
- const arrToFormColumns = (tableHeaderColumns = []) => {
- const columnList: any[] = [];
- tableHeaderColumns.forEach((item: any) => {
- let columnsItem;
- if (item.type == 1 || item.type == 10) {
- columnsItem = {
- label: item.unit ? `${item.des}(${item.unit})` : item.des, //_dictText
- field: item.monitorcode,
- component: item.type == 1 ? 'Input' : item.type == 10 ? 'InputTextArea' : '',
- };
- } else {
- if (item.type == 2 && item['monitorcode'] == 'nsubstationid') {
- columnsItem = {
- label: item.unit ? `${item.des}(${item.unit})` : item.des, //_dictText
- field: item.monitorcode,
- component: 'ApiSelect',
- componentProps: {
- api: substationList,
- labelField: 'strname',
- valueField: 'id',
- },
- };
- }
- if (item.type == 3) {
- columnsItem = {
- label: item.unit ? `${item.des}(${item.unit})` : item.des, //_dictText
- field: item.monitorcode,
- component: 'RadioGroup',
- defaultValue: 1,
- componentProps: () => {
- return {
- options: [
- { label: '是', value: 1, key: '1' },
- { label: '否', value: 0, key: '2' },
- ],
- stringToNumber: true,
- };
- },
- };
- }
- if (item.type == 4) {
- columnsItem = {
- label: item.unit ? `${item.des}(${item.unit})` : item.des, //_dictText
- field: item.monitorcode,
- component: 'JDictSelectTag',
- componentProps: {
- dictCode: item.dict,
- placeholder: '请选择',
- stringToNumber: true,
- },
- };
- }
- }
- columnList.push(columnsItem);
- });
- formSchema.value = columnList
- formSchema.value.unshift(
- {
- label: '设备id', //_dictText
- field: 'id',
- component: 'Input',
- componentProps: {
- disabled: true
- },
- },
- {
- label: '点表',
- field: 'strtype',
- component: 'JDictSelectTag',
- componentProps: {
- dictCode: `${deviceType.value}kind`,
- placeholder: '请选择点表',
- },
- }
- )
- formSchema.value.push(
- {
- label: '备用分站',
- field: 'stationids',
- component: 'ApiSelect',
- componentProps: {
- api: substationList,
- labelField: 'strname',
- valueField: 'id',
- },
- },
- )
- };
- onMounted(() => {
- const route = unref(currentRoute)
- const pageType = route.name
- deviceType.value = pageType
- searchFormSchema[0].componentProps['dictCode'] = `${deviceType.value}kind`
- columns.value = getTableHeaderColumns(`${deviceType.value}_list`) || []
- const formSchemaColumns = getFormSchemaColumns(`${deviceType.value}_edit`) || []
-
- arrToFormColumns(formSchemaColumns)
- isRefresh.value = true
- })
- </script>
- <style scoped></style>
|