|
|
- export default {
- props: {
- templateData: {
- type: Object,
- default: () => {},
- },
- },
- watch: {
- templateData: {
- immediate: true,
- handler(v) {
- if(v){
- let n = {...v};
- if(v.bdnr){
- n = {...n,...JSON.parse(v.bdnr)};
- }
- this.formData = n;
- this.setTemplateData(n);
- }
- }
- }
- },
- data() {
-
- },
- mounted() {
-
- setTimeout(() => {
- this.setConditionOptions(
- [
- { label: "条件5", value: "1" },
- { label: "条件6", value: "2" },
- { label: "条件7", value: "3" },
- { label: "其他", value: "-1" },
- ]
- )
- }, 1000);
- this.setTemplateStatus("preFill");
- // this.setTemplateStatus(this.fillType)
-
- },
- unmounted() {
- this.setTemplateStatus("");
- this.setTemplateData({});
- },
- methods: {
- setTemplateStatus(status) {
- this.$store.commit('template/SET_TEMPLATE_STATUS', status)
- },
- setConditionOptions(options) {
- this.$store.commit('template/SET_CONDITION_OPTIONS', options)
- },
- //统一处理blur事件,因为有效周期和过期日期是相关的,所以需要在有效周期失焦时更新过期日期
- onHandleBlur(fields){
- const {key ,effectivePeriodUnit,effectivePeriod} = fields;
- const {createTime} = this.formData;
- if(key ==="effectivePeriod"){//统一处理有效周期失焦,计算失效事件,保证字段名不能变
- const start = moment(createTime);
- const end = start.add(Number(effectivePeriod), effectivePeriodUnit).format("YYYY-MM-DD HH:mm:ss");
- this.$refs.stepFormPackageRef.updateFormField("expireDate", end);
- }
- }
-
- },
-
- }
|