import{i as e,t}from"./react-B8IZ02wI.js";import{t as n}from"./select-CDwQ-YxO.js";import{c as r,k as i,m as a}from"./authStore-BvQBJ9ky.js";import{n as o,pt as s,ut as c}from"./index-Bg7bo8aA.js";var l=e(t(),1),u=o(),d={DEVICE_FAULT:{type:`DEVICE`,label:`关联设备`},BAN:{type:`ACCOUNT`,label:`关联账号`},SIM_FAULT:{type:`SIM`,label:`关联 SIM 卡`},OTHER:null};function f({form:e}){let t=s.useWatch(`report_type`,e),o=t?d[t]:null,[f,p]=(0,l.useState)([]),[m,h]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(!o){e.setFieldsValue({resource_type:void 0,resource_id:void 0}),p([]);return}let t=e.getFieldValue(`resource_id`);e.setFieldsValue({resource_type:o.type}),h(!0),(async()=>{try{o.type===`DEVICE`?p(((await a.list({page:1,size:200})).data.list||[]).map(e=>({value:e.id,label:`${e.deviceCode} · ${e.brand||``} ${e.model||``}`.trim()}))):o.type===`ACCOUNT`?p(((await r.list({page:1,size:200})).data.list||[]).map(e=>({value:e.id,label:`${e.accountCode} · ${e.accountName||``}`.trim()}))):p(((await i.list({page:1,size:200})).data.list||[]).map(e=>({value:e.id,label:`${e.simCode} · ${e.phoneNumber||`—`}`}))),t&&e.setFieldsValue({resource_id:t})}finally{h(!1)}})()},[t,e,o?.type]),o?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(s.Item,{name:`resource_type`,hidden:!0,children:(0,u.jsx)(c,{})}),(0,u.jsx)(s.Item,{name:`resource_id`,label:o.label,children:(0,u.jsx)(n,{allowClear:!0,showSearch:!0,loading:m,placeholder:`请选择${o.label.replace(`关联 `,``)}`,optionFilterProp:`label`,options:f})})]}):null}export{f as t};