<template>
  <view class="container">
    <view>
      <form @submit="formSubmit">
        <scroll-view scroll-y="true" class="scroll-Y">
          <view v-for="item in list" class="list">
            <view class="item">
              <view class="dec">
                <view>&nbsp;员工姓名：</view>
                <view>&nbsp;&nbsp;&nbsp;{{ item.personName }}</view>
              </view>
              <view class="dec">
                <view><span style="color: red">*</span>报工数量：</view>
                <view><input class="uni-input" placeholder="请输入报工数量" v-model="item.reportCount" /></view>
              </view>
            </view>
          </view>
        </scroll-view>
        <u-button size="default" type="default" form-type="submit"
                  style="color:#3C9CFF;backgroundColor:#1AAD19;borderColor:#1AAD19"
                  hover-class="is-hover">提交
        </u-button>
      </form>
    </view>
  </view>
</template>

<script setup lang="ts">
/* 初始化 */
import { onShow } from "@dcloudio/uni-app"
import { getCurrentInstance, ref } from "vue"
/* 引入API */
import * as workSchedulingApi from "@/api/mes/workScheduling"

const { proxy } = getCurrentInstance()
let show = false

/* 是否显示"没有更多了" */
const status = ref("loadmore")
/* 列表数据集 */
const list = ref([])
function checkChange(checkedArray: string | any[]) {
  if (checkedArray.length == 0){
    show = true
  }
}
/* 列表调用API方法 */
async function formSubmit() {
  if (status.value === "nomore") return
  status.value = "loading"
  proxy.$modal.loading("提交中")
  await workSchedulingApi
    .reportWorkByProcess(list)
    .then((res) => {
      proxy.$modal.closeLoading()
    })
    .catch(() => {
      proxy.$modal.closeLoading()
    })
}
/* 打开详情页 */
function openDetail(item: any) {
  console.log(item)
  // proxy.$tab.navigateTo(`/pages/mes/orderDapPlan/detail?obj=${item}`)
}

/* 通用方法 */
onShow(() => {
  list.value = uni.getStorageSync("processReportList")
  debugger
})
</script>

<style lang="scss" scoped>
.container {
  background: #f5f5f5;
  min-height: 100vh;
}

.list {
  background: #f5f5f5;
  margin-top: 20rpx;

  .item {
    padding: 30rpx 30rpx 0px 30rpx;
    margin-top: 20rpx;
    background: white;
    position: relative;

    .title {
      display: flex;
      align-items: center;
      padding-bottom: 20rpx;

      .title-txt {
        color: #409eff;
        font-weight: bold;
        font-size: 36rpx;
        width: 0px;
        flex: 1;
        word-wrap: break-word;
      }

      .time {
        color: #919191;
      }
    }

    .dec {
      padding-bottom: 20rpx;
      display: flex;
      align-items: center;

      view {
        &:nth-child(1) {
          width: 160rpx;
        }

        &:nth-child(2) {
          color: #999999;
          flex: 1;
          width: 0px;
          word-wrap: break-word;
        }
      }
    }

    .last {
      padding-bottom: 30rpx;
    }

    .bottom {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-top: 1px solid #e4e4e4;
      padding: 20rpx 0px;
      height: 90rpx;
    }
  }
}

::v-deep .u-checkbox-group {
  display: grid !important;
}

.is-hover {
  color: rgba(255, 255, 255, 0.6);
  background-color: #179b16;
  border-color: #179b16;
}
</style>
