detail.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <!-- 流程表单详情抽屉 -->
  3. <div class="flow-flowForm-detail">
  4. <el-drawer v-model="isShowDialog" size="80%" direction="ltr">
  5. <template #header>
  6. <h4>{{ t('message.flowForm.detailTitle') }}</h4>
  7. </template>
  8. <div class="form-create-show">
  9. <FormCreate :option="detailData.option" :rule="detailData.rule" :locale="locale"/>
  10. </div>
  11. </el-drawer>
  12. </div>
  13. </template>
  14. <script lang="ts">
  15. // 引入 form-create
  16. import formCreate from '@form-create/element-ui'
  17. // 引入 form-create-edit
  18. import FcEditor from "@form-create/component-wangeditor";
  19. import { reactive, toRefs, defineComponent,ref,unref,getCurrentInstance,computed } from 'vue';
  20. import { useI18n } from 'vue-i18n'
  21. import {getFlowForm} from "/@/api/flow/flowForm";
  22. import {
  23. FlowFormInfoData,
  24. FlowFormEditState
  25. } from "/@/views/flow/flowForm/list/component/model"
  26. import {setConfAndFields2} from "/@/utils/formCreate";
  27. formCreate.component(FcEditor)
  28. //获取 formCreate 组件
  29. const FormCreate = formCreate.$form();
  30. export default defineComponent({
  31. name:"ApiV1FlowFlowFormDetail",
  32. components:{
  33. FormCreate
  34. },
  35. props:{
  36. statusOptions:{
  37. type:Array,
  38. default:()=>[]
  39. },
  40. },
  41. setup(props,{emit}) {
  42. const {proxy} = <any>getCurrentInstance()
  43. const { t,locale } = useI18n()
  44. const formRef = ref<HTMLElement | null>(null);
  45. const menuRef = ref();
  46. const detailData = ref({
  47. rule: [],
  48. option: {}
  49. })
  50. const state = reactive<FlowFormEditState>({
  51. loading:false,
  52. isShowDialog: false,
  53. formData: {
  54. id: undefined,
  55. name: undefined,
  56. status: false ,
  57. remark: undefined,
  58. createdAt: undefined,
  59. updatedAt: undefined,
  60. deletedAt: undefined,
  61. createdBy: undefined,
  62. updatedBy: undefined,
  63. conf: undefined,
  64. fields: undefined,
  65. },
  66. // 表单校验
  67. rules: {
  68. name : [
  69. { required: true, message: t('message.flowForm.nameRequired'), trigger: "blur" }
  70. ],
  71. status : [
  72. { required: true, message: t('message.flowForm.statusRequired'), trigger: "blur" }
  73. ],
  74. }
  75. });
  76. // 打开弹窗
  77. const openDialog = (row?: FlowFormInfoData) => {
  78. resetForm();
  79. if(row) {
  80. getFlowForm(row.id!).then((res:any)=>{
  81. const data = res;
  82. data.createdBy = data.createdUser?.userNickname
  83. data.updatedBy = data.updatedUser?.userNickname
  84. state.formData = data;
  85. setConfAndFields2(detailData, data.conf, data.fields)
  86. })
  87. }
  88. state.isShowDialog = true;
  89. };
  90. // 关闭弹窗
  91. const closeDialog = () => {
  92. state.isShowDialog = false;
  93. };
  94. // 取消
  95. const onCancel = () => {
  96. closeDialog();
  97. };
  98. const resetForm = ()=>{
  99. state.formData = {
  100. id: undefined,
  101. name: undefined,
  102. status: false ,
  103. remark: undefined,
  104. createdAt: undefined,
  105. updatedAt: undefined,
  106. deletedAt: undefined,
  107. createdBy: undefined,
  108. updatedBy: undefined,
  109. conf: undefined,
  110. fields: undefined,
  111. }
  112. };
  113. return {
  114. proxy,
  115. t,
  116. locale,
  117. openDialog,
  118. closeDialog,
  119. onCancel,
  120. menuRef,
  121. formRef,
  122. detailData,
  123. ...toRefs(state),
  124. };
  125. }
  126. })
  127. </script>
  128. <style scoped>
  129. .flow-flowForm-detail :deep(.el-form-item--large .el-form-item__label){
  130. font-weight: bolder;
  131. }
  132. .pic-block{
  133. margin-right: 8px;
  134. }
  135. .file-block{
  136. width: 100%;
  137. border: 1px solid var(--el-border-color);
  138. border-radius: 6px;
  139. cursor: pointer;
  140. position: relative;
  141. overflow: hidden;
  142. transition: var(--el-transition-duration-fast);
  143. margin-bottom: 5px;
  144. padding: 3px 6px;
  145. }
  146. .ml-2{margin-right: 5px;}
  147. .form-create-show{
  148. width: 100%;
  149. padding: 16px;
  150. }
  151. </style>