import{s as e,r as a}from"./index.f608f11e.js";import{d as l,k as t,o as d,J as s,r as i,F as n,c as o,b as r,W as u,X as c,B as f,Y as m,Z as _,$ as p,V as v,Q as y,H as b,K as g,x as h,I as x,O as k,P as I,T as w,m as C}from"./vendor.98dba853.js";const F={add:"新增",modify:"修改",delete:"删除",none:""},D=l({name:"ProductDataSet",setup(){const l=t();console.log("route:: ",l),d((()=>{e.dispatch("dataset/getDatasetFields",{dataset_id:l.query.dataset_id,page_size:10,page_index:1})}));const D=s([]),q=s("none"),z=s(""),O=i({id:0,field_name:"",field_type:0,field_describe:""}),T=i({field_name:[{required:!0,message:"请输入字段名称"}],field_type:[{required:!0,message:"请输入字段类型"}],field_describe:[{required:!0,message:"请输入字段说明"}]}),{resetFields:S,validate:R,validateInfos:U,mergeValidateInfo:j}=n.useForm(O,T),K=()=>{S(),q.value="add"},P=a=>{console.log("delete item:: ",a);const l=a instanceof Array?a:[a.id];y.confirm({title:"确定要删除吗？",okText:"确定",cancelText:"取消",onOk:()=>{e.dispatch("dataset/deleteDatasetFields",{list_id:l})}})},V=[{title:"ID",dataIndex:"id",resizable:!0,width:50},{title:"所属数据集",dataIndex:"dataset_id",resizable:!0,width:200,customRender:({record:e})=>o(b,null,[l.query.dataset_name])},{title:"字段名称",dataIndex:"field_name"},{title:"字段类型",dataIndex:"field_type",customRender:({record:e})=>o(b,null,[0==e.field_type?"数字":"字符串"])},{title:"说明",dataIndex:"field_describe"},{title:"创建时间",dataIndex:"create_time",resizable:!0,width:200},{key:"action",title:"操作",width:135,customRender:({record:e})=>o(b,null,[o(f,{size:"small",type:"primary",style:{margin:"0 5px 5px 0"},onClick:()=>{return a=e,O.field_name=a.field_name,O.field_type=a.field_type,O.field_describe=a.field_describe,O.id=a.id,void(q.value="modify");var a}},{default:()=>[r("修改")]}),o(f,{size:"small",type:"ghost",danger:!0,onClick:()=>P(e)},{default:()=>[r("删除")]})])}];return()=>{return o(b,null,[o("h2",{class:"title"},[r("字段配置管理"),o(u,{onSearch:e=>{z.value=e},class:"title-search",placeholder:"请输入字段名称"},null)]),o(c,null,null),o("div",{class:"table"},[o(f,{type:"ghost",danger:!0,icon:o(m,null,null),class:"table-delete "+(0==D.value.length?"hidden":""),onClick:()=>P(D.value)},{default:()=>[r("删除")]}),o(f,{type:"primary",icon:o(_,null,null),class:"table-add",onClick:K},{default:()=>[r("新增")]}),o(f,{type:"ghost",icon:o(p,null,null),class:"table-back",onClick:()=>a.back()},{default:()=>[r("返回")]}),o(v,{rowKey:"id",bordered:!0,loading:e.state.dataset.loading,columns:V,dataSource:(t=e.state.dataset.datasetsFields,z.value?t.filter((e=>e.field_name.indexOf(z.value)>-1)):t),rowSelection:{onChange:e=>{D.value=e}}},null)]),o(y,{title:()=>o(b,null,[o("strong",null,[F[q.value]]),r(" 字段集配置")]),width:800,visible:"none"!=q.value,closable:!0,onOk:()=>{console.log("itemData:: ",O),R().then((()=>{O.dataset_id=parseInt(l.query.dataset_id),0==O.id?e.dispatch("dataset/postDatasetField",O):e.dispatch("dataset/putDatasetField",O),q.value="none"})).catch((e=>{C.warn("表单字段填写有误，请检查后再次提交")}))},okText:"确定",cancelText:"取消",onCancel:()=>q.value="none",destroyOnClose:!1},{default:()=>[o(n,{name:"field"},{default:()=>[o(g,h({label:"字段名称"},U.field_name),{default:()=>[o(x,{value:O.field_name,"onUpdate:value":e=>O.field_name=e},null)]}),o(g,h({label:"字段类型"},U.field_type),{default:()=>[o(k,{value:O.field_type,"onUpdate:value":e=>O.field_type=e},{default:()=>[o(I,{value:0},{default:()=>[r("数字")]}),o(I,{value:1},{default:()=>[r("字符串")]})]})]}),o(g,h({label:"字段信息"},U.field_describe),{default:()=>[o(w,{value:O.field_describe,"onUpdate:value":e=>O.field_describe=e},null)]})]})]})]);var t}}});export{D as default};
