From a4ca216c5b215f323b3c439b2f445dad72bbfce1 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期一, 26 八月 2024 16:44:31 +0800
Subject: [PATCH] fix: 修改bug

---
 src/views/dmx/knowledgeLib/edit.vue |  234 +++++++++++++++++++++++-----------------------------------
 1 files changed, 92 insertions(+), 142 deletions(-)

diff --git a/src/views/dmx/knowledgeLib/edit.vue b/src/views/dmx/knowledgeLib/edit.vue
index 56fe9f9..64957a6 100644
--- a/src/views/dmx/knowledgeLib/edit.vue
+++ b/src/views/dmx/knowledgeLib/edit.vue
@@ -1,159 +1,109 @@
-
 <template>
-  <a-button type="primary" @click="handleClick">
-    <template #icon>
-      <icon-plus />
-    </template>
-    鏂板缓鏂囦欢
-  </a-button>
-  <a-modal v-model:visible="visible" title="涓婁紶鏂囦欢" @before-open="handleOpened" @cancel="handleCancel" @before-ok="handleBeforeOk" title-align="start">
-    <a-form ref="formRef" :rules="rules" :model="form" @submit="handleSubmit" >
-      <a-form-item field="name" label="鐢ㄦ埛鍚�">
-
+  <a-tooltip content="閲嶅懡鍚�">
+    <a-button
+      type="text"
+      v-hasPermi="'/kb/rename'"
+      :disabled="props.item.run == '1'"
+      @click="handleClick"
+      size="small"
+    >
+      <template #icon>
+        <icon-edit />
+      </template>
+    </a-button>
+  </a-tooltip>
+  <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-form-item>
-      <a-form-item label="澶囨敞">
-        <a-textarea  v-model="form.txt" placeholder="璇疯緭鍏�" allow-clear/>
+      <a-form-item>
+        <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
+          >
+        </div>
       </a-form-item>
-<!--      <a-form-item>-->
-<!--        <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>-->
-<!--        </div>-->
-<!--      </a-form-item>-->
     </a-form>
   </a-modal>
 </template>
 
 <script lang="ts" setup>
-import { onMounted ,onBeforeMount, reactive, ref } from "vue";
+  import { onMounted, onBeforeMount, reactive, ref } from 'vue';
+  import { kbdocumentrename, kbdocumentrm } from '@/api/kbList';
+  import { Message } from '@arco-design/web-vue';
 
-const visible = ref(false);
-const loading = ref(false);
-const form = reactive({
-  name: '',// 鐢ㄦ埛鍚�
-  nameJoin: '',// 鏄电О
-  post: '',// 宀椾綅
-  txt: '',// 澶囨敞
-});
-const formRef = ref(null);
-
-const rules = {
-  name: [
-    {
-      required: true,
-      message:'鐢ㄦ埛鍚嶄笉鍏佽涓虹┖',
-    },
-  ],
-  nameJoin: [
-    {
-      required: true,
-      message:'鏄电О涓嶅厑璁镐负绌�',
-    },
-  ],
-  password: [
-    {
-      required: true,
-      message:'password is required',
-    },
-  ],
-  password2: [
-    {
-      required: true,
-      message:'password is required',
-    },
-    {
-      validator: (value, cb) => {
-        if (value !== form.password) {
-          cb('two passwords do not match')
-        } else {
-          cb()
-        }
-      }
-    }
-  ],
-  email: [
-    {
-      type: 'email',
-      required: true,
-    }
-  ],
-  ip: [
-    {
-      type: 'ip',
-      required: true,
-    }
-  ],
-  url: [
-    {
-      type: 'url',
-      required: true,
-    }
-  ],
-  match: [
-    {
-      required: true,
-      validator: (value, cb) => {
-        return new Promise((resolve) => {
-          if (!value) {
-            cb('Please enter match')
-          }
-          if (value !== 'match') {
-            cb('match must be match!')
-          }
-          resolve()
-        })
-      }
-    }
-  ],
-}
-
-
-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 loading = ref(false);
+  const form = reactive({
+    name: '', // 鐢ㄦ埛鍚�
   });
-  formRef.value.resetFields();
-}
+  const formRef = ref(null);
 
-onBeforeMount(()=>{
+  const rules = {
+    name: [
+      {
+        required: true,
+        message: '鍚嶇О涓嶅厑璁镐负绌�',
+      },
+    ],
+  };
 
-})
-onMounted(()=>{
+  const props = defineProps(['item']);
 
+  const emit = defineEmits(['upTabdateItem']);
 
-})
+  const handleSubmit = async ({ values, errors }) => {
+    if (errors) return;
+    let data = await kbdocumentrename({
+      doc_id: props.item.id,
+      name: form.name,
+    });
+    if (data.code == 0) {
+      Message.success('鎿嶄綔鎴愬姛');
+      visible.value = false;
+      emit('upTabdateItem', props.item.id, form.name);
+    }
+  };
+
+  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) => {
+    console.log(props.item, 'props.item');
+    Object.assign(form, props.item);
+    // formRef.value.resetFields();
+  };
+
+  onBeforeMount(() => {});
+  onMounted(() => {});
 </script>
 
 <script lang="ts">
-export default {
-  name: 'add',
-  methods: {
-
-  }
-};
-</script>
\ No newline at end of file
+  export default {
+    name: 'add',
+    methods: {},
+  };
+</script>

--
Gitblit v1.8.0