Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
5d631ffbdb
|
@ -58,8 +58,8 @@
|
|||
"@tarojs/taro": "3.6.26",
|
||||
"dayjs": "^1.11.13",
|
||||
"pinia": "^2.2.2",
|
||||
"vue": "^3.0.0",
|
||||
"vuex": "^4.0.2"
|
||||
"vue": "^3.0.0"
|
||||
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.0",
|
||||
|
|
|
@ -12,19 +12,14 @@ export const useDailyStore = defineStore('daily', {
|
|||
this.userdailyinspection = [...data]
|
||||
},
|
||||
change_base64_1(data) {
|
||||
// console.log("🚀 ~ change_base64_1 ~ data:", data)
|
||||
this.base64_1 = data
|
||||
},
|
||||
change_base64_2(data) {
|
||||
this.base64_2 = data
|
||||
},
|
||||
cleardailtcolour() {
|
||||
this.userdailyinspection = {
|
||||
...this.userdailyinspection,
|
||||
markColor: this.userdailyinspection.markColor,
|
||||
markColor1: this.userdailyinspection.markColor,
|
||||
comment: ''
|
||||
}
|
||||
clearSignData() {
|
||||
this.base64_1 = ''
|
||||
this.base64_2 = ''
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<template>
|
||||
<view class="container">
|
||||
<!-- picker -->
|
||||
<picker mode="selector" :range="selector" rangeKey="label" @change="onChange">
|
||||
<view class="picker">
|
||||
考核单位:
|
||||
|
@ -12,8 +11,6 @@
|
|||
</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">
|
||||
当前考核项目:
|
||||
|
@ -24,7 +21,7 @@
|
|||
</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">
|
||||
|
@ -96,7 +93,7 @@ watch(
|
|||
starRating.value = newDaily
|
||||
}
|
||||
submitData.value = newDaily
|
||||
console.log('watch_______________', _form, submitData.value)
|
||||
// console.log('watch_______________', _form, submitData.value)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
@ -111,74 +108,31 @@ const Onrating = function (name: string, snowFlakeId: string) {
|
|||
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 获取考核规则
|
||||
*/
|
||||
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) {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true,
|
||||
})
|
||||
const res = await api.get<StarRating[]>(`/assessmentCriteria/assessmentCriteriaRulesByCkProjectId`, { ckProjectId })
|
||||
// ————————————————————————————————————————处理数据,默认添加已选择项
|
||||
|
||||
res.data?.forEach((item) => {
|
||||
item.currentScore = 0
|
||||
|
||||
item.itemList.forEach((element: ItemList) => {
|
||||
// element.selectedID = element.standardList[0].snowFlakeId
|
||||
element.standardList.forEach((ele) => {
|
||||
ele.isSelected = false
|
||||
})
|
||||
element.standardList.unshift({
|
||||
ckItemId: 'null',
|
||||
deductionPoints: 0,
|
||||
name: '达标',
|
||||
snowFlakeId: 'null',
|
||||
isSelected: true,
|
||||
})
|
||||
element.selectedID = element.standardList[0].snowFlakeId
|
||||
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)
|
||||
Taro.hideLoading()
|
||||
}
|
||||
|
@ -207,7 +163,6 @@ const onChangeType = function (e: any) {
|
|||
let index = Number(e.detail.value)
|
||||
selectorCheckedType.value = selectorType.value?.[index].label as string
|
||||
currentCkProjectId.value = selectorType.value?.[index].value as string
|
||||
// let ckProjectId = selectorType.value?.[index].value
|
||||
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value)
|
||||
_form.ckProjectId = selectorType.value?.[index].value as string
|
||||
}
|
||||
|
@ -215,11 +170,15 @@ const onChangeType = function (e: any) {
|
|||
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
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
const getUnitEnterprisesUnitList = async function () {
|
||||
|
@ -238,16 +197,20 @@ const _showToast = function (title) {
|
|||
|
||||
/**
|
||||
* @onSubmit 提交
|
||||
*/
|
||||
/**
|
||||
* @assessmentRecordDetails 选择后的数据用于提交
|
||||
* @clearData 清空数据
|
||||
*/
|
||||
interface Item {
|
||||
itemList: any[] // 根据实际情况调整类型
|
||||
snowFlakeId: string
|
||||
}
|
||||
|
||||
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 () {
|
||||
if (_form.enterprisesUnitId === '') {
|
||||
_showToast('请选择企事业单位')
|
||||
|
@ -302,14 +265,9 @@ const onSubmit = async function () {
|
|||
}
|
||||
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()
|
||||
store.dailyinspectionList([]) //清空数据
|
||||
assessmentRecordDetails.value = [] //清空数据
|
||||
assessmentCriteriaRulesByCkProjectId(currentCkProjectId.value) //重新获取数据
|
||||
clearData() //清空数据
|
||||
if (result.code === 200) {
|
||||
Taro.showToast({
|
||||
title: result.message,
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
<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">
|
||||
<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 v-for="(items, indexs) in item.standardList" size="40" :label="items.snowFlakeId" :key="indexs"> {{ items.name }}</nut-radio>
|
||||
</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
|
||||
@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"
|
||||
size="40"
|
||||
:label="items.snowFlakeId"
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
<script setup>
|
||||
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'
|
||||
const store = useDailyStore()
|
||||
|
@ -66,21 +66,17 @@ const onChange = (modelValue, name) => {
|
|||
if (name === element.name) {
|
||||
element.selectedID = modelValue
|
||||
element.standardList.forEach((item) => {
|
||||
// console.log('item.snowFlakeId, modelValue_________________', item.snowFlakeId, modelValue)
|
||||
if (item.snowFlakeId == modelValue) {
|
||||
element.selectedName = item.name // 添加扣分选项名字 selectedName 为标识数据———————便于区分测试
|
||||
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
|
||||
|
||||
starRating.value[findIndex.value].itemList.forEach((element, i) => {
|
||||
if (i === index) {
|
||||
element.selectedGroup.forEach((selectedId) => {
|
||||
|
@ -93,11 +89,27 @@ const checkboxGroupChange = function (arr, index) {
|
|||
}
|
||||
})
|
||||
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) {
|
||||
// console.log('🚀 ~ checkboxChange ~ state, label:', state, label)
|
||||
const checkboxChange = async function (state, label, index, i) {
|
||||
// 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(() => {
|
||||
let points = 0
|
||||
|
@ -105,7 +117,6 @@ useUnload(() => {
|
|||
points += element.selected_points
|
||||
})
|
||||
starRating.value[findIndex.value].currentScore = points
|
||||
|
||||
store.dailyinspectionList([...starRating.value])
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -12,7 +12,7 @@ const base64_2 = computed(() => store.get_base64_2)
|
|||
|
||||
const _index = ref(0)
|
||||
useLoad((options) => {
|
||||
console.log(options)
|
||||
// console.log(options)
|
||||
_index.value = Number(options.index)
|
||||
if (_index.value === 1) {
|
||||
imgData.value = base64_1.value
|
||||
|
@ -39,7 +39,7 @@ const convertToBase64 = (imgUrl: string): Promise<string> => {
|
|||
}
|
||||
const confirm = async (canvas: any, data: string) => {
|
||||
if (data) {
|
||||
console.log('imgData', canvas, data)
|
||||
console.log('imgData', canvas)
|
||||
try {
|
||||
const base64Image = await convertToBase64(data)
|
||||
if (_index.value === 1) {
|
||||
|
|
|
@ -102,3 +102,57 @@ interface BaseEnum<T, E = Record<string, any>> {
|
|||
label: string;
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue