Browse Source

检验方法

master_hella_20240701
zhaoyiran 8 months ago
parent
commit
54ff700b55
  1. 1
      src/api/qms/inspectionMethod/index.ts
  2. 12
      src/components/UploadFile/src/UploadFile.vue
  3. 59
      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) => {
// debugger
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) => {
console.log(uploadFile)
window.open(uploadFile.url)
}
//
const listToString = (list: UploadUserFile[], separator?: string) => {
@ -147,6 +148,17 @@ const listToString = (list: UploadUserFile[], separator?: string) => {
}
return strs != '' ? strs.substr(0, strs.length - 1) : ''
}
watch(
() => props.modelValue,
(data) => {
if (!data) return
fileList.value = data
},
{
deep: true,
immediate: true
}
)
</script>
<style scoped lang="scss">
.upload-file-uploader {

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

@ -149,26 +149,65 @@ const buttonTableClick = async (val, row) => {
/** 添加/修改操作 */
const basicFormRef = ref()
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)
}
// form
const formsSuccess = async (formType,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;
}
// data.filePathList = []
// data.tmp = []
data.filePathList = []
for (let i = 0; i < data.filePathListView.length; i++) {
data.filePathList.push(data.filePathListView[i].url)
}
if(data.activeTime==0)data.activeTime = null;
if(data.expireTime==0)data.expireTime = null;
if(data.filePathList.length>0){
data.videoAddress = data.filePathList.join(',')
}
// debugger
// 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') {
await InspectionMethodApi.createInspectionMethod(data)
message.success(t('common.createSuccess'))
} else {
// debugger
await InspectionMethodApi.updateInspectionMethod(data)
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'
},
},
{
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: '创建时间',
field: 'createTime',
@ -66,5 +99,5 @@ export const InspectionMethod = useCrudSchemas(reactive<CrudSchema[]>([
width: 150,
fixed: 'right'
}
}
},
]))

Loading…
Cancel
Save