index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 = []) => {
  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.unit ? `${item.des}(${item.unit})` : 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.unit ? `${item.des}(${item.unit})` : 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.unit ? `${item.des}(${item.unit})` : 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, ...columnList]
  74. });
  75. }else{
  76. formSchema.value = commentFormSchema as any[]
  77. }
  78. };
  79. const changeFormItems = (data) => {
  80. if(data && data['strtype']){
  81. const formSchemaColumns = getFormSchemaColumns(`${data['strtype']}_edit`) || []
  82. arrToFormColumns(formSchemaColumns)
  83. isRefresh.value = true
  84. }else{
  85. formSchema.value = commentFormSchema as any[]
  86. isRefresh.value = true
  87. }
  88. }
  89. onMounted(() => {
  90. })
  91. </script>
  92. <style scoped></style>