add.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <div class="agent_page">
  3. <div class="top">
  4. <img src="@/assets/images/agent/arrow_left.png" @click="handleBack">
  5. <div class="spans">
  6. <span>知识库</span>
  7. <span class="last">&nbsp;/&nbsp;创建知识库</span>
  8. </div>
  9. </div>
  10. <div class="steps adfacjc">
  11. <div class="s_text adfac" :class="{'active':step<3}">
  12. <div class="st_num">1</div>
  13. <span>知识库信息</span>
  14. </div>
  15. <div class="s_line"></div>
  16. <div class="s_text adfac" :class="{'active':step===2}">
  17. <div class="st_num">2</div>
  18. <span>数据添加</span>
  19. </div>
  20. </div>
  21. <template v-if="step===1">
  22. <div class="content">
  23. <div class="c_title">创建知识库</div>
  24. <el-form ref="knowledgeFormRef" :model="knowledgeDto" :rules="knowledgeRule" label-width="100px" style="margin-top: 38px;">
  25. <el-form-item label="知识库名称" prop="aaa">
  26. <el-input v-model="knowledgeDto.aaa" clearable placeholder="请输入知识库名称" maxlength="20" show-word-limit></el-input>
  27. </el-form-item>
  28. <el-form-item label="知识库描述" prop="bbb">
  29. <el-input type="textarea" v-model="knowledgeDto.bbb" clearable placeholder="请输入知识库描述" maxlength="200" show-word-limit></el-input>
  30. </el-form-item>
  31. </el-form>
  32. </div>
  33. </template>
  34. <template v-else-if="step===2">
  35. <div class="content">
  36. <div class="c_title">选择数据</div>
  37. <div class="c_tip">导入数据,构建知识库索引</div>
  38. <div class="c_type adfac">
  39. <span>添加知识</span>
  40. <el-radio-group v-model="addType">
  41. <el-radio :label="1">选择文件</el-radio>
  42. <el-radio :label="2">上传文件</el-radio>
  43. </el-radio-group>
  44. </div>
  45. <template v-if="addType===1">
  46. <div class="c_xzwj">
  47. <span>请选择类目</span>
  48. <div class="cx_box adf">
  49. <div class="cxb_left">
  50. <span>类目</span>
  51. <div class="cl_list">
  52. <div class="cl_item" :class="{'active':cidx===index}" v-for="(item,index) in categoryList" :key="index" @click="handleSelectCategory(item,index)">{{ item.name }}</div>
  53. </div>
  54. </div>
  55. <div class="cxb_rigth">
  56. <el-table :data="fileList" border cell-class-name="vertical-top-cell" v-loading="loading" empty-text="暂无文件" max-height="600px">
  57. <el-table-column label="序号" width="50">
  58. <template #default="scope">
  59. {{ scope.$index + 1 }}
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="文件名称" prop="aaa"></el-table-column>
  63. <el-table-column label="状态" prop="bbb">
  64. <template #default="{ row }"></template>
  65. </el-table-column>
  66. <el-table-column label="数据来源" prop="aaa"></el-table-column>
  67. <el-table-column label="文件格式" prop="aaa"></el-table-column>
  68. </el-table>
  69. <el-row style="display: flex;justify-content: center;">
  70. <el-pagination
  71. @size-change="handleSizeChange"
  72. @current-change="handleCurrentChange"
  73. :current-page="queryParams.page"
  74. :page-sizes="[5, 10, 20, 50]"
  75. :page-size="10"
  76. layout="total, sizes, prev, pager, next, jumper"
  77. :total="total"
  78. v-show="total > 0">
  79. </el-pagination>
  80. </el-row>
  81. </div>
  82. </div>
  83. </div>
  84. </template>
  85. <template v-else-if="addType===2">
  86. <div class="c_scwj">
  87. <div class="cs_item adfac">
  88. <span>选择类目</span>
  89. <el-select v-model="knowledgeDto.category" placeholder="请选择" style="width: 480px;"></el-select>
  90. </div>
  91. <div class="cs_item adfac" style="margin-top: 37px;">
  92. <span>添加方式</span>
  93. <el-radio-group v-model="tjfsType">
  94. <el-radio :label="1">本地上传</el-radio>
  95. <el-radio :label="2">网址提交</el-radio>
  96. <el-radio :label="3">百度网盘</el-radio>
  97. <el-radio :label="4">自媒体平台</el-radio>
  98. </el-radio-group>
  99. </div>
  100. <div class="cs_upload">
  101. <el-upload
  102. class="upload-demo"
  103. drag
  104. action=""
  105. multiple>
  106. <i class="el-icon-upload"></i>
  107. <div class="el-upload__text">点击或拖拽文件上传</div>
  108. <div class="el-upload__text" style="font-size: 12px;color: #C1C7D2;line-height: 20px;margin-top: 8px;">
  109. 支持 .pdf,.doc,.docx,.txt,.md,.pptx,.ppt,.png,.jpg,.jpeg,.bmp,.gif,.xls,.xlsx,.html 等格式<br>
  110. 单文档最大限制100MB或1000页,单图片最大限制20MB
  111. </div>
  112. </el-upload>
  113. </div>
  114. </div>
  115. </template>
  116. </div>
  117. </template>
  118. <div class="btns adfac">
  119. <el-button type="primary" @click="handleNext" v-if="step===1">下一步</el-button>
  120. <el-button type="primary" @click="handlePrevious" v-if="step===2">上一步</el-button>
  121. <el-button type="default" @click="handleCancel">取消</el-button>
  122. </div>
  123. </div>
  124. </template>
  125. <script setup name="">
  126. import { ref, getCurrentInstance } from 'vue'
  127. const { proxy } = getCurrentInstance();
  128. const step = ref(1)
  129. const addType = ref(1)
  130. const tjfsType = ref(1)
  131. const categoryList = ref([
  132. {id:1,name:'高企的发展路径'},
  133. {id:2,name:'团队管理'},
  134. {id:3,name:'默认类目'}
  135. ])
  136. const knowledgeFormRef = ref(null)
  137. const knowledgeDto = ref({
  138. aaa: '',
  139. bbb: '',
  140. category:''
  141. })
  142. const knowledgeRule = ref({
  143. aaa: [
  144. { required: true, message: '请输入知识库名称', trigger: 'blur' }
  145. ],
  146. bbb: [
  147. { required: true, message: '请输入知识库描述', trigger: 'blur' }
  148. ]
  149. })
  150. const fileList = ref([])
  151. const cidx = ref('')
  152. const loading = ref(false)
  153. const queryParams = ref({
  154. page: 1,
  155. limit: 10
  156. })
  157. const total = ref(0)
  158. const handleSizeChange = (val) => {
  159. queryParams.value.limit = val;
  160. getList()
  161. }
  162. const handleCurrentChange = (val) => {
  163. queryParams.value.page = val;
  164. getList()
  165. }
  166. const getList = () => {
  167. let query = {...queryParams.value};
  168. loading.value = true;
  169. // const res = await listOrder(query);
  170. // userList.value = res.data.list;
  171. // total.value = res.data.total;
  172. loading.value = false;
  173. }
  174. const handleSelectCategory = (item,index) => {
  175. cidx.value = index;
  176. getList();
  177. }
  178. const handleBack = () => {
  179. proxy.$router.go(-1)
  180. }
  181. const handleNext = () => {
  182. proxy.$refs.knowledgeFormRef.validate((valid) => {
  183. if (valid) {
  184. step.value = 2
  185. } else {
  186. return false;
  187. }
  188. })
  189. }
  190. const handlePrevious = () => {
  191. step.value = 1
  192. }
  193. const handleCancel = () => {
  194. proxy.$router.go(-1)
  195. }
  196. </script>
  197. <style scoped lang="scss">
  198. .agent_page{
  199. position: relative;
  200. .top{
  201. width: 100%;
  202. height: 64px;
  203. background: #FFFFFF;
  204. border-bottom: 1px solid #F3F4F6;
  205. display: flex;
  206. align-items: center;
  207. img{
  208. width: 36px;
  209. height: 36px;
  210. margin-left: 16px;
  211. cursor: pointer;
  212. }
  213. .spans{
  214. display: flex;
  215. align-items: center;
  216. margin-left: 23px;
  217. span{
  218. font-family: PingFangSC, PingFang SC;
  219. font-weight: 400;
  220. font-size: 14px;
  221. color: #6B7280;
  222. line-height: 14px;
  223. &.last{
  224. color: #111111;
  225. }
  226. }
  227. }
  228. }
  229. .steps{
  230. margin-top: 24px;
  231. .s_text{
  232. .st_num{
  233. width: 24px;
  234. height: 24px;
  235. border-radius: 50%;
  236. background: #DDE0E6;
  237. font-family: PingFang-SC, PingFang-SC;
  238. font-weight: bold;
  239. font-size: 14px;
  240. color: #FFFFFF;
  241. line-height: 24px;
  242. text-align: center;
  243. }
  244. span{
  245. margin-left: 10px;
  246. font-family: PingFangSC, PingFang SC;
  247. font-weight: 400;
  248. font-size: 14px;
  249. color: #6B7280;
  250. line-height: 14px;
  251. }
  252. &.active{
  253. .st_num{
  254. background: #761E6A;
  255. }
  256. span{
  257. color: #761E6A;
  258. }
  259. }
  260. }
  261. .s_line{
  262. width: 496px;
  263. height: 1px;
  264. border: 1px solid #E5E7EB;
  265. margin: 0 21px;
  266. }
  267. }
  268. .content{
  269. width: 100%;
  270. height: calc(100% - 190px);
  271. padding: 20px 30px 0;
  272. box-sizing: border-box;
  273. overflow-y: auto;
  274. .c_title{
  275. font-family: PingFang-SC, PingFang-SC;
  276. font-weight: bold;
  277. font-size: 16px;
  278. color: #111111;
  279. line-height: 16px;
  280. }
  281. .c_tip{
  282. font-family: PingFangSC, PingFang SC;
  283. font-weight: 400;
  284. font-size: 14px;
  285. color: #9CA3AF;
  286. line-height: 14px;
  287. margin-top: 16px;
  288. }
  289. .c_type{
  290. margin-top: 32px;
  291. span{
  292. font-family: PingFang-SC, PingFang-SC;
  293. font-weight: bold;
  294. font-size: 14px;
  295. color: #111111;
  296. line-height: 14px;
  297. margin-right: 40px;
  298. }
  299. }
  300. .c_xzwj{
  301. width: 100%;
  302. height: calc(100% - 122px);
  303. padding: 16px 19px;
  304. box-sizing: border-box;
  305. margin-top: 28px;
  306. border-radius: 6px;
  307. border: 1px solid #ECEEF5;
  308. overflow-y: auto;
  309. &>span{
  310. font-family: PingFangSC, PingFang SC;
  311. font-weight: 400;
  312. font-size: 14px;
  313. color: #111111;
  314. line-height: 14px;
  315. }
  316. .cx_box{
  317. width: 100%;
  318. height: calc(100% - 30px);
  319. margin-top: 14px;
  320. .cxb_left{
  321. width: 257px;
  322. height: 100%;
  323. border-radius: 6px;
  324. border: 1px solid #ECEEF5;
  325. padding: 25px 22px;
  326. box-sizing: border-box;
  327. overflow-y: auto;
  328. &>span{
  329. font-family: PingFangSC, PingFang SC;
  330. font-weight: 400;
  331. font-size: 14px;
  332. color: #111111;
  333. line-height: 14px;
  334. }
  335. .cl_list{
  336. margin-top: 13px;
  337. .cl_item{
  338. width: 100%;
  339. height: 36px;
  340. border-radius: 8px;
  341. font-family: PingFangSC, PingFang SC;
  342. font-weight: 400;
  343. font-size: 14px;
  344. color: #111111;
  345. line-height: 36px;
  346. padding-left: 40px;
  347. box-sizing: border-box;
  348. cursor: pointer;
  349. &.active,&:hover{
  350. background: #ECEEF5;
  351. color: #761E6A;
  352. }
  353. }
  354. }
  355. }
  356. .cxb_rigth{
  357. width: calc(100% - 257px);
  358. height: 100%;
  359. overflow-y: auto;
  360. padding-left: 10px;
  361. box-sizing: border-box;
  362. }
  363. }
  364. }
  365. .c_scwj{
  366. margin-top: 22px;
  367. .cs_item{
  368. span{
  369. font-family: PingFang-SC, PingFang-SC;
  370. font-weight: bold;
  371. font-size: 14px;
  372. color: #252525;
  373. line-height: 14px;
  374. margin-right: 43px;
  375. }
  376. }
  377. .cs_upload{
  378. width: 640px;
  379. padding: 24px 0 0 98px;
  380. box-sizing: border-box;
  381. }
  382. }
  383. }
  384. .btns{
  385. width: 100%;
  386. padding: 24px 29px;
  387. box-sizing: border-box;
  388. position: absolute;
  389. left: 0;
  390. bottom: 0;
  391. }
  392. }
  393. ::v-deep .el-upload,::v-deep .el-upload-dragger{
  394. width: 100% !important;
  395. background: #FAFAFB !important;
  396. }
  397. </style>