Browse Source

广场模型管理

CzRger 2 weeks ago
parent
commit
1c63ff62b8

+ 19 - 0
src/api/modules/center/square.ts

@@ -18,3 +18,22 @@ export const appManageGetAppManageById = (params) =>
 // 广场应用管理-批量删除
 export const appManageDeleteAppManageByPatch = (params) =>
   post(`/appManage/deleteAppManageByPatch`, params, {})
+
+// 广场模型管理-分页
+export const modelManageGetModelManageByPage = (params) =>
+  post(`/modelManage/getModelManageByPage`, params, {})
+// 广场模型管理-新增
+export const modelManageSaveModelManage = (params) =>
+  post(`/modelManage/saveModelManage`, params, {})
+// 广场模型管理-编辑
+export const modelManageUpdateModelManage = (params) =>
+  post(`/modelManage/updateModelManage`, params, {})
+// 广场模型管理-更改状态
+export const modelManageChangeState = (params) =>
+  post(`/modelManage/changeState`, params, {})
+// 广场模型管理-详情
+export const modelManageGetModelManageById = (params) =>
+  post(`/modelManage/getModelManageById`, params, {})
+// 广场模型管理-批量删除
+export const modelManageDeleteModelManagePatch = (params) =>
+  post(`/modelManage/deleteModelManagePatch`, params, {})

+ 1 - 3
src/views/manage/center/square/app.vue

@@ -308,9 +308,7 @@ onMounted(() => {
   initDictionary()
   onReset()
 })
-const initDictionary = () => {
-  DictionaryStore.initTenants()
-}
+const initDictionary = () => {}
 </script>
 
 <style lang="scss" scoped></style>

+ 60 - 43
src/views/manage/center/square/model-detail.vue

@@ -10,48 +10,53 @@
     :loading="state.loading"
   >
     <div class="bm-form">
-      <div class="mb-4 flex gap-4">
-        <template v-for="item in DictionaryStore.squareAppType">
-          <div
-            class="__hover flex flex-col items-center"
-            :class="
-              state.form.type === item.value
-                ? 'text-base font-bold text-[var(--czr-main-color)]'
-                : 'text-sm text-[#576275]'
-            "
-            @click="state.form.type = item.value"
-          >
-            <div class="flex h-4 items-center justify-center">
-              {{ item.label }}
-            </div>
-            <div class="mt-1.75 w-full px-2">
-              <div
-                class="h-0.5 w-full"
-                :class="
-                  state.form.type === item.value
-                    ? 'bg-[var(--czr-main-color)]'
-                    : ''
-                "
-              />
-            </div>
-          </div>
-        </template>
-      </div>
       <CzrForm ref="ref_form" :form-view="isViewCpt">
         <CzrFormColumn
           required
-          :span="24"
-          label="模型名称"
-          v-model:param="state.form.name"
-        />
-        <CzrFormColumn
-          required
-          :span="24"
-          label="应用介绍"
-          v-model:param="state.form.introduction"
-          link="markdown"
-          height="400px"
+          :span="12"
+          label="模型类型"
+          v-model:param="state.form.type"
+          link="select"
+          :options="DictionaryStore.modelTypes.list"
+          @change="state.form.pluginClass = ''"
         />
+        <template v-if="state.form.type">
+          <CzrFormColumn
+            required
+            :span="12"
+            label="模型供应商"
+            v-model:param="state.form.manufacturer"
+            link="select"
+            :options="
+              DictionaryStore.modelProvides.list.filter(
+                (v) => v.type === state.form.type,
+              )
+            "
+            @getObject="getModelProvide"
+          />
+          <template v-if="state.form.manufacturer">
+            <CzrFormColumn
+              :span="24"
+              label="版本"
+              v-model:param="state.form.version"
+              :disabled="true"
+            />
+            <CzrFormColumn
+              required
+              :span="24"
+              label="模型名称"
+              v-model:param="state.form.name"
+            />
+            <CzrFormColumn
+              required
+              :span="24"
+              label="模型介绍"
+              v-model:param="state.form.synopsis"
+              link="markdown"
+              height="400px"
+            />
+          </template>
+        </template>
       </CzrForm>
     </div>
   </CzrDialog>
@@ -80,6 +85,10 @@ import {
   appManageGetAppManageById,
   appManageSaveAppMange,
   appManageUpdatAppManage,
+  modelManageGetModelManageById,
+  modelManageSaveModelManage,
+  modelManageUpdateModelManage,
+  modelManageUpdatModelManage,
 } from '@/api/modules/center/square'
 
 const router = useRouter()
@@ -122,7 +131,6 @@ watch(
       initDictionary()
       state.form = {
         state: 0,
-        type: '0',
       }
       if (props.transfer.mode !== 'add') {
         initData()
@@ -133,10 +141,13 @@ watch(
     }
   },
 )
-const initDictionary = () => {}
+const initDictionary = () => {
+  DictionaryStore.initModelTypes()
+  DictionaryStore.initModelProvides()
+}
 const initData = () => {
   state.loading = true
-  appManageGetAppManageById(props.transfer.id)
+  modelManageGetModelManageById({ id: props.transfer.id })
     .then(({ data }: any) => {
       state.form = data
     })
@@ -154,7 +165,7 @@ const onSubmit = () => {
         onSubmit: () => {
           state.loading = true
           if (props.transfer.mode === 'add') {
-            appManageSaveAppMange(state.form)
+            modelManageSaveModelManage(state.form)
               .then(({ data }: any) => {
                 ElMessage.success(`${titleCpt.value}成功!`)
                 emit('update:show', false)
@@ -165,7 +176,7 @@ const onSubmit = () => {
                 state.loading = false
               })
           } else {
-            appManageUpdatAppManage(state.form)
+            modelManageUpdateModelManage(state.form)
               .then(({ data }: any) => {
                 ElMessage.success(`${titleCpt.value}成功!`)
                 emit('update:show', false)
@@ -187,6 +198,12 @@ const onSubmit = () => {
       })
     })
 }
+const getModelProvide = (obj) => {
+  console.log(obj)
+  state.form.name = obj.name
+  state.form.version = obj.version
+  state.form.synopsis = obj.description
+}
 </script>
 
 <style lang="scss" scoped></style>

+ 27 - 13
src/views/manage/center/square/model.vue

@@ -15,7 +15,7 @@
             class="__czr-table-form-column"
             :span="24"
             label-width="0px"
-            v-model:param="state.query.form.modeType"
+            v-model:param="state.query.form.type"
             link="select"
             :options="DictionaryStore.modelTypes.list"
             placeholder="模型类型"
@@ -61,8 +61,10 @@
         <template #caozuo-column-value="{ scope }">
           <div class="__czr-table-operations">
             <CzrButton type="table" title="查看" @click="onView(scope.row)" />
-            <CzrButton type="table" title="编辑" @click="onEdit(scope.row)" />
-            <CzrButton type="table-del" @click="onDel(scope.row)" />
+            <template v-if="scope.row.state != 1">
+              <CzrButton type="table" title="编辑" @click="onEdit(scope.row)" />
+              <CzrButton type="table-del" @click="onDel(scope.row)" />
+            </template>
           </div>
         </template>
       </CzrTable>
@@ -93,8 +95,10 @@ import {
   appManageChangeState,
   appManageDeleteAppManageByPatch,
   appManageGetAppManageByPage,
+  modelManageChangeState,
+  modelManageDeleteModelManagePatch,
+  modelManageGetModelManageByPage,
 } from '@/api/modules/center/square'
-import { pluginUpdateStatus } from '@/api/modules/model'
 
 const AppStore = useAppStore()
 const DialogStore = useDialogStore()
@@ -111,12 +115,17 @@ const state: any = reactive({
       { value: 'name', label: '模型名称', show: true },
       {
         value: 'type',
+        label: '模型类型',
+        show: true,
+        dictList: computed(() => DictionaryStore.modelTypes.list),
+      },
+      {
+        value: 'manufacturer',
         label: '模型厂商',
         show: true,
-        dictList: computed(() => DictionaryStore.squareAppType),
+        dictList: computed(() => DictionaryStore.modelProvides.list),
       },
-      { value: 'clickCount', label: '模型类型', show: true },
-      { value: 'clickCount', label: '模型版本', show: true },
+      { value: 'version', label: '模型版本', show: true },
       {
         value: 'createTime',
         label: '接入时间',
@@ -208,7 +217,7 @@ const onPage = (pageNum, pageSize) => {
   for (const [k, v] of Object.entries(state.query.sort)) {
   }
   state.query.loading = true
-  appManageGetAppManageByPage(params)
+  modelManageGetModelManageByPage(params)
     .then(({ data }: any) => {
       state.query.result.total = data.totalElements
       state.query.result.data = data.content
@@ -257,7 +266,7 @@ const onDel = (row: any = null) => {
       title: '删除确认',
       content: `请确认是否删除${row.name}?`,
       onSubmit: () => {
-        appManageDeleteAppManageByPatch([row.id])
+        modelManageDeleteModelManagePatch([row.id])
           .then(() => {
             ElMessage.success('删除成功!')
           })
@@ -272,11 +281,15 @@ const onDel = (row: any = null) => {
       ElMessage.warning('请至少选择一条记录!')
       return
     }
+    if (state.query.selected.some((v) => v.state == 1)) {
+      ElMessage.warning('已启用的应用不可删除,请重新选择!')
+      return
+    }
     DialogStore.confirm({
       title: '删除确认',
       content: `请确认是否删除${state.query.selected.length}条记录?`,
       onSubmit: () => {
-        appManageDeleteAppManageByPatch(state.query.selected.map((v) => v.id))
+        modelManageDeleteModelManagePatch(state.query.selected.map((v) => v.id))
           .then(() => {
             ElMessage.success('删除成功!')
           })
@@ -294,7 +307,7 @@ const onSwitch = (row) => {
       title: '停用确认',
       content: `${row.name}正在首页展示,停用将导致不可用,请确认是否停用`,
       onSubmit: () => {
-        appManageChangeState({ id: row.id, state: 0 })
+        modelManageChangeState({ id: row.id, state: 0 })
           .then(() => {
             ElMessage.success('停用成功!')
           })
@@ -306,7 +319,7 @@ const onSwitch = (row) => {
       onCancel: () => {},
     })
   } else {
-    appManageChangeState({ id: row.id, state: 1 })
+    modelManageChangeState({ id: row.id, state: 1 })
       .then(() => {
         ElMessage.success('启用成功!')
       })
@@ -321,7 +334,8 @@ onMounted(() => {
   onReset()
 })
 const initDictionary = () => {
-  DictionaryStore.initTenants()
+  DictionaryStore.initModelTypes()
+  DictionaryStore.initModelProvides()
 }
 </script>