| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924 |
- requirejs.config({
- paths: {
- vue: 'backend/stock/libs/vue',
- ELEMENT: 'backend/stock/libs/element-ui',
- },
- shim: {
- ELEMENT: ['vue']
- }
- })
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'vue', 'ELEMENT', 'moment'], function ($, undefined, Backend, Table, Form, Vue, ELEMENT, Moment) {
- var Controller = {
- index: function () {
- $('.btn-add,.btn-edit,.btn-audit,.btn-settle,.btn-split').data("area", ['100%', '100%']);
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'stock/stockout/index',
- add_url: 'stock/stockout/add',
- edit_url: 'stock/stockout/edit',
- del_url: 'stock/stockout/del',
- multi_url: 'stock/stockout/multi',
- table: 'stock_stockout',
- }
- });
- var table = $("#table");
- $.fn.bootstrapTable.locales[Table.defaults.locale]['formatSearch'] = function () {
- return '搜索[单据编号、客户名称]';
- };
- var selfOperate = {
- 'click .btn-editone': function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- if (!row.audittime) {
- var table = $(this).closest('table');
- var options = table.bootstrapTable('getOptions');
- var ids = row[options.pk];
- row = $.extend({}, row ? row : {}, { ids: ids });
- var url = options.extend.edit_url;
- Fast.api.open(Table.api.replaceurl(url, row, table), __('Edit'), $(this).data() || {});
- } else {
- Toastr.error('该出库记录已通过审核,不能修改!')
- }
- ;
- },
- 'click .btn-delone': function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- var that = this;
- var top = $(that).offset().top - $(window).scrollTop();
- var left = $(that).offset().left - $(window).scrollLeft() - 260;
- if (top + 154 > $(window).height()) {
- top = top - 154;
- }
- if ($(window).width() < 480) {
- top = left = undefined;
- }
- if (!row.auditTime) {
- Layer.confirm(
- __('Are you sure you want to delete this item?'), { icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true },
- function (index) {
- var table = $(that).closest('table');
- var options = table.bootstrapTable('getOptions');
- Table.api.multi("del", row[options.pk], table, that);
- Layer.close(index);
- }
- );
- } else {
- Toastr.error('该出库记录已通过审核,不能删除!')
- }
- ;
- }
- }
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- sortName: 'createtime',
- singleSelect: true, //是否启用单选
- columns: [
- [
- { checkbox: true },
- {field: 'Uniqid', title: __('出库编号'), },
- {field: '生产款号', title: __('生产款号'),operate: 'LIKE' },
- {field: '订单编号', title: __('订单编号'),operate: 'LIKE', sortable: true },
- {field: '客户编号', title: __('客户编号'), },
- {field: '款式', title: __('款式'), },
- {field: '订单数量', title: __('订单数量'), },
- {field: '面料', title: __('面料'), },
- {field: '出库日期', title: __('出库日期'), },
- {field: 'Sys_rq', title: __('下单日期'), },
- // { field: 'operate', title: __('Operate'), table: table, events: selfOperate, formatter: Table.api.formatter.operate }
- ]
- ],
- onPostBody: function () {
- $(".btn-editone ").data("area", ['100%', '100%']);
- },
- onCheck: function(row, $elment, filed) {
- $('.btn-print').removeClass('disabled');
- $('.btn-print').removeClass('btn-disabled');
- },
- onUncheck: function() {
- $('.btn-print').addClass('disabled');
- $('.btn-print').addClass('btn-disabled');
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 打印按钮事件
- $('.toolbar').on('click', '.btn-print', function () {
- console.log('打印')
- var that = this;
- var selectedrow = table.bootstrapTable('getSelections');
- console.log(selectedrow)
- if (selectedrow.length == 1) {
- Fast.api.open('stock/stockout/printer?id=' + selectedrow[0]['Uniqid'], __('打印'), $(that).data() || {});
- } else {
- Toastr.error(selectedrow.length > 1 ? '只能选择一条入库记录' : '请选择入库记录')
- }
- });
- // 批量编辑按钮事件
- $('.btn-edit').click(function (event) {
- event.stopPropagation();
- var selectedrow = table.bootstrapTable('getSelections');
- console.log(selectedrow);
- if (selectedrow.length == 1 && !selectedrow[0]['audittime']) {
- var that = this;
- var url = 'stock/stockout/edit';
- selectedrow[0] = $.extend({}, selectedrow[0] ? selectedrow[0] : {}, { ids: selectedrow[0]['id'] });
- var url = Table.api.replaceurl(url, selectedrow[0], table);
- Fast.api.open(url, __('Edit'), $(that).data() || {});
- } else {
- if (selectedrow[0]['audittime']) {
- Toastr.error('该记录已审核,不能修改!')
- } else {
- Toastr.error(selectedrow.length > 1 ? '只能选择一条记录' : '请选择一条记录')
- }
- }
- });
- // 审核/反审核按钮事件 结算/反结算按钮事件
- $('.toolbar').on('click', '.btn-audit,.btn-settle', function () {
- var that = this;
- var selectedrow = table.bootstrapTable('getSelections');
- var title = "审核";
- if (selectedrow.length == 1) {
- var operatetype = $(this).data("operatetype");
- if (operatetype == "audit") {
- console.log(selectedrow[0].settletime);
- if (selectedrow[0].settletime !== null) {
- Toastr.error("该出库单已结算,请先进行反结算!");
- return;
- } else {
- title = selectedrow[0].audittime == null ? "审核" : "反审核";
- }
- } else if (operatetype == "settle") {
- if (selectedrow[0].audittime == null) {
- Toastr.error("该出库单未审核,请先进行审核!");
- return;
- } else {
- title = selectedrow[0].settletime == null ? "结算" : "反结算";
- }
- }
- var url = 'stock/stockout/look?operatetype=' + operatetype;
- selectedrow[0] = $.extend({}, selectedrow[0] ? selectedrow[0] : {}, { ids: selectedrow[0]['id'] });
- var url = Table.api.replaceurl(url, selectedrow[0], table);
- Fast.api.open(url, title, $(that).data() || {});
- } else {
- Toastr.error(selectedrow.length > 1 ? '只能选择一条记录' : '请选择一条记录')
- }
- });
- },
- getlist: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- list_url: 'stock/stockout/getlist',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.list_url,
- pk: 'id',
- sortName: 'stockoutlist.id',
- height: $(window).height() - 97,
- columns: [
- [
- { checkbox: true },
- {
- field: 'id',
- title: __('Id'),
- },
- { field: 'stockout.docnum', operate: "LIKE", title: __('单据编号') },
- { field: 'stockout.customer.name', operate: "LIKE", title: __('客户名称'), sortable: true },
- { field: 'goods.volnum', title: '商品代码' },
- { field: 'goods.goodsname', title: '商品名称' },
- { field: 'goods.productmodel', title: '规格型号' },
- { field: 'goods.measureunit', title: '单位' },
- { field: 'stockoutnums', type: "Number", title: '出库数量' },
- { field: 'stockin.inboundprice', title: '单价', operate: 'BETWEEN' },
- { field: 'amount', title: '重量(kg)', operate: 'BETWEEN' },
- { field: 'stockout.outboundtime', title: '出库日期', operate: 'RANGE', formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD', addclass: 'datetimerange', sortable: true },
- { field: 'remark', title: __('Remark') },
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- look: function () {
- Vue.use(ELEMENT);
- var vm = new Vue({
- el: "#app",
- data: function () {
- return {
- row: { stock_customer_id: "", remark: "", outboundtime: "", docnum:"" },
- selectedgoodsdata: {
- table: { height: ($(window).height() - 355) + "px" },
- list: [],
- },
- commiturl: "",
- }
- },
- computed: {
- goodslist: function () { return JSON.stringify(this.selectedgoodsdata.list) },
- },
- created() {
- this.loadstockoutinfo()
- },
- methods: {
- loadstockoutinfo() {
- let operatetype = Fast.api.query("operatetype")
- let that = this;
- $.ajax({
- url: 'stock/stockout/info',
- type: "POST",
- data: { id: Fast.api.query("ids") },
- async: false,
- success: function (res) {
- res.row.outboundtime = Moment(parseInt(res.row.outboundtime) * 1000).format("YYYY-MM-DD");
- if (operatetype == "audit") {
- if (res.row.audittime) {
- that.commiturl = 'stock/stockout/unaudit';
- $('#audit').html('反审核');
- } else {
- that.commiturl = 'stock/stockout/audit';
- $('#audit').html('审核');
- }
- } else if (operatetype == "settle") {
- if (res.row.settletime) {
- that.commiturl = 'stock/stockout/unsettle';
- $('#audit').html('反结算');
- } else {
- that.commiturl = 'stock/stockout/settle';
- $('#audit').html('结算');
- }
- }
- that.row = res.row;
- that.selectedgoodsdata.list = res.goodslist;
- },
- error: function (res) {
- Toastr.error("加载失败!")
- }
- })
- }
- }
- })
- // 提交事件
- $(document).on('click', '#audit', function (e) {
- e.preventDefault();
- var url = $("#c-commiturl").val();
- Layer.confirm(
- __('确认提交?'), { icon: 3, title: __('Warning'), offset: 200, shadeClose: true },
- function (index) {
- $('#form').attr('action', url);
- $('#form').submit();
- Layer.close(index);
- }
- );
- });
- Form.api.bindevent($("form[role=form]"));
- },
- add: function () {
- Vue.use(ELEMENT);
- var vm = new Vue({
- el: "#app",
- data: function () {
- return {
- searchvalue: "",
- row: { stock_customer_id: "", remark: "", outboundtime: new Date() },
- curgood: { stock_goods_id: "", volnum: "", goodsname: "", productmodel: "", measureunit: "件", stocknum: "", stockoutnums: 0, stockoutgoodsremark: "", barcode: "" },
- defaultgood: { stock_goods_id: "", volnum: "", goodsname: "", productmodel: "", measureunit: "件", stocknum: "", stockoutnums: 0, stockoutgoodsremark: "", barcode: "" },
- customerlist: [],
- goodsdata: {
- table: { height: ($(window).height() - 490) + "px" },
- list: [],
- pagenation: {
- currentpage: 1,
- pagesize: 10,
- total: 0
- }
- },
- selectedgoodsdata: {
- table: { height: ($(window).height() - 310) + "px" },
- list: [],
- },
- rules: {
- stockinnums: [
- { required: true, message: '出库数量不能为空' },
- { type: 'number', message: '出库数量必须为数字值' }
- ],
- }
- }
- },
- computed: {
- main: function () { return JSON.stringify(this.row) },
- goodslist: function () { return JSON.stringify(this.selectedgoodsdata.list) }
- },
- created() {
- this.loadgoodslist()
- this.loadcustomerlist()
- },
- methods: {
- loadcustomerlist() {
- let that = this;
- $.ajax({
- url: 'stock/customer/index',
- data: {},
- success: function (res) {
- that.customerlist = res.rows;
- },
- error: function (res) {
- Toastr.error("加载失败!")
- }
- })
- },
- loadgoodslist() {
- let that = this;
- $.ajax({
- url: 'stock/goods/getlist',
- data: { sort: 'goods.id', order: 'desc', offset: this.goodsdata.pagenation.pagesize * (this.goodsdata.pagenation.currentpage - 1), limit: this.goodsdata.pagenation.pagesize, searchvalue: this.searchvalue },
- success: function (res) {
- that.goodsdata.list = res.rows;
- that.goodsdata.pagenation.total = res.total;
- },
- error: function (res) {
- Toastr.error("加载失败!")
- }
- })
- },
- handleSizeChange(val) {
- this.goodsdata.pagenation.pagesize = val;
- this.loadgoodslist();
- },
- handleCurrentChange(val) {
- this.goodsdata.pagenation.currentpage = val;
- this.loadgoodslist();
- },
- debounce(fn, delay) {
- let timeout = null;
- delay = delay || 500;
- return function (e) {
- let args = arguments;
- let that = this;
- clearTimeout(timeout);
- timeout = setTimeout(function () {
- fn.apply(that, args);
- }, delay);
- };
- },
- barcodeinputenter() {
- let that = this;
- if (this.curgood.barcode == "") {
- Fast.api.msg("请输入商品条码并按回车键!")
- } else {
- Fast.api.ajax({
- url: "stock/goods/getgoodsbybarcodeorid",
- data: { barcode: this.curgood.barcode }
- }, function (data) {
- if (data !== null) {
- that.curgood.stock_goods_id = data.id;
- that.curgood.volnum = data.volnum;
- that.curgood.goodsname = data.goodsname;
- that.curgood.productmodel = data.productmodel;
- that.curgood.measureunit = data.measureunit;
- that.curgood.stockoutnums = data.curstocknum >= 1 ? 1 : 0;
- that.curgood.stocknum = data.curstocknum;
- that.curgood.stockoutgoodsremark = "";
- }
- })
- }
- },
- onSearchvalueChange() {
- this.debounce(this.loadgoodslist, 1000)();
- },
- selectonegood(currentrow) {
- let that = this;
- Fast.api.ajax({
- url: "stock/goods/getgoodsbybarcodeorid",
- data: { id: currentrow.id }
- }, function (data) {
- if (data !== null) {
- that.curgood.stock_goods_id = data.id;
- that.curgood.volnum = data.volnum;
- that.curgood.goodsname = data.goodsname;
- that.curgood.productmodel = data.productmodel;
- that.curgood.measureunit = data.measureunit;
- that.curgood.barcode = data.barcode;
- that.curgood.stockoutnums = data.curstocknum >= 1 ? 1 : 0;
- that.curgood.stocknum = data.curstocknum;
- that.curgood.stockoutgoodsremark = "";
- }
- })
- },
- addtolist() {
- let that = this;
- let hasadded = false;
- if (this.curgood.stock_goods_id != "") {
- if (this.curgood.stockoutnums == 0) {
- Fast.api.msg("出库数量不能为0!");
- return;
- }
- if (this.curgood.stockoutnums > this.curgood.stocknum) {
- Fast.api.msg("出库数量不能大于库存数量,请修改!");
- return;
- }
- this.selectedgoodsdata.list.forEach(item => {
- if (item.stock_goods_id == that.curgood.stock_goods_id) {
- Fast.api.msg("该商品已添加,请勿重复添加!")
- hasadded = true;
- }
- });
- if (!hasadded) {
- let good = JSON.parse(JSON.stringify(this.curgood));
- this.selectedgoodsdata.list.unshift(good);
- this.curgood = JSON.parse(JSON.stringify(this.defaultgood));
- }
- } else {
- Fast.api.msg("请选择出库商品!")
- }
- },
- reset() {
- this.curgood = JSON.parse(JSON.stringify(this.defaultgood));
- },
- getcurgoodamount() {
- this.curgood.amount = this.accMul(this.curgood.stockinnums, this.curgood.inboundprice);
- },
- accMul(arg1, arg2) {
- var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
- try {
- m += s1.split(".")[1].length
- } catch (e) {
- }
- try {
- m += s2.split(".")[1].length
- } catch (e) {
- }
- return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
- },
- accAdd(arg1, arg2) {
- var r1, r2, m;
- try {
- r1 = arg1.toString().split(".")[1].length
- } catch (e) {
- r1 = 0
- }
- try {
- r2 = arg2.toString().split(".")[1].length
- } catch (e) {
- r2 = 0
- }
- m = Math.pow(10, Math.max(r1, r2))
- return (arg1 * m + arg2 * m) / m
- },
- accSub(arg1, arg2) {
- var r1, r2, m, n;
- try {
- r1 = arg1.toString().split(".")[1].length;
- } catch (e) {
- r1 = 0;
- }
- try {
- r2 = arg2.toString().split(".")[1].length;
- } catch (e) {
- r2 = 0;
- }
- m = Math.pow(10, Math.max(r1, r2));
- //last modify by deeka
- //动态控制精度长度
- n = (r1 >= r2) ? r1 : r2;
- return ((arg1 * m - arg2 * m) / m).toFixed(n);
- },
- deleteselected(row) {
- this.selectedgoodsdata.list = this.selectedgoodsdata.list.filter(item => {
- return item != row;
- });
- this.row.totalamount = this.accSub(this.row.totalamount, row.amount);
- }
- }
- })
- Form.api.bindevent($("form[role=form]"), "", "", function () {
- let main = JSON.parse($("#c-main").val());
- let goodslist = JSON.parse($("#c-goodslist").val());
- if (main.stock_customer_id == "") {
- Toastr.error("请选择客户");
- return false;
- } else if (goodslist.length < 1) {
- Toastr.error("请添加出库商品");
- return false;
- }
- });
- },
- edit: function () {
- Vue.use(ELEMENT);
- var vm = new Vue({
- el: "#app",
- data: function () {
- return {
- searchvalue: "",
- row: { stock_customer_id: "", remark: "", outboundtime: new Date() },
- curgood: { stock_goods_id: "", volnum: "", goodsname: "", productmodel: "", measureunit: "件", stocknum: "", stockoutnums: 0, stockoutgoodsremark: "", barcode: "" },
- defaultgood: { stock_goods_id: "", volnum: "", goodsname: "", productmodel: "", measureunit: "件", stocknum: "", stockoutnums: 0, stockoutgoodsremark: "", barcode: "" },
- customerlist: [],
- goodsdata: {
- table: { height: ($(window).height() - 490) + "px" },
- list: [],
- pagenation: {
- currentpage: 1,
- pagesize: 10,
- total: 0
- }
- },
- selectedgoodsdata: {
- table: { height: ($(window).height() - 350) + "px" },
- list: [],
- },
- deselectedgoodslist: [],
- rules: {
- stockinnums: [
- { required: true, message: '出库数量不能为空' },
- { type: 'number', message: '出库数量必须为数字值' }
- ],
- }
- }
- },
- computed: {
- main: function () { return JSON.stringify(this.row) },
- goodslist: function () { return JSON.stringify(this.selectedgoodsdata.list) }
- },
- created() {
- this.loadstockoutinfo()
- this.loadgoodslist()
- this.loadcustomerlist()
- },
- methods: {
- loadstockoutinfo() {
- let that = this;
- $.ajax({
- url: 'stock/stockout/info',
- type: "POST",
- data: { id: Fast.api.query("ids") },
- success: function (res) {
- res.row.outboundtime = Moment(parseInt(res.row.outboundtime) * 1000).format("YYYY-MM-DD");
- console.log(res.row);
- that.row = res.row;
- that.selectedgoodsdata.list = res.goodslist;
- },
- error: function (res) {
- Toastr.error("加载失败!")
- }
- })
- },
- loadcustomerlist() {
- let that = this;
- $.ajax({
- url: 'stock/customer/index',
- data: {},
- success: function (res) {
- that.customerlist = res.rows;
- },
- error: function (res) {
- Toastr.error("加载失败!")
- }
- })
- },
- loadgoodslist() {
- let that = this;
- $.ajax({
- url: 'stock/goods/getlist',
- data: { sort: 'goods.id', order: 'desc', offset: this.goodsdata.pagenation.pagesize * (this.goodsdata.pagenation.currentpage - 1), limit: this.goodsdata.pagenation.pagesize, searchvalue: this.searchvalue },
- success: function (res) {
- that.goodsdata.list = res.rows;
- that.goodsdata.pagenation.total = res.total;
- },
- error: function (res) {
- Toastr.error("加载失败!")
- }
- })
- },
- handleSizeChange(val) {
- this.goodsdata.pagenation.pagesize = val;
- this.loadgoodslist();
- },
- handleCurrentChange(val) {
- this.goodsdata.pagenation.currentpage = val;
- this.loadgoodslist();
- },
- debounce(fn, delay) {
- let timeout = null;
- delay = delay || 500;
- return function (e) {
- let args = arguments;
- let that = this;
- clearTimeout(timeout);
- timeout = setTimeout(function () {
- fn.apply(that, args);
- }, delay);
- };
- },
- barcodeinputenter() {
- let that = this;
- if (this.curgood.barcode == "") {
- Fast.api.msg("请输入商品条码并按回车键!")
- } else {
- Fast.api.ajax({
- url: "stock/goods/getgoodsbybarcodeorid",
- data: { barcode: this.curgood.barcode }
- }, function (data) {
- if (data !== null) {
- that.curgood.stock_goods_id = data.id;
- that.curgood.volnum = data.volnum;
- that.curgood.goodsname = data.goodsname;
- that.curgood.productmodel = data.productmodel;
- that.curgood.measureunit = data.measureunit;
- that.curgood.stockoutnums = data.curstocknum >= 1 ? 1 : 0;
- that.curgood.stocknum = data.curstocknum;
- that.curgood.stockoutgoodsremark = "";
- }
- })
- }
- },
- onSearchvalueChange() {
- this.debounce(this.loadgoodslist, 1000)();
- },
- selectonegood(currentrow) {
- let that = this;
- Fast.api.ajax({
- url: "stock/goods/getgoodsbybarcodeorid",
- data: { id: currentrow.id }
- }, function (data) {
- if (data !== null) {
- that.curgood.stock_goods_id = data.id;
- that.curgood.volnum = data.volnum;
- that.curgood.goodsname = data.goodsname;
- that.curgood.productmodel = data.productmodel;
- that.curgood.measureunit = data.measureunit;
- that.curgood.barcode = data.barcode;
- that.curgood.stockoutnums = data.curstocknum >= 1 ? 1 : 0;
- that.curgood.stocknum = data.curstocknum;
- that.curgood.stockoutgoodsremark = "";
- }
- })
- },
- addtolist() {
- let that = this;
- let hasadded = false;
- if (this.curgood.stock_goods_id != "") {
- if (this.curgood.stockoutnums == 0) {
- Fast.api.msg("出库数量不能为0!");
- return;
- }
- if (this.curgood.stockoutnums > this.curgood.stocknum) {
- Fast.api.msg("出库数量不能大于库存数量,请修改!");
- return;
- }
- this.selectedgoodsdata.list.forEach(item => {
- if (item.stock_goods_id == that.curgood.stock_goods_id) {
- Fast.api.msg("该商品已添加,请勿重复添加!")
- hasadded = true;
- }
- });
- if (!hasadded) {
- let good = JSON.parse(JSON.stringify(this.curgood));
- this.selectedgoodsdata.list.unshift(good);
- this.curgood = JSON.parse(JSON.stringify(this.defaultgood));
- }
- } else {
- Fast.api.msg("请选择出库商品!")
- }
- },
- reset() {
- this.curgood = JSON.parse(JSON.stringify(this.defaultgood));
- },
- getcurgoodamount() {
- this.curgood.amount = this.accMul(this.curgood.stockinnums, this.curgood.inboundprice);
- },
- accMul(arg1, arg2) {
- var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
- try {
- m += s1.split(".")[1].length
- } catch (e) {
- }
- try {
- m += s2.split(".")[1].length
- } catch (e) {
- }
- return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
- },
- accAdd(arg1, arg2) {
- var r1, r2, m;
- try {
- r1 = arg1.toString().split(".")[1].length
- } catch (e) {
- r1 = 0
- }
- try {
- r2 = arg2.toString().split(".")[1].length
- } catch (e) {
- r2 = 0
- }
- m = Math.pow(10, Math.max(r1, r2))
- return (arg1 * m + arg2 * m) / m
- },
- accSub(arg1, arg2) {
- var r1, r2, m, n;
- try {
- r1 = arg1.toString().split(".")[1].length;
- } catch (e) {
- r1 = 0;
- }
- try {
- r2 = arg2.toString().split(".")[1].length;
- } catch (e) {
- r2 = 0;
- }
- m = Math.pow(10, Math.max(r1, r2));
- //last modify by deeka
- //动态控制精度长度
- n = (r1 >= r2) ? r1 : r2;
- return ((arg1 * m - arg2 * m) / m).toFixed(n);
- },
- deleteselected(row) {
- if (row.id) {
- this.deselectedgoodslist.unshift(row.id);
- }
- this.selectedgoodsdata.list = this.selectedgoodsdata.list.filter(item => {
- return item != row;
- });
- this.row.totalamount = this.accSub(this.row.totalamount, row.amount);
- }
- }
- })
- Form.api.bindevent($("form[role=form]"), "", "", function () {
- let main = JSON.parse($("#c-main").val());
- let goodslist = JSON.parse($("#c-goodslist").val());
- if (main.stock_customer_id == "") {
- Toastr.error("请选择客户");
- return false;
- } else if (goodslist.length < 1) {
- Toastr.error("请添加出库商品");
- return false;
- }
- });
- },
- printer: function () {
- $.ajax({
- type: "POST",
- url: Fast.api.fixurl('stock/stockout/info'),
- data: { "id": Fast.api.query("id") },
- async: true, //或false,是否异步
- timeout: 5000, //超时时间
- dataType: 'json', //返回的数据格式:json/xml/html/script/jsonp/text
- success: function (data) {
- console.log(data)
- madehtml(data);
- }
- });
- function madehtml(data) {
- var h = "<div id=\"top\" class=\"page\"><div style=\"text-align: center;font-size:22px;line-height:38px; padding-bottom: 55px; position: relative; \" >出库单</div>" +
- "<div id=\"qrcode\" style=\"width:80px; height:80px; position: absolute; right: 32px; top: 30px;\"></div>" + // 添加二维码容器
- "<table style=\"width:100%;\" class=\"row2\">" +
- " <tr>" +
- " <td width=\"40%\"></td>" +
- "<td width=\"25%\"></td>" +
- // "<td width=\"12%\" tdata=\"pageNO\" format=\"##\" style=\"text-align:right;\">第页</td>" +
- // "<td width=\"13%\" tdata=\"pageCount\" format=\"##\" style=\"text-align:right;\"> 共页</td>" +
- " </tr>" +
- "<tr>" +
- "<td >客户号:" + data.goodslist.客户编号+ "</td>" +
- "<td>日期:" + Moment().format("YYYY-MM-DD") + "</td>"+
- "<td colspan=\"2\" style=\"text-align:right;\">单据号:CK202411061753001</td>" +
- "</tr>" +
- "</table>" +
- "</div>" +
- "<div id=\"maintable\"><table border=\"1\" style=\"width:100%;\">" +
- "<thead ><tr >" +
- // "<th width=\"5%\" style=\"text-align:center;\"><div style=\"line-height:20px;\">序号</th>" +
- "<th width=\"12%\" style=\"text-align:center;\"><div style=\"line-height:20px;\">库位号</th>" +
- "<th width=\"32%\" style=\"text-align:center;\"><div style=\"line-height:20px;\">面料</th>" +
- "<th width=\"8%\" style=\"text-align:center;\"><div style=\"line-height:20px;\">单位</th>" +
- "<th width=\"8%\" style=\"text-align:center;\"><div style=\"line-height:20px;\">数量</th>" +
- "<th width=\"10%\" style=\"text-align:center;\"><div style=\"line-height:20px;\">制单总数</th>" +
- "<th width=\"30%\" style=\"text-align:center;\"><div style=\"line-height:20px;\">备注</th>" +
- " <tr align=\"center\">\n" +
- // " <td >" + (1) + "</td>\n" +
- " <td >" + data.goodslist.Uniqid + "</td>\n" +
- " <td >" + data.goodslist.面料 + "</td>\n" +
- " <td >" + data.goodslist.单位 + "</td>\n" +
- " <td >" + data.goodslist.订单数量 + "</td>\n" +
- " <td >" + data.goodslist.订单数量 + "</td>\n" +
- " <td >" + data.goodslist.要求 + "</td>\n" +
- " </tr>"
- h += "<tfoot> " +
- // "<tr><td tindex=\"8\" tdata=\"SubSum\" format=\"UpperMoney\" colspan=\"5\" ><div style=\"line-height:25px;text-align: left;\">本页小计:</td>" +
- // "<td align=\"center\" tdata=\"SubSum\" format=\"#,##\"></td>" +
- // "<td></td>" +
- // "<td align=\"center\" tdata=\"SubSum\" format=\"#,##0.00\"></td>" +
- // "<td></td>" +
- // "</tr>" +
- "<tr><td colspan=\"5\" tindex=\"8\" tdata=\"AllSum\" format=\"UpperMoney\" ><div style=\"line-height:25px;text-align: left;\">合 计: </td>" +
- "<td align=\"center\" tdata=\"AllSum\" format=\"#,##\"></td>" +
- // "<td></td>" +
- "<td align=\"center\" tdata=\"AllSum\" format=\"#,##0.00\"></td>" +
- // "<td></td>" +
- "</tr>" +
- " </tfoot></table>" +
- "</div>" +
- "<div id=\"foot\"><table style=\"width:100%;\">" +
- "<tr >" +
- "<td width=\"30%\"><div style=\"line-height:30px;\">负责人:</td>" +
- "<td width=\"30%\"><div style=\"line-height:30px;\">经办人:</td>" +
- "<td width=\"30%\"><div style=\"line-height:30px;\">库管员:</td>" +
- "</tr>" +
- "<tr>" +
- "</tr>" +
- "</table></div>";
- $('.printContent').append(h);
- // 生成二维码
- new QRCode(document.getElementById("qrcode"), {
- text: data.goodslist.订单编号, // 二维码内容为订单编号
- width: 80,
- height: 80
- });
- }
- // require(['lodop'], function (locop) {
- $(".printt").click(function () {
- console.log(123)
- const div1 = document.getElementById('div1');
- const newWindow = window.open('', '_blank'); // 打开一个新的窗口
- newWindow.document.write('<html><head><title>打印</title>');
- newWindow.document.write('<style>.row2 { padding-top: 40px}</style></head><body>');
- newWindow.document.write(div1.innerHTML); // 将 div1 的内容写入新窗口
- newWindow.document.write('</body></html>');
- newWindow.document.close();
- newWindow.print(); // 调用打印
- newWindow.close(); // 打印后关闭窗口
- // var LODOP = getLodop();
- // if (typeof (LODOP) != "undefined") {
- // var strStyle = "<style>table{table-layout:fixed;word-break:break-all;} table,td,th {border-width: 1px;border-style: solid;border-color:black;border-collapse: collapse}</style>"
- // LODOP.ADD_PRINT_TABLE("30mm", "5%", "90%", "70mm", strStyle + document.getElementById("maintable").innerHTML);
- // LODOP.SET_PRINT_STYLEA(0, "Vorient", 3);
- // LODOP.ADD_PRINT_HTM("2mm", "5%", "90%", "25mm", document.getElementById("top").innerHTML);
- // LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
- // LODOP.ADD_PRINT_HTM("120mm", "5%", "90%", "25mm", document.getElementById("foot").innerHTML);
- // LODOP.SET_PRINT_STYLEA(0, "LinkedItem", 4);
- // LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
- // LODOP.SET_PRINT_STYLEA(0, "FontColor", "#FF0000");
- // LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
- // LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
- // LODOP.SET_PRINT_STYLEA(0, "Horient", 3);
- // LODOP.SET_PRINT_PAGESIZE(2, 0, 0, "A5")
- // LODOP.PREVIEW();
- // }
- });
- // });
- },
- api: {
- formatter: {
- audit: function (value, row, index) {
- //颜色状态数组,可使用red/yellow/aqua/blue/navy/teal/olive/lime/fuchsia/purple/maroon
- var colorArr = { normal: 'success', hidden: 'grey', deleted: 'danger', locked: 'info' };
- // 如果字段列有定义custom
- var newValue = value == null ? '未审核' : '已审核';
- var color = value == null ? 'danger' : 'primary';
- var html = '<span class="text-' + color + '"><i class="fa fa-circle"></i> ' + __(newValue) + '</span>';
- return html;
- },
- settle: function (value, row, index) {
- //颜色状态数组,可使用red/yellow/aqua/blue/navy/teal/olive/lime/fuchsia/purple/maroon
- var colorArr = { normal: 'success', hidden: 'grey', deleted: 'danger', locked: 'info' };
- // 如果字段列有定义custom
- var newValue = value == null ? '未结算' : '已结算';
- var color = value == null ? 'danger' : 'primary';
- var html = '<span class="text-' + color + '"><i class="fa fa-circle"></i> ' + __(newValue) + '</span>';
- return html;
- },
- },
- bindevent: function () {
- $('form[role=form]').data('validator-options', { msgClass: "n-bottom" });
- //重置
- $('#btnreset').click(function () {
- $('#paneladdgoods :text').val('');
- $('#paneladdgoods [type=number]').val('');
- });
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- }
- );
|