2024-11-08 16:18:15 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="container">
|
|
|
|
|
<!-- picker -->
|
|
|
|
|
<picker mode="selector" :range="selector" rangeKey="label" @change="onChange">
|
|
|
|
|
<view class="picker">
|
|
|
|
|
考核单位:
|
|
|
|
|
<view style="display: flex; align-items: center">
|
|
|
|
|
<view v-if="selectorChecked.length === 0" style="color: #606266">请选择考核单位:</view>
|
|
|
|
|
<view> {{ selectorChecked }}</view>
|
|
|
|
|
<IconFont name="arrow-right"></IconFont>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</picker>
|
|
|
|
|
|
|
|
|
|
<!-- picker -->
|
|
|
|
|
<!-- 如果 selectorType 为 undefined 或 null,?.length 会返回 undefined,然后通过 ?? 运算符将其替换为 0,确保条件判断不会出错。 -->
|
|
|
|
|
<picker v-if="(selectorType?.length ?? 0) > 0" mode="selector" :range="selectorType" rangeKey="label" @change="onChangeType">
|
|
|
|
|
<view class="picker">
|
|
|
|
|
当前考核项目:
|
|
|
|
|
<view style="display: flex; align-items: center">
|
|
|
|
|
<view v-if="selectorCheckedType.length === 0" style="color: #606266">请选择考核项目</view>
|
|
|
|
|
<view> {{ selectorCheckedType }}</view>
|
|
|
|
|
<IconFont name="arrow-right"></IconFont>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</picker>
|
|
|
|
|
<!-- 选择题 -->
|
|
|
|
|
<view class="exit" v-for="item in starRating" :key="item.snowFlakeId" @click="Onrating(item.name, item.snowFlakeId)">
|
|
|
|
|
<view class="exitItem">
|
|
|
|
|
<text style="margin-left: 30rpx; font-size: 16px">
|
|
|
|
|
<text>{{ item.name }}({{ item.totalScore }}分) </text>
|
|
|
|
|
</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view style="margin-right: 30rpx; display: flex; align-items: center">
|
|
|
|
|
<view v-if="item.currentScore > 0" style="color: #ff0000"> -{{ item.currentScore }}</view>
|
|
|
|
|
<IconFont name="arrow-right"></IconFont>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<nut-form>
|
|
|
|
|
<nut-form-item label-width="50" label="备注">
|
|
|
|
|
<nut-input v-model="_form.remark" placeholder="请输入备注" type="text" />
|
|
|
|
|
</nut-form-item>
|
|
|
|
|
</nut-form>
|
|
|
|
|
<!-- 签字 -->
|
|
|
|
|
<view>
|
|
|
|
|
<nut-form labelWidth="320rpx" labelAlign="left">
|
|
|
|
|
<nut-form-item label="考核人员签字:">
|
|
|
|
|
<navigator :url="`/subPages/select/signature/signature?index=${1}`" hover-class="navigator-hover">
|
|
|
|
|
<nut-button style="height: 50rpx" shape="square" type="info">考核人员签字</nut-button>
|
|
|
|
|
</navigator>
|
|
|
|
|
</nut-form-item>
|
|
|
|
|
<nut-form-item v-if="mydailycolors">
|
|
|
|
|
<view style="padding: 0">
|
|
|
|
|
<image :src="mydailycolors"></image>
|
|
|
|
|
</view>
|
|
|
|
|
</nut-form-item>
|
|
|
|
|
<nut-form-item label="被考评学校签名:">
|
|
|
|
|
<navigator :url="`/subPages/select/signature/signature?index=${2}`" hover-class="navigator-hover">
|
|
|
|
|
<nut-button style="height: 50rpx" shape="square" type="info">被考评学校负责人</nut-button>
|
|
|
|
|
</navigator>
|
|
|
|
|
</nut-form-item>
|
|
|
|
|
<nut-form-item v-if="mydailycolorschools">
|
|
|
|
|
<view style="padding: 0">
|
|
|
|
|
<image :src="mydailycolorschools"></image>
|
|
|
|
|
</view>
|
|
|
|
|
</nut-form-item>
|
|
|
|
|
<nut-form-item label="确认:">
|
|
|
|
|
<nut-button style="height: 50rpx" shape="square" type="info" @click="onSubmit">确认提交</nut-button>
|
|
|
|
|
</nut-form-item>
|
|
|
|
|
<view style="height: 20px"></view>
|
|
|
|
|
</nut-form>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { IconFont } from '@nutui/icons-vue-taro'
|
|
|
|
|
import Taro, { useLoad } from '@tarojs/taro'
|
|
|
|
|
import './dailyInspection.scss'
|
|
|
|
|
import { ref, computed, reactive, watch } from 'vue'
|
|
|
|
|
import api from '@/request/index'
|
|
|
|
|
import { useDailyStore } from '@/store/daily'
|
2024-11-08 16:52:10 +08:00
|
|
|
|
const starRating = ref<any[]>([])
|
2024-11-08 16:18:15 +08:00
|
|
|
|
const store = useDailyStore()
|
|
|
|
|
const daily = computed(() => store.getdailyinspection)
|
|
|
|
|
const base64_1 = computed(() => store.get_base64_1)
|
|
|
|
|
const base64_2 = computed(() => store.get_base64_2)
|
2024-11-08 17:21:50 +08:00
|
|
|
|
const currentCkProjectId = ref('')
|
2024-11-08 16:18:15 +08:00
|
|
|
|
const submitData = ref<Item[]>([])
|
|
|
|
|
// watch(
|
|
|
|
|
// daily,
|
|
|
|
|
// (newData) => {
|
|
|
|
|
// console.log('watch_______________', newData)
|
|
|
|
|
// if (newData.length > 0) starRating.value = newData
|
|
|
|
|
// submitData.value = newData
|
|
|
|
|
// },
|
|
|
|
|
// { immediate: true }
|
|
|
|
|
// )
|
|
|
|
|
const _form = reactive({
|
|
|
|
|
enterprisesUnitId: '', //企事业单位id
|
|
|
|
|
ckProjectId: '', //考核项目
|
|
|
|
|
assessmentUserSignature: '', //考核人员签字
|
|
|
|
|
byAssessmentEnterprisesUnitUserSignature: '', // 被考核单位人员签字
|
|
|
|
|
remark: '', //考核备注
|
|
|
|
|
})
|
|
|
|
|
watch(
|
|
|
|
|
[daily, base64_1, base64_2],
|
|
|
|
|
([newDaily, newBase64_1, newBase64_2]) => {
|
|
|
|
|
_form.assessmentUserSignature = newBase64_1
|
|
|
|
|
_form.byAssessmentEnterprisesUnitUserSignature = newBase64_2
|
|
|
|
|
console.log('watch_______________', _form)
|
|
|
|
|
|
|
|
|
|
if (newDaily.length > 0) {
|
|
|
|
|
starRating.value = newDaily
|
|
|
|
|
}
|
|
|
|
|
submitData.value = newDaily
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true }
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const mydailycolors = ref('')
|
|
|
|
|
const mydailycolorschools = ref('')
|
|
|
|
|
|
|
|
|
|
useLoad(async () => {
|
|
|
|
|
await getUnitEnterprisesUnitList()
|
|
|
|
|
})
|
2024-11-08 16:52:10 +08:00
|
|
|
|
|
2024-11-08 16:18:15 +08:00
|
|
|
|
const Onrating = function (name: string, snowFlakeId: string) {
|
|
|
|
|
let index = starRating.value.findIndex((item) => item.snowFlakeId === snowFlakeId)
|
|
|
|
|
Taro.navigateTo({
|
|
|
|
|
url: `/subPages/select/dailyLife/dailyLife?name=${name}&index=${index}`,
|
|
|
|
|
// url: `/subPages/select/dailyLife/dailyLife`,
|
|
|
|
|
// success: function (res) {
|
|
|
|
|
// try {
|
|
|
|
|
// if (process.env.TARO_ENV === 'weapp') {
|
|
|
|
|
// res.eventChannel.emit('starRating', { data: selectedItemList })
|
|
|
|
|
// }
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
interface UnitEnterprisesUnitList {
|
|
|
|
|
label: string
|
|
|
|
|
value: string
|
|
|
|
|
extData: {
|
|
|
|
|
type: {
|
|
|
|
|
label: string
|
|
|
|
|
value: string
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
interface CkProjectListByType {
|
|
|
|
|
label: string
|
|
|
|
|
value: string
|
|
|
|
|
extData: {
|
|
|
|
|
createTime: string
|
|
|
|
|
remark: string
|
|
|
|
|
totalScore: number
|
|
|
|
|
type: {
|
|
|
|
|
label: string
|
|
|
|
|
value: string
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @assessmentCriteriaRulesByCkProjectId 获取考核规则
|
|
|
|
|
*/
|
|
|
|
|
const assessmentCriteriaRulesByCkProjectId = async function (ckProjectId) {
|
|
|
|
|
Taro.showLoading({
|
|
|
|
|
title: '加载中...',
|
|
|
|
|
mask: true,
|
|
|
|
|
})
|
|
|
|
|
const res = await api.get<any[]>(`/assessmentCriteria/assessmentCriteriaRulesByCkProjectId`, { ckProjectId })
|
|
|
|
|
// ————————————————————————————————————————处理数据,默认添加已选择项
|
|
|
|
|
res.data?.forEach((item) => {
|
|
|
|
|
item.currentScore = 0
|
|
|
|
|
|
|
|
|
|
item.itemList.forEach((element) => {
|
|
|
|
|
// element.selectedID = element.standardList[0].snowFlakeId
|
|
|
|
|
element.standardList.unshift({
|
|
|
|
|
ckItemId: 'null',
|
|
|
|
|
deductionPoints: 0,
|
|
|
|
|
name: '达标',
|
|
|
|
|
snowFlakeId: 'null',
|
|
|
|
|
})
|
|
|
|
|
element.selectedID = element.standardList[0].snowFlakeId
|
|
|
|
|
element.selected_points = 0 // 默认达标 默认扣 0 分
|
|
|
|
|
// 多选
|
|
|
|
|
if (element.type.value === 'multiple') {
|
|
|
|
|
element.selectedGroup = [element.selectedID]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
starRating.value = res.data ?? [] // 如果 res.data 为 undefined,则使用空数组
|
|
|
|
|
store.dailyinspectionList(starRating.value)
|
|
|
|
|
Taro.hideLoading()
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @ckProjectListByType 根据类型获取考核标准列表
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const selectorCheckedType = ref<string>('')
|
|
|
|
|
const selectorType = ref<CkProjectListByType[]>()
|
|
|
|
|
const ckProjectListByType = async function (type) {
|
|
|
|
|
const res = await api.get<CkProjectListByType[]>(`/assessmentCriteria/ckProjectListByType`, { type })
|
|
|
|
|
selectorType.value = res.data
|
|
|
|
|
}
|
2024-11-08 17:21:50 +08:00
|
|
|
|
|
2024-11-08 16:18:15 +08:00
|
|
|
|
const onChangeType = function (e: any) {
|
|
|
|
|
let index = Number(e.detail.value)
|
|
|
|
|
selectorCheckedType.value = selectorType.value?.[index].label as string
|
2024-11-08 17:21:50 +08:00
|
|
|
|
currentCkProjectId.value = selectorType.value?.[index].value as string
|
|
|
|
|
// let ckProjectId = selectorType.value?.[index].value
|
|
|
|
|
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value)
|
2024-11-08 16:18:15 +08:00
|
|
|
|
_form.ckProjectId = selectorType.value?.[index].value as string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const selector = ref<UnitEnterprisesUnitList[]>()
|
|
|
|
|
const selectorChecked = ref<string>('')
|
|
|
|
|
const onChange = function (e: any) {
|
|
|
|
|
let index = Number(e.detail.value)
|
|
|
|
|
selectorChecked.value = selector.value?.[index].label as string
|
|
|
|
|
let type = selector.value?.[index].extData.type.value
|
|
|
|
|
ckProjectListByType(type)
|
|
|
|
|
_form.enterprisesUnitId = selector.value?.[index].value as string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getUnitEnterprisesUnitList = async function () {
|
|
|
|
|
const res = await api.get<UnitEnterprisesUnitList[]>(`/policeIndex/getUnitEnterprisesUnitList`)
|
|
|
|
|
selector.value = res.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const _showToast = function (title) {
|
|
|
|
|
Taro.showToast({
|
|
|
|
|
title,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1500,
|
|
|
|
|
mask: true,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @onSubmit 提交
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* @assessmentRecordDetails 选择后的数据用于提交
|
|
|
|
|
*/
|
|
|
|
|
interface Item {
|
|
|
|
|
itemList: any[] // 根据实际情况调整类型
|
2024-11-08 16:38:41 +08:00
|
|
|
|
snowFlakeId: string
|
2024-11-08 16:18:15 +08:00
|
|
|
|
}
|
2024-11-08 16:38:41 +08:00
|
|
|
|
|
2024-11-08 16:18:15 +08:00
|
|
|
|
const assessmentRecordDetails = ref<any[]>([])
|
|
|
|
|
const onSubmit = async function () {
|
|
|
|
|
if (_form.enterprisesUnitId === '') {
|
|
|
|
|
_showToast('请选择企事业单位')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (_form.ckProjectId === '') {
|
|
|
|
|
_showToast('请选择考核项目')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (_form.assessmentUserSignature === '') {
|
|
|
|
|
_showToast('请考核人员签字')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (_form.byAssessmentEnterprisesUnitUserSignature === '') {
|
|
|
|
|
_showToast('请被考核单位人员签字')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
Taro.showLoading({
|
|
|
|
|
title: '加载中...',
|
|
|
|
|
mask: true,
|
|
|
|
|
})
|
2024-11-08 16:38:41 +08:00
|
|
|
|
|
2024-11-08 16:18:15 +08:00
|
|
|
|
submitData.value.forEach((element) => {
|
|
|
|
|
element?.itemList.forEach((item) => {
|
|
|
|
|
item.standardList.forEach((ele) => {
|
|
|
|
|
if (ele.snowFlakeId === item.selectedID && !item.hasOwnProperty('selectedGroup') && item.selectedID != 'null') {
|
|
|
|
|
assessmentRecordDetails.value.push({
|
2024-11-08 16:38:41 +08:00
|
|
|
|
ckGroupId: element.snowFlakeId, //选项的雪花Id
|
2024-11-08 16:18:15 +08:00
|
|
|
|
ckItemId: ele.ckItemId, //已选择的ID
|
|
|
|
|
ckStandardId: item.selectedID, //已选择的雪花ID
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-11-08 17:21:50 +08:00
|
|
|
|
if (item.hasOwnProperty('selectedGroup')) {
|
|
|
|
|
item.selectedGroup.forEach((selectedItem) => {
|
|
|
|
|
console.log(selectedItem)
|
|
|
|
|
if (selectedItem != 'null') {
|
|
|
|
|
assessmentRecordDetails.value.push({
|
|
|
|
|
ckGroupId: element.snowFlakeId, //选项的雪花Id
|
|
|
|
|
ckItemId: item.snowFlakeId, //已选择的ID
|
|
|
|
|
ckStandardId: selectedItem, //已选择的雪花ID
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-11-08 16:18:15 +08:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const assessmentRecordParams = {
|
|
|
|
|
assessmentRecordDetails: [] as any[],
|
|
|
|
|
}
|
|
|
|
|
Object.assign(assessmentRecordParams, _form)
|
|
|
|
|
assessmentRecordParams.assessmentRecordDetails = [...assessmentRecordDetails.value]
|
|
|
|
|
console.log('🚀 ~ onSubmit ~ assessmentRecordParams:', assessmentRecordParams)
|
|
|
|
|
|
|
|
|
|
const result = await api.post('/assessmentCriteria/submitAssessmentRecord', assessmentRecordParams)
|
|
|
|
|
console.log('🚀 ~ onSubmit ~ result:', result)
|
|
|
|
|
Taro.hideLoading()
|
2024-11-08 17:21:50 +08:00
|
|
|
|
store.dailyinspectionList([]) //清空数据
|
2024-11-08 17:29:05 +08:00
|
|
|
|
assessmentRecordDetails.value = []
|
2024-11-08 17:21:50 +08:00
|
|
|
|
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value) //重新获取数据
|
2024-11-08 16:18:15 +08:00
|
|
|
|
if (result.code === 200) {
|
|
|
|
|
Taro.showToast({
|
|
|
|
|
title: result.message,
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 1500,
|
|
|
|
|
mask: true,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
_showToast(result.message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// useDidShow(() => {
|
|
|
|
|
// // 测试 pinia 数据是否更新
|
|
|
|
|
// console.log('onShow_______________测试 pinia 数据是否更新', submitData.value)
|
|
|
|
|
// })
|
|
|
|
|
</script>
|