import { O as S } from './index.00e2f453.js'
import { O as B, i as b, a as N } from './index.9a8cd497.js'
import { O as F } from './index.67af0c64.js'
import { O as y } from './index.4f243ca1.js'
import { i as E, a as k, b as j } from './icon-message.4fd79f9f.js'
import { i as P } from './icon_teacher.40b6f077.js'
import {
  d as L,
  aQ as A,
  R as O,
  X as D,
  s as _,
  k as e,
  a2 as i,
  l,
  be as M,
  P as h,
  p as f,
  F as Q,
  ad as z,
  g
} from './index.879f7421.js'
import { a as U } from './index.a25f99fd.js'
import { A as G } from './index.5e1e8fd9.js'
import { L as V } from './index.9f8069d8.js'
import { C as q } from './index.9a3a3b84.js'
import { I as c } from './index.c463dbd0.js'
import { T as K } from './index.30499db4.js'
import { G as C, a as u } from './index.6515ab4b.js'
import { P as R } from './index.ea988859.js'
import './index.00975bf6.js'
import './use-tab-status.fe36a003.js'
import './index.58ad42d7.js'
import './index.3c962eae.js'
import './index.e17cc929.js'
const H = '_searchBand_p2lg0_1',
  W = '_manageCell_p2lg0_7',
  X = '_teacherContent_p2lg0_14',
  J = '_content_p2lg0_19',
  Y = '_name_p2lg0_22',
  Z = '_classNum_p2lg0_29',
  $ = '_num_p2lg0_33',
  ee = '_numText_p2lg0_39',
  se = '_messageImg_p2lg0_44',
  te = '_img_p2lg0_49',
  oe = '_phone_p2lg0_62',
  ae = '_status_p2lg0_67',
  le = '_frozen_p2lg0_72',
  ne = '_codeContainer_p2lg0_75',
  ce = '_codeImg_p2lg0_75',
  re = '_codeContent_p2lg0_82',
  ie = '_codeTitle_p2lg0_85',
  ue = '_codeName_p2lg0_93',
  de = '_codeQr_p2lg0_99',
  pe = '_codeBtnText_p2lg0_112',
  me = '_codeTips_p2lg0_122',
  he = '_close_p2lg0_130',
  ge = '_codeBottom_p2lg0_135',
  _e = '_title_p2lg0_142',
  fe = '_shareImg_p2lg0_157',
  Ce = '_shareText_p2lg0_161'
var o = {
  searchBand: H,
  manageCell: W,
  teacherContent: X,
  content: J,
  name: Y,
  classNum: Z,
  num: $,
  numText: ee,
  messageImg: se,
  img: te,
  phone: oe,
  status: ae,
  frozen: le,
  codeContainer: ne,
  codeImg: ce,
  codeContent: re,
  codeTitle: ie,
  codeName: ue,
  codeQr: de,
  codeBtnText: pe,
  codeTips: me,
  close: he,
  codeBottom: ge,
  title: _e,
  shareImg: fe,
  shareText: Ce
}
function w(r) {
  return (
    typeof r == 'function' || (Object.prototype.toString.call(r) === '[object Object]' && !z(r))
  )
}
var Qe = L({
  name: 'companion-teacher',
  setup() {
    const r = A(),
      s = O({
        showMessage: !1,
        showPopover: !1,
        oPopover: !1,
        showQrcode: !1,
        schoolName: null,
        schoolId: null,
        url: null,
        subjectList: [],
        list: [],
        listState: { dataShow: !0, loading: !1, finished: !1 },
        subjectText: '\u5168\u90E8\u58F0\u90E8',
        statusText: '\u72B6\u6001',
        params: { keyword: null, status: null, subjectId: null, page: 1, rows: 20 },
        selectItem: {}
      }),
      v = async () => {
        try {
          const { data: a } = await g.post('/api-school/subject/page', {
            data: { page: 1, rows: 50 }
          })
          ;(a.rows || []).forEach((n) => {
            s.subjectList.push({ text: n.name, value: n.id })
          })
        } catch {}
      },
      T = async (a) => {
        try {
          const t = await g.get('/api-school/schoolStaff/detail/' + a)
          console.log(t, 'res'),
            (s.schoolName = t.data.schoolName),
            (s.schoolId = t.data.schoolId),
            (s.url =
              location.origin +
              '/orchestra-school/#/companion-teacher-register?id=' +
              t.data.schoolId +
              '&name=' +
              t.data.schoolName)
        } catch {}
      },
      d = async () => {
        try {
          const a = await g.post('/api-school/teacher/page', {
            data: { ...s.params, schoolId: _.user.data.school.id }
          })
          s.listState.loading = !1
          const t = a.data || {}
          if (s.list.length > 0 && t.current === 1) return
          const n = t.rows || []
          n.forEach((m) => {
            m.subjectNames = m.subjectName ? m.subjectName.split(',') : []
          }),
            (s.list = s.list.concat(n)),
            (s.listState.finished = t.current >= t.pages),
            (s.params.page = t.current + 1),
            (s.listState.dataShow = s.list.length > 0)
        } catch {
          ;(s.listState.dataShow = !1), (s.listState.finished = !0)
        }
      },
      p = () => {
        ;(s.params.page = 1),
          (s.list = []),
          (s.listState.dataShow = !0),
          (s.listState.loading = !1),
          (s.listState.finished = !1),
          d()
      },
      x = (a) => {
        r.push({ path: '/companion-teacher-detail', query: { id: a.id } })
      },
      I = (a) => {
        ;(s.subjectText = a.selectedOptions[0].text),
          (s.params.subjectId = a.selectedOptions[0].value),
          (s.showPopover = !1),
          p()
      }
    return (
      D(() => {
        T(_.user.data.id), v(), d()
      }),
      () => {
        let a
        return e(Q, null, [
          e(
            y,
            { position: 'top' },
            {
              default: () => [
                e(
                  S,
                  { border: !1 },
                  {
                    right: () =>
                      e(i, { name: 'plus', size: 19, onClick: () => (s.showQrcode = !0) }, null)
                  }
                ),
                e(
                  F,
                  {
                    placeholder: '\u8BF7\u8F93\u5165\u4F34\u5B66\u8001\u5E08\u59D3\u540D',
                    inputBackground: 'white',
                    background: '#f6f8f9',
                    onSearch: (t) => {
                      ;(s.params.keyword = t), p()
                    }
                  },
                  null
                ),
                e('div', { style: { padding: '12px 13px 16px', background: '#F8F8F8' } }, [
                  e('div', { class: o.searchBand, onClick: () => (s.showPopover = !0) }, [
                    s.subjectText,
                    l(' '),
                    e(i, { name: s.showPopover ? 'arrow-up' : 'arrow-down' }, null)
                  ]),
                  e(
                    'div',
                    {
                      class: o.searchBand,
                      style: 'margin-left: 16px',
                      onClick: () => (s.oPopover = !0)
                    },
                    [
                      s.statusText,
                      l(' '),
                      e(i, { name: s.oPopover ? 'arrow-up' : 'arrow-down' }, null)
                    ]
                  )
                ])
              ]
            }
          ),
          s.listState.dataShow
            ? e(
                V,
                {
                  loading: s.listState.loading,
                  'onUpdate:loading': (t) => (s.listState.loading = t),
                  finished: s.listState.finished,
                  finishedText: ' ',
                  class: [o.liveList],
                  onLoad: d,
                  immediateCheck: !1
                },
                w(
                  (a = s.list.map((t) =>
                    e(
                      q,
                      { center: !0, isLink: !0, class: o.manageCell, onClick: () => x(t) },
                      {
                        icon: () => e(c, { class: o.img, src: t.avatar ? t.avatar : P }, null),
                        title: () =>
                          e('div', { class: o.teacherContent }, [
                            e('div', { class: o.content }, [
                              e('p', { class: [o.name, 'van-ellipsis'] }, [t.nickname]),
                              e('p', { class: o.subjects }, [
                                t.subjectNames &&
                                  t.subjectNames.length > 0 &&
                                  t.subjectNames.map((n) =>
                                    e(K, { type: 'primary' }, w(n) ? n : { default: () => [n] })
                                  )
                              ])
                            ]),
                            e('div', { class: o.classNum }, [
                              e('p', { class: o.num }, [
                                t.completedCourseScheduleNum || 0,
                                l('/'),
                                t.totalCourseScheduleNum || 0
                              ]),
                              e('p', { class: o.numText }, [l('\u8BFE\u65F6')])
                            ]),
                            e(
                              'div',
                              {
                                class: o.message,
                                onClick: (n) => {
                                  n.stopPropagation(),
                                    n.preventDefault(),
                                    (s.showMessage = !0),
                                    (s.selectItem = t)
                                }
                              },
                              [e(c, { class: o.messageImg, src: E }, null)]
                            )
                          ]),
                        value: () =>
                          e('span', { class: [o.status, t.status === 'LOCKED' ? o.frozen : ''] }, [
                            U[t.status]
                          ])
                      }
                    )
                  ))
                )
                  ? a
                  : { default: () => [a] }
              )
            : e(
                M,
                {
                  btnStatus: !1,
                  classImgSize: 'SMALL',
                  tips: '\u6682\u65E0\u4F34\u5B66\u8001\u5E08'
                },
                null
              ),
          e(
            h,
            {
              show: s.showQrcode,
              'onUpdate:show': (t) => (s.showQrcode = t),
              position: 'bottom',
              style: { background: 'transparent' },
              safeAreaInsetBottom: !0
            },
            {
              default: () => [
                e('div', { class: o.codeContainer }, [
                  e('div', { class: o.codeImg }, [
                    e('div', { class: o.codeContent }, [
                      e('h2', { class: o.codeTitle }, [s.schoolName]),
                      e('div', { class: o.codeName }, [
                        l('\u9080\u8BF7\u60A8\u6210\u4E3A\u4E50\u56E2\u4F34\u5B66\u8001\u5E08')
                      ]),
                      e('div', { class: o.codeQr }, [e(B, { text: s.url, size: '100%' }, null)]),
                      e('div', { style: { textAlign: 'center' } }, [
                        e('span', { class: o.codeBtnText }, [
                          l(
                            '\u626B\u63CF\u4E0A\u65B9\u4E8C\u7EF4\u7801\u5B8C\u6210\u8D44\u6599\u586B\u5199'
                          )
                        ])
                      ]),
                      e('div', { class: o.codeTips }, [
                        l(
                          '\u4E8C\u7EF4\u7801\u5C06\u5728\u4E24\u5C0F\u65F6\u540E\u5931\u6548\uFF0C\u8BF7\u53CA\u65F6\u767B\u8BB0'
                        )
                      ])
                    ])
                  ]),
                  e('div', { class: o.codeBottom }, [
                    e(
                      i,
                      {
                        name: 'cross',
                        size: 22,
                        class: o.close,
                        color: '#666',
                        onClick: () => (s.showQrcode = !1)
                      },
                      null
                    ),
                    e('h3', { class: o.title }, [
                      e('i', null, null),
                      l('\u5206\u4EAB\u65B9\u5F0F')
                    ]),
                    e(
                      C,
                      { columnNum: 2, border: !1 },
                      {
                        default: () => [
                          e(u, null, {
                            icon: () => e(c, { class: o.shareImg, src: b }, null),
                            text: () =>
                              e('div', { class: o.shareText }, [l('\u4FDD\u5B58\u56FE\u7247')])
                          }),
                          e(u, null, {
                            icon: () => e(c, { class: o.shareImg, src: N }, null),
                            text: () => e('div', { class: o.shareText }, [l('\u5FAE\u4FE1')])
                          })
                        ]
                      }
                    )
                  ])
                ])
              ]
            }
          ),
          e(
            h,
            {
              show: s.showMessage,
              'onUpdate:show': (t) => (s.showMessage = t),
              position: 'bottom',
              style: { background: 'transparent' },
              safeAreaInsetBottom: !0
            },
            {
              default: () => [
                e('div', { class: o.codeContainer }, [
                  e('div', { class: o.codeBottom }, [
                    e(
                      i,
                      {
                        name: 'cross',
                        size: 22,
                        class: o.close,
                        color: '#666',
                        onClick: () => (s.showMessage = !1)
                      },
                      null
                    ),
                    e('h3', { class: o.title }, [
                      e('i', null, null),
                      l('\u8054\u7CFB\u65B9\u5F0F')
                    ]),
                    e(
                      C,
                      { columnNum: 2, border: !1 },
                      {
                        default: () => [
                          e(
                            u,
                            {
                              onClick: () => {
                                f({
                                  api: 'joinChatGroup',
                                  content: { type: 'single', id: s.selectItem.id }
                                }),
                                  (s.showMessage = !1)
                              }
                            },
                            {
                              icon: () => e(c, { class: o.shareImg, src: k }, null),
                              text: () =>
                                e('div', { class: o.shareText }, [l('\u53D1\u9001\u6D88\u606F')])
                            }
                          ),
                          e(
                            u,
                            {
                              onClick: () => {
                                f({ api: 'callPhone', content: { id: s.selectItem.phone } }),
                                  (s.showMessage = !1)
                              }
                            },
                            {
                              icon: () => e(c, { class: o.shareImg, src: j }, null),
                              text: () =>
                                e('div', { class: o.shareText }, [l('\u62E8\u6253\u7535\u8BDD')])
                            }
                          )
                        ]
                      }
                    )
                  ])
                ])
              ]
            }
          ),
          e(
            G,
            {
              show: s.oPopover,
              'onUpdate:show': (t) => (s.oPopover = t),
              cancelText: '\u53D6\u6D88',
              actions: [
                { name: '\u5168\u90E8', id: 'ALL' },
                { name: '\u6CE8\u9500', id: 'CANCEL' },
                { name: '\u51BB\u7ED3', id: 'LOCKED' },
                { name: '\u6B63\u5E38', id: 'ACTIVATION' }
              ],
              onSelect: (t) => {
                ;(s.statusText = t.name),
                  (s.params.status = t.id === 'ALL' ? null : t.id),
                  (s.oPopover = !1),
                  p()
              }
            },
            null
          ),
          e(
            h,
            {
              show: s.showPopover,
              'onUpdate:show': (t) => (s.showPopover = t),
              round: !0,
              position: 'bottom'
            },
            {
              default: () => [
                e(
                  R,
                  {
                    columns: s.subjectList,
                    onCancel: () => (s.showPopover = !1),
                    onConfirm: (t) => I(t)
                  },
                  null
                )
              ]
            }
          )
        ])
      }
    )
  }
})
export { Qe as default }
