/*
 * @Author: your name
 * @Date: 2022-03-23 08:57:54
 * @LastEditTime: 2022-03-23 08:59:15
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \tableDisplayBusiness\src\tools\specialTreatment.js
 */
export default {
    install: function(Vue, str, options) {
        Vue.prototype.popupAssign = function(type, bbdm, frameId, val) {
            var tableData = this.$store.state.data.engines;
            if (type == 'init') {
                if (bbdm == "10102_014") {
                    if (frameId == "545d0710-5c1b-4544-a5a1-2c0a4432b5c8") {
                        //bug29012 保存状态下，不该再弹出下面系统提示
                        var menuList = this.$store.state.data.menuList;
                        var defaultMenu = this.$store.state.data.defaultMenu;
                        var menu = {}
                        menuList.forEach(element => {
                            if (element.bbDm + '_' + element.detailPcdm == defaultMenu) {
                                menu = element
                            }
                        });
                        if (menu.verificationState != "empty") {
                            return true
                        } else {
                            return false
                        }
                    }
                }
            } else if (type == 'cell') {
                if (bbdm == "10102_009") {
                    //bug29015 选择特殊的减免性质代码，选中后缺少提示
                    var mes = ""
                    var dm = val[0].dm
                    if (dm == "0001081517") {
                        mes = "此免税项目的适用主体为合格境外投资者（QFII），请确认填写是否准确！"
                    } else if (dm == "0001083920") {
                        mes = "此免税项目的适用主体为人民币合格境外机构投资者（RQFII）或境外机构，请确认填写是否准确！"
                    } else if (dm == "0001081524") {
                        mes = "此免税项目的适用主体为境外机构，请确认填写是否准确！"
                    } else if (['0001081511', '0001081512'].includes(dm)) {
                        mes = "此免税项目的适用主体为香港市场投资者，请确认填写是否准确！"
                    } else if (dm == "0001032103") {
                        mes = "此免税项目的适用主体为台湾航运公司、航空公司，请确认填写是否准确！"
                    } else if (['0001102914', '0001102931'].includes(dm)) {
                        mes = "此免税项目的适用主体为财政部、税务总局发布的免税清单企业，请确认填写是否准确！"
                    } else if (dm == "0001021906") {
                        mes = "此免税项目的适用主体为科技、教育部门认定的科技企业孵化器、大学科技园和国家备案众创空间，请确认填写是否准确！"
                    } else if (['0001081519', '0001129928'].includes(dm)) {
                        mes = "此免税项目的适用主体为行政机关或者事业单位，请确认填写是否准确！"
                    } else if (['0001083903', '0001083901', '0001083911'].includes(dm)) {
                        mes = "此免税项目的适用主体为特定金融资产管理公司，请确认填写是否准确！"
                    } else if (['0001012715', '0001101403', '0001103230', '0001081518', '0001019908', '0001012717', '0001011703', '0001011701', '0001011705'].includes(dm)) {
                        mes = "此减免税项目的适用主体为个人，请确认填写是否准确！"
                    }
                    return mes
                } else {
                    return ""
                }
            } else if (type == 'array') {
                if (bbdm == "10102_001") {
                    var idList = []
                    val.forEach(element => {
                        idList.push(element.index)
                    });
                    if (idList.includes("0e850f7e-be5d-4745-b8f9-83bd41b11e84")) {
                        if (!idList.includes("35a53e15-9142-4327-bb0c-ca1672bc42e1") && !idList.includes("0d08fd72-4692-4a38-899c-8fc6ce3cf98b")) {
                            val = Enumerable.From(val).Where(function(obj) {
                                return obj.index != "0e850f7e-be5d-4745-b8f9-83bd41b11e84"
                            }).ToArray();
                        }
                    }
                    val = this.chaoticOrder(val, "openOrder", true)
                    return val
                } else {
                    return val
                }
            } else if (type == 'sure') {
                if (bbdm == "10102_001") {
                    if (frameId == "0e850f7e-be5d-4745-b8f9-83bd41b11e84") {
                        //bug 28983 填写了本期销售不动产销售额，该隐藏列值为1，否则为0 单元格隐藏列节点名称  hidden_563
                        //bug 29057 不论填写多少 点击确定后 hidden_563就应该是1
                        if (["", undefined, null].includes(val)) {
                            val = "0.00"
                        }
                        tableData.updateNodeValue([{
                                "hidden_563": "1"
                            }])
                            //bug 28984 给“本期销售不动产的销售额”赋值
                        tableData.updateNodeValue([{
                            "cell_55": val
                        }])
                        this.saveAgain()
                    } else if (frameId == "8396fd03-9a00-47a7-b3b7-ed6df66e54c4") {
                        this.saveTsxx(bbdm)
                    }
                }
            }
        };
        Vue.prototype.saveAgain = function() {
            var tableData = this.$store.state.data.engines;
            var saveTableData = tableData.getTableData();
            var checkList = saveTableData.checkList.checkList
            this.$store.commit("checkList", checkList);
            var parent = this.$store.state.data.parent
            var obj = this.recursionChild(parent.$refs.buttonArea.$children, "saveButton");
            obj.saveFun("modal");
        };
        Vue.prototype.getTsxxFun = function(bbDm) {
            var _self = this;
            var getUrl = interfacePrefix + config.tsxxGet;
            var params = {
                bblxDm: this.$store.state.data.openData.bblxDm, // 报表类型代码
                bbDm: bbDm, // 报表代码
                djxh: this.$store.state.data.openData.djxh, // 登记序号
            }
            this.ajax.post(getUrl, params, function(data) {
                if (data.returnCode == "00") {
                    data.content = 'N'
                    if (data.content == 'N') { //content 返回N弹出提示，返回Y不弹出提示
                        if (bbDm != "10101_003") {
                            return true
                        } else {
                            return false
                        }
                    } else {
                        return false
                    }
                } else {
                    return false
                }
            }, "json", true);
        };
        Vue.prototype.getNowFormatDate = function() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            var hour = date.getHours();
            var minute = date.getMinutes();
            var second = date.getSeconds();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 1 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            if (hour >= 0 && hour <= 9) {
                hour = "0" + hour;
            }
            if (minute >= 0 && minute <= 9) {
                minute = "0" + minute;
            }
            if (second >= 0 && second <= 9) {
                second = "0" + second;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
                " " + hour + seperator2 + minute +
                seperator2 + second;
            return currentdate;
        };
        Vue.prototype.saveTsxx = function(bbDm) {
            var _self = this;
            var saveUrl = interfacePrefix + config.tsxxSave;
            var params = {
                bblxDm: this.$store.state.data.openData.bblxDm, // 报表类型代码
                bbDm: bbDm, // 报表代码
                djxh: this.$store.state.data.openData.djxh, // 登记序号
                qqsj: this.getNowFormatDate(), // 获取当前时间 YYYY-MM-DD hh:mm:ss
            }
            this.ajax.post(saveUrl, params, function(data) {}, "json", true);
        }
    }
}