<template>
|
<view>
|
<view class="form">
|
<view class="form-item">
|
<view class="title">条码</view>
|
<view class="right" style="width: 350rpx;">
|
<input type="text" :focus="HBarCodeFocus" v-model="hform.HBarCode" placeholder="请扫描(或输入)条码"
|
@confirm="getHBarCodeData(hform.HBarCode)" />
|
</view>
|
<uni-icons type="scan"
|
style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
|
size="20" @click="toScanCode"></uni-icons>
|
</view>
|
<view class="tabs">
|
<view :class="tabs == 0 ? 'on':''" @tap="() => { tabs = 0; reFocusBarCode(); }">单据信息</view>
|
<view :class="tabs == 1 ? 'on':''" @tap="() => { tabs = 1; reFocusBarCode(); }">工单信息</view>
|
<view :class="tabs == 2 ? 'on':''" @tap="() => { tabs = 2; reFocusBarCode(); }">制单信息</view>
|
</view>
|
|
<!-- 单据信息 -->
|
<view v-if="tabs == 0">
|
<view class="form-item">
|
<view class="title">角色</view>
|
<view class="right">
|
<!-- 多选下拉框 -->
|
<uni-data-select v-model="hform.HRoles" :multiple="true" :localdata="roleOptions"
|
placeholder="请选择角色" :clear="false" @change="onRoleChange">
|
</uni-data-select>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>生产车间:</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHDeptName" placeholder="请选择部门" v-model="hform.HDeptName"
|
@input="HDeptNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>签到人员:</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHEmpName" placeholder="请选择操作员" v-model="hform.HEmpName"
|
@input="HEmpNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>生产资源:</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHSourceName" placeholder="请选择生产资源" v-model="hform.HSourceName"
|
@input="HSourceNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>生产班组:</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHGroupName" placeholder="请选择班组" v-model="hform.HGroupName"
|
@input="HGroupNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>生产班次:</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHShiftsName" placeholder="请选择班次" v-model="hform.HShiftsName"
|
@input="HShiftsNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>模具实际出数:</view>
|
<view class="right">
|
<input name="HMouldRelQty" v-model="hform.HMouldRelQty" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">工序:</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHProcName" placeholder="请选择工序" v-model="hform.HProcName"
|
@input="HProcNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">设备编号:</view>
|
<view class="righton">
|
<input name="HEquipNumber" disabled v-model="hform.HEquipNumber" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">设备名称:</view>
|
<view class="righton">
|
<input name="HEquipName" disabled v-model="hform.HEquipName" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">模具编码:</view>
|
<view class="righton">
|
<input name="HMouldNo" disabled v-model="hform.HMouldNo" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">模具名称:</view>
|
<view class="righton">
|
<input name="HMouldName" disabled v-model="hform.HMouldName" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">模具状态:</view>
|
<view class="righton">
|
<input name="HMouldState" disabled v-model="hform.HMouldState" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">单据号:</view>
|
<view class="righton">
|
<input name="HBillNo" disabled v-model="hform.HBillNo" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">单据日期:</view>
|
<view class="righton">
|
<picker mode="date" v-model="hform.HDate" @change="HDateChange">
|
<input disabled v-model="hform.HDate" placeholder="请选择日期" />
|
</picker>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">备注:</view>
|
<view class="right">
|
<textarea name="HRemark" v-model="hform.HRemark" auto-height placeholder="请输入备注"></textarea>
|
</view>
|
</view>
|
|
</view>
|
<!-- 模具信息 -->
|
<view v-if="tabs == 1">
|
<view class="card-list" :style="{height: `${listTableHeight}px`, overflow: 'auto'}">
|
<!-- 卡片列表 -->
|
<view v-for="(item, index) in listData" :key="index" class="card-item">
|
<uni-card style="margin: 10rpx 0;">
|
<view class="card-content">
|
<view class="card-row">
|
<text class="card-label">流转卡号:</text>
|
<text class="card-value">{{ item['流转卡号'] || '-' }}</text>
|
</view>
|
<view class="card-row">
|
<text class="card-label">物料代码:</text>
|
<text class="card-value">{{ item['物料代码'] || '-' }}</text>
|
</view>
|
<view class="card-row">
|
<text class="card-label">物料名称:</text>
|
<text class="card-value">{{ item['物料名称'] || '-' }}</text>
|
</view>
|
<view class="card-row">
|
<text class="card-label">规格型号:</text>
|
<text class="card-value">{{ item['规格型号'] || '-' }}</text>
|
</view>
|
<view class="card-row">
|
<text class="card-label">数量:</text>
|
<text class="card-value">{{ item['数量'] || '0' }}</text>
|
</view>
|
<view class="card-row">
|
<text class="card-label">生产资源:</text>
|
<text class="card-value">{{ item['生产资源'] || '-' }}</text>
|
</view>
|
</view>
|
</uni-card>
|
</view>
|
|
<view class="over" v-if="listData.length == 0">暂无工单信息</view>
|
</view>
|
</view>
|
|
<view v-if="tabs == 2">
|
<view class="form-item">
|
<view class="title">制单人:</view>
|
<view class="righton">
|
<input v-model="hform.HMaker" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">制单日期:</view>
|
<view class="righton">
|
<input v-if="hform.HMakeDate" v-model="hform.HMakeDate.substr(0,10)" disabled />
|
<input v-else v-model="hform.HMakeDate" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">修改人:</view>
|
<view class="righton">
|
<input v-model="hform.HUpDater" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">修改日期:</view>
|
<view class="righton">
|
<input v-if="hform.HUpDateDate" v-model="hform.HUpDateDate.substr(0,10)" disabled />
|
<input v-else v-model="hform.HUpDateDate" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">审核人:</view>
|
<view class="righton">
|
<input v-model="hform.HChecker" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">审核日期:</view>
|
<view class="righton">
|
<input v-if="hform.HCheckDate" v-model="hform.HCheckDate.substr(0,10)" disabled />
|
<input v-else v-model="hform.HCheckDate" disabled />
|
</view>
|
</view>
|
|
</view>
|
|
<view class="bottom-btn">
|
<button v-if="btnType == 1 && !isEdit" class="btn-a" size="mini" @tap="submit">提交</button>
|
<button v-if="btnType != 1 && !isEdit" class="btn-a" size="mini" @tap="ifEdit">修改</button>
|
<button v-if="btnType != 1 && isEdit" class="btn-a" size="mini" @tap="submit">提交</button>
|
<button class="btn-c" size="mini" @tap="goBack">退出</button>
|
</view>
|
</view>
|
|
</view>
|
</template>
|
<script>
|
import getDateTime from '@/utils/getdateTime.js';
|
import {
|
getUserInfo
|
} from "@/utils/auth.js";
|
import dayjs from 'dayjs'
|
import {
|
CommonUtils
|
} from "@/utils/common.js"
|
import {
|
MpaasScan
|
} from "@/utils/mpaasScan.js"
|
export default {
|
data() {
|
return {
|
// 计算列表高度
|
bottomBtnTop: 0,
|
listTableTop: 0,
|
tabs: 0,
|
|
userInfo: getUserInfo(),
|
serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
|
linterid: '',
|
HBillNo: '',
|
btnType: 1, //1新增,3修改
|
showmore: false,
|
HBarCodeFocus: false,
|
|
arrayHDeptName: [], //部门
|
HDeptNameList: [],
|
arrayHEmpName: [], //发现人/负责人
|
HEmpNameList: [],
|
arrayHSourceName: [], //生产资源
|
HSourceNameList: [],
|
arrayHGroupName: [], //班组
|
HGroupNameList: [],
|
arrayHShiftsName: [], //班次
|
HShiftsNameList: [],
|
arrayHProcName: [], //工序
|
HProcNameList: [],
|
|
|
isEdit: false,
|
listOption: [], // 列表选项
|
listData: [], // 表格数据
|
selectedRows: [], // 表格选中的数据
|
roleOptions: [], // 下拉框选项
|
roleList: [], // 完整角色列表(包含ID)
|
|
// 添加用户已绑定角色数据
|
userBoundRoles: [], // 用户已绑定的角色ID列表
|
HBillType: 4616,
|
|
hform: {
|
HInterID: '',
|
HBillNo: '',
|
HDate: getDateTime.dateTimeStr('y-m-d'),
|
HBarCode: '',
|
HDeptName: uni.getStorageSync('HDeptName'),
|
HDeptID: uni.getStorageSync('HDeptID'),
|
HEmpName: uni.getStorageSync('HEmpName'),
|
HEmpID: uni.getStorageSync('HEmpID'),
|
HSourceID: uni.getStorageSync('HSourceID'),
|
HSourceName: uni.getStorageSync('HSourceName'),
|
HProcID: uni.getStorageSync('HProcID'),
|
HProcName: uni.getStorageSync('HProcName'),
|
HGroupID: uni.getStorageSync('HGroupID'),
|
HGroupName: uni.getStorageSync('HGroupName'),
|
HShiftsID: 0,
|
HShiftsName: '',
|
HMouldID: 0,
|
HMouldName: '',
|
HMouldNumber: '',
|
HMouldNo: '',
|
HMouldState: '',
|
HEquipID: 0,
|
HEquipNumber: '',
|
HEquipName: '',
|
HSignInReason: '',
|
HSignRemark: '',
|
HMouldRelQty: 0,
|
HOrgID: uni.getStorageSync('OrganizationID'),
|
|
HMaker: '',
|
HMakeDate: '',
|
HUpDater: '',
|
HUpDateDate: '',
|
HChecker: '',
|
HCheckDate: '',
|
HCloseMan: '',
|
HCloseDate: '',
|
HDeleteMan: '',
|
HDeleteDate: '',
|
|
HRoles: [],
|
eventType: 'Add'
|
}
|
}
|
},
|
onLoad(e) {
|
this.HBarCodeFocus = true
|
this.getHDeptList()
|
this.getHEmpList()
|
this.getHSourceList()
|
this.getHGroupList()
|
this.getHShiftsList()
|
this.getHProcList()
|
//先获取角色列表,然后获取用户绑定的角色
|
this.getRoleList().then(() => {
|
this.getUserBoundRoles();
|
});
|
this.hform.HMaker = uni.getStorageSync('HUserName')
|
console.log(e, this.userInfo)
|
if (e.linterid) {
|
this.btnType = 3
|
this.linterid = e.linterid
|
this.HBillNo = e.HBillNo
|
} else {
|
this.getNewData()
|
}
|
this.tabs = 0
|
},
|
// ==================== 计算属性 ====================
|
computed: {
|
// 计算表格高度
|
listTableHeight: {
|
get() {
|
return this.bottomBtnTop - this.listTableTop - 10
|
}
|
}
|
},
|
methods: {
|
//扫码
|
toScanCode() {
|
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
|
mpaasScanModule.mpaasScan({
|
'hideAlbum': true,
|
'timeoutInterval': '10', //超时时间
|
'timeoutText': '未识别到二维码' //超时提醒
|
}, (ret) => {
|
console.log(ret.resp_result)
|
this.hform.HBarCode = ret.resp_result
|
this.getHBarCodeData(ret.resp_result)
|
})
|
},
|
//光标
|
async refreshBarCodeState() {
|
this.HBarCodeFocus = false
|
await this.$nextTick(() => {
|
this.HBarCodeFocus = true
|
this.hform.HBarCode = ""
|
})
|
},
|
// 添加一个重新聚焦的方法
|
reFocusBarCode() {
|
this.HBarCodeFocus = false;
|
this.$nextTick(() => {
|
this.HBarCodeFocus = true;
|
});
|
},
|
//日期
|
HDateChange(e) {
|
console.log(e.detail.value)
|
this.hform.HDate = e.detail.value
|
},
|
getHBarCodeData(HBarCode) {
|
uni.request({
|
url: this.serverUrl + '/Sc_EmployeeSignInNoteBillController/txtHBarCode_KeyDown',
|
data: {
|
HBarCode: this.hform.HBarCode
|
},
|
success: (res) => {
|
if (res.data.code == 1) {
|
var data = res.data.data[0];
|
this.hform.HEquipID = data.HInterID
|
this.hform.HEquipNumber = data.设备代码
|
this.hform.HEquipName = data.设备名称
|
this.hform.HSourceID = data.HSourceID
|
this.hform.HSourceName = data.生产资源名称
|
this.getHMouldList()
|
this.getHIcmoList()
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: '接口请求失败',
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//获取模具信息
|
getHMouldList() {
|
uni.request({
|
url: this.serverUrl + '/Sc_EmployeeSignInNoteBillController/Get_HMouldList',
|
data: {
|
HInterID: this.hform.HEquipID,
|
UserNmae: uni.getStorageSync('Czybm'),
|
},
|
success: (res) => {
|
if (res.data.code == 1) {
|
var data = res.data.data[0];
|
this.hform.HMouldID = data.模具id
|
this.hform.HMouldNo = data.模具编码
|
this.hform.HMouldName = data.模具名称
|
this.hform.HMouldState = data.模具状态
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: '接口请求失败',
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//获取生产工单
|
getHIcmoList() {
|
uni.request({
|
url: this.serverUrl + '/Sc_EmployeeSignInNoteBillController/Get_HIcmoList',
|
data: {
|
HInterID: this.hform.HSourceID,
|
UserNmae: uni.getStorageSync('Czybm'),
|
},
|
success: (res) => {
|
if (res.data.code == 1) {
|
var data = res.data.data;
|
console.log(data)
|
for (let i = 0; i < data.length; i++) {
|
this.listData.push(Object.assign(data[i], {
|
index: i
|
}))
|
}
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: '接口请求失败',
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//获取使用部门数据
|
getHDeptList() {
|
uni.request({
|
url: this.serverUrl + '/PublicPageMethod/DeptList',
|
data: {
|
sWhere: "where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + uni.getStorageSync(
|
'OrganizationID') + ""
|
},
|
success: (res) => {
|
if (res.data.count == 1) {
|
this.HDeptNameList = res.data.data
|
for (var i = 0; i < res.data.data.length; i++) {
|
this.arrayHDeptName[i] = res.data.data[i].HName
|
}
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: '接口请求失败',
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//选择使用部门
|
HDeptNameChange(e) {
|
for (var i = 0; i < this.HDeptNameList.length; i++) {
|
if (this.HDeptNameList[i].HName == e) {
|
this.hform.HDeptID = this.HDeptNameList[i].HItemID
|
}
|
}
|
},
|
//操作员、负责人
|
getHEmpList() {
|
uni.request({
|
url: this.serverUrl + '/Web/GetEmployeeList_Json',
|
data: {
|
Employee: '',
|
HGroupID: 0
|
},
|
success: (res) => {
|
if (res.data.count == 1) {
|
this.HEmpNameList = res.data.data
|
for (var i = 0; i < res.data.data.length; i++) {
|
this.arrayHEmpName[i] = res.data.data[i].HName
|
}
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: '接口请求失败',
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//选择操作员
|
HEmpNameChange(e) {
|
for (var i = 0; i < this.HEmpNameList.length; i++) {
|
if (this.HEmpNameList[i].HName == e) {
|
this.hform.HEmpID = this.HEmpNameList[i].HItemID
|
}
|
}
|
},
|
//生产资源
|
getHSourceList() {
|
uni.request({
|
url: this.serverUrl + '/api/newBill/getSourceList',
|
data: {
|
sWhere: " and HUSEORGID = " + uni.getStorageSync('OrganizationID') + ""
|
},
|
success: (res) => {
|
if (res.data.code == 1) {
|
this.HSourceNameList = res.data.data.Gy_Source
|
for (var i = 0; i < res.data.data.Gy_Source.length; i++) {
|
this.arrayHSourceName[i] = res.data.data.Gy_Source[i].生产资源
|
}
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: '接口请求失败',
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//选择生产资源
|
HSourceNameChange(e) {
|
for (var i = 0; i < this.HSourceNameList.length; i++) {
|
if (this.HSourceNameList[i].生产资源 == e) {
|
this.hform.HSourceID = this.HSourceNameList[i].HItemID
|
}
|
}
|
},
|
//班组
|
async getHGroupList() {
|
try {
|
let res = await CommonUtils.doRequest2Async({
|
url: '/Gy_Group/list',
|
data: {
|
sWhere: '',
|
user: getUserInfo()['Czymc'] || '',
|
},
|
})
|
|
console.log('res: ', res);
|
if (res.data.count > 0) {
|
console.log('res.data.data: ', res.data.data);
|
this.HGroupNameList = res.data.data
|
this.arrayHGroupName = res.data.data.map(item => item.班组名称)
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
} catch (err) {
|
uni.showToast({
|
title: err,
|
icon: 'none'
|
})
|
}
|
|
},
|
//选择班组
|
HGroupNameChange(e) {
|
for (var i = 0; i < this.HGroupNameList.length; i++) {
|
if (this.HGroupNameList[i].班组名称 == e) {
|
this.hform.HGroupID = this.HGroupNameList[i].HItemID
|
}
|
}
|
},
|
//班次
|
async getHShiftsList() {
|
try {
|
let res = await CommonUtils.doRequest2Async({
|
url: '/Gy_ShiftsController/Get_Gy_WorkShiftList',
|
data: {
|
sWhere: '',
|
HMaker: getUserInfo()['Czymc'] || '',
|
},
|
})
|
|
console.log('res: ', res);
|
if (res.data.count > 0) {
|
console.log('res.data.data: ', res.data.data);
|
this.HShiftsNameList = res.data.data
|
this.arrayHShiftsName = res.data.data.map(item => item.班次名称)
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
} catch (err) {
|
uni.showToast({
|
title: err,
|
icon: 'none'
|
})
|
}
|
|
},
|
//选择班次
|
HShiftsNameChange(e) {
|
for (var i = 0; i < this.HSourceNameList.length; i++) {
|
if (this.HSourceNameList[i].班次名称 == e) {
|
this.hform.HSourceID = this.HSourceNameList[i].HInterID
|
}
|
}
|
},
|
//工序
|
async getHProcList() {
|
try {
|
let res = await CommonUtils.doRequest2Async({
|
url: '/Gy_Process/list',
|
data: {
|
sWhere: '',
|
user: getUserInfo()['Czymc'] || '',
|
},
|
})
|
|
console.log('工序res: ', res);
|
if (res.data.count > 0) {
|
console.log('工序res.data.data: ', res.data.data);
|
this.HProcNameList = res.data.data
|
this.arrayHProcName = res.data.data.map(item => item.工序名称)
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
} catch (err) {
|
uni.showToast({
|
title: err,
|
icon: 'none'
|
})
|
}
|
|
},
|
//选择Proc
|
HProcNameChange(e) {
|
for (var i = 0; i < this.HProcNameList.length; i++) {
|
if (this.HProcNameList[i].工序名称 == e) {
|
this.hform.HProcID = this.HProcNameList[i].HItemID
|
}
|
}
|
},
|
// 获取用户已绑定的角色
|
async getUserBoundRoles() {
|
try {
|
// 确保角色列表已加载
|
if (!this.roleList || this.roleList.length === 0) {
|
console.log('角色列表未加载,先加载角色列表');
|
await this.getRoleList();
|
}
|
let res = await CommonUtils.doRequest2Async({
|
url: '/Xt_UserGroup/UserGroupInfoList',
|
data: {
|
sWhere: ' and userid = '+getUserInfo()['Czybm']+''
|
},
|
});
|
|
if (res.data.count > 0) {
|
|
// 提取角色ID
|
const boundRoleIds = res.data.data.map(item => item.GroupId);
|
this.userBoundRoles = boundRoleIds;
|
|
// 将角色ID转换为角色名称
|
const boundRoleNames = [];
|
for (const roleId of boundRoleIds) {
|
// 在角色列表中查找对应的角色
|
const roleItem = this.roleList.find(r => r.HGroupID == roleId);
|
if (roleItem && roleItem.角色) {
|
boundRoleNames.push(roleItem.角色);
|
}
|
}
|
|
console.log('用户绑定角色名称: ', boundRoleNames);
|
|
// 如果是新增模式,设置默认选中的角色
|
if (this.btnType == 1) {
|
this.hform.HRoles = boundRoleNames;
|
console.log('已设置默认角色: ', this.hform.HRoles);
|
}
|
|
this.$forceUpdate();
|
} else {
|
// 如果没有绑定角色,清空选择
|
if (this.btnType == 1) {
|
this.hform.HRoles = [];
|
}
|
console.log('用户未绑定任何角色');
|
}
|
} catch (err) {
|
console.error('获取用户绑定角色失败:', err);
|
uni.showToast({
|
title: err.message || '获取用户角色失败',
|
icon: 'none'
|
});
|
}
|
},
|
|
// 获取角色信息
|
async getRoleList() {
|
try {
|
let res = await CommonUtils.doRequest2Async({
|
url: '/Xt_UserGroup/list',
|
data: {
|
sWhere: '',
|
},
|
});
|
if (res.data.count > 0) {
|
console.log('角色列表res.data.data: ', res.data.data);
|
|
// 保存原始角色列表,包含角色ID
|
this.roleList = res.data.data;
|
|
// 生成下拉框选项
|
this.roleOptions = res.data.data.map(item => {
|
return {
|
value: item.角色,
|
text: item.角色
|
};
|
});
|
|
// 更新视图
|
this.$forceUpdate();
|
|
// 返回Promise以便链式调用
|
return Promise.resolve();
|
} else {
|
uni.showToast({
|
title: res.data.Message || '获取角色列表失败',
|
icon: 'none'
|
});
|
|
// 设置空数组
|
this.roleList = [];
|
this.roleOptions = [];
|
|
// 返回Promise以便链式调用
|
return Promise.reject('获取角色列表失败');
|
}
|
} catch (err) {
|
uni.showToast({
|
title: err.message || '获取角色列表异常',
|
icon: 'none'
|
});
|
|
// 设置空数组
|
this.roleList = [];
|
this.roleOptions = [];
|
|
// 返回Promise以便链式调用
|
return Promise.reject(err);
|
}
|
},
|
|
//新增
|
getNewData() {
|
uni.request({
|
url: this.serverUrl + '/Web/GetMAXNum',
|
data: {
|
HBillType: '4616'
|
},
|
success: (res) => {
|
console.log(res.data)
|
if (res.data.count == 1) {
|
this.hform.HInterID = 0
|
this.hform.HBillNo = res.data.data[0].HBillNo
|
this.hform.HMakeDate = getDateTime.dateTimeStr('y-m-d')
|
this.btnType = 1
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: '接口请求失败',
|
icon: 'none'
|
})
|
},
|
});
|
},
|
submit() {
|
this.hform.HInterID = 0
|
for (let i = 0; i < this.hform.HRoles.length; i++) {
|
this.hform.HSignRemark = this.hform.HSignRemark + this.hform.HRoles[i] + ","
|
}
|
let oMain = JSON.stringify(this.hform);
|
console.log("提交的json", oMain)
|
|
let sMainSub = oMain + ';' + getUserInfo()['OrganizationID'] + ';' + getUserInfo()['Czymc'];
|
CommonUtils.doRequest2({
|
url: "/Sc_EmployeeSignInNoteBillController/SaveBill_APP",
|
data: {
|
"msg": sMainSub
|
},
|
method: "POST",
|
resFunction: (res) => {
|
let {
|
data,
|
count,
|
Message
|
} = res.data
|
if (count == 1) {
|
uni.showModal({
|
title: '提示',
|
content: res.data.Message + ' 是否继续新增?',
|
success: (res) => {
|
if (res.confirm) {
|
console.log('用户点击确定');
|
uni.redirectTo({
|
url: '/pages/EmployeeRecords/EmployeeRecordsBill'
|
})
|
} else if (res.cancel) {
|
console.log('用户点击取消');
|
setTimeout(() => {
|
uni.navigateBack();
|
}, 50)
|
}
|
}
|
});
|
} else {
|
uni.showToast({
|
icon: 'none',
|
title: Message
|
})
|
this.EnableSubmit = true;
|
}
|
}
|
})
|
},
|
goBack() {
|
uni.showModal({
|
title: '提示',
|
content: '确认要退出当前页面吗?',
|
success: (res) => {
|
if (res.confirm) {
|
console.log('用户点击确定');
|
uni.navigateBack()
|
} else if (res.cancel) {
|
console.log('用户点击取消');
|
}
|
}
|
});
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.form {
|
width: 668rpx;
|
margin: 20rpx auto;
|
padding-bottom: 240rpx;
|
}
|
|
.tab_area {
|
width: 100%;
|
height: 50rpx;
|
}
|
|
.other {
|
margin-top: 8rpx;
|
text-align: center;
|
font-size: 28rpx;
|
padding: 4rpx 18rpx;
|
color: #1890FF;
|
}
|
|
.form-item {
|
display: flex;
|
align-items: center;
|
font-size: 30rpx;
|
padding: 6rpx 0;
|
|
.title {
|
width: 208rpx;
|
|
text {
|
color: red;
|
font-weight: bold;
|
}
|
}
|
|
.right {
|
width: 450rpx;
|
border-radius: 22rpx;
|
border: 1px solid #acacac;
|
}
|
|
.righton {
|
width: 450rpx;
|
border-radius: 22rpx;
|
border: 1px solid #e4e4e4;
|
background-color: #e4e4e4;
|
}
|
|
input {
|
width: 100%;
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
}
|
|
textarea {
|
width: 98%;
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
}
|
|
}
|
|
.bottom-btn {
|
width: 100%;
|
// height: 120rpx;
|
position: fixed;
|
bottom: 0;
|
left: 0;
|
background-color: #fff;
|
box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
|
padding: 30rpx 40rpx 40rpx 40rpx;
|
|
button {
|
border-radius: 50rpx;
|
width: 180rpx;
|
height: 66rpx;
|
line-height: 66rpx;
|
font-size: 28rpx;
|
}
|
|
.btn-a {
|
background-color: #3A78FF;
|
color: #fff;
|
}
|
|
.btn-b {
|
background-color: #41a863;
|
color: #fff;
|
}
|
|
.btn-c {
|
background-color: #FFA500;
|
color: #fff;
|
position: absolute;
|
right: 120rpx;
|
}
|
|
.btn-d {
|
background-color: #ff8901;
|
color: #fff;
|
}
|
}
|
|
.tabs {
|
width: 100%;
|
display: flex;
|
border-bottom: 1px solid #ddd;
|
margin: 20rpx 0;
|
|
view {
|
width: 25%;
|
font-size: 30rpx;
|
color: #555;
|
text-align: center;
|
padding: 16rpx 0;
|
}
|
|
.on {
|
color: #3a78ff;
|
font-weight: bold;
|
border-bottom: 3px solid #3a78ff;
|
}
|
}
|
</style>
|