陈薪名 1 year ago
parent
commit
89cb28f4c6
  1. 6
      src/components/Annex/src/Annex.vue
  2. 2
      src/components/Form/src/helper.ts
  3. 27
      src/components/ImportForm/src/ImportForm.vue
  4. 16
      src/components/UploadFile/src/UploadFile.vue
  5. 1
      src/types/components.d.ts
  6. 43
      src/utils/disposition/tableColumns.ts
  7. 2
      src/views/system/user/UserImportForm.vue
  8. 16
      src/views/wms/itembasic/ItembasicDetail.vue
  9. 39
      src/views/wms/itembasic/ItembasicForm.vue

6
src/components/Annex/src/Annex.vue

@ -3,10 +3,7 @@
<div class="annex">
<div class="title flex items-center">
<div class="title-txt">附件</div>
<el-button type="primary" @click="handleImport">
<Icon icon="ep:upload" />
添加附件
</el-button>
<UploadFile :isShowFile="false" :isShowTip="false" title="添加附件"/>
</div>
<div class="list">
<div class="item flex items-start" v-for="(item, index) in data.annexList" :key="index">
@ -28,6 +25,7 @@
</template>
<script lang="ts" setup>
import UploadFile from '@/components/UploadFile/src/UploadFile.vue'
const message = useMessage() //
const { t } = useI18n() //
defineComponent({

2
src/components/Form/src/helper.ts

@ -21,6 +21,8 @@ export const setTextPlaceholder = (schema: FormSchema): PlaceholderModel => {
}
if (selectMap.includes(schema?.component as string)) {
// 一些范围选择器
console.log('type=' +schema?.componentProps?.type);
const twoTextMap = ['datetimerange', 'daterange', 'monthrange', 'datetimerange', 'daterange']
if (
twoTextMap.includes(

27
src/components/ImportForm/src/ImportForm.vue

@ -1,7 +1,7 @@
<!-- 导入组件 -->
<template>
<Dialog v-model="dialogVisible" title="导入" width="600">
<el-upload ref="uploadRef" v-model:file-list="fileList" :action="importUrl + '?updateSupport=' + updateSupport"
<el-upload ref="uploadRef" v-model:file-list="fileList" :action="importUrl + '?mode=' + mode + '&file=' + file + '&updatePart=' + updatePart"
:auto-upload="false" :disabled="formLoading" :headers="uploadHeaders" :limit="1" :on-error="submitFormError"
:on-exceed="handleExceed" :on-success="submitFormSuccess" :accept="accept" drag
style="width:300px;margin:0 auto">
@ -13,7 +13,7 @@
<div class="label h-32px mr-26px color-#acaeb3 font-size-14px" style="line-height:32px">导入模式</div>
<div class="">
<div class="radio">
<el-radio-group v-model="updateSupport">
<el-radio-group v-model="mode">
<el-radio :label="1" :disabled="updateIsDisable">更新</el-radio>
<el-radio :label="2" :disabled="appendIsDisable">追加</el-radio>
<el-radio :label="3" :disabled="coverIsDisable">覆盖</el-radio>
@ -31,7 +31,7 @@
<div class="label h-32px mr-26px color-#acaeb3 font-size-14px" style="line-height:32px">部分保存</div>
<div class="">
<div class="switch">
<el-switch v-model="isSaveAll" />
<el-switch v-model="updatePart" />
</div>
<div class="tips color-#acaeb3 font-size-14px">
@ -62,6 +62,7 @@
// import * as UserApi from '@/api/system/user'
import { getAccessToken, getTenantId } from '@/utils/auth'
import download from '@/utils/download'
import { log } from 'console'
defineOptions({ name: 'ImportForm' })
@ -74,6 +75,7 @@ const importUrl =
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/system/user/import'
const uploadHeaders = ref() // Header
const fileList = ref([]) //
const file = ref('')
@ -89,7 +91,7 @@ const fileList = ref([]) // 文件列表
default:'.xlsx,.xls'
},
// .1
updateSupport: {
mode: {
type: Number,
required: false,
default: 1
@ -113,18 +115,19 @@ const fileList = ref([]) // 文件列表
default: false
},
// ,
isSaveAll: {
updatePart: {
type: Boolean,
required: false,
default: true
},
})
const { importTemplateData, accept } = toRefs(props)
const updateSupport = ref(props.updateSupport)//.1
const importTemplateData= ref(props.importTemplateData)
const accept= ref(props.accept)
const mode = ref(props.mode)//.1
const updateIsDisable = ref(props.updateIsDisable)//,
const appendIsDisable = ref(props.appendIsDisable)//,
const coverIsDisable = ref(props.coverIsDisable)//,
const isSaveAll = ref(props.isSaveAll)//
const updatePart = ref(props.updatePart)//
/** 打开弹窗 */
const open = () => {
@ -135,10 +138,12 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const submitForm = async () => {
if (fileList.value.length == 0) {
message.error('请上传文件')
return
}
file.value = fileList.value[0].name
//
uploadHeaders.value = {
Authorization: 'Bearer ' + getAccessToken(),
@ -171,8 +176,10 @@ const submitFormSuccess = (response: any) => {
text += '< ' + username + ': ' + data.failureUsernames[username] + ' >'
}
message.alert(text)
//
emits('success')
dialogVisible.value = false
}
/** 上传错误提示 */
@ -195,8 +202,8 @@ const handleExceed = (): void => {
/** 下载模板操作 */
const importTemplate = () => {
const res = importTemplateData.templateUrl
download.excel(res, importTemplateData.templateTitle)
const res = importTemplateData.value.templateUrl
download.excel(res, importTemplateData.value.templateTitle)
}
</script>

16
src/components/UploadFile/src/UploadFile.vue

@ -20,15 +20,19 @@
:on-preview="handlePreview"
class="upload-file-uploader"
>
<el-button type="primary"><Icon icon="ep:upload-filled" />选取文件</el-button>
<el-button type="primary"><Icon icon="ep:upload-filled" />{{ title }}</el-button>
<template v-if="isShowTip" #tip>
<div style="font-size: 8px">
<div style="font-size: 8px;margin-top: 10px;">
大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
</div>
<div style="font-size: 8px">
格式为 <b style="color: #f56c6c">{{ fileType.join('/') }}</b> 的文件
</div>
</template>
<template v-if="!isShowFile" #file >
<div>
</div>
</template>
</el-upload>
</div>
</template>
@ -56,13 +60,15 @@ const props = defineProps({
limit: propTypes.number.def(5), //
autoUpload: propTypes.bool.def(true), //
drag: propTypes.bool.def(false), //
isShowTip: propTypes.bool.def(true) //
isShowTip: propTypes.bool.def(true), //
isShowFile: propTypes.bool.def(true), //
})
// ========== ==========
const valueRef = ref(props.modelValue)
const uploadRef = ref<UploadInstance>()
const uploadList = ref<UploadUserFile[]>([])
const fileList = ref<UploadUserFile[]>(props.modelValue)
const fileList = props.modelValue && props.modelValue.length > 0 ? ref<UploadUserFile[]>(props.modelValue) : ref<UploadUserFile[]>([])
const uploadNumber = ref<number>(0)
const uploadHeaders = ref({
Authorization: 'Bearer ' + getAccessToken(),
@ -148,7 +154,7 @@ const listToString = (list: UploadUserFile[], separator?: string) => {
:deep(.upload-file-list .el-upload-list__item) {
position: relative;
margin-bottom: 10px;
// margin-bottom: 10px;
line-height: 2;
border: 1px solid #e4e7ed;
}

1
src/types/components.d.ts

@ -37,6 +37,7 @@ export type ColProps = {
export type ComponentOptions = {
label?: string
type?: string
value?: FormValueType
disabled?: boolean
key?: string | number

43
src/utils/disposition/tableColumns.ts

@ -42,10 +42,14 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
sort: 'custom',
dictType: DICT_TYPE.ITEM_STATUS,
dictClass: 'string',
isForm: true,
isSearch: true,
isTable: true,
table: {
width: 100
} ,
form: {
component: 'Select',
}
},
{
@ -82,6 +86,9 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true,
table: {
width: 120
},
form: {
component: 'Switch',
}
},
{
@ -94,6 +101,9 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true,
table: {
width: 100
},
form: {
component: 'Radio',
}
},
{
@ -106,6 +116,9 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true,
table: {
width: 100
} ,
form: {
component: 'Radio',
}
},
{
@ -118,6 +131,9 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true,
table: {
width: 120
} ,
form: {
component: 'Radio',
}
},
{
@ -130,6 +146,9 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true,
table: {
width: 100
},
form: {
component: 'Radio',
}
},
{
@ -142,6 +161,9 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true,
table: {
width: 100
} ,
form: {
component: 'Radio',
}
},
{
@ -242,7 +264,11 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
sort: 'custom',
table: {
width: 120
} },
},
form: {
component: 'InputNumber',
}
},
{
label: '是否可用',
field: 'available',
@ -253,6 +279,9 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true,
table: {
width: 120
},
form: {
component: 'Radio',
}
},
{
@ -266,6 +295,13 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
},
table: {
width: 120
} ,
form: {
component: 'TimePicker',
componentProps: {
type: 'datetimerange',
// disabled:true,
}
}
},
{
@ -279,6 +315,11 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
},
table: {
width: 120
} ,
form: {
component: 'TimePicker',
// valueFormat: 'YYYY-MM-DD HH:mm:ss',
// format: 'YYYY-MM-DD HH:mm:ss',
}
},
{

2
src/views/system/user/UserImportForm.vue

@ -127,6 +127,8 @@ const handleExceed = (): void => {
/** 下载模板操作 */
const importTemplate = async () => {
console.log(await UserApi.importUserTemplate());
const res = await UserApi.importUserTemplate()
download.excel(res, '用户导入模版.xls')
}

16
src/views/wms/itembasic/ItembasicDetail.vue

@ -109,22 +109,26 @@ const changeRecordData = reactive({
}]
})
const detailData = ref("")//
onMounted(async () => {
//
detailData.value = await getItembasic(query.id)
})
//
const importTemplateData = reactive({
templateUrl: UserApi.importUserTemplate(),
templateUrl: '',
templateTitle: '导入模版99.xls'
})
onMounted(async () => {
//
detailData.value = await getItembasic(query.id)
importTemplateData.templateUrl = await UserApi.importUserTemplate()
})
//
const importSuccess = () => {
}
/** 搜索按钮操作 */
const handleQuery = () => {
importFormRef.value.open()
}
/** 重置按钮操作 */
@ -163,9 +167,7 @@ const current = ref(0)
const { tableObject, tableMethods } = useTable({
getListApi: ItembasicApi.getItembasicPage //
})
console.log(tableObject);
const change = (item, index) => {
console.log(item);
current.value = index
}

39
src/views/wms/itembasic/ItembasicForm.vue

@ -1,17 +1,13 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<div class="p-20px m--10px" style="max-height: 500px;overflow-y: auto;">
<Form ref="formRef" v-loading="formLoading" :rules="ItemBasicRules" :schema="ItemBasic.allSchemas.formSchema" :is-col="true"/>
<Form ref="formRef" v-loading="formLoading" :rules="ItemBasicRules" :schema="ItemBasic.allSchemas.formSchema" :model="formData"
:is-col="true" />
</div>
</div>
<template #footer>
<!-- <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button> -->
<!-- 列表头部 -->
<TableHead
:HeadButttondata="Butttondata"
@buttonBaseClick="buttonBaseClick"
/>
<!-- 列表头部 -->
<TableHead :HeadButttondata="Butttondata" @buttonBaseClick="buttonBaseClick" />
</template>
</Dialog>
@ -21,6 +17,7 @@ import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
import * as ItembasicApi from '@/api/wms/itembasic'
import { ItemBasic, ItemBasicRules } from '@/utils/disposition/tableColumns.ts'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import { log } from 'console'
const { t } = useI18n() //
const message = useMessage() //
@ -28,6 +25,7 @@ const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formData = ref('')
const formType = ref('') // create - update -
const formRef = ref() // Ref
@ -38,14 +36,16 @@ const open = async (type: string, id?: number) => {
formType.value = type
resetForm()
//
// if (id) {
// formLoading.value = true
// try {
// formData.value = await ItembasicApi.getItembasic(id)
// } finally {
// formLoading.value = false
// }
// }
if (id) {
formLoading.value = true
try {
const data = await ItembasicApi.getItembasic(id)
formRef.value.setValues(data)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
@ -126,7 +126,4 @@ const buttonBaseClick = (val, item) => {
}
</script>
<style scoped>
</style>
<style scoped></style>

Loading…
Cancel
Save