CzRger 2 mesi fa
parent
commit
d3f12c4d37

+ 9 - 5
src/views/manage/knowledge/documents/document/index.vue

@@ -75,7 +75,7 @@
           </template>
           <template #caozuo-column-value="{ scope }">
             <div class="__czr-table-operations">
-              <CzrButton type="table" title="重命名"/>
+              <CzrButton type="table" title="重命名" @click="onRename(scope.row)"/>
               <CzrButton type="table" title="迁移"/>
               <CzrButton type="table" title="归档"/>
               <CzrButton type="table-del"/>
@@ -84,6 +84,7 @@
         </CzrTable>
       </template>
     </CzrContent>
+    <renameCom v-model:show="state.rename.show" :transfer="state.rename.transfer" @refresh="onSearch"/>
   </div>
 </template>
 
@@ -93,6 +94,7 @@ import { Search } from '@element-plus/icons-vue'
 import {debounce} from "lodash";
 import {useDialogStore, useDictionaryStore} from "@/stores";
 import {ElMessage} from "element-plus";
+import renameCom from './rename.vue'
 
 const DialogStore = useDialogStore();
 const DictionaryStore = useDictionaryStore();
@@ -129,7 +131,7 @@ const state: any = reactive({
     },
     selected: []
   },
-  detail: {
+  rename: {
     show: false,
     transfer: {}
   },
@@ -225,9 +227,11 @@ const onDel = (row: any) => {
     }
   })
 }
-const onChangeTag = (row, tags) => {
-  row.tags = tags
-  // onSearch()
+const onRename = (row) => {
+  state.rename.transfer = {
+    row: JSON.parse(JSON.stringify(row))
+  }
+  state.rename.show = true
 }
 const initDictionary = () => {
   DictionaryStore.initKnowledgeGroups()

+ 83 - 0
src/views/manage/knowledge/documents/document/rename.vue

@@ -0,0 +1,83 @@
+<template>
+  <CzrDialog
+    :show="show"
+    title="重命名"
+    @onClose="$emit('update:show', false)"
+    @onSubmit="onSubmit"
+    width="33rem"
+    :loading="state.loading"
+  >
+    <div class="bm-form">
+      <CzrForm ref="ref_form" layout="y">
+        <CzrFormColumn
+          required
+          :span="24"
+          label="文件名称"
+          v-model:param="state.form.p1"
+        />
+      </CzrForm>
+    </div>
+  </CzrDialog>
+</template>
+
+<script setup lang="ts">
+import {computed, getCurrentInstance, nextTick, reactive, ref, watch} from "vue";
+import {ElMessage, ElMessageBox} from "element-plus";
+import {useDialogStore, useDictionaryStore} from "@/stores";
+import {useRouter} from "vue-router";
+
+const router = useRouter()
+const DictionaryStore = useDictionaryStore();
+const DialogStore = useDialogStore();
+const emit = defineEmits(['update:show', 'refresh'])
+const {proxy} = getCurrentInstance()
+const props = defineProps({
+  show: {default: false},
+  transfer: <any>{}
+})
+const state: any = reactive({
+  loading: false,
+  form: {}
+})
+const ref_form = ref()
+watch(() => props.show, (n) => {
+  if (n) {
+    initDictionary()
+    state.form = {}
+    if (props.transfer.mode !== 'add') {
+      initData()
+    }
+    nextTick(() => {
+      ref_form.value.reset()
+    })
+  }
+})
+const initDictionary = () => {
+}
+const initData = () => {
+  state.form = props.transfer.row
+}
+const onSubmit = (isImport) => {
+  ref_form.value.submit().then(() => {
+    DialogStore.confirm({
+      content: `请确认是否重命名文件?`,
+      onSubmit: () => {
+        state.loading = true
+        ElMessage.success(`重命名成功!`)
+        emit('update:show', false)
+        emit('refresh')
+        state.loading = false
+      }
+    })
+  }).catch((e) => {
+    ElMessage({
+      message: e[0].message,
+      grouping: true,
+      type: 'warning',
+    })
+  })
+}
+</script>
+
+<style lang="scss" scoped>
+</style>