<template>
  <view class="add">
    <view class="form">
      <uv-form
        labelPosition="left"
        :model="form"
        ref="formRef"
        labelWidth="140"
        :labelStyle="labelStyle"
      >
        <uv-form-item label="执行包名称" prop="scorePackageName" borderBottom required>
          <uv-input
            v-model="form.scorePackageName"
            border="none"
            placeholder="请输入"
            inputAlign="right"
            readonly
          />
        </uv-form-item>
        <uv-form-item label="服务总值" prop="score" borderBottom required>
          <uv-input v-model="form.score" inputAlign="right" readonly border="none" />
        </uv-form-item>
        <uv-form-item label="发布日期" prop="belongDate" borderBottom required>
          <uv-input v-model="form.belongDate" inputAlign="right" readonly border="none" />
        </uv-form-item>
        <uv-form-item label="承接对象" prop="belongDate" borderBottom required>
          <uv-input v-model="form.userListLabel" inputAlign="right" readonly border="none" />
        </uv-form-item>
        <uv-form-item label="执行包状态" prop="scorePackageStatusName" borderBottom required>
          <uv-input
            v-model="form.scorePackageStatusName"
            inputAlign="right"
            readonly
            border="none"
          />
        </uv-form-item>
        <uv-form-item label="完成服务分值" prop="ysh" borderBottom required>
          <uv-input v-model="form.ysh" readonly inputAlign="right" border="none" />
        </uv-form-item>
        <uv-form-item label="完成百分比（%）" prop="yshtt" borderBottom required>
          <uv-input v-model="form.yshtt" readonly inputAlign="right" border="none" />
        </uv-form-item>
        <uv-form-item label="审核通过服务分值" prop="shtg" borderBottom required>
          <uv-input v-model="form.shtg" readonly inputAlign="right" border="none" />
        </uv-form-item>
        <uv-form-item label="审核通过百分比(%)" prop="shtgtt" borderBottom required>
          <uv-input v-model="form.shtgtt" readonly inputAlign="right" border="none" />
        </uv-form-item>
        <uv-form-item label="关联执行包名称" prop="relationScoreId" borderBottom required>
          <uv-input v-model="form.relationScoreId" inputAlign="right" readonly border="none" />
        </uv-form-item>
        <uv-form-item label="承接对象范围" prop="packageUserScopeName" borderBottom required>
          <uv-input v-model="form.packageUserScopeName" inputAlign="right" readonly border="none" />
        </uv-form-item>
        <uv-form-item label="承接对象范围" prop="typeidName" borderBottom required>
          <uv-input v-model="form.typeidName" inputAlign="right" readonly border="none" />
        </uv-form-item>
      </uv-form>
    </view>
    <view class="task-type">
      <view class="title">有效服务类型如下：</view>
      <view class="item">
        <view class="list" v-for="(item, index) in taskTypeList" :key="index">
          <view class="dot">
            <text></text>
          </view>
          <view class="txt"> {{ item.code }}：{{ item.label }}</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app'
import { useReview } from '@/store/review'
import { ref } from 'vue'
import { reactive } from 'vue'
import { getTypeidPersonalApi, selectByScorePackageIdById } from '@/service/modules/assignPoints'
import { getDictByNameApi } from '@/service/modules/getDict'

const reviewStore = useReview()

const currInfo = ref()
onLoad((e) => {
  const str = reviewStore.assignPointsInfo
  if (str) {
    currInfo.value = JSON.parse(reviewStore.assignPointsInfo)
    initForm()
  }
})

const labelStyle = {
  fontWeight: 400,
  fontSize: '30rpx',
  color: '#000'
}

const form = reactive({
  scorePackageName: '',
  score: '',
  belongDate: '',
  userListLabel: '',
  scorePackageStatusName: '',
  ysh: 0,
  yshtt: 0,
  shtg: 0,
  shtgtt: 0,
  relationScoreId: '',
  packageUserScopeName: '',
  typeidName: ''
})

const plist = {
  'p-1': '学术会议服务',
  'p-2': '学术拜访服务',
  'p-3': '市场信息服务',
  'p-4': '产品推广',
  'p-5': '学术信息交流',
  'p-6': '医药研发服务',
  'p-7': '',
  'p-17': '专项服务',
  'p-18': '商业公司客户管理',
  'p-19': '代理商客户管理'
} as any
const taskTypeList = ref<any[]>([])
const initForm = async () => {
  const res = await getTypeidPersonalApi()
  const resA = await getDictByNameApi('score_package_status')
  form.scorePackageName = currInfo.value.scorePackageName
  form.score = currInfo.value.score
  form.belongDate = currInfo.value.belongDate
  form.userListLabel = currInfo.value?.userList[0]
  const currA = resA.data.find((item: any) => item.value == currInfo.value.scorePackageStatus)
  if (currA) {
    form.scorePackageStatusName = currA.label
  }
  form.ysh = currInfo.value?.ysh
  form.yshtt = currInfo.value?.yshtt
  form.shtg = currInfo.value?.shtg
  form.shtgtt = currInfo.value?.shtgtt
  form.relationScoreId = currInfo.value?.relationScoreId
  form.packageUserScopeName = currInfo.value?.packageUserScopeName
  const currB = res.data.find((item: any) => item.value == currInfo.value.typeid)
  if (currB) {
    form.typeidName = currB.label
  }
  const resC = await selectByScorePackageIdById({ id: currInfo.value?.id })
  resC.data.forEach((item: any) => {
    item.code = plist[item.code]
  })
  taskTypeList.value = resC.data
}
</script>

<style lang="scss" scoped>
.add {
  background: #f2f2f2;
  min-height: 100vh;
  box-sizing: border-box;
  padding: 24rpx;
  .form {
    background: #fff;
    padding: 30rpx;
    border-radius: 12rpx;
  }
}
:deep(.uv-form-item__body__left) {
  padding-left: 18rpx;
}
.task-type {
  margin-top: 20rpx;
  background: #fff;
  border-radius: 12rpx;
  padding: 20rpx 30rpx;

  .title {
    font-weight: 400;
    font-size: 28rpx;
    line-height: 40rpx;
    color: #000;
  }
  .item {
    margin-top: 30rpx;
    .list {
      display: flex;
      margin-bottom: 24rpx;
      .dot {
        margin-right: 10rpx;
        height: 36rpx;
        display: flex;
        align-items: center;
        text {
          display: block;
          width: 8rpx;
          height: 8rpx;
          border-radius: 50%;
          background-color: #606266;
        }
      }
      .txt {
        font-weight: 400;
        font-size: 26rpx;
        line-height: 36rpx;
      }
    }
  }
}
</style>
