123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>添加项目</title>
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
- <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
- <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
- </head>
- <body>
- <div class="layui-fluid">
- <div class="layui-card">
- <div class="layui-card-body" pad15>
- <div class="layui-row layui-col-space15">
- <div class="layui-col-md12">
- <div class="layui-col-md12">
- <div class="layui-col-sm6">
- <input type="text" autocomplete="off" class="layui-input" id="repair-keyword" placeholder="请输入名称/代码/助记码搜索"/>
- </div>
- <div class="layui-col-sm6">
- <button type="button" class="layui-btn" data-type="onSearchPurchase">
- <i class="layui-icon layui-icon-search"></i> 搜索
- </button>
- <button type="button" class="layui-btn layui-btn-warm" id="btn_create_consumable" data-permission="material.add_consumable"><i
- class="layui-icon layui-icon-add-circle"></i> 新建耗材
- </button>
- <button type="button" class="layui-btn layui-btn-warm" id="btn_create_material" data-permission="material.add_material"><i
- class="layui-icon layui-icon-add-circle"></i> 新建原料
- </button>
- </div>
- <div style="clear:both;height: 5px;"></div>
- </div>
- <div class="layui-col-md12">
- <table id="dataTable" lay-filter="dataTable" class="layui-hide"></table>
- </div>
- <button class="layui-btn" lay-submit id="btn_search_product_ok" style="display: none">确定</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script src="../../layuiadmin/layui/layui.js"></script>
- <script>
- layui.config({
- base: '../../../layuiadmin/' //静态资源所在路径
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'table'], function(){
- var $ = layui.$
- ,table = layui.table;
- var type = layui.view.getParameterByName('type');
- var warehouse = layui.view.getParameterByName('warehouse');
- if (type) {
- if (type == 0){
- $('#btn_create_consumable').css({'display': 'none'});
- }else if(type == 1) {
- $('#btn_create_material').css({'display': 'none'});
- }
- }
- $('#btn_search_product_ok').on('click', function () {
- var oldData = table.cache[layTableId];
- var data = [];
- for (var i in oldData){
- if(oldData[i].LAY_CHECKED){
- data.push(oldData[i])
- }
- }
- parent.layui.onSubmitChild(data);
- });
- parent.layui.submitChild = function () {
- $("#btn_search_product_ok").click();
- };
- var tbWidth = $("#tableRes").width();
- var layTableId = "layTable";
- var tableIns = table.render({
- elem: '#dataTable',
- id: layTableId,
- data: [],
- width: tbWidth,
- page: true,
- loading: true,
- even: true, //不开启隔行背景
- cols: [[
- {title: '序号', type: 'numbers'},
- {title: 'ck', type: 'checkbox'},
- {field: 'name', title: '名称', width: 150},
- {field: 'model', title: '代码', width: 150},
- {field: 'unit', title: '单位', width: 150},
- {field: 'standard', title: '规格', width: 150},
- {field: 'type_text', title: '产品类别', minWidth: 150},
- {field: 'option_type_text', title: '类型', minWidth: 150},
- {field: 'warehouse_place', title: '库位', minWidth: 150}
- ]]
- ,done:function () {
- layui.index.removeNoPermButtons();
- }
- });
- //定义事件集合
- var active = {
- onSearchPurchase: function(){
- var $ = layui.$;
- var value = $('#repair-keyword').val();
- var admin = layui.admin;
- admin.req({
- url: '/purchase/search_product/?param=' + value + '&type=' + type + '&warehouse=' + warehouse,
- done: function (res) {
- var data = res.data.data;
- var oldData = [];
- for (var i in data) {
- var item = data[i];
- var newRow = {
- name: item.name,
- model: item.model,
- unit: item.unit,
- option_type_text: item.option_type_text,
- type_text: item.type_text,
- warehouse_place: item.warehouse_place,
- surplus_count: item.surplus_count,
- entry_notes: item.notes,
- id: item.id,
- record_data: item.record_data,
- standard:item.standard
- };
- oldData.push(newRow);
- }
- tableIns.reload({
- data : oldData
- });
- }
- });
- },
- }
- //激活事件
- var activeByType = function (type, arg) {
- if(arguments.length === 2){
- active[type] ? active[type].call(this, arg) : '';
- }else{
- active[type] ? active[type].call(this) : '';
- }
- }
- //注册按钮事件
- $('.layui-btn[data-type]').on('click', function () {
- var type = $(this).data('type');
- activeByType(type);
- });
- active.onSearchPurchase();
- var oldOnSubmitChild = null;
- var oldSubmitChild = null;
- $(document).on('click','#btn_create_consumable',function(){
- oldOnSubmitChild = parent.layui.onSubmitChild;
- oldSubmitChild = parent.layui.submitChild;
- parent.layer.open({
- type: 2,
- title: '添加耗材',
- area: ['500px', '98%'],
- btn: ['保存', '取消'],
- end: function() {
- parent.layui.onSubmitChild = oldOnSubmitChild;
- parent.layui.submitChild = oldSubmitChild;
- },
- yes: function(index, dom){
- parent.layui.onSubmitChild = function (data) {
- parent.layer.close(index);
- };
- parent.layui.submitChild();
- },
- btn2: function(index, layero){
- parent.layer.close(index);//关闭当前按钮
- },
- content: '/views/material/consumable_edit.html'
- });
- });
- $(document).on('click','#btn_create_material',function(){
- oldOnSubmitChild = parent.layui.onSubmitChild;
- oldSubmitChild = parent.layui.submitChild;
- parent.layer.open({
- type: 2,
- title: '添加原料',
- area: ['500px', '98%'],
- btn: ['保存', '取消'],
- end: function() {
- parent.layui.onSubmitChild = oldOnSubmitChild;
- parent.layui.submitChild = oldSubmitChild;
- },
- yes: function(index, dom){
- parent.layui.onSubmitChild = function (data) {
- parent.layer.close(index);
- };
- parent.layui.submitChild();
- },
- btn2: function(index, layero){
- parent.layer.close(index);//关闭当前按钮
- },
- content: '/views/material/material_edit.html'
- });
- });
- });
- </script>
- </body>
- </html>
|