diff --git a/src/App.vue b/src/App.vue index b8a1e05..18d390c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -25,3 +25,6 @@ export default { }, }; + diff --git a/src/main.js b/src/main.js index 3bd07f6..cad56e7 100644 --- a/src/main.js +++ b/src/main.js @@ -46,6 +46,7 @@ import WmsWarehouseCascader from '@/components/WmsWarehouseCascader'; import WmsCarrierSelect from "@/components/WmsCarrierSelect/index.vue"; import DictRadio from '@/components/DictRadio'; import DictSelect from '@/components/DictSelect'; +import vuePlugsPrint from '@/utils/vuePlugsPrint' import KrPrintDesigner from "kr-print-designer"; import "kr-print-designer/lib/kr-print-designer.css"; @@ -102,6 +103,7 @@ Vue.component('WmsCarrierSelect', WmsCarrierSelect) Vue.component('DictRadio', DictRadio) Vue.component('DictSelect', DictSelect) Vue.component('WmsWarehouseCascader', WmsWarehouseCascader) +Vue.use(vuePlugsPrint); Vue.use(KrPrintDesigner); Vue.use(permission) diff --git a/src/settings.js b/src/settings.js index 0b1c2ee..2577930 100644 --- a/src/settings.js +++ b/src/settings.js @@ -3,7 +3,7 @@ module.exports = { * 框架版本号 */ version: '3.8.1', - title: '上海干巷MES', + title: '上海干巷MOM', /** * 主题颜色 */ diff --git a/src/store/index.js b/src/store/index.js index 84024a5..a779b6a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,6 +7,8 @@ import permission from './modules/permission' import settings from './modules/settings' import socket from './modules/socket' import quality from './modules/quality' +import wms from './modules/wms' +import dict from './modules/dict' import getters from './getters' Vue.use(Vuex) @@ -15,20 +17,22 @@ Vue.use(Vuex) * 当前用户数据 */ const state = { - appVersionInfo: '' + appVersionInfo: '' } const store = new Vuex.Store({ - modules: { - app, - user, - tagsView, - permission, - settings, + modules: { + app, + user, + tagsView, + permission, + settings, socket, - quality, - }, - state: state,//这里放全局参数 - getters + quality, + wms, + dict, + }, + state: state, //这里放全局参数 + getters }) -export default store +export default store \ No newline at end of file diff --git a/src/style/base.styl b/src/style/base.styl new file mode 100644 index 0000000..425c6af --- /dev/null +++ b/src/style/base.styl @@ -0,0 +1,145 @@ +@import 'reset' +@import "variables.styl" +.icon + width 1em + height 1em + vertical-align -0.15em + fill currentColor + overflow hidden + +@keyframes spin { + 0% { + transform rotate(0deg) + } + 100% { + transform rotate(360deg) + } +} +.tc + text-align center +.tl + text-align left +.tr + text-align right +.spin + animation spin .6s infinite linear + display inline-block +.lineov2 + overflow hidden + text-overflow ellipsis + display -webkit-box + -webkit-line-clamp 2 + -webkit-box-orient vertical + +.lineov1 + text-overflow ellipsis + overflow hidden + white-space nowrap + +.flex-container + display flex + +.align-center + align-items center + +.flex-center + display flex + align-items center + +.flex-top + display flex + align-items flex-start + +.justify-end + justify-content flex-end + +.flex-one + flex 1 1 0 + +.flex-two + flex 2 + +.mouse-pointer + cursor pointer + +.no-break + word-break keep-all + white-space nowrap + +.break-all + word-break break-all + white-space normal + +/* ---- Chrome ----*/ +.scroll::-webkit-scrollbar + width: 5px; + +/*滚动条粗细*/ + +.scroll::-webkit-scrollbar-track + -webkit-box-shadow: none; + background: #f8f8f9; /*滑道颜色*/ + border-radius: 5px; + +/*滑道的圆滑度*/ + +.scroll::-webkit-scrollbar-thumb + background: #c1c1c1; /*滑块颜色*/ + border-radius: 5px + +/*滑块圆滑度*/ + +.scroll::-webkit-scrollbar-thumb:hover + background: gray; + +/*滑块上浮*/ + +/*--- FirFox ---*/ +.scroll + scrollbar-width: thin; + scrollbar-color: orange green; + +/*滚动条的基本颜色*/ + +.common-table + width 100% + border-collapse: collapse; + tr > td, tr > th + border 1px solid $border-color + padding 5px 8px + tr > th + font-weight bolder + white-space nowrap + +.inline-div + display inline-block + +[class~=flex].gutter-span + > * + * + margin-left .75rem + +.warning + color $yellow +.active + color $active-color +.white + color white +.gold + color $gold-color +.gray + color $gray-color +.red + color $red +.blue + color $blue +.green + color green +.bg-white + background #fff +.pct100 + width 100% +.bolder-font + font-weight bolder + +.large-tip + font-size 16px diff --git a/src/style/reset.styl b/src/style/reset.styl new file mode 100644 index 0000000..eeeda5a --- /dev/null +++ b/src/style/reset.styl @@ -0,0 +1,51 @@ + +// @for num from 1 through 10 +for num in (1..20) + .mt{num * 5} + margin-top: 5px * num + .mr{num * 5} + margin-right: 5px * num + .mb{num * 5} + margin-bottom: 5px * num + .ml{num * 5} + margin-left: 5px * num + .m{num * 5} + margin: 5px * num + .pt{num * 5} + padding-top: 5px * num + .pr{num * 5} + padding-right: 5px * num + .pb{num * 5} + padding-bottom: 5px * num + .pl{num * 5} + padding-left: 5px * num + .p{num * 5} + padding: 5px * num +// @for num from 1 through 10 +for num in (1..5) + .mt{num * 8} + margin-top: 8px * num + .mr{num * 8} + margin-right: 8px * num + .mb{num * 8} + margin-bottom: 8px * num + .ml{num * 8} + margin-left: 8px * num + .m{num * 8} + margin: 8px * num + .pt{num * 8} + padding-top: 8px * num + .pr{num * 8} + padding-right: 8px * num + .pb{num * 8} + padding-bottom: 8px * num + .pl{num * 8} + padding-left: 8px * num + .p{num * 8} + padding: 8px * num +for num in (1..20) + .pct{num * 5} + width 5% * num +for num in (1..30) + .w{num * 10} + width 10px * num diff --git a/src/style/variables.styl b/src/style/variables.styl new file mode 100644 index 0000000..cf78e30 --- /dev/null +++ b/src/style/variables.styl @@ -0,0 +1,29 @@ +body + --active #409EFF + --success #67C23A + --warning #E6A23C + --red #F56C6C + --info var(--gray-6) + --gray-1 #F2F6FC + --gray-2 #EBEEF5 + --gray-3 #E4E7ED + --gray-4 #DCDFE6 + --gray-5 #C0C4CC + --gray-6 #909399 + --gray-7 #606266 + --gray-8 #303133 + --white #FFFFFF + --black #000000 + --transparent transparent + +$gray-1 = var(--gray-1) +$gray-2 = var(--gray-2) +$gray-3 = var(--gray-3) +$gray-4 = var(--gray-4) +$gray-5 = var(--gray-5) +$gray-6 = var(--gray-6) +$gray-7 = var(--gray-7) +$gray-8 = var(--gray-8) +$active-color = var(--active) +$red = var(--red) +$border-color = var(--gray-4) diff --git a/src/utils/vuePlugsPrint.js b/src/utils/vuePlugsPrint.js new file mode 100644 index 0000000..97dba19 --- /dev/null +++ b/src/utils/vuePlugsPrint.js @@ -0,0 +1,143 @@ +// 打印类属性、方法定义 +/* eslint-disable */ +const Print = function (dom, options, pageSize) { + + if (!(this instanceof Print)) return new Print(dom, options, pageSize); + + this.options = this.extend({ + 'noPrint': '.no-print' + }, options, pageSize); + + if ((typeof dom) === "string") { + this.dom = document.querySelector(dom); + } else { + this.isDOM(dom) + this.dom = this.isDOM(dom) ? dom : dom.$el; + } + + this.init(pageSize); +}; +Print.prototype = { + init: function (pageSize) { + var content = this.getStyle(pageSize) + this.getHtml(); + this.writeIframe(content); + }, + extend: function (obj, obj2) { + for (var k in obj2) { + obj[k] = obj2[k]; + } + return obj; + }, + + getStyle: function (pageSize) { + var str = "", + styles = document.querySelectorAll('style,link'); + for (var i = 0; i < styles.length; i++) { + str += styles[i].outerHTML; + } + str += ""; + str += ""; + + str = str.replace('size: A5', `size: ${pageSize}`); + + return str; + }, + + getHtml: function () { + var inputs = document.querySelectorAll('input'); + var textareas = document.querySelectorAll('textarea'); + var selects = document.querySelectorAll('select'); + + for (var k = 0; k < inputs.length; k++) { + if (inputs[k].type == "checkbox" || inputs[k].type == "radio") { + if (inputs[k].checked == true) { + inputs[k].setAttribute('checked', "checked") + } else { + inputs[k].removeAttribute('checked') + } + } else if (inputs[k].type == "text") { + inputs[k].setAttribute('value', inputs[k].value) + } else { + inputs[k].setAttribute('value', inputs[k].value) + } + } + + for (var k2 = 0; k2 < textareas.length; k2++) { + if (textareas[k2].type == 'textarea') { + textareas[k2].innerHTML = textareas[k2].value + } + } + + for (var k3 = 0; k3 < selects.length; k3++) { + if (selects[k3].type == 'select-one') { + var child = selects[k3].children; + for (var i in child) { + if (child[i].tagName == 'OPTION') { + if (child[i].selected == true) { + child[i].setAttribute('selected', "selected") + } else { + child[i].removeAttribute('selected') + } + } + } + } + } + + let content = this.dom.outerHTML; + if (content.indexOf('hidden="hidden"') > -1) { + content = content.replace('hidden="hidden"', ''); + } + return content; + }, + + writeIframe: function (content) { + var w, doc, iframe = document.createElement('iframe'), f = document.body.appendChild(iframe); + iframe.id = "myIframe"; + //iframe.style = "position:absolute;width:0;height:0;top:-10px;left:-10px;"; + iframe.setAttribute('style', 'position:absolute;width:0;height:0;top:-10px;left:-10px;'); + w = f.contentWindow || f.contentDocument; + doc = f.contentDocument || f.contentWindow.document; + doc.open(); + doc.write(content); + doc.close(); + var _this = this + iframe.onload = function () { + _this.toPrint(w, _this.options); + setTimeout(function () { + document.body.removeChild(iframe) + }, 100) + } + }, + + toPrint: function (frameWindow, options) { + try { + setTimeout(function () { + frameWindow.focus(); + try { + if (!frameWindow.document.execCommand('print', false, null)) { + frameWindow.print(); + } + if (options.callback ) options.callback() + } catch (e) { + frameWindow.print(); + } + frameWindow.close(); + }, 10); + } catch (err) { + console.log('err', err); + } + }, + isDOM: (typeof HTMLElement === 'object') ? + function (obj) { + return obj instanceof HTMLElement; + } : + function (obj) { + return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string'; + }, +}; +const MyPlugin = {} +MyPlugin.install = function (Vue, options) { + // 4. 添加实例方法 + Vue.prototype.$print = Print +} +export default MyPlugin diff --git a/src/views/components/ItemSelect.vue b/src/views/components/ItemSelect.vue index 5ec6812..2fe0bf4 100644 --- a/src/views/components/ItemSelect.vue +++ b/src/views/components/ItemSelect.vue @@ -2,7 +2,7 @@