123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- (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)
|