CzRger 2 meses atrás
pai
commit
0547449726

+ 28 - 6
src/components/czr-ui/CzrConfirm.vue

@@ -15,18 +15,40 @@
           <SvgIcon name="czr_close" size="14" color="#909399" />
         </div>
       </div>
-      <div class="__czr-confirm-content">
+      <div
+        class="__czr-confirm-content"
+        :class="{
+          'no-foot': !(
+            DialogStore.confirmParam.props.showSubmit ||
+            DialogStore.confirmParam.props.showCancel
+          ),
+        }"
+      >
         <div>
           <SvgIcon name="czr_tip" size="20" :active="true" />
         </div>
         <div v-html="DialogStore.confirmParam.content" />
       </div>
-      <div class="__czr-confirm-foot">
-        <div class="__czr-dialog-foot_submit __hover" @click="CDSubmit">
-          确认
+      <div
+        class="__czr-confirm-foot"
+        v-if="
+          DialogStore.confirmParam.props.showSubmit ||
+          DialogStore.confirmParam.props.showCancel
+        "
+      >
+        <div
+          class="__czr-dialog-foot_submit __hover"
+          @click="CDSubmit"
+          v-if="DialogStore.confirmParam.props.showSubmit"
+        >
+          {{ DialogStore.confirmParam.props.submitText }}
         </div>
-        <div class="__czr-dialog-foot_cancel __hover" @click="CDClose">
-          取消
+        <div
+          class="__czr-dialog-foot_cancel __hover"
+          @click="CDClose"
+          v-if="DialogStore.confirmParam.props.showCancel"
+        >
+          {{ DialogStore.confirmParam.props.cancelText }}
         </div>
       </div>
     </div>

+ 12 - 1
src/stores/modules/dialog.ts

@@ -1,5 +1,11 @@
 import { defineStore } from 'pinia'
 
+const defaultProps = {
+  showSubmit: true,
+  showCancel: true,
+  submitText: '确认',
+  cancelText: '取消',
+}
 export const useDialogStore = defineStore('dialog', {
   state: () => ({
     dialogShows: <any>[],
@@ -10,6 +16,9 @@ export const useDialogStore = defineStore('dialog', {
       content: '',
       onSubmit: () => {},
       onCancel: () => {},
+      props: {
+        ...defaultProps,
+      },
     },
     zIndex: 100,
   }),
@@ -37,8 +46,9 @@ export const useDialogStore = defineStore('dialog', {
       width = '31.25rem',
       title = '提示',
       content,
-      onSubmit,
+      onSubmit = () => {},
       onCancel = () => {},
+      props = {},
     }) {
       this.confirmParam = {
         width,
@@ -47,6 +57,7 @@ export const useDialogStore = defineStore('dialog', {
         content,
         onSubmit: onSubmit,
         onCancel: onCancel,
+        props: Object.assign(defaultProps, props),
       }
     },
     addZIndex() {

+ 3 - 0
src/style/czr.scss

@@ -387,6 +387,9 @@
         background-color: var(--czr-dialog-bg);
         border-radius: 0.5rem;
         display: flex;
+        &.no-foot {
+          margin-bottom: 1rem;
+        }
         > div:nth-child(1) {
           margin-right: 0.75rem;
         }

+ 95 - 4
src/views/manage/app/make/index.vue

@@ -520,7 +520,7 @@
             <div class="text-2xl font-bold text-[#303133]">预览</div>
             <div
               class="flex items-center gap-2 text-sm text-[var(--czr-error-color)]"
-              v-if="debugError"
+              v-if="modelApplyCpt"
             >
               <SvgIcon name="czr_tip" color="var(--czr-error-color)" />
               编排中有申请中的模型,预览暂不可用
@@ -581,6 +581,39 @@
       v-model:show="state.templateDetail.show"
       :transfer="state.templateDetail.transfer"
     />
+    <CzrDialog
+      :show="state.publish.show"
+      title="发布"
+      @onClose="state.publish.show = false"
+      @onSubmit="onPublishSubmit"
+      width="42.5rem"
+      height="auto"
+    >
+      <div class="bm-form">
+        <CzrForm ref="ref_formPublish">
+          <CzrFormColumn
+            required
+            label="发布渠道"
+            :span="24"
+            v-model:param="state.publish.form.name"
+            link="select"
+            :options="[
+              { label: '个人', value: '1' },
+              { label: '公共空间(需审批)', value: '2' },
+            ]"
+            :clearable="false"
+          />
+          <CzrFormColumn
+            v-if="state.publish.form.name == 2"
+            label="申请留言"
+            :span="24"
+            v-model:param="state.publish.form.description"
+            type="textarea"
+            :rows="10"
+          />
+        </CzrForm>
+      </div>
+    </CzrDialog>
   </div>
 </template>
 
@@ -597,7 +630,7 @@ import {
 } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { ElLoading, ElMessage } from 'element-plus'
-import { useDictionaryStore } from '@/stores'
+import { useDialogStore, useDictionaryStore } from '@/stores'
 import { Search } from '@element-plus/icons-vue'
 import knowledgeSelect from './knowledge-select.vue'
 import modelSelect from './model-select.vue'
@@ -609,8 +642,10 @@ import templateSelect from './template-select.vue'
 import templateDetail from './template-detail.vue'
 import workflowSelect from './workflow-select.vue'
 import CzrForm from '@/components/czr-ui/CzrForm.vue'
+import CzrDialog from '@/components/czr-ui/CzrDialog.vue'
 
 const DictionaryStore = useDictionaryStore()
+const DialogStore = useDialogStore()
 const route = useRoute()
 const router = useRouter()
 const emit = defineEmits([])
@@ -649,12 +684,13 @@ const state: any = reactive({
     method: 1,
     voicePackage: '',
     advise: {
-      types: ['open', 'tips', 'knowledge'],
+      types: [],
       model: { name: '' },
       tips: '',
       knowledges: [],
     },
   },
+  detail: {},
   knowledgeSelect: {
     show: false,
     transfer: {},
@@ -674,6 +710,11 @@ const state: any = reactive({
     show: false,
     transfer: {},
   },
+  publish: {
+    show: false,
+    transfer: {},
+    form: {},
+  },
   prologuesAdd: {
     value: '',
   },
@@ -681,10 +722,11 @@ const state: any = reactive({
   isDebug: false,
 })
 const ref_form = ref()
+const ref_formPublish = ref()
 const ref_tips = ref()
 const ref_prologue = ref()
 const ref_prologueBody = ref()
-const debugError = computed(() => {
+const modelApplyCpt = computed(() => {
   return true
 })
 const initDetail = () => {
@@ -818,12 +860,61 @@ const onPublish = () => {
   ref_form.value
     .submit()
     .then(() => {
+      if (state.detail.type == 1) {
+        if (state.form.workflows.length === 0) {
+          ElMessage.warning('请添加工作流!')
+          return
+        }
+      }
       if (state.form.advise.types.includes('knowledge')) {
         if (state.form.advise.knowledges.length === 0) {
           ElMessage.warning('请添加问题建议知识库!')
           return
         }
       }
+      // if (modelApplyCpt.value) {
+      //   DialogStore.confirm({
+      //     content: `编排中有申请中的模型,暂不可发布!`,
+      //     props: {
+      //       showSubmit: false,
+      //       showCancel: false,
+      //     },
+      //   })
+      // }
+      // if (1) {
+      //   DialogStore.confirm({
+      //     title: '发布失败',
+      //     content: `该应用有发布中的申请,无法提交发布!<br/>申请提交时间:2023-02-02 15:21:23`,
+      //     onSubmit: () => {},
+      //     props: {
+      //       submitText: '撤销上一次的申请,重新发布',
+      //       cancelText: '等待审批',
+      //     },
+      //   })
+      // }
+      if (1) {
+        state.publish.transfer = {}
+        state.publish.show = true
+      }
+    })
+    .catch((e) => {
+      ElMessage({
+        message: e[0].message,
+        grouping: true,
+        type: 'warning',
+      })
+    })
+}
+const onPublishSubmit = () => {
+  ref_formPublish.value
+    .submit()
+    .then(() => {
+      DialogStore.confirm({
+        content: `请确认是否提交?`,
+        onSubmit: () => {
+          state.publish.show = false
+        },
+      })
     })
     .catch((e) => {
       ElMessage({