Browse Source

检验方法

master_hella_20240701
zhaoyiran 6 months ago
parent
commit
54ff700b55
  1. 1
      src/api/qms/inspectionMethod/index.ts
  2. 12
      src/components/UploadFile/src/UploadFile.vue
  3. 57
      src/views/qms/inspectionMethod/index.vue
  4. 35
      src/views/qms/inspectionMethod/inspectionMethod.data.ts

1
src/api/qms/inspectionMethod/index.ts

@ -33,6 +33,7 @@ export const createInspectionMethod = async (data: InspectionMethodVO) => {
// 修改检验方法 // 修改检验方法
export const updateInspectionMethod = async (data: InspectionMethodVO) => { export const updateInspectionMethod = async (data: InspectionMethodVO) => {
// debugger
return await request.put({ url: `/qms/inspection-method/update`, data }) return await request.put({ url: `/qms/inspection-method/update`, data })
} }

12
src/components/UploadFile/src/UploadFile.vue

@ -137,6 +137,7 @@ const handleRemove = (file) => {
} }
const handlePreview: UploadProps['onPreview'] = (uploadFile) => { const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
console.log(uploadFile) console.log(uploadFile)
window.open(uploadFile.url)
} }
// //
const listToString = (list: UploadUserFile[], separator?: string) => { const listToString = (list: UploadUserFile[], separator?: string) => {
@ -147,6 +148,17 @@ const listToString = (list: UploadUserFile[], separator?: string) => {
} }
return strs != '' ? strs.substr(0, strs.length - 1) : '' return strs != '' ? strs.substr(0, strs.length - 1) : ''
} }
watch(
() => props.modelValue,
(data) => {
if (!data) return
fileList.value = data
},
{
deep: true,
immediate: true
}
)
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.upload-file-uploader { .upload-file-uploader {

57
src/views/qms/inspectionMethod/index.vue

@ -149,26 +149,65 @@ const buttonTableClick = async (val, row) => {
/** 添加/修改操作 */ /** 添加/修改操作 */
const basicFormRef = ref() const basicFormRef = ref()
const openForm = (type: string, row?: any) => { const openForm = (type: string, row?: any) => {
// debugger
console.log(row)
if(row && row.videoAddress.trim()){
row.filePathList = row.videoAddress.split(',')
}
if (row && row.filePathList && row.filePathList.length > 0) {
row.filePathListView = row.filePathList.map((item) => {
return {
name: item,
url: item
}
})
}
basicFormRef.value.open(type, row) basicFormRef.value.open(type, row)
} }
// form // form
const formsSuccess = async (formType,data) => { const formsSuccess = async (formType,data) => {
var isHave =InspectionMethod.allSchemas.formSchema.some(function (item) { // data.filePathList = []
return item.field === 'activeTime' || item.field === 'expireTime'; // data.tmp = []
}); data.filePathList = []
if(isHave){ for (let i = 0; i < data.filePathListView.length; i++) {
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ data.filePathList.push(data.filePathListView[i].url)
message.error('失效时间要大于生效时间')
return;
} }
if(data.filePathList.length>0){
data.videoAddress = data.filePathList.join(',')
} }
if(data.activeTime==0)data.activeTime = null; // debugger
if(data.expireTime==0)data.expireTime = null; // if(data.filePathListView instanceof Array){
// for(let i=0; i<data.filePathListView.length; i++){
// data.tmp.push(data.filePathListView[i].url)
// }
// data.videoAddress = data.tmp.join(',')
// }else{
// data.videoAddress = data.filePathListView
// data.filePathListView = data.filePathListView.split(',').map(url=>{return {url}})
// }
// for (let i = 0; i < data.filePathListView.length; i++) {
// data.filePathList.push(data.filePathListView[i])
// }
// console.log(1111,data)
// var isHave =InspectionMethod.allSchemas.formSchema.some(function (item) {
// return item.field === 'activeTime' || item.field === 'expireTime';
// });
// if(isHave){
// if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
// message.error('')
// return;
// }
// }
// if(data.activeTime==0)data.activeTime = null;
// if(data.expireTime==0)data.expireTime = null;
if (formType === 'create') { if (formType === 'create') {
await InspectionMethodApi.createInspectionMethod(data) await InspectionMethodApi.createInspectionMethod(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
// debugger
await InspectionMethodApi.updateInspectionMethod(data) await InspectionMethodApi.updateInspectionMethod(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }

35
src/views/qms/inspectionMethod/inspectionMethod.data.ts

@ -51,6 +51,39 @@ export const InspectionMethod = useCrudSchemas(reactive<CrudSchema[]>([
component: 'SelectV2' component: 'SelectV2'
}, },
}, },
{
label: '文件',
field: 'filePathListView',
sort: 'custom',
isTable: false,
table: {
},
form: {
component: 'UploadFile',
componentProps: {
upData:{
tableName:'basicInspectionMethod',
tableId:'',
// fileType:['doc', 'xls', 'ppt', 'txt']
}
}
}
},
{
label: '文件',
field: 'filePathList',
sort: 'custom',
isTable: false,
isForm: false,
table: {
},
form: {
component: 'UploadFile',
componentProps: {
}
}
},
{ {
label: '创建时间', label: '创建时间',
field: 'createTime', field: 'createTime',
@ -66,5 +99,5 @@ export const InspectionMethod = useCrudSchemas(reactive<CrudSchema[]>([
width: 150, width: 150,
fixed: 'right' fixed: 'right'
} }
} },
])) ]))

Loading…
Cancel
Save