import{B as A,C as S,m as f,cX as G,cY as j,cW as q}from"./index-mobile-Cdp4yXnt.js";import{d as $,e as M,f as C,r as F,c as X,w as L,P as w,Q as p,U as I,R as Q,X as W,m as a,a3 as Y,_ as u,F as Z,af as H,Z as y,u as J,a4 as K,ab as h,a0 as ee}from"./vue-C-_v7KcX.js";import{m as te,D as se,F as ae,l as oe,d as ne,B as le,A as re}from"./element-plus-iuNPLb4-.js";const ie={class:""},de={class:"flex flex-row justify-between items-center"},ce={key:0,class:"flex flex-row items-center"},ue={class:"mt-3"},pe={class:"flex flex-row flex-wrap justify-left"},ge=$({__name:"FileListTable",props:{needUpdate:{type:Boolean},zxlPrdId:{},documentType:{},userRequestObId:{},testCaseObId:{},menuOperationObId:{},versionId:{},enableSearch:{type:Boolean,default:!0}},setup(x,{expose:P}){const l=x,g=M(()=>!!l.versionId),E=C([]),i=F({currentPage:1,pageSize:10,total:0}),R={TO_BE_GENERATED:"待生成",GENERATING:"生成中",GENERATED:"已生成",GENERATED_FAIL:"生成失败"},N=(t,e,s,c)=>s&&R[s]||"",b=C(!1),O=X({lastest:null,versionList:[]}),U=async()=>{if(l.zxlPrdId)try{const e=(await q(l.zxlPrdId))?.data||[];O.versionList=e||[],r.versionObId=l.versionId||void 0}catch{}},r=F({versionObId:void 0,documentType:l.documentType}),d=async t=>{const e=t==="show-tip";b.value=!0;try{const s={cmd:"getFileList",zxlPrdId:l.zxlPrdId,versionId:g.value?l.versionId:r.versionObId,fileType:r.documentType,isPaging:!0,page:i.currentPage,pageSize:i.pageSize,relationObjectObId:l.userRequestObId||l.testCaseObId||l.menuOperationObId||null},c=await S({url:"/zxl_pm/general/file.svc",method:"get",params:s});e&&f({type:"success",message:"刷新成功"}),console.log(c),E.value=c?.data||[],i.total=c?.total||0}catch(s){f({type:"error",message:s||"获取分享记录失败！"})}b.value=!1},k=async t=>{const e=l.zxlPrdId;b.value=!0;try{const{documentType:s,fileForm:c,userRequestObId:v,testCaseObId:_,generateUrl:m="/zxl_pm/general/file.svc?cmd=createFile",extraParams:n}=t,z=await S({url:m,method:"post",data:{...{fileType:s,fileForm:c,zxlPrdId:e,userRequestObId:v||null,testCaseObId:_||null},...n}});f({type:"success",message:"操作成功"}),r.versionObId?r.versionObId=void 0:d()}catch(s){f({type:"error",message:s||"操作失败！"})}b.value=!1},D=async t=>{const e=await j(t);return e&&e.url||""},B=async t=>{const e=t.fileId;t.downloadLoading=!0;try{if(!e)throw new Error("参数错误！");const s=await D(t.fileId);if(s)G(s,`${t.fileType}.${t.fileForm?.toLowerCase()||"doc"}`);else throw new Error("下载地址为空！")}catch(s){f({type:"error",message:s||"下载失败！"})}t.downloadLoading=!1};return L(()=>l.needUpdate,async t=>{t&&(await U(),d())},{immediate:!0}),L(()=>r.versionObId,async t=>{d()}),P({updateGenerateDocumentList:d,confimGenerateDocument:k}),(t,e)=>{const s=ae,c=se,v=te,_=oe,m=ne,n=le,T=re,z=A;return p(),w("div",ie,[I("div",de,[Q(t.$slots,"generate-btn"),x.enableSearch?(p(),w("div",ce,[a(_,{model:r,ref:"fromRef","label-width":"auto",inline:!0},{default:u(()=>[a(v,{class:"!mb-0",label:"版本：",prop:"versionObId"},{default:u(()=>[a(c,{class:"!w-40",modelValue:r.versionObId,"onUpdate:modelValue":e[0]||(e[0]=o=>r.versionObId=o),clearable:"",disabled:g.value},{default:u(()=>[(p(!0),w(Z,null,H(J(O).versionList,o=>(p(),y(s,{key:o.versionTranId,value:o.versionTranId,label:o.versionNo+" "+o.statusCn},null,8,["value","label"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1})]),_:1},8,["model"]),Y(a(m,{type:"primary",bg:"",onClick:ee(d,["stop"])},{default:u(()=>[...e[4]||(e[4]=[h("查询",-1)])]),_:1},512),[[K,!g.value]])])):W("",!0)]),I("div",ue,[a(T,{class:"",data:E.value,stripe:""},{default:u(()=>[a(n,{width:"100",prop:"fileNo",label:"编号"}),a(n,{"min-width":"150",prop:"fileType",label:"文件类型"}),a(n,{width:"100",prop:"fileForm",label:"格式"}),a(n,{width:"100",prop:"version",label:"版本"}),a(n,{width:"120",prop:"submitUserName",label:"提交人"}),a(n,{width:"160",prop:"submitTime",label:"提交时间"}),a(n,{width:"160",prop:"beginTime",label:"开始生成时间"}),a(n,{width:"160",prop:"finishTime",label:"生成完成时间"}),a(n,{width:"120",prop:"fileSizeStr",label:"大小"}),a(n,{width:"80",prop:"fileStatus",label:"状态",formatter:N,fixed:"right"}),a(n,{width:"120",label:"操作",align:"left",fixed:"right"},{default:u(({row:o})=>[I("div",pe,[o.fileStatus&&/^GENERATED/.test(o.fileStatus)?(p(),y(m,{key:0,loading:o.downloadLoading,class:"!p-1",text:"",bg:"",onClick:V=>B(o)},{default:u(()=>[...e[5]||(e[5]=[h("下载",-1)])]),_:1},8,["loading","onClick"])):(p(),y(m,{key:1,class:"!p-1",text:"",bg:"",onClick:e[1]||(e[1]=V=>d("show-tip"))},{default:u(()=>[...e[6]||(e[6]=[h("刷新",-1)])]),_:1}))])]),_:1})]),_:1},8,["data"]),a(z,{class:"pt-3 justify-end","current-page":i.currentPage,"onUpdate:currentPage":e[2]||(e[2]=o=>i.currentPage=o),"page-size":i.pageSize,"onUpdate:pageSize":e[3]||(e[3]=o=>i.pageSize=o),"page-sizes":[10,20,50,100],background:!0,layout:"total, sizes, prev, pager, next, jumper",total:i.total,onSizeChange:d,onCurrentChange:d},null,8,["current-page","page-size","total"])])])}}});export{ge as _};
