index.vue 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div class="device-manager-box">
  3. <CustomNormalTable
  4. :columns="[]"
  5. :searchFormSchema="searchFormSchema"
  6. :list="list"
  7. :formSchema="formSchema"
  8. :deleteById="deleteById"
  9. :batchDelete="batchDeleteById"
  10. :saveOrUpdate="saveOrUpdate"
  11. @edit-handler="changeFormItems"
  12. designScope="workingFace-tabel"
  13. title="智能管控"
  14. :showTab="true"
  15. deviceType="managesys"
  16. columnsType="managesys_list"
  17. />
  18. </div>
  19. </template>
  20. <script lang="ts" name="system-user" setup>
  21. //ts语法
  22. import { ref, onMounted } from 'vue';
  23. import CustomNormalTable from './CustomNormalTable.vue';
  24. import { searchFormSchema, commentFormSchema } from './workingFace.data';
  25. import { list, deleteById, batchDeleteById, saveOrUpdate } from './workingFace.api';
  26. import { FormSchema } from '/@/components/Table';
  27. import { getFormSchemaColumns } from '/@/hooks/web/useWebColumns';
  28. const formSchema = ref<FormSchema[]>([]);
  29. const isRefresh = ref(false);
  30. const arrToFormColumns = (tableHeaderColumns = [], strtype) => {
  31. const columnList: any[] = [];
  32. if (tableHeaderColumns.length > 0) {
  33. tableHeaderColumns.forEach((item: any) => {
  34. let columnsItem;
  35. if (item.type == 1 || item.type == 10) {
  36. columnsItem = {
  37. label: item.des, //_dictText
  38. field: item.monitorcode,
  39. component: item.type == 1 ? 'Input' : item.type == 10 ? 'InputTextArea' : '',
  40. };
  41. } else {
  42. if (item.type == 3) {
  43. columnsItem = {
  44. label: item.des, //_dictText
  45. field: item.monitorcode,
  46. component: 'RadioGroup',
  47. defaultValue: 1,
  48. componentProps: () => {
  49. return {
  50. options: [
  51. { label: '是', value: 1, key: '1' },
  52. { label: '否', value: 0, key: '2' },
  53. ],
  54. stringToNumber: true,
  55. };
  56. },
  57. };
  58. }
  59. if (item.type == 4) {
  60. columnsItem = {
  61. label: item.des, //_dictText
  62. field: item.monitorcode,
  63. component: 'JDictSelectTag',
  64. componentProps: {
  65. dictCode: item.dict,
  66. placeholder: '请选择',
  67. stringToNumber: true,
  68. },
  69. };
  70. }
  71. }
  72. columnList.push(columnsItem);
  73. formSchema.value = [...commentFormSchema(strtype), ...columnList];
  74. });
  75. } else {
  76. formSchema.value = commentFormSchema(strtype) as any[];
  77. }
  78. };
  79. const changeFormItems = (data) => {
  80. if (data && data['strtype']) {
  81. const formSchemaColumns = getFormSchemaColumns(`${data['strtype']}_edit`) || [];
  82. arrToFormColumns(formSchemaColumns, data['strtype']);
  83. isRefresh.value = true;
  84. } else {
  85. formSchema.value = commentFormSchema(data['strtype']) as any[];
  86. isRefresh.value = true;
  87. }
  88. };
  89. onMounted(() => {});
  90. </script>
  91. <style scoped></style>