import { venders } from '@/api/scan/config'
import http from '@/api/scan/httpUtil'

/**** 修改 */
//修改创建维修商

//生产商修改
function updateVenderManufacturer(param, success) {
    let url = `${venders}/manufacturer/update`
    http.postJson(url, param, success)
}

//保险商修改
function updateVenderInsurer(param, success) {
    let url = `${venders}/insurance/update`
    http.postJson(url, param, success)
}

//保险商修改
function updateVenderMaintainer(param, success) {
    let url = `${venders}/maintainer/update`
    http.postJson(url, param, success)
}

//供应商修改
function updateVenderSupplier(param, success) {
    let url = `${venders}/supplier/update`
    http.postJson(url, param, success)
}

//品牌修改
function updateVenderBrand(param, success) {
    let url = `${venders}/manufacturer/brand/update`
    http.postJson(url, param, success)
}

//型号修改
function updateVenderSpecification(param, success) {
    let url = `${venders}/manufacturer/specification/update`
    http.postJson(url, param, success)
}

/** 获取 */
function getList(param, success) {
    let url = `${venders}/basic/vender/query`
    http.postJson(url, param, success)
}

function getManufacturer(param, success) {
    let url = `${venders}/manufacturer/brand/findOne`
    http.postJson(url, param, success)
}

function getSpecification(param, success) {
    let url = `${venders}/manufacturer/specification/findOne`
    http.postJson(url, param, success)
}

/** 创建 */
//创建品牌
function createBrand(param, success) {
    let url = `${venders}/manufacturer/brand/create`
    http.postJson(url, param, success)
}
//创建生产商
function createManufacturer(param, success) {
    let url = `${venders}/manufacturer/create`
    http.postJson(url, param, success)
}
//创建供应商
function createSupplier(param, success) {
    let url = `${venders}/supplier/create`
    http.postJson(url, param, success)
}
//创建保险商
function createInsurance(param, success) {
    let url = `${venders}/insurance/create`
    http.postJson(url, param, success)
}
//创建维修商
function createMaintainance(param, success) {
    let url = `${venders}/maintainance/create`
    http.postJson(url, param, success)
}

//创建产品
function createProduct(param, success) {
    let url = `${venders}/manufacturer/product/create`
    http.postJson(url, param, success)
}

//创建型号
function createSpecification(param, success) {
    let url = `${venders}/manufacturer/specification/create`
    http.postJson(url, param, success)
}

/***  联系人信息 */
//添加修改维修商联系信息
function updateMaintainance(param, success) {
    let url = `${venders}/maintainance/link/create`
    http.postJson(url, param, success)
}

//修改创建供应商联系人
function updateSupplier(param, success) {
    let url = `${venders}/supplier/link/create`
    http.postJson(url, param, success)
}
//修改创建保险商联系人
function updateInsurance(param, success) {
    let url = `${venders}/insurance/link/create`
    http.postJson(url, param, success)
}



let arr = [{
        name: "生产商",
        infosArr: ["manufacturer"],
        createFunc: createManufacturer,
        getList: getList,
        infosKey: "dpManufacturerId",
        update: "",
        updateVender: updateVenderManufacturer,
        options: [{
            key: "vender.name",
            label: "生产商名称",
            optLabel: "manufacturer",
            type: "Str"
        }]
    },
    {
        name: "品牌",
        infosArr: ["Brand"],
        infosKey: "dpBrandId",
        createFunc: createBrand,
        getList: getManufacturer,
        update: "",
        options: [{
            key: "content.name",
            label: "品牌",
            optLabel: "Brand",
            type: "Str"
        }],
        updateVender: updateVenderBrand
    },
    {
        name: "保险商",
        infosArr: ["insurer", "insurerContactor", "insurerPhone", "insurerEmail", "insurerWeb", "insurerFax"],
        createFunc: createInsurance,
        getList: getList,
        infosKey: "dpInsurerId",
        getWebSite: "",
        updateVender: updateVenderInsurer,
        update: updateInsurance,
        options: [{
                key: "vender.name",
                label: "保险公司名称",
                optLabel: "insurer",
                type: "Str"
            },
            {
                key: "vender.website",
                label: "保险公司网址",
                optLabel: "insurerWeb",
                type: "Str"
            },
            {
                key: "contact.name",
                label: "联系人",
                optLabel: "insurerContactor",
                type: "Str"
            },
            {
                key: "contact.phone",
                label: "联系人电话",
                optLabel: "insurerPhone",
                type: "Num"
            }, {
                key: "contact.email",
                label: "联系人邮箱",
                optLabel: "insurerEmail",
                type: "Str"
            }, {
                key: "contact.fax",
                label: "联系人传真",
                optLabel: "insurerFax",
                type: "Str"
            }
        ],
    },
    {
        name: "维修商",
        infosArr: ["maintainer", "MaintainerContactor", "MaintainerPhone", "MaintainerEmail", "MaintainerWeb", "MaintainerFax"],
        createFunc: createMaintainance,
        updateVender: updateVenderMaintainer,
        options: [{
                key: "vender.name",
                label: "维修商单位名称",
                optLabel: "maintainer",
                type: "Str"
            },
            {
                key: "vender.website",
                label: "维修商网址",
                optLabel: "MaintainerWeb",
                type: "Str"
            }, {
                key: "contact.name",
                label: "联系人",
                optLabel: "MaintainerContactor",
                type: "Str"
            },
            {
                key: "contact.phone",
                label: "联系人电话",
                optLabel: "MaintainerPhone",
                type: "Num"
            }, {
                key: "contact.email",
                label: "联系人邮箱",
                optLabel: "MaintainerEmail",
                type: "Str"
            }, {
                key: "contact.fax",
                label: "联系人传真",
                optLabel: "MaintainerFax",
                type: "Str"
            }
        ],
        getList: getList,
        update: updateMaintainance,
        infosKey: "dpMaintainerId",
        getWebSite: "",
    },
    {
        name: "供应商",
        infosArr: ["Supplier", "SupplierContactor", "SupplierPhone", "SupplierEmail", "SupplierWeb", "SupplierFax"],
        createFunc: createSupplier,
        updateVender: updateVenderSupplier,
        options: [{
                key: "vender.name",
                label: "供应商单位名称",
                optLabel: "Supplier",
                type: "Str"
            },
            {
                key: "vender.website",
                label: "供应商网址",
                optLabel: "SupplierWeb",
                type: "Str"
            }, {
                key: "contact.name",
                label: "联系人",
                optLabel: "SupplierContactor",
                type: "Str"
            },
            {
                key: "contact.phone",
                label: "联系人电话",
                optLabel: "SupplierPhone",
                type: "Num"
            }, {
                key: "contact.email",
                label: "联系人邮箱",
                optLabel: "SupplierEmail",
                type: "Str"
            }, {
                key: "contact.fax",
                label: "联系人传真",
                optLabel: "SupplierFax",
                type: "Str"
            }
        ],
        getList: getList,
        update: updateSupplier,
        infosKey: "dpSupplierId",
        getWebSite: "",
    },
    {
        name: "型号",
        infosArr: ["specificationName"],
        getList: getSpecification,
        createFunc: createSpecification,
        createProduct: createProduct,
        update: "",
        options: [],
        updateVender: updateVenderSpecification,
        infosKey: "dpSpecificationId",
        getWebSite: ""
    }
]

export default arr