<script setup>
import { getOtherMaintainRecordListApi } from '@/api/elevator'
import { usePaging } from '@/composables/use-paging'

const tabs = reactive([{ name: '未完成' }, { name: '已完成' }])
const handleTab = (e) => {
  console.log('handleTab', e)
  reload()
}

const addHandler = () => {
  console.log('addHandler 维修')
}

// 期望时间 关联电梯 电梯地址 维保人员 物业是否评价 工作描述
const keyValue = reactive([
  { key: '期望时间', value: '2021-12-12' },
  { key: '关联电梯', value: '某某某电梯' },
  { key: '电梯地址', value: '某某某地址' },
  { key: '维保人员', value: '某某某' },
  { key: '物业是否评价', value: '是' },
  { key: '工作描述', value: '领导派发' }
])

const query = ref({
  type: 1,
  elevatorName: ''
})
const { paging, dataList, reload, queryHandler, clearHandler, enterHandler } =
  usePaging({
    apiFn: getOtherMaintainRecordListApi,
    query
  })

const options = ref({})
onLoad(async (e) => {
  options.value = e
})
</script>

<template>
  <view class="elevator-rescue" w-full h-100vh flex-col f-s-c bg="#F8F8F8">
    <view w-full>
      <up-tabs
        :list="tabs"
        :scrollable="false"
        :item-style="{
          width: '50%',
          height: '80rpx'
        }"
        :active-style="{
          color: '#3c9cff',
          fontWeight: 'bold'
        }"
        @click="handleTab"
      />
    </view>

    <view f-c-c mt-8 w-full flex-none bg-white>
      <up-input
        v-model="query.elevatorName"
        placeholder="请输入电梯名称"
        prefix-icon="search"
        prefix-icon-style="font-size: 22px;color: #909399"
        clearable
        :border="`${'none'}`"
        :custom-style="{
          height: '80rpx',
          padding: '0 20rpx'
        }"
        @clear="
          () => {
            query.elevatorName = ''
            clearHandler()
          }
        "
        @confirm="enterHandler"
      />
    </view>

    <view w-full flex-auto overflow-hidden mt-8 bg-white>
      <z-paging
        ref="paging"
        v-model="dataList"
        :fixed="false"
        @query="queryHandler"
      >
        <up-card
          v-for="(item, index) in dataList"
          :key="index"
          title="发布人员：某某某公司"
        >
          <template #body>
            <view>
              <view px-30 text-36 font-500 f-c-c justify-between>
                <text>已接单</text>
                <text text-28 text="#909399">2021-12-12 12:00</text>
              </view>
              <up-cell
                v-for="(val, idx) in keyValue"
                :key="idx"
                :title="val.key"
                :value="val.value"
              />
            </view>
          </template>
        </up-card>
      </z-paging>
    </view>
  </view>

  <FloatFixedAddBtn @click="addHandler" />
</template>

<style>
.elevator-rescue .u-tabs {
  background-color: #fff !important;
}
</style>
