Merge remote-tracking branch 'origin/main'

This commit is contained in:
luozhun 2024-11-12 09:49:38 +08:00
commit 5d631ffbdb
6 changed files with 119 additions and 101 deletions

View File

@ -58,8 +58,8 @@
"@tarojs/taro": "3.6.26", "@tarojs/taro": "3.6.26",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"pinia": "^2.2.2", "pinia": "^2.2.2",
"vue": "^3.0.0", "vue": "^3.0.0"
"vuex": "^4.0.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.8.0", "@babel/core": "^7.8.0",

View File

@ -12,19 +12,14 @@ 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
}, },
cleardailtcolour() { clearSignData() {
this.userdailyinspection = { this.base64_1 = ''
...this.userdailyinspection, this.base64_2 = ''
markColor: this.userdailyinspection.markColor,
markColor1: this.userdailyinspection.markColor,
comment: ''
}
} }
}, },
getters: { getters: {

View File

@ -1,6 +1,5 @@
<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">
考核单位 考核单位
@ -12,8 +11,6 @@
</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">
当前考核项目 当前考核项目
@ -24,7 +21,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">
@ -96,7 +93,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 }
) )
@ -111,74 +108,31 @@ 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.selectedID = element.standardList[0].snowFlakeId element.standardList.forEach((ele) => {
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
@ -188,7 +142,9 @@ const assessmentCriteriaRulesByCkProjectId = async function (ckProjectId) {
} }
}) })
}) })
starRating.value = res.data ?? [] // res.data undefined使 starRating.value = res.data ?? []
// console.log('starRating.value______________________________', starRating.value)
store.dailyinspectionList(starRating.value) store.dailyinspectionList(starRating.value)
Taro.hideLoading() Taro.hideLoading()
} }
@ -207,7 +163,6 @@ 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
} }
@ -215,11 +170,15 @@ 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) {
let index = Number(e.detail.value) try {
selectorChecked.value = selector.value?.[index].label as string let index = Number(e.detail.value)
let type = selector.value?.[index].extData.type.value selectorChecked.value = selector.value?.[index].label as string
ckProjectListByType(type) let type = selector.value?.[index].extData.type.value
_form.enterprisesUnitId = selector.value?.[index].value as string ckProjectListByType(type)
_form.enterprisesUnitId = selector.value?.[index].value as string
} catch (error) {
console.log('🚀 ~ onChange ~ error:', error)
}
} }
const getUnitEnterprisesUnitList = async function () { const getUnitEnterprisesUnitList = async function () {
@ -238,16 +197,20 @@ const _showToast = function (title) {
/** /**
* @onSubmit 提交 * @onSubmit 提交
*/
/**
* @assessmentRecordDetails 选择后的数据用于提交 * @assessmentRecordDetails 选择后的数据用于提交
* @clearData 清空数据
*/ */
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('请选择企事业单位')
@ -302,14 +265,9 @@ 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()
store.dailyinspectionList([]) // clearData() //
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
@change="(state, label) => checkboxChange(state, label)" v-model="items.isSelected"
@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 } from 'vue' import { ref, computed, watch, nextTick } from 'vue'
import { useDailyStore } from '@/store/daily.ts' import { useDailyStore } from '@/store/daily.ts'
const store = useDailyStore() const store = useDailyStore()
@ -66,21 +66,17 @@ 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) {
// console.log('🚀 ~ checkboxGroupChange ~ arr:', arr)
// console.log(index)
// console.log(starRating.value[findIndex.value].itemList[index]) const checkboxGroupChange = function (arr, index) {
let points = 0 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) => {
@ -93,11 +89,27 @@ 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 = function (state, label) { const checkboxChange = async function (state, label, index, i) {
// console.log('🚀 ~ checkboxChange ~ state, label:', state, label) // DOM
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
@ -105,7 +117,6 @@ 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, data) console.log('imgData', canvas)
try { try {
const base64Image = await convertToBase64(data) const base64Image = await convertToBase64(data)
if (_index.value === 1) { if (_index.value === 1) {

View File

@ -102,3 +102,57 @@ 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
}