123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- ;
- layui.config({
- base: "../../js/layuiPlugins/"
- }).use(['form', 'layer', 'jquery', 'table', 'laytpl'], function () {
- var form = layui.form,
- layer = layui.layer,
- laytpl = layui.laytpl,
- $ = layui.jquery,
- table = layui.table;
- var funcName = "pdinfo";
- var funcName2 = "pdinfo2";
- form.verify({
- namelength: [
- /^.{0,12}$/,
- "长度限制在0-12个字符噢"
- ]
- });
- //批次的处理
- //工具条处理
- function toolOperating(obj) {
- var data = obj.data;
- if (obj.event === 'del') {
- layer.confirm('真的删除吗?', function (index) {
- layer.close(index);
- var index1 = layer.msg('删除中,请稍候', {
- icon: 16,
- time: false,
- shade: 0.8
- });
- $.ajax({
- type: "get",
- url: 'delete_' + funcName + '?guid=' + obj.data.guid,
- success: function (res) {
- layer.close(index1);
- if (!(res.code - 0)) {
- obj.del();
- table.reload(funcName);
- }
- }
- });
- });
- } else if (obj.event === 'edit') { //修改
- layer.open({
- type: 2,
- anim: 0,
- title: "修改",
- area: ['80%', '80%'],
- fixed: true,
- scrollbar: true,
- maxmin: true,
- content: 'add_change.html?event=edit&guid=' + data.guid,
- end: function () {
- table.reload(funcName); //重新载入表格
- }
- });
- } else if (obj.event === 'view') { //查看
- layer.open({
- type: 2,
- anim: 0,
- title: "查看",
- area: ['80%', '80%'],
- fixed: true,
- scrollbar: true,
- maxmin: true,
- content: 'add_change.html?event=view&guid=' + data.guid,
- end: function () {
- }
- });
- } else if (obj.event === 'code') { //生成溯源码
- layer.open({
- type: 2,
- anim: 0,
- title: "生成溯源码",
- area: ['300px', '240px'],
- fixed: true,
- scrollbar: true,
- maxmin: true,
- content: 'add_change3.html?event=code&guid=' + data.guid,
- end: function () {
- }
- });
- }
- }
- //列表
- var DataList = {
- id: funcName,
- elem: '#DataTable',
- url: funcName + 'List',
- page: true,
- method: "post",
- contentType: 'application/json',
- loading: true,
- cellMinWidth: 80,
- cols: [
- [ //标题栏
- {
- field: 'goodsBatchNo',
- title: '批次编码',
- align: 'left',
- }, {
- field: 'goodsName',
- title: '产品分类',
- align: 'left',
- }, {
- field: 'goodsUnit',
- title: '产品规格',
- align: 'left',
- }, {
- field: 'goodsProductDate',
- title: '生产日期',
- align: 'center'
- }, {
- field: 'goodsExpired',
- title: '保质期',
- align: 'center'
- }, {
- field: 'operating',
- title: '操作',
- toolbar: '#operatingTool',
- align: 'center',
- fixed: 'right',
- width: 240
- }
- ]
- ] //设置表头
- , done: function (res) {
- resetButton(layui.sessionData(window.hywa.sessionTable.tableName).userData.menus.subMenuList, $);
- //res.button.add ? $('.add-btn-0').show() : $('.add-btn-0').hide();
- }
- };
- //执行默认渲染表格
- table.render(DataList);
- //监听产品工具事件条
- table.on('tool(DataTable)', function (obj) {
- toolOperating(obj);
- });
- //搜索响应函数
- var infoSearch = function (obj) {
- table.reload(funcName, { //执行重载
- where: obj.field
- });
- return false;
- };
- //监听搜索表单事件
- form.on("submit(DataSearch)", infoSearch);
- var pdName = "", pid = "";
- $("#addBtn").on("click", function () {
- if (pdName == "") {
- layer.msg("请先选择一个产品");
- return;
- }
- layer.open({
- type: 2,
- anim: 0,
- title: "新增",
- area: ['90%', '90%'],
- fixed: true,
- scrollbar: true,
- maxmin: true,
- content: 'add_change.html?pdName=' + pdName + '&pid=' + pid,
- end: function () {
- table.reload(funcName);
- }
- });
- });
- //产品的处理
- //工具条处理
- function toolOperating2(obj) {
- var data = obj.data;
- if (obj.event === 'del') {
- layer.confirm('真的删除吗?', function (index) {
- layer.close(index);
- var index1 = layer.msg('删除中,请稍候', {
- icon: 16,
- time: false,
- shade: 0.8
- });
- $.ajax({
- type: "get",
- url: 'delete_' + funcName2 + '?guid=' + obj.data.guid,
- success: function (res) {
- layer.close(index1);
- if (!(res.code - 0)) {
- obj.del();
- table.reload(funcName2);
- }
- }
- });
- });
- } else if (obj.event === 'edit') { //修改
- layer.open({
- type: 2,
- anim: 0,
- title: "修改",
- area: ['300px', '200px'],
- fixed: true,
- scrollbar: true,
- maxmin: true,
- content: 'add_change2.html?event=edit&guid=' + data.guid,
- end: function () {
- table.reload(funcName2); //重新载入表格
- }
- });
- }
- }
- //列表
- var DataList2 = {
- id: funcName2,
- elem: '#DataTable2',
- url: funcName2 + 'List',
- page: true,
- method: "post",
- contentType: 'application/json',
- loading: true,
- cellMinWidth: 80,
- cols: [
- [ //标题栏
- {
- field: 'goodsName',
- title: '产品分类',
- align: 'left',
- }, {
- field: 'operating',
- title: '操作',
- toolbar: '#operatingTool2',
- align: 'center',
- fixed: 'right',
- width: 120
- }
- ]
- ] //设置表头
- , done: function (res) {
- resetButton(layui.sessionData(window.hywa.sessionTable.tableName).userData.menus.subMenuList, $);
- //res.button.add ? $('.add-btn-0').show() : $('.add-btn-0').hide();
- }
- };
- //执行默认渲染表格
- table.render(DataList2);
- //监听产品工具事件条
- table.on('tool(DataTable2)', function (obj) {
- toolOperating2(obj);
- });
- table.on('row(DataTable2)', function (obj) {
- $(".my-search")[0].value = obj.data.goodsName;
- $(".my-search")[1].value = "";
- pdName = obj.data.goodsName;
- pid = obj.data.guid;
- infoSearch({ field: { goodsName: obj.data.goodsName, goodsBatchNo: obj.data.goodsBatchNo, } })
- });
- //搜索响应函数
- var infoSearch2 = function (obj) {
- table.reload(funcName2, { //执行重载
- where: obj.field
- });
- return false;
- };
- //监听搜索表单事件
- form.on("submit(DataSearch2)", infoSearch2);
- $("#addBtn2").on("click", function () {
- layer.open({
- type: 2,
- anim: 0,
- title: "新增",
- area: ['300px', '200px'],
- fixed: true,
- scrollbar: true,
- maxmin: true,
- content: 'add_change2.html',
- end: function () {
- table.reload(funcName2);
- }
- });
- });
- });
|