CzRger 6 天之前
父節點
當前提交
d25d1f16d8

+ 3 - 0
src/components/czr-ui/CzrFormColumn.vue

@@ -66,6 +66,9 @@
             "
           >
             <slot />
+            <template #row="{ row }">
+              <slot name="row" :row="row" />
+            </template>
           </SelectCom>
         </template>
         <template v-else-if="link === 'date'">

+ 4 - 2
src/components/czr-ui/czr-form-link/select.vue

@@ -35,7 +35,9 @@
           :label="item[labelKey]"
           :value="item[valueKey]"
           :title="item[labelKey]"
-        />
+        >
+          <slot name="row" :row="item" />
+        </el-option>
       </slot>
     </el-select>
   </div>
@@ -56,7 +58,7 @@ const emit = defineEmits(['emitParam', 'getObject'])
 const props = defineProps({
   param: {},
   label: {},
-  options: { type: Array, default: () => [] },
+  options: <any>{ type: Array, default: () => [] },
   labelKey: { type: String, default: 'label' },
   valueKey: { type: String, default: 'value' },
   static: { default: false },

+ 99 - 9
src/views/manage/app/make/index.vue

@@ -168,15 +168,15 @@
                     required
                     label-width="0px"
                     :span="24"
-                    v-model:param="state.form.model"
+                    v-model:param="state.form.prologue"
                     link="rich"
                     :height="300"
                   />
                 </div>
                 <div class="__czr-title_2 mt-4">
                   开场白引导问题
-                  <template v-if="state.form.prologues.length > 0">
-                    ({{ state.form.prologues.length }})
+                  <template v-if="state.form.prologueQuestions.length > 0">
+                    ({{ state.form.prologueQuestions.length }})
                   </template>
                   <div class="ml-auto">
                     <el-radio-group
@@ -194,7 +194,9 @@
                     ref="ref_prologueBody"
                     v-if="state.dragRefresh"
                   >
-                    <template v-for="(item, index) in state.form.prologues">
+                    <template
+                      v-for="(item, index) in state.form.prologueQuestions"
+                    >
                       <div
                         class="flex items-center gap-2"
                         style="-webkit-user-drag: element"
@@ -229,7 +231,7 @@
                           class="__hover"
                           name="czr_del"
                           color="var(--czr-error-color)"
-                          @click="state.form.prologues.splice(index, 1)"
+                          @click="state.form.prologueQuestions.splice(index, 1)"
                         />
                       </div>
                     </template>
@@ -259,6 +261,90 @@
                   </div>
                 </div>
                 <div class="__czr-title_2 mt-4">用户输入方式</div>
+                <div class="mt-4">
+                  <CzrFormColumn
+                    class="__czr-table-form-column"
+                    required
+                    label="输入方式"
+                    :span="24"
+                    v-model:param="state.form.method"
+                    link="select"
+                    :options="[
+                      { value: 1, label: '文字/语音输入' },
+                      { value: 2, label: '语音通话' },
+                    ]"
+                    :clearable="false"
+                  />
+                  <div
+                    class="mt-4 flex items-center"
+                    v-if="state.form.method == 2"
+                  >
+                    <div class="flex-1">
+                      <CzrFormColumn
+                        class="__czr-table-form-column"
+                        required
+                        label="语音包"
+                        :span="24"
+                        v-model:param="state.form.voicePackage"
+                        link="select"
+                        :options="[
+                          { value: 1, label: '语音包1' },
+                          { value: 2, label: '语音包2' },
+                        ]"
+                        :clearable="false"
+                      >
+                        <template #row="{ row }">
+                          <div class="flex h-full items-center">
+                            {{ row.label }}
+                            <div
+                              class="__hover ml-auto text-[var(--czr-main-color)]"
+                              @click.stop=""
+                            >
+                              试听
+                            </div>
+                          </div>
+                        </template>
+                      </CzrFormColumn>
+                    </div>
+                    <div
+                      class="__hover ml-4 text-sm text-[var(--czr-main-color)]"
+                    >
+                      试听
+                    </div>
+                  </div>
+                </div>
+                <div class="__czr-title_2 mt-4">
+                  问题建议
+                  <div class="ml-auto">
+                    <el-checkbox-group
+                      v-model="state.form.adviseType"
+                      size="small"
+                    >
+                      <el-checkbox-button value="open">
+                        开启
+                      </el-checkbox-button>
+                      <template v-if="state.form.adviseType.includes('open')">
+                        <el-checkbox-button value="cus">
+                          自定义提示词
+                        </el-checkbox-button>
+                        <el-checkbox-button value="knowledge">
+                          仅从知识库建议
+                        </el-checkbox-button>
+                      </template>
+                    </el-checkbox-group>
+                  </div>
+                </div>
+                <div class="mt-4">
+                  <CzrFormColumn
+                    class="__czr-table-form-column"
+                    required
+                    label="模型选择"
+                    :span="24"
+                    v-model:param="state.form.adviseModel"
+                    link="select"
+                    :options="[]"
+                  />
+                </div>
               </div>
             </div>
           </CzrForm>
@@ -309,7 +395,8 @@ const state: any = reactive({
     model: '',
     components: [],
     knowledges: [],
-    prologues: [
+    prologue: '',
+    prologueQuestions: [
       { value: '1' },
       { value: '2' },
       { value: '3' },
@@ -317,6 +404,9 @@ const state: any = reactive({
       { value: '5' },
     ],
     prologueType: 'three',
+    method: 1,
+    voicePackage: '',
+    adviseType: [],
   },
   knowledgeSelect: {
     show: false,
@@ -351,11 +441,11 @@ const initDrag = () => {
       animation: 150,
       handle: '.drag-icon', // 设置可拖拽行的类名(el-table自带的类名)
       onEnd: ({ newIndex, oldIndex }: any) => {
-        const d = [...state.form.prologues]
+        const d = [...state.form.prologueQuestions]
         const targetRow = d[oldIndex]
         d.splice(oldIndex, 1)
         d.splice(newIndex, 0, targetRow)
-        state.form.prologues = [...d]
+        state.form.prologueQuestions = [...d]
         state.dragRefresh = false
         setTimeout(() => {
           state.dragRefresh = true
@@ -397,7 +487,7 @@ const onPrologue = (row) => {
   }, 100)
 }
 const onAddPrologue = () => {
-  state.form.prologues.push({ value: state.prologuesAdd.value + '' })
+  state.form.prologueQuestions.push({ value: state.prologuesAdd.value + '' })
   state.prologuesAdd.value = ''
 }
 const onEditPrologue = (row) => {

+ 6 - 7
src/views/manage/app/make/knowledge-select.vue

@@ -7,13 +7,12 @@
     width="62.5rem"
     height="auto"
   >
-    <div class="max-h-140" v-if="show">
-      <knowledgeCard
-        ref="ref_knowledgeCard"
-        :multiple="true"
-        :ids="transfer.ids"
-      />
-    </div>
+    <knowledgeCard
+      v-if="show"
+      ref="ref_knowledgeCard"
+      :multiple="true"
+      :ids="transfer.ids"
+    />
   </CzrDialog>
 </template>
 

+ 130 - 57
src/views/manage/knowledge/documents/document/knowledge-card.vue

@@ -1,56 +1,73 @@
 <template>
   <div
-    class="grid grid-cols-2 gap-4 rounded-lg bg-[var(--czr-dialog-bg)] p-4"
-    v-loading="state.loading"
+    class="flex flex-col rounded-lg bg-[var(--czr-dialog-bg)] p-4"
+    v-loading="state.query.loading"
   >
-    <template v-for="item in state.list">
-      <div
-        class="__hover relative col-span-1 flex flex-col overflow-hidden rounded-lg border-1 border-[#E6E8EA] px-6 py-4"
-        :class="{
-          active: state.selectedMap.has(item.id),
-          'border-[var(--czr-main-color)]': state.selectedMap.has(item.id),
-        }"
-        @click="onSelect(item)"
-      >
-        <div class="flex">
-          <img
-            src="@/assets/images/knowledge/knowledge-item-icon-2.png"
-            class="mr-2.5 h-11 w-11"
-          />
-          <div class="flex flex-1 flex-col justify-around overflow-hidden">
-            <div class="flex items-center">
+    <div>
+      {{ ids }}
+      {{ Array.from(state.selectedMap.keys()) }}
+      <CzrFormColumn
+        class="__czr-table-form-column"
+        label-width="0px"
+        :span="8"
+        :offset="16"
+        v-model:param="state.text"
+        placeholder="按名称搜索"
+        :prefix-icon="Search"
+      />
+    </div>
+    <div
+      class="mt-2 grid max-h-[600px] flex-1 grid-cols-2 gap-4 overflow-y-auto"
+    >
+      <template v-for="item in state.query.result.data">
+        <div
+          class="__hover relative col-span-1 flex flex-col overflow-hidden rounded-lg border-1 border-[#E6E8EA] px-6 py-4"
+          :class="{
+            active: state.selectedMap.has(item.id),
+            'border-[var(--czr-main-color)]': state.selectedMap.has(item.id),
+          }"
+          @click="onSelect(item)"
+        >
+          <div class="flex">
+            <img
+              src="@/assets/images/knowledge/knowledge-item-icon-2.png"
+              class="mr-2.5 h-11 w-11"
+            />
+            <div class="flex flex-1 flex-col justify-around overflow-hidden">
+              <div class="flex items-center">
+                <div
+                  class="flex-1 text-[1.25rem] font-bold text-[#2E3238]"
+                  v-title
+                >
+                  {{ item.name }}
+                </div>
+              </div>
               <div
-                class="flex-1 text-[1.25rem] font-bold text-[#2E3238]"
-                v-title
+                class="flex items-center gap-2.5 text-[0.75rem] text-[#6F7889]"
               >
-                {{ item.name }}
+                <div>文档数:{{ item.docCount }}</div>
+                <div>|</div>
+                <div>字符:{{ item.wordCounts }}</div>
+                <div>|</div>
+                <div>创建者:{{ item.userName }}</div>
               </div>
             </div>
-            <div
-              class="flex items-center gap-2.5 text-[0.75rem] text-[#6F7889]"
-            >
-              <div>文档数:{{ item.docCount }}</div>
-              <div>|</div>
-              <div>字符:{{ item.wordCounts }}</div>
-              <div>|</div>
-              <div>创建者:{{ item.userName }}</div>
-            </div>
           </div>
-        </div>
-        <div
-          class="mt-2.5 mb-auto text-sm text-[#606266]"
-          style="line-height: 1.4rem"
-          v-title="{ lines: 2 }"
-        >
-          {{ item.description }}
-        </div>
-        <template v-if="state.selectedMap.has(item.id)">
           <div
-            class="absolute top-0 right-0 h-[2rem] w-[2rem] bg-[url('@/assets/images/knowledge/checked.png')]"
-          ></div>
-        </template>
-      </div>
-    </template>
+            class="mt-2.5 mb-auto text-sm text-[#606266]"
+            style="line-height: 1.4rem"
+            v-title="{ lines: 2 }"
+          >
+            {{ item.description }}
+          </div>
+          <template v-if="state.selectedMap.has(item.id)">
+            <div
+              class="absolute top-0 right-0 h-[2rem] w-[2rem] bg-[url('@/assets/images/knowledge/checked.png')]"
+            ></div>
+          </template>
+        </div>
+      </template>
+    </div>
   </div>
 </template>
 
@@ -67,6 +84,9 @@ import {
 import { useAppStore, useDialogStore, useDictionaryStore } from '@/stores'
 import { useRouter } from 'vue-router'
 import { datasetsGetAllByPage } from '@/api/modules/knowledge'
+import CzrFormColumn from '@/components/czr-ui/CzrFormColumn.vue'
+import { Search } from '@element-plus/icons-vue'
+import { debounce } from 'lodash'
 
 const router = useRouter()
 const DictionaryStore = useDictionaryStore()
@@ -79,28 +99,81 @@ const props = defineProps({
   ids: { default: () => <any>[] },
 })
 const state: any = reactive({
-  loading: false,
-  list: [],
   selectedMap: new Map(),
+  text: '',
+  query: {
+    init: false,
+    loading: false,
+    page: {
+      pageNum: 1,
+      pageSize: 20,
+    },
+    form: {},
+    formReal: {},
+    result: {
+      total: 0,
+      data: [],
+    },
+  },
 })
-const initDictionary = () => {
-  state.loading = true
-  datasetsGetAllByPage({
+const setText = debounce((v) => {
+  state.query.form.name = v
+}, 1000)
+watch(
+  () => state.text,
+  (n) => {
+    setText(n)
+  },
+)
+watch(
+  () => state.query.form,
+  (n) => {
+    if (state.query.init) {
+      onSearch()
+    }
+  },
+  { deep: true },
+)
+const onSearch = () => {
+  state.query.formReal = JSON.parse(JSON.stringify(state.query.form))
+  onPage(1, 100000)
+}
+const onPage = (pageNum, pageSize) => {
+  setTimeout(() => {
+    state.query.init = true
+  }, 100)
+  state.query.page = {
+    pageNum: pageNum,
+    pageSize: pageSize,
+  }
+  const params = {
     tenantId: AppStore.tenantInfo?.id,
-    page: 1,
-    size: 100000,
-  })
+    page: state.query.page.pageNum,
+    size: state.query.page.pageSize,
+  }
+  //  添加表单参数
+  for (const [k, v] of Object.entries(state.query.formReal)) {
+    if (proxy.$czrUtil.isValue(v)) {
+      params[k] = v
+    }
+  }
+  state.query.loading = true
+  datasetsGetAllByPage(params)
     .then(({ data }: any) => {
-      state.list = data.content
-      state.list.forEach((v: any) => {
+      state.query.result.total = data.totalElements
+      state.query.result.data = data.content
+      state.query.result.data.forEach((v) => {
         if (props.ids.includes(v.id)) {
-          onSelect(v)
+          if (!props.multiple) {
+            state.selectedMap.clear()
+          }
+          state.selectedMap.set(v.id, v)
         }
       })
     })
     .catch(() => {})
     .finally(() => {
-      state.loading = false
+      state.query.loading = false
     })
 }
 const onSelect = (row) => {
@@ -117,7 +190,7 @@ const getData = () => {
   return Array.from(state.selectedMap.values())
 }
 onMounted(() => {
-  initDictionary()
+  onSearch()
 })
 defineExpose({
   getData,

+ 1 - 3
src/views/manage/knowledge/documents/document/move-select.vue

@@ -8,9 +8,7 @@
     height="auto"
     :loading="state.loading"
   >
-    <div class="max-h-140">
-      <knowledgeCard ref="ref_knowledgeCard" />
-    </div>
+    <knowledgeCard ref="ref_knowledgeCard" />
   </CzrDialog>
 </template>