| | |
| | | </div> |
| | | </div> |
| | | <div class="bg_list_item_num" v-if="from.undesirable > 0"> |
| | | <div class="bg_list_item_num_item" @click="show = true"> |
| | | <div class="bg_list_item_num_item" @click="openBL"> |
| | | <span><b>*</b>不良项</span> |
| | | <div class="bg_list_item_num_item_sr"> |
| | | <span class="wulll" :style="{color: from.defectiveName ? '#305ED5' : ''}">{{from.defectiveName ? from.defectiveName : '设置'}}</span> |
| | |
| | | </div> |
| | | <div class="bg_plan" @click="TimeShow = true"> |
| | | <div class="bg_plan_label"> |
| | | <span><b>*</b>报工时长</span> |
| | | <span>报工时长</span> |
| | | </div> |
| | | <div class="bg_plan_label_val"> |
| | | <span :style="{color: from.durationName ? '#333' : ''}">{{from.durationName ? from.durationName : '请选择'}}</span> |
| | | <img src="@/assets/icon/ic_ar@2x.png" alt="" /> |
| | | </div> |
| | | </div> |
| | | <div class="bg_list_item" v-if="infoBox"> |
| | | <div class="bg_list_item" v-if="arrType && arrType.length > 0"> |
| | | <div class="bg_list_item_top"> |
| | | <div class="bg_list_item_top_left"> |
| | | <div class="bg_list_item_top_left_x"></div> |
| | |
| | | <div class="bg_list_item_num_item"> |
| | | <span>计件方式</span> |
| | | <div class="bg_list_item_num_item_list"> |
| | | <div class="bg_list_item_num_item_list_item active" v-if="infoBox.type == 0">计件</div> |
| | | <div class="bg_list_item_num_item_list_item active" v-if="infoBox.type == 1">计时</div> |
| | | <div :class="item.active ? 'bg_list_item_num_item_list_item active' : 'bg_list_item_num_item_list_item'" v-for="(item, index) in arrType" :key="index" @click="clickPerformanceType(index)">{{ item.name }}</div> |
| | | <!-- <div class="bg_list_item_num_item_list_item active" v-if="infoBox.type == 0">计件</div> |
| | | <div class="bg_list_item_num_item_list_item active" v-if="infoBox.type == 1">计时</div> --> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | <div class="bg_list_item_num_item"> |
| | | <span>工资单价</span> |
| | | <div class="bg_list_item_num_item_sr"> |
| | | <span class="color1">{{(infoBox.salary / 10 / 10).toFixed(2)}}元/{{infoBox.type == 0 ? '件' : '时'}}</span> |
| | | <span class="color1">{{(arrType[from.index].salary / 10 / 10).toFixed(2)}}元/{{arrType[from.index].type == 0 ? '件' : '时'}}</span> |
| | | <!-- <span class="color1">{{(infoBox.salary / 10 / 10).toFixed(2)}}元/{{infoBox.type == 0 ? '件' : '时'}}</span> --> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | <!-- 报工按钮 --> |
| | | <div class="bh_zw"></div> |
| | | <div class="bg_footer"> |
| | | <div class="bg_footer_submit1">继续报工</div> |
| | | <div class="bg_footer_submit1" @click="continueSubmit">继续报工</div> |
| | | <div class="bg_footer_submit" @click="submit">提交</div> |
| | | </div> |
| | | <!-- 选择不良项 --> |
| | |
| | | <script setup lang="ts"> |
| | | import { onMounted, ref, reactive, getCurrentInstance, computed } from 'vue' |
| | | import { useRouter } from 'vue-router' |
| | | import { getDeviceByCondition, getFindAll, queryOne, autoWorkReport, getIdPlansExt, categoryExtList } from '@/apis/PlanningAPI' |
| | | import { useStore } from 'vuex' |
| | | import { getDeviceByCondition, getFindAll, queryOne, queryList, autoWorkReport, getIdPlansExt, categoryExtList } from '@/apis/PlanningAPI' |
| | | import MaterialY from '@/components/newCom/MaterialY.vue' |
| | | import user from '@/components/newCom/user.vue' |
| | | import { Toast } from 'vant' |
| | | |
| | | const {$Bus} = getCurrentInstance().appContext.config.globalProperties |
| | | const router = useRouter() |
| | | const store = useStore() |
| | | let show = ref(false) |
| | | let show1 = ref(false) |
| | | let TimeShow = ref(false) |
| | |
| | | processPlan: null, |
| | | deviceId: '', |
| | | deviceName: '', |
| | | userId: '', |
| | | userName: '', |
| | | userId: store.state.userInfo.id, |
| | | userName: store.state.userInfo.companyUser.name, |
| | | qualified: '', // 良品数 |
| | | undesirable: '', // 不良数 |
| | | duration: '', |
| | | durationName: '', |
| | | durationName: '0小时0分钟', |
| | | time: '', |
| | | defective: [], |
| | | defectiveName: '' |
| | | defectiveName: '', |
| | | type: '', // 绩效类型 |
| | | index: 0 |
| | | }) |
| | | |
| | | // { name: '计件', active: false, id: 0 }, { name: '计时', active: false, id: 1 } |
| | | let arrType: any = ref([]) |
| | | |
| | | let infoBox: any = ref(null) // 工资绩效 |
| | | |
| | |
| | | }; |
| | | let userShow = ref(false) |
| | | let wuList = ref<Array<any>>([]) |
| | | |
| | | const openBL = () => { |
| | | cateList.value.forEach((item: any) => { |
| | | if (!item.active) { |
| | | item.num = '' |
| | | } |
| | | if (item.active && item.num <= 0) { |
| | | item.active = false |
| | | } |
| | | }) |
| | | show.value = true |
| | | } |
| | | |
| | | // 切换绩效类型 |
| | | const clickPerformanceType = (i: number) => { |
| | | from.index = i |
| | | arrType.value.forEach((item: any, index: number) => { |
| | | if (i === index) { |
| | | from.type = item.id |
| | | } |
| | | item.active = index === i |
| | | }) |
| | | } |
| | | |
| | | // 产出数量验证 |
| | | const changeNum = (type: number) => { |
| | |
| | | let arr: any = [] |
| | | let total: any = 0 |
| | | let name: any = '' |
| | | cateList.value.forEach((item: any, index: number) => { |
| | | if (item.active) { |
| | | if (item.num <= 0) { |
| | | for (let i = 0; i < cateList.value.length; i++) { |
| | | if (cateList.value[i].active) { |
| | | if (cateList.value[i].num <= 0) { |
| | | return Toast('不良数量必须大于0') |
| | | } |
| | | total = total += item.num |
| | | arr.push(item) |
| | | name += item.name + item.num + ';' |
| | | total = total += cateList.value[i].num |
| | | arr.push(cateList.value[i]) |
| | | name += cateList.value[i].name + cateList.value[i].num + ';' |
| | | } |
| | | }) |
| | | } |
| | | // cateList.value.forEach((item: any, index: number) => { |
| | | // if (item.active) { |
| | | // if (item.num <= 0) { |
| | | // return Toast('不良数量必须大于0') |
| | | // } |
| | | // total = total += item.num |
| | | // arr.push(item) |
| | | // name += item.name + item.num + ';' |
| | | // } |
| | | // }) |
| | | if (total !== from.undesirable) return Toast('不良数必须等于产出不良数') |
| | | from.defective = arr |
| | | from.defectiveName = name |
| | | show.value = false |
| | | } |
| | | |
| | | const continueSubmit = () => { |
| | | if (!from.processPlan) return Toast('计划不能为空') |
| | | if (!from.deviceId) return Toast('设备不能为空') |
| | | if (!from.userId) return Toast('生产人员不能为空') |
| | | if (hasBom.value == 1 && bomType.value == 1) { |
| | | console.log('不需要投料') |
| | | } else { |
| | | if (!wuList.value.length === 0) return Toast('投料不能为空') |
| | | } |
| | | if (!from.qualified && !from.undesirable) { |
| | | return Toast('良品数与不良数不能同时为空') |
| | | } |
| | | // if (!from.qualified) return Toast('良品数不能为空') |
| | | // 有不良数 |
| | | if (from.undesirable > 0) { |
| | | if (from.defective.length === 0) return Toast('不良项不能为空') |
| | | } |
| | | // if (!from.duration) return Toast('报工时长不能为空') |
| | | let type = '' |
| | | arrType.value.forEach((item: any) => { |
| | | if (item.active) { |
| | | type = item.id |
| | | } |
| | | }) |
| | | autoWorkReport({ |
| | | createWorkorderRecordDTO: { |
| | | type, |
| | | duration: from.duration, |
| | | qualifiedNum: from.qualified ? from.qualified : 0, |
| | | unQualifiedNum: from.undesirable ? from.undesirable : 0 |
| | | }, |
| | | plansId: from.processPlan.id, |
| | | proGroupId: deviceId.value, |
| | | proUserList: [from.userId], |
| | | recordList: wuList.value.map((item: any) => { |
| | | return { |
| | | wstockId: item.id, |
| | | num: item.num |
| | | } |
| | | }), |
| | | createUnqualifiedDTOList: from.defective.map((item: any) => { |
| | | return { |
| | | categoryId: item.id, |
| | | unQualifiedNum: item.num |
| | | } |
| | | }) |
| | | }).then(res => { |
| | | if (res.code === 200) { |
| | | Toast.success({message: '报工成功!'}) |
| | | from.processPlan = null |
| | | from.deviceId = '' |
| | | from.deviceName = '' |
| | | from.userId = '' |
| | | from.userName = '' |
| | | from.qualified = '' |
| | | from.undesirable = '' |
| | | from.duration = '' |
| | | from.durationName = '0小时0分钟' |
| | | from.time = '' |
| | | from.defective = [] |
| | | from.defectiveName = '' |
| | | wuList.value = [] |
| | | deviceId.value = '' |
| | | plansId.value = '' |
| | | ids.value = '' |
| | | total.value = '' |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const submit = () => { |
| | |
| | | if (from.undesirable > 0) { |
| | | if (from.defective.length === 0) return Toast('不良项不能为空') |
| | | } |
| | | if (!from.duration) return Toast('报工时长不能为空') |
| | | // if (!from.duration) return Toast('报工时长不能为空') |
| | | let type = '' |
| | | arrType.value.forEach((item: any) => { |
| | | if (item.active) { |
| | | type = item.id |
| | | } |
| | | }) |
| | | autoWorkReport({ |
| | | createWorkorderRecordDTO: { |
| | | type, |
| | | duration: from.duration, |
| | | qualifiedNum: from.qualified ? from.qualified : 0, |
| | | unQualifiedNum: from.undesirable ? from.undesirable : 0 |
| | |
| | | |
| | | // 预计工资 |
| | | const expectedSalary = computed(() => { |
| | | if (!infoBox.value) return 0; |
| | | // 按件计算 |
| | | if (infoBox.value.type == 0) { |
| | | if (arrType.value.length === 0) return 0; |
| | | if (arrType.value[from.index].type == 0) { |
| | | if (!from.qualified) return 0 |
| | | if (infoBox.value.unqualified == 1) { // 是否计入不良品 |
| | | if (arrType.value[from.index].unqualified == 1) { // 是否计入不良品 |
| | | let total = Number(from.qualified) + Number(from.undesirable) |
| | | return (total * (infoBox.value.salary / 10 / 10)).toFixed(2) || 0 |
| | | return (total * (arrType.value[from.index].salary / 10 / 10)).toFixed(2) |
| | | } else { |
| | | return (Number(from.qualified) * (infoBox.value.salary / 10 / 10)).toFixed(2) || 0 |
| | | return (Number(from.qualified) * (arrType.value[from.index].salary / 10 / 10)).toFixed(2) |
| | | } |
| | | } else { |
| | | if (!from.duration) return 0; |
| | | let h = (from.duration / 60 / 60).toFixed(2) |
| | | return (Number(h) * (infoBox.value.salary / 10 / 10)).toFixed(2) || 0 |
| | | return (Number(h) * (arrType.value[from.index].salary / 10 / 10)).toFixed(2) |
| | | } |
| | | // if (!infoBox.value) return 0; |
| | | // 按件计算 |
| | | // if (infoBox.value.type == 0) { |
| | | // if (!from.qualified) return 0 |
| | | // if (infoBox.value.unqualified == 1) { // 是否计入不良品 |
| | | // let total = Number(from.qualified) + Number(from.undesirable) |
| | | // return (total * (infoBox.value.salary / 10 / 10)).toFixed(2) |
| | | // } else { |
| | | // return (Number(from.qualified) * (infoBox.value.salary / 10 / 10)).toFixed(2) |
| | | // } |
| | | // } else { |
| | | // if (!from.duration) return 0; |
| | | // let h = (from.duration / 60 / 60).toFixed(2) |
| | | // return (Number(h) * (infoBox.value.salary / 10 / 10)).toFixed(2) |
| | | // } |
| | | }) |
| | | |
| | | // 达标率 |
| | | const complianceRate = computed(() => { |
| | | if (!infoBox.value) return 0; |
| | | if (arrType.value.length === 0) return 0; |
| | | if (!from.qualified && !from.undesirable) return 0; |
| | | if (!from.duration) return 0; |
| | | if (!arrType.value[from.index].num) return 0; |
| | | // 按件计算 |
| | | // if (infoBox.value.type == 0) { |
| | | if (infoBox.value.unqualified == 1) { // 是否计入不良品 |
| | | let a = ((Number(from.qualified) + Number(from.undesirable)) / (from.duration / 60 / 60)).toFixed(2) |
| | | let b = (infoBox.value.num / (infoBox.value.times / 60 / 60)).toFixed(2) |
| | | if (arrType.value[from.index].unqualified == 1) { // 是否计入不良品 |
| | | let a = ((Number(from.qualified) + Number(from.undesirable)) / (from.duration / 3600)).toFixed(2) |
| | | let b = (arrType.value[from.index].num / (arrType.value[from.index].times / 3600)).toFixed(2) |
| | | console.log(a) |
| | | console.log(b) |
| | | return ((Number(a) / Number(b)) * 100).toFixed(2) || 0 |
| | | return ((Number(a) / Number(b)) * 100).toFixed(2) |
| | | // let total = (Number(from.qualified) + Number(from.undesirable)) / ((from.duration * 60 * 60) * infoBox.value.num / ) |
| | | // return total * infoBox.value.salary; |
| | | } else { |
| | | let a = (from.qualified / (from.duration / 60 / 60)).toFixed(2) |
| | | let b = (infoBox.value.num / (infoBox.value.times / 60 / 60)).toFixed(2) |
| | | let a = (from.qualified / (from.duration / 3600)).toFixed(2) |
| | | let b = (arrType.value[from.index].num / (arrType.value[from.index].times / 3600)).toFixed(2) |
| | | console.log(a) |
| | | console.log(b) |
| | | return ((Number(a) / Number(b)) * 100).toFixed(2) || 0 |
| | | return ((Number(a) / Number(b)) * 100).toFixed(2) |
| | | // return Number(from.qualified) * infoBox.value.salary; |
| | | } |
| | | |
| | | // if (!infoBox.value) return 0; |
| | | // if (!from.qualified && !from.undesirable) return 0; |
| | | // if (!from.duration) return 0; |
| | | // if (!infoBox.value.num) return 0; |
| | | // // 按件计算 |
| | | // // if (infoBox.value.type == 0) { |
| | | // if (infoBox.value.unqualified == 1) { // 是否计入不良品 |
| | | // let a = ((Number(from.qualified) + Number(from.undesirable)) / (from.duration / 3600)).toFixed(2) |
| | | // let b = (infoBox.value.num / (infoBox.value.times / 3600)).toFixed(2) |
| | | // console.log(a) |
| | | // console.log(b) |
| | | // return ((Number(a) / Number(b)) * 100).toFixed(2) |
| | | // // let total = (Number(from.qualified) + Number(from.undesirable)) / ((from.duration * 60 * 60) * infoBox.value.num / ) |
| | | // // return total * infoBox.value.salary; |
| | | // } else { |
| | | // let a = (from.qualified / (from.duration / 3600)).toFixed(2) |
| | | // let b = (infoBox.value.num / (infoBox.value.times / 3600)).toFixed(2) |
| | | // console.log(a) |
| | | // console.log(b) |
| | | // return ((Number(a) / Number(b)) * 100).toFixed(2) |
| | | // // return Number(from.qualified) * infoBox.value.salary; |
| | | // } |
| | | // } else { |
| | | // console.log('按时长') |
| | | // } |
| | |
| | | from.deviceId = '' |
| | | from.deviceName = '' |
| | | deviceId.value = '' |
| | | from.userId = '' |
| | | from.userName = '' |
| | | // from.userId = '' |
| | | // from.userName = '' |
| | | total.value = res.num - res.workorderDistributNum |
| | | // 获取设备 |
| | | getDeviceByCondition({ procedureId: res.procedureId }) |
| | |
| | | } |
| | | }) |
| | | // 获取工资绩效数据 |
| | | queryOne({ |
| | | queryList({ |
| | | deleted: 0, |
| | | departId: res.factoryId, |
| | | materialId: res.materialId, |
| | | procedureId: res.procedureId |
| | | }).then(result => { |
| | | if (result.code === 200) { |
| | | infoBox.value = result.data |
| | | if (result.data && result.data.length > 0) { |
| | | result.data.forEach((item: any, index: number) => { |
| | | item.name = item.type == 0 ? '计件' : '计时' |
| | | item.id = item.type |
| | | item.active = index == 0 |
| | | }) |
| | | arrType.value = result.data |
| | | } else { |
| | | arrType.value = [] |
| | | } |
| | | // infoBox.value = result.data |
| | | } |
| | | }) |
| | | }) |