import { O as T } from './index.00e2f453.js'
import { O as b } from './index.4f243ca1.js'
import {
  d as N,
  R as C,
  X as v,
  k as e,
  be as j,
  F as y,
  ad as w,
  g as f,
  s as q,
  b8 as k,
  aQ as B,
  l as h,
  B as F,
  j as S
} from './index.879f7421.js'
import { O as I } from './index.c8b56350.js'
import { O as L } from './index.67af0c64.js'
import { i as O } from './icon_teacher.40b6f077.js'
import { L as A } from './index.9f8069d8.js'
import { C as E } from './index.9a3a3b84.js'
import { I as G } from './index.c463dbd0.js'
import { T as x } from './index.30499db4.js'
import { C as V } from './index.4aec72fa.js'
import { a as z } from './function-call.3c67215d.js'
import './index.00975bf6.js'
import './use-tab-status.fe36a003.js'
const R = '_unbindTips_1tv2q_1',
  D = '_detailCellGroup_1tv2q_11',
  $ = '_detailCell_1tv2q_11',
  M = '_teacherName_1tv2q_23',
  U = '_teacherContent_1tv2q_29',
  H = '_content_1tv2q_34',
  P = '_classNum_1tv2q_37',
  Q = '_className_1tv2q_41',
  X = '_musicName_1tv2q_47',
  J = '_nums_1tv2q_52',
  K = '_numTip_1tv2q_58'
var c = {
  unbindTips: R,
  detailCellGroup: D,
  detailCell: $,
  teacherName: M,
  teacherContent: U,
  content: H,
  classNum: P,
  className: Q,
  musicName: X,
  nums: J,
  numTip: K
}
const W = '_name_nzdqe_1',
  Y = '_img_nzdqe_8',
  Z = '_subjects_nzdqe_15'
var i = { name: W, img: Y, subjects: Z }
function g(l) {
  return (
    typeof l == 'function' || (Object.prototype.toString.call(l) === '[object Object]' && !w(l))
  )
}
var ee = N({
  name: 'teacher',
  emits: ['close', 'select'],
  setup(l, { slots: _, attrs: n, emit: d }) {
    const t = C({
        schoolId: null,
        list: [],
        listState: { dataShow: !0, loading: !1, finished: !1 },
        params: { keyword: null, page: 1, rows: 20 },
        selectItem: {}
      }),
      u = async () => {
        try {
          const a = await f.post('/api-school/teacher/page', {
            data: { ...t.params, schoolId: q.user.data.school.id }
          })
          t.listState.loading = !1
          const s = a.data || {}
          if (t.list.length > 0 && s.current === 1) return
          const r = s.rows || []
          r.forEach((m) => {
            m.subjectNames = m.subjectName ? m.subjectName.split(',') : []
          }),
            (t.list = t.list.concat(r)),
            (t.listState.finished = s.current >= s.pages),
            (t.params.page = s.current + 1),
            (t.listState.dataShow = t.list.length > 0)
        } catch {
          ;(t.listState.dataShow = !1), (t.listState.finished = !0)
        }
      },
      p = () => {
        ;(t.params.page = 1),
          (t.list = []),
          (t.listState.dataShow = !0),
          (t.listState.loading = !1),
          (t.listState.finished = !1),
          u()
      },
      o = (a) => {
        d('select', a), d('close')
      }
    return (
      v(() => {
        u()
      }),
      () => {
        let a
        return e(y, null, [
          e(
            b,
            { position: 'top' },
            {
              default: () => [
                e(T, { title: '\u4EA4\u63A5\u8001\u5E08' }, null),
                e(
                  L,
                  {
                    placeholder: '\u8BF7\u8F93\u5165\u8001\u5E08\u59D3\u540D',
                    inputBackground: 'white',
                    background: '#F8F8F8',
                    onSearch: (s) => {
                      ;(t.params.keyword = s), p()
                    }
                  },
                  null
                )
              ]
            }
          ),
          t.listState.dataShow
            ? e(
                A,
                {
                  loading: t.listState.loading,
                  'onUpdate:loading': (s) => (t.listState.loading = s),
                  finished: t.listState.finished,
                  finishedText: ' ',
                  class: [i.liveList],
                  onLoad: u,
                  immediateCheck: !1
                },
                g(
                  (a = t.list.map((s) =>
                    e(
                      E,
                      { onClick: () => o(s) },
                      {
                        icon: () => e(G, { class: i.img, src: s.avatar || O }, null),
                        title: () =>
                          e('div', { class: i.content }, [
                            e('p', { class: [i.name, 'van-ellipsis'] }, [s.nickname]),
                            e('p', { class: i.subjects }, [
                              s.subjectNames &&
                                s.subjectNames.length > 0 &&
                                s.subjectNames.map((r) =>
                                  e(x, { type: 'primary' }, g(r) ? r : { default: () => [r] })
                                )
                            ])
                          ])
                      }
                    )
                  ))
                )
                  ? a
                  : { default: () => [a] }
              )
            : e(
                j,
                {
                  btnStatus: !1,
                  classImgSize: 'SMALL',
                  tips: '\u6682\u65E0\u4F34\u5B66\u8001\u5E08'
                },
                null
              )
        ])
      }
    )
  }
})
function te(l) {
  return (
    typeof l == 'function' || (Object.prototype.toString.call(l) === '[object Object]' && !w(l))
  )
}
var _e = N({
  name: 'unbind',
  setup() {
    const l = k(),
      _ = B(),
      n = C({ teacherStatus: !1, classList: [], selectTeacher: {} }),
      d = async () => {
        try {
          const o = l.query,
            { data: a } = await f.post('/api-school/classGroup/page', {
              data: { teacherId: o.id, schoolId: q.user.data.school.id, page: 1, rows: 100 }
            })
          n.classList = a.rows || []
        } catch {}
      },
      t = (o) => {
        ;(n.teacherStatus = !0), (n.selectTeacher = o)
      },
      u = (o) => {
        console.log(o, 'steacher'), (n.selectTeacher.sTeacher = o)
      },
      p = () => {
        console.log('submit')
        let o = !1
        const a = []
        if (
          (n.classList.forEach((s) => {
            ;(!s.sTeacher || (s.sTeacher && !s.sTeacher.id)) && (o = !0),
              s.sTeacher && a.push({ classGroupId: s.id, teacherId: s.sTeacher.id })
          }),
          o)
        ) {
          S('\u8BF7\u9009\u62E9\u4EA4\u63A5\u8001\u5E08')
          return
        }
        try {
          z({
            title: '\u63D0\u793A',
            message: '\u662F\u5426\u786E\u8BA4\u4EA4\u63A5',
            showCancelButton: !0
          }).then(async () => {
            await f.post('/api-school/classGroup/handoverTeacher', {
              data: { teacherId: l.query.id, updateTeacherList: [...a] }
            }),
              setTimeout(() => {
                S('\u4EA4\u63A5\u6210\u529F')
              }, 100),
              setTimeout(() => {
                _.replace('/companion-teacher')
              }, 1e3)
          })
        } catch {}
      }
    return (
      v(() => {
        d()
      }),
      () => {
        let o
        return e(y, null, [
          e(T, null, null),
          e('div', { class: c.unbindTips }, [
            h(
              '\u8BE5\u4F34\u5B66\u8001\u5E08\u5B58\u5728\u4EE5\u4E0B\u73ED\u7EA7\u53CA\u8BFE\u7A0B\u672A\u5F00\u59CB\uFF0C\u8BF7\u9009\u62E9\u4EA4\u63A5\u8001\u5E08'
            )
          ]),
          e(
            V,
            { inset: !0, class: c.detailCellGroup },
            te(
              (o = n.classList.map((a) =>
                e(
                  E,
                  { center: !0, class: c.detailCell, isLink: !0, onClick: () => t(a) },
                  {
                    title: () =>
                      e('div', { class: c.teacherContent }, [
                        e('div', { class: c.classInfo }, [
                          e('p', { class: c.className }, [a.name]),
                          e('p', { class: c.musicName }, [a.orchestraName])
                        ]),
                        e('div', { class: c.classNum }, [
                          e('p', { class: c.nums }, [
                            a.courseScheduleNum - a.completeCourseScheduleNum
                          ]),
                          e('p', { class: c.numTip }, [h('\u5269\u4F59\u8BFE\u65F6')])
                        ])
                      ]),
                    value: () =>
                      e('span', { class: c.teacherName }, [a.sTeacher && a.sTeacher.nickname])
                  }
                )
              ))
            )
              ? o
              : { default: () => [o] }
          ),
          e(
            b,
            { position: 'bottom' },
            {
              default: () => [
                e(
                  'div',
                  { class: ['btnGroup'], style: { paddingLeft: '13px', paddingRight: '13px' } },
                  [
                    e(
                      F,
                      { type: 'primary', round: !0, block: !0, onClick: p },
                      { default: () => [h('\u786E\u8BA4\u4EA4\u63A5')] }
                    )
                  ]
                )
              ]
            }
          ),
          e(
            I,
            { modelValue: n.teacherStatus, 'onUpdate:modelValue': (a) => (n.teacherStatus = a) },
            { default: () => [e(ee, { onClose: () => (n.teacherStatus = !1), onSelect: u }, null)] }
          )
        ])
      }
    )
  }
})
export { _e as default }
