import { getNumber } from '@/api/base';

export default {
    data() {
        return {
            pdfNumberRes: '',
            pdfNumberList: [],
        }
    },
    methods: {
        async loadPdfNumber(type) {
            this.pdfNumberList = await getNumber(type);
            // 消防监督检查记录编号改为:"编号：〔2022 〕 第XXX号"
            // 责令限期改正通知书编号改为:"CC消限字〔2022〕第XXX号"
            // 责令立即改正通知书编号改为:"CC消即字〔2022〕第XXX号"
            this.pdfNumberRes = this.pdfNumberList.join('');
        },
        setupStaticNoticeResult(task, key, value, markValue) {
            let res = task.static_notice_result || '{}';
            res = JSON.parse(res);
            if (key == 'record') {
                const obj = {
                    number: this.pdfNumberList
                };
                if (value) {
                    obj.content = value;
                }
                if (markValue) {
                    obj.mark = markValue;
                }
                res.record = obj;
            }
            if (key == 'immediately') {
                const obj = {
                    number: this.pdfNumberList,
                    content: JSON.stringify(value)
                };
                if (markValue) {
                    obj.mark = markValue;
                }
                res.immediately = obj;
            }
            if (key == 'deadline') {
                const obj = {
                    number: this.pdfNumberList,
                    content: JSON.stringify(value)
                };
                if (markValue) {
                    obj.mark = markValue;
                }
                res.deadline = obj;
            }
            return JSON.stringify(res);
        },
    }
}