From 7b8ac484c22a2e5b726579b8e13fff5048de0dd5 Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期三, 07 八月 2024 15:00:17 +0800
Subject: [PATCH] 配置bug页面修改

---
 src/views/dmx/knowledgeLib/addDetails.vue |  193 ++++++++++++++++++++++++++++++-----------------
 1 files changed, 123 insertions(+), 70 deletions(-)

diff --git a/src/views/dmx/knowledgeLib/addDetails.vue b/src/views/dmx/knowledgeLib/addDetails.vue
index 07db2d2..9285d39 100644
--- a/src/views/dmx/knowledgeLib/addDetails.vue
+++ b/src/views/dmx/knowledgeLib/addDetails.vue
@@ -1,19 +1,66 @@
-
 <template>
   <a-button type="primary" @click="handleClick" style="margin-left: 10px">
     <template #icon>
       <icon-plus />
     </template>
   </a-button>
-  <a-modal v-model:visible="visible" title="鍒涘缓鐭ヨ瘑搴�" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start">
-    <a-form ref="formRef" :rules="rules" :model="form" @submit="handleSubmit" >
-      <a-form-item field="name" label="鍚嶇О">
-        <a-input v-model="form.name" placeholder="璇疯緭鍏ュ悕绉�"/>
+  <a-modal
+    v-model:visible="visible"
+    title="鍒涘缓瑙f瀽鍧�"
+    @before-open="handleOpened"
+    @cancel="handleCancel"
+    :footer="false"
+    title-align="start"
+  >
+    <a-form
+      ref="formRef"
+      :rules="rules"
+      :model="form"
+      @submit="handleSubmit"
+      layout="vertical"
+    >
+      <a-form-item field="content_with_weight" label="瑙f瀽鍧�">
+        <a-textarea
+          v-model="form.content_with_weight"
+          placeholder=""
+          style="height: 100px"
+          auto-size
+        />
       </a-form-item>
+      <a-form-item field="important_kwd_key" label="鍏抽敭璇� *">
+        <div style="width: auto">
+          <a-tag
+            v-for="(item, index) in form.important_kwd"
+            :key="index"
+            closable
+            bordered
+            @close="form.important_kwd.splice(index, 1)"
+            style="margin-right: 10px"
+          >
+            {{ item }}
+          </a-tag>
+
+          <a-input
+            ref="formInput"
+            v-show="keyVisible"
+            v-model="form.important_kwd_key"
+            placeholder=""
+            size="small"
+            style="width: 80px; margin-right: 16px"
+            @blur="inputChange"
+          />
+          <a-button type="dashed" shape="circle" size="small" @click="addKey">
+            <icon-plus />
+          </a-button>
+        </div>
+      </a-form-item>
+
       <a-form-item>
-        <div style="width: 100%;text-align: right">
+        <div style="width: 100%; text-align: right">
           <a-button @click="visible = false">鍙栨秷</a-button>
-          <a-button style="margin-left: 10px" type="primary" html-type="submit">纭畾</a-button>
+          <a-button style="margin-left: 10px" type="primary" html-type="submit"
+            >纭畾</a-button
+          >
         </div>
       </a-form-item>
     </a-form>
@@ -21,74 +68,80 @@
 </template>
 
 <script lang="ts" setup>
-import { onMounted ,onBeforeMount, reactive, ref } from "vue";
+  import { onMounted, onBeforeMount, reactive, ref } from 'vue';
+  import { achunkCreate } from '@/api/kbList';
 
-const visible = ref(false);
-const loading = ref(false);
-const form = reactive({
-  name: '',// 鐢ㄦ埛鍚�
-  nameJoin: '',// 鏄电О
-  post: '',// 宀椾綅
-  txt: '',// 澶囨敞
-});
-const formRef = ref(null);
+  const props = defineProps(['item']);
 
-const rules = {
-  name: [
-    {
-      required: true,
-      message:'鍚嶇О涓嶅厑璁镐负绌�',
-    },
-  ],
-}
-
-
-const handleSubmit = ({values, errors}) => {
-  console.log('values:', values, '\nerrors:', errors)
-}
-
-const handleClick = () => {
-  visible.value = true;
-};
-const handleBeforeOk = (done) => {
-    formRef.value.validate().then(res => {
-      console.log('form:', form)
-      if (!form.name) {
-        done(false)
-      }else {
-        console.log('璇锋眰鏁版嵁');
-
-      }
-    })
-};
-const handleCancel = () => {
-  visible.value = false;
-}
-
-const handleOpened =(el) => {
-  Object.assign(form,{
-    name: '',// 鐢ㄦ埛鍚�
-    nameJoin: '',// 鏄电О
-    post: '',// 宀椾綅
-    txt: '',// 澶囨敞
+  const visible = ref(false);
+  const keyVisible = ref(false);
+  const loading = ref(false);
+  const form = reactive({
+    content_with_weight: '',
+    important_kwd: [],
+    important_kwd_key: '',
   });
-  formRef.value.resetFields();
-}
+  const formRef = ref(null);
+  const formInput = ref(null);
+  const rules = {
+    content_with_weight: [
+      {
+        required: true,
+        message: '璇疯緭鍏ュ�硷紒',
+      },
+    ],
+  };
 
-onBeforeMount(()=>{
+  const handleSubmit = async ({ values, errors }) => {
+    console.log(props.item.id);
+    if (!errors) {
+      const res = await achunkCreate({
+        content_with_weight: values.content_with_weight,
+        important_kwd: values.important_kwd,
+        doc_id: props.item.id,
+      });
+    }
+  };
 
-})
-onMounted(()=>{
+  const handleClick = () => {
+    visible.value = true;
+  };
+  const handleBeforeOk = (done) => {
+    formRef.value.validate().then((res) => {
+      console.log('form:', form);
+    });
+  };
+  const handleCancel = () => {
+    visible.value = false;
+  };
 
+  const handleOpened = (el) => {
+    Object.assign(form, {
+      content_with_weight: '',
+      important_kwd: [],
+      important_kwd_key: '',
+    });
+    formRef.value.resetFields();
+    keyVisible.value = false;
+  };
 
-})
+  const addKey = () => {
+    form.important_kwd_key = '';
+    formInput.value.focus();
+    keyVisible.value = true;
+  };
+
+  const inputChange = (e) => {
+    if (
+      !form.important_kwd.includes(form.important_kwd_key) &&
+      form.important_kwd_key
+    ) {
+      form.important_kwd.push(form.important_kwd_key);
+    } else {
+    }
+    keyVisible.value = false;
+  };
+
+  onBeforeMount(() => {});
+  onMounted(() => {});
 </script>
-
-<script lang="ts">
-export default {
-  name: 'add',
-  methods: {
-
-  }
-};
-</script>
\ No newline at end of file

--
Gitblit v1.8.0