123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- <div class="plg-tab-container">
- <div class="plg-flex" style="height: 100%">
- <div class="flex_item" id="resource">
-
- </div>
- </div>
- </div>
- <style>
- </style>
- <script>
- (function () {
-
- window.global_fun.resource={}
-
- var res_opts = {
- fixedLast: true,
- renderer: "resource",
- url: APIS.resource.getList(),
- type: "get",
- // pageNum: "pageNo",//设置分页参数页码key值,默认为pageNum
- };
- res_opts.pagebar = {
- buttons: [
- { text: PLG_BUTTON.value.delBtn(), className: "layui-btn-danger plg-btn-height-auto", name: "delBtn" }
- ]
- },
- res_opts.columns = [
- {
- name: "id",
- id: "id",
- hidden: true
- },
- {
- name: "服务名称",
- id: "serviceName",
- align: "center",
- type: "ro",
- width:200
- },
- {
- name: "请求访式",
- id: "method",
- align: "center",
- type: "ro",
- width:150
- },
- {
- name: "地址路径",
- id: "source",
- align: "left",
- type: "ro",
- width:350
- },
- {
- name: "说明",
- id: "notes",
- align: "left",
- type: "ro",
- },
- {
- id: "op",
- name: "操作",
- type: 'button',
- width: 180,
- align: "center",
- render: function (v, d) {
- return '修改^global_fun.resource.editClick,删除^global_fun.resource.deleteClick';
- }
- }
- ];
- res_opts.toolbar = [{
- type: 'row',
- blockOffset: 0,
- className: "layui-col-md12",
- list: [
- {
- type: "row",
- className: "layui-col-md6",
- blockOffset: 0,
- list: [{
- className: "layui-col-md4",
- type: "input",
- name: "likeMap",
- label: "搜索",
- placeholder: "服务名/请求方式/地址"
- },
- {
- type: "button",
- className: "left",
- name: "selectAllBtn",
- value: PLG_BUTTON.value.searchBtn()
- },
- {
- type: "button",
- name: "resetBtn",
- className: "left",
- value: PLG_BUTTON.value.resetBtn()
- },
- ]
- },
- {
- type: "block",
- className: "layui-col-md6 right",
- blockOffset: 0,
- list: [
- {
- type: "button",
- name: "addBtn",
- value: PLG_BUTTON.value.addBtn()
- },
- {
- type: "newcolumn"
- },
- {
- className: "upload",
- type: "button",
- name: "importBtn",
- value: PLG_BUTTON.value.importBtn()
- },
-
- {
- type: "newcolumn"
- },
- {
- type: "button",
- name: "downBtn",
- value: PLG_BUTTON.value.downBtn()
- },
- {
- type: "newcolumn"
- },
- {
- type: "button",
- name: "aotuLoadBtn",
- value: "加载资源"
- }
- ]
- }]
- }];
- res_opts.formData = [{
- type: "row",
- list: [{
- type: "settings",
- labelWidth: 90,
- position: "label-left",
- labelAlign: "right"
- },
- {
- type: "hidden",
- name: "id",
- label: "id",
- value: 0,
- },
- {
- type: "input",
- name: "serviceName",
- label: "服务名",
- required: true,
- validate: 'NotEmpty',
- placeholder: _t("请输入服务名")
- },
- {
- type: "input",
- name: "source",
- label: "接口地址",
- required: true,
- validate: "NotEmpty",
- placeholder: _t("请输入接口地址")
- },
- {
- type: "select",
- name: "method",
- label: "提交方式",
- required: true,
- options: [
- { value: "GET", text: "GET", selected: true },
- { value: "POST", text: "POST" },
- { value: "PUT", text: "PUT" },
- { value: "DELETE", text: "DELETE" }
- ]
- },
- { type: "input", name: "notes", validate: 'NotEmpty', required: true, label: "说明:", rows: 3, labelTop: -20, placeholder: "请填写这个服务是干什么用的" }
- ]
- }
- ]
- var res_inst = new GridPlant({
- instance: new PlgGrid(setConfig(res_opts)).loadData(),
- addBtnUrl: APIS.resource.getResource(),
- editBtnUrl: APIS.resource.update(),
- delBtnUrl: APIS.resource.deleteAll(),
- downBtnUrl: APIS.resource.download(),
- importBtnUrl: APIS.resource.import(),
- }).init();
-
- res_inst.selectAllBtnAfter(function (obj) {
- var likeMap = res_inst.PlgGridInstance.getToolBarForm().getItemValue("likeMap");
- obj.serviceName = likeMap
- obj.method = likeMap
- obj.source = likeMap
- delete obj.likeMap
- })
- res_inst.PlgGridInstance.attachPageBarEvent(function () {
-
- this.delBtn({ids:this.idS});
- }.bind(res_inst))
- window.global_fun.resource.editClick = function () {
- res_inst.PlgGridInstance.selectRowById(arguments[0]);
- res_inst.editBtn();
- }
- window.global_fun.resource.deleteClick = function () {
- res_inst.PlgGridInstance.selectRowById(arguments[0]);
- res_inst.formatForm(3, "POST", _t("是否删除当前数据"), APIS.resource.delete(), { id: arguments[0] })
- }
- //自动加载配制
- var aotu_opts = {
- sysOpts: null,
- renderer: Prolog.createRandomId(),
- url: APIS.resource.getNameByList(),
- type: "get",
- page: false,
- multiselect: false,
- params: { serviceName: "" }
- };
- aotu_opts.toolbar = [
- {
- type: "row",
- className: "layui-col-md12",
- list: [
- {
- className: "layui-col-md12",
- type: "combo",
- name: "serviceName",
- label: "选择服务",
- remote: {
- url: APIS.resource.getSysNames(),
- type: "GET",
- success: function (da) {
- if (da.success && da.data != null && da.data.length > 0) {
- var myForm = res_inst.autoLoadInsta.getToolBarForm();
- var myCombo = myForm.getCombo("serviceName");
- myCombo.clearAll(false);
- var array = new Array();
- da.data.map(x => { array.push([x, x]) });
- myCombo.addOption(array);
- myCombo.setComboValue(da.data[0]);
- }
- }
- },
- options: null
- }
- ]
- }
- ]
- aotu_opts.columns = [{
- name: "id",
- id: "id",
- hidden: true
- },
- {
- name: "服务名",
- id: "serviceName",
- align: "left",
- type: "ro",
- width:140,
- },
- {
- name: "请求访式",
- width:60,
- id: "method",
- align: "center",
- type: "ro"
- },
- {
- name: "地址路径",
- id: "source",
- align: "left",
- type: "ro"
- },
- {
- name: "说明",
- id: "notes",
- align: "left",
- type: "ro"
- }]
- res_inst.aotuLoadBtn = function () {
- var _this = this;
- var v = ""
- var winoptions = {
- title: "加载资源",
- closeBtn: 1,
- closeBtn: 1,
- type: 1,
- resize: true,
- tipsMore: true,
- btn: [_t("加载"), _t("取消")],
- btn1: function (index) {
- var close = PlgDialog.loading2();
- Prolog.ajax({
- type: "post",
- url: APIS.resource.importInterface(),
- data: { serviceName: v },
- success: function (response) {
- if (response.success) {
- res_inst.PlgGridInstance.reload()
- PlgDialog.close(index);
- PlgDialog.msg("加载成功")
- } else {
- PlgDialog.msg(response.message)
- }
- },
- complete :function(){
- close()
- }
- });
- },
- btn2: function (param) { },
- area: [800 + 'px', 600 + 'px'],
- content: '<div id="' + aotu_opts.renderer + '"></div>',
- success: function (lyaer, index) {
- res_inst.autoLoadInsta = new PlgGrid(setConfig(aotu_opts));
- var myForm = res_inst.autoLoadInsta.getToolBarForm();
- var myCombo = myForm.getCombo("serviceName");
- res_inst.autoLoadInsta.getToolBarForm().on("onChange", function () {
- v = myCombo.getSelectedValue();
- res_inst.autoLoadInsta.setParams({ serviceName: v });
- res_inst.autoLoadInsta.reload();
- })
- myForm.loadComboData("serviceName");
- }
- }
- PlgDialog.open(winoptions);
- }
- })()
- </script>
|