(function(exports) { var Selectors = { createSupplierTypeSelect: function(el, dirctory) { $(el).bsSuggest({ url: httpRequest.server + "/svr-iot/systemDict/findDictByCode?dictName=" + dirctory, getDataMethod: "firstByUrl", effectiveFields: ["value"], idField: "code", keyField: "value", fnProcessData: function(res) { return { value: [{ code: "0", value: "全部" }].concat(res.detailModelList) } } }); }, createDictSelect: function(el, dirctory, option) { $(el).bsSuggest({ url: httpRequest.server + "/svr-iot/systemDict/findDictByCode?dictName=" + dirctory, getDataMethod: "firstByUrl", effectiveFields: ["value"], idField: "code", keyField: "value", fnProcessData: function(res) { return (option && option.fnProcessData)?option.fnProcessData(res): res.detailModelList } }) }, // 获取当下企业证书 createCertificate: function(el, companyId, option) { $(el).bsSuggest({ url: httpRequest.server + "/svr-iot/company/findCompanyCertByCompanyId?companyId=" + companyId, getDataMethod: "firstByUrl", effectiveFields: ["name"], idField: "id", keyField: "name", fnProcessData: function(res) { return (option && option.fnProcessData)?option.fnProcessData(res): res.detailModelList } }) }, createJudgeStatusSelect: function(el) { $(el).bsSuggest({ data: { value: [{ code: "001", name: "已审核" }, { code: "002", name: "未审核" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name" }); }, createDeviceBindSelect: function(el) { $(el).bsSuggest({ data: { value: [ { code: "", name: "全部" }, { code: "1", name: "已绑定" }, { code: "2", name: "未绑定" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name" }); }, createDeviceTypeSelect: function(el) { $(el).bsSuggest({ data: { value: [{ code: "001", name: "血糖仪" }, { code: "002", name: "血压仪" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name" }); }, createDeviceStatusSelect: function(el) { $(el).bsSuggest({ data: { value: [{ code: "001", name: "状态1" }, { code: "002", name: "状态2" }] }, getDataMethod: "data", effectiveFields: ["code","name"], idField: "code", keyField: "name", effectiveFieldsAlias: { code: "编号", name: "名称" } }); }, createOrderStatusSelect: function(el) { $(el).bsSuggest({ data: { value: [{ code: "001", name: "状态1" }, { code: "002", name: "状态2" }] }, getDataMethod: "data", effectiveFields: ["code","name"], idField: "code", keyField: "name", effectiveFieldsAlias: { code: "编号", name: "名称" } }); }, createDeviceSelect: function(el) { $(el).bsSuggest({ data: { value: [{ code: "001", name: "设备1" }, { code: "002", name: "设备2" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name" }); }, createIsSureSelect: function(el, option) { $(el).bsSuggest({ data: { value: [{ code: "1", name: "是" }, { code: "0", name: "否" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name" }).on('onSetSelectValue', function (e, keyword) { option && option.onSetSelectValue && option.onSetSelectValue(e, keyword) }); }, createDeviceSupplierSelect2: function(el, option) { $(el).bsSuggest({ data: { value: [{ code: "001", name: "供应商1" }, { code: "002", name: "供应商2" }, { code: "", name: "+没有找到设备供应商?点击新增" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name", processData: function(json){ // url 获取数据时,对数据的处理,作为 getData 的回调函数 // var i, len, data = {value: []}; // // if(!json || !json.result || json.result.length == 0) { // return false; // } // // console.log(json); // len = json.result.length; // // for (i = 0; i < len; i++) { // data.value.push({ // "Id": (i + 1), // "Keyword": json.result[i][0], // "Count": json.result[i][1] // }); // } // console.log(data); return data; } }).on('onSetSelectValue', function (e, keyword) { option && option.onSetSelectValue && option.onSetSelectValue(e, keyword) }); }, createDeviceManufacturerSelect2: function(el, option) { $(el).bsSuggest({ data: { value: [{ code: "001", name: "厂商1" }, { code: "002", name: "厂商2" }, { code: "", name: "+没有找到设备厂商?点击新增" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name", processData: function(json){ // url 获取数据时,对数据的处理,作为 getData 的回调函数 // var i, len, data = {value: []}; // // if(!json || !json.result || json.result.length == 0) { // return false; // } // // console.log(json); // len = json.result.length; // // for (i = 0; i < len; i++) { // data.value.push({ // "Id": (i + 1), // "Keyword": json.result[i][0], // "Count": json.result[i][1] // }); // } // console.log(data); return data; } }).on('onSetSelectValue', function (e, keyword) { option && option.onSetSelectValue && option.onSetSelectValue(e, keyword) }); }, createDataTransModeSelect: function(el) { $(el).bsSuggest({ data: { value: [{ code: "1", name: "WIFI" }, { code: "2", name: "蓝牙" }, { code: "3", name: "SIM卡" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name" }); }, createPurchasingDeviceSelect2: function(el, option) { $(el).bsSuggest({ data: { value: [{ code: "001", name: "厂商1" }, { code: "002", name: "厂商2" }, { code: "", name: "+没有找到设备?点击新增" }] }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name", processData: function(json){ // url 获取数据时,对数据的处理,作为 getData 的回调函数 // var i, len, data = {value: []}; // // if(!json || !json.result || json.result.length == 0) { // return false; // } // // console.log(json); // len = json.result.length; // // for (i = 0; i < len; i++) { // data.value.push({ // "Id": (i + 1), // "Keyword": json.result[i][0], // "Count": json.result[i][1] // }); // } // console.log(data); return data; } }).on('onSetSelectValue', function (e, keyword) { option && option.onSetSelectValue && option.onSetSelectValue(e, keyword) }); }, createCompanySelect: function(el, option) { $(el).bsSuggest({ url: httpRequest.server + "/svr-iot/company/findCompanyPage?size=100", getDataMethod: "url", effectiveFields: ["value"], idField: "code", keyField: "value", adjustAjaxParam: function(keyword) { return { name: keyword, size: 100 } }, fnProcessData: function(json){ var data = {} data.value = _.map(json.detailModelList, function(v) { return { code: v.id, value: v.name } }) return data } }).on('onSetSelectValue', function (e, keyword) { option && option.onSetSelectValue && option.onSetSelectValue(e, keyword) }); }, //获取API类别 createShareInterfaceTypeSelect: function(el) { $(el).bsSuggest({ url: httpRequest.openServer + "/apiCategory/page?page=1&&size=10000", getDataMethod: "url", effectiveFields: ["name"], idField: "id", keyField: "name", fnProcessData: function(res) { var data = {} data.value = _.map(res.datas, function(v) { return { id: v.id, name: v.name } }) return data } }) }, createDefinedSelect: function(el,datas) { $(el).bsSuggest("destroy"); $(el).bsSuggest({ data: { value: datas }, getDataMethod: "data", effectiveFields: ["name"], idField: "code", keyField: "name" }); }, } exports.Selectors = Selectors; })(window)