jy-safe-app/pages/apply/subPages/FO/2currentClassRecordEdit.vue

541 lines
19 KiB
Vue
Raw Normal View History

2025-10-14 15:17:30 +08:00
<template>
<view class="todo-page">
<view class="card">
<view class="background"></view>
<!-- <uni-card margin="0" :is-shadow="true"> -->
<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" :rules="rules" ref="wForm" errorType="border-bottom" class="demo-ruleForm">
<u-form-item label="审核意见:" prop="AUDIT_OPINION" borderBottom v-if="model.SHIFT_STATUS==9">
</u-form-item>
<u--textarea v-html="model.AUDIT_OPINION" border="surround" v-if="model.SHIFT_STATUS==9" disabled></u--textarea>
<u-form-item label="本班运行情况:" prop="CURRENT_CLASS_STATUS_SHOW" @click="handleShowSheet({title: '运行情况', name: 'CURRENT_CLASS_STATUS'})">
<u--input :value="CURRENT_CLASS_STATUS_SHOW" disabled disabledColor="#fff" placeholder="请选择本班运行情况" border="none" inputAlign="right" fontSize="14px"></u--input>
<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12"></u-icon>
</u-form-item>
<u-form-item label="存在问题:" prop="CURRENT_CLASS_QUESTION" borderBottom v-if="model.CURRENT_CLASS_STATUS==1" required>
</u-form-item>
<u--textarea v-model="model.CURRENT_CLASS_QUESTION" placeholder="请输入存在问题" border="surround" v-if="model.CURRENT_CLASS_STATUS==1" :required="model.CURRENT_CLASS_STATUS==1"></u--textarea>
<u-form-item label="处理情况:" prop="CURRENT_CLASS_MEASURE" borderBottom v-if="model.CURRENT_CLASS_STATUS==1" required>
</u-form-item>
<u--textarea v-model="model.CURRENT_CLASS_MEASURE" placeholder="请输入处理情况" border="surround" v-if="model.CURRENT_CLASS_STATUS==1" :required="model.CURRENT_CLASS_STATUS==1"></u--textarea>
<u-form-item label="设备运行情况:" prop="DEVICE_STATUS_SHOW" @click="handleShowSheet({title: '运行情况', name: 'DEVICE_STATUS'})">
<u--input :value="DEVICE_STATUS_SHOW" disabled disabledColor="#fff" placeholder="请选择设备运行情况" border="none" inputAlign="right" fontSize="14px"></u--input>
<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12"></u-icon>
</u-form-item>
<u-form-item label="存在问题:" prop="DEVICE_QUESTION" borderBottom v-if="model.DEVICE_STATUS==1" required>
</u-form-item>
<u--textarea v-model="model.DEVICE_QUESTION" placeholder="请输入存在问题" border="surround" v-if="model.DEVICE_STATUS==1" :required="model.DEVICE_STATUS==1"></u--textarea>
<u-form-item label="处理情况:" prop="DEVICE_MEASURE" borderBottom v-if="model.DEVICE_STATUS==1" required>
</u-form-item>
<u--textarea v-model="model.DEVICE_MEASURE" placeholder="请输入处理情况" border="surround" v-if="model.DEVICE_STATUS==1" :required="model.DEVICE_STATUS==1"></u--textarea>
<u-form-item label="现场环境情况:" prop="ENVIRONMENT_STATUS_SHOW" @click="handleShowSheet({title: '运行情况', name: 'ENVIRONMENT_STATUS'})">
<u--input :value="ENVIRONMENT_STATUS_SHOW" disabled disabledColor="#fff" placeholder="请选择本班运行情况" border="none" inputAlign="right" fontSize="14px"></u--input>
<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12"></u-icon>
</u-form-item>
<u-form-item label="存在问题:" prop="ENVIRONMENT_QUESTION" borderBottom v-if="model.ENVIRONMENT_STATUS==1" required>
</u-form-item>
<u--textarea v-model="model.ENVIRONMENT_QUESTION" placeholder="请输入存在问题" border="surround" v-if="model.ENVIRONMENT_STATUS==1"></u--textarea>
<u-form-item label="处理情况:" prop="ENVIRONMENT_MEASURE" borderBottom v-if="model.ENVIRONMENT_STATUS==1" required>
</u-form-item>
<u--textarea v-model="model.ENVIRONMENT_MEASURE" placeholder="请输入处理情况" border="surround" v-if="model.ENVIRONMENT_STATUS==1"></u--textarea>
<u-form-item label="劳保用品情况:" prop="SUPPLIES_STATUS_SHOW" @click="handleShowSheet({title: '运行情况', name: 'SUPPLIES_STATUS'})">
<u--input :value="SUPPLIES_STATUS_SHOW" disabled disabledColor="#fff" placeholder="请选择劳保用品情况" border="none" inputAlign="right" fontSize="14px"></u--input>
<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12"></u-icon>
</u-form-item>
<u-form-item label="存在问题:" prop="SUPPLIES_QUESTION" borderBottom v-if="model.SUPPLIES_STATUS==1" required>
</u-form-item>
<u--textarea v-model="model.SUPPLIES_QUESTION" placeholder="请输入存在问题" border="surround" v-if="model.SUPPLIES_STATUS==1"></u--textarea>
<u-form-item label="处理情况:" prop="SUPPLIES_MEASURE" borderBottom v-if="model.SUPPLIES_STATUS==1" required>
</u-form-item>
<u--textarea v-model="model.SUPPLIES_MEASURE" placeholder="请输入处理情况" border="surround" v-if="model.SUPPLIES_STATUS==1"></u--textarea>
<u-form-item label="是否佩戴:" prop="SUPPLIES_USED_SHOW" @click="handleShowSheet({title: '运行情况', name: 'SUPPLIES_USED'})">
<u--input :value="SUPPLIES_USED_SHOW" disabled disabledColor="#fff" placeholder="请选择劳保用品情况" border="none" inputAlign="right" fontSize="14px"></u--input>
<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12"></u-icon>
</u-form-item>
<u-form-item label="设备工具使用存放情况:" prop="DEVICE_STORAGE" borderBottom required>
</u-form-item>
<u--textarea v-model="model.DEVICE_STORAGE" placeholder="请输入设备工具使用存放情况
" border="surround"></u--textarea>
<!-- <u-form-item label="当班人员:" prop="UserNames" borderBottom>
<u--input v-html="model.UserNames" border="none" slot="right" inputAlign="right" disabled
disabledColor="#ffffff" fontSize="14px"></u--input>
</u-form-item> -->
<u-form-item v-if="isAdd==1" label="是否触发交接班记录:" prop="IS_HANDOVER" borderBottom>
<u-switch v-model="model.IS_HANDOVER" @change="changeSwitch" border="none" slot="right" inputAlign="right"></u-switch>
</u-form-item>
<view class="upload-title">附件</view>
<full-upload v-model="model.Nav_Files" :isShowBtn='true' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>
</u--form>
<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom" class="sub-form" v-if="model.Nav_Users">
<view style="margin: 10px 0px;">
<u-button text="新增人员" type="primary" @click="handleAddPerson" v-if="ORG_ID=='8b3c41aa-51b1-7ce9-1879-248a038c1b5c'"></u-button>
</view>
<u-collapse :border="false" accordion>
<uni-card margin="0" spacing="0" :is-shadow="false" v-for="(item, index) in model.Nav_Users.filter(i => !i.IS_DELETED)">
<u-form-item :label="(index+1)+'. '+item['Nav_User'].NAME+' - '+item['USER_SHIFT_STATUSName']" prop="Nav_User.NAME" @click="handleChangeUser(item)" >
<view slot="right" class="row-action" v-if="ORG_ID=='8b3c41aa-51b1-7ce9-1879-248a038c1b5c'">
<view class="action" @click.stop>
<u-icon @click="handleDelPersonRowBefore(index, item)" class="icon" name="trash" color="#ff4d4f" size="21"></u-icon>
</view>
</view>
</u-form-item>
</uni-card>
</u-collapse>
</u--form>
<!-- </uni-card> -->
</view>
<u-picker :defaultIndex="[0]" :show="comPickerInfo.showSheet" :columns="comPickerInfo.columns" @confirm="onConfirmPicker" @close="closePicker" @cancel="closePicker" keyName="NAME"></u-picker>
<view style="padding: 10px 16px;" class="bottom-button">
<u-button type="primary" :disabled="isSubmit" :loading="isSubmit" @click="submit" v-if='tableKey==1||isAdd==1' color="#3d4b70">提交</u-button>
</view>
<query-selector :show="showPopup" :total="curTotal" :lists="userLists" :defaultValue="currentOperateUser.NAME" @close="handleClosePopup" @search="handleSearchUser" @select="handleSelectedUser" />
<u-modal :show="showDelModalIndexPerson >= 0" @confirm="confirmDelPerson" @cancel="cancelDelPerson" showCancelButton title="确认删除?"></u-modal>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex'
import {
extendFilterGroup,
extendGroupRule,
extendInclude,
extendOrder,
extendRule,
guid,
initFilter,
initFilterGroup
} from '../../../../utils/common'
import {
getRequest,
} from '../../../../services/apply/FOServices/FOServices';
import config from '../../../../config/common'
import {
getEnum,
getUserLists
} from '../../../../services/common';
export default {
data() {
return {
listPropUpload: ['CURRENT_CLASS_RECORD_ID'],
listPropValUpload: [],
UserNames: "",
model: {
CURRENT_CLASS_STATUS: 0,
DEVICE_STATUS: 0,
ENVIRONMENT_STATUS: 0,
SUPPLIES_STATUS: 0,
SUPPLIES_USED: 1,
ORG_ID: "",
ENABLE_STATUS: 0,
IS_HANDOVER: true,
},
subModel: {
Nav_User: {},
USER_ID: ""
},
rules: {
'CURRENT_CLASS_QUESTION': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
'CURRENT_CLASS_MEASURE': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
'DEVICE_QUESTION': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
'DEVICE_MEASURE': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
'ENVIRONMENT_QUESTION': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
'ENVIRONMENT_MEASURE': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
'SUPPLIES_QUESTION': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
'SUPPLIES_MEASURE': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
'DEVICE_STORAGE': {
type: 'string',
required: true,
trigger: ['blur', 'change']
},
},
comPickerInfo: {
showSheet: false,
columns: [],
title: '',
dataIndex: undefined,
formIndex: undefined,
name: ''
},
currentOperateUser: {},
showPopup: false,
tableKey: '0',
TaskID: null,
isLoadOK: false,
showDelModalIndex: undefined,
uploadFiles: [],
isAdd: 0,
ORG_ID: uni.getStorageSync('orgId'),
CURRENT_CLASS_STATUS_SHOW: "",
DEVICE_STATUS_SHOW: "",
ENVIRONMENT_STATUS_SHOW: "",
SUPPLIES_USED_SHOW: "",
SUPPLIES_STATUS_SHOW: "",
isSubmit: false,
currentOperateUser: {},
showPopup: false,
userLists: [],
curTotal: 0,
showDelModalIndexPerson: undefined,
enumsData: {}, // 存储所有枚举数据(键:枚举名称,值:处理后的枚举列表)
enumsText: {} // 存储枚举文本列表(用于下拉选择等场景)
}
},
onLoad(option) {
this.model.ID = option.ID;
this.TaskID = option.taskID ? option.taskID : "00000000-0000-0000-0000-000000000000";
this.tableKey = option.tableKey ? option.tableKey : '0';
if (option.isAdd != 1) {
this.fetchEnums(['FOUserShiftStatusEnum']);
} else {
this.isAdd = 1;
this.model.ID = guid();
this.model.CURRENT_CLASS_STATUS == 0 ? this.CURRENT_CLASS_STATUS_SHOW = "正常" : this
.CURRENT_CLASS_STATUS_SHOW = "不正常";
this.model.DEVICE_STATUS == 0 ? this.DEVICE_STATUS_SHOW = "正常" : this
.DEVICE_STATUS_SHOW = "正常";
this.model.ENVIRONMENT_STATUS == 0 ? this.ENVIRONMENT_STATUS_SHOW = "正常" : this
.ENVIRONMENT_STATUS_SHOW = "正常";
this.model.SUPPLIES_STATUS == 0 ? this.SUPPLIES_STATUS_SHOW = "正常" : this
.SUPPLIES_STATUS_SHOW = "正常";
this.model.SUPPLIES_USED == 0 ? this.SUPPLIES_USED_SHOW = "否" : this
.SUPPLIES_USED_SHOW = "是";
}
},
methods: {
async fetchEnums(enumNames) {
try {
// 存储所有枚举请求的Promise
const enumPromises = enumNames.map(name => {
return getEnum({
name
}).then(res => {
// 统一处理枚举格式添加name/code字段便于后续映射
return {
enumName: name,
data: res.map(item => ({
...item,
name: item.NAME, // 统一显示名称字段
code: item.ID // 统一值字段
}))
};
});
});
// 等待所有枚举请求完成
const results = await Promise.all(enumPromises);
// 存储枚举结果到data中键为枚举名称值为处理后的数据
results.forEach(({
enumName,
data
}) => {
this.enumsData[enumName] = data;
// 生成文本列表(如需要)
this.enumsText[enumName] = data.map(item => item.name);
});
// 所有枚举获取完成后执行loadData
this.loadData();
} catch (error) {
console.error('枚举请求失败:', error);
uni.showToast({
title: '枚举数据加载失败',
icon: 'none'
});
}
},
changeSwitch(e) {
this.model.IS_HANDOVER = e;
},
loadData() {
const json = initFilter(this.ORG_ID, "", "")
if (this.listPropValUpload.length == 0) {
this.listPropValUpload.push(this.model.ID)
}
extendInclude(json, "Nav_Files.Nav_ImgFile")
extendInclude(json, "Nav_Users.Nav_User")
extendRule(json, 'ID', 1, this.model.ID)
getRequest(json, "/FO/CurrentClassRecord/Get").then(res => {
this.model = res;
this.model.CURRENT_CLASS_STATUS == 0 ? this.CURRENT_CLASS_STATUS_SHOW = "正常" : this
.CURRENT_CLASS_STATUS_SHOW = "不正常";
this.model.DEVICE_STATUS == 0 ? this.DEVICE_STATUS_SHOW = "正常" : this
.DEVICE_STATUS_SHOW = "正常";
this.model.ENVIRONMENT_STATUS == 0 ? this.ENVIRONMENT_STATUS_SHOW = "正常" : this
.ENVIRONMENT_STATUS_SHOW = "正常";
this.model.SUPPLIES_STATUS == 0 ? this.SUPPLIES_STATUS_SHOW = "正常" : this
.SUPPLIES_STATUS_SHOW = "正常";
this.model.SUPPLIES_USED == 0 ? this.SUPPLIES_USED_SHOW = "否" : this
.SUPPLIES_USED_SHOW = "是";
let strUserName = ''
if (res.Nav_Users && res.Nav_Users.length > 0) {
for (let i = 0; i < res.Nav_Users.length; i++) {
res.Nav_Users[i].USER_SHIFT_STATUSName = res.Nav_Users[i].USER_SHIFT_STATUS !== undefined ? this.enumsData['FOUserShiftStatusEnum'].find(item => item.code === res.Nav_Users[i]
.USER_SHIFT_STATUS).name : '';
if (res.Nav_Users[i].USER_SHIFT_STATUS == 0) {
strUserName += (strUserName.length > 0 ? "," : "") + "<text style='color:red'>" +
res.Nav_Users[i].Nav_User.NAME + "</text>";
} else {
strUserName += (strUserName.length > 0 ? "," : "") + res.Nav_Users[
i].Nav_User.NAME;
}
}
}
this.model.UserNames = strUserName;
})
},
handleSearchUser(val, pageIndex) {
const json = initFilter(this.ORG_ID, "", "NAME", '', pageIndex)
extendRule(json, 'ENABLE_STATUS', 1, '0')
// extendRule(json, 'DEPARTMENT_ID', 1, uni.getStorageSync('appInfo').User.DEPARTMENT_ID)
if (val !== 'init') {
const tempGroup = initFilterGroup(false);
extendGroupRule(tempGroup, 'NAME', 9, val)
extendFilterGroup(json, tempGroup);
}
json.Limit = 20
if (pageIndex) {
json.Start = (pageIndex - 1) * 20;
}
getUserLists(json).then(res => {
if (res.IsSuccessful) {
this.userLists = res.Data.map(i => {
return {
...i,
name: i.NAME,
code: i.CODE
}
})
this.curTotal = res.TotalCount
}
})
},
handleSelectedUser(val) {
this.showPopup = false
this.lists = []
this.currentOperateUser.USER_ID = val.ID;
this.currentOperateUser.Nav_User = val;
},
handleClosePopup() {
this.showPopup = false
},
handleChangeUser(user) {
if (user.Nav_User.NAME == '') {
this.currentOperateUser = user;
this.showPopup = true;
this.handleSearchUser('init');
}
},
handleDelPersonRowBefore(index, item) {
if (item.USER_ID == "") {
this.model.Nav_Users.splice(index, 1)
} else {
this.showDelModalIndexPerson = index
}
},
cancelDelPerson() {
this.showDelModalIndexPerson = undefined
},
confirmDelPerson() {
this.model.Nav_Users.filter(i => !i.IS_DELETED)[this.showDelModalIndexPerson].IS_DELETED = true;
//this.model.Nav_Users.splice(this.showDelModalIndex, 1)
this.showDelModalIndexPerson = undefined
},
handleAddPerson() {
this.model.Nav_Users.unshift({
CURRENT_CLASS_RECORD_ID: this.model.ID,
ID: guid(),
ORG_ID: this.ORG_ID,
Nav_User: {
NAME: "",
CODE: ""
},
USER_SHIFT_STATUSName: '',
USER_ID: "",
IS_DELETED: false,
})
},
onConfirmPicker(e) {
const {
name,
formIndex
} = this.comPickerInfo
this.model[name] = e.value[0].ID
this[name + '_SHOW'] = e.value[0].NAME
this.comPickerInfo.showSheet = false
},
closePicker() {
this.comPickerInfo = {
showSheet: false,
columns: [],
title: '',
name: '',
formIndex: undefined
}
},
submit() {
this.isSubmit = true;
const ele = this.$refs
ele['wForm'].validate().then(res => {
this.modelEdit = JSON.parse(JSON.stringify(this.model))
this.modelEdit.PUBLISH = "SaveAndNotify";
if (this.modelEdit.ORG_ID == "") {
this.modelEdit.ORG_ID = this.ORG_ID;
}
this.modelEdit.TaskID = this.TaskID;
getRequest(this.modelEdit, "/FO/FOCurrentClassRecord/FullUpdate").then(res => {
if (res) {
this.isSubmit = false;
uni.$showMsgFunc('操作成功!', () => {
uni.navigateBack()
}, 'success', 1000)
}
})
}).catch(err => {
this.isSubmit = false;
uni.$showErrorInfo('请检查必填项,必填项不能为空')
})
},
async handleShowSheet(p) {
let column = []
if (p.name === 'CURRENT_CLASS_STATUS' || p.name === 'DEVICE_STATUS' || p.name ===
'ENVIRONMENT_STATUS' || p.name === 'SUPPLIES_STATUS') {
column = [{
NAME: '正常',
ID: 0
},
{
NAME: '不正常',
ID: 1
}
]
} else if (p.name === 'SUPPLIES_USED') {
column = [{
NAME: '否',
ID: 0
},
{
NAME: '是',
ID: 1
}
]
}
if (column.length) {
this.comPickerInfo = {
showSheet: true,
title: p.title,
name: p.name,
formIndex: p.formIndex,
columns: [column]
}
} else {}
},
}
}
</script>
<style scoped>
/* @import url("../../../../style/css/editTemplate.css"); */
.todo-page {
/* padding: 16px 16px 70px; */
}
.background {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #edf1fd;
z-index: -1;
}
.card {
margin: 20px 16px 100px 16px;
/* border: 1px solid #EBEEF5; */
padding: 20px 30px 40px 30px;
/* box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 3px 1px; */
background-color: #ffffff;
border-radius: 10px;
}
.demo-ruleForm>>>.u-form-item__body__left__content__label {
font-size: 14px;
color: #8e8b9c;
/* justify-content: flex-start; */
}
.demo-ruleForm>>>.u-form-item__body__left__content__ {
left: -11px;
top: 0px
}
.demo-ruleForm>>>.u-textarea__field {
font-size: 14px;
}
.demo-ruleForm>>>.u-cell__title-text {
font-size: 14px;
}
.upload-title {
font-size: 14px;
color: #8e8b9c;
line-height: 22px;
padding: 8px 0px;
}
.bottom-button {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
padding: 10px 16px;
box-sizing: border-box;
background: #edf1fd;
z-index: 999;
}
</style>