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.

2 lines
10 KiB

3 weeks ago
import{_ as ae,u as U,s as le,g as ne,i as V,j as oe,r as m,k as R,l as v,o as s,c as O,h as c,w as f,F as B,m as w,n as g,d as C,e as ie,t as re,E as Y,p as h,q as P}from"./index-CI8aco7-.js";import{s as se,_ as pe,a as ue,i as ce,b as de,g as me,c as he,d as ge,p as fe,e as ye,f as be,h as _e,j as Ce,k as Oe,l as Ne,q as Se}from"./index-Dt44Wo52.js";import{d as Te}from"./download-DA4MPZiT.js";const Fe={class:"app-container"},ke=Object.assign({name:"tablePage"},{__name:"index",props:{apiName:{type:String,default:null},specialColumnName:{type:String,default:null},specialLocalColumnName:{type:String,default:null},authName:{type:String,default:null},apiType:{type:String,default:null},hideSearch:{type:Boolean,default:!1},multipleTable:{type:Boolean,default:!1},leftOperation:{type:Object,default:null},leftOperationColumnWidth:{type:Number,default:120},rightOperation:{type:[Object,String],default:null},showApiRightOperation:{type:Object,default:null},apiRightHideConfig:{type:Object,default:{apiUpdate:{prop:"writeState",ruleValue:!0},apiDelete:{prop:"writeState",ruleValue:!0}}},tableColumns:{type:Object,default:null},searchOptions:{type:Object,default:[]},searchButtons:{type:Object,default:["search","export"]},searchFilter:{type:Object,default:{}},searchFilterOptions:{type:Object,default:{}},columnWidth:{type:Number,default:120},columnHeaderAlign:{type:String,default:"center"},columnAlign:{type:String,default:"center"},apiEditFormRules:{type:Object,default:null},hideSetColums:{type:Boolean,default:!1}},emits:["leftOperationHadel","rightOperationHadel","tableSelectionHandle"],setup(E,{expose:j,emit:L}){const M=U(),b=le.userStore().state,a=ne({loading:!1,searchBtnOptions:{search:{icon:"Search",auth:":page",label:"查询",type:null},create:{icon:"Plus",auth:":create",label:"新增",type:"primary"},import:{icon:"BottomRight",auth:":import",label:"导入",type:"warning"},export:{icon:"TopRight",auth:":export",label:"导出",type:"success"},custominvoke:{icon:"Position",auth:":custominvoke",label:"手动开关",type:"primary"}},innerTableColumns:null,tableData:[],sortFilter:{sortBy:void 0,isAscending:void 0},pager:{page:1,pageSize:10,total:1},tableSelectList:[],initTableColums:[],localTableColumnsName:null}),e=E;function N(){let l=e.specialLocalColumnName||U().name;a.localTableColumnsName=me(l);let t=JSON.parse(localStorage.getItem(a.localTableColumnsName)),i=e.specialColumnName||e.apiName;a.initTableColums=e.tableColumns||he[i];let n=t&&t!=null&&t!=null?t:JSON.parse(JSON.stringify(a.initTableColums));return a.innerTableColumns=n,n}const S=L;function W(l){a.tableSelectList=l,S("tableSelectionHandle",l)}function z(l,t){S("leftOperationHadel",l,t)}function D(){if(typeof e.rightOperation=="object"&&!e.showApiRightOperation)return e.rightOperation;if(typeof e.rightOperation=="object"&&e.showApiRightOperation||typeof e.rightOperation=="string"){let l=e.showApiRightOperation||e.rightOperation.split(","),t={apiUpdate:{label:"编辑",type:"warning"},apiDelete:{label:"删除",type:"danger"}},i=[];return l&&l.length>0&&l.forEach(n=>{i.push({label:t[n].label,name:n,link:!0,type:t[n].type,auth:(e.authName||e.apiName)+":"+n,hide:(r,_)=>r[e.apiRightHideConfig[n].prop]==e.apiRightHideConfig[n].ruleValue})}),typeof e.rightOperation=="object"&&(i=[...i,...e.rightOperation]),i}}const d=V();function $(l,t){if(l.name=="apiUpdate"){let n=N().filter(r=>!r.noEdit);d.value.open(n,t.row)}l.name=="apiDelete"&&Y.confirm("是否确定删除?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{a.loading=!0,ge(e.apiName,t.row.uId).then(i=>{h.success("操作成功!"),p(1)}).finally(()=>{a.loading=!1})}),S("rightOperationHadel",l,t)}const q=async(l,t,i)=>{d.value.validate(n=>{n&&(l=="create"?(t.hasOwnProperty("createUser")&&(t.createUser=b.realName),t.hasOwnProperty("createByUser")&&(t.createByUser=b.realName),t.hasOwnProperty("createTime")&&(t.createTime=P(new Date,"YYYY-mm-dd HH:MM:SS")),d.value.changeLoading(!0),fe(e.apiName,t).then(r=>{d.value.close(),h.success("操作成功!"),p(1)}).catch(r=>{h.error("操作失