| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989 |
- /**
- * 图片上传
- */
- Vue.component('spaceUploadImg', {
- data: function () {
- return {
- id: "spaceUploadImg" + space.utils.random(6),
- }
- },
- name: "spaceUploadImg",
- model: {
- prop: 'patharry',
- evnet: 'click'
- },
- /**
- * patharry: v-model 绑定的值,非空,字符串数组
- * type: 上传按钮的风格,可空,缺省值为 button ,可选值为button / img
- * width: 图片裁剪的宽度,可空
- * height: 图片裁剪的高度,可空
- * maxsize: 最大上传的图片数量,可空,缺省值为1
- * tip: 提示语,可空
- * color: 图片背景,可空,值的类型与css的color值类型一样
- * source: 是否可上传原图
- */
- props: {
- patharry: {
- type: Array,
- required: true
- },
- type: {
- type: String,
- default: "button"
- },
- width: [String, Number],
- height: [String, Number],
- maxsize: {
- type: [String, Number],
- default: 1
- },
- tip: [String, Number],
- color: [String, Number],
- source: {
- type: Boolean,
- default: false,
- }
- },
- created: function () {
- // 对初始化值进行处理,排除掉空数据
- if (!this.patharry) {
- this.patharry = [];
- }
- var newAry = [];
- if (typeof this.patharry == "string") {
- if (space.utils.notNull(this.patharry)) {
- newAry.push(this.patharry);
- }
- } else {
- for (let index = 0; index < this.patharry.length; index++) {
- const element = this.patharry[index];
- if (space.utils.notNull(element)) {
- newAry.push(element);
- }
- }
- }
- this.patharry = newAry;
- this.$emit("input", newAry);
- },
- mounted: function () {
- var that = this;
- space.plugins.cropper.init({
- el: $("#" + that.id),
- photoSize: { // 裁剪的图片大小,会自动计算裁剪比例
- width: that.width,
- height: that.height,
- source: that.source,
- },
- show: function (setting) { //打开裁剪框前的回调
- setting.photoSize = {
- width: that.width,
- height: that.height,
- source: that.source,
- }
- },
- success: function (path) { // 成功后的回调方法,path为裁剪后的img路径
- that.patharry.push(path);
- that.$emit("input", that.patharry);
- },
- });
- },
- methods: {
- uploadClick: function () {
- if (this.patharry.length >= this.maxsize) {
- space.message.warning("最多上传" + this.maxsize + "张图片");
- return false;
- }
- $("#" + this.id).click();
- },
- removeCropperImg: function (index) {
- this.patharry.splice(index, 1);
- space.message.success("图片已删除");
- this.$emit("input", this.patharry);
- },
- },
- template: `
- <div class="space-upload-img">
- <el-button size="small" icon="el-icon-upload" @click="uploadClick" :disabled="patharry.length >= maxsize" v-if="type == 'button' || space.utils.isNull(type)">上传</el-button>
- <span v-show="patharry.length >= maxsize" style="color: #C0C4CC;margin-left: 6px;">
- 最多上传{{maxsize}}张图片
- </span>
- <span v-show="tip" style="color: #888;margin-left: 6px;">
- {{tip}}
- </span>
- <input type="file" accept="image/*" :id="id" style="display: none;" />
- <div>
- <div v-show="patharry" class="cropper-img-content" v-for="(item, index) in patharry" :key="index"">
- <el-image class="cropper-img" fit="contain" :style="{'background-color': color}"
- :src="item" @click="space.plugins.elPreview.show(item, patharry)">
- </el-image>
- <i class="el-icon-close" @click="removeCropperImg(index)"></i>
- </div>
- <div class="uploadButton-img" v-if="type == 'img'" @click="uploadClick" v-show="patharry.length < maxsize">
- <i class="el-icon-plus"></i>
- </div>
- </div>
-
- </div>
- `
- })
- /**
- * 图片预览
- */
- Vue.component('spacePreviewImg', {
- data: function () {
- return {
- newAry: [],
- }
- },
- name: "spacePreviewImg",
- /**
- * paths: 绑定的值,非空,字符串/数组
- * color: 图片背景色,可空,值的类型与css的color值类型一样
- */
- props: {
- paths: {
- type: [Array, String],
- required: true
- },
- color: {
- type: String,
- }
- },
- created: function () {
- // 对初始化值进行处理,排除掉空数据
- if (!this.paths) {
- this.paths = [];
- }
- if (typeof this.paths == "string") {
- if (space.utils.notNull(this.paths)) {
- this.newAry.push(this.paths);
- }
- } else {
- for (let index = 0; index < this.paths.length; index++) {
- const element = this.paths[index];
- if (space.utils.notNull(element)) {
- this.newAry.push(element);
- }
- }
- }
- this.$emit("input", this.newAry);
- },
- mounted: function () {
- },
- methods: {
- },
- template: `
- <div class="space-preview-img">
- <div class="cropper-img-content" v-for="(item, index) in newAry" :key="index">
- <el-image class="cropper-img" fit="contain" :style="{'background-color': color}"
- :src="item" @click="space.plugins.elPreview.show(item, newAry)">
- </el-image>
- </div>
- </div>
- `
- })
- /**
- * 对象选择器
- */
- Vue.component('spaceSelect', {
- data: function () {
- return {
- id: "spaceSelect" + space.utils.random(6),
- randomNum: space.utils.random(6),
- options: [],
- isOpen: true, // 是否打开
- }
- },
- name: "spaceSelect",
- model: {
- prop: 'modelAry',
- evnet: 'click'
- },
- /**
- * modelAry: 绑定的值,非空,字符串/数组
- * predefine: 预定义对象,非空,可选值有person、department、post、role
- * datasize: 最多选择的数量,可空,默认值为1
- * method:自定义方法
- */
- props: ['modelAry', "predefine", "datasize", "method"],
- watch: {
- modelAry: function (newVal, oldVal) {
- // 没有打开时,则可以初始化选择数据集合
- if (!this.isOpen) {
- this.isOpen = true;
- this.initSelectedDataList();
- } else {
- this.isOpen = false;
- }
- }
- },
- created: function () {
- if (this.predefine && this.method) {
- space.message.error('predefine 与 method 不能同时存在');
- }
- if (!this.isPredefine()) {
- if (!this.method) {
- space.message.warning('预定义选择器不存在:' + this.predefine);
- }
- }
- },
- mounted: function () {
- var that = this;
- if (!this.method) {
- // 初始化选择窗
- space.choose[that.predefine].init({
- el: $("#choose" + that.predefine + that.randomNum), // 点击弹出选择窗的元素
- selectAry: function () {
- return that.modelAry;
- }, // 已选的数组
- selectCountNum: that.datasize || 1, // 最多选择的数量
- success: function (param) { // 成功后的回调
- that.options = param;
- that.modelAry = [];
- that.options.forEach(function (item) {
- that.modelAry.push(item["id"]);
- });
- that.$emit("input", that.modelAry);
- }
- })
- }
- /* 监听容器高度 */
- const erd = elementResizeDetectorMaker();
- var eles = $("#" + that.id).find("div.el-input--suffix")[0];
- erd.listenTo(eles, element => {
- const height = element.offsetHeight;
- $("#choose" + that.predefine + that.randomNum).css("height", height);
- });
- this.initSelectedDataList();
- },
- methods: {
- removeFun: function () {
- this.$emit("input", this.modelAry);
- },
- /**
- * 获取最大限制绑定的值
- */
- getMaxSelectedModelAry: function () {
- var tmpAry = [];
- var _this = this;
- this.options.forEach(function (item) {
- tmpAry.push(item["id"]);
- });
- if (this.datasize == undefined || this.datasize == 1) {
- return tmpAry.length > 0 ? [tmpAry[tmpAry.length - 1]] : [];
- } else if (this.datasize > 1) {
- var selectedAry = [];
- tmpAry.forEach(function (item, index) {
- if ((index + 1) > _this.datasize) {
- return;
- }
- selectedAry.push(item);
- });
- return selectedAry;
- } else if (this.datasize == '*') {
- return tmpAry;
- } else {
- return [];
- }
- },
- /**
- * 是否预定义选择器,false:不是预定义选择器,true:是预定义选择器
- */
- isPredefine: function () {
- if (this.predefine != "person" && this.predefine != "department" && this.predefine != "post" && this.predefine != "role") {
- return false; // 不是预定义选择器
- } else {
- return true; // 预定义选择器
- }
- },
- /**
- * 获取预定义的服务
- */
- getPredefineService: function () {
- var map = new Map();
- map.set("person", "/apps?ark=personnel.person_getChoolsePersonInfoApi");
- map.set("department", "/apps?ark=sys.department_getChoolseDepartmentInfoApi");
- map.set("post", "/apps?ark=sys.post_getChoolsePostInfoApi");
- map.set("role", "/apps?ark=sys.role_getChoolseRoleInfoApi");
- return map.get(this.predefine);
- },
- /**
- * 初始化选择数据集合
- */
- initSelectedDataList: function () {
- if (!this.isPredefine() || this.method) {
- return;
- }
- if (!this.modelAry || this.modelAry.length == 0) {
- this.isOpen = false; // 没有数据时,则关闭
- return;
- }
- var url = this.getPredefineService();
- var ids = typeof (this.modelAry) == 'string' || typeof (this.modelAry) == 'number' ? this.modelAry : this.modelAry.join(',');
- var _this = this;
- // 查询选中的列表
- space.utils.ajax({
- url: url,
- data: {
- "ids": ids
- },
- dataType: 'json',
- callback: function (data) {
- _this.options = data.data;
- var tmpAry = _this.getMaxSelectedModelAry();
- _this.$emit("input", tmpAry);
- }
- })
- },
- },
- template: `
- <div class="space-select" :id="id" >
- <el-select class="choose-obj" v-model="modelAry" multiple placeholder="请选择" :value-key="id" clearable
- :popper-append-to-body="false" style="width: calc(100% - 60px);" :disabled="!modelAry.length>0" @remove-tag="removeFun" @clear="removeFun">
- <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
- </el-option>
- </el-select>
- <el-button type="button" size="medium" class="choose-btn" :id="'choose' + predefine + randomNum" icon="el-icon-search"></el-button>
- </div>
- `
- })
- /**
- * Editor 编辑器
- */
- Vue.component('spaceEditor', {
- data: function () {
- return {
- id: "spaceEditor" + space.utils.random(6),
- editor: undefined,
- // 编辑器需要的 js 文件
- jsUrl: [
- '/apps/space/plug-in/ckeditor5/build/ckeditor.js',
- '/apps/space/plug-in/ckeditor5/src/plugins/upload/src/myUploadAdapter.js'
- ],
- // 标识,全部为 true 则代表全部加载完成
- jsUrlFlag: [],
- notLoadEditor: true, // 未加载完 editor 编辑器,true:未加载完,false:已加载完
- }
- },
- name: "spaceEditor",
- model: {
- prop: 'htmlContent',
- evnet: 'click'
- },
- /**
- * htmlContent: v-model 绑定的值,非空,html 字符串
- * size: 编辑器的大小,small、medium、large
- * width: 编辑器的宽度,可空
- * height: 编辑器的高度,可空
- * placeholder:占位符
- * type:编辑器工具栏类型
- * isfullscreen:是否有全屏,
- */
- props: ['htmlContent', 'size', 'width', 'height', 'placeholder', 'type', 'isfullscreen'],
- watch: {
- height: function (newVal, oldVal) {
- if (this.height && this.height.toString().toLocaleLowerCase().indexOf('px') == -1) {
- this.height += 'px';
- } else {
- this.setEditorHeight();
- }
- },
- editor: function (newVal, oldVal) {
- this.setEditorHeight();
- },
- jsUrlFlag: function (newVal, oldVal) {
- if (this.jsUrl.length > 0 && this.jsUrl.length == this.jsUrlFlag.length) {
- if (this.jsUrlFlag.indexOf('false') != -1) {
- return;
- }
- this.initEditor();
- this.notLoadEditor = false;
- this.setEditorHeight();
- }
- },
- notLoadEditor: function (newVal, oldVal) {
- this.setEditorHeight();
- },
- },
- created: function () {
- var _this = this;
- for (var i = 0; i < _this.jsUrl.length; i++) {
- _this.loadJS(_this.jsUrl[i], function () {
- _this.jsUrlFlag.push('true');
- });
- }
- },
- methods: {
- loadJS: function (url, callback) {
- for (var i = 0; i < document.getElementsByTagName('head')[0].getElementsByTagName('script').length; i++) {
- var src = document.getElementsByTagName('head')[0].getElementsByTagName('script')[i].getAttribute('src');
- if (url == src) {
- // 防止一个页面有多个编辑器时,编辑器加载失败
- if (space.vars.editorReady != true) {
- var winInterval = setInterval(function () {
- if (space.vars.editorReady != true) {
- return;
- }
- window.clearInterval(winInterval);
- if (callback) {
- callback();
- }
- }, 100)
- }
- return;
- }
- }
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.onload = function () {
- if (callback) {
- callback();
- }
- };
- script.src = url;
- document.getElementsByTagName('head')[0].appendChild(script);
- },
- myCustomUploadAdapterPlugin: function (editor) {
- editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
- // 第二个参数设置上传图片的地址
- return new MyUploadAdapter(loader);
- };
- },
- /**
- * 获取高度
- */
- getHeight: function () {
- if (!this.height) {
- if (this.size == undefined || this.size == "small") {
- return '200px';
- } else if (this.size == "medium") {
- return '400px';
- } else if (this.size == "large") {
- return '600px';
- }
- } else if (this.height) {
- if (this.height.toString().toLocaleLowerCase().indexOf('px') == -1) {
- return this.height + 'px';
- } else {
- return this.height;
- }
- }
- return "";
- },
- /**
- * 设置编辑器高度
- */
- setEditorHeight: function () {
- if (this.notLoadEditor) {
- return;
- }
- var height = this.getHeight();
- if (!this.editor || !height) {
- return;
- }
- var _this = this;
- // 设置编辑器高度
- _this.editor.editing.view.change(writer => {
- writer.setStyle(
- "height",
- height,
- _this.editor.editing.view.document.getRoot()
- );
- });
- },
- /**
- * 获取工具栏
- */
- getToolbar: function () {
- var items = [];
- // 是否有全屏工具
- if (this.isfullscreen == false) {
- // 没有全屏工具栏
- items = [
- 'fontfamily', 'fontsize', 'fontColor', 'fontBackgroundColor', 'blockQuote', 'bold', 'italic', 'link', '|',
- 'alignment', 'horizontalLine', '|', 'indent', 'outdent', '|', 'imageUpload', 'wordUpload', 'insertTable', 'mediaEmbed', 'phrase', 'undo', 'redo'
- ];
- } else {
- items = [
- 'fontfamily', 'fontsize', 'fontColor', 'fontBackgroundColor', 'blockQuote', 'bold', 'italic', 'link', '|',
- 'alignment', 'horizontalLine', '|', 'indent', 'outdent', '|', 'imageUpload', 'wordUpload', 'insertTable', 'mediaEmbed', 'phrase', 'undo', 'redo', 'fullScreen'
- ];
- }
- var toolbar = {
- items: items
- };
- if (!this.type) {
- return toolbar;
- }
- var map = new Map();
- map.set("flow", ['phrase']);
- if (map.get(this.type)) {
- return {
- items: map.get(this.type)
- }
- }
- return toolbar;
- },
- alignFullScreenToolbarButton: function () {
- if (!this.editor || !this.editor.ui || !this.editor.ui.view || !this.editor.ui.view.element) {
- return;
- }
- var toolbarItems = this.editor.ui.view.element.querySelector(".ck-toolbar__items");
- if (!toolbarItems) {
- return;
- }
- var buttons = toolbarItems.querySelectorAll(".ck-button");
- for (var i = 0; i < buttons.length; i++) {
- var label = (buttons[i].getAttribute("aria-label") || buttons[i].getAttribute("title") || buttons[i].textContent || "").replace(/\s/g, "");
- if (label.indexOf("全屏") != -1) {
- buttons[i].style.marginLeft = "auto";
- toolbarItems.appendChild(buttons[i]);
- return;
- }
- }
- },
- /**
- * 初始化编辑器
- */
- initEditor: function () {
- var toolbar = this.getToolbar();
- var _this = this;
- ClassicEditor.create(document.querySelector("#" + _this.id), {
- extraPlugins: [_this.myCustomUploadAdapterPlugin], // 添加上传适配器
- toolbar: toolbar || {},
- language: 'zh-cn',
- placeholder: _this.placeholder || '',
- mediaEmbed: {
- providers: [{
- name: 'myprovider',
- url: [
- /^lizzy.*\.com.*\/media\/(\w+)/,
- /^www\.lizzy.*/,
- /^.*/
- ],
- html: match => {
- //获取媒体url
- const input = match['input'];
- return (
- `<iframe src="${input}" allowFullScreen="true" frameborder="0"></iframe>`
- );
- }
- }]
- }
- }).then(editor => {
- space.vars.editorReady = true;
- _this.editor = editor;
- _this.alignFullScreenToolbarButton();
- if (_this.htmlContent != undefined) {
- _this.editor.setData(_this.htmlContent);
- }
- /**
- * 禁止在编辑器内回车事件
- */
- editor.ui.view.element.onkeydown = function (event) {
- // 回车键
- if (event.keyCode == 13) {
- event.stopPropagation();
- return false;
- }
- // tab 转空格
- if (event.keyCode == 9) {
- const model = editor.model;
- model.change(writer => {
- const ele = writer.createElement('span');
- writer.insertText(" ", ele);
- // 一定要 Element
- model.insertContent(ele);
- });
- event.stopPropagation();
- return false;
- }
- _this.$emit("input", editor.getData());
- };
- // 设置编辑器宽度
- if (_this.width) {
- $(editor.ui.view.element).css({
- 'width': _this.width
- })
- }
- // 监听编辑器的内容变动事件
- editor.model.document.on('change:data', function () {
- _this.$emit("input", editor.getData());
- });
- }).catch(error => {
- console.log(error);
- });
- }
- },
- template: `
- <div :id="id">
- <script type="text/plain"></script>
- </div>
- `
- })
- /**
- * CMS
- */
- Vue.component('spaceCms', {
- data: function () {
- return {
- fileCount: 0, // 文件总数
- }
- },
- name: "spaceCms",
- model: {
- prop: 'cmsid',
- evnet: 'click'
- },
- props: {
- // v-model
- cmsid: {
- type: [String],
- required: true
- },
- // 文件类型
- accept: {
- type: String
- },
- // 最大上传数量,默认199
- maxsize: {
- type: [String, Number],
- default: 199
- },
- },
- created: function () {
- this.getCmsFileCount(this.cmsid);
- },
- watch: {
- cmsid: function (newVal, oldVal) {
- this.getCmsFileCount(newVal);
- }
- },
- methods: {
- open: function () {
- var that = this;
- space.plugins.cms.openCMS({
- cmsid: that.cmsid,
- accept: that.accept,
- maxsize: that.maxsize
- }, that.callback);
- },
- callback: function (data, callback2) {
- this.$emit("input", data.cmsid);
- this.cmsid = data.cmsid;
- this.fileCount = data.fileCount;
- callback2();
- },
- getCmsFileCount: function (cmsid) {
- if (space.utils.isNull(cmsid)) {
- return;
- }
- var that = this;
- space.utils.ajax({
- url: '/apps?ark=sys.cms_getCmsInfo',
- data: {
- "idcard": cmsid
- },
- dataType: 'json',
- loadLayer: false,
- autoTip: false,
- async: false, // 同步请求
- callback: function (data) {
- if (data.code == "success") {
- that.fileCount = data.data.filecount;
- }
- }
- });
- }
- },
- template: `<div class="cms-upload">
- <el-badge :value="fileCount" type="primary" v-show="fileCount > 0">
- <el-button icon="el-icon-upload2" @click="open" >上传文件</el-button>
- </el-badge>
- <el-button icon="el-icon-upload2" v-show="fileCount == 0" @click="open" >上传文件</el-button>
- </div>`
- })
- /**
- * CMS预览
- */
- Vue.component('spaceCmsView', {
- data: function () {
- return {
- thumbnail: "",
- filename: "",
- filecount: 0,
- isShowEl: true, //是否显示整个组件元素
- }
- },
- name: "spaceCmsView",
- /**
- * cmsid: 绑定的值,非空
- * thumbnail: 缩略图
- * filename: 文件名
- * filecount: 文件数
- */
- props: {
- cmsid: {
- type: [String, Number],
- required: true
- }
- },
- created: function () {
- var that = this;
- if (space.utils.isNull(that.cmsid)) {
- // 不显示整个组件元素
- that.isShowEl = false;
- return;
- }
- space.utils.ajax({
- url: '/apps?ark=sys.cms_getCmsInfo',
- data: {
- "idcard": that.cmsid
- },
- dataType: 'json',
- loadLayer: false,
- autoTip: false,
- async: false, // 同步请求
- callback: function (data) {
- if (data.code == "success") {
- that.thumbnail = data.data.thumbnail;
- that.filename = data.data.filename;
- that.filecount = data.data.filecount;
- } else if (data.code == "warning") {
- // 不显示整个组件元素
- that.isShowEl = false;
- }
- }
- });
- },
- methods: {
- open: function () {
- var that = this;
- space.plugins.cms.openCMSView({
- cmsid: that.cmsid
- });
- },
- },
- template: `
- <div class="space-cms-view" v-if="isShowEl">
- <div class="space-cms-view-wrap" @click="open">
- <div class="space-cms-view-main">
- <el-image :src="thumbnail">
- <div slot="error" class="image-slot">
- <i class="el-icon-picture-outline"></i>
- </div>
- </el-image>
- <span>{{filename}}</span>
- </div>
- <div v-show="filecount >=2 " class="more-file"></div>
- <div v-show="filecount >=2 " class="more-file more-file-bottom"></div>
- </div>
- </div>
- `
- })
- /**
- * 业务流转
- */
- Vue.component('spacePluginFlow', {
- data: function () {
- return {
- isOpenFlowDrawer: false, // 是否打开抽屉
- isLoadShow: true, // 是否显示加载动画
- frameID: space.utils.randomStringAndNumber(6) + 'Frm', // frame 窗口ID
- closeBtnID: space.utils.randomStringAndNumber(6) + 'Close', // 关闭按钮的ID
- url: '/app/flow/time/', // url
- title: '业务流转', // 标题
- closeTitle: '收起', // 关闭按钮文本内容
- }
- },
- name: "spacePluginFlow",
- /**
- * cmsid: 绑定的值,非空
- * size: 抽屉大小,可传px、%,默认30%
- */
- props: {
- audit: {
- type: String,
- required: true
- },
- apply: {
- type: String,
- required: true
- },
- open: {
- type: Boolean,
- },
- size: {
- type: String
- },
- },
- created: function () {
- this.url = this.url + "?auditid=" + this.audit + "&applyid=" + this.apply;
- this.size = space.utils.isNull(this.size) ? '360px' : this.size;
- this.isOpenFlowDrawer = space.utils.isNull(this.open) ? false : this.open;
- this.showLoad();
- },
- mounted: function () {
- var that = this;
- // 监听窗口变化,计算关闭按钮的位置
- window.onresize = function () {
- // 抽屉打开状态
- if (that.isOpenFlowDrawer) {
- that.initCloseBtnLocation();
- }
- }
- },
- methods: {
- /**
- * 计算关闭按钮的坐标
- */
- initCloseBtnLocation: function () {
- var offset = space.utils.getDomPosition(document.getElementById(this.frameID));
- $("#" + this.closeBtnID).css("left", (offset.left - $("#" + this.closeBtnID).width()) + "px");
- },
- /**
- * 显示抽屉
- */
- showDrawer: function () {
- var that = this;
- that.initCloseBtnLocation();
- $("#" + that.closeBtnID).fadeIn(200);
- // 为了更好的动画体验
- setTimeout(() => {
- $("#" + that.closeBtnID).css("z-index", "999999999999999");
- }, 200);
- },
- /**
- * 控制加载动画
- */
- showLoad: function () {
- var that = this;
- var loadInterval = setInterval(() => {
- var frameEle = document.getElementById(that.frameID);
- console.log("loadInterval");
- frameEle.onload = function () {
- window.clearInterval(loadInterval);
- that.isLoadShow = false;
- }
- }, 100);
- }
- },
- watch: {
- isOpenFlowDrawer: function (newVal, oldVal) {
- var that = this;
- // 打开
- if (newVal) {
- var getFrameInterval = setInterval(() => {
- var frameEle = document.getElementById(that.frameID);
- if (!frameEle) {
- return;
- }
- window.clearInterval(getFrameInterval);
- that.showDrawer();
- }, 200);
- }
- // 关闭
- else {
- $("#" + that.closeBtnID).hide();
- $("#" + that.closeBtnID).css("z-index", "");
- }
- },
- open: function (newVal, oldVal) {
- this.isOpenFlowDrawer = space.utils.isNull(newVal) ? false : newVal;
- }
- },
- template: `
- <div class="space-app-plugin">
- <div class="space-app-plugin-open disable-select animate__animated animate__slideInRight" v-show="!isOpenFlowDrawer" @click="isOpenFlowDrawer = true">{{title}}</div>
- <div :id="closeBtnID" class="space-app-plugin-close disable-select animate__animated animate__slideInRight" @click="isOpenFlowDrawer = false">{{closeTitle}}</div>
- <el-drawer :modal="false" :visible.sync="isOpenFlowDrawer" :size="size" :with-header="false" :wrapper-closable="false" >
- <iframe :id="frameID" :src="url"></iframe>
- <div class="space-app-plugin-load" v-show="isLoadShow" ><i class="el-icon-loading" ></i>加载中</div>
- </el-drawer>
- </div>
- `
- })
|