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,mn as y,p as b,w as x}from"./_plugin-vue_export-helper-C0lsYS1a.js";import{c as S,i as C,o as w,r as T,t as E}from"./GxPagination-DaT0MOF0.js";import{n as D,t as O}from"./form-B9CYF2OU.js";import{t as k}from"./button-CTBy3KbX.js";import{Ia as A,Ma as j,Tr as M}from"./stores-PVUTfPb_.js";import{g as N}from"./useStructurizedVersionDialog-ByTgs9AA.js";import{a as P}from"./validate-C3ezFD8l.js";var F={class:``},I={class:`flex flex-row justify-between items-center`},L={key:0,class:`flex flex-row items-center`},R={class:`mt-3`},z={class:`flex flex-row flex-wrap justify-left`},B=a({__name:`FileListTable`,props:{needUpdate:{type:Boolean},zxlPrdId:{},documentType:{},userRequestObId:{},testCaseObId:{},menuOperationObId:{},versionId:{},enableSearch:{type:Boolean,default:!0}},setup(a,{expose:y}){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 M(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 A({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&&P({type:`success`,message:`刷新成功`}),console.log(e),H.value=e?.data||[],U.total=e?.total||0}catch(e){P({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 A({url:o,method:`post`,data:{fileType:n,fileForm:r,zxlPrdId:t,userRequestObId:i||null,testCaseObId:a||null,...s}}),P({type:`success`,message:`操作成功`}),Y.versionObId?Y.versionObId=void 0:X()}catch(e){P({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)N(n,`${e.fileType}.${e.fileForm?.toLowerCase()||`doc`}`);else throw Error(`下载地址为空！`)}catch(e){P({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()}),y({updateGenerateDocumentList:X,confimGenerateDocument:Z}),(r,s)=>{let c=w,f=S,v=D,y=O,A=k,j=C,M=T,N=E;return u(),i(`div`,F,[n(`div`,I,[e(r.$slots,`generate-btn`),a.enableSearch?(u(),i(`div`,L,[t(y,{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(),x(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),[[b,!V.value]])])):l(``,!0)]),n(`div`,R,[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`,z,[e.fileStatus&&/^GENERATED/.test(e.fileStatus)?(u(),x(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(),x(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{B as t};