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