!355 修复一些 issues 提到的问题

Merge pull request !355 from puhui999/dev-crm
This commit is contained in:
芋道源码 2023-12-30 13:26:46 +00:00 committed by Gitee
commit 0338caeef6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 96 additions and 85 deletions

View File

@ -2,25 +2,27 @@
<div class="upload-file"> <div class="upload-file">
<el-upload <el-upload
ref="uploadRef" ref="uploadRef"
:multiple="props.limit > 1"
name="file"
v-model="valueRef"
v-model:file-list="fileList" v-model:file-list="fileList"
:show-file-list="true"
:auto-upload="autoUpload"
:action="updateUrl" :action="updateUrl"
:auto-upload="autoUpload"
:before-upload="beforeUpload"
:drag="drag"
:headers="uploadHeaders" :headers="uploadHeaders"
:limit="props.limit" :limit="props.limit"
:drag="drag" :multiple="props.limit > 1"
:before-upload="beforeUpload"
:on-exceed="handleExceed"
:on-success="handleFileSuccess"
:on-error="excelUploadError" :on-error="excelUploadError"
:on-remove="handleRemove" :on-exceed="handleExceed"
:on-preview="handlePreview" :on-preview="handlePreview"
:on-remove="handleRemove"
:on-success="handleFileSuccess"
:show-file-list="true"
class="upload-file-uploader" class="upload-file-uploader"
name="file"
> >
<el-button type="primary"><Icon icon="ep:upload-filled" />选取文件</el-button> <el-button type="primary">
<Icon icon="ep:upload-filled" />
选取文件
</el-button>
<template v-if="isShowTip" #tip> <template v-if="isShowTip" #tip>
<div style="font-size: 8px"> <div style="font-size: 8px">
大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
@ -35,8 +37,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { getAccessToken, getTenantId } from '@/utils/auth' import { getAccessToken, getTenantId } from '@/utils/auth'
import type { UploadInstance, UploadUserFile, UploadProps, UploadRawFile } from 'element-plus' import type { UploadInstance, UploadProps, UploadRawFile, UploadUserFile } from 'element-plus'
import { isArray, isString } from '@/utils/is' import { isString } from '@/utils/is'
defineOptions({ name: 'UploadFile' }) defineOptions({ name: 'UploadFile' })
@ -54,8 +56,8 @@ const props = defineProps({
drag: propTypes.bool.def(false), // drag: propTypes.bool.def(false), //
isShowTip: propTypes.bool.def(true) // isShowTip: propTypes.bool.def(true) //
}) })
// ========== ========== // ========== ==========
const valueRef = ref(props.modelValue)
const uploadRef = ref<UploadInstance>() const uploadRef = ref<UploadInstance>()
const uploadList = ref<UploadUserFile[]>([]) const uploadList = ref<UploadUserFile[]>([])
const fileList = ref<UploadUserFile[]>([]) const fileList = ref<UploadUserFile[]>([])
@ -64,6 +66,7 @@ const uploadHeaders = ref({
Authorization: 'Bearer ' + getAccessToken(), Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId() 'tenant-id': getTenantId()
}) })
// //
const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => { const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => {
if (fileList.value.length >= props.limit) { if (fileList.value.length >= props.limit) {
@ -97,12 +100,10 @@ const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => {
// //
const handleFileSuccess: UploadProps['onSuccess'] = (res: any): void => { const handleFileSuccess: UploadProps['onSuccess'] = (res: any): void => {
message.success('上传成功') message.success('上传成功')
const fileListNew = fileList.value fileList.value.shift()
fileListNew.pop()
fileList.value = fileListNew
uploadList.value.push({ name: res.data, url: res.data }) uploadList.value.push({ name: res.data, url: res.data })
if (uploadList.value.length == uploadNumber.value) { if (uploadList.value.length == uploadNumber.value) {
fileList.value = fileList.value.concat(uploadList.value) fileList.value.push(...uploadList.value)
uploadList.value = [] uploadList.value = []
uploadNumber.value = 0 uploadNumber.value = 0
emitUpdateModelValue() emitUpdateModelValue()
@ -131,29 +132,25 @@ const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
// //
watch( watch(
() => props.modelValue, () => props.modelValue,
() => { (val: string | string[]) => {
const files: string[] = [] if (!val) {
// 1 fileList.value = [] // fix
if (isString(props.modelValue)) { return
// 1.1
if (props.modelValue.includes(',')) {
files.concat(props.modelValue.split(','))
} else if (props.modelValue.length > 0) {
files.push(props.modelValue)
}
} else if (isArray(props.modelValue)) {
// 2
files.concat(props.modelValue)
} else if (props.modelValue == null) {
// 3undefined
} else {
throw new Error('不支持的 modelValue 类型')
} }
fileList.value = files.map((url: string) => {
return { url, name: url.substring(url.lastIndexOf('/') + 1) } as UploadUserFile fileList.value = [] //
}) // 1
if (isString(val)) {
fileList.value.push(
...val.split(',').map((url) => ({ name: url.substring(url.lastIndexOf('/') + 1), url }))
)
}
// 2
fileList.value.push(
...(val as string[]).map((url) => ({ name: url.substring(url.lastIndexOf('/') + 1), url }))
)
}, },
{ immediate: true } { immediate: true, deep: true }
) )
// //
const emitUpdateModelValue = () => { const emitUpdateModelValue = () => {
@ -166,7 +163,7 @@ const emitUpdateModelValue = () => {
emit('update:modelValue', result) emit('update:modelValue', result)
} }
</script> </script>
<style scoped lang="scss"> <style lang="scss" scoped>
.upload-file-uploader { .upload-file-uploader {
margin-bottom: 5px; margin-bottom: 5px;
} }

View File

@ -1,13 +1,13 @@
<template> <template>
<el-form <el-form
ref="formRef" ref="formRef"
v-loading="formLoading"
:model="formData" :model="formData"
:rules="formRules" :rules="formRules"
label-width="80px" label-width="80px"
v-loading="formLoading"
> >
<el-form-item label="请假类型" prop="type"> <el-form-item label="请假类型" prop="type">
<el-select v-model="formData.type" placeholder="请选择请假类型" clearable> <el-select v-model="formData.type" clearable placeholder="请选择请假类型">
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE)"
:key="dict.value" :key="dict.value"
@ -18,27 +18,27 @@
</el-form-item> </el-form-item>
<el-form-item label="开始时间" prop="startTime"> <el-form-item label="开始时间" prop="startTime">
<el-date-picker <el-date-picker
clearable
v-model="formData.startTime" v-model="formData.startTime"
clearable
placeholder="请选择开始时间"
type="datetime" type="datetime"
value-format="x" value-format="x"
placeholder="请选择开始时间"
/> />
</el-form-item> </el-form-item>
<el-form-item label="结束时间" prop="endTime"> <el-form-item label="结束时间" prop="endTime">
<el-date-picker <el-date-picker
clearable
v-model="formData.endTime" v-model="formData.endTime"
clearable
placeholder="请选择结束时间"
type="datetime" type="datetime"
value-format="x" value-format="x"
placeholder="请选择结束时间"
/> />
</el-form-item> </el-form-item>
<el-form-item label="原因" prop="reason"> <el-form-item label="原因" prop="reason">
<el-input v-model="formData.reason" type="textarea" placeholder="请输请假原因" /> <el-input v-model="formData.reason" placeholder="请输请假原因" type="textarea" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</template> </template>
@ -50,9 +50,6 @@ import { useTagsViewStore } from '@/store/modules/tagsView'
defineOptions({ name: 'BpmOALeaveCreate' }) defineOptions({ name: 'BpmOALeaveCreate' })
const message = useMessage() // const message = useMessage() //
const { delView } = useTagsViewStore() //
const { currentRoute } = useRouter() //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formData = ref({ const formData = ref({
type: undefined, type: undefined,
@ -67,7 +64,8 @@ const formRules = reactive({
endTime: [{ required: true, message: '请假结束时间不能为空', trigger: 'change' }] endTime: [{ required: true, message: '请假结束时间不能为空', trigger: 'change' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const { delView } = useTagsViewStore() //
const { push, currentRoute } = useRouter() //
/** 提交表单 */ /** 提交表单 */
const submitForm = async () => { const submitForm = async () => {
// //
@ -82,6 +80,7 @@ const submitForm = async () => {
message.success('发起成功') message.success('发起成功')
// Tab // Tab
delView(unref(currentRoute)) delView(unref(currentRoute))
await push({ name: 'BpmOALeave' })
} finally { } finally {
formLoading.value = false formLoading.value = false
} }

View File

@ -2,18 +2,18 @@
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form <el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef" ref="queryFormRef"
:inline="true" :inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px" label-width="68px"
> >
<el-form-item label="请假类型" prop="type"> <el-form-item label="请假类型" prop="type">
<el-select <el-select
v-model="queryParams.type" v-model="queryParams.type"
placeholder="请选择请假类型"
clearable
class="!w-240px" class="!w-240px"
clearable
placeholder="请选择请假类型"
> >
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE)"
@ -26,16 +26,16 @@
<el-form-item label="申请时间" prop="createTime"> <el-form-item label="申请时间" prop="createTime">
<el-date-picker <el-date-picker
v-model="queryParams.createTime" v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px" class="!w-240px"
end-placeholder="结束日期"
start-placeholder="开始日期"
type="daterange"
value-format="YYYY-MM-DD HH:mm:ss"
/> />
</el-form-item> </el-form-item>
<el-form-item label="结果" prop="result"> <el-form-item label="结果" prop="result">
<el-select v-model="queryParams.result" placeholder="请选择结果" clearable class="!w-240px"> <el-select v-model="queryParams.result" class="!w-240px" clearable placeholder="请选择结果">
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT)" v-for="dict in getIntDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT)"
:key="dict.value" :key="dict.value"
@ -47,17 +47,24 @@
<el-form-item label="原因" prop="reason"> <el-form-item label="原因" prop="reason">
<el-input <el-input
v-model="queryParams.reason" v-model="queryParams.reason"
placeholder="请输入原因"
clearable
@keyup.enter="handleQuery"
class="!w-240px" class="!w-240px"
clearable
placeholder="请输入原因"
@keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> <el-button @click="handleQuery">
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> <Icon class="mr-5px" icon="ep:search" />
<el-button type="primary" plain @click="handleCreate()"> 搜索
<Icon icon="ep:plus" class="mr-5px" /> 发起请假 </el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button plain type="primary" @click="handleCreate()">
<Icon class="mr-5px" icon="ep:plus" />
发起请假
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -66,63 +73,63 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="申请编号" align="center" prop="id" /> <el-table-column align="center" label="申请编号" prop="id" />
<el-table-column label="状态" align="center" prop="result"> <el-table-column align="center" label="状态" prop="result">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.result" /> <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.result" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="开始时间" :formatter="dateFormatter"
align="center" align="center"
label="开始时间"
prop="startTime" prop="startTime"
width="180" width="180"
:formatter="dateFormatter"
/> />
<el-table-column <el-table-column
label="结束时间" :formatter="dateFormatter"
align="center" align="center"
label="结束时间"
prop="endTime" prop="endTime"
width="180" width="180"
:formatter="dateFormatter"
/> />
<el-table-column label="请假类型" align="center" prop="type"> <el-table-column align="center" label="请假类型" prop="type">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.BPM_OA_LEAVE_TYPE" :value="scope.row.type" /> <dict-tag :type="DICT_TYPE.BPM_OA_LEAVE_TYPE" :value="scope.row.type" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="原因" align="center" prop="reason" /> <el-table-column align="center" label="原因" prop="reason" />
<el-table-column <el-table-column
label="申请时间" :formatter="dateFormatter"
align="center" align="center"
label="申请时间"
prop="createTime" prop="createTime"
width="180" width="180"
:formatter="dateFormatter"
/> />
<el-table-column label="操作" align="center" width="200"> <el-table-column align="center" label="操作" width="200">
<template #default="scope"> <template #default="scope">
<el-button <el-button
v-hasPermi="['bpm:oa-leave:query']"
link link
type="primary" type="primary"
@click="handleDetail(scope.row)" @click="handleDetail(scope.row)"
v-hasPermi="['bpm:oa-leave:query']"
> >
详情 详情
</el-button> </el-button>
<el-button <el-button
v-hasPermi="['bpm:oa-leave:query']"
link link
type="primary" type="primary"
@click="handleProcessDetail(scope.row)" @click="handleProcessDetail(scope.row)"
v-hasPermi="['bpm:oa-leave:query']"
> >
进度 进度
</el-button> </el-button>
<el-button <el-button
v-if="scope.row.result === 1"
v-hasPermi="['bpm:oa-leave:create']"
link link
type="danger" type="danger"
@click="cancelLeave(scope.row)" @click="cancelLeave(scope.row)"
v-hasPermi="['bpm:oa-leave:create']"
v-if="scope.row.result === 1"
> >
取消 取消
</el-button> </el-button>
@ -131,9 +138,9 @@
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
<Pagination <Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList" @pagination="getList"
/> />
</ContentWrap> </ContentWrap>
@ -228,6 +235,14 @@ const handleProcessDetail = (row) => {
}) })
} }
// fix:
watch(
() => router.currentRoute.value,
() => {
getList()
}
)
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getList() getList()