editFormDialog.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="flow-container">
  3. <el-dialog v-model="state.isShowDialog" :width="800" draggable :close-on-click-modal="false">
  4. <template #header>
  5. <div style="color: #fff">
  6. <el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
  7. <span>{{ props.title }}</span>
  8. </div>
  9. </template>
  10. <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
  11. <el-row :gutter="35">
  12. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
  13. <el-form-item label="库定位器" prop="configId" :rules="[{ required: true, message: '库定位器不能为空', trigger: 'blur' }]">
  14. <el-select v-model="state.ruleForm.configId" placeholder="库名" filterable @change="dbChanged()" class="w100">
  15. <el-option v-for="item in state.dbData" :key="item.configId" :label="item.configId" :value="item.configId" />
  16. </el-select>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
  20. <el-form-item label="表定位器" prop="tableName" :rules="[{ required: true, message: '表定位器不能为空', trigger: 'blur' }]">
  21. <el-select v-model="state.ruleForm.tableName" value-key="value" filterable clearable class="w100">
  22. <el-option v-for="item in state.tableData" :key="item.name" :label="item.name + ' [ ' + item.description + ' ]'" :value="item.name" />
  23. </el-select>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
  27. <el-form-item label="操作" prop="typeName" :rules="[{ required: true, message: '操作不能为空', trigger: 'blur' }]">
  28. <el-select v-model="state.ruleForm.typeName" value-key="value" filterable clearable class="w100">
  29. <el-option v-for="item in state.typeData" :key="item.name" :label="item.name + ' ( ' + item.value + ' )' + ' [ ' + item.description + ' ]'" :value="item.value" />
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. </el-row>
  34. </el-form>
  35. <template #footer>
  36. <span class="dialog-footer">
  37. <el-button @click="cancel">取 消</el-button>
  38. <el-button type="primary" @click="submit">确 定</el-button>
  39. </span>
  40. </template>
  41. </el-dialog>
  42. </div>
  43. </template>
  44. <script setup lang="ts">
  45. import { reactive, ref, onMounted } from 'vue';
  46. import type { FormRules } from 'element-plus';
  47. import { getAPI } from '/@/utils/axios-utils';
  48. import { ApprovalFlowApi } from '/@/api-plugins/_approvalFlow/api';
  49. import { ApprovalFlowOutput, UpdateApprovalFlowInput } from '/@/api-plugins/_approvalFlow/models';
  50. import { SysDatabaseApi, SysCodeGenApi } from '/@/api-services/api';
  51. import { DbTableInfo } from '/@/api-services/models';
  52. var props = defineProps({
  53. title: {
  54. type: String,
  55. default: '',
  56. },
  57. });
  58. const emit = defineEmits(['reloadTable']);
  59. const ruleFormRef = ref();
  60. const state = reactive({
  61. loading: false,
  62. isShowDialog: false,
  63. ruleSource: {} as UpdateApprovalFlowInput,
  64. ruleForm: {} as any,
  65. dbData: [] as any,
  66. tableData: [] as Array<DbTableInfo>,
  67. typeData: [
  68. {
  69. name: 'Add',
  70. value: 'add',
  71. description: '新增',
  72. },
  73. {
  74. name: 'Update',
  75. value: 'update',
  76. description: '更新',
  77. },
  78. {
  79. name: 'Delete',
  80. value: 'delete',
  81. description: '删除',
  82. },
  83. {
  84. name: 'Select',
  85. value: 'select',
  86. description: '查询',
  87. },
  88. {
  89. name: 'Export',
  90. value: 'export',
  91. description: '导出',
  92. },
  93. ],
  94. });
  95. const rules = ref<FormRules>({});
  96. onMounted(async () => {
  97. var resDb = await getAPI(SysCodeGenApi).apiSysCodeGenDatabaseListGet();
  98. state.dbData = resDb.data.result;
  99. });
  100. const openDialog = (row: ApprovalFlowOutput) => {
  101. state.ruleSource = row as UpdateApprovalFlowInput;
  102. state.ruleForm = row.formJson ? JSON.parse(row.formJson) : {};
  103. state.isShowDialog = true;
  104. dbChanged();
  105. };
  106. const closeDialog = () => {
  107. emit('reloadTable');
  108. state.isShowDialog = false;
  109. };
  110. const cancel = () => {
  111. state.isShowDialog = false;
  112. };
  113. const submit = async () => {
  114. state.ruleSource.formJson = JSON.stringify(state.ruleForm);
  115. await getAPI(ApprovalFlowApi).apiApprovalFlowUpdatePost(state.ruleSource);
  116. closeDialog();
  117. };
  118. // db改变
  119. const dbChanged = async () => {
  120. if (state.ruleForm.configId === '') return;
  121. var res = await getAPI(SysDatabaseApi).apiSysDatabaseTableListConfigIdGet(state.ruleForm.configId);
  122. state.tableData = res.data.result ?? [];
  123. };
  124. defineExpose({ openDialog });
  125. </script>
  126. <style scoped lang="scss">
  127. :deep(.el-select),
  128. :deep(.el-input-number) {
  129. width: 100%;
  130. }
  131. </style>