policeSecurity/collect_information/src/subPages/police/dailyInspection/dailyInspection.vue

405 lines
14 KiB
Vue
Raw Normal View History

2024-11-08 16:18:15 +08:00
<template>
<view class="container">
<nut-form labelWidth="320rpx" labelAlign="left" @click.stop="openSearch">
<nut-form-item label="考核单位:">
<view class="input_width">
2024-11-15 11:48:03 +08:00
<input style="width: 300rpx" disabled="true" v-model="enterprisesName" placeholder="请选择考核单位:" />
<IconFont name="arrow-down"></IconFont>
</view>
</nut-form-item>
</nut-form>
<!-- <picker mode="selector" :range="selector" rangeKey="label" @change="onChange">
2024-11-08 16:18:15 +08:00
<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> -->
2024-11-08 16:18:15 +08:00
<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>
2024-11-12 09:47:29 +08:00
2024-11-08 16:18:15 +08:00
<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">
2024-11-12 10:24:08 +08:00
<text>{{ item.name }}{{ item?.totalScore }} </text>
2024-11-08 16:18:15 +08:00
</text>
</view>
<view style="margin-right: 30rpx; display: flex; align-items: center">
2024-11-12 10:24:08 +08:00
<view v-if="item.currentScore > 0" style="color: #ff0000"> -{{ item?.currentScore }}</view>
2024-11-08 16:18:15 +08:00
<IconFont name="arrow-right"></IconFont>
</view>
</view>
<view>
<nut-form labelWidth="320rpx" labelAlign="left">
<nut-form-item label="备注">
<nut-input v-model="_form.remark" placeholder="请输入备注" type="text" />
</nut-form-item>
2024-11-12 17:23:52 +08:00
<nut-form-item label="考核人员签名:">
<navigator :url="`/subPages/select/signature/signature?index=${1}&name=考核人员签名`" hover-class="navigator-hover">
<nut-button style="height: 50rpx" shape="square" type="info">考核人员签字</nut-button>
2024-11-08 16:18:15 +08:00
</navigator>
</nut-form-item>
2024-11-12 17:23:52 +08:00
<view style="display: flex; justify-content: center">
<image v-if="_form.assessmentUserSignature" :src="_form.assessmentUserSignature" mode="aspectFit" style="height: 300rpx"></image>
2024-11-12 17:23:52 +08:00
</view>
2024-11-08 16:18:15 +08:00
<nut-form-item label="被考评学校签名:">
2024-11-12 17:23:52 +08:00
<navigator :url="`/subPages/select/signature/signature?index=${2}&name=被考评学校签名`" hover-class="navigator-hover">
<nut-button style="height: 50rpx" shape="square" type="info">被考评学校负责人</nut-button>
2024-11-08 16:18:15 +08:00
</navigator>
</nut-form-item>
2024-11-12 17:23:52 +08:00
<view style="display: flex; justify-content: center">
<image v-if="_form.byAssessmentEnterprisesUnitUserSignature" :src="_form.byAssessmentEnterprisesUnitUserSignature" mode="heightFix" style="height: 300rpx"></image>
</view>
2024-11-08 16:18:15 +08:00
</nut-form>
</view>
<view style="height: 150rpx"></view>
<view style="display: flex; width: 100%; justify-content: center; position: fixed; bottom: 50rpx">
2024-11-12 17:23:52 +08:00
<nut-button :loading="isLoading" shape="round" type="info" @click="onSubmit" style="height: 80rpx; width: 702rpx; margin: 10rpx auto">确认提交</nut-button>
</view>
<nut-popup v-model:visible="show" position="bottom" :round="true">
<view style="height: 1031rpx">
<view class="uiwu-picker-search">
<view class="uiwu-picker-search-btn uiwu-flex uiwu-flex-space">
<text @tap.stop="show = false">取消</text>
<text @tap.stop="determine">确定</text>
</view>
<view class="uiwu-picker-search-input uiwu-flex uiwu-flex-align">
<input v-model="inputText" type="text" placeholder="请输入单位名称" confirm-type="search" @confirm="confirm_" />
<view @click.stop="confirm" class="searchButton">搜索</view>
</view>
<scroll-view class="scroll-view" :scroll-y="true">
<!-- <radio-group class="radio-group" @change="radioChange">
<view class="radio-group-item uiwu-flex uiwu-flex-space" v-for="(item, index) in selector" :key="index">
<text>{{ item.label }}</text>
<radio :value="item.value" color="#687CFF" />
</view>
</radio-group> -->
2024-11-15 11:48:03 +08:00
<nut-radio-group v-if="(selectorCopy?.length ?? 0) > 0" style="margin-left: 30rpx" v-model="selectedID">
<nut-radio icon-size="20" v-for="(item, index) in selectorCopy" :key="index" :label="item.value"> {{ item.label }}</nut-radio>
<view style="height: 40rpx"></view>
</nut-radio-group>
2024-11-15 11:48:03 +08:00
<nut-empty v-else description="暂无单位"></nut-empty>
</scroll-view>
</view>
</view>
</nut-popup>
2024-11-08 16:18:15 +08:00
</view>
<!-- <picker-search ref="picker_search" @change="changeSearch" /> -->
2024-11-08 16:18:15 +08:00
</template>
2024-11-08 16:18:15 +08:00
<script setup lang="ts">
// import PickerSearch from '@/components/PickerSearch.vue'
// import picker-search from
2024-11-08 16:18:15 +08:00
import { IconFont } from '@nutui/icons-vue-taro'
2024-11-12 17:23:52 +08:00
import Taro, { useLoad, useUnload } from '@tarojs/taro'
2024-11-08 16:18:15 +08:00
import './dailyInspection.scss'
import { ref, computed, reactive, watch } from 'vue'
import api from '@/request/index'
import { useDailyStore } from '@/store/daily'
const picker_search = ref()
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-12 17:23:52 +08:00
2024-11-08 17:21:50 +08:00
const currentCkProjectId = ref('')
2024-11-08 16:18:15 +08:00
const submitData = ref<Item[]>([])
const enterprisesName = ref('')
2024-11-08 16:18:15 +08:00
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
if (newDaily.length > 0) {
starRating.value = newDaily
}
submitData.value = newDaily
2024-11-12 09:47:29 +08:00
// console.log('watch_______________', _form, submitData.value)
2024-11-08 16:18:15 +08:00
},
{ immediate: true }
)
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}`,
})
}
2024-11-12 09:47:29 +08:00
2024-11-08 16:18:15 +08:00
/**
* @assessmentCriteriaRulesByCkProjectId 获取考核规则
*/
2024-11-12 09:47:29 +08:00
2024-11-08 16:18:15 +08:00
const assessmentCriteriaRulesByCkProjectId = async function (ckProjectId) {
2024-11-12 17:23:52 +08:00
// Taro.showLoading({
// title: '加载中...',
// mask: true,
// })
const res = await api.get<StarRating[]>(`/assessmentCriteria/assessmentCriteriaRulesByCkProjectId`, { ckProjectId })
2024-11-12 09:47:29 +08:00
2024-11-08 16:18:15 +08:00
res.data?.forEach((item) => {
item.currentScore = 0
item.itemList.forEach((element: ItemList) => {
2024-11-12 09:47:29 +08:00
element.standardList.forEach((ele) => {
ele.isSelected = false
})
2024-11-08 16:18:15 +08:00
element.standardList.unshift({
ckItemId: 'null',
deductionPoints: 0,
name: '达标',
snowFlakeId: 'null',
2024-11-12 09:47:29 +08:00
isSelected: true,
2024-11-08 16:18:15 +08:00
})
element.selectedID = element.standardList[0].snowFlakeId
element.selected_points = 0 // 默认达标 默认扣 0 分
// 多选
if (element.type.value === 'multiple') {
element.selectedGroup = [element.selectedID]
}
})
})
2024-11-12 09:47:29 +08:00
starRating.value = res.data ?? []
// console.log('starRating.value______________________________', starRating.value)
2024-11-08 16:18:15 +08:00
store.dailyinspectionList(starRating.value)
2024-11-12 17:23:52 +08:00
// Taro.hideLoading()
2024-11-08 16:18:15 +08:00
}
/**
* @ckProjectListByType 根据类型获取考核标准列表
*/
const selectorCheckedType = ref<string>('')
const selectorType = ref<CkProjectListByType[]>()
const ckProjectListByType = async function (type) {
const res = await api.get<CkProjectListByType[]>(`/assessmentCriteria/ckProjectListByType`, { type })
2024-11-12 17:23:52 +08:00
console.log(res.data)
if (res.data?.length === 0) {
let timeID = setTimeout(() => {
Taro.showToast({
title: '该单位下面没有考核标准',
icon: 'none',
duration: 2000,
})
clearTimeout(timeID)
}, 500)
}
2024-11-08 16:18:15 +08:00
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
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value)
2024-11-08 16:18:15 +08:00
_form.ckProjectId = selectorType.value?.[index].value as string
}
const selector = ref<UnitEnterprisesUnitList[]>()
const selectorCopy = ref<UnitEnterprisesUnitList[]>()
2024-11-08 16:18:15 +08:00
const selectorChecked = ref<string>('')
const onChange = function (e: any) {
2024-11-12 09:47:29 +08:00
try {
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
} catch (error) {
console.log('🚀 ~ onChange ~ error:', error)
}
2024-11-08 16:18:15 +08:00
}
const getUnitEnterprisesUnitList = async function () {
const res = await api.get<UnitEnterprisesUnitList[]>(`/policeIndex/getUnitEnterprisesUnitList`)
2024-11-12 17:23:52 +08:00
2024-11-08 16:18:15 +08:00
selector.value = res.data
selectorCopy.value = res.data
2024-11-08 16:18:15 +08:00
}
const _showToast = function (title) {
Taro.showToast({
title,
icon: 'none',
duration: 1500,
mask: true,
})
}
/**
* @onSubmit 提交
* @assessmentRecordDetails 选择后的数据用于提交
2024-11-12 09:47:29 +08:00
* @clearData 清空数据
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[]>([])
2024-11-12 09:47:29 +08:00
const clearData = function () {
store.clearSignData()
store.dailyinspectionList([])
assessmentRecordDetails.value = []
_form.assessmentUserSignature = ''
_form.byAssessmentEnterprisesUnitUserSignature = ''
_form.remark = ''
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value) //重新获取数据
}
2024-11-12 17:23:52 +08:00
const isLoading = ref(false)
2024-11-08 16:18:15 +08:00
const onSubmit = async function () {
if (_form.enterprisesUnitId === '') {
_showToast('请选择企事业单位')
return
}
if (_form.ckProjectId === '') {
_showToast('请选择考核项目')
return
}
if (_form.assessmentUserSignature === '') {
_showToast('请考核人员签字')
return
}
if (_form.byAssessmentEnterprisesUnitUserSignature === '') {
_showToast('请被考核单位人员签字')
return
}
2024-11-12 17:23:52 +08:00
isLoading.value = true
2024-11-08 16:38:41 +08:00
submitData.value.forEach((element: StarRating) => {
element?.itemList.forEach((item: ItemList) => {
item.standardList.forEach((ele: StandardList) => {
2024-11-08 16:18:15 +08:00
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) => {
item.standardList.forEach((standard_Element) => {
if (selectedItem != 'null' && selectedItem === standard_Element.snowFlakeId) {
assessmentRecordDetails.value.push({
ckGroupId: element.snowFlakeId, //选项的雪花Id
ckItemId: standard_Element.ckItemId, //已选择的ID
ckStandardId: selectedItem, //已选择的雪花ID
})
}
})
2024-11-08 17:21:50 +08:00
})
}
2024-11-08 16:18:15 +08:00
})
})
const assessmentRecordParams = {
assessmentRecordDetails: [] as any[],
}
Object.assign(assessmentRecordParams, _form)
assessmentRecordParams.assessmentRecordDetails = [...assessmentRecordDetails.value]
const result = await api.post('/assessmentCriteria/submitAssessmentRecord', assessmentRecordParams)
2024-11-12 17:23:52 +08:00
2024-11-12 09:47:29 +08:00
clearData() //清空数据
2024-11-08 16:18:15 +08:00
if (result.code === 200) {
2024-11-12 17:23:52 +08:00
isLoading.value = false
let timeID = setTimeout(() => {
Taro.showToast({
title: result.message,
icon: 'success',
duration: 2000,
mask: true,
})
clearTimeout(timeID)
}, 500)
2024-11-08 16:18:15 +08:00
} else {
_showToast(result.message)
}
}
2024-11-12 17:23:52 +08:00
useUnload(() => {
store.clearSignData()
store.dailyinspectionList([])
assessmentRecordDetails.value = []
_form.assessmentUserSignature = ''
_form.byAssessmentEnterprisesUnitUserSignature = ''
_form.remark = ''
})
const show = ref(false)
const inputText = ref('')
const selectedID = ref('')
const openSearch = () => {
show.value = true
}
const fuzzySearch = function (query) {
selectorCopy.value = selector.value?.filter((item) => item.label.includes(query))
}
const confirm = () => {
console.log(inputText.value)
if (inputText.value.trim() === '') {
selectorCopy.value = selector.value
} else {
fuzzySearch(inputText.value.trim())
}
}
const confirm_ = ({ detail: { value } }) => {
console.log('confirm', value)
if (inputText.value.trim() === '') {
selectorCopy.value = selector.value
} else {
fuzzySearch(inputText.value.trim())
}
}
const determine = () => {
2024-11-15 11:48:03 +08:00
console.log(selectedID.value)
if (selectedID.value === '' && (selector.value?.length as number) > 0) {
Taro.showToast({
title: '请选择单位',
icon: 'none',
duration: 1500,
mask: true,
})
return
}
let index: number = selector.value?.findIndex((item) => item.value === selectedID.value) as number
_form.enterprisesUnitId = selectedID.value
let type = selector.value?.[index].extData.type.value
enterprisesName.value = selector.value?.[index].label as string
show.value = false
ckProjectListByType(type)
}
2024-11-08 16:18:15 +08:00
</script>