数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
58 KiB

2 years ago
import{d as se,ar as ve,f as B,o as p,b as U,g as O,F as q,e as X,j as A,t as pe,y as we,N as I,bp as Le,r as te,C as ie,n as xe,bq as be,br as re,c as P,w as r,a as n,bs as je,bt as $e,bu as Fe,a3 as Je,G as he,as as Ge,bv as Ie,bw as Se,M as We,b7 as Ze,E as le,aP as Qe,aQ as Xe,$ as Ye,ai as et,aj as tt,b6 as lt,b4 as ot,ap as at,az as nt,P as rt,ag as it,aK as st,aL as ct,bx as ut,a1 as dt,by as oe,a9 as de,bz as _e,H as Be,X as qe,bA as pt,bB as ft,B as mt,J as vt,m as bt,bC as ht,a7 as yt,bD as Ue,bE as Ve,bF as ge,aM as gt,bG as Ne,bH as Re,bI as kt}from"./index-b0696d90.js";/* empty css *//* empty css *//* empty css */const Ce=[],ke={optionsType:0},Ae=[{title:"基础字段",children:[{type:"input",label:"单行文本",icon:"input",control:{modelValue:""},config:{}},{type:"textarea",label:"多行文本",icon:"textarea",control:{modelValue:""},config:{}},{type:"radio",label:"单选框组",icon:"radio",control:{modelValue:""},options:Ce,config:ke},{type:"checkbox",label:"多选框组",icon:"checkbox",control:{modelValue:[]},options:Ce,config:ke},{type:"select",label:"下拉选择框",icon:"select",control:{modelValue:"",appendToBody:!0},options:Ce,config:ke},{type:"datePicker",label:"日期选择器",icon:"date",control:{modelValue:"",type:"date"},config:{}},{type:"timePicker",label:"时间选择器",icon:"time",control:{modelValue:""},config:{}},{type:"colorPicker",label:"取色器",icon:"color",control:{modelValue:""},config:{}},{type:"switch",label:"开关",icon:"switch",control:{modelValue:!1},config:{}},{type:"inputNumber",label:"计数器",icon:"number",control:{modelValue:0},config:{}},{type:"cascader",label:"级联选择器",icon:"cascader",control:{modelValue:[]},options:[],config:ke},{type:"rate",label:"评分",icon:"rate",control:{modelValue:0},config:{}},{type:"slider",label:"滑块",icon:"slider",control:{modelValue:0},config:{}},{type:"treeSelect",label:"树形控件",icon:"tree2",control:{modelValue:"",data:[],renderAfterExpand:!1},config:{optionsType:0}},{type:"txt",label:"文字",icon:"text",control:{modelValue:""},config:{}},{type:"title",label:"标题",icon:"title",control:{modelValue:"标题"},config:{}},{type:"button",label:"按钮",icon:"button",control:{label:"保存"},config:{}}]},{title:"高级字段",children:[{type:"table",label:"子表",icon:"table",list:[],tableData:[],control:{border:!0},config:{addBtnText:"添加一行"}},{type:"component",label:"自定义组件",icon:"component",control:{modelValue:""},config:{}},{type:"upload",label:"图片/文件",icon:"image",control:{modelValue:""},config:{}},{type:"tinymce",label:"富文本",icon:"tinymce",control:{modelValue:""},config:{}}]},{title:"布局字段",children:[{type:"grid",label:"格栅布局",icon:"grid",columns:[{attr:{span:12},list:[]},{attr:{span:12},list:[]}],control:{},config:{}},{type:"tabs",label:"标签页",icon:"tabs",columns:[{label:"Tab1",list:[]}],control:{},config:{}},{type:"card",label:"卡片布局",icon:"card",list:[],control:{},config:{},item:{}},{type:"flex",label:"弹性布局",icon:"flex",list:[],tableData:[],control:{},config:{addBtnText:"添加一行"}},{type:"divider",label:"分割线",icon:"divider",control:{},config:{}},{type:"div",label:"容器",icon:"div",control:{},config:{},list:[]}]},{title:"扩展组件",children:[{type:"expand-user",label:"选择用户",icon:"user",control:{modelValue:""},config:{}}]}],_t={key:0,class:"no-date"},wt={key:1,class:"list"},St=["onClick"],Vt=["src"],Ct=se({__name:"template",emits:["click"],setup(z,{expose:H,emit:N}){const $=ve({visible:!1,list:[]}),w=()=>{$.visible=!0,t()},t=()=>{const e=Object.assign({});console.log(e),$.list=[],Object.keys(e).forEach(d=>{const y=e[d];$.list.push({imgPath:y.imgPath,title:y.title,formData:y.formData})})},c=e=>{N("click",e.formData),$.visible=!1};return H({open:w}),(e,d)=>B($).visible?(p(),U("div",{key:0,class:we(["use-template",{active:B($).visible}])},[O("span",{class:"close icon-close",onClick:d[0]||(d[0]=y=>B($).visible=!1)}),B($).list.length===0?(p(),U("div",_t,"暂无可用模板")):(
* clipboard.js v2.0.11
* https://clipboardjs.com/
*
* Licensed MIT © Zeno Rocha
*/(function(z,H){(function($,w){z.exports=w()})(ut,function(){return function(){var N={686:function(t,c,e){e.d(c,{default:function(){return E}});var d=e(279),y=e.n(d),f=e(370),_=e.n(f),u=e(817),T=e.n(u);function k(m){try{return document.execCommand(m)}catch{return!1}}var h=function(s){var i=T()(s);return k("cut"),i},g=h;function R(m){var s=document.documentElement.getAttribute("dir")==="rtl",i=document.createElement("textarea");i.style.fontSize="12pt",i.style.border="0",i.style.padding="0",i.style.margin="0",i.style.position="absolute",i.style[s?"right":"left"]="-9999px";var S=window.pageYOffset||document.documentElement.scrollTop;return i.style.top="".concat(S,"px"),i.setAttribute("readonly",""),i.value=m,i}var Z=function(s,i){var S=R(s);i.container.appendChild(S);var b=T()(S);return k("copy"),S.remove(),b},K=function(s){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},S="";return typeof s=="string"?S=Z(s,i):s instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(s==null?void 0:s.type)?S=Z(s.value,i):(S=T()(s),k("copy")),S},C=K;function V(m){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?V=function(i){return typeof i}:V=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},V(m)}var F=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=s.action,S=i===void 0?"copy":i,b=s.container,D=s.target,L=s.text;if(S!=="copy"&&S!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(D!==void 0)if(D&&V(D)==="object"&&D.nodeType===1){if(S==="copy"&&D.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(S==="cut"&&(D.hasAttribute("readonly")||D.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(L)return C(L,{container:b});if(D)return S==="cut"?g(D):C(D,{container:b})},G=F;function J(m){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?J=function(i){return typeof i}:J=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},J(m)}function j(m,s){if(!(m instanceof s))throw new TypeError("Cannot call a class as a function")}function Y(m,s){for(var i=0;i<s.length;i++){var S=s[i];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(m,S.key,S)}}function M(m,s,i){return s&&Y(m.prototype,s),i&&Y(m,i),m}function ae(m,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");m.prototype=Object.create(s&&s.prototype,{constructor:{value:m,writable:!0,configurable:!0}}),s&&Q(m,s)}function Q(m,s){return Q=Object.setPrototypeOf||function(S,b){return S.__proto__=b,S},Q(m,s)}function fe(m){var s=ne();return function(){var S=a(m),b;if(s){var D=a(this).constructor;b=Reflect.construct(S,arguments,D)}else b=S.apply(this,arguments);return ce(this,b)}}function ce(m,s){return s&&(J(s)==="object"||typeof s=="function")?s:ye(m)}function ye(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function ne(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(m){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},a(m)}function o(m,s){var i="data-clipboard-".concat(m);if(s.hasAttribute(i))return s.getAttribute(i)}var x=function(m){ae(i,m);var s=fe(i);function i(S,b){var D;return j(this,i),D=s.call(this),D.resolveOptions(b),D.listenClick(S),D}return M(i,[{key:"resolveOptions",value:function(){var b=arguments.length>0&&arguments[0]!==v
provide("${h.methods}", (rule, value, callback) => {
if (value === '') {
callback(new Error('Please input the password again'))
} else if (value !== 'abc') {
callback(new Error("Two inputs don't match!"))
} else {
callback()
}
})`)})}),{rulesMethods:_,sourceFun:u}},t=f=>{N.value=!0;const _=w(f),{addUrl:u,editUrl:T,requestUrl:k}=f.config;k&&delete f.config.requestUrl,T&&delete f.config.editUrl,u&&delete f.config.addUrl;const h=`<template>
<div>
<ak-form
ref="formNameEl"
:type="formType"
:formData="formData"
requestUrl="${k}"
addUrl="${u}"
editUrl="${T}"
:beforeSubmit="beforeSubmit">
</ak-form>
</div>
</template>
<script setup lang="ts">
import { ref, computed, provide } from 'vue'
const formNameEl = ref()
const formData = ref(${oe(f)})
// todo 存在编辑时,可根据路由等参数设置当前表单模式 1新增 2编辑
const formType = computed(() => {
return 1
})
${_.rulesMethods}
${_.sourceFun}
// 表单提交时参数处理
const beforeSubmit = (params)=>{
// 如编辑时添加参数
// params.id='xxx'
return params
}
<\/script>`;de(()=>{$.value=_e(h,"editJsonCopy","html")})},c=f=>{var K,C,V,F;const _=((K=f.config)==null?void 0:K.openType)==="dialog",u=((C=f.config)==null?void 0:C.dialogWidth)||"600px",T=(V=f.config)==null?void 0:V.requestUrl;T&&delete f.config.requestUrl;const k=(F=f.config)==null?void 0:F.deleteUrl;k&&delete f.config.deleteUrl;let h="",g="",R="";_&&(R='@btn-click="listBtnClick"',h=`<el-dialog
destroy-on-close
v-model="dialog.visible"
:title="dialog.title"
width="${u}"
>
<ak-form
ref="formEl"
:formData="formData"
:dict="dialog.dict"
:type="dialog.formType"
requestUrl=""
addUrl=""
editUrl=""
:beforeSubmit="beforeSubmit"
:afterSubmit="afterSubmit"
@btn-click="dialogBtnClick"
></ak-form>
</el-dialog>`,g=`const formEl = ref()
// todo 表单数据可从设计表单导出vue文件或保存生成脚本
const formData = ref({list:[],form:{},config:{}})
const dialog = reactive({
visible: false,
title: '',
formType: 1,
dict: {},
editId: ''
})
const listBtnClick = (btn, row) => {
// 使用弹窗方式打开新增编辑
if (btn.key === 'add' || btn.key === 'edit') {
// 打开弹窗
dialog.visible = true
dialog.title = btn.key === 'add' ? '新增' : '编辑'
dialog.formType = btn.key === 'add' ? 1 : 2
dialog.editId = row && row.id
if (btn.key === 'add' && formData.value.config?.addLoad) {
// 添加时需要加载数据
nextTick(() => {
formEl.value.getData()
})
}
// 编辑,根据id加载
if (btn.key === 'edit') {
nextTick(() => {
// eslint-disable-next-line no-irregular-whitespace
  // todo 当表单内容字段比较少,所需值从列表数据就可以获取
  // formEl.value.setValue(row)
formEl.value.getData({ id: row.id })
})
}
}
}
// 提交表单前事件
const beforeSubmit = (params) => {
if(dialog.formType===2){ // 编辑模式下添加参数
params.id = dialog.editId
}
return params
}
// 提交表单后事件
const afterSubmit = (type) => {
if (type === 'success') {
// 添加成功,刷新列表数据
closeResetDialog()
tableListEl.value.getListData()
}
}
// 关闭弹窗并重置表单,否则下次打开会保留上次数据
const closeResetDialog = () => {
dialog.visible = false
dialog.editId = ''
// formEl.value.resetFields() // 重置表单
}
// 点击弹窗取消按钮时
const dialogBtnClick = (type) => {
if (type === 'reset') {
closeResetDialog()
}
}
`),N.value=!0;const Z=`<template>
<div>
<ak-list
ref="tableListEl"
requestUrl="${T}"
deleteUrl="${k}"
:searchData="searchData"
:tableData="tableData"
${R}>
</ak-list>
${h}
</div>
</template>
<script setup>
// import {useRoute, useRouter} from 'vue-router'
import { ref, nextTick,reactive } from 'vue'
// const route = useRoute()
// const router = useRouter()
const tableListEl = ref()
const searchData = ref({})
const tableData = ref(${oe(f)})
${g}
<\/script>`;de(()=>{$.value=_e(Z,"editJsonCopy","html")})},e=f=>{N.value=!0;let _="",u="",T="";const k=f.config.style;k&&(_=`<style>
${k}
</style>`),f.config.requestUrl&&(T="import { getGlobalData } from '@/views/design/dataScreen/getData'",u=`const globalScreen = ref({})
provide('globalScreen', globalScreen)
const {requestUrl, afterResponse, beforeRequest, method} = screenData.value.config
getGlobalData(requestUrl, afterResponse, beforeRequest, method)
.then((res: any) => {
globalScreen.value = res
})`);const h=`<template>
<div :style="screenStyle" class="design-canvas">
<ak-screen
v-for="(element, index) in screenData.list"
:key="index"
:data="element"
></ak-screen>
</div>
</template>
<script setup lang="ts">
import { ref, computed, provide } from 'vue'
${T}
const loading = ref(true)
const screenData = ref(${oe(f)})
const screenStyle = computed(() => {
const { width, height, background, primary } = screenData.value.config
return {
width: width,
height: height,
background: background,
color: primary,
position: 'relative'
}
})
${u}
<\/script>
${_}`;de(()=>{$.value=_e(h,"editJsonCopy","html")})},d=f=>{de(()=>{const _=new Xt(f.target,{text:()=>$.value.getValue()});_.on("success",function(){le({message:"复制成功!",type:"success"}),_.destroy()}),_.on("error",function(){le.error("复制失败"),_.destroy()}),_.onClick(f)})},y=()=>{var k;const f="data:text/csv;charset=utf-8,"+((k=$.value)==null?void 0:k.getValue()),_=new Date().getTime()+".vue",u=encodeURI(f),T=document.createElement("a");T.setAttribute("href",u),T.setAttribute("download",_),T.click()};return H({open:t,openTable:c,openScreen:e}),(f,_)=>{const u=he,T=Be;return p(),P(T,{modelValue:N.value,"onUpdate:modelValue":_[0]||(_[0]=k=>N.value=k),title:"导出vue文件",class:"export-dialog",width:"80%"},{footer:r(()=>[O("div",el,[n(u,{size:"small",type:"primary",onClick:d},{default:r(()=>[A(" 复制数据 ")]),_:1}),n(u,{type:"primary",size:"small",onClick:y},{default:r(()=>[A(" 导出代码 ")]),_:1})])]),default:r(()=>[Yt]),_:1},8,["modelValue"])}}});const ll=["innerHTML"],ol=["id"],al={class:"dialog-footer"},nl=se({__name:"aceDrawer",props:{modelValue:{type:Boolean},title:{},direction:{default:"ltr"},content:{default:""},id:{default:"editJson"},codeType:{}},emits:["beforeClose","confirm","update:modelValue"],setup(z,{emit:H}){const N=z,$=te({}),w=te(!1);xe(()=>N.modelValue,d=>{w.value=d,d&&t()});const t=()=>{de(()=>{$.value=_e(N.content,N.id,N.codeType)})},c=()=>{const d=$.value.getValue();H("confirm",d)},e=()=>{H("update:modelValue",!1),H("beforeClose")};return qe(()=>{}),pt(()=>{Object.keys($.value).length!==0&&($.value.destroy(),$.value.container.remove())}),(d,y)=>{const f=he,_=ft;return p(),P(_,{modelValue:w.value,"onUpdate:modelValue":y[0]||(y[0]=u=>w.value=u),size:"60%",title:d.title,direction:d.direction,class:"ace-dialog","append-to-body":!0,"before-close":e},{header:r(()=>[O("div",{innerHTML:d.title},null,8,ll)]),default:r(()=>[w.value?(p(),U("div",{key:0,id:d.id},null,8,ol)):I("",!0),O("div",al,[n(f,{type:"primary",size:"small",onClick:c},{default:r(()=>[A(" 确定 ")]),_:1})])]),_:1},8,["modelValue","title","direction"])}}}),Pe=window.sessionStorage.getItem("tagViews");let Me=[];Pe&&(Me=JSON.parse(Pe));const rl=mt("layout",{state:()=>({breadcrumb:[],tabs:Me,reloadFlag:!0}),actions:{changeBreadcrumb(z){this.breadcrumb=z},setTabsViews(z){this.tabs=z,window.sessionStorage.setItem("tagViews",JSON.stringify(z))},setReloadRouter(){this.reloadFlag=!1,de(()=>{this.reloadFlag=!0})}}}),il={class:"design-container"},sl={class:"main-body"},cl={class:"main-form"},ul={key:0,class:"empty-tips"},dl={class:"dialog-footer"},bl=se({__name:"index",setup(z){rl().changeBreadcrumb([{label:"系统工具"},{label:"表单设计"}]);const N=Ie(),$=vt(),w=bt().query||{},t=ve({formData:{list:[],form:{size:"default",name:""},config:{}},editor:{},loading:!1,formDataPreview:{},previewVisible:!1,designType:w.type,formDict:{},formOtherData:{source:w.source||"",formName:"未命名表单"}}),c=ve({visible:!1,type:"",title:"",codeType:"",direction:void 0,callback:""}),e=te(),d=te();ht("formDesignType",t.designType);const y=()=>{const C=w.id;C&&(t.loading=!0,be("designById",{id:C}).then(V=>{const F=V.data;F.data&&(t.formData=re(F.data)),t.formDict=Ve(F.dict),t.formOtherData.source=F.source,t.formOtherData.formName=F.name,F.source&&t.designType!=="search"&&d.value.getFormFieldBySource(F.source),t.loading=!1}).catch(V=>{le.error(V.message||"加载异常"),t.loading=!1}))},f=C=>{switch(C){case"del":t.formData.list=[],N.setActiveKey(""),N.setControlAttr({});break;case"eye":N.setActiveKey(""),N.setControlAttr({}),t.previewVisible=!0;let V=oe(t.formData);const F=t.formData.form.name,G=new RegExp(`get${F}ControlByName`,"g");V=V.replace(G,`getPreview${F}ControlByName`),t.formDataPreview=re(V),t.formDataPreview.form.name=`Preview${F}`;break;case"json":T({direction:"rtl",content:t.formData,title:"可编辑修改或将已生成的脚本粘贴进来"});break;case"save":u();break;case"vue":e.value.open(t.formData);break}},_=C=>{try{if(typeof c.callback=="function"){const V=c.codeType==="json"?Ve(C):re(C);c.callback(V)}else switch(c.type){