Browse Source

feat:[模板管理][暂存]

lkf
luojie 1 month ago
parent
commit
ecb1a1fa72
4 changed files with 162 additions and 9 deletions
  1. +13
    -0
      src/components/Template/BaseInfoFormPackage.vue
  2. +21
    -4
      src/components/Template/CustomTable.vue
  3. +121
    -3
      src/components/Template/HandleFormItem.vue
  4. +7
    -2
      src/views/business/comps/template/comps/yp/YP003.vue

+ 13
- 0
src/components/Template/BaseInfoFormPackage.vue View File

@ -114,6 +114,13 @@
@update:error="errors[key] = false" @resetRecord="resetRecord(key)" :item="sItem" @update:error="errors[key] = false" @resetRecord="resetRecord(key)" :item="sItem"
:value="formFields[key]" /> :value="formFields[key]" />
</div> </div>
<div v-else-if="sItem.type === 'checkboxTag'" class="flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key"
type="checkboxTag" :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>
<div v-else-if="sItem.type === 'checkboxList'" class="flex1"> <div v-else-if="sItem.type === 'checkboxList'" class="flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key" <HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key"
type="checkboxList" :item="sItem" :value="formFields[key]" type="checkboxList" :item="sItem" :value="formFields[key]"
@ -268,6 +275,12 @@
@update:error="errors[key] = false" @resetRecord="resetRecord(key)" :item="sItem" @update:error="errors[key] = false" @resetRecord="resetRecord(key)" :item="sItem"
:value="formFields[key]" /> :value="formFields[key]" />
</div> </div>
<div v-else-if="sItem.type === 'checkboxTag'" class="flex flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key"
type="checkboxTag" :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>
<div v-else-if="sItem.type === 'checkboxList'" class="flex flex1"> <div v-else-if="sItem.type === 'checkboxList'" class="flex flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key" <HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey + '_' + key"
type="checkboxList" :item="sItem" :value="formFields[key]" @copy="onCopy(sItem, key)" type="checkboxList" :item="sItem" :value="formFields[key]" @copy="onCopy(sItem, key)"

+ 21
- 4
src/components/Template/CustomTable.vue View File

@ -109,10 +109,20 @@
{{ row[col.prop] }} {{ row[col.prop] }}
</div> </div>
</template> </template>
<template v-else-if="col.bodyType === 'span'">
<div class="body-span">
{{ row[col.prop] }}
<template v-else-if="col.bodyType === 'checkboxTag'">
<div class="flex flex-wrap">
<HandleFormItem v-for="(tag, tagIndex) in row[col.prop]" :key="tagIndex"
:fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex + '_' + tagIndex"
:fieldItemLabel="fieldItemLabel" type="checkboxTag"
@blur="onBlur(rowIndex, col.prop, $event)"
:value="tag"
:item="getBodyItem(col, rowIndex)"
@change="onCheckboxTagChange(rowIndex, colIndex,tagIndex, $event)"
:error="hasError(rowIndex, colIndex, col.prop)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)"
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" />
</div> </div>
</template> </template>
</div> </div>
@ -130,7 +140,8 @@
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.otherCode)" /> :orange-bg="hasOrangeBg(rowIndex, colIndex, col.otherCode)" />
</div> </div>
</div> </div>
<div class="m-l-5" :class="{'flex1':col.bodySubType !== 'button'}" v-if="isShowBodySub(col, row)">
<div class="m-l-5" :class="{ 'flex1': col.bodySubType !== 'button' }"
v-if="isShowBodySub(col, row)">
<template v-if="col.bodySubType === 'inputNumber'"> <template v-if="col.bodySubType === 'inputNumber'">
<HandleFormItem :fieldKey="prefixKey + '_' + col.bodySubKey + '_' + rowIndex" <HandleFormItem :fieldKey="prefixKey + '_' + col.bodySubKey + '_' + rowIndex"
:fieldItemLabel="fieldItemLabel" type="inputNumber" :fieldItemLabel="fieldItemLabel" type="inputNumber"
@ -306,6 +317,9 @@ export default {
this.oldLocalDataSource = []; this.oldLocalDataSource = [];
}, },
methods: { methods: {
onCheckboxTagChange(rowIndex, colIndex,tagIndex, e) {
console.log(e,"eee")
},
handleClickButton(e, data, key, rowIndex, colIndex) { handleClickButton(e, data, key, rowIndex, colIndex) {
this.$emit("clickButton", key, rowIndex, colIndex, e, data,) this.$emit("clickButton", key, rowIndex, colIndex, e, data,)
}, },
@ -1013,4 +1027,7 @@ export default {
text-align: center; text-align: center;
width: 100px; width: 100px;
} }
.flex-wrap{
flex-wrap: wrap;
}
</style> </style>

+ 121
- 3
src/components/Template/HandleFormItem.vue View File

@ -1,6 +1,6 @@
<template> <template>
<div class="flex " :class="type !=='radio' ? 'flex1' : ''">
<div class="flex" :class="type !=='radio' ? 'flex1' : ''">
<div class="flex " :class="getFlexClass()">
<div class="flex" :class="getFlexClass()">
<el-input v-if="type === 'input'" :maxlength="item.maxlength || 50" :disabled="getDisabled()" <el-input v-if="type === 'input'" :maxlength="item.maxlength || 50" :disabled="getDisabled()"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" @blur="onBlur" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" @blur="onBlur"
:placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" /> :placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" />
@ -89,6 +89,30 @@
<div slot="tip" class="el-upload__tip">支持扩展名.rar .zip .doc .docx .pdf .jpg文件大小不超过2MB</div> <div slot="tip" class="el-upload__tip">支持扩展名.rar .zip .doc .docx .pdf .jpg文件大小不超过2MB</div>
</el-upload> </el-upload>
</template> </template>
<div v-else-if="type === 'checkboxTag'" class="flex1 checkbox-tag-container"
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')">
<div class="checkbox-tag-item">
<el-checkbox v-model="checkboxTagChecked" :disabled="getDisabled()" @change="onCheckboxTagChange"></el-checkbox>
<div class="tag-content blue-border" @click="onTagClick">
<el-input v-if="isEditingTag"
v-model="tagValue"
ref="tagInput"
:maxlength="item.maxlength || 20"
@blur="onTagBlur"
@keyup.enter.native="onTagBlur"
placeholder="请输入"
size="mini"
class="tag-input" />
<el-tag v-else
:type="'info'"
class="tag-display"
:closable="false">
{{ tagValue || '点击输入' }}
</el-tag>
</div>
<i class="el-icon-close delete-icon" @click="onDeleteTag" v-if="tagValue"></i>
</div>
</div>
</div> </div>
<div class="handle-row" v-if="isShowHandle()"> <div class="handle-row" v-if="isShowHandle()">
@ -218,7 +242,7 @@ export default {
}, },
data() { data() {
let initialValue = this.value; let initialValue = this.value;
let initialOtherValues = {};
let initialOtherValues = {},checkboxTagChecked = false,tagValue = '';
// checkboxListvalue // checkboxListvalue
if (this.type === 'checkboxList' && this.value && typeof this.value === 'object') { if (this.type === 'checkboxList' && this.value && typeof this.value === 'object') {
@ -226,6 +250,9 @@ export default {
initialOtherValues = this.value.otherValues || {}; initialOtherValues = this.value.otherValues || {};
} else if (this.type === 'checkboxList' && !Array.isArray(this.value)) { } else if (this.type === 'checkboxList' && !Array.isArray(this.value)) {
initialValue = []; initialValue = [];
}else if (this.type === 'checkboxTag' && this.value && typeof this.value === 'object') {
checkboxTagChecked = this.value.checked || false;
tagValue = this.value.tagValue || '';
} }
return { return {
inputValue: initialValue, inputValue: initialValue,
@ -241,6 +268,9 @@ export default {
replyContent: '', // replyContent: '', //
visible: false,// visible: false,//
checkboxValue: this.getChecked(),// checkboxValue: this.getChecked(),//
checkboxTagChecked: checkboxTagChecked, // checkboxTagcheckbox
tagValue: tagValue, // checkboxTagtag
isEditingTag: false, // tag
uuid: getuuid(), // EventBus uuid: getuuid(), // EventBus
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], //// regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], ////
selectRegentInfo: {},//// selectRegentInfo: {},////
@ -255,9 +285,13 @@ export default {
}, },
watch: { watch: {
value(newVal) { value(newVal) {
console.log(newVal,"newVal")
if (this.type === 'checkboxList' && newVal && typeof newVal === 'object') { if (this.type === 'checkboxList' && newVal && typeof newVal === 'object') {
this.inputValue = newVal.checkboxValues || []; this.inputValue = newVal.checkboxValues || [];
this.otherValues = newVal.otherValues || {}; this.otherValues = newVal.otherValues || {};
} else if (this.type === 'checkboxTag' && newVal && typeof newVal === 'object') {
this.checkboxTagChecked = newVal.checked || false;
this.tagValue = newVal.tagValue || '';
} else { } else {
this.inputValue = this.type === 'checkboxList' && !Array.isArray(newVal) ? [] : newVal; this.inputValue = this.type === 'checkboxList' && !Array.isArray(newVal) ? [] : newVal;
} }
@ -294,6 +328,10 @@ export default {
EventBus.$off("onMixReagentSubmit", this.onMixReagentSubmit) EventBus.$off("onMixReagentSubmit", this.onMixReagentSubmit)
}, },
methods: { methods: {
getFlexClass(){
const noFlexArr = ["radio","checkboxTag"]
return noFlexArr.includes(this.type) ? '' : 'flex1'
},
getDecimalDigits(){ getDecimalDigits(){
const {precision} = this.item; const {precision} = this.item;
if(!isNaN(precision)){ if(!isNaN(precision)){
@ -774,6 +812,40 @@ export default {
this.otherValues[code] = value; this.otherValues[code] = value;
this.onInputChange(); this.onInputChange();
}, },
// checkboxTagcheckbox
onCheckboxTagChange() {
this.emitCheckboxTagValue();
},
// tag
onTagClick() {
this.isEditingTag = true;
this.$nextTick(() => {
this.$refs.tagInput && this.$refs.tagInput.focus();
});
},
// tag
onTagBlur() {
this.isEditingTag = false;
this.emitCheckboxTagValue();
//
if (this.tagValue) {
this.onCommonHandleSaveRecord(this.tagValue);
}
},
// tag
onDeleteTag() {
this.tagValue = '';
this.emitCheckboxTagValue();
this.onCommonHandleSaveRecord('');
},
// checkboxTag
emitCheckboxTagValue() {
const value = {
checked: this.checkboxTagChecked,
tagValue: this.tagValue
};
this.$emit('change', value);
},
// //
onBlur(e) { onBlur(e) {
this.onCommonHandleSaveRecord(e.target.value); this.onCommonHandleSaveRecord(e.target.value);
@ -1572,4 +1644,50 @@ export default {
border-color: #f9c588; border-color: #f9c588;
} }
} }
// checkboxTag
.checkbox-tag-container {
border-radius: 4px;
// transition: all 0.3s;
margin-bottom: 5px;
margin-right: 5px;
&.error-border {
border-color: #ff5d5d !important;
box-shadow: 0 0 6px #ffc3c3 !important;
}
.checkbox-tag-item {
display: flex;
align-items: center;
gap: 8px;
.tag-content {
cursor: pointer;
.tag-input {
width: 100px;
}
.tag-display {
cursor: pointer;
user-select: none;
}
}
.delete-icon {
cursor: pointer;
color: #909399;
font-size: 14px;
padding: 2px;
border-radius: 50%;
// transition: all 0.3s;
&:hover {
color: #ff5d5d;
background-color: #f5f5f5;
}
}
}
}
</style> </style>

+ 7
- 2
src/views/business/comps/template/comps/yp/YP003.vue View File

@ -231,9 +231,14 @@ export default {
this.$refs.ImportExcelDialog.show() this.$refs.ImportExcelDialog.show()
}, },
onLoadExcelData(excelData) { onLoadExcelData(excelData) {
console.log(excelData)
const data = excelData.splice(1); const data = excelData.splice(1);
this.$refs.tableRef.updateDataSourceByRowIndex(this.currentRowIndex,data);
const tagData = data.map((item)=>{
return {
checked:false,
tagValue:item[0],
}
})
this.$refs.tableRef.updateDataSourceByRowIndex(this.currentRowIndex,{dwbh:tagData});
this.$refs.ImportExcelDialog.cancel() this.$refs.ImportExcelDialog.cancel()
}, },
downloadExcelTemplate(arr){ downloadExcelTemplate(arr){

Loading…
Cancel
Save