| | |
| | | |
| | | <template> |
| | | <a-button type="primary" @click="handleClick"> |
| | | <a-button type="text" @click="handleClick" size="small"> |
| | | <template #icon> |
| | | <icon-plus /> |
| | | <icon-edit /> |
| | | </template> |
| | | 新建文件 |
| | | </a-button> |
| | | <a-modal v-model:visible="visible" title="上传文件" @before-open="handleOpened" @cancel="handleCancel" @before-ok="handleBeforeOk" title-align="start"> |
| | | <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-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 { 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); |
| | | |
| | |
| | | name: [ |
| | | { |
| | | required: true, |
| | | message:'用户名不允许为空', |
| | | 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 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('请求数据'); |
| | | 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: '',// 备注 |
| | | }); |
| | | formRef.value.resetFields(); |
| | | console.log(props.item, 'props.item'); |
| | | Object.assign(form,props.item); |
| | | // formRef.value.resetFields(); |
| | | } |
| | | |
| | | onBeforeMount(()=>{ |