陈薪名 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. 63
      src/utils/disposition/tableColumns.ts
  7. 2
      src/views/system/user/UserImportForm.vue
  8. 16
      src/views/wms/itembasic/ItembasicDetail.vue
  9. 43
      src/views/wms/itembasic/ItembasicForm.vue

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

@ -3,10 +3,7 @@
<div class="annex"> <div class="annex">
<div class="title flex items-center"> <div class="title flex items-center">
<div class="title-txt">附件</div> <div class="title-txt">附件</div>
<el-button type="primary" @click="handleImport"> <UploadFile :isShowFile="false" :isShowTip="false" title="添加附件"/>
<Icon icon="ep:upload" />
添加附件
</el-button>
</div> </div>
<div class="list"> <div class="list">
<div class="item flex items-start" v-for="(item, index) in data.annexList" :key="index"> <div class="item flex items-start" v-for="(item, index) in data.annexList" :key="index">
@ -28,6 +25,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import UploadFile from '@/components/UploadFile/src/UploadFile.vue'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
defineComponent({ 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)) { if (selectMap.includes(schema?.component as string)) {
// 一些范围选择器 // 一些范围选择器
console.log('type=' +schema?.componentProps?.type);
const twoTextMap = ['datetimerange', 'daterange', 'monthrange', 'datetimerange', 'daterange'] const twoTextMap = ['datetimerange', 'daterange', 'monthrange', 'datetimerange', 'daterange']
if ( if (
twoTextMap.includes( twoTextMap.includes(

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

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

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

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

1
src/types/components.d.ts

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

63
src/utils/disposition/tableColumns.ts

@ -42,11 +42,15 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
sort: 'custom', sort: 'custom',
dictType: DICT_TYPE.ITEM_STATUS, dictType: DICT_TYPE.ITEM_STATUS,
dictClass: 'string', dictClass: 'string',
isForm: true,
isSearch: true, isSearch: true,
isTable: true, isTable: true,
table: { table: {
width: 100 width: 100
} } ,
form: {
component: 'Select',
}
}, },
{ {
label: '计量单位', label: '计量单位',
@ -82,7 +86,10 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true, isTable: true,
table: { table: {
width: 120 width: 120
} },
form: {
component: 'Switch',
}
}, },
{ {
label: '可采购', label: '可采购',
@ -94,7 +101,10 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true, isTable: true,
table: { table: {
width: 100 width: 100
} },
form: {
component: 'Radio',
}
}, },
{ {
label: '可制造', label: '可制造',
@ -106,7 +116,10 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true, isTable: true,
table: { table: {
width: 100 width: 100
} } ,
form: {
component: 'Radio',
}
}, },
{ {
label: '可委外加工', label: '可委外加工',
@ -118,7 +131,10 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true, isTable: true,
table: { table: {
width: 120 width: 120
} } ,
form: {
component: 'Radio',
}
}, },
{ {
label: '回收件', label: '回收件',
@ -130,7 +146,10 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true, isTable: true,
table: { table: {
width: 100 width: 100
} },
form: {
component: 'Radio',
}
}, },
{ {
label: '虚零件', label: '虚零件',
@ -142,7 +161,10 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true, isTable: true,
table: { table: {
width: 100 width: 100
} } ,
form: {
component: 'Radio',
}
}, },
{ {
label: 'ABC类', label: 'ABC类',
@ -242,7 +264,11 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
sort: 'custom', sort: 'custom',
table: { table: {
width: 120 width: 120
} }, },
form: {
component: 'InputNumber',
}
},
{ {
label: '是否可用', label: '是否可用',
field: 'available', field: 'available',
@ -253,7 +279,10 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
isTable: true, isTable: true,
table: { table: {
width: 120 width: 120
} },
form: {
component: 'Radio',
}
}, },
{ {
label: '生效时间', label: '生效时间',
@ -266,7 +295,14 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
}, },
table: { table: {
width: 120 width: 120
} } ,
form: {
component: 'TimePicker',
componentProps: {
type: 'datetimerange',
// disabled:true,
}
}
}, },
{ {
label: '失效时间', label: '失效时间',
@ -279,7 +315,12 @@ export const ItemBasic = useCrudSchemas(reactive<CrudSchema[]>([
}, },
table: { table: {
width: 120 width: 120
} } ,
form: {
component: 'TimePicker',
// valueFormat: 'YYYY-MM-DD HH:mm:ss',
// format: 'YYYY-MM-DD HH:mm:ss',
}
}, },
{ {
label: '创建时间', label: '创建时间',

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

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

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

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

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

@ -1,19 +1,15 @@
<template> <template>
<Dialog :title="dialogTitle" v-model="dialogVisible"> <Dialog :title="dialogTitle" v-model="dialogVisible">
<div class="p-20px m--10px" style="max-height: 500px;overflow-y: auto;"> <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> <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> </template>
</Dialog> </Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -21,6 +17,7 @@ import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
import * as ItembasicApi from '@/api/wms/itembasic' import * as ItembasicApi from '@/api/wms/itembasic'
import { ItemBasic, ItemBasicRules } from '@/utils/disposition/tableColumns.ts' import { ItemBasic, ItemBasicRules } from '@/utils/disposition/tableColumns.ts'
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import { log } from 'console'
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -28,6 +25,7 @@ const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formData = ref('')
const formType = ref('') // create - update - const formType = ref('') // create - update -
const formRef = ref() // Ref const formRef = ref() // Ref
@ -38,14 +36,16 @@ const open = async (type: string, id?: number) => {
formType.value = type formType.value = type
resetForm() resetForm()
// //
// if (id) { if (id) {
// formLoading.value = true formLoading.value = true
// try { try {
// formData.value = await ItembasicApi.getItembasic(id) const data = await ItembasicApi.getItembasic(id)
// } finally { formRef.value.setValues(data)
// formLoading.value = false
// } } finally {
// } formLoading.value = false
}
}
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -126,7 +126,4 @@ const buttonBaseClick = (val, item) => {
} }
</script> </script>
<style scoped> <style scoped></style>
</style>

Loading…
Cancel
Save