|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
- * Copyright (c) 2013-2018 北京泉江科技有限公司
- * 创建人:超级管理员
- * 日 期:2019-03-29 10:33
- * 描 述:采购
- */
- var refreshGirdData;
- var selectedRow;
- var bootstrap = function ($, learun) {
- "use strict";
- var startTime;
- var endTime;
- var processId = '';
- var page = {
- init: function () {
- page.initGird();
- page.bind();
- },
- bind: function () {
- // 时间搜索框
- $('#datesearch').lrdate({
- dfdata: [
- { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
- { name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
- { name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
- { name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }
- ],
- // 月
- mShow: false,
- premShow: false,
- // 季度
- jShow: false,
- prejShow: false,
- // 年
- ysShow: false,
- yxShow: false,
- preyShow: false,
- yShow: false,
- // 默认
- dfvalue: '1',
- selectfn: function (begin, end) {
- startTime = begin;
- endTime = end;
- page.search();
- }
- });
- $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
- page.search(queryJson);
- }, 220, 400);
- // 刷新
- $('#lr_refresh').on('click', function () {
- location.reload();
- });
- // 新增
- $('#lr_add').on('click', function () {
- learun.layerForm({
- id: 'formAss_Purchase',
- title: '新增',
- url: top.$.rootUrl + '/AssetManagementSystem/Ass_Purchase/Form',
- width: 1000,
- height: 600,
- callBack: function (id) {
- var res = false;
- // 验证数据
- res = top[id].validForm();
- // 保存数据
- if (res) {
- //processId = learun.newGuid();
- //res = top[id].save(processId, refreshGirdData);
- res = top[id].save('', function () {
- page.search();
- });
- }
- return res;
- }
- });
- });
- // 编辑
- $('#lr_edit').on('click', function () {
- var keyValue = $('#gridtable').jfGridValue('PId');
- selectedRow = $('#gridtable').jfGridGet('rowdata');
- if (learun.checkrow(keyValue)) {
- if (selectedRow.PStatus == 2) {//已采购
- learun.alert.warning("当前采购记录已完成采购!");
- return false;
- }
- learun.layerForm({
- id: 'formAss_Purchase',
- title: '编辑',
- url: top.$.rootUrl + '/AssetManagementSystem/Ass_Purchase/Form?keyValue=' + keyValue,
- width: 1000,
- height: 600,
- callBack: function (id) {
- var res = false;
- // 验证数据
- res = top[id].validForm();
- // 保存数据
- if (res) {
- res = top[id].save('', function () {
- page.search();
- });
- }
- return res;
- }
- });
- }
- });
- // 删除
- $('#lr_delete').on('click', function () {
- var keyValue = $('#gridtable').jfGridValue('PId');
- if (learun.checkrow(keyValue)) {
- learun.layerConfirm('是否确认删除该项!', function (res) {
- if (res) {
- learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_Purchase/DeleteForm', { keyValue: keyValue }, function () {
- //refreshGirdData();
- page.search();
- });
- }
- });
- }
- });
- //开始采购
- $('#lr_start').on('click', function () {
- var keyValue = $('#gridtable').jfGridValue('PId');
- selectedRow = $('#gridtable').jfGridGet('rowdata');
- if (learun.checkrow(keyValue)) {
- if (selectedRow.PStatus == 1) {
- learun.alert.warning("当前采购已经开始!");
- return false;
- }
- else if (selectedRow.PStatus == 2) {
- learun.alert.warning("当前采购已经完成!");
- return false;
- }
- learun.layerForm({
- id: 'startformAss_Purchase',
- title: '开始采购',
- url: top.$.rootUrl + '/AssetManagementSystem/Ass_Purchase/StartForm?keyValue=' + keyValue + '&PAId=' + selectedRow.PAId,
- width: 1000,
- height: 700,
- callBack: function (id) {
- return top[id].acceptClick( function () { page.search(); });
- }
- });
- }
- });
- // 完成采购
- $('#lr_submit').on('click', function () {
- var keyValue = $('#gridtable').jfGridValue('PId');
- selectedRow = $('#gridtable').jfGridGet('rowdata');
- if (learun.checkrow(keyValue)) {
- if (selectedRow.PStatus == 0) {
- learun.alert.warning("当前采购还未开始!");
- return false;
- } else if (selectedRow.PStatus == 2) {
- learun.alert.warning("当前采购已经完成!");
- return false;
- }
- learun.layerForm({
- id: 'formAss_Purchase',
- title: '完成采购',
- url: top.$.rootUrl + '/AssetManagementSystem/Ass_Purchase/Form?keyValue=' + keyValue+'&PAId='+selectedRow.PAId,
- width: 1000,
- height: 600,
- callBack: function (id) {
- var res = false;
- // 验证数据
- res = top[id].validForm();
- // 保存数据
- if (res) {
- res = top[id].save('', function () {
- page.search();
- });
- }
- return res;
- }
- });
- }
- });
- // 查看
- $('#lr_view').on('click', function () {
- var keyValue = $('#gridtable').jfGridValue('PId');
- selectedRow = $('#gridtable').jfGridGet('rowdata');
- if (learun.checkrow(keyValue)) {
- if (selectedRow.PStatus !== 2) {
- learun.alert.warning("当前采购未完成,请完成后再查看!");
- return false;
- }
- learun.layerForm({
- id: 'formviewAss_Purchase',
- title: '查看',
- url: top.$.rootUrl + '/AssetManagementSystem/Ass_Purchase/FormView?keyValue=' + keyValue,
- width: 1000,
- height: 600,
- btn: null
- });
- }
- });
- },
- // 初始化列表
- initGird: function () {
- $('#gridtable').lrAuthorizeJfGrid({
- url: top.$.rootUrl + '/AssetManagementSystem/Ass_Purchase/GetPageList',
- headData: [
- { label: "采购申请单号", name: "PACode", width: 200, align: "left" },
- { label: "预计采购时间", name: "PEstimateTime", width: 130, align: "left" },
- { label: "实际采购时间", name: "PActualTime", width: 130, align: "left" },
- {
- label: "采购人", name: "PUserId", width: 100, align: "left"
- },
- {
- label: "资产属性", name: "PAssType", width: 100, align: "left",
- formatterAsync: function (callback, value, row, op, $cell) {
- learun.clientdata.getAsync('dataItem', {
- key: value,
- code: 'AssType',
- callback: function (_data) {
- callback(_data.text);
- }
- });
- }
- },
- { label: "采购总价", name: "PActualPrice", width: 100, align: "left" },
- {
- label: "采购状态", name: "PStatus", width: 100, align: "left",
- formatter: function (cellvalue, row) {
- if (cellvalue == 1) {
- return '<span class=\"label label-warning\" >采购中</span>';
- } else if (cellvalue == 2) {
- return '<span class=\"label label-success\" >已采购</span>';
- } else {
- return '<span class=\"label label-default\" >未采购</span>';
- }
- }
- },
- {
- label: "入库状态", name: "PStoregeStatus", width: 100, align: "left",
- formatter: function (cellvalue, row) {
- if (cellvalue == 1) {
- return '<span class=\"label label-warning\" >入库中</span>';
- } else if (cellvalue == 2) {
- return '<span class=\"label label-success\" >已入库</span>';
- } else {
- return '<span class=\"label label-default\" >未入库</span>';
- }
- }
- },
- ],
- mainId: 'PId',
- isPage: true,
- sidx: 'PActualTime',
- sord:'DESC'
- });
- },
- search: function (param) {
- param = param || {};
- //param.StartTime = startTime;
- //param.EndTime = endTime;
- $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
- }
- };
- refreshGirdData = function (res, postData) {
- if (res.code == 200) {
- // 发起流程
- learun.workflowapi.create({
- isNew: true,
- schemeCode: '',// 填写流程对应模板编号
- processId: processId,
- processName: '系统表单流程',// 对应流程名称
- processLevel: '1',
- description: '',
- formData: JSON.stringify(postData),
- callback: function (res, data) {
- }
- });
- page.search();
- }
- };
- page.init();
- }
|