Compare commits

..

No commits in common. "4007d4f761f1afd9843f7140edf2d2216b4f28d5" and "be88ef1658be5afc45ab9b72b0b3f184d37386a9" have entirely different histories.

5 changed files with 100 additions and 118 deletions

View File

@ -12,14 +12,19 @@ export const useDailyStore = defineStore('daily', {
this.userdailyinspection = [...data] this.userdailyinspection = [...data]
}, },
change_base64_1(data) { change_base64_1(data) {
// console.log("🚀 ~ change_base64_1 ~ data:", data)
this.base64_1 = data this.base64_1 = data
}, },
change_base64_2(data) { change_base64_2(data) {
this.base64_2 = data this.base64_2 = data
}, },
clearSignData() { cleardailtcolour() {
this.base64_1 = '' this.userdailyinspection = {
this.base64_2 = '' ...this.userdailyinspection,
markColor: this.userdailyinspection.markColor,
markColor1: this.userdailyinspection.markColor,
comment: ''
}
} }
}, },
getters: { getters: {

View File

@ -1,5 +1,6 @@
<template> <template>
<view class="container"> <view class="container">
<!-- picker -->
<picker mode="selector" :range="selector" rangeKey="label" @change="onChange"> <picker mode="selector" :range="selector" rangeKey="label" @change="onChange">
<view class="picker"> <view class="picker">
考核单位 考核单位
@ -11,6 +12,8 @@
</view> </view>
</picker> </picker>
<!-- picker -->
<!-- 如果 selectorType undefined null?.length 会返回 undefined然后通过 ?? 运算符将其替换为 0确保条件判断不会出错 -->
<picker v-if="(selectorType?.length ?? 0) > 0" mode="selector" :range="selectorType" rangeKey="label" @change="onChangeType"> <picker v-if="(selectorType?.length ?? 0) > 0" mode="selector" :range="selectorType" rangeKey="label" @change="onChangeType">
<view class="picker"> <view class="picker">
当前考核项目 当前考核项目
@ -21,7 +24,7 @@
</view> </view>
</view> </view>
</picker> </picker>
<!-- 选择题 -->
<view class="exit" v-for="item in starRating" :key="item.snowFlakeId" @click="Onrating(item.name, item.snowFlakeId)"> <view class="exit" v-for="item in starRating" :key="item.snowFlakeId" @click="Onrating(item.name, item.snowFlakeId)">
<view class="exitItem"> <view class="exitItem">
<text style="margin-left: 30rpx; font-size: 16px"> <text style="margin-left: 30rpx; font-size: 16px">
@ -93,7 +96,7 @@ watch(
starRating.value = newDaily starRating.value = newDaily
} }
submitData.value = newDaily submitData.value = newDaily
// console.log('watch_______________', _form, submitData.value) console.log('watch_______________', _form, submitData.value)
}, },
{ immediate: true } { immediate: true }
) )
@ -108,31 +111,74 @@ const Onrating = function (name: string, snowFlakeId: string) {
url: `/subPages/select/dailyLife/dailyLife?name=${name}&index=${index}`, url: `/subPages/select/dailyLife/dailyLife?name=${name}&index=${index}`,
}) })
} }
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 获取考核规则 * @assessmentCriteriaRulesByCkProjectId 获取考核规则
*/ */
interface StandardList {
ckItemId: string
deductionPoints: number
name: string
snowFlakeId: string
}
interface ItemList {
ckGroupId: string
name: string
remark: string
snowFlakeId: string
standardList: StandardList[]
type: { value: string; label: string }
selectedID: string
selected_points: number
selectedGroup: string[]
}
interface StarRating {
itemList: ItemList[]
name: string
remark: string
snowFlakeId: string
totalScore: number
currentScore: number
}
const assessmentCriteriaRulesByCkProjectId = async function (ckProjectId) { const assessmentCriteriaRulesByCkProjectId = async function (ckProjectId) {
Taro.showLoading({ Taro.showLoading({
title: '加载中...', title: '加载中...',
mask: true, mask: true,
}) })
const res = await api.get<StarRating[]>(`/assessmentCriteria/assessmentCriteriaRulesByCkProjectId`, { ckProjectId }) const res = await api.get<StarRating[]>(`/assessmentCriteria/assessmentCriteriaRulesByCkProjectId`, { ckProjectId })
//
res.data?.forEach((item) => { res.data?.forEach((item) => {
item.currentScore = 0 item.currentScore = 0
item.itemList.forEach((element: ItemList) => { item.itemList.forEach((element: ItemList) => {
element.standardList.forEach((ele) => { // element.selectedID = element.standardList[0].snowFlakeId
ele.isSelected = false
})
element.standardList.unshift({ element.standardList.unshift({
ckItemId: 'null', ckItemId: 'null',
deductionPoints: 0, deductionPoints: 0,
name: '达标', name: '达标',
snowFlakeId: 'null', snowFlakeId: 'null',
isSelected: true,
}) })
element.selectedID = element.standardList[0].snowFlakeId element.selectedID = element.standardList[0].snowFlakeId
element.selected_points = 0 // 0 element.selected_points = 0 // 0
@ -142,9 +188,7 @@ const assessmentCriteriaRulesByCkProjectId = async function (ckProjectId) {
} }
}) })
}) })
starRating.value = res.data ?? [] starRating.value = res.data ?? [] // res.data undefined使
// console.log('starRating.value______________________________', starRating.value)
store.dailyinspectionList(starRating.value) store.dailyinspectionList(starRating.value)
Taro.hideLoading() Taro.hideLoading()
} }
@ -163,6 +207,7 @@ const onChangeType = function (e: any) {
let index = Number(e.detail.value) let index = Number(e.detail.value)
selectorCheckedType.value = selectorType.value?.[index].label as string selectorCheckedType.value = selectorType.value?.[index].label as string
currentCkProjectId.value = selectorType.value?.[index].value as string currentCkProjectId.value = selectorType.value?.[index].value as string
// let ckProjectId = selectorType.value?.[index].value
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value) assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value)
_form.ckProjectId = selectorType.value?.[index].value as string _form.ckProjectId = selectorType.value?.[index].value as string
} }
@ -170,15 +215,11 @@ const onChangeType = function (e: any) {
const selector = ref<UnitEnterprisesUnitList[]>() const selector = ref<UnitEnterprisesUnitList[]>()
const selectorChecked = ref<string>('') const selectorChecked = ref<string>('')
const onChange = function (e: any) { const onChange = function (e: any) {
try {
let index = Number(e.detail.value) let index = Number(e.detail.value)
selectorChecked.value = selector.value?.[index].label as string selectorChecked.value = selector.value?.[index].label as string
let type = selector.value?.[index].extData.type.value let type = selector.value?.[index].extData.type.value
ckProjectListByType(type) ckProjectListByType(type)
_form.enterprisesUnitId = selector.value?.[index].value as string _form.enterprisesUnitId = selector.value?.[index].value as string
} catch (error) {
console.log('🚀 ~ onChange ~ error:', error)
}
} }
const getUnitEnterprisesUnitList = async function () { const getUnitEnterprisesUnitList = async function () {
@ -197,20 +238,16 @@ const _showToast = function (title) {
/** /**
* @onSubmit 提交 * @onSubmit 提交
* @assessmentRecordDetails 选择后的数据用于提交
* @clearData 清空数据
*/ */
/**
* @assessmentRecordDetails 选择后的数据用于提交
*/
interface Item {
itemList: any[] //
snowFlakeId: string
}
const assessmentRecordDetails = ref<any[]>([]) const assessmentRecordDetails = ref<any[]>([])
const clearData = function () {
store.clearSignData()
store.dailyinspectionList([])
assessmentRecordDetails.value = []
_form.assessmentUserSignature = ''
_form.byAssessmentEnterprisesUnitUserSignature = ''
_form.remark = ''
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value) //
}
const onSubmit = async function () { const onSubmit = async function () {
if (_form.enterprisesUnitId === '') { if (_form.enterprisesUnitId === '') {
_showToast('请选择企事业单位') _showToast('请选择企事业单位')
@ -265,9 +302,14 @@ const onSubmit = async function () {
} }
Object.assign(assessmentRecordParams, _form) Object.assign(assessmentRecordParams, _form)
assessmentRecordParams.assessmentRecordDetails = [...assessmentRecordDetails.value] assessmentRecordParams.assessmentRecordDetails = [...assessmentRecordDetails.value]
console.log('🚀 ~ onSubmit ~ assessmentRecordParams:', assessmentRecordParams)
const result = await api.post('/assessmentCriteria/submitAssessmentRecord', assessmentRecordParams) const result = await api.post('/assessmentCriteria/submitAssessmentRecord', assessmentRecordParams)
console.log('🚀 ~ onSubmit ~ result:', result)
Taro.hideLoading() Taro.hideLoading()
clearData() // store.dailyinspectionList([]) //
assessmentRecordDetails.value = [] //
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value) //
if (result.code === 200) { if (result.code === 200) {
Taro.showToast({ Taro.showToast({
title: result.message, title: result.message,

View File

@ -5,14 +5,14 @@
<nut-collapse v-model="item.snowFlakeId" accordion v-for="(item, index) in starRating[findIndex].itemList" :key="item.snowFlakeId"> <nut-collapse v-model="item.snowFlakeId" accordion v-for="(item, index) in starRating[findIndex].itemList" :key="item.snowFlakeId">
<nut-collapse-item :name="item.snowFlakeId" :title="item.name"> <nut-collapse-item :name="item.snowFlakeId" :title="item.name">
<view class="singleChoice"> <view class="singleChoice">
<!-- v-model="form[item.name]" -->
<nut-radio-group v-if="item.type.value === 'radio'" v-model="item.selectedID" @change="(modelValue) => onChange(modelValue, item.name)"> <nut-radio-group v-if="item.type.value === 'radio'" v-model="item.selectedID" @change="(modelValue) => onChange(modelValue, item.name)">
<nut-radio v-for="(items, indexs) in item.standardList" size="40" :label="items.snowFlakeId" :key="indexs"> {{ items.name }}</nut-radio> <nut-radio v-for="(items, indexs) in item.standardList" size="40" :label="items.snowFlakeId" :key="indexs"> {{ items.name }}</nut-radio>
</nut-radio-group> </nut-radio-group>
<!-- 不能直接去更改 v-model 绑定的 这个数据 ,否则会造成无限递归-->
<nut-checkbox-group v-else v-model="item.selectedGroup" @change="(arr) => checkboxGroupChange(arr, index)" style="display: flex; flex-direction: column"> <nut-checkbox-group v-else v-model="item.selectedGroup" @change="(arr) => checkboxGroupChange(arr, index)" style="display: flex; flex-direction: column">
<nut-checkbox <nut-checkbox
v-model="items.isSelected" @change="(state, label) => checkboxChange(state, label)"
@change="(state, label) => checkboxChange(state, label, index, i)"
v-for="(items, i) in item.standardList" v-for="(items, i) in item.standardList"
size="40" size="40"
:label="items.snowFlakeId" :label="items.snowFlakeId"
@ -31,7 +31,7 @@
<script setup> <script setup>
import Taro, { useLoad, useUnload } from '@tarojs/taro' import Taro, { useLoad, useUnload } from '@tarojs/taro'
import { ref, computed, watch, nextTick } from 'vue' import { ref, computed, watch } from 'vue'
import { useDailyStore } from '@/store/daily.ts' import { useDailyStore } from '@/store/daily.ts'
const store = useDailyStore() const store = useDailyStore()
@ -66,17 +66,21 @@ const onChange = (modelValue, name) => {
if (name === element.name) { if (name === element.name) {
element.selectedID = modelValue element.selectedID = modelValue
element.standardList.forEach((item) => { element.standardList.forEach((item) => {
// console.log('item.snowFlakeId, modelValue_________________', item.snowFlakeId, modelValue)
if (item.snowFlakeId == modelValue) { if (item.snowFlakeId == modelValue) {
element.selectedName = item.name // selectedName 便
element.selected_points = item.deductionPoints // element.selected_points = item.deductionPoints //
} }
}) })
} }
}) })
} }
const checkboxGroupChange = function (arr, index) { const checkboxGroupChange = function (arr, index) {
let points = 0 // console.log('🚀 ~ checkboxGroupChange ~ arr:', arr)
// console.log(index)
// console.log(starRating.value[findIndex.value].itemList[index])
let points = 0
starRating.value[findIndex.value].itemList.forEach((element, i) => { starRating.value[findIndex.value].itemList.forEach((element, i) => {
if (i === index) { if (i === index) {
element.selectedGroup.forEach((selectedId) => { element.selectedGroup.forEach((selectedId) => {
@ -89,27 +93,11 @@ const checkboxGroupChange = function (arr, index) {
} }
}) })
starRating.value[findIndex.value].itemList[index].selected_points = points starRating.value[findIndex.value].itemList[index].selected_points = points
// console.log(points)
// console.log(starRating.value[findIndex.value].itemList[index].selected_points)
} }
const checkboxChange = async function (state, label, index, i) { const checkboxChange = function (state, label) {
// DOM // console.log('🚀 ~ checkboxChange ~ state, label:', state, label)
await nextTick() // DOM
// DOM
let arr
if (label === '达标' && i === 0) {
console.log(11111111111111)
arr = ['null']
} else {
arr = starRating.value[findIndex.value].itemList[index].selectedGroup.filter((selectedId) => selectedId != 'null')
}
if (arr?.length === 0) {
arr = ['null']
}
if (JSON.stringify(arr) !== JSON.stringify(starRating.value[findIndex.value].itemList[index].selectedGroup)) {
starRating.value[findIndex.value].itemList[index].selectedGroup = arr
}
} }
useUnload(() => { useUnload(() => {
let points = 0 let points = 0
@ -117,6 +105,7 @@ useUnload(() => {
points += element.selected_points points += element.selected_points
}) })
starRating.value[findIndex.value].currentScore = points starRating.value[findIndex.value].currentScore = points
store.dailyinspectionList([...starRating.value]) store.dailyinspectionList([...starRating.value])
}) })
</script> </script>

View File

@ -12,7 +12,7 @@ const base64_2 = computed(() => store.get_base64_2)
const _index = ref(0) const _index = ref(0)
useLoad((options) => { useLoad((options) => {
// console.log(options) console.log(options)
_index.value = Number(options.index) _index.value = Number(options.index)
if (_index.value === 1) { if (_index.value === 1) {
imgData.value = base64_1.value imgData.value = base64_1.value
@ -39,7 +39,7 @@ const convertToBase64 = (imgUrl: string): Promise<string> => {
} }
const confirm = async (canvas: any, data: string) => { const confirm = async (canvas: any, data: string) => {
if (data) { if (data) {
console.log('imgData', canvas) console.log('imgData', canvas, data)
try { try {
const base64Image = await convertToBase64(data) const base64Image = await convertToBase64(data)
if (_index.value === 1) { if (_index.value === 1) {

View File

@ -102,57 +102,3 @@ interface BaseEnum<T, E = Record<string, any>> {
label: string; label: string;
extData: E; extData: E;
} }
interface StandardList {
ckItemId: string
deductionPoints: number
name: string
snowFlakeId: string
isSelected: boolean
}
interface ItemList {
ckGroupId: string
name: string
remark: string
snowFlakeId: string
standardList: StandardList[]
type: { value: string; label: string }
selectedID: string
selected_points: number
selectedGroup: any[]
}
interface StarRating {
itemList: ItemList[]
name: string
remark: string
snowFlakeId: string
totalScore: number
currentScore: number
}
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
}
}
}
interface Item {
itemList: any[] // 根据实际情况调整类型
snowFlakeId: string
}