Browse Source

feat:[模板管理][update]

lkf
luojie 2 months ago
parent
commit
516db3f78f
6 changed files with 82 additions and 45 deletions
  1. +2
    -2
      src/components/Template/BaseInfoFormPackage.vue
  2. +2
    -1
      src/components/Template/CustomTable.vue
  3. +68
    -12
      src/components/Template/HandleFormItem.vue
  4. +4
    -9
      src/components/Template/mixins/formPackageMixins.js
  5. +5
    -20
      src/views/business/comps/template/comps/sp/SP007.vue
  6. +1
    -1
      src/views/business/comps/template/formConfig/sp/SP007.js

+ 2
- 2
src/components/Template/BaseInfoFormPackage.vue View File

@ -60,8 +60,8 @@
<div class="p-r-20">
<div class="form-title">{{ $t( sItem.label) }}</div>
<div class="flex flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+key" type="attachment" :item="sItem" v-model="formFields[key]"
@copy="onCopy(sItem, key)" @change="(e,type)=>onSelectChange(key, e,type)"
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+key" type="attachment" :item="sItem" :value="formFields[key]"
@copy="onCopy(sItem, key)" @change="(e)=>onAttachmentChange(key, e)"
:error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" />
</div>

+ 2
- 1
src/components/Template/CustomTable.vue View File

@ -308,6 +308,7 @@ export default {
if (this.templateFillType !== 'actFill') {
return
}
this.updateDataSourceByRowIndex(rowIndex,{[col.prop]:data.selectedId})
this.$emit("onRegentSubmit", {selectInfo:data,key:col.prop, col, rowIndex, colIndex, rowData:row})
},
isShowAddRos() {
@ -630,7 +631,7 @@ export default {
this.checkCompareToOnDataLoad();
},
// autoUpdateRecord
updateDataSourceByRowIndex(rowIndex, data, type) {
updateDataSourceByRowIndex(rowIndex, data) {
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource));
// if (type === "clickable") {//customclickable
// this.showEditSignDialog(rowIndex,data);

+ 68
- 12
src/components/Template/HandleFormItem.vue View File

@ -55,9 +55,10 @@
<el-upload class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview"
:headers="headers"
:on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="10"
:on-success="handleSuccess"
:on-exceed="handleExceed" :file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
<div slot="tip" class="el-upload__tip">支持扩展名.rar .zip .doc .docx .pdf .jpg</div>
</el-upload>
</template>
@ -213,12 +214,6 @@ export default {
watch: {
value(newVal) {
this.inputValue = newVal;
// typeclickable
// if (this.item.type === 'clickable') {
// this.$nextTick(() => {
// this.onCommonHandleSaveRecord(newVal);
// });
// }
}
},
filters: {
@ -226,6 +221,13 @@ export default {
},
mounted() {
if(this.item.type === 'attachment'){
try{
this.fileList = JSON.parse(this.value);
}catch(e){
this.fileList = [];
}
}
EventBus.$on('onExternalFieldUpdate', this.handleExternalFieldUpdate);
EventBus.$on('onEditSignCancel', this.handleEditSignCancel);
EventBus.$on('onEditSignCallback', this.handleEditSignCallback);
@ -245,11 +247,65 @@ export default {
EventBus.$off("onMixReagentSubmit", this.onMixReagentSubmit)
},
methods: {
handleSuccess(res, file, fileList) {
if(res.code == 200){
this.fileList = fileList;
// inputValue便
this.inputValue = JSON.stringify(this.getFileList(fileList));
this.$emit("change",this.inputValue)
this.onCommonHandleSaveRecord();
this.$message.success('文件上传成功');
} else {
this.$message.error(res.message || '文件上传失败');
}
},
getFileList(fileList) {
const list = [];
fileList.forEach(item => {
const o = {name:item.name};
if(item.url){//
o.url = item.url
}else{//
o.url = item.response.data.url
}
list.push(o)
})
return list;
},
handleRemove(file, fileList) {
console.log(file, fileList);
//
const index = fileList.indexOf(file);
if (index > -1) {
fileList.splice(index, 1);
}
// inputValue
this.inputValue = JSON.stringify(this.getFileList(fileList));
this.$emit("change",this.inputValue)
//
this.onCommonHandleSaveRecord();
this.$message.info(`文件 ${file.name} 已移除`);
},
handlePreview(file) {
console.log(file);
//
if (file.url) {
const fileType = file.type || file.name.split('.').pop().toLowerCase();
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp'];
if (imageTypes.includes(fileType)) {
//
window.open(process.env.VUE_APP_FILE_DOMAIN + file.url, '_blank');
} else {
//
const link = document.createElement('a');
link.href = file.url;
link.download = file.name;
link.target = '_blank';
link.click();
}
}
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
@ -262,7 +318,7 @@ export default {
if (data.uuid !== this.uuid) return;
this.inputValue = data.selectedId;
this.selectRegentInfo = data;
this.onCommonHandleSaveRecord();
this.onCommonHandleSaveRecord(this.inputValue);
// this.inputValue = this.item.label;
},
///
@ -566,12 +622,12 @@ export default {
if (this.templateFillType === "actFill") {//
this.updateZdxgjl(record);
}
setTimeout(() => {
this.$nextTick(()=>{
EventBus.$emit('onModifyRecord', params,)
if (this.regentType.includes(this.item.type)) {
this.$emit("onRegentSubmit", this.selectRegentInfo);
}
}, 10);
})
},
//

+ 4
- 9
src/components/Template/mixins/formPackageMixins.js View File

@ -48,6 +48,7 @@ export default {
methods: {
//试剂/仪器等弹窗提交
onRegentSubmit(data,key,item){
this.updateFormData(key,data.selectedId);
this.$emit("onRegentSubmit", {selectInfo:data,key,config:item});
},
getRegentItem(item,fieldCode="type"){
@ -218,6 +219,7 @@ export default {
selectInfoKeys.forEach(key => {
result[key] = formData[key];
})
console.log(result,"result")
// 更新表单字段
this.formFields = result;
this.allFieldsConfig = config;
@ -255,7 +257,7 @@ export default {
const errors = [];
// 清空之前的错误状态
this.errors = {};
console.log(allFieldsConfig,"allFieldsConfig")
console.log(allFieldsConfig,formFields,"allFieldsConfig")
for (const key in allFieldsConfig) {
const o = allFieldsConfig[key];
if (o.otherCode) {//
@ -366,15 +368,8 @@ export default {
this.compareFieldsIsEqual(val, compareToValue, key);
}
},
onSelectChange(key, val, type) {
// 获取对应的配置
const currentConfig = this.allFieldsConfig[key];
if (currentConfig.selectTo) {
this.formFields[currentConfig.selectTo] = val;
}
this.onValueChangeCompareTo(key, val);
onAttachmentChange(key, val) {
this.formFields[key] = val;
this.$emit("select", { key, value: val, type });
// 清除该表单项的错误状态
if (this.errors[key]) {
this.$set(this.errors, key, false);

+ 5
- 20
src/views/business/comps/template/comps/sp/SP007.vue View File

@ -26,7 +26,7 @@
</div>
</div>
</div>
<!-- <button @click="onSave">保存</button> -->
<button @click="onSave">保存</button>
</div>
</template>
@ -82,11 +82,6 @@ export default {
};
},
mounted() {
const formData = this.getFormDataByTemplateData();
if(!formData.targetCodeSn&& this.fillType === "actFill"){
this.getCode(formData);
}
},
methods: {
//
@ -98,24 +93,14 @@ export default {
EventBus.$emit('showTagPrintDialog', { printConfig })
},
//
getCode: debounce(async function (v) {
const result = await getLatestSn({
count: 1,
pre:v.targetCode,
type:1
})
if (result.code == 200) {
this.$refs.stepFormPackageRef.updateFormData("targetCodeSn", result.data[0])
}
}, 100),
//
getFilledFormData() {
return this.getFilledFormDataByRefs(["baseInfoRef", "storageConditionRef", "stepFormPackageRef", "stepRef", "remarkRef"])
return this.getFilledFormDataByRefs(["baseInfoRef", "storageConditionRef", "ybRef","stepRef", "remarkRef","fjRef"])
},
//
async getFormData() {
let content = await this.validFormFields(["baseInfoRef", "storageConditionRef", "stepFormPackageRef", "stepRef", "remarkRef"]);
let content = await this.validFormFields(["baseInfoRef", "storageConditionRef", "ybRef","stepRef", "remarkRef","fjRef"]);
//resource
let tmpResource = []
if (this.fillType === "actFill") {
@ -147,7 +132,7 @@ export default {
},
//
async onSave() {
let content =await this.$refs.stepRef.getFormData();
let content =await this.$refs.fjRef.getFormData();
console.log(content);
},

+ 1
- 1
src/views/business/comps/template/formConfig/sp/SP007.js View File

@ -149,7 +149,7 @@ export const getfjFormConfig = () => {
{
type: "attachment",
config: {
storageCondition: {
attTitle: {
label: '标题',
type: "attachment",
fillType: "preFill",

Loading…
Cancel
Save